ttp-agent-sdk 2.28.3 â 2.28.4
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/agent-widget.esm.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see agent-widget.esm.js.LICENSE.txt */
|
|
2
|
-
import{useEffect as e,useRef as t,useState as n}from"react";var o={698:(e,t)=>{var n=Symbol.for("react.transitional.element");function o(e,t,o){var i=null;if(void 0!==o&&(i=""+o),void 0!==t.key&&(i=""+t.key),"key"in t)for(var r in o={},t)"key"!==r&&(o[r]=t[r]);else o=t;return t=o.ref,{$$typeof:n,type:e,key:i,ref:void 0!==t?t:null,props:o}}Symbol.for("react.fragment"),t.jsx=o,t.jsxs=o},848:(e,t,n)=>{e.exports=n(698)}},i={};function r(e){var t=i[e];if(void 0!==t)return t.exports;var n=i[e]={exports:{}};return o[e](n,n.exports,r),n.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};r.r(a),r.d(a,{checkPermissionState:()=>xe,getDeviceInfo:()=>ye,getPermissionInstructions:()=>we,openSettings:()=>Se});var s={};r.r(s),r.d(s,{showBlockedModal:()=>Pe,showNoMicrophoneModal:()=>Ee,showPrePromptModal:()=>ke});const c=class{constructor(){this.events={}}on(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),this}off(e,t){return this.events[e]?(this.events[e]=this.events[e].filter(e=>e!==t),this):this}emit(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return!!this.events[e]&&(this.events[e].forEach(e=>{e(...n)}),!0)}once(e,t){var n=this,o=function(){t(...arguments),n.off(e,o)};return this.on(e,o)}removeAllListeners(e){return e?delete this.events[e]:this.events={},this}},l=class{constructor(){this.name="PCM"}decode(e){if(e instanceof ArrayBuffer)return e;if(e instanceof Uint8Array)return e.buffer;throw new Error("Invalid PCM data type")}encode(e){return e}},d=class{constructor(){this.name="PCMU"}decode(e){for(var t=e instanceof Uint8Array?e:new Uint8Array(e),n=new Int16Array(t.length),o=0;o<t.length;o++)n[o]=this.mulawToLinear(t[o]);return n.buffer}encode(e){for(var t=e instanceof Int16Array?e:new Int16Array(e),n=new Uint8Array(t.length),o=0;o<t.length;o++)n[o]=this.linearToMulaw(t[o]);return n}mulawToLinear(e){var t=1<<3+(e>>4&7);return(128&e?-1:1)*(132+(15&e)*t+(t>>1)-4)}linearToMulaw(e){var t=e>>8&128;t&&(e=-e),e>32635&&(e=32635),e+=132;for(var n=7,o=16384;0===(e&o)&&n>0;n--,o>>=1);return 255&~(t|n<<4|e>>n+3&15)}},u=class{constructor(){this.name="PCMA"}decode(e){for(var t=e instanceof Uint8Array?e:new Uint8Array(e),n=new Int16Array(t.length),o=0;o<t.length;o++)n[o]=this.alawToLinear(t[o]);return n.buffer}encode(e){for(var t=e instanceof Int16Array?e:new Int16Array(e),n=new Uint8Array(t.length),o=0;o<t.length;o++)n[o]=this.linearToAlaw(t[o]);return n}alawToLinear(e){var t=(e^=85)>>4&7,n=15&e;return(128&e?-1:1)*(0===t?8+(n<<4):264+(n<<4)<<t-1)}linearToAlaw(e){var t,n,o=e>>8&128;if(o&&(e=-e),e>32635&&(e=32635),e<256)t=0,n=e>>4;else{t=7;for(var i=16384;0===(e&i)&&t>0;t--,i>>=1);n=e>>t+3&15}return 85^(o|t<<4|n)}};function h(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}function p(e){return function(){var t=this,n=arguments;return new Promise(function(o,i){var r=e.apply(t,n);function a(e){h(r,o,i,a,s,"next",e)}function s(e){h(r,o,i,a,s,"throw",e)}a(void 0)})}}const g=class extends c{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.config=e,this.audioContext=null,this.audioQueue=[],this.isPlaying=!1,this.isProcessingQueue=!1,this.currentSource=null,this.outputFormat=null,this.nextStartTime=0,this.scheduledBuffers=0,this.scheduledSources=new Set,this.pcmChunkQueue=[],this.preparedBuffer=[],this.isProcessingPcmQueue=!1,this.isSchedulingFrames=!1,this.MAX_LOOKAHEAD_SECONDS=.02,this.pendingSentenceText=null,this.sentenceTimings=[],this.isCheckingTranscripts=!1,this.codecs={pcm:new l,pcmu:new d,pcma:new u},this.SUPPORTED_CONTAINERS=["wav","raw"],this.SUPPORTED_ENCODINGS=["pcm","pcmu","pcma"],this.SUPPORTED_SAMPLE_RATES=[8e3,16e3,22050,24e3,44100,48e3],this.SUPPORTED_BIT_DEPTHS=[8,16,24],this.SUPPORTED_CHANNELS=[1],console.log("đĩ AudioPlayer v2 initialized")}setOutputFormat(e){var t;this.validateFormat(e)||(console.warn("â ī¸ AudioPlayer: Invalid format, using defaults:",e),e=this.getDefaultFormat());var n=null===(t=this.outputFormat)||void 0===t?void 0:t.sampleRate,o=e.sampleRate;this.outputFormat=e,console.log("â
AudioPlayer v2: Format set:",e),this.audioContext&&n&&n!==o&&(console.warn("â ī¸ AudioPlayer: Sample rate changed, recreating AudioContext"),console.warn(" Old: ".concat(n,"Hz â New: ").concat(o,"Hz")),this.stopImmediate(),"closed"!==this.audioContext.state&&this.audioContext.close(),this.audioContext=null,console.log("âšī¸ AudioContext will be recreated on next audio chunk with correct sample rate")),this.audioContext||(this.initializeAudioContext(),this.audioContext&&"suspended"===this.audioContext.state&&this.audioContext.resume().then(()=>{console.log("â
AudioPlayer v2: AudioContext resumed and ready")}).catch(e=>{console.warn("â ī¸ AudioPlayer v2: Could not resume AudioContext:",e)}))}validateFormat(e){var t,n;if(!e)return!1;var o=null===(t=e.container)||void 0===t?void 0:t.toLowerCase(),i=null===(n=e.encoding)||void 0===n?void 0:n.toLowerCase();return o&&i&&this.SUPPORTED_CONTAINERS.includes(o)&&this.SUPPORTED_ENCODINGS.includes(i)&&this.SUPPORTED_SAMPLE_RATES.includes(e.sampleRate)&&this.SUPPORTED_BIT_DEPTHS.includes(e.bitDepth)&&(!e.channels||this.SUPPORTED_CHANNELS.includes(e.channels))}getDefaultFormat(){return{container:"raw",encoding:"pcm",sampleRate:16e3,channels:1,bitDepth:16}}playAudio(e){try{var t=this.createAudioBlob(e);this.audioQueue.push(t),this.isPlaying||this.isProcessingQueue||this.currentSource||setTimeout(()=>this.processQueue(),50)}catch(e){console.error("â AudioPlayer v2: Playback error:",e),this.emit("playbackError",e)}}playChunk(e){var t=this;return p(function*(){var n,o=t.prepareChunk(e);o?(t.preparedBuffer.push(o),t.isSchedulingFrames?setTimeout(()=>{t.preparedBuffer.length>0&&!t.isSchedulingFrames&&t.schedulePreparedFrames()},5):t.schedulePreparedFrames(),t.pcmChunkQueue.length>0&&!t.isProcessingPcmQueue&&t.processPcmQueue()):(console.error("â AudioPlayer: playChunk failed - prepareChunk returned null"),console.error(" pcmData length:",(null==e?void 0:e.byteLength)||"undefined"),console.error(" outputFormat:",t.outputFormat),console.error(" audioContext:",t.audioContext?"initialized":"not initialized"),console.error(" audioContext state:",(null===(n=t.audioContext)||void 0===n?void 0:n.state)||"N/A"),t.emit("playbackError",new Error("Failed to prepare PCM chunk for playback")))})()}prepareChunk(e){try{var t;if(!this.outputFormat)return console.error("â AudioPlayer: Cannot prepare chunk - outputFormat not set"),console.error(" Call setOutputFormat() before playing audio chunks"),null;if(this.audioContext||this.initializeAudioContext(),!this.audioContext)return console.error("â AudioPlayer: Cannot prepare chunk - AudioContext not available"),null;var n=e;if(e.byteLength%2!=0){console.warn("â ī¸ Odd PCM chunk size, padding:",e.byteLength);var o=new Uint8Array(e.byteLength+1);o.set(new Uint8Array(e),0),o[e.byteLength]=0,n=o.buffer}for(var i=new Int16Array(n),r=new Float32Array(i.length),a=1/32768,s=i.length,c=0;c<s;c++)r[c]=i[c]*a;var l=(null===(t=this.outputFormat)||void 0===t?void 0:t.sampleRate)||this.audioContext.sampleRate,d=this.audioContext.sampleRate,u=this.audioContext.createBuffer(1,r.length,l);u.getChannelData(0).set(r);var h=u.duration,p=r.length,g=h;return d!==l&&(g=p/d),{buffer:u,duration:g,sampleRate:l,contextSampleRate:d}}catch(e){return console.error("â AudioPlayer: Error preparing chunk:",e),null}}applyFadeOut(e){return e}schedulePreparedFrames(){var e=this;return p(function*(){if(!e.isSchedulingFrames){e.isSchedulingFrames=!0;var t=e.preparedBuffer.length,n=Math.min(t,5);0===n&&t>0&&(n=1);try{e.audioContext||e.initializeAudioContext();var o=0===e.scheduledBuffers&&!e.isPlaying;"suspended"===e.audioContext.state&&(yield e.audioContext.resume(),o&&(yield new Promise(e=>setTimeout(e,50)))),"running"!==e.audioContext.state&&(console.warn("AudioPlayer v2: AudioContext not in running state:",e.audioContext.state),"suspended"===e.audioContext.state&&(yield e.audioContext.resume(),o?yield new Promise(e=>setTimeout(e,50)):yield new Promise(e=>setTimeout(e,10))));for(var i=0,r=function*(){var t=e.preparedBuffer.shift();if(!t)return 1;var n=e.audioContext.createBufferSource();n.buffer=t.buffer,n.connect(e.audioContext.destination),e.scheduledSources.add(n);var o=e.audioContext.currentTime;if(0===e.scheduledBuffers)e.nextStartTime<o&&(e.nextStartTime=o+e.MAX_LOOKAHEAD_SECONDS),console.log("đĩ Starting playback with minimal delay:",e.nextStartTime);else{var r=o+e.MAX_LOOKAHEAD_SECONDS;e.nextStartTime<r&&(e.nextStartTime=r,console.warn("â ī¸ AudioPlayer: Fell behind schedule, adjusting nextStartTime to ".concat(e.nextStartTime.toFixed(4),"s")))}e.pendingSentenceText&&(e.sentenceTimings.push({startTime:e.nextStartTime,text:e.pendingSentenceText,displayed:!1}),console.log("đ AudioPlayer: Sentence scheduled at ".concat(e.nextStartTime.toFixed(3),'s: "').concat(e.pendingSentenceText.substring(0,40),'..."')),e.pendingSentenceText=null,e.isCheckingTranscripts||e.startTranscriptChecker()),n.start(e.nextStartTime),e.nextStartTime+=t.duration,e.nextStartTime=Math.round(1e6*e.nextStartTime)/1e6;var a=e.nextStartTime-t.duration;e.scheduledBuffers<5&&(console.log("đĩ AudioPlayer: Scheduled frame ".concat(e.scheduledBuffers+1," at ").concat(a.toFixed(4),"s, next at ").concat(e.nextStartTime.toFixed(4),"s")),console.log(" Duration: ".concat(t.duration.toFixed(4),"s (").concat((1e3*t.duration).toFixed(2),"ms), Queued: ").concat(e.preparedBuffer.length,", Scheduled: ").concat(e.scheduledBuffers))),e.scheduledBuffers++,i++,n.onended=()=>{if(e.scheduledSources.delete(n),e.scheduledBuffers--,0===e.scheduledBuffers&&0===e.preparedBuffer.length&&0===e.pcmChunkQueue.length)e.isPlaying=!1,e.isSchedulingFrames=!1,console.log("đ AudioPlayer: Emitting playbackStopped event (all buffers finished)"),e.emit("playbackStopped");else if(e.preparedBuffer.length>0)setTimeout(()=>{e.preparedBuffer.length>0&&!e.isSchedulingFrames&&e.schedulePreparedFrames()},0);else if(e.scheduledBuffers>0){var t=()=>{e.preparedBuffer.length>0&&!e.isSchedulingFrames&&e.scheduledBuffers>0?e.schedulePreparedFrames():e.scheduledBuffers>0&&setTimeout(t,10)};setTimeout(t,10)}},e.isPlaying||(e.isPlaying=!0,console.log("đĩ AudioPlayer: Emitting playbackStarted event"),e.emit("playbackStarted"))};e.preparedBuffer.length>0&&i<n&&!(yield*r()););e.isSchedulingFrames=!1,e.preparedBuffer.length>0&&requestAnimationFrame(()=>{e.preparedBuffer.length>0&&!e.isSchedulingFrames&&e.schedulePreparedFrames()}),e.scheduledBuffers>0&&setTimeout(()=>{e.preparedBuffer.length>0&&!e.isSchedulingFrames&&e.scheduledBuffers>0?e.schedulePreparedFrames():e.scheduledBuffers>0&&setTimeout(()=>{e.preparedBuffer.length>0&&!e.isSchedulingFrames&&e.scheduledBuffers>0&&e.schedulePreparedFrames()},10)},10)}catch(t){console.error("â AudioPlayer v2: Error scheduling frames:",t),e.emit("playbackError",t),e.isSchedulingFrames=!1}}})()}processPcmQueue(){var e=this;return p(function*(){if(!e.isProcessingPcmQueue){e.isProcessingPcmQueue=!0;try{e.audioContext||e.initializeAudioContext();var t=0===e.scheduledBuffers&&!e.isPlaying;for("suspended"===e.audioContext.state&&(yield e.audioContext.resume(),t&&(yield new Promise(e=>setTimeout(e,50)))),"running"!==e.audioContext.state&&(console.warn("AudioPlayer v2: AudioContext not in running state:",e.audioContext.state),"suspended"===e.audioContext.state&&(yield e.audioContext.resume(),t?yield new Promise(e=>setTimeout(e,50)):yield new Promise(e=>setTimeout(e,10))));e.pcmChunkQueue.length>0;){var n,o,i=e.pcmChunkQueue.shift();if(i){var r=i;if(i.byteLength%2!=0){console.warn("â ī¸ Odd PCM chunk size, padding:",i.byteLength);var a=new Uint8Array(i.byteLength+1);a.set(new Uint8Array(i),0),a[i.byteLength]=0,r=a.buffer}for(var s=new Int16Array(r),c=new Float32Array(s.length),l=1/32768,d=s.length,u=0;u<d;u++)c[u]=s[u]*l;var h=(null===(n=e.outputFormat)||void 0===n?void 0:n.sampleRate)||e.audioContext.sampleRate,p=e.audioContext.sampleRate;null!==(o=e.outputFormat)&&void 0!==o&&o.sampleRate?e.scheduledBuffers<3&&console.log("đĩ AudioPlayer: Creating buffer at ".concat(h,"Hz (AudioContext: ").concat(p,"Hz)")):console.warn("â ī¸ AudioPlayer: outputFormat.sampleRate not set! Using AudioContext sample rate:",p);var g=e.audioContext.createBuffer(1,c.length,h);g.getChannelData(0).set(c);var m=e.audioContext.createBufferSource();m.buffer=g,m.connect(e.audioContext.destination);var v=e.audioContext.currentTime;e.nextStartTime<v&&(e.nextStartTime=v,0===e.scheduledBuffers&&console.log("đĩ Starting playback at current time:",v));var f=g.duration,y=c.length,x=f;if(p!==h&&(x=y/p,e.scheduledBuffers<3&&(console.log("đ Resampling detected: ".concat(h,"Hz â ").concat(p,"Hz")),console.log(" Buffer duration: ".concat(f.toFixed(4),"s, Calculated: ").concat(x.toFixed(4),"s")))),m.start(e.nextStartTime),e.nextStartTime+=x,e.nextStartTime=Math.round(1e6*e.nextStartTime)/1e6,e.scheduledBuffers<3){var b=e.nextStartTime-x;console.log("đĩ AudioPlayer: Scheduled chunk ".concat(e.scheduledBuffers+1," at ").concat(b.toFixed(4),"s, next at ").concat(e.nextStartTime.toFixed(4),"s")),console.log(" Duration: ".concat(x.toFixed(4),"s (").concat((1e3*x).toFixed(2),"ms)"))}e.scheduledBuffers++,m.onended=()=>{e.scheduledBuffers--,0===e.scheduledBuffers&&0===e.pcmChunkQueue.length&&(e.isPlaying=!1,e.isProcessingPcmQueue=!1,e.emit("playbackStopped"))},e.isPlaying||(e.isPlaying=!0,e.emit("playbackStarted"))}}e.isProcessingPcmQueue=!1}catch(t){console.error("â AudioPlayer v2: Error playing chunk:",t),e.emit("playbackError",t),e.isProcessingPcmQueue=!1}}})()}createAudioBlob(e){var t=new Uint8Array(e);console.log("đĩ AudioPlayer: Processing ".concat(t.length," bytes")),console.log("đĩ AudioPlayer: Negotiated format:",this.outputFormat);var n=this.outputFormat&&this.outputFormat.container&&"wav"===this.outputFormat.container.toLowerCase(),o=this.outputFormat&&this.outputFormat.container&&"raw"===this.outputFormat.container.toLowerCase(),i=this.isWavFile(t);if(i&&console.log("đĩ AudioPlayer: Data has WAV header (RIFF)"),o&&i)return console.error("â AudioPlayer: CRITICAL MISMATCH!"),console.error(" Negotiated format: RAW"),console.error(" Actual data: WAV (RIFF header detected)"),console.error(" Backend is ignoring format request and sending WAV anyway."),console.warn("â ī¸ AudioPlayer: Processing as WAV to avoid playback failure, but UI configuration was bypassed."),this.handleWavFile(t);if(o&&!i)console.log("đĩ AudioPlayer: Processing as RAW data (as negotiated)");else{if(n&&i)return console.log("â
AudioPlayer: Processing as WAV file (matches negotiation)"),this.handleWavFile(t);if(n&&!i)return console.warn("â ī¸ AudioPlayer: Negotiated WAV but data lacks WAV header. Attempting WAV processing anyway."),this.handleWavFile(t);if(!this.outputFormat&&i)return console.log("đĩ AudioPlayer: No format negotiated, auto-detecting WAV"),this.handleWavFile(t);this.outputFormat||i||(console.warn("â ī¸ AudioPlayer: No format negotiated and data not WAV, using defaults"),this.outputFormat=this.getDefaultFormat())}return this.outputFormat||(console.warn("â ī¸ AudioPlayer: No format set, using defaults"),this.outputFormat=this.getDefaultFormat()),console.log("đĩ AudioPlayer: Processing as RAW data with encoding:",this.outputFormat.encoding),this.handleRawData(t)}isWavFile(e){return e.length>=44&&82===e[0]&&73===e[1]&&70===e[2]&&70===e[3]}handleWavFile(e){var t=this.parseWavHeader(e);if(console.log("đĩ WAV file detected:",{format:t.audioFormat,encoding:this.getEncodingName(t.audioFormat),sampleRate:t.sampleRate,channels:t.channels,bitDepth:t.bitsPerSample}),1===t.audioFormat)return console.log("â
PCM WAV - using directly"),new Blob([e],{type:"audio/wav"});var n=this.getCodecForWavFormat(t.audioFormat);if(!n)throw new Error("Unsupported WAV format code: ".concat(t.audioFormat));console.log("đ Non-PCM WAV - converting to PCM WAV");var o=e.slice(44),i=n.decode(o),r=this.createWavHeader(i.byteLength,t.sampleRate,t.channels,16);return new Blob([r,i],{type:"audio/wav"})}handleRawData(e){var t,n,o=this.outputFormat.encoding.toLowerCase(),i=this.getCodec(o);if(!i)throw new Error("No codec found for encoding: ".concat(o));if(console.log("đĩ AudioPlayer: Decoding ".concat(o.toUpperCase()," to PCM")),console.log("đĩ AudioPlayer: Input format - bitDepth: ".concat(this.outputFormat.bitDepth,", sampleRate: ").concat(this.outputFormat.sampleRate)),"pcm"===o){var r=this.outputFormat.bitDepth||16;e.length,24===r?(console.warn("â ī¸ AudioPlayer: Format says 24-bit PCM, but browser support is limited."),console.warn(" Treating as 16-bit PCM. If audio sounds wrong, backend should send 16-bit instead."),t=this.convert24BitTo16Bit(e),n=16):8===r?(console.log("đ AudioPlayer: Converting 8-bit PCM to 16-bit PCM"),t=this.convert8BitTo16Bit(e),n=16):(t=e.buffer,n=r,console.log("â
AudioPlayer: Using native ".concat(r,"-bit PCM (no conversion needed)")))}else t=i.decode(e),n=16,console.log("đ AudioPlayer: Decoded ".concat(o.toUpperCase()," to 16-bit PCM"));var a=this.createWavHeader(t.byteLength,this.outputFormat.sampleRate,this.outputFormat.channels,n);return new Blob([a,t],{type:"audio/wav"})}convert24BitTo16Bit(e){for(var t=Math.floor(e.length/3),n=new Int16Array(t),o=0;o<t;o++){var i=e[3*o],r=e[3*o+1],a=e[3*o+2],s=i|r<<8|(255&a)<<16;128&a&&(s|=4278190080),n[o]=Math.max(-32768,Math.min(32767,Math.round(s/256)))}return n.buffer}convert8BitTo16Bit(e){for(var t=e.length,n=new Int16Array(t),o=0;o<t;o++){var i=e[o];n[o]=256*(i-128)}return n.buffer}getCodec(e){var t={pcm:"pcm",linear:"pcm",l16:"pcm",pcmu:"pcmu",ulaw:"pcmu",mulaw:"pcmu",g711u:"pcmu",pcma:"pcma",alaw:"pcma",g711a:"pcma"}[e.toLowerCase()];return this.codecs[t]}getCodecForWavFormat(e){switch(e){case 1:return this.codecs.pcm;case 6:return this.codecs.pcma;case 7:return this.codecs.pcmu;default:return null}}getEncodingName(e){switch(e){case 1:return"PCM";case 6:return"A-law";case 7:return"Îŧ-law";default:return"Unknown (".concat(e,")")}}parseWavHeader(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);return{audioFormat:t.getUint16(20,!0),channels:t.getUint16(22,!0),sampleRate:t.getUint32(24,!0),byteRate:t.getUint32(28,!0),blockAlign:t.getUint16(32,!0),bitsPerSample:t.getUint16(34,!0)}}createWavHeader(e,t,n,o){var i=new ArrayBuffer(44),r=new DataView(i);return r.setUint32(0,1380533830,!1),r.setUint32(4,36+e,!0),r.setUint32(8,1463899717,!1),r.setUint32(12,1718449184,!1),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,n,!0),r.setUint32(24,t,!0),r.setUint32(28,t*n*o/8,!0),r.setUint16(32,n*o/8,!0),r.setUint16(34,o,!0),r.setUint32(36,1684108385,!1),r.setUint32(40,e,!0),i}initializeAudioContext(){var e,t,n=(null===(e=this.outputFormat)||void 0===e?void 0:e.sampleRate)||44100;if(48e3!==n&&44100!==n&&(console.log("âšī¸ AudioPlayer: Backend requested ".concat(n,"Hz, but browser may resample")),console.log(" Consider requesting 44100Hz or 48000Hz from backend to avoid resampling and improve quality")),this.audioContext){var o=this.audioContext.sampleRate;if(!(Math.abs(o-n)>100))return;console.warn("â ī¸ AudioPlayer: AudioContext sample rate (".concat(o,"Hz) doesn't match format (").concat(n,"Hz), recreating...")),this.stopImmediate(),"closed"!==this.audioContext.state&&this.audioContext.close(),this.audioContext=null}console.log("đĩ AudioPlayer: Creating AudioContext at ".concat(n,"Hz (from outputFormat: ").concat((null===(t=this.outputFormat)||void 0===t?void 0:t.sampleRate)||"not set",")"));try{this.audioContext=new(window.AudioContext||window.webkitAudioContext)({sampleRate:n,latencyHint:"playback"}),console.log("â
AudioContext created at ".concat(this.audioContext.sampleRate,"Hz (requested: ").concat(n,"Hz)")),Math.abs(this.audioContext.sampleRate-n)>100?(console.error("â CRITICAL: Browser sample rate mismatch!"),console.error(" Requested: ".concat(n,"Hz")),console.error(" Got: ".concat(this.audioContext.sampleRate,"Hz")),console.error(" This WILL cause audio distortion/noise!"),console.error(" Solution: Backend should send ".concat(this.audioContext.sampleRate,"Hz audio instead"))):this.audioContext.sampleRate!==n&&(console.warn("â ī¸ Browser adjusted sample rate: ".concat(n,"Hz â ").concat(this.audioContext.sampleRate,"Hz")),console.warn(" Browser will automatically resample audio."))}catch(e){console.error("â Failed to create AudioContext:",e),this.audioContext=new(window.AudioContext||window.webkitAudioContext),console.log("âšī¸ Using browser default: ".concat(this.audioContext.sampleRate,"Hz"))}}processQueue(){var e=this;return p(function*(){if(!e.isProcessingQueue&&0!==e.audioQueue.length){e.isProcessingQueue=!0;var t=e.audioQueue.shift();if(t)try{var n=!e.isPlaying&&null===e.currentSource;e.audioContext||e.initializeAudioContext();var o=e.audioContext;"suspended"===o.state&&(yield o.resume(),n&&(yield new Promise(e=>setTimeout(e,50)))),"running"!==o.state&&(console.warn("AudioPlayer v2: AudioContext not in running state:",o.state),"suspended"===o.state&&(yield o.resume(),n?yield new Promise(e=>setTimeout(e,50)):yield new Promise(e=>setTimeout(e,10))));var i=yield t.arrayBuffer(),r=yield o.decodeAudioData(i),a=n&&!e.isPlaying&&null===e.currentSource,s=o.createBufferSource();s.buffer=r,s.connect(o.destination),e.currentSource=s,e.isPlaying=!0,a&&e.emit("playbackStarted"),s.onended=()=>{e.currentSource=null,e.isProcessingQueue=!1,e.audioQueue.length>0?setTimeout(()=>e.processQueue(),50):setTimeout(()=>{0!==e.audioQueue.length||e.currentSource||(e.isPlaying=!1,e.emit("playbackStopped"))},100)},s.start()}catch(t){console.error("â AudioPlayer v2: Error processing queue:",t),e.currentSource=null,e.emit("playbackError",t),e.audioQueue.length>0?(e.isProcessingQueue=!1,setTimeout(()=>e.processQueue(),100)):(e.isPlaying=!1,e.isProcessingQueue=!1,e.emit("playbackStopped"))}else e.isProcessingQueue=!1}})()}stop(){this.stopImmediate()}reset(){this.stop(),this.audioQueue=[],this.pcmChunkQueue=[]}stopImmediate(){var e=this.isPlaying||null!==this.currentSource||this.scheduledSources.size>0;if(console.log("đ AudioPlayer.stopImmediate() called"),console.log(" isPlaying:",this.isPlaying),console.log(" currentSource:",null!==this.currentSource),console.log(" scheduledSources.size:",this.scheduledSources.size),console.log(" scheduledBuffers:",this.scheduledBuffers),this.currentSource){try{console.log(" Stopping currentSource..."),this.currentSource.stop()}catch(e){console.log(" currentSource already stopped or error:",e.message)}this.currentSource=null}if(this.scheduledSources.size>0){console.log(" Stopping ".concat(this.scheduledSources.size," scheduled sources..."));var t=0;for(var n of this.scheduledSources)try{n.stop(),t++}catch(e){console.log(" Source already stopped or not started:",e.message)}console.log(" Stopped ".concat(t," sources")),this.scheduledSources.clear()}this.isPlaying=!1,this.isProcessingQueue=!1,this.audioQueue=[],this.pcmChunkQueue=[],this.preparedBuffer=[],this.isProcessingPcmQueue=!1,this.isSchedulingFrames=!1,this.nextStartTime=0,this.scheduledBuffers=0,this.clearTranscriptState(),e&&(console.log("đ AudioPlayer: Emitting playbackStopped event (stopImmediate called)"),this.emit("playbackStopped"))}markNewSentence(e){this.pendingSentenceText=e,console.log('đ AudioPlayer: New sentence marked: "'.concat(e.substring(0,40),'..."'))}startTranscriptChecker(){if(!this.isCheckingTranscripts){this.isCheckingTranscripts=!0,console.log("đ AudioPlayer: Transcript checker started");var e=()=>{if(this.isCheckingTranscripts&&this.audioContext){var t=this.audioContext.currentTime;for(var n of this.sentenceTimings)!n.displayed&&t>=n.startTime&&(n.displayed=!0,console.log("đ AudioPlayer: Display transcript at ".concat(t.toFixed(3),'s: "').concat(n.text.substring(0,40),'..."')),this.emit("transcriptDisplay",{text:n.text}));this.isPlaying||this.scheduledBuffers>0?requestAnimationFrame(e):(this.isCheckingTranscripts=!1,console.log("đ AudioPlayer: Transcript checker stopped"))}};requestAnimationFrame(e)}}clearTranscriptState(){this.pendingSentenceText=null,this.sentenceTimings=[],this.isCheckingTranscripts=!1,console.log("đ AudioPlayer: Transcript state cleared")}resumeAudioContext(){var e=this;return p(function*(){if(e.audioContext&&"closed"!==e.audioContext.state){if("suspended"===e.audioContext.state)try{yield e.audioContext.resume(),console.log("â
AudioPlayer v2: AudioContext resumed after mic permission")}catch(e){console.warn("â ī¸ AudioPlayer v2: Failed to resume AudioContext:",e)}}else yield e.initializeAudioContext()})()}getStatus(){return{isPlaying:this.isPlaying,isProcessingQueue:this.isProcessingQueue,queueLength:this.audioQueue.length,audioContextState:this.audioContext?this.audioContext.state:"closed",outputFormat:this.outputFormat,scheduledBuffers:this.scheduledBuffers,preparedBufferLength:this.preparedBuffer.length,scheduledSourcesCount:this.scheduledSources.size}}destroy(){this.stop(),this.audioContext&&"closed"!==this.audioContext.state&&(this.audioContext.close(),this.audioContext=null),this.removeAllListeners()}};function m(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}function v(e){return function(){var t=this,n=arguments;return new Promise(function(o,i){var r=e.apply(t,n);function a(e){m(r,o,i,a,s,"next",e)}function s(e){m(r,o,i,a,s,"throw",e)}a(void 0)})}}class f extends c{constructor(e){super(),this.config=e,this.audioContext=null,this.audioWorkletNode=null,this.mediaStream=null,this.isRecording=!1}getAudioProcessorPath(){if(this.config.audioProcessorPath)return this.config.audioProcessorPath;var e=document.getElementsByTagName("script");for(var t of e){var n=t.src;if(n&&(n.includes("agent-widget.js")||n.includes("ttp-agent-sdk")))try{var o=n.substring(0,n.lastIndexOf("/"));return"".concat(o,"/audio-processor.js")}catch(e){var i=n.substring(0,n.lastIndexOf("/"));return"".concat(i,"/audio-processor.js")}}return"https://cdn.talktopc.com/audio-processor.js"}start(){var e=this;return v(function*(){try{if("https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname){var t=new Error("Microphone access requires HTTPS. Please use https:// or test on localhost.");throw console.error("â AudioRecorder:",t.message),e.emit("error",t),t}if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){var n=new Error("getUserMedia is not supported in this browser. Please use a modern browser.");throw console.error("â AudioRecorder:",n.message),e.emit("error",n),n}console.log("đ¤ AudioRecorder: Requesting microphone access..."),e.mediaStream=yield navigator.mediaDevices.getUserMedia({audio:{sampleRate:e.config.sampleRate,channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),console.log("â
AudioRecorder: Microphone access granted"),e.audioContext=new(window.AudioContext||window.webkitAudioContext)({sampleRate:e.config.sampleRate}),"suspended"===e.audioContext.state&&(yield e.audioContext.resume());var o=e.getAudioProcessorPath();yield e.audioContext.audioWorklet.addModule(o),e.audioWorkletNode=new AudioWorkletNode(e.audioContext,"audio-processor"),e.audioContext.createMediaStreamSource(e.mediaStream).connect(e.audioWorkletNode),e.audioWorkletNode.port.onmessage=t=>{var{type:n,data:o}=t.data;"pcm_audio_data"===n&&e.emit("audioData",o)},e.audioWorkletNode.port.postMessage({type:"setForceContinuous",data:{enabled:!0}}),e.isRecording=!0,e.emit("recordingStarted")}catch(t){var i=t.message;"NotAllowedError"===t.name||"PermissionDeniedError"===t.name?(i="Microphone permission denied. Please allow microphone access in your browser settings and try again.",console.error("â AudioRecorder: Permission denied. User needs to grant microphone access.")):"NotFoundError"===t.name||"DevicesNotFoundError"===t.name?(i="No microphone found. Please connect a microphone and try again.",console.error("â AudioRecorder: No microphone device found.")):"NotReadableError"===t.name||"TrackStartError"===t.name?(i="Microphone is already in use by another application. Please close other apps using the microphone and try again.",console.error("â AudioRecorder: Microphone is busy or not readable.")):t.message&&t.message.includes("not allowed by the user agent")&&(i="Microphone access blocked. On mobile devices, please tap the recording button directly (not from an iframe or popup).",console.error("â AudioRecorder: User agent blocked microphone access. This often happens on mobile when not called from direct user interaction."));var r=new Error(i);throw r.name=t.name,r.originalError=t,console.error("â AudioRecorder: Failed to start recording:",r),e.emit("error",r),r}})()}stop(){var e=this;return v(function*(){if(e.isRecording)try{e.audioWorkletNode&&(e.audioWorkletNode.port.postMessage({type:"flush"}),yield new Promise(e=>setTimeout(e,100))),e.mediaStream&&(e.mediaStream.getTracks().forEach(e=>e.stop()),e.mediaStream=null),e.audioContext&&"closed"!==e.audioContext.state&&(yield e.audioContext.close(),e.audioContext=null),e.audioWorkletNode=null,e.isRecording=!1,e.emit("recordingStopped")}catch(t){throw e.emit("error",t),t}})()}getStatus(){return{isRecording:this.isRecording,audioContextState:this.audioContext?this.audioContext.state:"closed"}}destroy(){this.stop()}}class y{static extractPcmFromWav(e){var t=e instanceof Uint8Array?e:new Uint8Array(e);if(t.length<44)throw new Error("WAV data too short (< 44 bytes)");if("RIFF"!==String.fromCharCode(t[0],t[1],t[2],t[3]))throw new Error("Not a valid WAV file - missing RIFF header");if("WAVE"!==String.fromCharCode(t[8],t[9],t[10],t[11]))throw new Error("Not a valid WAV file - missing WAVE format");for(var n=t[22]|t[23]<<8,o=t[24]|t[25]<<8|t[26]<<16|t[27]<<24,i=t[34]|t[35]<<8,r=-1,a=12;a<t.length-8;a+=4){if("data"===String.fromCharCode(t[a],t[a+1],t[a+2],t[a+3])){r=a;break}a+=4+(t[a+4]|t[a+5]<<8|t[a+6]<<16|t[a+7]<<24)}if(-1===r)throw new Error("No data chunk found in WAV");var s=t[r+4]|t[r+5]<<8|t[r+6]<<16|t[r+7]<<24,c=r+8,l=Math.min(s,t.length-c);return{pcmData:t.slice(c,c+l).buffer,format:{sampleRate:o,channels:n,bitDepth:i}}}static isWavFile(e){return e.length>=44&&82===e[0]&&73===e[1]&&70===e[2]&&70===e[3]}static createWavHeader(e,t,n,o){var i=new ArrayBuffer(44),r=new DataView(i);return r.setUint32(0,1380533830,!1),r.setUint32(4,36+e,!0),r.setUint32(8,1463899717,!1),r.setUint32(12,1718449184,!1),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,n,!0),r.setUint32(24,t,!0),r.setUint32(28,t*n*o/8,!0),r.setUint16(32,n*o/8,!0),r.setUint16(34,o,!0),r.setUint32(36,1684108385,!1),r.setUint32(40,e,!0),i}static wrapPcmInWav(e,t){var n=y.createWavHeader(e.byteLength,t.sampleRate,t.channels||1,t.bitDepth||16),o=new Uint8Array(n.byteLength+e.byteLength);return o.set(new Uint8Array(n),0),o.set(new Uint8Array(e),n.byteLength),o.buffer}}const x=y,b=class{constructor(){this.codecs={pcm:new l,pcmu:new d,pcma:new u}}decodeToPcm(e,t){var n=null==t?void 0:t.toLowerCase();if(!n||"pcm"===n)return e instanceof ArrayBuffer?e:e instanceof Uint8Array?e.buffer:e;var o=this.codecs[n];if(!o)throw new Error("Unsupported encoding: ".concat(t));var i=e instanceof Uint8Array?e:new Uint8Array(e);return o.decode(i)}encodeFromPcm(e,t){var n=null==t?void 0:t.toLowerCase();if(!n||"pcm"===n)return e;var o=this.codecs[n];if(!o)throw new Error("Unsupported target encoding: ".concat(t));var i=o.encode(e);return i instanceof Uint8Array?i.buffer:i}getCodec(e){var t=null==e?void 0:e.toLowerCase();return this.codecs[t]||null}};class w{static convert(e,t,n){if(t===n)return e;if(8===t)throw new Error("Source bit depth cannot be 8-bit (only 16-bit or 24-bit supported)");var o=t/8,i=n/8,r=e.byteLength/o;if(new ArrayBuffer(r*i),16===t&&16===n)return e;if(24===t&&16===n)return w.convert24To16(e);if(16===t&&24===n)return w.convert16To24(e);if(16===t&&8===n)return w.convert16To8(e);if(24===t&&8===n)return w.convert24To8(e);throw new Error("Unsupported bit depth conversion: ".concat(t,"-bit â ").concat(n,"-bit"))}static convert24To16(e){for(var t=new Uint8Array(e),n=Math.floor(t.length/3),o=new Int16Array(n),i=0;i<n;i++){var r=t[3*i],a=t[3*i+1],s=t[3*i+2],c=r|a<<8|(255&s)<<16;128&s&&(c|=4278190080),o[i]=Math.max(-32768,Math.min(32767,Math.round(c/256)))}return o.buffer}static convert16To24(e){for(var t=new Int16Array(e),n=new Uint8Array(3*t.length),o=0;o<t.length;o++){var i=256*t[o];n[3*o]=255&i,n[3*o+1]=i>>8&255,n[3*o+2]=i>>16&255}return n.buffer}static convert16To8(e){for(var t=new Int16Array(e),n=new Uint8Array(t.length),o=0;o<t.length;o++){var i=t[o];n[o]=Math.max(0,Math.min(255,Math.round(i/256+128)))}return n.buffer}static convert24To8(e){var t=w.convert24To16(e);return w.convert16To8(t)}}const S=w;function C(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}const k=class{static resample(e,t,n){return(o=function*(){if(t===n)return e;for(var o=new Int16Array(e),i=new Float32Array(o.length),r=1/32768,a=0;a<o.length;a++)i[a]=o[a]*r;var s=Math.ceil(i.length*n/t),c=new OfflineAudioContext(1,s,n),l=c.createBuffer(1,i.length,t);l.getChannelData(0).set(i);var d=c.createBufferSource();d.buffer=l,d.connect(c.destination),d.start();for(var u=(yield c.startRendering()).getChannelData(0),h=new Int16Array(u.length),p=0;p<u.length;p++){var g=Math.max(-1,Math.min(1,u[p]));h[p]=Math.round(32767*g)}return h.buffer},function(){var e=this,t=arguments;return new Promise(function(n,i){var r=o.apply(e,t);function a(e){C(r,n,i,a,s,"next",e)}function s(e){C(r,n,i,a,s,"throw",e)}a(void 0)})})();var o}};class P{static convert(e,t,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:16;if(t===n)return e;if(1===t&&1===n)return e;if(1===t&&2===n)return P.monoToStereo(e,o);if(2===t&&1===n)return P.stereoToMono(e,o);throw new Error("Unsupported channel conversion: ".concat(t," â ").concat(n))}static monoToStereo(e,t){for(var n=t/8,o=e.byteLength/n,i=new ArrayBuffer(o*n*2),r=new Uint8Array(e),a=new Uint8Array(i),s=0;s<o;s++)for(var c=s*n,l=s*n*2,d=0;d<n;d++)a[l+d]=r[c+d],a[l+n+d]=r[c+d];return i}static stereoToMono(e,t){var n=t/8,o=e.byteLength/(2*n),i=new ArrayBuffer(o*n),r=new Uint8Array(e),a=new Uint8Array(i);if(16===t)for(var s=0;s<o;s++){var c=s*n*2,l=c+n,d=(r[c]|r[c+1]<<8)<<16>>16,u=(r[l]|r[l+1]<<8)<<16>>16,h=Math.round((d+u)/2),p=s*n;a[p]=255&h,a[p+1]=h>>8&255}else for(var g=0;g<o;g++)for(var m=g*n*2,v=g*n,f=0;f<n;f++)a[v+f]=r[m+f];return i}}const E=P;function T(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)}return n}function I(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?T(Object(n),!0).forEach(function(t){A(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function A(e,t,n){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function R(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}const D=class{constructor(e,t){this.requestedFormat=e,this.actualFormat=t,this.encodingConverter=new b,this.conversionSteps=[],this._analyzeConversions()}_analyzeConversions(){this.conversionSteps=[],this.actualFormat.container!==this.requestedFormat.container&&("wav"===this.actualFormat.container?this.conversionSteps.push("extract_wav"):"wav"===this.requestedFormat.container&&this.conversionSteps.push("wrap_wav")),this.actualFormat.encoding!==this.requestedFormat.encoding&&("pcm"!==this.actualFormat.encoding&&this.conversionSteps.push("decode_encoding"),"pcm"!==this.requestedFormat.encoding&&this.conversionSteps.push("encode_encoding")),this.actualFormat.sampleRate!==this.requestedFormat.sampleRate&&this.conversionSteps.push("resample"),this.actualFormat.bitDepth!==this.requestedFormat.bitDepth&&this.conversionSteps.push("convert_bitdepth"),this.actualFormat.channels!==this.requestedFormat.channels&&this.conversionSteps.push("convert_channels")}needsConversion(){return this.conversionSteps.length>0}getConversionSteps(){var e=[];return this.conversionSteps.includes("extract_wav")&&e.push("Extract PCM from WAV (".concat(this.actualFormat.container," â raw)")),this.conversionSteps.includes("decode_encoding")&&e.push("Decode ".concat(this.actualFormat.encoding.toUpperCase()," â PCM")),this.conversionSteps.includes("resample")&&e.push("Resample ".concat(this.actualFormat.sampleRate,"Hz â ").concat(this.requestedFormat.sampleRate,"Hz")),this.conversionSteps.includes("convert_bitdepth")&&e.push("Convert bit depth ".concat(this.actualFormat.bitDepth,"-bit â ").concat(this.requestedFormat.bitDepth,"-bit")),this.conversionSteps.includes("convert_channels")&&e.push("Convert channels ".concat(this.actualFormat.channels," â ").concat(this.requestedFormat.channels)),this.conversionSteps.includes("encode_encoding")&&e.push("Encode PCM â ".concat(this.requestedFormat.encoding.toUpperCase())),this.conversionSteps.includes("wrap_wav")&&e.push("Wrap in WAV container (raw â ".concat(this.requestedFormat.container,")")),e}convert(e){var t,n=this;return(t=function*(){if(!n.needsConversion())return e instanceof ArrayBuffer?e:e.buffer;var t=e instanceof ArrayBuffer?e:e.buffer,o=I({},n.actualFormat);if(n.conversionSteps.includes("extract_wav")){var i=x.extractPcmFromWav(t);t=i.pcmData,o=I(I({},o),{},{container:"raw",sampleRate:i.format.sampleRate,channels:i.format.channels,bitDepth:i.format.bitDepth}),console.log("đ AudioFormatConverter: Extracted PCM from WAV",i.format)}if(n.conversionSteps.includes("decode_encoding")&&(t=n.encodingConverter.decodeToPcm(t,o.encoding),o.encoding="pcm",o.bitDepth=16,console.log("đ AudioFormatConverter: Decoded ".concat(n.actualFormat.encoding.toUpperCase()," â PCM"))),24===o.bitDepth&&o.bitDepth!==n.requestedFormat.bitDepth&&(n.conversionSteps.includes("resample")||n.conversionSteps.includes("convert_channels")||24!==n.requestedFormat.bitDepth)&&(t=S.convert(t,24,16),o.bitDepth=16,console.log("đ AudioFormatConverter: Normalized 24-bit â 16-bit PCM")),n.conversionSteps.includes("resample")&&(t=yield k.resample(t,o.sampleRate,n.requestedFormat.sampleRate),o.sampleRate=n.requestedFormat.sampleRate,console.log("đ AudioFormatConverter: Resampled ".concat(n.actualFormat.sampleRate,"Hz â ").concat(n.requestedFormat.sampleRate,"Hz"))),n.conversionSteps.includes("convert_channels")&&(t=E.convert(t,o.channels,n.requestedFormat.channels,o.bitDepth),o.channels=n.requestedFormat.channels,console.log("đ AudioFormatConverter: Converted channels ".concat(n.actualFormat.channels," â ").concat(n.requestedFormat.channels))),n.conversionSteps.includes("convert_bitdepth")&&(t=S.convert(t,o.bitDepth,n.requestedFormat.bitDepth),o.bitDepth=n.requestedFormat.bitDepth,console.log("đ AudioFormatConverter: Converted bit depth ".concat(n.actualFormat.bitDepth,"-bit â ").concat(n.requestedFormat.bitDepth,"-bit"))),n.conversionSteps.includes("encode_encoding")){var r=n.encodingConverter.encodeFromPcm(t,n.requestedFormat.encoding);t=r instanceof ArrayBuffer?r:r.buffer,o.encoding=n.requestedFormat.encoding,console.log("đ AudioFormatConverter: Encoded PCM â ".concat(n.requestedFormat.encoding.toUpperCase()))}return n.conversionSteps.includes("wrap_wav")&&(t=x.wrapPcmInWav(t,o),o.container="wav",console.log("đ AudioFormatConverter: Wrapped in WAV container")),console.log("â
AudioFormatConverter: Conversion complete"),t},function(){var e=this,n=arguments;return new Promise(function(o,i){var r=t.apply(e,n);function a(e){R(r,o,i,a,s,"next",e)}function s(e){R(r,o,i,a,s,"throw",e)}a(void 0)})})()}};function F(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}const B=class{constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>null;this.handlers=new Map,this.sendMessage=e,this.getConversationId=t}registerHandler(e,t){if("function"!=typeof t)throw new Error("Handler for tool '".concat(e,"' must be a function"));this.handlers.set(e,t),console.log("đ§ ClientTools: Registered handler for '".concat(e,"'"))}unregisterHandler(e){this.handlers.delete(e),console.log("đ§ ClientTools: Unregistered handler for '".concat(e,"'"))}hasHandler(e){return this.handlers.has(e)}getRegisteredTools(){return Array.from(this.handlers.keys())}handleToolCall(e){var t,n=this;return(t=function*(){var{toolCallId:t,toolName:o,parameters:i}=e,r=Date.now(),a=(new Date).toISOString();console.log("đ§ ClientTools: [".concat(a,"] Received tool call '").concat(o,"' (id: ").concat(t,")")),console.log(" đ Full message received:",JSON.stringify(e,null,2)),console.log(" âąī¸ Start time: ".concat(r,"ms (").concat(new Date(r).toISOString(),")"));var s=n.handlers.get(o);if(!s)return console.warn("đ§ ClientTools: No handler registered for '".concat(o,"'")),void n.sendError(t,o,"No handler registered for tool '".concat(o,"'"),"NO_HANDLER",r);try{var c=yield s(i),l=Date.now()-r;console.log("đ§ ClientTools: Tool '".concat(o,"' completed in ").concat(l,"ms")),n.sendResult(t,o,c,l)}catch(e){var d,u,h=Date.now()-r;console.error("đ§ ClientTools: Tool '".concat(o,"' failed:"),e);var p="EXECUTION_ERROR";"NotAllowedError"===e.name||null!==(d=e.message)&&void 0!==d&&d.includes("permission")?p="PERMISSION_DENIED":("NotSupportedError"===e.name||null!==(u=e.message)&&void 0!==u&&u.includes("not supported"))&&(p="API_UNAVAILABLE"),n.sendError(t,o,e.message||"Unknown error",p,h)}},function(){var e=this,n=arguments;return new Promise(function(o,i){var r=t.apply(e,n);function a(e){F(r,o,i,a,s,"next",e)}function s(e){F(r,o,i,a,s,"throw",e)}a(void 0)})})()}sendResult(e,t,n,o){var i=this.getConversationId(),r=(new Date).toISOString(),a={t:"client_tool_result",toolCallId:e,toolName:t,conversationId:i,result:n,executionTimeMs:o};console.log("đ§ ClientTools: [".concat(r,"] Sending result for tool '").concat(t,"'")),console.log(" đ toolCallId: ".concat(e)),console.log(" đ conversationId: ".concat(i||"null")),console.log(" đ toolName: ".concat(t)),console.log(" đ result:",n),console.log(" đ Full message:",JSON.stringify(a,null,2)),this.sendMessage(a),console.log("â
ClientTools: Result message sent at ".concat(r))}sendError(e,t,n,o,i){var r="number"==typeof i?Date.now()-i:i,a=(new Date).toISOString(),s=this.getConversationId(),c={t:"client_tool_error",toolCallId:e,toolName:t,conversationId:s,error:n,errorCode:o,executionTimeMs:r};console.log("đ§ ClientTools: [".concat(a,"] Sending error for tool '").concat(t,"'")),console.log(" đ toolCallId: ".concat(e)),console.log(" đ conversationId: ".concat(s||"null")),console.log(" đ toolName: ".concat(t)),console.log(" đ error: ".concat(n,", errorCode: ").concat(o)),console.log(" đ Full message:",JSON.stringify(c,null,2)),this.sendMessage(c),console.log("â
ClientTools: Error message sent at ".concat(a))}setSendMessage(e){this.sendMessage=e}};function _(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)}return n}function O(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?_(Object(n),!0).forEach(function(t){N(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function M(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}function U(e){return function(){var t=this,n=arguments;return new Promise(function(o,i){var r=e.apply(t,n);function a(e){M(r,o,i,a,s,"next",e)}function s(e){M(r,o,i,a,s,"throw",e)}a(void 0)})}}function N(e,t,n){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class z extends c{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.version="2.0.0",this.config={signedUrl:e.signedUrl||e.websocketUrl||"wss://speech.talktopc.com/ws/conv",websocketUrl:e.signedUrl||e.websocketUrl||"wss://speech.talktopc.com/ws/conv",agentId:e.agentId,appId:e.appId,sampleRate:e.sampleRate||16e3,channels:e.channels||1,bitDepth:e.bitDepth||16,audioProcessorPath:e.audioProcessorPath,outputContainer:e.outputContainer||this.getDefaultContainer(e),outputEncoding:e.outputEncoding||e.outputCodec||"pcm",outputSampleRate:e.outputSampleRate||16e3,outputChannels:e.outputChannels||1,outputBitDepth:e.outputBitDepth||16,outputFrameDurationMs:e.outputFrameDurationMs||600,outputCodec:e.outputCodec,agentSettingsOverride:e.agentSettingsOverride||null,variables:e.variables||null,autoReconnect:!1!==e.autoReconnect,protocolVersion:e.protocolVersion||2},this.isConnected=!1,this.hasEverConnected=!1,this.isRecording=!1,this.isPlaying=!1,this.isDestroyed=!1,this.outputAudioFormat=null,this.requestedOutputFormat=null,this.formatConverter=null,this.websocket=null,this.conversationId=null,this.transcriptQueue=[],this.currentPlayingSentenceId=null,this.audioFrameCount=0,this.audioPlayer=new g(this.config),this.audioRecorder=new f(this.config),this.setupAudioPlayerEvents(),this.setupAudioRecorderEvents(),this.clientToolsRegistry=new B(e=>this.sendMessage(e),()=>this.conversationId),this.validateConfig(),this._setupPageUnloadHandler(),console.log("đĩ VoiceSDK v2 initialized:",{version:this.version,outputContainer:this.config.outputContainer,outputEncoding:this.config.outputEncoding,outputSampleRate:this.config.outputSampleRate})}getStoredConversationId(){try{if("undefined"==typeof sessionStorage)return console.warn("â ī¸ VoiceSDK v2: sessionStorage not available (private mode?)"),null;var e=sessionStorage.getItem(z.RESUME_STORAGE_KEY);if(e){var t=JSON.parse(e);if(t&&t.conversationId)return console.log("đĻ VoiceSDK v2: Found stored conversationId:",t.conversationId),t.conversationId}return null}catch(e){return console.warn("â ī¸ VoiceSDK v2: Error reading sessionStorage:",e),null}}storeConversationId(e){if(e)try{if("undefined"==typeof sessionStorage)return void console.warn("â ī¸ VoiceSDK v2: sessionStorage not available (private mode?)");var t={},n=sessionStorage.getItem(z.RESUME_STORAGE_KEY);if(n)try{t=JSON.parse(n)}catch(e){}t.conversationId=e,t.timestamp=Date.now(),t.fromPage=t.fromPage||window.location.pathname+window.location.search,sessionStorage.setItem(z.RESUME_STORAGE_KEY,JSON.stringify(t)),console.log("đž VoiceSDK v2: Stored conversationId:",e)}catch(e){console.warn("â ī¸ VoiceSDK v2: Error writing to sessionStorage:",e)}}clearStoredConversationId(){try{if("undefined"==typeof sessionStorage)return;sessionStorage.removeItem(z.RESUME_STORAGE_KEY),console.log("đī¸ VoiceSDK v2: Cleared stored conversationId")}catch(e){console.warn("â ī¸ VoiceSDK v2: Error clearing sessionStorage:",e)}}_getResumeState(){try{if("undefined"==typeof sessionStorage)return null;var e=sessionStorage.getItem(z.RESUME_STORAGE_KEY);if(!e)return null;var t=JSON.parse(e),n=Date.now()-t.timestamp;return n>z.RESUME_TTL_MS?(console.log("[VoiceSDK] Resume state expired:",n,"ms"),this._clearResumeState(),null):(console.log("[VoiceSDK] Found valid resume state:",t,"age:",n,"ms"),t)}catch(e){return console.warn("[VoiceSDK] Failed to get resume state:",e),null}}_clearResumeState(){try{if("undefined"==typeof sessionStorage)return;sessionStorage.removeItem(z.RESUME_STORAGE_KEY)}catch(e){}}_setupPageUnloadHandler(){window.addEventListener("beforeunload",()=>{this.conversationId&&this.websocket&&this.websocket.readyState===WebSocket.OPEN&&this.storeConversationId(this.conversationId)}),document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&this.conversationId&&this.websocket&&this.websocket.readyState===WebSocket.OPEN&&this.storeConversationId(this.conversationId)})}checkAndResume(){var e=this._getResumeState();if(!e)return null;var t=window.location.pathname+window.location.search;return console.log("[VoiceSDK] Auto-resuming conversation:",e.conversationId),console.log("[VoiceSDK] Page change:",e.fromPage,"â",t),{conversationId:e.conversationId,fromPage:e.fromPage,toPage:t}}getDefaultContainer(e){return"wav"===e.outputCodec?"wav":"raw"}validateInputFormat(e){var t;if(!e)return"Input format is required";var n=null===(t=e.encoding)||void 0===t?void 0:t.toLowerCase();return n&&z.SUPPORTED_INPUT_ENCODINGS.includes(n)?e.sampleRate&&z.SUPPORTED_INPUT_SAMPLE_RATES.includes(e.sampleRate)?e.bitDepth&&z.SUPPORTED_INPUT_BIT_DEPTHS.includes(e.bitDepth)?e.channels&&z.SUPPORTED_INPUT_CHANNELS.includes(e.channels)?null:"Unsupported input channels: ".concat(e.channels,". Supported: ").concat(z.SUPPORTED_INPUT_CHANNELS.join(", ")):"Unsupported input bit depth: ".concat(e.bitDepth,". Supported: ").concat(z.SUPPORTED_INPUT_BIT_DEPTHS.join(", ")):"Unsupported input sample rate: ".concat(e.sampleRate,". Supported: ").concat(z.SUPPORTED_INPUT_SAMPLE_RATES.join(", ")):"Unsupported input encoding: ".concat(e.encoding,". Supported: ").concat(z.SUPPORTED_INPUT_ENCODINGS.join(", "))}validateOutputFormat(e){var t,n;if(!e)return"Output format is required";var o=null===(t=e.encoding)||void 0===t?void 0:t.toLowerCase();if(!o||!z.SUPPORTED_OUTPUT_ENCODINGS.includes(o))return"Unsupported output encoding: ".concat(e.encoding,". Supported: ").concat(z.SUPPORTED_OUTPUT_ENCODINGS.join(", "));if(!e.sampleRate||!z.SUPPORTED_OUTPUT_SAMPLE_RATES.includes(e.sampleRate))return"Unsupported output sample rate: ".concat(e.sampleRate,". Supported: ").concat(z.SUPPORTED_OUTPUT_SAMPLE_RATES.join(", "));if(!e.bitDepth||!z.SUPPORTED_OUTPUT_BIT_DEPTHS.includes(e.bitDepth))return"Unsupported output bit depth: ".concat(e.bitDepth,". Supported: ").concat(z.SUPPORTED_OUTPUT_BIT_DEPTHS.join(", "));if(!e.channels||!z.SUPPORTED_OUTPUT_CHANNELS.includes(e.channels))return"Unsupported output channels: ".concat(e.channels,". Supported: ").concat(z.SUPPORTED_OUTPUT_CHANNELS.join(", "));var i=null===(n=e.container)||void 0===n?void 0:n.toLowerCase();return i&&z.SUPPORTED_OUTPUT_CONTAINERS.includes(i)?null:"Unsupported output container: ".concat(e.container,". Supported: ").concat(z.SUPPORTED_OUTPUT_CONTAINERS.join(", "))}validateConfig(){var e={encoding:"pcm",sampleRate:this.config.sampleRate,channels:this.config.channels,bitDepth:this.config.bitDepth},t=this.validateInputFormat(e);if(t)return console.error("â VoiceSDK v2: Invalid input format:",t),void this.emit("error",new Error(t));var n={encoding:this.config.outputEncoding,sampleRate:this.config.outputSampleRate,channels:this.config.outputChannels,bitDepth:this.config.outputBitDepth,container:this.config.outputContainer},o=this.validateOutputFormat(n);if(o)return console.error("â VoiceSDK v2: Invalid output format:",o),void this.emit("error",new Error(o));console.log("â
VoiceSDK v2: Format validation passed")}setupAudioPlayerEvents(){this.audioPlayer.on("playbackStarted",()=>{this.isPlaying=!0,this.emit("playbackStarted"),this.isConnected?(console.log("đ¤ VoiceSDK v2: Sending audio_started_playing message to server"),this.sendMessage({t:"audio_started_playing"})):console.warn("â ī¸ VoiceSDK v2: Cannot send audio_started_playing - not connected")}),this.audioPlayer.on("transcriptDisplay",e=>{var t=this.currentPlayingSentenceId?this.currentPlayingSentenceId+1:1;this.currentPlayingSentenceId=t;var n={text:e.text,role:"assistant",sentenceId:t,final:!0,timestamp:Date.now()};console.log("đ VoiceSDK v2: Emitting synced transcriptDisplay from AudioPlayer:",n),this.emit("transcriptDisplay",n),this.emit("transcript",n)}),this.audioPlayer.on("playbackStopped",()=>{this.isPlaying=!1,this.emit("playbackStopped"),this.isConnected?(console.log("đ¤ VoiceSDK v2: Sending audio_stopped_playing message to server"),this.sendMessage({t:"audio_stopped_playing"})):console.warn("â ī¸ VoiceSDK v2: Cannot send audio_stopped_playing - not connected")}),this.audioPlayer.on("playbackError",e=>{this.emit("playbackError",e),this.emit("error",e)})}setupAudioRecorderEvents(){this.audioRecorder.on("recordingStarted",()=>{this.isRecording=!0,this.emit("recordingStarted")}),this.audioRecorder.on("recordingStopped",()=>{this.isRecording&&(this.isRecording=!1,this.emit("recordingStopped"),console.log("đ VoiceSDK v2: Recording stopped (from audioRecorder event)"))}),this.audioRecorder.on("audioData",e=>{this.isConnected&&this.sendBinary(e)}),this.audioRecorder.on("error",e=>{console.error("â AudioRecorder error:",e),this.emit("error",e)})}buildWebSocketUrl(){var e=this.config.signedUrl||this.config.websocketUrl,t=new URL(e,"wss://placeholder.com"),n=t.searchParams;this.config.agentId&&!n.has("agentId")&&n.append("agentId",this.config.agentId),this.config.appId&&!n.has("appId")&&n.append("appId",this.config.appId);var o=this.getStoredConversationId();o&&!n.has("conversationId")&&(n.append("conversationId",o),console.log("đ VoiceSDK v2: Attempting resume via query param:",o));var i=window.location.pathname+window.location.search;i&&!n.has("currentPage")&&n.append("currentPage",i);var r=n.toString();return r?"".concat(t.origin).concat(t.pathname,"?").concat(r):"".concat(t.origin).concat(t.pathname)}connect(){var e=this;return U(function*(){if(e.isDestroyed)return console.warn("VoiceSDK v2: Cannot connect - SDK is destroyed"),!1;if(e.isConnected)return console.warn("VoiceSDK v2: Already connected"),!0;try{var t=e.buildWebSocketUrl();return console.log("đ VoiceSDK v2: Connecting to",t),yield new Promise((n,o)=>{e.websocket=new WebSocket(t),e.websocket.onopen=()=>{console.log("â
VoiceSDK v2: WebSocket connected"),e.isConnected=!0,e.hasEverConnected=!0,e.clientToolsRegistry&&e.clientToolsRegistry.setSendMessage(t=>e.sendMessage(t)),e.sendHelloMessage(),e.emit("connected"),n(!0)},e.websocket.onerror=e=>{console.error("â VoiceSDK v2: WebSocket error:",e),o(e)},e.websocket.onclose=t=>{console.log("đ VoiceSDK v2: WebSocket closed:",t.code,t.reason),e.isConnected=!1,e.isRecording&&e.stopRecording().catch(e=>console.error("Error stopping recording:",e)),e.emit("disconnected",t),e.config.autoReconnect&&!e.isDestroyed&&e.hasEverConnected?(console.log("đ VoiceSDK v2: Auto-reconnecting in 3s..."),setTimeout(()=>{e.isDestroyed||e.isConnected||e.connect()},3e3)):e.config.autoReconnect&&!e.hasEverConnected&&console.log("â ī¸ VoiceSDK v2: Initial connection failed. Auto-reconnect disabled to prevent retry loop.")},e.websocket.onmessage=t=>{e.handleMessage(t)}})}catch(t){return console.error("đ VoiceSDK v2: Connection failed:",t),e.emit("error",t),!1}})()}sendHelloMessage(){if(this.isConnected){var e={encoding:"pcm",sampleRate:this.config.sampleRate,channels:this.config.channels,bitDepth:this.config.bitDepth},t={encoding:this.config.outputEncoding,sampleRate:this.config.outputSampleRate,channels:this.config.outputChannels,bitDepth:this.config.outputBitDepth,container:this.config.outputContainer},n=this.validateInputFormat(e);if(n)return console.error("â VoiceSDK v2: Cannot send hello - invalid input format:",n),void this.emit("error",new Error("Invalid input format: ".concat(n)));var o=this.validateOutputFormat(t);if(o)return console.error("â VoiceSDK v2: Cannot send hello - invalid output format:",o),void this.emit("error",new Error("Invalid output format: ".concat(o)));var i={t:"hello",v:this.config.protocolVersion,inputFormat:e,requestedOutputFormat:t,outputFrameDurationMs:this.config.outputFrameDurationMs};this.config.agentSettingsOverride&&(i.agentSettingsOverride=this.config.agentSettingsOverride),console.log("đ VoiceSDK v2: Checking variables:",{hasVariables:!!this.config.variables,variables:this.config.variables,keys:this.config.variables?Object.keys(this.config.variables):[]}),this.config.variables&&Object.keys(this.config.variables).length>0?(i.variables=this.config.variables,console.log("đ VoiceSDK v2: Including variables in hello:",Object.keys(this.config.variables))):console.log("â ī¸ VoiceSDK v2: Variables NOT included - condition failed"),console.log("đ¤ VoiceSDK v2: Sending hello:",{version:i.v,requestedFormat:i.requestedOutputFormat,variables:i.variables?Object.keys(i.variables):void 0}),console.log("đ¤ VoiceSDK v2: Requested output format:",{container:i.requestedOutputFormat.container,encoding:i.requestedOutputFormat.encoding,sampleRate:i.requestedOutputFormat.sampleRate,bitDepth:i.requestedOutputFormat.bitDepth}),console.log("đ¤ VoiceSDK v2: Full hello message being sent:",JSON.stringify(i,null,2));try{this.sendMessage(i)}catch(e){console.error("VoiceSDK v2: Failed to send hello:",e),this.emit("error",e)}}else console.warn("VoiceSDK v2: Cannot send hello - not connected")}handleMessage(e){if(e.data instanceof ArrayBuffer||e.data instanceof Blob)this.handleBinaryMessage(e.data);else try{var t=JSON.parse(e.data);switch("audio"!==t.t&&console.log("đĨ VoiceSDK v2: Received message type:",t.t,"Full message:",JSON.stringify(t).substring(0,200)),!this.conversationId&&t.conversationId&&(this.conversationId=t.conversationId,console.log("đ VoiceSDK v2: Captured conversationId from message:",this.conversationId),this.emit("conversationIdChanged",this.conversationId)),"audio"!==t.t&&console.log("đ¨ VoiceSDK v2: Received message type:",t.t,t),t.t){case"hello_ack":this.handleHelloAck(t);break;case"transcript":console.log("đ VoiceSDK v2: Processing transcript message:",t),this.handleTranscript(t);break;case"user_transcript":console.log("đ VoiceSDK v2: Received user_transcript:",t),this.emit("message",t);break;case"agent_response":if(console.log("đ VoiceSDK v2: Received agent_response:",t),(t.text||t.transcript)&&(console.log("đ VoiceSDK v2: agent_response contains transcript data:",t.text||t.transcript),t.sentenceId&&(t.text||t.transcript))){var n={t:"transcript",sentenceId:t.sentenceId,text:t.text||t.transcript,role:t.role||"assistant",final:!1!==t.final,timestamp:t.timestamp||Date.now()};console.log("đ VoiceSDK v2: Converting agent_response to transcript:",n),this.handleTranscript(n)}this.emit("message",t);break;case"error":this.emit("message",t);break;case"barge_in":this.emit("bargeIn",t),this.stopAudioPlayback();break;case"stop_playing":this.emit("stopPlaying",t),this.stopAudioPlayback();break;case"audio_start":console.log("đ VoiceSDK v2: Received audio_start with text:",t.text),t.text&&this.audioPlayer&&this.audioPlayer.markNewSentence(t.text),this.emit("message",t);break;case"client_tool_call":this.clientToolsRegistry.handleToolCall(t);break;case"hangup_ack":console.log("đ VoiceSDK v2: Hangup acknowledged by server"),this.websocket&&this.websocket.readyState===WebSocket.OPEN&&(this.websocket.close(1e3,"User hangup"),this.websocket=null),this.isConnected=!1,this.emit("hangupAcknowledged");break;default:if(console.log("VoiceSDK v2: Unknown message type:",t.t,"Full message:",JSON.stringify(t).substring(0,300)),(t.text||t.transcript||t.transcription)&&(console.log("đ VoiceSDK v2: Unknown message contains transcript-like data:",{text:t.text,transcript:t.transcript,transcription:t.transcription,sentenceId:t.sentenceId,role:t.role}),t.sentenceId&&(t.text||t.transcript||t.transcription))){var o={t:"transcript",sentenceId:t.sentenceId,text:t.text||t.transcript||t.transcription,role:t.role||"assistant",final:!1!==t.final,timestamp:t.timestamp||Date.now()};console.log("đ VoiceSDK v2: Attempting to process unknown message as transcript:",o),this.handleTranscript(o)}this.emit("message",t)}}catch(e){console.error("VoiceSDK v2: Error parsing message:",e)}}handleHelloAck(e){if(console.log("đĨ VoiceSDK v2: Received hello_ack:",{hasOutputFormat:!!e.outputAudioFormat,outputFormat:e.outputAudioFormat,hasConversationId:!!e.conversationId,messageType:e.t}),e.conversationId&&(this.conversationId=e.conversationId,console.log("đ VoiceSDK v2: Received conversationId:",this.conversationId),this.emit("conversationIdChanged",this.conversationId),this.storeConversationId(this.conversationId)),!0===e.resumed?(console.log("â
VoiceSDK v2: Conversation resumed successfully"),this.emit("callResumed",{conversationId:this.conversationId,timestamp:Date.now()})):!1===e.resumed&&e.resumeRejectedReason&&(console.warn("â ī¸ VoiceSDK v2: Resume rejected:",e.resumeRejectedReason),this.clearStoredConversationId(),this.emit("resumeRejected",{reason:e.resumeRejectedReason,conversationId:e.conversationId||null,timestamp:Date.now()})),e.outputAudioFormat){this.outputAudioFormat=e.outputAudioFormat,this.audioPlayer.setOutputFormat(e.outputAudioFormat),console.log("â
VoiceSDK v2: Format negotiated by server:",this.outputAudioFormat),this.requestedOutputFormat={container:this.config.outputContainer||"wav",encoding:this.config.outputEncoding||"pcm",sampleRate:this.config.outputSampleRate||16e3,bitDepth:this.config.outputBitDepth||16,channels:this.config.outputChannels||1};var t={container:this.outputAudioFormat.container||"unknown",encoding:this.outputAudioFormat.encoding||"unknown",sampleRate:this.outputAudioFormat.sampleRate||0,bitDepth:this.outputAudioFormat.bitDepth||0,channels:this.outputAudioFormat.channels||0},n=[];if(this.requestedOutputFormat.container!==t.container&&n.push('container: "'.concat(this.requestedOutputFormat.container,'" â "').concat(t.container,'"')),this.requestedOutputFormat.encoding!==t.encoding&&n.push('encoding: "'.concat(this.requestedOutputFormat.encoding,'" â "').concat(t.encoding,'"')),this.requestedOutputFormat.sampleRate!==t.sampleRate&&n.push("sampleRate: ".concat(this.requestedOutputFormat.sampleRate,"Hz â ").concat(t.sampleRate,"Hz")),this.requestedOutputFormat.bitDepth!==t.bitDepth&&n.push("bitDepth: ".concat(this.requestedOutputFormat.bitDepth,"-bit â ").concat(t.bitDepth,"-bit")),this.requestedOutputFormat.channels!==t.channels&&n.push("channels: ".concat(this.requestedOutputFormat.channels," â ").concat(t.channels)),n.length>0){console.warn("â ī¸ VoiceSDK v2: Format negotiation mismatch!"),console.warn(" Requested:",this.requestedOutputFormat),console.warn(" Negotiated:",t),console.warn(" Differences:",n.join(", "));try{if(this.formatConverter=new D(this.requestedOutputFormat,t),this.formatConverter.needsConversion()){var o=this.formatConverter.getConversionSteps();console.log("đ VoiceSDK v2: Format conversion enabled"),console.log(" Conversion steps:",o.join(", ")),console.log(" Audio will be automatically converted to requested format")}}catch(e){console.error("â VoiceSDK v2: Failed to create format converter:",e),console.warn(" Will use backend format without conversion"),this.formatConverter=null}}else console.log("â
VoiceSDK v2: Format perfectly matched!",t),this.formatConverter=null;this.emit("formatNegotiated",this.outputAudioFormat)}else{this.config.protocolVersion>=2?(console.warn("â ī¸ VoiceSDK v2: hello_ack received but no outputAudioFormat in response."),console.warn(" This may happen if:"),console.warn(" 1. Backend is not sending outputAudioFormat (check backend logs)"),console.warn(" 2. Hello message missing v2 fields (v, inputFormat, requestedOutputFormat)"),console.warn(" 3. Backend validation failed (check backend error logs)"),console.warn(" Using default format from config...")):console.log("â
VoiceSDK v2: Connected (v1 legacy mode)");var i={container:this.config.outputContainer||"wav",encoding:this.config.outputEncoding||"pcm",sampleRate:this.config.outputSampleRate||16e3,channels:this.config.outputChannels||1,bitDepth:this.config.outputBitDepth||16};this.outputAudioFormat=i,this.requestedOutputFormat=i,this.audioPlayer.setOutputFormat(i),this.formatConverter=null}}handleTranscript(e){if(e.sentenceId&&e.text){var t=e.sentenceId,n={text:e.text,role:e.role||"assistant",sentenceId:t,final:!1!==e.final,timestamp:e.timestamp||Date.now()};this.transcriptQueue.push(n),console.log("đ VoiceSDK v2: Received transcript for sentence",t,":",n.text),console.log(" Transcript queue length:",this.transcriptQueue.length),console.log(" Current playing sentence:",this.currentPlayingSentenceId),console.log("đ VoiceSDK v2: Displaying transcript for completed sentence",t),this.emit("transcriptDisplay",n),this.currentPlayingSentenceId=t,this.emit("transcript",n)}else console.warn("â ī¸ VoiceSDK v2: Invalid transcript message:",e)}handleBinaryMessage(e){var t=this;return U(function*(){var n,o=n=e instanceof Blob?yield e.arrayBuffer():e;if(t.formatConverter&&t.formatConverter.needsConversion())try{o=yield t.formatConverter.convert(n),console.log("â
VoiceSDK v2: Audio converted to requested format")}catch(e){console.error("â VoiceSDK v2: Format conversion failed:",e),console.warn(" Using backend format without conversion"),o=n}var i=t.formatConverter&&t.formatConverter.needsConversion()?t.requestedOutputFormat:t.outputAudioFormat||{container:t.config.outputContainer||"raw",encoding:t.config.outputEncoding||"pcm",sampleRate:t.config.outputSampleRate||16e3,bitDepth:t.config.outputBitDepth||16,channels:t.config.outputChannels||1},r=i.container||"raw",a=(i.encoding||"pcm").toLowerCase();if("raw"===r){var s=o;if("pcm"!==a){var c=t.audioPlayer.getCodec(a);if(c){var l=c.decode(new Uint8Array(o));s=l.buffer,console.log("đ VoiceSDK v2: Decoded ".concat(a.toUpperCase()," to PCM (").concat(l.byteLength," bytes)"))}else console.warn("â ī¸ VoiceSDK v2: No codec for ".concat(a,", treating as PCM"))}t.audioPlayer.outputFormat||(console.warn("â ī¸ VoiceSDK v2: outputFormat not set on AudioPlayer, setting from playbackFormat"),t.audioPlayer.setOutputFormat(i)),t.audioFrameCount++,t.audioPlayer.playChunk(s)}else t.audioFrameCount++,t.audioPlayer.playAudio(o)})()}sendMessage(e){if(!this.websocket||this.websocket.readyState!==WebSocket.OPEN)return console.warn("VoiceSDK v2: Cannot send message - not connected"),!1;try{var t=(new Date).toISOString(),n=this.websocket?this.websocket.readyState:"NO_WEBSOCKET",o=this.websocket?{0:"CONNECTING",1:"OPEN",2:"CLOSING",3:"CLOSED"}[n]:"NO_WEBSOCKET";if("client_tool_result"!==e.t&&"client_tool_error"!==e.t||(console.log("đ¤ VoiceSDK v2: [".concat(t,"] Sending tool ").concat(e.t)),console.log(" đ WebSocket state: ".concat(o," (").concat(n,")")),console.log(" đ toolCallId: ".concat(e.toolCallId)),console.log(" đ conversationId: ".concat(e.conversationId||"null")),console.log(" đ toolName: ".concat(e.toolName)),"client_tool_result"===e.t?console.log(" đ result:",e.result):console.log(" đ error: ".concat(e.error,", errorCode: ").concat(e.errorCode)),console.log(" đ Full message:",JSON.stringify(e,null,2))),!this.websocket||this.websocket.readyState!==WebSocket.OPEN)return console.error("â VoiceSDK v2: Cannot send message - WebSocket not open (state: ".concat(o,")")),!1;var i=JSON.stringify(e);return this.websocket.send(i),"client_tool_result"!==e.t&&"client_tool_error"!==e.t||console.log("â
VoiceSDK v2: [".concat(t,"] Tool ").concat(e.t," message sent successfully (").concat(i.length," bytes)")),!0}catch(e){return console.error("VoiceSDK v2: Error sending message:",e),this.emit("error",e),!1}}sendBinary(e){if(!this.websocket||this.websocket.readyState!==WebSocket.OPEN)return console.warn("VoiceSDK v2: Cannot send audio - not connected"),!1;try{return this.websocket.send(e),!0}catch(e){return console.error("VoiceSDK v2: Error sending audio:",e),this.emit("error",e),!1}}hangup(){if(this.websocket&&this.websocket.readyState===WebSocket.OPEN){console.log("đ VoiceSDK v2: Hanging up call..."),this.clearStoredConversationId(),this.stopRecording(),this.audioPlayer&&this.stopAudioPlayback();try{this.sendMessage({t:"hangup"}),setTimeout(()=>{this.websocket&&this.websocket.readyState===WebSocket.OPEN&&(this.websocket.close(1e3,"User hangup"),this.websocket=null),this.isConnected=!1},100)}catch(e){console.error("VoiceSDK v2: Error sending hangup message:",e),this.websocket&&(this.websocket.close(1e3,"User hangup"),this.websocket=null),this.isConnected=!1}}else console.warn("đ VoiceSDK v2: Cannot hangup - WebSocket not open")}startRecording(){var e=this;return U(function*(){if(!e.isConnected){var t=new Error("Not connected to voice server");throw e.emit("error",t),t}if(e.isRecording)return console.warn("VoiceSDK v2: Already recording"),!0;console.log("đ¤ VoiceSDK v2: Starting recording...");try{return console.log("đ¤ VoiceSDK v2: Requesting microphone permission (mobile-friendly)..."),yield e.audioRecorder.start(),yield e.audioPlayer.resumeAudioContext(),e.sendMessage({t:"start_continuous_mode",ttpId:e.generateTtpId()}),!0}catch(t){if(console.error("â VoiceSDK v2: Failed to start recording:",t),"NotAllowedError"===t.name||"PermissionDeniedError"===t.name){var n=new Error("Microphone permission denied. Please allow microphone access in your browser settings and try again.");n.name=t.name,n.originalError=t,e.emit("error",n)}else e.emit("error",t);return!1}})()}stopRecording(){var e=this;return U(function*(){if(!e.isRecording)return console.warn("VoiceSDK v2: Not recording"),!0;console.log("đ VoiceSDK v2: Stopping recording...");try{return e.sendMessage({t:"stop_continuous_mode",ttpId:e.generateTtpId()}),e.isRecording=!1,e.emit("recordingStopped"),console.log("đ VoiceSDK v2: Recording stopped (emitted before audioRecorder.stop())"),yield e.audioRecorder.stop(),e.stopAudioPlayback(),!0}catch(t){return console.error("VoiceSDK v2: Error stopping recording:",t),e.emit("error",t),!1}})()}toggleRecording(){var e=this;return U(function*(){return e.isRecording?yield e.stopRecording():yield e.startRecording()})()}clearTranscriptState(){this.currentPlayingSentenceId=null,console.log("đ VoiceSDK v2: Cleared transcript state")}stopAudioPlayback(){this.audioPlayer.stopImmediate(),this.clearTranscriptState()}handleBargeIn(){var e=this;return U(function*(){e.stopAudioPlayback(),e.isRecording||(yield e.startRecording())})()}getStatus(){return{version:this.version,isConnected:this.isConnected,isRecording:this.isRecording,isPlaying:this.isPlaying,outputFormat:this.outputAudioFormat,conversationId:this.conversationId,audioPlayer:this.audioPlayer.getStatus(),audioRecorder:this.audioRecorder.getStatus()}}updateConfig(e){this.config=O(O({},this.config),e)}generateTtpId(){return"sdk_"+Math.random().toString(36).substr(2,9)+"_"+Date.now()}registerToolHandler(e,t){return this.clientToolsRegistry.registerHandler(e,t)}unregisterToolHandler(e){return this.clientToolsRegistry.unregisterHandler(e)}hasToolHandler(e){return this.clientToolsRegistry.hasHandler(e)}getRegisteredTools(){return this.clientToolsRegistry.getRegisteredTools()}destroy(){this.isDestroyed||(console.log("đī¸ VoiceSDK v2: Destroying..."),this.isDestroyed=!0,this.isRecording&&this.stopRecording(),this.audioPlayer&&this.stopAudioPlayback(),this.websocket&&(this.websocket.close(),this.websocket=null),this.isConnected=!1,this.audioPlayer&&this.audioPlayer.destroy(),this.audioRecorder&&this.audioRecorder.destroy(),this.clientToolsRegistry&&this.clientToolsRegistry.getRegisteredTools().forEach(e=>this.clientToolsRegistry.unregisterHandler(e)),this.removeAllListeners())}}N(z,"RESUME_STORAGE_KEY","voice_resume_state"),N(z,"RESUME_TTL_MS",1e4),N(z,"SUPPORTED_INPUT_ENCODINGS",["pcm","pcmu","pcma"]),N(z,"SUPPORTED_INPUT_SAMPLE_RATES",[8e3,16e3,22050,24e3,44100,48e3]),N(z,"SUPPORTED_INPUT_BIT_DEPTHS",[8,16,24]),N(z,"SUPPORTED_INPUT_CHANNELS",[1]),N(z,"SUPPORTED_OUTPUT_ENCODINGS",["pcm","pcmu","pcma"]),N(z,"SUPPORTED_OUTPUT_SAMPLE_RATES",[8e3,16e3,22050,24e3,44100,48e3]),N(z,"SUPPORTED_OUTPUT_BIT_DEPTHS",[8,16,24]),N(z,"SUPPORTED_OUTPUT_CHANNELS",[1]),N(z,"SUPPORTED_OUTPUT_CONTAINERS",["raw","wav"]);const H=z;class L{constructor(){this.events={}}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}off(e,t){this.events[e]&&(this.events[e]=this.events[e].filter(e=>e!==t))}emit(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];this.events[e]&&this.events[e].forEach(t=>{try{t(...n)}catch(t){console.error("Error in event listener for ".concat(e,":"),t)}})}removeAllListeners(e){e?delete this.events[e]:this.events={}}}function K(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}function V(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)}return n}function j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?V(Object(n),!0).forEach(function(t){W(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):V(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function W(e,t,n){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class q extends L{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super();var t=this.readScriptTagConfig();this.config=j({baseWsUrl:"wss://backend.talktopc.com/chat/websocket",appId:e.appId||t.appId,agentId:e.agentId||t.agentId,conversationId:void 0!==e.conversationId?e.conversationId:this.getPersistedConversationId(),forceConversationId:e.forceConversationId,queue:[],inFlight:!1},e),this.fullResponseBuffer=""}readScriptTagConfig(){try{var e=Array.from(document.getElementsByTagName("script")).reverse().find(e=>e.dataset&&(e.dataset.appId||e.dataset.agentId)||e.src&&e.src.includes("agent-widget"));return e?{appId:e.dataset.appId,agentId:e.dataset.agentId}:{}}catch(e){return{}}}buildWebSocketUrl(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.config.baseWsUrl,t=new URLSearchParams;return this.config.appId&&t.append("appId",this.config.appId),this.config.agentId&&t.append("agentId",this.config.agentId),this.config.conversationId&&t.append("conversationId",this.config.conversationId),"".concat(e,"?").concat(t.toString())}sendMessage(e){var t,n=this;return(t=function*(){return new Promise((t,o)=>{if(e&&e.trim())if(n.config.appId&&n.config.agentId){var i={text:e,resolve:t,reject:o};n.config.inFlight?n.config.queue.push(i):n.executeTask(i)}else o(new Error("Missing appId or agentId"));else o(new Error("Message is empty"))})},function(){var e=this,n=arguments;return new Promise(function(o,i){var r=t.apply(e,n);function a(e){K(r,o,i,a,s,"next",e)}function s(e){K(r,o,i,a,s,"throw",e)}a(void 0)})})()}executeTask(e){if(this.config.inFlight=!0,this.fullResponseBuffer="",!this.config.conversationId){var t=this.getPersistedConversationId();t&&(this.config.conversationId=t,console.log("đ TextChatSDK hydrated conversationId from storage:",t))}var n=this.buildWebSocketUrl(this.config.baseWsUrl),o=this.config.baseWsUrl.endsWith("/websocket")?this.config.baseWsUrl.replace(/\/websocket$/,""):"".concat(this.config.baseWsUrl,"/websocket"),i=this.buildWebSocketUrl(o),r=!1,a=!1,s=null,c=t=>{if(!a)try{var n={message:e.text},o=this.config.forceConversationId||this.config.conversationId;o&&(n.conversationId=o,this.config.forceConversationId&&!this.config.conversationId&&(this.config.conversationId=o,this.persistConversationId(o))),console.log("đ TextChatSDK sending payload:",n,"conversationId in config:",this.config.conversationId),t.send(JSON.stringify(n)),a=!0}catch(n){e.reject(n),this.emit("error",n);try{t.close()}catch(e){}}},l=e=>()=>{this.config.conversationId?c(e):s=setTimeout(()=>c(e),200)},d=t=>n=>{try{try{console.log("đ [TextChatSDK] WS <= raw:",n.data)}catch(e){}var o=JSON.parse(n.data);try{console.log("đ [TextChatSDK] WS <= parsed:",o)}catch(e){}if("hello"===o.type&&o.conversationId){if(console.log("đ TextChatSDK received conversationId:",o.conversationId),this.config.conversationId=o.conversationId,this.persistConversationId(o.conversationId),this.emit&&this.emit("conversationIdChanged",o.conversationId),!a&&t&&1===t.readyState){if(s)try{clearTimeout(s)}catch(e){}c(t)}return}if(!this.config.conversationId&&o.conversationId&&(console.log("đ TextChatSDK captured conversationId from message:",o.conversationId),this.config.conversationId=o.conversationId,this.persistConversationId(o.conversationId)),"chunk"===o.type&&"string"==typeof o.content)this.fullResponseBuffer+=o.content,this.emit("chunk",o.content);else if("done"===o.type){try{var i=o.text||o.content||o.answer||o.message||"";i&&!this.fullResponseBuffer&&(this.fullResponseBuffer=i)}catch(e){}!this.config.conversationId&&o.conversationId&&(console.log("đ TextChatSDK captured conversationId from done:",o.conversationId),this.config.conversationId=o.conversationId),this.persistConversationId(this.config.conversationId),this.emit("done",{text:this.fullResponseBuffer}),e.resolve({conversationId:this.config.conversationId,fullText:this.fullResponseBuffer});try{t.close()}catch(e){}}else if("error"===o.type){var r=new Error(o.message||"Server error");this.emit("error",r),e.reject(r);try{t.close()}catch(e){}}}catch(e){}},u=t=>{if(1008===t.code&&t.reason&&(t.reason.includes("Domain not whitelisted")||t.reason.includes("domain")||t.reason.includes("whitelist"))){var n=new Error("DOMAIN_NOT_WHITELISTED");return n.reason=t.reason,n.code=t.code,this.emit("domainError",n),e.reject(n),this.config.inFlight=!1,void this.drainQueue()}this.config.inFlight=!1,this.drainQueue()},h=new WebSocket(n);h.onopen=l(h),h.onmessage=d(h),h.onerror=(t=>n=>{if(!r){r=!0;try{t.close()}catch(e){}var o=new WebSocket(i);return o.onopen=l(o),o.onmessage=d(o),o.onerror=t=>{this.emit("error",t),e.reject(t)},void(o.onclose=u)}this.emit("error",n),e.reject(n)})(h),h.onclose=u}drainQueue(){if(0!==this.config.queue.length&&!this.config.inFlight){var e=this.config.queue.shift();this.executeTask(e)}}persistConversationId(e){try{e&&localStorage.setItem("ttp_text_chat_conversation_id",e)}catch(e){}}getPersistedConversationId(){try{return localStorage.getItem("ttp_text_chat_conversation_id")||null}catch(e){return null}}updateConfig(e){this.config=j(j({},this.config),e)}destroy(){this.config.queue=[],this.config.inFlight=!1,this.removeAllListeners()}}function Q(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}const G=new class extends L{constructor(){super(),this.connections=new Map,this.connectionCounts=new Map,this.creatingConnections=new Set}getConnection(e){var t,n=this;return(t=function*(){if(n.connections.has(e)){var t=n.connections.get(e);return n.connectionCounts.set(e,(n.connectionCounts.get(e)||0)+1),t}if(n.creatingConnections&&n.creatingConnections.has(e))return new Promise(t=>{var o=()=>{if(n.connections.has(e)){var i=n.connections.get(e);n.connectionCounts.set(e,(n.connectionCounts.get(e)||0)+1),t(i)}else setTimeout(o,50)};o()});n.creatingConnections.add(e);var o=new WebSocket(e);return n.connections.set(e,o),n.connectionCounts.set(e,1),o.addEventListener("open",t=>{n.creatingConnections.delete(e),n.emit("open",t,e)}),o.addEventListener("close",t=>{n.creatingConnections.delete(e),n.connections.delete(e),n.connectionCounts.delete(e),n.emit("close",t,e)}),o.addEventListener("error",t=>{n.creatingConnections.delete(e),n.emit("error",t,e)}),o.addEventListener("message",t=>{n.emit("message",t,e)}),o},function(){var e=this,n=arguments;return new Promise(function(o,i){var r=t.apply(e,n);function a(e){Q(r,o,i,a,s,"next",e)}function s(e){Q(r,o,i,a,s,"throw",e)}a(void 0)})})()}releaseConnection(e){if(this.connections.has(e)){var t=this.connectionCounts.get(e)||0,n=Math.max(0,t-1);if(this.connectionCounts.set(e,n),0===n){var o=this.connections.get(e);o&&o.readyState===WebSocket.OPEN&&o.close(1e3,"No more subscribers"),this.connections.delete(e),this.connectionCounts.delete(e)}}}forceClose(e){if(this.connections.has(e)){var t=this.connections.get(e);t&&t.readyState===WebSocket.OPEN&&t.close(1e3,"Force close"),this.connections.delete(e),this.connectionCounts.delete(e)}}getConnectionStatus(e){return this.connections.has(e)?{exists:!0,readyState:this.connections.get(e).readyState,subscribers:this.connectionCounts.get(e)||0}:{exists:!1,readyState:null,subscribers:0}}getAllConnections(){var e={};for(var[t,n]of this.connections.entries())e[t]={readyState:n.readyState,subscribers:this.connectionCounts.get(t)||0};return e}clearAll(){for(var[e,t]of this.connections.entries())t&&t.readyState===WebSocket.OPEN&&t.close(1e3,"Clear all");this.connections.clear(),this.connectionCounts.clear(),this.creatingConnections.clear()}};function Y(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}class J extends L{constructor(e){super(),this.config=e,this.ws=null,this.isConnected=!1,this.connectionId=null}connect(){var e,t=this;return(e=function*(){return new Promise((e,n)=>{try{t.connectionId=Date.now()+"_"+Math.random().toString(36).substr(2,9),t.connectResolve=e,t.connectReject=n;var o=t.config.signedUrl||t.config.websocketUrl;G.getConnection(o,t.config).then(n=>{t.ws=n,t.setupEventListeners(),n.readyState===WebSocket.OPEN&&(t.isConnected=!0,t.emit("connected"),e(),t.connectResolve=null,t.connectReject=null)}).catch(e=>{console.error("đ WebSocketManager: Connection failed ".concat(t.connectionId),e),n(e),t.connectResolve=null,t.connectReject=null})}catch(e){console.error("đ WebSocketManager: Connection error ".concat(t.connectionId),e),n(e),t.connectResolve=null,t.connectReject=null}})},function(){var t=this,n=arguments;return new Promise(function(o,i){var r=e.apply(t,n);function a(e){Y(r,o,i,a,s,"next",e)}function s(e){Y(r,o,i,a,s,"throw",e)}a(void 0)})})()}setupEventListeners(){if(this.ws){var e=(e,t)=>{t===(this.config.signedUrl||this.config.websocketUrl)&&(this.isConnected=!0,this.emit("connected"),this.connectResolve&&(this.connectResolve(),this.connectResolve=null,this.connectReject=null))},t=(e,t)=>{t===(this.config.signedUrl||this.config.websocketUrl)&&(this.isConnected=!1,this.emit("disconnected",e))},n=(e,t)=>{t===(this.config.signedUrl||this.config.websocketUrl)&&(this.emit("error",e),this.connectReject&&(this.connectReject(e),this.connectResolve=null,this.connectReject=null))},o=(e,t)=>{t===(this.config.signedUrl||this.config.websocketUrl)&&this.handleMessage(e)};G.on("open",e),G.on("close",t),G.on("error",n),G.on("message",o),this.eventHandlers={open:e,close:t,error:n,message:o}}}disconnect(){this.eventHandlers&&(G.off("open",this.eventHandlers.open),G.off("close",this.eventHandlers.close),G.off("error",this.eventHandlers.error),G.off("message",this.eventHandlers.message));var e=this.config.signedUrl||this.config.websocketUrl;e&&G.releaseConnection(e),this.ws=null,this.isConnected=!1}sendMessage(e){if(this.isConnected&&this.ws)try{this.ws.send(JSON.stringify(e))}catch(e){console.warn("đ WebSocketManager: Failed to send message:",e.message)}}sendBinary(e){if(this.isConnected&&this.ws)try{this.ws.send(e)}catch(e){console.warn("đ WebSocketManager: Failed to send binary data:",e.message)}}handleMessage(e){if(e.data instanceof ArrayBuffer)this.emit("binaryAudio",e.data);else if(e.data instanceof Blob)e.data.arrayBuffer().then(e=>{this.emit("binaryAudio",e)}).catch(e=>{console.error("đ WebSocketManager: Error converting Blob to ArrayBuffer:",e)});else try{var t=JSON.parse(e.data);"barge_in_ack"!==t.t&&"stop_sending"!==t.t||this.emit("bargeIn",t),"stop_playing"===t.t&&this.emit("stopPlaying",t),this.emit("message",t)}catch(e){this.emit("error",e)}}getStatus(){return{isConnected:this.isConnected,readyState:this.ws?this.ws.readyState:null,connectionId:this.connectionId}}static getSingletonStatus(){return G.getAllConnections()}static clearAllConnections(){G.clearAll()}}function $(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}function X(e){return function(){var t=this,n=arguments;return new Promise(function(o,i){var r=e.apply(t,n);function a(e){$(r,o,i,a,s,"next",e)}function s(e){$(r,o,i,a,s,"throw",e)}a(void 0)})}}class Z extends L{constructor(e){super(),this.config=e,this.audioContext=null,this.audioWorkletNode=null,this.mediaStream=null,this.isRecording=!1}getAudioProcessorPath(){if(this.config.audioProcessorPath)return this.config.audioProcessorPath;var e=document.getElementsByTagName("script");for(var t of e){var n=t.src;if(n&&(n.includes("agent-widget.js")||n.includes("ttp-agent-sdk")))try{new URL(n);var o=n.substring(0,n.lastIndexOf("/"));return"".concat(o,"/audio-processor.js")}catch(e){var i=n.substring(0,n.lastIndexOf("/"));return"".concat(i,"/audio-processor.js")}}return"https://cdn.talktopc.com/audio-processor.js"}checkPermissionState(){return X(function*(){try{if(navigator.permissions&&navigator.permissions.query)return(yield navigator.permissions.query({name:"microphone"})).state}catch(e){console.log("â ī¸ AudioRecorder: Permissions API not available or not supported for microphone")}return null})()}requestPermission(){var e=this;return X(function*(){try{if("granted"===(yield e.checkPermissionState()))return console.log("â
AudioRecorder: Microphone permission already granted"),!0;console.log("đ¤ AudioRecorder: Requesting microphone permission...");var t=e.config.sampleRate||e.config.outputSampleRate||44100;return(yield navigator.mediaDevices.getUserMedia({audio:{sampleRate:t,channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})).getTracks().forEach(e=>e.stop()),console.log("â
AudioRecorder: Microphone permission granted"),!0}catch(e){return console.error("â AudioRecorder: Failed to get microphone permission:",e),!1}})()}start(){var e=this;return X(function*(){try{console.log("đ¤ AudioRecorder: Requesting microphone access...");var t=yield e.checkPermissionState();t&&(console.log("đ AudioRecorder: Current permission state: ".concat(t)),"denied"===t&&console.warn('â ī¸ AudioRecorder: Permission state is "denied" - browser may not show prompt. User may need to change in browser settings.'));var n=e.config.sampleRate||e.config.outputSampleRate||44100;e.mediaStream=yield navigator.mediaDevices.getUserMedia({audio:{sampleRate:n,channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),e.audioContext=new(window.AudioContext||window.webkitAudioContext)({sampleRate:n}),"suspended"===e.audioContext.state&&(yield e.audioContext.resume());var o=e.getAudioProcessorPath();yield e.audioContext.audioWorklet.addModule(o),e.audioWorkletNode=new AudioWorkletNode(e.audioContext,"audio-processor",{processorOptions:{sampleRate:n,outputSampleRate:e.config.outputSampleRate}}),e.audioContext.createMediaStreamSource(e.mediaStream).connect(e.audioWorkletNode),e.audioWorkletNode.port.onmessage=t=>{var{type:n,data:o}=t.data;"pcm_audio_data"===n&&e.emit("audioData",o)},e.audioWorkletNode.port.postMessage({type:"setForceContinuous",data:{enabled:!0}}),console.log("â
AudioRecorder: Microphone access granted"),e.isRecording=!0,e.emit("recordingStarted")}catch(t){var i=t.message;if("NotAllowedError"===t.name||"PermissionDeniedError"===t.name){var r=yield e.checkPermissionState();"denied"===r?(i='Microphone access was blocked. To enable it: 1) Click the lock icon (đ) in your browser\'s address bar, 2) Find "Microphone" and change it to "Allow", 3) Refresh this page and try again.',console.error("â AudioRecorder: Permission explicitly denied. User must change in browser settings.")):"prompt"===r?(i='Microphone permission was denied. Click the "Voice Call" button again to see the permission prompt.',console.error('â AudioRecorder: Permission denied but state is "prompt" - user can try again.')):(i="Microphone permission was denied. Click the button again to retry, or enable microphone access in your browser settings (lock icon đ in address bar).",console.error("â AudioRecorder: Permission denied. User can try again or change in browser settings."))}else"NotFoundError"===t.name||"DevicesNotFoundError"===t.name?(i="No microphone found. Please connect a microphone and try again.",console.error("â AudioRecorder: No microphone device found.")):"NotReadableError"===t.name||"TrackStartError"===t.name?(i="Microphone is already in use by another application. Please close other apps using the microphone and try again.",console.error("â AudioRecorder: Microphone is busy or not readable.")):"SecurityError"!==t.name&&"PermissionDeniedError"!==t.name||(i="Microphone access blocked. On mobile devices, please tap the recording button directly (not from an iframe or popup).",console.error("â AudioRecorder: User agent blocked microphone access. This often happens on mobile when not called from direct user interaction."));var a=new Error(i);throw a.name=t.name,a.originalError=t,e.emit("error",a),a}})()}stop(){var e=this;return X(function*(){if(e.isRecording)try{e.audioWorkletNode&&(e.audioWorkletNode.port.postMessage({type:"flush"}),yield new Promise(e=>setTimeout(e,100))),e.mediaStream&&(e.mediaStream.getTracks().forEach(e=>e.stop()),e.mediaStream=null),e.audioContext&&"closed"!==e.audioContext.state&&(yield e.audioContext.close(),e.audioContext=null),e.audioWorkletNode=null,e.isRecording=!1,e.emit("recordingStopped")}catch(t){throw e.emit("error",t),t}})()}getStatus(){return{isRecording:this.isRecording,audioContextState:this.audioContext?this.audioContext.state:"closed"}}destroy(){this.stop()}}function ee(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}function te(e){return function(){var t=this,n=arguments;return new Promise(function(o,i){var r=e.apply(t,n);function a(e){ee(r,o,i,a,s,"next",e)}function s(e){ee(r,o,i,a,s,"throw",e)}a(void 0)})}}class ne extends L{constructor(e){super(),this.config=e,this.audioContext=null,this.audioQueue=[],this.isPlaying=!1,this.isProcessingQueue=!1,this.currentSource=null,this.audioContextReady=!1,this.initializeAudioContext().catch(()=>{})}initializeAudioContext(){var e=this;return te(function*(){if(!e.audioContext||"closed"===e.audioContext.state)try{var t={sampleRate:e.config.sampleRate||e.config.outputSampleRate||44100};if(e.audioContext=new(window.AudioContext||window.webkitAudioContext)(t),"suspended"===e.audioContext.state&&(yield e.audioContext.resume()),"running"===e.audioContext.state)try{var n=e.audioContext.sampleRate,o=e.audioContext.createBuffer(1,.01*n,n),i=e.audioContext.createBufferSource();i.buffer=o,i.connect(e.audioContext.destination),i.start(0),i.stop(e.audioContext.currentTime+.01)}catch(e){console.debug("AudioPlayer: AudioContext warmup skipped:",e)}e.audioContextReady=!0}catch(t){console.warn("AudioPlayer: Failed to pre-initialize AudioContext:",t),e.audioContextReady=!1}})()}playAudio(e){try{var t=this.createAudioBlob(e);if(this.audioQueue.push(t),!this.isPlaying&&!this.isProcessingQueue&&!this.currentSource){var n=this.audioContextReady?0:50;setTimeout(()=>this.processQueue(),n)}}catch(e){this.emit("playbackError",e)}}createAudioBlob(e){var t=new Uint8Array(e);if(t.length>=4){if(82===t[0]&&73===t[1]&&70===t[2]&&70===t[3])return new Blob([e],{type:"audio/wav"});if(255===t[0]&&!(224&~t[1]))return new Blob([e],{type:"audio/mpeg"});if(79===t[0]&&103===t[1]&&103===t[2]&&83===t[3])return new Blob([e],{type:"audio/ogg"})}return new Blob([e],{type:"audio/wav"})}processQueue(){var e=this;return te(function*(){if(!e.isProcessingQueue&&0!==e.audioQueue.length){e.isProcessingQueue=!0;var t=e.audioQueue.shift();if(t)try{var n=!e.isPlaying&&null===e.currentSource;e.audioContext&&"closed"!==e.audioContext.state||(yield e.initializeAudioContext());var o=e.audioContext;"suspended"===o.state&&(yield o.resume(),n&&(yield new Promise(e=>setTimeout(e,10)))),"running"!==o.state&&(console.warn("AudioPlayer: AudioContext not in running state:",o.state),"suspended"===o.state&&(yield o.resume(),yield new Promise(e=>setTimeout(e,10))));var i=yield t.arrayBuffer(),r=yield o.decodeAudioData(i),a=n&&!e.isPlaying&&null===e.currentSource,s=o.createBufferSource();s.buffer=r,s.connect(o.destination),e.currentSource=s,e.isPlaying=!0,a&&e.emit("playbackStarted"),s.onended=()=>{e.currentSource=null,e.isProcessingQueue=!1,e.audioQueue.length>0?setTimeout(()=>e.processQueue(),0):setTimeout(()=>{0!==e.audioQueue.length||e.currentSource||(e.isPlaying=!1,e.emit("playbackStopped"))},100)},s.start()}catch(t){e.currentSource=null,e.emit("playbackError",t),e.audioQueue.length>0?(e.isProcessingQueue=!1,setTimeout(()=>e.processQueue(),100)):(e.isPlaying=!1,e.isProcessingQueue=!1,e.emit("playbackStopped"))}else e.isProcessingQueue=!1}})()}stop(){this.stopImmediate()}stopImmediate(){var e=this.isPlaying||null!==this.currentSource;if(this.currentSource){try{this.currentSource.stop()}catch(e){}this.currentSource=null}this.isPlaying=!1,this.isProcessingQueue=!1,this.audioQueue=[],e&&this.emit("playbackStopped")}resumeAudioContext(){var e=this;return te(function*(){if(e.audioContext&&"closed"!==e.audioContext.state){if("suspended"===e.audioContext.state)try{yield e.audioContext.resume(),console.log("â
AudioPlayer: AudioContext resumed after mic permission")}catch(e){console.warn("â ī¸ AudioPlayer: Failed to resume AudioContext:",e)}}else yield e.initializeAudioContext()})()}getStatus(){return{isPlaying:this.isPlaying,isProcessingQueue:this.isProcessingQueue,queueLength:this.audioQueue.length,audioContextState:this.audioContext?this.audioContext.state:"closed"}}destroy(){this.stop(),this.audioContext&&"closed"!==this.audioContext.state&&(this.audioContext.close(),this.audioContext=null),this.audioContextReady=!1}}var oe=r(848);function ie(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)}return n}function re(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ie(Object(n),!0).forEach(function(t){ae(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ie(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ae(e,t,n){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function se(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}const ce=o=>{var{signedUrl:i,websocketUrl:r,agentId:a,appId:s,voice:c="default",language:l="en",autoReconnect:d=!0,agentSettingsOverride:u=null,onConnected:h,onDisconnected:p,onRecordingStarted:g,onRecordingStopped:m,onPlaybackStarted:v,onPlaybackStopped:f,onError:y,onMessage:x,onBargeIn:b,onStopPlaying:w,onStartConversation:S,onEndConversation:C,className:k="",style:P={},children:E}=o,[T,I]=n(!1),[A,R]=n(!1),[D,F]=n(!1),[B,_]=n("Disconnected"),O=t(null);e(()=>{console.log("đī¸ VoiceButton: Creating VoiceSDK_v2 instance for ".concat(r||i)),O.current&&(console.log("đī¸ VoiceButton: Destroying existing VoiceSDK_v2 instance"),O.current.destroy(),O.current=null);var e=new H({signedUrl:r||i,websocketUrl:r||i,agentId:a,appId:s,voice:c,language:l,autoReconnect:d,agentSettingsOverride:u,onStartConversation:S,onEndConversation:C});return e.on("connected",()=>{I(!0),_("Connected"),null==h||h()}),e.on("disconnected",()=>{I(!1),_("Disconnected"),null==p||p()}),e.on("recordingStarted",()=>{R(!0),null==g||g()}),e.on("recordingStopped",()=>{R(!1),null==m||m()}),e.on("playbackStarted",()=>{F(!0),null==v||v()}),e.on("playbackStopped",()=>{F(!1),null==f||f()}),e.on("error",e=>{null==y||y(e)}),e.on("message",e=>{null==x||x(e)}),e.on("bargeIn",e=>{null==b||b(e)}),e.on("stopPlaying",e=>{null==w||w(e)}),O.current=e,e.connect(),()=>{var e=i||r;console.log("đī¸ VoiceButton: Cleaning up VoiceSDK instance for ".concat(e)),O.current&&(O.current.destroy(),O.current=null)}},[i,r,a,s,c,l,u]);var M=function(){var e,t=(e=function*(){if(O.current)try{yield O.current.toggleRecording()}catch(e){console.error("Error toggling recording:",e)}},function(){var t=this,n=arguments;return new Promise(function(o,i){var r=e.apply(t,n);function a(e){se(r,o,i,a,s,"next",e)}function s(e){se(r,o,i,a,s,"throw",e)}a(void 0)})});return function(){return t.apply(this,arguments)}}(),U=(0,oe.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,oe.jsx)("div",{style:{fontSize:"20px"},children:A?"đ´":"đ¤"}),(0,oe.jsx)("div",{children:A?"Stop Listening":"Start Listening"})]});return(0,oe.jsx)("button",{className:"voice-button ".concat(A?"recording":""," ").concat(k),style:re({padding:"12px 24px",border:"none",borderRadius:"8px",backgroundColor:A?"#dc3545":"#007bff",color:"white",cursor:"pointer",fontSize:"16px",fontWeight:"500",transition:"all 0.2s ease"},P),onClick:M,disabled:!T,children:E||U})};function le(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}function de(e){return function(){var t=this,n=arguments;return new Promise(function(o,i){var r=e.apply(t,n);function a(e){le(r,o,i,a,s,"next",e)}function s(e){le(r,o,i,a,s,"throw",e)}a(void 0)})}}function ue(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)}return n}function he(e,t,n){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class pe{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ue(Object(n),!0).forEach(function(t){he(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ue(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({websocketUrl:e.websocketUrl||"wss://speech.talktopc.com/ws/conv",agentId:e.agentId,voice:e.voice||"default",language:e.language||"en",container:e.container||document.body,buttonText:e.buttonText||"Start Listening",buttonClass:e.buttonClass||"voice-button"},e),this.isConnected=!1,this.isRecording=!1,this.isPlaying=!1,this.voiceSDK=new H({signedUrl:this.options.websocketUrl||this.options.signedUrl,websocketUrl:this.options.websocketUrl||this.options.signedUrl,agentId:this.options.agentId,appId:this.options.appId,voice:this.options.voice,language:this.options.language}),this.setupEventListeners(),this.createButton(),this.connect()}setupEventListeners(){this.voiceSDK.on("connected",()=>{var e,t;this.isConnected=!0,this.updateButton(),null===(e=(t=this.options).onConnected)||void 0===e||e.call(t)}),this.voiceSDK.on("disconnected",()=>{var e,t;this.isConnected=!1,this.updateButton(),null===(e=(t=this.options).onDisconnected)||void 0===e||e.call(t)}),this.voiceSDK.on("recordingStarted",()=>{var e,t;this.isRecording=!0,this.updateButton(),null===(e=(t=this.options).onRecordingStarted)||void 0===e||e.call(t)}),this.voiceSDK.on("recordingStopped",()=>{var e,t;this.isRecording=!1,this.updateButton(),null===(e=(t=this.options).onRecordingStopped)||void 0===e||e.call(t)}),this.voiceSDK.on("playbackStarted",()=>{var e,t;this.isPlaying=!0,null===(e=(t=this.options).onPlaybackStarted)||void 0===e||e.call(t)}),this.voiceSDK.on("playbackStopped",()=>{var e,t;this.isPlaying=!1,null===(e=(t=this.options).onPlaybackStopped)||void 0===e||e.call(t)}),this.voiceSDK.on("error",e=>{var t,n;null===(t=(n=this.options).onError)||void 0===t||t.call(n,e)}),this.voiceSDK.on("message",e=>{var t,n;null===(t=(n=this.options).onMessage)||void 0===t||t.call(n,e)}),this.voiceSDK.on("bargeIn",e=>{var t,n;null===(t=(n=this.options).onBargeIn)||void 0===t||t.call(n,e)}),this.voiceSDK.on("stopPlaying",e=>{var t,n;null===(t=(n=this.options).onStopPlaying)||void 0===t||t.call(n,e)})}createButton(){this.button=document.createElement("button"),this.button.className=this.options.buttonClass,this.button.style.cssText="\n padding: 12px 24px;\n border: none;\n border-radius: 8px;\n background-color: #6c757d;\n color: white;\n cursor: pointer;\n font-size: 16px;\n font-weight: 500;\n transition: all 0.2s ease;\n display: flex;\n align-items: center;\n gap: 8px;\n ",this.button.addEventListener("click",()=>this.toggleRecording()),this.options.container.appendChild(this.button),this.updateButton()}updateButton(){if(this.button){var e=this.isRecording?"đ´":"đ¤",t=this.isRecording?"Stop Listening":"Start Listening";this.button.innerHTML='\n <span style="font-size: 20px;">'.concat(e,"</span>\n <span>").concat(t,"</span>\n "),this.button.disabled=!this.isConnected,this.button.style.backgroundColor=this.isRecording?"#dc3545":this.isConnected?"#007bff":"#6c757d"}}connect(){var e=this;return de(function*(){try{yield e.voiceSDK.connect()}catch(e){console.error("Failed to connect:",e)}})()}toggleRecording(){var e=this;return de(function*(){if(e.voiceSDK)try{yield e.voiceSDK.toggleRecording()}catch(e){console.error("Error toggling recording:",e)}})()}getStatus(){return{isConnected:this.isConnected,isRecording:this.isRecording,isPlaying:this.isPlaying}}updateConfig(e){this.voiceSDK.updateConfig(e)}destroy(){this.button&&this.button.parentNode&&this.button.parentNode.removeChild(this.button),this.voiceSDK&&this.voiceSDK.destroy()}}function ge(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}function me(e){return function(){var t=this,n=arguments;return new Promise(function(o,i){var r=e.apply(t,n);function a(e){ge(r,o,i,a,s,"next",e)}function s(e){ge(r,o,i,a,s,"throw",e)}a(void 0)})}}class ve{constructor(e){console.log("đ AgentSDK v2.1.8 initialized with config:",e),this.config=e,this.voiceSDK=null,this.isConnected=!1,this.isListening=!1,this.wasListening=!1,this._resumeInfo=null,this.onConnected=()=>{},this.onDisconnected=()=>{},this.onError=e=>console.error("SDK Error:",e),this.onTranscript=e=>{},this.onAgentSpeaking=e=>{},this.onConversationStart=e.onConversationStart||(()=>{}),this.onConversationEnd=e.onConversationEnd||(()=>{}),this.onBargeIn=e.onBargeIn||(()=>{}),this.onAudioStartPlaying=e.onAudioStartPlaying||(()=>{}),this.onAudioStoppedPlaying=e.onAudioStoppedPlaying||(()=>{}),this.onSubtitleDisplay=e.onSubtitleDisplay||(()=>{})}checkResumeBeforeConnect(){try{var e=new H({signedUrl:"wss://placeholder",autoReconnect:!1,agentId:this.config.agentId,appId:this.config.appId,language:this.config.language||"en",protocolVersion:2}).checkAndResume();return e?(console.log("đ [AGENT SDK] Found resume state before connect:",e),this._resumeInfo=e,e):null}catch(e){return console.warn("â ī¸ [AGENT SDK] Error checking resume:",e),null}}connect(e){var t=this;return me(function*(){try{if(!e)throw new Error("signedUrl is required");if(t.voiceSDK&&(console.log("đ AgentSDK: Cleaning up existing connection"),t.voiceSDK.destroy(),t.voiceSDK=null),t.voiceSDK=new H({signedUrl:e,autoReconnect:!1,agentId:t.config.agentId,appId:t.config.appId,language:t.config.language||"en",agentSettingsOverride:t.config.agentSettingsOverride,protocolVersion:2,outputContainer:t.config.outputContainer||"raw",outputEncoding:t.config.outputEncoding||"pcm",outputSampleRate:t.config.outputSampleRate||44100,outputChannels:t.config.outputChannels||1,outputBitDepth:t.config.outputBitDepth||16}),t._resumeInfo&&(console.log("đ [AGENT SDK] Using stored resume info:",t._resumeInfo),console.log(" From:",t._resumeInfo.fromPage,"â To:",t._resumeInfo.toPage)),t.voiceSDK.on("connected",()=>{t.isConnected=!0,t.onConnected()}),setTimeout(()=>{t.voiceSDK&&t.voiceSDK.isConnected&&!t.isConnected&&(t.isConnected=!0,t.onConnected())},10),t.voiceSDK.on("disconnected",e=>{if(t.isConnected=!1,e&&1008===e.code&&e.reason&&(e.reason.includes("Domain not whitelisted")||e.reason.includes("domain")||e.reason.includes("whitelist"))){var n=new Error("DOMAIN_NOT_WHITELISTED");n.reason=e.reason,n.code=e.code,t.onError(n)}if((t.isListening||t.wasListening)&&(console.log("đ¤ [AGENT SDK] disconnected event - calling onConversationEnd hook (isListening:",t.isListening,", wasListening:",t.wasListening,")"),t.onConversationEnd&&"function"==typeof t.onConversationEnd))try{t.onConversationEnd(),console.log("đ¤ [AGENT SDK] â
onConversationEnd hook called from disconnected event"),t.wasListening=!1}catch(e){console.error("đ¤ [AGENT SDK] â Error calling onConversationEnd from disconnected:",e)}t.onDisconnected()}),t.voiceSDK.on("domainError",e=>{t.onError(e)}),t.voiceSDK.on("error",e=>{t.onError(e)}),t.voiceSDK.on("message",e=>{t.handleWebSocketMessage(e)}),t.voiceSDK.on("recordingStarted",()=>{if(t.isListening=!0,t.wasListening=!0,t.onConversationStart&&"function"==typeof t.onConversationStart)try{t.onConversationStart()}catch(e){console.error("đ¤ [AGENT SDK] â Error calling onConversationStart:",e)}}),t.voiceSDK.on("recordingStopped",()=>{console.log("đ¤ [AGENT SDK] recordingStopped event received");var e=t.isListening;if(t.isListening=!1,e&&t.onConversationEnd&&"function"==typeof t.onConversationEnd)try{console.log("đ¤ [AGENT SDK] â
Calling onConversationEnd hook from recordingStopped"),t.onConversationEnd(),console.log("đ¤ [AGENT SDK] â
onConversationEnd hook called successfully"),t.wasListening=!1}catch(e){console.error("đ¤ [AGENT SDK] â Error calling onConversationEnd:",e)}}),t.voiceSDK.on("playbackStarted",()=>{t.onAgentSpeaking(!0),t.onAudioStartPlaying()}),t.voiceSDK.on("playbackStopped",()=>{t.onAgentSpeaking(!1),t.onAudioStoppedPlaying()}),t.voiceSDK.on("bargeIn",e=>{t.onBargeIn(e)}),t.voiceSDK.on("transcriptDisplay",e=>{console.log("đ [AGENT SDK] transcriptDisplay event received:",e),e&&e.text&&(console.log("đ [AGENT SDK] Calling onTranscript with text:",e.text),t.onTranscript&&"function"==typeof t.onTranscript?t.onTranscript(e.text):console.warn("đ [AGENT SDK] â ī¸ onTranscript is not a function!",typeof t.onTranscript)),t.onSubtitleDisplay(e)}),t._pendingToolHandlers&&t._pendingToolHandlers.size>0)for(var[n,o]of(console.log("đ§ AgentSDK: Registering ".concat(t._pendingToolHandlers.size," pending tool handlers")),t._pendingToolHandlers))t.voiceSDK.registerToolHandler(n,o);yield t.voiceSDK.connect()}catch(e){throw t.onError(e),e}})()}handleWebSocketMessage(e){switch(e.t||e.type){case"connected":case"hello_ack":console.log("Session started successfully");break;case"user_transcript":this.onTranscript(e.user_transcription||e.text||e.transcript);break;case"agent_response":case"barge_in":case"stop_playing":default:break;case"error":this.onError(new Error(e.message||e.error||"Unknown error"))}}startListening(){var e=this;return me(function*(){if(console.log("đ¤ AgentSDK: startListening() called"),!e.voiceSDK)throw console.error("â AgentSDK: No voiceSDK instance available"),new Error("No voiceSDK instance available");try{console.log("đ¤ AgentSDK: Starting recording..."),yield e.voiceSDK.startRecording(),console.log("â
AgentSDK: Recording started successfully")}catch(e){throw console.error("â AgentSDK: Failed to start recording:",e),e}})()}stopListening(){this.voiceSDK&&this.voiceSDK.stopRecording()}hangup(){this.voiceSDK&&this.voiceSDK.hangup()}updateVariables(e){this.voiceSDK&&this.isConnected&&this.voiceSDK.sendMessage({t:"update_variables",variables:e})}disconnect(){this.voiceSDK&&(this.voiceSDK.destroy(),this.voiceSDK=null),this.isConnected=!1,this.isListening=!1}registerToolHandler(e,t){if(this.voiceSDK)return this.voiceSDK.registerToolHandler(e,t);this._pendingToolHandlers||(this._pendingToolHandlers=new Map),this._pendingToolHandlers.set(e,t),console.log("đ§ AgentSDK: Queued tool handler '".concat(e,"' for registration after connect"))}unregisterToolHandler(e){if(this.voiceSDK)return this.voiceSDK.unregisterToolHandler(e);this._pendingToolHandlers&&this._pendingToolHandlers.delete(e)}hasToolHandler(e){var t;return this.voiceSDK?this.voiceSDK.hasToolHandler(e):(null===(t=this._pendingToolHandlers)||void 0===t?void 0:t.has(e))||!1}getRegisteredTools(){return this.voiceSDK?this.voiceSDK.getRegisteredTools():this._pendingToolHandlers?Array.from(this._pendingToolHandlers.keys()):[]}}function fe(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}function ye(){var e=navigator.userAgent,t=/iPad|iPhone|iPod/.test(e)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,n=/Android/.test(e),o=/Mac/.test(e)&&!t,i=/Win/.test(e),r=/Chrome/.test(e)&&!/Edg|OPR/.test(e),a=/Safari/.test(e)&&!/Chrome/.test(e),s=/Firefox/.test(e),c=/Edg/.test(e),l=/SamsungBrowser/.test(e),d="unknown";t?d="safari":l?d="samsung":r?d="chrome":a?d="safari":s?d="firefox":c&&(d="edge");var u="unknown";return t?u="ios":n?u="android":o?u="mac":i&&(u="windows"),{platform:u,browser:d,isIOS:t,isAndroid:n,isMac:o,isWindows:i,isMobile:t||n,isDesktop:!t&&!n}}function xe(){return be.apply(this,arguments)}function be(){var e;return e=function*(){try{if(navigator.permissions&&navigator.permissions.query)return(yield navigator.permissions.query({name:"microphone"})).state}catch(e){console.log("â ī¸ MicPermissionUtils: Permissions API not available or not supported for microphone")}return"unknown"},be=function(){var t=this,n=arguments;return new Promise(function(o,i){var r=e.apply(t,n);function a(e){fe(r,o,i,a,s,"next",e)}function s(e){fe(r,o,i,a,s,"throw",e)}a(void 0)})},be.apply(this,arguments)}function we(e){var{platform:t,browser:n}=e,o={ios:{title:"Enable Microphone on iPhone/iPad",icon:"đą",steps:["Tap the <strong>lock icon đ</strong>, <strong>information icon âšī¸</strong>, or <strong>AA icon</strong> in the address bar","Tap <strong>Website Settings</strong> or <strong>Permissions</strong>","Find <strong>Microphone</strong> and set it to <strong>Allow</strong>","Return to this page and refresh"],altTitle:"Alternative Method",altSteps:["Open the <strong>Settings</strong> app on your device","Scroll down and tap <strong>Safari</strong> (or your browser app)",'Tap <strong>Microphone</strong> under "Settings for Websites"',"Set it to <strong>Allow</strong> or <strong>Ask</strong>","Return to this page and refresh"],note:"On iOS, you can also change permissions in the browser address bar or in device Settings.",canOpenSettings:!0,settingsButtonText:"Open Settings App"},android_chrome:{title:"Enable Microphone in Chrome",icon:"đ¤",steps:["Tap the <strong>lock icon đ</strong>, <strong>information icon âšī¸</strong>, or <strong>settings icon âŽ</strong> in the address bar","Tap <strong>Permissions</strong>","Tap <strong>Microphone</strong>","Select <strong>Allow</strong>","The page will refresh automatically"],altTitle:"Alternative Method",altSteps:["Tap the <strong>⎠menu</strong> (three dots)","Tap <strong>Settings â Site settings â Microphone</strong>","Find this website and set to <strong>Allow</strong>"],canOpenSettings:!0,settingsButtonText:"Open App Settings"},android_firefox:{title:"Enable Microphone in Firefox",icon:"đĻ",steps:["Tap the <strong>lock icon đ</strong> or <strong>information icon âšī¸</strong> in the address bar","Tap <strong>Edit Site Permissions</strong>","Toggle <strong>Microphone</strong> to enabled","Refresh the page"],canOpenSettings:!1},android_samsung:{title:"Enable Microphone in Samsung Browser",icon:"đą",steps:["Tap the <strong>menu icon</strong> (three lines)","Tap <strong>Settings â Sites and downloads</strong>","Tap <strong>Site permissions â Microphone</strong>","Find this website and set to <strong>Allow</strong>","Return and refresh the page"],canOpenSettings:!1},desktop_chrome:{title:"Enable Microphone in Chrome",icon:"đ",steps:["Click the <strong>lock icon đ</strong> or <strong>information icon âšī¸</strong> in the address bar (left side)","Find <strong>Microphone</strong> in the dropdown menu",'Change it from "Block" to <strong>Allow</strong>',"Click the <strong>Refresh</strong> button or press F5"],showAddressBarHint:!0,canOpenSettings:!1},desktop_safari:{title:"Enable Microphone in Safari",icon:"đ§",steps:["Click <strong>Safari</strong> in the menu bar (top of screen)","Click <strong>Settings for This Website...</strong>","Find <strong>Microphone</strong> in the popup","Change it to <strong>Allow</strong>","Close settings and refresh the page"],canOpenSettings:!1},desktop_firefox:{title:"Enable Microphone in Firefox",icon:"đĻ",steps:["Click the <strong>lock icon đ</strong> in the address bar",'Click the <strong>X</strong> next to "Blocked" for Microphone',"Refresh the page (press F5)","Click <strong>Allow</strong> when prompted again"],note:"Firefox requires you to clear the block and then re-allow on the next prompt.",showAddressBarHint:!0,canOpenSettings:!1},desktop_edge:{title:"Enable Microphone in Edge",icon:"đ",steps:["Click the <strong>lock icon đ</strong> in the address bar","Find <strong>Microphone</strong> in the permissions list","Change it to <strong>Allow</strong>","Refresh the page"],showAddressBarHint:!0,canOpenSettings:!1},unknown:{title:"Enable Microphone Access",icon:"đ¤",steps:["Look for a <strong>lock icon đ</strong>, <strong>information icon âšī¸</strong>, or <strong>settings icon</strong> in your browser's address bar","Find the <strong>Microphone</strong> permission setting","Change it to <strong>Allow</strong>","Refresh this page"],canOpenSettings:!1}};return"ios"===t?o.ios:"android"===t?o["android_".concat(n)]||o.android_chrome:o["desktop_".concat(n)]||o.desktop_chrome}function Se(e){var{isIOS:t,isAndroid:n,browser:o}=e;if(t)try{return window.location.href="app-settings:",!0}catch(e){return console.warn("Could not open iOS settings:",e),!1}if(n&&"chrome"===o)try{return window.location.href="intent:#Intent;action=android.settings.APPLICATION_DETAILS_SETTINGS;data=package:com.android.chrome;end",!0}catch(e){return console.warn("Could not open Android settings:",e),!1}return!1}class Ce{constructor(){this.overlay=null,this.modal=null}createOverlay(){var e=document.createElement("div");return e.className="mic-permission-overlay",e.style.cssText="\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.6);\n backdrop-filter: blur(4px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n padding: 20px;\n animation: mic-fadeIn 0.2s ease-out;\n ",document.getElementById("mic-permission-styles")||this.injectStyles(),e}injectStyles(){if(!document.getElementById("mic-permission-styles")){var e=document.createElement("style");e.id="mic-permission-styles",e.textContent="\n @keyframes mic-fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n \n @keyframes mic-slideUp {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n \n @keyframes mic-bounce {\n 0%, 100% { transform: translateY(0); }\n 50% { transform: translateY(-5px); }\n }\n \n .mic-permission-overlay {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.6);\n backdrop-filter: blur(4px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n padding: 20px;\n animation: mic-fadeIn 0.2s ease-out;\n }\n \n .mic-permission-modal {\n background: #ffffff;\n border-radius: 16px;\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);\n max-width: 480px;\n width: 100%;\n padding: 32px;\n position: relative;\n animation: mic-slideUp 0.3s ease-out;\n max-height: 90vh;\n overflow-y: auto;\n }\n \n .mic-permission-modal__close {\n position: absolute;\n top: 16px;\n right: 16px;\n background: none;\n border: none;\n font-size: 20px;\n cursor: pointer;\n color: #6b7280;\n width: 32px;\n height: 32px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background 0.2s;\n }\n \n .mic-permission-modal__close:hover {\n background: #e5e7eb;\n }\n \n .mic-permission-modal__icon {\n font-size: 48px;\n text-align: center;\n margin-bottom: 16px;\n }\n \n .mic-permission-modal__title {\n font-size: 24px;\n font-weight: 700;\n color: #111827;\n margin: 0 0 12px;\n line-height: 1.3;\n text-align: center;\n }\n \n .mic-permission-modal__description {\n color: #6b7280;\n font-size: 16px;\n line-height: 1.6;\n margin: 0 0 20px;\n text-align: center;\n }\n \n .mic-permission-modal__highlight {\n display: flex;\n align-items: center;\n gap: 12px;\n background: linear-gradient(135deg, #dbeafe, #ede9fe);\n padding: 16px 20px;\n border-radius: 8px;\n margin-bottom: 20px;\n border: 1px solid #bfdbfe;\n }\n \n .mic-permission-modal__highlight-icon {\n font-size: 24px;\n animation: mic-bounce 1s infinite;\n }\n \n .mic-permission-modal__status {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n background: #fef2f2;\n color: #ef4444;\n padding: 12px 16px;\n border-radius: 8px;\n margin-bottom: 20px;\n font-weight: 500;\n }\n \n .mic-permission-modal__note {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n background: #fffbeb;\n color: #92400e;\n padding: 12px 16px;\n border-radius: 8px;\n margin-bottom: 20px;\n font-size: 14px;\n line-height: 1.5;\n border: 1px solid #fde68a;\n }\n \n .mic-permission-modal__steps {\n margin-bottom: 20px;\n }\n \n .mic-permission-modal__steps h3 {\n font-size: 14px;\n font-weight: 600;\n color: #6b7280;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n margin: 0 0 12px;\n }\n \n .mic-permission-modal__steps ol {\n margin: 0;\n padding-left: 24px;\n counter-reset: step-counter;\n list-style: none;\n }\n \n .mic-permission-modal__steps li {\n position: relative;\n padding: 12px 0 12px 16px;\n border-left: 2px solid #e5e7eb;\n color: #111827;\n font-size: 15px;\n line-height: 1.5;\n counter-increment: step-counter;\n }\n \n .mic-permission-modal__steps li::before {\n content: counter(step-counter);\n position: absolute;\n left: -14px;\n top: 10px;\n width: 24px;\n height: 24px;\n background: #4f46e5;\n color: white;\n border-radius: 50%;\n font-size: 12px;\n font-weight: 600;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n \n .mic-permission-modal__steps li:last-child {\n border-left-color: transparent;\n }\n \n .mic-permission-modal__actions {\n display: flex;\n flex-direction: column;\n gap: 10px;\n margin-top: 24px;\n }\n \n .mic-permission-modal__btn {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 14px 24px;\n border-radius: 8px;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n border: none;\n width: 100%;\n }\n \n .mic-permission-modal__btn--primary {\n background: #4f46e5;\n color: white;\n }\n \n .mic-permission-modal__btn--primary:hover {\n background: #4338ca;\n transform: translateY(-1px);\n }\n \n .mic-permission-modal__btn--secondary {\n background: #e5e7eb;\n color: #111827;\n }\n \n .mic-permission-modal__btn--secondary:hover {\n background: #d1d5db;\n }\n \n .mic-permission-modal__footer {\n text-align: center;\n font-size: 13px;\n color: #6b7280;\n margin-top: 20px;\n margin-bottom: 0;\n }\n \n .mic-permission-modal__visual-guide {\n width: 100%;\n max-width: 380px;\n height: auto;\n margin: 20px auto;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);\n display: block;\n }\n \n .mic-permission-modal__visual-guide-container {\n text-align: center;\n margin: 20px 0;\n }\n \n @media (max-width: 480px) {\n .mic-permission-modal {\n padding: 24px 20px;\n margin: 10px;\n max-height: 85vh;\n }\n \n .mic-permission-modal__title {\n font-size: 20px;\n }\n \n .mic-permission-modal__icon {\n font-size: 40px;\n }\n \n .mic-permission-modal__visual-guide {\n max-width: 100%;\n }\n }\n ",document.head.appendChild(e)}}close(){this.overlay&&this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay),this.overlay=null,this.modal=null}show(){this.overlay&&this.modal&&document.body.appendChild(this.overlay)}}function ke(e,t){var n=new Ce,o=n.createOverlay(),i=ye(),r=document.createElement("div");return r.className="mic-permission-modal",r.innerHTML='\n <div class="mic-permission-modal__icon">đ¤</div>\n <h2 class="mic-permission-modal__title">Enable Your Microphone</h2>\n <p class="mic-permission-modal__description">\n To start a voice call with our agent, we need access to your microphone.\n </p>\n <div class="mic-permission-modal__highlight">\n <span class="mic-permission-modal__highlight-icon">đ</span>\n <span>Please click <strong>"Allow"</strong> on the next popup</span>\n </div>\n '.concat(i.isIOS?'\n <div class="mic-permission-modal__note">\n <span>âšī¸</span>\n <span>On iPhone/iPad, you may need to allow microphone access in your device Settings.</span>\n </div>\n ':"",'\n <div class="mic-permission-modal__actions">\n <button class="mic-permission-modal__btn mic-permission-modal__btn--primary" data-action="accept">\n Continue\n </button>\n <button class="mic-permission-modal__btn mic-permission-modal__btn--secondary" data-action="cancel">\n Not Now\n </button>\n </div>\n '),o.appendChild(r),n.overlay=o,n.modal=r,r.querySelector('[data-action="accept"]').addEventListener("click",()=>{n.close(),e()}),r.querySelector('[data-action="cancel"]').addEventListener("click",()=>{n.close(),t()}),o.addEventListener("click",e=>{e.target===o&&(n.close(),t())}),n.show(),n}function Pe(e,t){var n,o,i,r=new Ce,a=r.createOverlay(),s=ye(),c=we(s),l=document.createElement("div");l.className="mic-permission-modal";var d="";c.altSteps&&c.altSteps.length>0&&(d='\n <div style="margin-top: 20px; border-top: 1px solid #e5e7eb; padding-top: 16px;">\n <button class="mic-permission-modal__alt-toggle" style="background: none; border: none; color: #4f46e5; font-size: 14px; font-weight: 500; cursor: pointer; padding: 0; margin-bottom: 12px;">\n âŧ '.concat(c.altTitle||"Alternative method",'\n </button>\n <ol style="margin: 0; padding-left: 20px; display: none;">\n ').concat(c.altSteps.map(e=>'<li style="padding: 8px 0; font-size: 14px; color: #6b7280;">'.concat(e,"</li>")).join(""),"\n </ol>\n </div>\n "));var u=function(e){var{platform:t,browser:n}=e,o=document.getElementsByTagName("script"),i="";for(var r of o){var a=r.src;if(a&&(a.includes("agent-widget.js")||a.includes("ttp-agent-sdk")||a.includes("ttp-sdk-front")))try{new URL(a),i=a.substring(0,a.lastIndexOf("/"));break}catch(e){var s=a.match(/^(.*\/)[^\/]+$/);if(s){i=s[1];break}}}var c;if(c="ios"===t?"ios-settings.svg":"android"===t?"android-chrome.svg":"chrome"===n?"desktop-chrome.svg":"safari"===n?"desktop-safari.svg":"firefox"===n?"desktop-firefox.svg":"edge"===n?"desktop-edge.svg":"desktop-chrome.svg",!i||""===i||i.startsWith("/")){for(var l of o){var d=l.src;if(d&&(d.includes("cdn.talktopc.com")||d.includes("talktopc.com"))){if(d.includes("/ttp-agent-sdk/")||d.includes("/ttp-sdk-front/")){var u=d.match(/(https?:\/\/[^\/]+(?:\/[^\/]+)*)/);if(u){i=u[1].replace(/\/[^\/]+\.js$/,"");break}}if(!i&&(d.includes("cdn.talktopc.com")||d.includes("talktopc.com"))){i="https://cdn.talktopc.com/ttp-agent-sdk";break}}}if(!i||""===i)if(window.location.hostname.includes("cdn.talktopc.com")||window.location.hostname.includes("talktopc.com"))i="https://cdn.talktopc.com/ttp-agent-sdk";else{var h=window.location.pathname.split("/");h.pop(),(i=window.location.origin+h.join("/"))&&i!==window.location.origin||(i=window.location.origin)}}i=i.replace(/\/$/,"");var p="".concat(i,"/shared/mic-permission-assets/").concat(c);return"undefined"!=typeof console&&console.log&&console.log("[MicPermission] Visual guide path:",p,"Base path:",i,"Platform:",t,"Browser:",n),p}(s);l.innerHTML='\n <button class="mic-permission-modal__close" data-action="close">â</button>\n <div style="display: flex; align-items: center; gap: 12px; margin-bottom: 20px;">\n <span style="font-size: 32px;">'.concat(c.icon,'</span>\n <h2 class="mic-permission-modal__title" style="text-align: left; margin: 0;">').concat(c.title,'</h2>\n </div>\n <div class="mic-permission-modal__status">\n <span>đĢ</span>\n <span>Microphone access is currently blocked</span>\n </div>\n ').concat(c.note?'\n <div class="mic-permission-modal__note">\n <span>âšī¸</span>\n <span>'.concat(c.note,"</span>\n </div>\n "):"",'\n <div class="mic-permission-modal__visual-guide-container">\n <img src="').concat(u,'" alt="Visual guide for enabling microphone" class="mic-permission-modal__visual-guide" \n onerror="console.error(\'[MicPermission] Failed to load image:\', this.src); this.style.display=\'none\';" \n onload="console.log(\'[MicPermission] Image loaded successfully:\', this.src);" />\n </div>\n <div class="mic-permission-modal__steps">\n <h3>Follow these steps:</h3>\n <ol>\n ').concat(c.steps.map(e=>"<li>".concat(e,"</li>")).join(""),"\n </ol>\n </div>\n ").concat(d,'\n <div class="mic-permission-modal__actions">\n ').concat(c.canOpenSettings?'\n <button class="mic-permission-modal__btn mic-permission-modal__btn--primary" data-action="open-settings">\n '.concat(c.settingsButtonText||"Open Settings","\n </button>\n "):"","\n ").concat(c.showAddressBarHint?'\n <button class="mic-permission-modal__btn mic-permission-modal__btn--primary" data-action="show-hint">\n Show Me Where\n </button>\n ':"",'\n <button class="mic-permission-modal__btn mic-permission-modal__btn--secondary" data-action="refresh">\n đ Refresh Page\n </button>\n </div>\n <p class="mic-permission-modal__footer">\n After enabling microphone access, return here and click "Refresh Page"\n </p>\n '),a.appendChild(l),r.overlay=a,r.modal=l,null===(n=l.querySelector('[data-action="close"]'))||void 0===n||n.addEventListener("click",()=>{r.close(),e()}),null===(o=l.querySelector('[data-action="open-settings"]'))||void 0===o||o.addEventListener("click",()=>{Se(s)}),null===(i=l.querySelector('[data-action="refresh"]'))||void 0===i||i.addEventListener("click",()=>{window.location.reload()});var h=l.querySelector('[data-action="show-hint"]');h&&h.addEventListener("click",()=>{r.close(),e(),function(){var e=document.getElementById("mic-address-bar-hint");e&&e.remove(),ye();var t=document.getElementsByTagName("script"),n="";for(var o of t){var i=o.src;if(i&&(i.includes("agent-widget.js")||i.includes("ttp-agent-sdk")||i.includes("ttp-sdk-front")))try{new URL(i),n=i.substring(0,i.lastIndexOf("/"));break}catch(e){var r=i.match(/^(.*\/)[^\/]+$/);if(r){n=r[1];break}}}if(!n||""===n||n.startsWith("/")){for(var a of t){var s=a.src;if(s&&(s.includes("cdn.talktopc.com")||s.includes("talktopc.com"))){if(s.includes("/ttp-agent-sdk/")||s.includes("/ttp-sdk-front/")){var c=s.match(/(https?:\/\/[^\/]+(?:\/[^\/]+)*)/);if(c){n=c[1].replace(/\/[^\/]+\.js$/,"");break}}if(!n&&(s.includes("cdn.talktopc.com")||s.includes("talktopc.com"))){n="https://cdn.talktopc.com/ttp-agent-sdk";break}}}if(!n||""===n)if(window.location.hostname.includes("cdn.talktopc.com")||window.location.hostname.includes("talktopc.com"))n="https://cdn.talktopc.com/ttp-agent-sdk";else{var l=window.location.pathname.split("/");l.pop(),(n=window.location.origin+l.join("/"))&&n!==window.location.origin||(n=window.location.origin)}}n=n.replace(/\/$/,"");var d="".concat(n,"/shared/mic-permission-assets/address-bar-hint.svg"),u=document.createElement("div");u.id="mic-address-bar-hint",u.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n z-index: 10001;\n padding: 10px 20px;\n pointer-events: none;\n animation: mic-fadeIn 0.3s ease-out;\n display: flex;\n justify-content: center;\n ";var h=document.createElement("div");h.style.cssText="\n display: flex;\n align-items: center;\n gap: 12px;\n background: #f59e0b;\n color: white;\n padding: 12px 20px;\n border-radius: 0 0 8px 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n pointer-events: all;\n animation: mic-slideDown 0.3s ease-out;\n max-width: 540px;\n ";var p=document.createElement("div");p.style.cssText="\n flex-shrink: 0;\n ";var g=document.createElement("img");g.src=d,g.alt="Address bar hint",g.style.cssText="\n width: auto;\n height: 80px;\n display: block;\n ",g.onerror=()=>{p.style.display="none"},p.appendChild(g);var m=document.createElement("div");m.style.cssText="\n display: flex;\n flex-direction: column;\n gap: 4px;\n flex: 1;\n ";var v=document.createElement("div");v.style.cssText="\n font-size: 15px;\n font-weight: 500;\n ",v.innerHTML="Click the <strong>lock icon đ</strong>, <strong>information icon âšī¸</strong>, or <strong>settings icon âŽ</strong> in the address bar to enable microphone";var f=document.createElement("button");if(f.style.cssText="\n background: rgba(255, 255, 255, 0.2);\n border: none;\n color: white;\n width: 28px;\n height: 28px;\n border-radius: 50%;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n transition: background 0.2s;\n flex-shrink: 0;\n ",f.textContent="â",f.addEventListener("click",()=>{u.remove()}),f.addEventListener("mouseenter",()=>{f.style.background="rgba(255, 255, 255, 0.3)"}),f.addEventListener("mouseleave",()=>{f.style.background="rgba(255, 255, 255, 0.2)"}),!document.getElementById("mic-address-bar-hint-styles")){var y=document.createElement("style");y.id="mic-address-bar-hint-styles",y.textContent="\n @keyframes mic-slideDown {\n from {\n opacity: 0;\n transform: translateY(-100%);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n \n @keyframes mic-pointUp {\n 0%, 100% {\n transform: translate(0, 0);\n }\n 50% {\n transform: translate(-5px, -5px);\n }\n }\n ",document.head.appendChild(y)}m.appendChild(v),h.appendChild(p),h.appendChild(m),h.appendChild(f),u.appendChild(h),document.body.appendChild(u),setTimeout(()=>{u.parentNode&&(u.style.opacity="0",u.style.transition="opacity 0.3s ease-out",setTimeout(()=>{u.parentNode&&u.remove()},300))},1e4)}()});var p=l.querySelector(".mic-permission-modal__alt-toggle");if(p&&c.altSteps){var g=p.nextElementSibling;g&&(g.style.display="none",p.addEventListener("click",()=>{"none"===g.style.display?(g.style.display="block",p.innerHTML="âŧ ".concat(c.altTitle||"Alternative method")):(g.style.display="none",p.innerHTML="âļ ".concat(c.altTitle||"Alternative method"))}))}return a.addEventListener("click",t=>{t.target===a&&(r.close(),e())}),r.show(),r}function Ee(e){var t=new Ce,n=t.createOverlay(),o=document.createElement("div");return o.className="mic-permission-modal",o.innerHTML='\n <div class="mic-permission-modal__icon">đ¤â</div>\n <h2 class="mic-permission-modal__title">No Microphone Found</h2>\n <p class="mic-permission-modal__description">\n We couldn\'t detect a microphone on your device. Please make sure:\n </p>\n <ul style="list-style: none; padding: 0; margin: 0 0 24px;">\n <li style="padding: 10px 0 10px 32px; position: relative; color: #111827; border-bottom: 1px solid #e5e7eb;">\n <span style="position: absolute; left: 0; font-size: 18px;">â</span>\n Your microphone is properly connected\n </li>\n <li style="padding: 10px 0 10px 32px; position: relative; color: #111827; border-bottom: 1px solid #e5e7eb;">\n <span style="position: absolute; left: 0; font-size: 18px;">â</span>\n Your microphone is not muted at the hardware level\n </li>\n <li style="padding: 10px 0 10px 32px; position: relative; color: #111827;">\n <span style="position: absolute; left: 0; font-size: 18px;">â</span>\n No other app is exclusively using the microphone\n </li>\n </ul>\n <div class="mic-permission-modal__actions">\n <button class="mic-permission-modal__btn mic-permission-modal__btn--primary" data-action="retry">\n Retry\n </button>\n <button class="mic-permission-modal__btn mic-permission-modal__btn--secondary" data-action="close">\n Close\n </button>\n </div>\n ',n.appendChild(o),t.overlay=n,t.modal=o,o.querySelector('[data-action="retry"]').addEventListener("click",()=>{window.location.reload()}),o.querySelector('[data-action="close"]').addEventListener("click",()=>{t.close(),e()}),n.addEventListener("click",o=>{o.target===n&&(t.close(),e())}),t.show(),t}function Te(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}function Ie(e){return function(){var t=this,n=arguments;return new Promise(function(o,i){var r=e.apply(t,n);function a(e){Te(r,o,i,a,s,"next",e)}function s(e){Te(r,o,i,a,s,"throw",e)}a(void 0)})}}class Ae{constructor(e){this.config=e,this.audioStream=null,this.callStartTime=null,this.callTimerInterval=null,this.sdk=null,this.isActive=!1,this.shadowRoot=e.shadowRoot||document,this.sdk=new ve({agentId:e.agentId,appId:e.appId,signedUrl:e.signedUrl,agentSettingsOverride:e.agentSettingsOverride,variables:e.variables||{},language:e.language||"en",outputContainer:e.outputContainer,outputEncoding:e.outputEncoding,outputSampleRate:e.outputSampleRate,outputChannels:e.outputChannels,outputBitDepth:e.outputBitDepth,onConversationStart:e.onConversationStart,onConversationEnd:e.onConversationEnd,onBargeIn:e.onBargeIn,onAudioStartPlaying:e.onAudioStartPlaying,onAudioStoppedPlaying:e.onAudioStoppedPlaying,onSubtitleDisplay:e.onSubtitleDisplay}),this.setupSDKEventHandlers(),this.checkAndHandleResume()}checkAndHandleResume(){if(this._resumeInfo)return console.log("đ [VOICE INTERFACE] Returning cached resume info:",this._resumeInfo),this._resumeInfo;var e=this.sdk.checkResumeBeforeConnect();return e?(console.log("đ [WIDGET] Auto-resuming call:",e),console.log(" From:",e.fromPage,"â To:",e.toPage),this._resumeInfo=e,this.config.onResume&&this.config.onResume(e),e):null}setupSDKEventHandlers(){this.sdk.onTranscript=e=>{console.log("đ [VOICE INTERFACE] onTranscript called with text:",e),this.updateTranscript(e)},this.sdk.onAgentSpeaking=e=>{var t=this.shadowRoot.getElementById("voiceAvatarActive");t&&(e?t.classList.add("speaking"):t.classList.remove("speaking"))},this.sdk.onDisconnected=()=>{console.log("đ WebSocket disconnected, hanging up call..."),this.isActive&&(this.isActive=!1,this.endVoiceCall())},this.sdk.onError=e=>{console.error("â Voice SDK Error:",e),e&&("DOMAIN_NOT_WHITELISTED"===e.message||e.message&&e.message.includes("Domain not whitelisted"))?this.showDomainError():this.showError(e.message||e)}}t(e){var t,n,o=this.config.language||"en";return((null===(t=this.config.translations)||void 0===t?void 0:t[o])||(null===(n=this.config.translations)||void 0===n?void 0:n.en)||{})[e]||e}getText(e,t){return void 0!==this.config[e]&&null!==this.config[e]?this.config[e]:this.t(t)}getTooltip(e){var t,n=null===(t=this.config.tooltips)||void 0===t?void 0:t[e];return null!=n?n:{mute:this.t("mute"),speaker:this.t("speaker"),endCall:this.t("endCall")}[e]||""}generateHTML(){return'<div class="voice-interface" id="voiceInterface">\n \x3c!-- Before Call State --\x3e\n <div id="voiceIdleState">\n <div class="voice-avatar" id="voiceAvatar">đ¤</div>\n <div class="voice-status">\n <div class="voice-status-title">'.concat(this.getText("startCallTitle","clickToStartCall"),'</div>\n <div class="voice-status-subtitle">').concat(this.getText("startCallSubtitle","realTimeVoice"),'</div>\n </div>\n <button class="start-call-btn" id="startCallBtn">\n <svg width="32" height="32" viewBox="0 0 24 24" fill="currentColor">\n <path d="M20.01 15.38c-1.23 0-2.42-.2-3.53-.56-.35-.12-.74-.03-1.01.24l-1.57 1.97c-2.83-1.35-5.48-3.9-6.89-6.83l1.95-1.66c.27-.28.35-.67.24-1.02-.37-1.11-.56-2.3-.56-3.53 0-.54-.45-.99-.99-.99H4.19C3.65 3 3 3.24 3 3.99 3 13.28 10.73 21 20.01 21c.71 0 .99-.63.99-1.18v-3.45c0-.54-.45-.99-.99-.99z"/>\n </svg>\n <span>').concat(this.getText("startCallButtonText","startCall"),'</span>\n </button>\n </div>\n \x3c!-- During Call State --\x3e\n <div id="voiceActiveState" style="display: none;">\n <div class="voice-avatar-active" id="voiceAvatarActive">\n <div class="voice-rings">\n <div class="voice-ring"></div>\n <div class="voice-ring"></div>\n <div class="voice-ring"></div>\n </div>\n đ¤\n </div>\n <div class="voice-status">\n <div class="voice-status-title" id="voiceStatusTitleActive">').concat(this.t("listening"),'</div>\n <div class="voice-status-subtitle" id="voiceStatusSubtitleActive">').concat(this.t("speakFreely"),'</div>\n </div>\n <div class="voice-transcript">\n <div class="transcript-label">').concat(this.t("liveTranscript"),'</div>\n <div class="transcript-text empty" id="transcriptText">\n ').concat(this.t("transcriptWillAppear"),'\n </div>\n </div>\n <div class="voice-controls">\n <button class="voice-control-btn secondary" id="muteBtn" title="').concat(this.getTooltip("mute"),'">\n <svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="mute-icon">\n <path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/>\n <path d="M19 10v2a7 7 0 0 1-14 0v-2"/>\n <line x1="12" y1="19" x2="12" y2="23"/>\n <line x1="8" y1="23" x2="16" y2="23"/>\n <line x1="2" y1="2" x2="22" y2="22" class="mute-cross" style="display: none; stroke: #ef4444; stroke-width: 3.5;"/>\n </svg>\n </button>\n <button class="voice-control-btn primary active" id="endCallBtn" title="').concat(this.getTooltip("endCall"),'">\n <svg width="56" height="56" viewBox="0 0 24 24" fill="#ef4444">\n <rect x="6" y="6" width="12" height="12" rx="2"/>\n </svg>\n <div class="voice-timer" id="voiceTimer">00:00</div>\n </button>\n <button class="voice-control-btn secondary" id="speakerBtn" title="').concat(this.getTooltip("speaker"),'">\n <svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">\n <polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/>\n <path d="M19.07 4.93a10 10 0 0 1 0 14.14"/>\n <path d="M15.54 8.46a5 5 0 0 1 0 7.07"/>\n </svg>\n </button>\n </div>\n </div>\n </div>')}generateCSS(){var e=this.config.avatarBackgroundColor||"#667eea",t=this.config.avatarActiveBackgroundColor||this.config.avatarBackgroundColor||"#667eea",n=this.config.statusTitleColor||"#1e293b",o=this.config.statusSubtitleColor||"#64748b",i=this.config.startCallButtonColor||"#667eea",r=this.config.startCallButtonTextColor||"#FFFFFF",a=this.config.transcriptBackgroundColor||"#FFFFFF",s=this.config.transcriptTextColor||"#1e293b",c=this.config.transcriptLabelColor||"#94a3b8",l=this.config.controlButtonColor||"#FFFFFF",d=this.config.controlButtonSecondaryColor||"#64748b",u=(this.config.endCallButtonColor,!1===this.config.useShadowDOM?" !important":"");return"\n /* Voice Interface Styles - Ultra-compact for Wix iframes */\n .voice-interface { \n display: none".concat(u,"; \n flex: 1; \n flex-direction: column;\n align-items: center; \n justify-content: center; \n padding: 6px 10px 6px 10px; \n background: linear-gradient(180deg, #f8fafc 0%, #e0e7ff 100%);\n overflow: hidden;\n min-height: 0;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n }\n .voice-interface.active { display: flex").concat(u,'; }\n \n /* Voice States - Better scaling gaps */\n #voiceIdleState,\n #voiceActiveState {\n display: flex;\n flex-direction: column;\n align-items: center;\n width: 100%;\n height: 100%;\n min-height: 0;\n justify-content: center;\n overflow: hidden;\n flex: 1;\n box-sizing: border-box;\n gap: clamp(6px, 1.5vh, 12px);\n }\n \n #voiceActiveState[style*="display: none"] {\n display: none !important;\n }\n \n /* Voice Avatar - Scales better from small to large */\n .voice-avatar,\n .voice-avatar-active {\n width: clamp(80px, 18vh, 160px);\n height: clamp(80px, 18vh, 160px);\n aspect-ratio: 1;\n border-radius: 50%;\n background: linear-gradient(135deg, ').concat(e," 0%, ").concat(t," 100%);\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: clamp(40px, 9vh, 80px);\n margin: 0;\n box-shadow: 0 8px 30px rgba(102, 126, 234, 0.3);\n transition: all 0.3s ease;\n flex-shrink: 1;\n position: relative;\n }\n \n .voice-avatar-active {\n animation: avatarPulse 2s ease-in-out infinite;\n }\n \n @keyframes avatarPulse {\n 0%, 100% { \n transform: scale(1);\n }\n 50% { \n transform: scale(1.05);\n }\n }\n \n .voice-avatar-active.speaking {\n animation: avatarSpeak 0.5s ease-in-out infinite;\n }\n \n @keyframes avatarSpeak {\n 0%, 100% { transform: scale(1); }\n 50% { transform: scale(1.08); }\n }\n \n /* Voice Rings Animation */\n .voice-rings {\n position: absolute;\n width: 100%;\n height: 100%;\n border-radius: 50%;\n }\n \n .voice-ring {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n border: 2px solid rgba(102, 126, 234, 0.3);\n border-radius: 50%;\n opacity: 0;\n animation: ringExpand 2s ease-out infinite;\n }\n \n .voice-ring:nth-child(2) { animation-delay: 0.5s; }\n .voice-ring:nth-child(3) { animation-delay: 1s; }\n \n @keyframes ringExpand {\n 0% {\n width: 100%;\n height: 100%;\n opacity: 0.6;\n }\n 100% {\n width: 160%;\n height: 160%;\n opacity: 0;\n }\n }\n \n /* Voice Status - Scales with container */\n .voice-status {\n text-align: center;\n margin: 0;\n flex-shrink: 1;\n min-height: 0;\n }\n \n .voice-status-title {\n font-size: clamp(12px, 3vh, 20px);\n font-weight: 600;\n color: ").concat(n,";\n margin-bottom: clamp(2px, 0.5vh, 4px);\n line-height: 1.2;\n }\n \n .voice-status-subtitle {\n font-size: clamp(10px, 2vh, 14px);\n color: ").concat(o,";\n line-height: 1.2;\n }\n \n /* Start Call Button - Scales with container */\n .start-call-btn {\n margin: 0;\n width: min(280px, 70vw);\n height: clamp(48px, 8vh, 64px);\n border-radius: clamp(24px, 4vh, 32px);\n border: none;\n background: ").concat(i,";\n color: ").concat(r,";\n font-size: clamp(14px, 2.5vh, 18px);\n font-weight: 600;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: clamp(8px, 1.5vh, 12px);\n box-shadow: 0 12px 30px rgba(102, 126, 234, 0.4);\n transition: all 0.3s ease;\n flex-shrink: 0;\n }\n \n .start-call-btn svg {\n width: clamp(22px, 4vh, 32px);\n height: clamp(22px, 4vh, 32px);\n }\n \n .start-call-btn:hover {\n transform: translateY(-2px);\n box-shadow: 0 12px 28px rgba(102, 126, 234, 0.5);\n }\n \n .start-call-btn:active {\n transform: translateY(-1px);\n }\n \n /* Voice Transcript - Scales with container */\n .voice-transcript {\n background: ").concat(a,";\n padding: clamp(6px, 1.5vh, 12px);\n border-radius: 10px;\n width: min(360px, calc(100% - 40px));\n margin: 0;\n min-height: clamp(100px, 18vh, 140px);\n max-height: clamp(120px, 22vh, 160px);\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);\n flex-shrink: 1;\n overflow-y: auto;\n overflow-x: hidden;\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n }\n \n .transcript-label {\n font-size: clamp(8px, 1.4vh, 11px);\n color: ").concat(c,";\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.3px;\n margin-bottom: clamp(3px, 0.6vh, 6px);\n flex-shrink: 0;\n word-wrap: break-word;\n }\n \n .transcript-text {\n font-size: clamp(11px, 2vh, 15px);\n color: ").concat(s,";\n line-height: 1.4;\n flex: 1;\n overflow-y: auto;\n overflow-x: hidden;\n word-wrap: break-word;\n overflow-wrap: break-word;\n }\n \n .transcript-text.empty {\n color: #cbd5e1;\n font-style: italic;\n }\n \n /* Voice Controls - Scales with container */\n .voice-controls {\n display: flex;\n gap: clamp(8px, 1.8vh, 14px);\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n margin: 0;\n padding-top: clamp(5px, 1.2vh, 10px);\n }\n \n .voice-control-btn {\n width: clamp(48px, 9vh, 72px);\n height: clamp(48px, 9vh, 72px);\n aspect-ratio: 1;\n border-radius: 50%;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s;\n position: relative;\n flex-shrink: 0;\n }\n \n .voice-control-btn svg {\n width: 48%;\n height: 48%;\n }\n \n .voice-control-btn.primary {\n width: clamp(54px, 10vh, 80px);\n height: clamp(54px, 10vh, 80px);\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n box-shadow: 0 6px 18px rgba(102, 126, 234, 0.4);\n }\n \n .voice-control-btn.primary:hover {\n transform: scale(1.05);\n }\n \n .voice-control-btn.primary.active {\n background: white;\n animation: recordingPulse 1.5s ease-in-out infinite;\n }\n \n @keyframes recordingPulse {\n 0%, 100% { \n box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);\n }\n 50% { \n box-shadow: 0 6px 24px rgba(239, 68, 68, 0.7);\n }\n }\n \n .voice-control-btn.secondary {\n background: ").concat(l,";\n color: ").concat(d,";\n box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);\n }\n \n .voice-control-btn.secondary:hover {\n background: #f8fafc;\n transform: scale(1.05);\n }\n \n .voice-control-btn.secondary.muted {\n background: #f3f4f6;\n }\n \n .voice-control-btn.secondary.muted .mute-icon {\n stroke: #9ca3af !important;\n }\n \n .voice-timer {\n position: absolute;\n bottom: clamp(-18px, -3vh, -24px);\n font-size: clamp(9px, 1.6vh, 12px);\n color: #64748b;\n font-weight: 500;\n white-space: nowrap;\n }\n \n /* Mobile optimization */\n @media (max-width: 768px) {\n .voice-interface {\n padding: 6px 10px;\n }\n }\n \n @media (max-width: 480px) {\n .voice-interface {\n padding: 5px 8px;\n }\n }\n ")}setupEventHandlers(e){var t=this,n=this.shadowRoot.getElementById("startCallBtn"),o=this.shadowRoot.getElementById("endCallBtn"),i=this.shadowRoot.getElementById("muteBtn"),r=this.shadowRoot.getElementById("speakerBtn");n&&(n.onclick=()=>this.startVoiceCall()),o&&(o.onclick=()=>this.endVoiceCall()),i&&(i.onclick=()=>this.toggleMute()),r&&(r.onclick=()=>this.toggleSpeaker());var a=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=t.shadowRoot.getElementById("voiceInterface");n&&n.classList.contains("active")&&n.clientHeight>100?(console.log("â
Interface is active and has proper dimensions, adjusting sizes (attempt",e+1,")"),t.adjustSizesForContainer(),0===e&&setTimeout(()=>t.adjustSizesForContainer(),500)):e<15?(console.log("âŗ Interface not ready yet (height:",null==n?void 0:n.clientHeight,"), retrying... (attempt",e+1,")"),setTimeout(()=>a(e+1),250)):(console.warn("â ī¸ Interface never became fully ready, adjusting sizes anyway"),t.adjustSizesForContainer())};setTimeout(()=>a(),200),window.addEventListener("resize",()=>{console.log("đ Window resized, re-adjusting sizes"),this.adjustSizesForContainer()})}getSignedUrl(){var e=this;return Ie(function*(){if(e.config.signedUrl)return e.config.signedUrl;if(!e.config.agentId)throw new Error("agentId is required when signedUrl is not provided");var t=e.config.websocketUrl||"wss://speech.talktopc.com/ws/conv",n=new URLSearchParams;return n.append("agentId",e.config.agentId),e.config.appId&&n.append("appId",e.config.appId),!1!==e.config.demo&&n.append("demo","true"),"".concat(t,"?").concat(n.toString())})()}adjustSizesForContainer(){var e=this.shadowRoot.getElementById("voiceInterface");if(e){var t=e.clientHeight,n=e.clientWidth;console.log("đ Container size:",t,"x",n);var o,i,r,a,s,c,l,d,u,h=this.shadowRoot.getElementById("voiceIdleState"),p=this.shadowRoot.getElementById("voiceActiveState"),g=h&&"none"!==h.style.display,m=p&&"none"!==p.style.display;console.log("đī¸ Visible state - Idle:",g,"Active:",m),t<=350?(u=5,o=70,i=35,r=11,a=9,s=32,c=100,l=42,d=48):t<=450?(u=7,o=110,i=55,r=15,a=11,s=38,c=110,l=52,d=58):t<=550?(u=8,o=140,i=70,r=16,a=12,s=42,c=120,l=56,d=64):t<=700?(u=10,o=130,i=65,r=18,a=13,s=46,c=130,l=60,d=70):(u=12,o=150,i=75,r=20,a=14,s=50,c=140,l=66,d=76),this.shadowRoot.querySelectorAll("#voiceIdleState, #voiceActiveState").forEach(e=>{e.style.gap="".concat(u,"px")});var v=this.shadowRoot.querySelectorAll(".voice-avatar, .voice-avatar-active");console.log("đ¤ Found",v.length,"avatars, setting size to",o,"px"),v.forEach(e=>{e.style.width="".concat(o,"px"),e.style.height="".concat(o,"px"),e.style.fontSize="".concat(i,"px")}),this.shadowRoot.querySelectorAll(".voice-status-title").forEach(e=>e.style.fontSize="".concat(r,"px")),this.shadowRoot.querySelectorAll(".voice-status-subtitle").forEach(e=>e.style.fontSize="".concat(a,"px"));var f=this.shadowRoot.querySelector(".voice-transcript");f&&(f.style.minHeight="".concat(c,"px"),f.style.maxHeight="".concat(c,"px"),f.style.height="".concat(c,"px"),f.style.width="min(360px, ".concat(n-40,"px)"),f.style.boxSizing="border-box");var y=this.shadowRoot.querySelector(".transcript-label");y&&(y.style.fontSize="".concat(Math.max(8,r-4),"px"));var x=this.shadowRoot.querySelector(".transcript-text");x&&(x.style.fontSize="".concat(Math.max(10,r-2),"px")),this.shadowRoot.querySelectorAll(".voice-control-btn.secondary").forEach(e=>{e.style.width="".concat(l,"px"),e.style.height="".concat(l,"px");var t=e.querySelector("svg");if(t){var n=.65*l;t.style.setProperty("width","".concat(n,"px"),"important"),t.style.setProperty("height","".concat(n,"px"),"important"),t.style.setProperty("min-width","".concat(n,"px"),"important"),t.style.setProperty("min-height","".concat(n,"px"),"important")}});var b=this.shadowRoot.querySelector(".voice-control-btn.primary");if(b){b.style.width="".concat(d,"px"),b.style.height="".concat(d,"px");var w=b.querySelector("svg");if(w){var S=.7*d;w.style.setProperty("width","".concat(S,"px"),"important"),w.style.setProperty("height","".concat(S,"px"),"important"),w.style.setProperty("min-width","".concat(S,"px"),"important"),w.style.setProperty("min-height","".concat(S,"px"),"important")}}var C=this.shadowRoot.querySelector(".start-call-btn");if(C){var k,P;t<=350?(k=48,P=14):t<=450?(k=52,P=15):t<=550?(k=58,P=17):t<=700?(k=62,P=18):(k=64,P=18),C.style.height="".concat(k,"px"),C.style.fontSize="".concat(P,"px");var E=C.querySelector("svg");if(E){var T=Math.max(22,.5*k);E.style.width="".concat(T,"px"),E.style.height="".concat(T,"px")}}console.log("â
Sizes adjusted - Avatar:",o,"Status:",s,"Transcript:",c,"Buttons:",l)}else console.warn("â ī¸ voiceInterface not found, skipping size adjustment")}startVoiceCall(){var e=this;return Ie(function*(){if(e.isActive)console.log("â ī¸ Voice call already active");else{console.log("đ¤ Starting voice call...");var t=yield xe();if(console.log("đ Current permission state: ".concat(t)),"denied"!==t){if("prompt"===t||"unknown"===t)return console.log("đ Permission is in prompt state, showing pre-prompt modal..."),new Promise(t=>{ke(Ie(function*(){console.log("â
Pre-prompt accepted, proceeding with voice call..."),yield e.proceedWithVoiceCall(),t()}),()=>{console.log("â Pre-prompt cancelled"),t()})});yield e.proceedWithVoiceCall()}else console.log("đĢ Permission is denied, showing blocked modal..."),ye(),Pe(()=>{console.log("Blocked modal closed")})}})()}proceedWithVoiceCall(){var e=this;return Ie(function*(){try{var t=e.shadowRoot.getElementById("voiceIdleState"),n=e.shadowRoot.getElementById("voiceActiveState"),o=e.shadowRoot.getElementById("voiceInterface");t&&(t.style.display="none"),n&&(n.style.display="flex"),setTimeout(()=>e.adjustSizesForContainer(),50),o&&(o.scrollTop=0);var i=ye(),r=yield xe();if(i.isMobile&&"granted"!==r){console.log("đą Mobile device detected - requesting mic permission before connecting..."),console.log("đ Current permission state: ".concat(r));try{var a=e.config.outputSampleRate||44100;(yield navigator.mediaDevices.getUserMedia({audio:{sampleRate:a,channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})).getTracks().forEach(e=>e.stop()),console.log("â
Microphone permission granted on mobile - proceeding with connection")}catch(t){return console.log("đĢ Permission denied on mobile, showing blocked modal..."),void Pe(()=>{e.resetUIState()})}}var s=yield e.getSignedUrl();if(console.log("đ Got signed URL:",s),e.sdk&&e.sdk.isConnected){console.log("đ SDK already connected, disconnecting for clean retry...");try{e.sdk.disconnect(),yield new Promise(e=>setTimeout(e,100))}catch(e){console.warn("Warning: Error disconnecting existing connection:",e)}}var c=yield e.sdk.connect(s);console.log("â
Connected to WebSocket, connected:",c);for(var l=0;l<50&&!(e.sdk.isConnected&&e.sdk.voiceSDK&&e.sdk.voiceSDK.isConnected&&e.sdk.voiceSDK.websocket&&e.sdk.voiceSDK.websocket.readyState===WebSocket.OPEN);)yield new Promise(e=>setTimeout(e,100)),l++;e.sdk.isConnected&&e.sdk.voiceSDK&&e.sdk.voiceSDK.websocket&&e.sdk.voiceSDK.websocket.readyState===WebSocket.OPEN?(console.log("â
WebSocket ready, starting listening..."),yield e.sdk.startListening(),console.log("đ¤ Started listening"),e.isActive=!0,e.callStartTime=Date.now(),e.callTimerInterval=setInterval(()=>{var t=Date.now()-e.callStartTime,n=Math.floor(t/6e4),o=Math.floor(t%6e4/1e3),i=e.shadowRoot.getElementById("voiceTimer");i&&(i.textContent="".concat(n.toString().padStart(2,"0"),":").concat(o.toString().padStart(2,"0")))},1e3)):(console.warn("â ī¸ Connection not fully ready, but trying to start listening anyway..."),yield e.sdk.startListening(),console.log("đ¤ Started listening"),e.isActive=!0,e.callStartTime=Date.now(),e.callTimerInterval=setInterval(()=>{var t=Date.now()-e.callStartTime,n=Math.floor(t/6e4),o=Math.floor(t%6e4/1e3),i=e.shadowRoot.getElementById("voiceTimer");i&&(i.textContent="".concat(n.toString().padStart(2,"0"),":").concat(o.toString().padStart(2,"0")))},1e3)),console.log("â
Voice call started successfully")}catch(t){if(console.error("â Error starting voice call:",t),e.isActive=!1,e.callTimerInterval&&(clearInterval(e.callTimerInterval),e.callTimerInterval=null),e.sdk&&e.sdk.isConnected)try{e.sdk.disconnect()}catch(e){console.warn("Error disconnecting SDK on error:",e)}"NotAllowedError"===t.name||"PermissionDeniedError"===t.name?(ye(),Pe(()=>{e.resetUIState()})):"NotFoundError"===t.name||"DevicesNotFoundError"===t.name?Ee(()=>{e.resetUIState()}):(e.showError(t.message||t),e.resetUIState())}})()}resetUIState(){var e=this.shadowRoot.getElementById("voiceIdleState"),t=this.shadowRoot.getElementById("voiceActiveState");e&&(e.style.display="flex"),t&&(t.style.display="none")}endVoiceCall(){console.log("đ´ Ending voice call..."),this.sdk&&this.isActive&&(this.sdk.stopListening(),this.sdk.hangup(),this.isActive=!1),this.audioStream&&(this.audioStream.getTracks().forEach(e=>e.stop()),this.audioStream=null),this.callTimerInterval&&(clearInterval(this.callTimerInterval),this.callTimerInterval=null);var e=this.shadowRoot.getElementById("voiceIdleState"),t=this.shadowRoot.getElementById("voiceActiveState");e&&(e.style.display="flex"),t&&(t.style.display="none"),setTimeout(()=>this.adjustSizesForContainer(),50);var n=this.shadowRoot.getElementById("transcriptText");n&&(n.textContent=this.t("transcriptWillAppear"),n.classList.add("empty"));var o=this.shadowRoot.getElementById("voiceAvatarActive");o&&o.classList.remove("speaking"),console.log("â
Voice call ended")}updateTranscript(e){console.log("đ [VOICE INTERFACE] updateTranscript called with text:",e);var t=this.shadowRoot.getElementById("transcriptText");t?(console.log("đ [VOICE INTERFACE] Found transcript element, updating text"),t.textContent=e,t.classList.remove("empty")):console.warn("đ [VOICE INTERFACE] â ī¸ transcriptText element not found!")}showError(e){var t=this.shadowRoot.getElementById("transcriptText");t&&(t.textContent="".concat(this.t("error"),": ").concat(e),t.classList.remove("empty"))}showDomainError(){var e=this.shadowRoot.getElementById("transcriptText");if(e){var t=this.t("domainNotValidated"),n=this.t("domainErrorMessage");e.innerHTML='<div style="font-weight: 600; font-size: 16px; margin-bottom: 8px; color: #991B1B;">'.concat(t,'</div><div style="font-size: 14px; color: #991B1B; line-height: 1.5;">').concat(n,"</div>"),e.classList.remove("empty")}}toggleMute(){if(this.sdk&&this.isActive){var e=null;if(this.sdk.voiceSDK&&this.sdk.voiceSDK.audioRecorder&&this.sdk.voiceSDK.audioRecorder.mediaStream&&(e=this.sdk.voiceSDK.audioRecorder.mediaStream.getAudioTracks()[0]),!e&&this.audioStream&&(e=this.audioStream.getAudioTracks()[0]),e){e.enabled=!e.enabled;var t=this.shadowRoot.getElementById("muteBtn"),n=null==t?void 0:t.querySelector(".mute-icon"),o=null==t?void 0:t.querySelector(".mute-cross");t&&n&&o&&(e.enabled?(n.style.stroke="",o.style.display="none",t.classList.remove("muted")):(n.style.stroke="#9ca3af",o.style.display="block",t.classList.add("muted"))),console.log(e.enabled?"đ Unmuted":"đ Muted")}else console.warn("â ī¸ No audio track available for mute toggle")}}toggleSpeaker(){console.log("đ Speaker toggle")}destroy(){this.isActive&&this.endVoiceCall(),this.audioStream&&(this.audioStream.getTracks().forEach(e=>e.stop()),this.audioStream=null),this.callTimerInterval&&(clearInterval(this.callTimerInterval),this.callTimerInterval=null),this.sdk&&(this.sdk.disconnect(),this.sdk=null)}}function Re(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}function De(e){return function(){var t=this,n=arguments;return new Promise(function(o,i){var r=e.apply(t,n);function a(e){Re(r,o,i,a,s,"next",e)}function s(e){Re(r,o,i,a,s,"throw",e)}a(void 0)})}}class Fe{constructor(e,t){this.config=e,this.sdk=t,this.streamingEl=null,this.hasStartedStreaming=!1,this.isActive=!1,this.shadowRoot=e.shadowRoot||document,this.eventHandlers={autoResize:null,keydown:null},this.eventHandlersSetup=!1}t(e){var t,n,o=this.config.language||"en";return((null===(t=this.config.translations)||void 0===t?void 0:t[o])||(null===(n=this.config.translations)||void 0===n?void 0:n.en)||{})[e]||e}generateHTML(){var e,t,n,o,i,r,a,s,c,l=this.config.inputPlaceholder||(null===(e=this.config.panel)||void 0===e?void 0:e.inputPlaceholder)||this.t("typeMessage")||"Type your message...";return'<div class="text-interface" id="textInterface">\n <div class="messages-container" id="messagesContainer">\n <div class="empty-state">\n <div class="empty-state-icon">đŦ</div>\n <div class="empty-state-title">'.concat(this.t("hello"),'</div>\n <div class="empty-state-text">').concat(this.t("sendMessage"),'</div>\n </div>\n </div>\n <div class="input-container">\n <div class="input-wrapper" style="flex:1;">\n <textarea class="message-input" id="messageInput" placeholder="').concat(l,'" rows="1" dir="').concat(this.config.direction||"ltr",'"></textarea>\n </div>\n <button class="send-button" id="sendButton" aria-label="').concat(this.t("sendMessageAria"),'">').concat(this.config.sendButtonText||"â¤","</button>\n ").concat(null!==(t=this.config.sendButtonHint)&&void 0!==t&&t.text||null!==(n=this.config.panel)&&void 0!==n&&null!==(n=n.sendButtonHint)&&void 0!==n&&n.text?'\n <div class="send-button-hint" style="color: '.concat((null===(o=this.config.sendButtonHint)||void 0===o?void 0:o.color)||(null===(i=this.config.panel)||void 0===i||null===(i=i.sendButtonHint)||void 0===i?void 0:i.color)||"#6B7280","; font-size: ").concat((null===(r=this.config.sendButtonHint)||void 0===r?void 0:r.fontSize)||(null===(a=this.config.panel)||void 0===a||null===(a=a.sendButtonHint)||void 0===a?void 0:a.fontSize)||"12px",'; text-align: center; margin-top: 4px;">\n ').concat((null===(s=this.config.sendButtonHint)||void 0===s?void 0:s.text)||(null===(c=this.config.panel)||void 0===c||null===(c=c.sendButtonHint)||void 0===c?void 0:c.text),"\n </div>\n "):"","\n </div>\n </div>")}generateCSS(){var e,t,n,o,i,r,a,s,c,l,d,u,h,p=this.config.messages,g=(this.config.panel,this.config.animation,this.config.sendButtonColor||(null===(e=this.config.panel)||void 0===e?void 0:e.sendButtonColor)||"#7C3AED"),m=this.config.sendButtonHoverColor||(null===(t=this.config.panel)||void 0===t?void 0:t.sendButtonHoverColor)||"#6D28D9",v=this.config.sendButtonTextColor||(null===(n=this.config.panel)||void 0===n?void 0:n.sendButtonTextColor)||"#FFFFFF",f=(this.config.inputPlaceholder||null===(o=this.config.panel)||void 0===o||o.inputPlaceholder,this.config.inputBorderColor||(null===(i=this.config.panel)||void 0===i?void 0:i.inputBorderColor)||"#E5E7EB"),y=this.config.inputFocusColor||(null===(r=this.config.panel)||void 0===r?void 0:r.inputFocusColor)||"#7C3AED",x=this.config.inputBackgroundColor||(null===(a=this.config.panel)||void 0===a?void 0:a.inputBackgroundColor)||"#FFFFFF",b=this.config.inputTextColor||(null===(s=this.config.panel)||void 0===s?void 0:s.inputTextColor)||"#1F2937",w=this.config.inputFontSize||(null===(c=this.config.panel)||void 0===c?void 0:c.inputFontSize)||"14px",S=this.config.inputBorderRadius||(null===(l=this.config.panel)||void 0===l?void 0:l.inputBorderRadius)||20,C=this.config.inputPadding||(null===(d=this.config.panel)||void 0===d?void 0:d.inputPadding)||"6px 14px",k=!1===this.config.useShadowDOM?" !important":"";return"\n /* Messages container using new classes */\n #messagesContainer { \n flex: 1; \n overflow-y: auto; \n overflow-x: hidden; \n padding: 20px; \n background: #f8fafc; \n display: flex; \n flex-direction: column; \n gap: 16px; \n min-height: 0; \n }\n .empty-state { \n flex: 1; \n display: flex; \n flex-direction: column; \n align-items: center; \n justify-content: center; \n gap: 12px; \n color: #64748b; \n text-align: center; \n padding: 20px; \n }\n .empty-state-icon { font-size: 48px; opacity: 0.3; }\n .empty-state-title { font-size: 20px; font-weight: 700; color: #334155; }\n .empty-state-text { font-size: 13px; max-width: 280px; }\n\n .text-interface { \n display: none".concat(k,"; \n flex: 1; \n flex-direction: column; \n min-height: 0; \n overflow: hidden; \n }\n .text-interface.active { display: flex").concat(k,"; }\n \n .message { \n display: flex; \n gap: 8px; \n padding: 4px 0; \n max-width: 100%; \n align-items: center; \n }\n .message.edge-left { flex-direction: row; }\n .message.edge-right { flex-direction: row-reverse; }\n .message-bubble { \n padding: 12px; \n border-radius: ").concat(p.borderRadius,"px; \n max-width: 80%; \n font-size: ").concat(p.fontSize,"; \n color: ").concat(p.textColor,"; \n word-wrap: break-word; \n text-align: ").concat("rtl"===this.config.direction?"right":"left","; \n direction: ").concat(this.config.direction||"ltr",";\n }\n .message.user { \n background: ").concat(p.userBackgroundColor,"; \n align-self: ").concat("rtl"===this.config.direction?"flex-start":"flex-end","; \n }\n .message.agent { \n background: ").concat(p.agentBackgroundColor,"; \n align-self: ").concat("rtl"===this.config.direction?"flex-end":"flex-start","; \n }\n .message .message-bubble { \n text-align: ").concat("rtl"===this.config.direction?"right":"left"," !important; \n }\n ").concat("rtl"===this.config.direction?"\n .message-bubble {\n text-align: right !important;\n }\n ":"","\n .message-avatar { \n width: 20px; \n height: 20px; \n display: flex; \n align-items: center; \n justify-content: center; \n flex-shrink: 0; \n color: inherit; \n font-size: 18px; \n line-height: 1; \n background: transparent; \n border: none; \n }\n .message-avatar.user { background: transparent; }\n .message-avatar.agent { background: transparent; }\n \n .message.system {\n background: ").concat(p.systemBackgroundColor,";\n align-self: flex-start;\n }\n .message.error {\n background: ").concat(p.errorBackgroundColor,";\n align-self: flex-start;\n }\n \n .input-container {\n display: flex;\n gap: 8px;\n padding: 12px 16px;\n background: #FFFFFF;\n border-top: 1px solid #E5E7EB;\n align-items: center;\n flex-shrink: 0;\n flex-direction: ").concat("rtl"===this.config.direction?"row-reverse":"row",";\n }\n \n .input-wrapper {\n position: relative;\n display: flex;\n align-items: center;\n }\n \n .message-input {\n width: 100%;\n min-height: 32px;\n max-height: 120px;\n padding: ").concat(C,";\n border: 1px solid ").concat(f,";\n border-radius: ").concat(S,"px;\n font-size: ").concat(w,";\n font-family: inherit;\n line-height: 1.3;\n resize: none;\n overflow-y: auto;\n background: ").concat(x,";\n color: ").concat(b,";\n vertical-align: top;\n margin: 0;\n display: block;\n white-space: pre-wrap;\n word-wrap: break-word;\n text-align: ").concat("rtl"===this.config.direction?"right":"left",";\n direction: ").concat(this.config.direction||"ltr",";\n -webkit-appearance: none;\n appearance: none;\n box-sizing: border-box;\n }\n \n .message-input:focus {\n outline: none;\n border-color: ").concat(y,";\n background: ").concat("#FFFFFF"===x?"#FFFFFF":x,";\n box-shadow: 0 0 0 3px ").concat(y,"33;\n }\n \n .message-input::placeholder {\n color: #9CA3AF;\n text-align: ").concat("rtl"===this.config.direction?"right":"left",";\n }\n \n .send-button {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n border: none;\n background: ").concat(g,";\n color: ").concat(v,";\n font-size: ").concat(this.config.sendButtonFontSize||(null===(u=this.config.panel)||void 0===u?void 0:u.sendButtonFontSize)||"18px",";\n font-weight: ").concat(this.config.sendButtonFontWeight||(null===(h=this.config.panel)||void 0===h?void 0:h.sendButtonFontWeight)||"500",";\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n transition: all 0.2s ease;\n box-shadow: 0 4px 12px rgba(124, 60, 237, 0.3);\n }\n \n .send-button:hover:not(:disabled) {\n background: ").concat(m,";\n transform: scale(1.05);\n box-shadow: 0 6px 16px rgba(124, 60, 237, 0.4);\n }\n \n .send-button-hint {\n width: 100%;\n text-align: center;\n margin-top: 4px;\n }\n \n .send-button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n \n .typing-indicator {\n display: inline-flex;\n gap: 4px;\n align-items: center;\n }\n \n .typing-dot {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: #64748b;\n animation: typingDot 1.4s ease-in-out infinite;\n }\n \n .typing-dot:nth-child(2) { animation-delay: 0.2s; }\n .typing-dot:nth-child(3) { animation-delay: 0.4s; }\n \n @keyframes typingDot {\n 0%, 60%, 100% { transform: translateY(0); opacity: 0.7; }\n 30% { transform: translateY(-8px); opacity: 1; }\n }\n \n .error-message {\n padding: 12px;\n background: ").concat(p.errorBackgroundColor,";\n border-radius: ").concat(p.borderRadius,"px;\n color: #991B1B;\n font-size: ").concat(p.fontSize,";\n margin: 8px 0;\n }\n \n @media (max-width: 768px) {\n #messagesContainer {\n padding: 12px;\n gap: 12px;\n }\n \n .message-bubble {\n max-width: 85%;\n font-size: 14px;\n padding: 10px;\n }\n \n .text-input-container {\n padding: 10px;\n gap: 8px;\n }\n \n #text-chat-input {\n font-size: 16px !important; /* Prevents iOS zoom on focus */\n padding: 10px 14px;\n min-height: 44px;\n }\n \n #text-chat-send {\n min-width: 56px;\n min-height: 44px;\n width: 56px;\n height: 44px;\n }\n \n .empty-state-icon {\n font-size: 40px;\n }\n \n .empty-state-title {\n font-size: 18px;\n }\n \n .empty-state-text {\n font-size: 12px;\n }\n }\n \n @media (max-width: 480px) {\n #messagesContainer {\n padding: 10px;\n gap: 10px;\n }\n \n .message-bubble {\n max-width: 90%;\n font-size: 13px;\n padding: 8px;\n }\n \n .text-input-container {\n padding: 8px;\n }\n \n #text-chat-input {\n font-size: 16px !important;\n padding: 8px 12px;\n }\n }\n ")}setupEventHandlers(){var e=this.shadowRoot.getElementById("sendButton"),t=this.shadowRoot.getElementById("messageInput"),n=this.shadowRoot.getElementById("newChatBtn");if(e&&(e.onclick=()=>this.sendMessage()),n&&(n.onclick=()=>this.startNewChat()),this.updateInputAttributes(),t){t.style.height="32px",t.style.overflow="hidden";var o=()=>{t.style.height="auto";var e=Math.min(t.scrollHeight,120);t.style.height=e+"px",t.style.overflowY=e>=120?"auto":"hidden",e>=120&&setTimeout(()=>{t.scrollTop=t.scrollHeight},0)};t.addEventListener("input",o),t.addEventListener("keydown",e=>{"Enter"!==e.key||e.shiftKey?"Enter"===e.key&&e.shiftKey&&setTimeout(o,0):(e.preventDefault(),this.sendMessage())})}}startNewChat(){try{localStorage.removeItem("ttp_text_chat_conversation_id")}catch(e){}this.sdk&&(this.sdk.config.conversationId=null);var e=this.shadowRoot.getElementById("messagesContainer");e&&(e.innerHTML='\n <div class="empty-state">\n <div class="empty-state-icon">đŦ</div>\n <div class="empty-state-title">'.concat(this.t("hello"),'</div>\n <div class="empty-state-text">').concat(this.t("sendMessage"),"</div>\n </div>"));var t=this.shadowRoot.getElementById("messageInput");t&&t.focus()}updateInputAttributes(){var e=this.shadowRoot.getElementById("messageInput");if(e){var t,n=this.config.inputPlaceholder||(null===(t=this.config.panel)||void 0===t?void 0:t.inputPlaceholder)||this.t("typeMessage")||"Type your message...";e.placeholder=n,e.dir=this.config.direction||"ltr",e.style.textAlign="rtl"===this.config.direction?"right":"left"}}show(){var e=this.shadowRoot.getElementById("textInterface");e&&e.classList.add("active"),setTimeout(()=>{var e=this.shadowRoot.getElementById("messageInput");e&&e.focus()},50)}hide(){var e=this.shadowRoot.getElementById("textInterface");e&&e.classList.remove("active")}startChat(){var e=this;return De(function*(){e.isActive=!0,e.updateSendButtonState()})()}sendMessage(){var e=this;return De(function*(){var t=e.shadowRoot.getElementById("messageInput"),n=t.value.trim();if(n){e.isActive||(yield e.startChat()),e.addMessage("user",n),t.value="",t.style.height="32px",t.style.overflow="hidden";try{e.beginStreaming(),yield e.sdk.sendMessage(n)}catch(t){console.error("â Failed to send message:",t),t&&("DOMAIN_NOT_WHITELISTED"===t.message||t.message&&t.message.includes("Domain not whitelisted"))||e.showError(t),e.stopStreamingState()}}})()}updateSendButtonState(){var e=this.shadowRoot.getElementById("sendButton");e&&(e.disabled=!this.isActive)}addMessage(e,t){var n=this.shadowRoot.getElementById("messagesContainer");if(n){var o=n.querySelector(".empty-state");o&&o.remove();var i=document.createElement("div"),r="rtl"===this.config.direction?"user"===e?"edge-left":"edge-right":"user"===e?"edge-right":"edge-left";i.className="message ".concat(e," ").concat(r);var a=document.createElement("div");a.className="message-avatar ".concat(e),a.textContent="user"===e?"đ¤":"đ¤";var s=document.createElement("div");s.className="message-bubble",s.textContent=t,i.appendChild(a),i.appendChild(s),n.appendChild(i),n.scrollTop=n.scrollHeight}}beginStreaming(){var e=this.shadowRoot.getElementById("messagesContainer");if(e){this.stopStreamingState();var t=document.createElement("div"),n="rtl"===this.config.direction?"edge-right":"edge-left";t.className="message agent ".concat(n),t.id="agent-streaming";var o=document.createElement("div");o.className="message-avatar agent",o.textContent="đ¤";var i=document.createElement("div");i.className="message-bubble",i.innerHTML='<span class="typing-indicator"><span class="typing-dot"></span><span class="typing-dot"></span><span class="typing-dot"></span></span>',t.appendChild(o),t.appendChild(i),e.appendChild(t),this.streamingEl=i,this.hasStartedStreaming=!1,e.scrollTop=e.scrollHeight}}appendStreamingChunk(e){if(this.streamingEl){this.hasStartedStreaming||(this.streamingEl.textContent="",this.hasStartedStreaming=!0),this.streamingEl.textContent+=e;var t=this.shadowRoot.getElementById("messagesContainer");t&&(t.scrollTop=t.scrollHeight)}}finalizeStreaming(e){if(this.streamingEl){this.streamingEl.textContent=e||this.streamingEl.textContent;var t=this.shadowRoot.getElementById("agent-streaming");t&&(t.id=""),this.streamingEl=null}this.updateSendButtonState()}stopStreamingState(){var e=this.shadowRoot.getElementById("agent-streaming");e&&e.remove(),this.streamingEl=null,this.hasStartedStreaming=!1}showError(e){var t=this.shadowRoot.getElementById("messagesContainer");if(t){if(e&&("DOMAIN_NOT_WHITELISTED"===e.message||"string"==typeof e&&e.includes("DOMAIN_NOT_WHITELISTED")||e.message&&e.message.includes("Domain not whitelisted")||"string"==typeof e&&e.includes("Domain not whitelisted"))){var n,o=document.createElement("div");o.className="error-message",o.style.cssText="padding: 16px; margin: 12px; border-radius: 8px; background: "+((null===(n=this.config.messages)||void 0===n?void 0:n.errorBackgroundColor)||"#FEE2E2")+";";var i=document.createElement("div");i.style.cssText="font-weight: 600; font-size: 16px; margin-bottom: 8px; color: #991B1B;",i.textContent=this.t("domainNotValidated");var r=document.createElement("div");r.style.cssText="font-size: 14px; color: #991B1B; line-height: 1.5;",r.textContent=this.t("domainErrorMessage"),o.appendChild(i),o.appendChild(r),t.appendChild(o)}else{var a=document.createElement("div");a.className="error-message",a.textContent="string"==typeof e?e:(null==e?void 0:e.message)||e,t.appendChild(a)}t.scrollTop=t.scrollHeight}}setActive(e){this.isActive=e,this.updateSendButtonState()}}const Be={en:{landingTitle:"How would you like to communicate?",voiceCall:"Voice Call",textChat:"Text Chat",clickToStartCall:"Click to Start Call",realTimeVoice:"Real-time voice conversation",startCall:"Start Call",listening:"Listening...",speakFreely:"Speak freely",liveTranscript:"Live Transcript",transcriptWillAppear:"Transcript will appear here during the call...",mute:"Mute",speaker:"Speaker",endCall:"End Call",hello:"Hello! How can I help?",sendMessage:"Send a message to get started",online:"Online",newChat:"New Chat",back:"Back",close:"Close",error:"Error",typeMessage:"Type your message...",sendMessageAria:"Send message",domainNotValidated:"Domain not validated",domainErrorMessage:"This domain is not whitelisted. Please contact the administrator to whitelist your website URL."},he:{landingTitle:"××× ×Ēר×Ļ× ××Ēק׊ר?",voiceCall:"׊××× ×§××××Ē",textChat:"×Ļ'×× ×קץ×",clickToStartCall:"×××Ĩ ×××Ē×××Ē ×Š×××",realTimeVoice:"׊××× ×§××××Ē ×××× ×××Ē",startCall:"××Ē×× ×Š×××",listening:"×ק׊××...",speakFreely:"××ר ×××פ׊×××Ē",liveTranscript:"×Ē×××× ×××× ×××Ē",transcriptWillAppear:"××Ē×××× ××פ××ĸ ××× ××××× ×׊×××...",mute:"×׊×Ē×§",speaker:"ר××§××",endCall:"ץ××× ×Š×××",hello:"׊×××! ××× ×פ׊ר ××ĸ××ר?",sendMessage:"׊×× ××××ĸ× ×× ×ĸ××ר ×××Ļ× ×§××× ×׊××× ×××× ×××Ē",online:"××§×××",newChat:"×Ļ'×× ××׊",back:"×××ר",close:"ץ××ר",error:"׊××××",typeMessage:"××§×× ××××ĸ×...",sendMessageAria:"׊×× ××××ĸ×",domainNotValidated:"×××××× ×× ×××××Ē",domainErrorMessage:"×××××× ×× ×× ×ר׊×××Ē ×××ר׊××. ×× × ×¤× × ××× ×× ×××ĸר××Ē ××× ×××ץ××Ŗ ××Ē ××Ē×××Ē ×××Ēר ׊×× ×ר׊×××."},ar:{landingTitle:"ŲŲŲ ØĒØąŲØ¯ Ø§ŲØĒŲØ§ØĩŲØ",voiceCall:"Ų
ŲØ§ŲŲ
ØŠ ØĩŲØĒŲØŠ",textChat:"Ø¯ØąØ¯Ø´ØŠ ŲØĩŲØŠ",clickToStartCall:"اŲŲØą ŲØ¨Ø¯ØĄ اŲŲ
ŲØ§ŲŲ
ØŠ",realTimeVoice:"Ų
ØØ§Ø¯ØĢØŠ ØĩŲØĒŲØŠ ŲŲ Ø§ŲŲŲØĒ Ø§ŲŲØšŲŲ",startCall:"Ø§Ø¨Ø¯ØŖ اŲŲ
ŲØ§ŲŲ
ØŠ",listening:"Ø§ŲØ§ØŗØĒŲ
اؚ...",speakFreely:"ØĒŲŲŲ
Ø¨ØØąŲØŠ",liveTranscript:"ŲØĩ Ų
Ø¨Ø§Ø´Øą",transcriptWillAppear:"ØŗŲØ¸ŲØą اŲŲØĩ ŲŲØ§ ØŖØĢŲØ§ØĄ اŲŲ
ŲØ§ŲŲ
ØŠ...",mute:"ŲØĒŲ
Ø§ŲØĩŲØĒ",speaker:"Ų
ŲØ¨Øą Ø§ŲØĩŲØĒ",endCall:"ØĨŲŲØ§ØĄ اŲŲ
ŲØ§ŲŲ
ØŠ",hello:"Ų
ØąØØ¨Ø§! ŲŲŲ ŲŲ
ŲŲŲŲ Ø§ŲŲ
ØŗØ§ØšØ¯ØŠØ",sendMessage:"ØŖØąØŗŲ ØąØŗØ§ŲØŠ ŲŲØ¨Ø¯ØĄ",online:"Ų
ØĒØĩŲ",newChat:"Ų
ØØ§Ø¯ØĢØŠ ØŦØ¯ŲØ¯ØŠ",back:"ØąØŦŲØš",close:"ØĨØēŲØ§Ų",error:"ØŽØˇØŖ",typeMessage:"Ø§ŲØĒØ¨ ØąØŗØ§ŲØŠ...",sendMessageAria:"ØĨØąØŗØ§Ų ØąØŗØ§ŲØŠ",domainNotValidated:"اŲŲØˇØ§Ų ØēŲØą Ų
ØšØĒŲ
د",domainErrorMessage:"ŲØ°Ø§ اŲŲØˇØ§Ų ØēŲØą Ų
ØŗŲ
ŲØ بŲ. ŲØąØŦŲ Ø§ŲØ§ØĒØĩØ§Ų Ø¨Ø§ŲŲ
ØŗØ¤ŲŲ ŲØĨØļØ§ŲØŠ ØšŲŲØ§Ų Ų
Ųب𠨧ŲŲŲØ¨ Ø§ŲØŽØ§Øĩ Ø¨Ų ØĨŲŲ Ø§ŲŲØ§ØĻŲ
ØŠ."},ru:{landingTitle:"ĐаĐē Đ˛Ņ Ņ
ĐžŅиŅĐĩ ОйŅаŅŅŅŅ?",voiceCall:"ĐĐžĐģĐžŅОвОК СвОĐŊĐžĐē",textChat:"ĐĸĐĩĐēŅŅОвŅĐš ŅаŅ",clickToStartCall:"ĐаĐļĐŧиŅĐĩ, ŅŅĐžĐąŅ ĐŊаŅаŅŅ ĐˇĐ˛ĐžĐŊĐžĐē",realTimeVoice:"ĐĐžĐģĐžŅОвОК ŅĐ°ĐˇĐŗĐžĐ˛ĐžŅ Đ˛ ŅĐĩаĐģŅĐŊĐžĐŧ вŅĐĩĐŧĐĩĐŊи",startCall:"ĐаŅаŅŅ ĐˇĐ˛ĐžĐŊĐžĐē",listening:"ĐĄĐģŅŅаŅ...",speakFreely:"ĐОвОŅиŅĐĩ ŅвОйОдĐŊĐž",liveTranscript:"ĐĐ¸Đ˛Đ°Ņ ŅŅаĐŊŅĐēŅиĐŋŅиŅ",transcriptWillAppear:"ĐĸŅаĐŊŅĐēŅиĐŋŅĐ¸Ņ ĐŋĐžŅвиŅŅŅ ĐˇĐ´ĐĩŅŅ Đ˛Đž вŅĐĩĐŧŅ ĐˇĐ˛ĐžĐŊĐēа...",mute:"ĐŅĐēĐģŅŅиŅŅ ĐˇĐ˛ŅĐē",speaker:"ĐиĐŊаĐŧиĐē",endCall:"ĐавĐĩŅŅиŅŅ ĐˇĐ˛ĐžĐŊĐžĐē",hello:"ĐŅивĐĩŅ! ĐаĐē Ņ ĐŧĐžĐŗŅ ĐŋĐžĐŧĐžŅŅ?",sendMessage:"ĐŅĐŋŅавŅŅĐĩ ŅООйŅĐĩĐŊиĐĩ Đ´ĐģŅ ĐŊаŅаĐģа",online:"Đ ŅĐĩŅи",newChat:"ĐОвŅĐš ŅаŅ",back:"ĐаСад",close:"ĐаĐēŅŅŅŅ",error:"ĐŅийĐēа",typeMessage:"ĐвĐĩдиŅĐĩ ŅООйŅĐĩĐŊиĐĩ...",sendMessageAria:"ĐŅĐŋŅавиŅŅ ŅООйŅĐĩĐŊиĐĩ",domainNotValidated:"ĐĐžĐŧĐĩĐŊ ĐŊĐĩ ĐŋŅОвĐĩŅĐĩĐŊ",domainErrorMessage:"ĐŅĐžŅ Đ´ĐžĐŧĐĩĐŊ ĐŊĐĩ в ĐąĐĩĐģĐžĐŧ ŅĐŋиŅĐēĐĩ. ĐĐžĐļаĐģŅĐšŅŅа, ŅвŅĐļиŅĐĩŅŅ Ņ Đ°Đ´ĐŧиĐŊиŅŅŅаŅĐžŅĐžĐŧ, ŅŅĐžĐąŅ Đ´ĐžĐąĐ°Đ˛Đ¸ŅŅ URL ваŅĐĩĐŗĐž вĐĩĐą-ŅаКŅа в ŅĐŋиŅĐžĐē."},es:{landingTitle:"ÂŋCÃŗmo te gustarÃa comunicarte?",voiceCall:"Llamada de voz",textChat:"Chat de texto",clickToStartCall:"Haz clic para iniciar la llamada",realTimeVoice:"ConversaciÃŗn de voz en tiempo real",startCall:"Iniciar llamada",listening:"Escuchando...",speakFreely:"Habla libremente",liveTranscript:"TranscripciÃŗn en vivo",transcriptWillAppear:"La transcripciÃŗn aparecerÃĄ aquà durante la llamada...",mute:"Silenciar",speaker:"Altavoz",endCall:"Terminar llamada",hello:"ÂĄHola! ÂŋCÃŗmo puedo ayudarte?",sendMessage:"EnvÃa un mensaje para comenzar",online:"En lÃnea",newChat:"Nuevo chat",back:"AtrÃĄs",close:"Cerrar",error:"Error",typeMessage:"Escribe un mensaje...",sendMessageAria:"Enviar mensaje",domainNotValidated:"Dominio no validado",domainErrorMessage:"Este dominio no estÃĄ en la lista blanca. Por favor, contacte al administrador para agregar la URL de su sitio web a la lista."},fr:{landingTitle:"Comment souhaitez-vous communiquer?",voiceCall:"Appel vocal",textChat:"Chat texte",clickToStartCall:"Cliquez pour dÊmarrer l'appel",realTimeVoice:"Conversation vocale en temps rÊel",startCall:"DÊmarrer l'appel",listening:"Ãcoute...",speakFreely:"Parlez librement",liveTranscript:"TranscripciÃŗn en direct",transcriptWillAppear:"La transcription apparaÃŽtra ici pendant l'appel...",mute:"Muet",speaker:"Haut-parleur",endCall:"Terminer l'appel",hello:"Bonjour! Comment puis-je vous aider?",sendMessage:"Envoyez un message pour commencer",online:"En ligne",newChat:"Nouveau chat",back:"Retour",close:"Fermer",error:"Erreur",typeMessage:"Tapez votre message...",sendMessageAria:"Envoyer un message",domainNotValidated:"Domaine non validÊ",domainErrorMessage:"Ce domaine n'est pas sur la liste blanche. Veuillez contacter l'administrateur pour ajouter l'URL de votre site Web à la liste."},de:{landingTitle:"Wie mÃļchten Sie kommunizieren?",voiceCall:"Sprachanruf",textChat:"Text-Chat",clickToStartCall:"Klicken Sie, um den Anruf zu starten",realTimeVoice:"Sprachanruf in Echtzeit",startCall:"Anruf starten",listening:"HÃļren...",speakFreely:"Sprechen Sie frei",liveTranscript:"Live-Transkription",transcriptWillAppear:"Die Transkription erscheint hier während des Anrufs...",mute:"Stumm",speaker:"Lautsprecher",endCall:"Anruf beenden",hello:"Hallo! Wie kann ich helfen?",sendMessage:"Senden Sie eine Nachricht zum Starten",online:"Online",newChat:"Neuer Chat",back:"ZurÃŧck",close:"SchlieÃen",error:"Fehler",typeMessage:"Geben Sie eine Nachricht ein...",sendMessageAria:"Nachricht senden",domainNotValidated:"Domain nicht validiert",domainErrorMessage:"Diese Domain steht nicht auf der Whitelist. Bitte kontaktieren Sie den Administrator, um die URL Ihrer Website zur Liste hinzuzufÃŧgen."}};function _e(e,t,n,o,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,i)}function Oe(e){return function(){var t=this,n=arguments;return new Promise(function(o,i){var r=e.apply(t,n);function a(e){_e(r,o,i,a,s,"next",e)}function s(e){_e(r,o,i,a,s,"throw",e)}a(void 0)})}}function Me(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)}return n}function Ue(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Me(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Me(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class ze{constructor(){var e,t,n,o,i,r,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.config=this.mergeWithDefaults(a),this.sdk=new q(this.config),this.isOpen=!1,this.isActive=!1,this.translations=Be,this.currentView="landing",this.shadowRoot=null,this.container=null,this._pendingClientTools=null,this.config.useShadowDOM?(this.createShadowHost(),this.container=this.shadowRoot):(this.createRegularContainer(),this.container=this.regularContainer,this.shadowRoot=document);var s=Ue(Ue(Ue({},this.config),this.config.voice),{},{language:(null===(e=this.config.voice)||void 0===e?void 0:e.language)||this.config.language||"en",signedUrl:this.config.signedUrl,agentSettingsOverride:this.config.agentSettingsOverride,translations:this.translations,shadowRoot:this.shadowRoot,outputContainer:(null===(t=this.config.voice)||void 0===t?void 0:t.outputContainer)||"raw",outputEncoding:(null===(n=this.config.voice)||void 0===n?void 0:n.outputEncoding)||"pcm",outputSampleRate:(null===(o=this.config.voice)||void 0===o?void 0:o.outputSampleRate)||44100,outputChannels:(null===(i=this.config.voice)||void 0===i?void 0:i.outputChannels)||1,outputBitDepth:(null===(r=this.config.voice)||void 0===r?void 0:r.outputBitDepth)||16,onConversationStart:this.config.onConversationStart,onConversationEnd:this.config.onConversationEnd,onBargeIn:this.config.onBargeIn,onAudioStartPlaying:this.config.onAudioStartPlaying,onAudioStoppedPlaying:this.config.onAudioStoppedPlaying,onSubtitleDisplay:this.config.onSubtitleDisplay});this.voiceInterface=new Ae(s);var c=Ue(Ue(Ue({},this.config),this.config.text),{},{translations:this.translations,shadowRoot:this.shadowRoot});if(this.textInterface=new Fe(c,this.sdk),this.createWidget(),this.setupEventHandlers(),this.config.behavior.startOpen||this.config.behavior.autoOpen){var l,d=null===(l=this.shadowRoot)||void 0===l?void 0:l.getElementById("text-chat-panel");d&&(this.isOpen=!0,d.classList.add("open"))}this.checkAndHandleResume()}checkAndHandleResume(){var e=this.voiceInterface.checkAndHandleResume();e&&(console.log("đ [WIDGET] Auto-resuming call from page navigation"),console.log(" From:",e.fromPage,"â To:",e.toPage),this.open(),this.showVoice(),setTimeout(()=>{this.startVoiceCall().then(()=>{console.log("â
[WIDGET] Auto-resumed call successfully")}).catch(e=>{console.error("â [WIDGET] Failed to auto-resume call:",e)})},100))}open(){var e;if(!this.isOpen){var t=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("text-chat-panel");t&&(this.isOpen=!0,t.classList.add("open"))}}mergeWithDefaults(e){var t,n,o,i,r,a,s,c,l,d,u,h,p,g,m,v,f,y,x,b,w,S,C,k,P,E,T,I,A,R,D,F,B,_,O,M,U,N,z,H,L,K,V,j,W,q,Q,G,Y,J,$,X,Z,ee,te,ne,oe,ie,re,ae,se,ce,le,de,ue,he,pe,ge,me,ve,fe,ye,xe,be,we,Se,Ce,ke,Pe,Ee,Te,Ie,Ae,Re,De,Fe,Be,_e,Oe,Me,Ne,ze,He,Le,Ke,Ve,je,We,qe,Qe,Ge,Ye,Je,$e,Xe,Ze,et,tt,nt,ot,it,rt,at,st,ct,lt,dt,ut,ht,pt,gt,mt,vt,ft,yt,xt,bt,wt,St,Ct,kt,Pt,Et,Tt,It,At,Rt,Dt,Ft,Bt,_t=e.position||"bottom-right";if("string"==typeof _t){var Ot=_t.split("-");_t={vertical:Ot[0]||"bottom",horizontal:Ot[1]||"right",offset:e.positionOffset||{x:20,y:20}}}var Mt=e.primaryColor||(null===(t=e.button)||void 0===t?void 0:t.primaryColor)||(null===(n=e.button)||void 0===n?void 0:n.backgroundColor)||"#FFFFFF",Ut=(null===(o=e.header)||void 0===o?void 0:o.backgroundColor)||"#7C3AED";return Ue({agentId:e.agentId,appId:e.appId,signedUrl:e.signedUrl,agentSettingsOverride:e.agentSettingsOverride,demo:!1!==e.demo,direction:e.direction||"ltr",language:e.language||"en",icon:Ue({type:(null===(i=e.icon)||void 0===i?void 0:i.type)||"custom",customImage:(null===(r=e.icon)||void 0===r?void 0:r.customImage)||"https://talktopc.com/logo192.png",emoji:(null===(a=e.icon)||void 0===a?void 0:a.emoji)||"đ¤",text:(null===(s=e.icon)||void 0===s?void 0:s.text)||"AI",size:(null===(c=e.icon)||void 0===c?void 0:c.size)||"medium",backgroundColor:(null===(l=e.icon)||void 0===l?void 0:l.backgroundColor)||"#FFFFFF"},e.icon),position:Ue({vertical:_t.vertical||"bottom",horizontal:_t.horizontal||"right",offset:_t.offset||{x:20,y:20}},"object"==typeof e.position?e.position:{}),button:Ue({size:(null===(d=e.button)||void 0===d?void 0:d.size)||"medium",shape:(null===(u=e.button)||void 0===u?void 0:u.shape)||"circle",backgroundColor:(null===(h=e.button)||void 0===h?void 0:h.backgroundColor)||(null===(p=e.icon)||void 0===p?void 0:p.backgroundColor)||"#FFFFFF",hoverColor:(null===(g=e.button)||void 0===g?void 0:g.hoverColor)||"#D3D3D3",shadow:!1!==(null===(m=e.button)||void 0===m?void 0:m.shadow),shadowColor:(null===(v=e.button)||void 0===v?void 0:v.shadowColor)||"rgba(0,0,0,0.15)",primaryColor:(null===(f=e.button)||void 0===f?void 0:f.backgroundColor)||(null===(y=e.icon)||void 0===y?void 0:y.backgroundColor)||"#FFFFFF"},e.button),panel:Ue({width:(null===(x=e.panel)||void 0===x?void 0:x.width)||350,height:(null===(b=e.panel)||void 0===b?void 0:b.height)||500,borderRadius:(null===(w=e.panel)||void 0===w?void 0:w.borderRadius)||12,backgroundColor:(null===(S=e.panel)||void 0===S?void 0:S.backgroundColor)||"#FFFFFF",backdropFilter:(null===(C=e.panel)||void 0===C?void 0:C.backdropFilter)||null,border:(null===(k=e.panel)||void 0===k?void 0:k.border)||"1px solid #E5E7EB"},e.panel),voice:Ue({micButtonColor:(null===(P=e.voice)||void 0===P?void 0:P.micButtonColor)||(null===(E=e.panel)||void 0===E?void 0:E.micButtonColor)||Mt,micButtonActiveColor:(null===(T=e.voice)||void 0===T?void 0:T.micButtonActiveColor)||(null===(I=e.panel)||void 0===I?void 0:I.micButtonActiveColor)||"#EF4444",micButtonHint:Ue(Ue({text:(null===(A=e.voice)||void 0===A||null===(A=A.micButtonHint)||void 0===A?void 0:A.text)||(null===(R=e.panel)||void 0===R||null===(R=R.micButtonHint)||void 0===R?void 0:R.text)||"Click the button to start voice conversation",color:(null===(D=e.voice)||void 0===D||null===(D=D.micButtonHint)||void 0===D?void 0:D.color)||(null===(F=e.panel)||void 0===F||null===(F=F.micButtonHint)||void 0===F?void 0:F.color)||"#6B7280",fontSize:(null===(B=e.voice)||void 0===B||null===(B=B.micButtonHint)||void 0===B?void 0:B.fontSize)||(null===(_=e.panel)||void 0===_||null===(_=_.micButtonHint)||void 0===_?void 0:_.fontSize)||"12px"},null===(O=e.voice)||void 0===O?void 0:O.micButtonHint),null===(M=e.panel)||void 0===M?void 0:M.micButtonHint),avatarBackgroundColor:(null===(U=e.voice)||void 0===U?void 0:U.avatarBackgroundColor)||"#667eea",avatarActiveBackgroundColor:(null===(N=e.voice)||void 0===N?void 0:N.avatarActiveBackgroundColor)||"#667eea",statusTitleColor:(null===(z=e.voice)||void 0===z?void 0:z.statusTitleColor)||"#1e293b",statusSubtitleColor:(null===(H=e.voice)||void 0===H?void 0:H.statusSubtitleColor)||"#64748b",startCallButtonColor:(null===(L=e.voice)||void 0===L?void 0:L.startCallButtonColor)||"#667eea",startCallButtonTextColor:(null===(K=e.voice)||void 0===K?void 0:K.startCallButtonTextColor)||"#FFFFFF",startCallTitle:(null===(V=e.voice)||void 0===V?void 0:V.startCallTitle)||null,startCallSubtitle:(null===(j=e.voice)||void 0===j?void 0:j.startCallSubtitle)||null,startCallButtonText:(null===(W=e.voice)||void 0===W?void 0:W.startCallButtonText)||null,transcriptBackgroundColor:(null===(q=e.voice)||void 0===q?void 0:q.transcriptBackgroundColor)||"#FFFFFF",transcriptTextColor:(null===(Q=e.voice)||void 0===Q?void 0:Q.transcriptTextColor)||"#1e293b",transcriptLabelColor:(null===(G=e.voice)||void 0===G?void 0:G.transcriptLabelColor)||"#94a3b8",controlButtonColor:(null===(Y=e.voice)||void 0===Y?void 0:Y.controlButtonColor)||"#FFFFFF",controlButtonSecondaryColor:(null===(J=e.voice)||void 0===J?void 0:J.controlButtonSecondaryColor)||"#64748b",endCallButtonColor:(null===($=e.voice)||void 0===$?void 0:$.endCallButtonColor)||"#ef4444",language:(null===(X=e.voice)||void 0===X?void 0:X.language)||e.language||"en"},e.voice),text:Ue({sendButtonColor:(null===(Z=e.text)||void 0===Z?void 0:Z.sendButtonColor)||(null===(ee=e.panel)||void 0===ee?void 0:ee.sendButtonColor)||"#7C3AED",sendButtonHoverColor:(null===(te=e.text)||void 0===te?void 0:te.sendButtonHoverColor)||(null===(ne=e.panel)||void 0===ne?void 0:ne.sendButtonHoverColor)||"#6D28D9",sendButtonActiveColor:(null===(oe=e.text)||void 0===oe?void 0:oe.sendButtonActiveColor)||(null===(ie=e.panel)||void 0===ie?void 0:ie.sendButtonActiveColor)||"#6D28D9",sendButtonText:(null===(re=e.text)||void 0===re?void 0:re.sendButtonText)||(null===(ae=e.panel)||void 0===ae?void 0:ae.sendButtonText)||"â¤",sendButtonTextColor:(null===(se=e.text)||void 0===se?void 0:se.sendButtonTextColor)||(null===(ce=e.panel)||void 0===ce?void 0:ce.sendButtonTextColor)||"#FFFFFF",sendButtonFontSize:(null===(le=e.text)||void 0===le?void 0:le.sendButtonFontSize)||(null===(de=e.panel)||void 0===de?void 0:de.sendButtonFontSize)||"18px",sendButtonFontWeight:(null===(ue=e.text)||void 0===ue?void 0:ue.sendButtonFontWeight)||(null===(he=e.panel)||void 0===he?void 0:he.sendButtonFontWeight)||"500",sendButtonHint:Ue(Ue({text:(null===(pe=e.text)||void 0===pe||null===(pe=pe.sendButtonHint)||void 0===pe?void 0:pe.text)||(null===(ge=e.panel)||void 0===ge||null===(ge=ge.sendButtonHint)||void 0===ge?void 0:ge.text)||"",color:(null===(me=e.text)||void 0===me||null===(me=me.sendButtonHint)||void 0===me?void 0:me.color)||(null===(ve=e.panel)||void 0===ve||null===(ve=ve.sendButtonHint)||void 0===ve?void 0:ve.color)||"#6B7280",fontSize:(null===(fe=e.text)||void 0===fe||null===(fe=fe.sendButtonHint)||void 0===fe?void 0:fe.fontSize)||(null===(ye=e.panel)||void 0===ye||null===(ye=ye.sendButtonHint)||void 0===ye?void 0:ye.fontSize)||"12px"},null===(xe=e.text)||void 0===xe?void 0:xe.sendButtonHint),null===(be=e.panel)||void 0===be?void 0:be.sendButtonHint),inputPlaceholder:(null===(we=e.text)||void 0===we?void 0:we.inputPlaceholder)||(null===(Se=e.panel)||void 0===Se?void 0:Se.inputPlaceholder)||"Type your message...",inputBorderColor:(null===(Ce=e.text)||void 0===Ce?void 0:Ce.inputBorderColor)||(null===(ke=e.panel)||void 0===ke?void 0:ke.inputBorderColor)||"#E5E7EB",inputFocusColor:(null===(Pe=e.text)||void 0===Pe?void 0:Pe.inputFocusColor)||(null===(Ee=e.panel)||void 0===Ee?void 0:Ee.inputFocusColor)||"#7C3AED",inputBackgroundColor:(null===(Te=e.text)||void 0===Te?void 0:Te.inputBackgroundColor)||(null===(Ie=e.panel)||void 0===Ie?void 0:Ie.inputBackgroundColor)||"#FFFFFF",inputTextColor:(null===(Ae=e.text)||void 0===Ae?void 0:Ae.inputTextColor)||(null===(Re=e.panel)||void 0===Re?void 0:Re.inputTextColor)||"#1F2937",inputFontSize:(null===(De=e.text)||void 0===De?void 0:De.inputFontSize)||(null===(Fe=e.panel)||void 0===Fe?void 0:Fe.inputFontSize)||"14px",inputBorderRadius:(null===(Be=e.text)||void 0===Be?void 0:Be.inputBorderRadius)||(null===(_e=e.panel)||void 0===_e?void 0:_e.inputBorderRadius)||20,inputPadding:(null===(Oe=e.text)||void 0===Oe?void 0:Oe.inputPadding)||(null===(Me=e.panel)||void 0===Me?void 0:Me.inputPadding)||"6px 14px"},e.text),landing:Ue({backgroundColor:(null===(Ne=e.landing)||void 0===Ne?void 0:Ne.backgroundColor)||"linear-gradient(180deg, #f8fafc 0%, #e0e7ff 100%)",logo:(null===(ze=e.landing)||void 0===ze?void 0:ze.logo)||"đ¤",title:(null===(He=e.landing)||void 0===He?void 0:He.title)||null,titleColor:(null===(Le=e.landing)||void 0===Le?void 0:Le.titleColor)||"#1e293b",modeCardBackgroundColor:(null===(Ke=e.landing)||void 0===Ke?void 0:Ke.modeCardBackgroundColor)||"#FFFFFF",modeCardBorderColor:(null===(Ve=e.landing)||void 0===Ve?void 0:Ve.modeCardBorderColor)||"#E2E8F0",modeCardHoverBorderColor:(null===(je=e.landing)||void 0===je?void 0:je.modeCardHoverBorderColor)||Ut,modeCardIconBackgroundColor:(null===(We=e.landing)||void 0===We?void 0:We.modeCardIconBackgroundColor)||Ut,modeCardTitleColor:(null===(qe=e.landing)||void 0===qe?void 0:qe.modeCardTitleColor)||"#111827",voiceCardIcon:(null===(Qe=e.landing)||void 0===Qe?void 0:Qe.voiceCardIcon)||"đ¤",textCardIcon:(null===(Ge=e.landing)||void 0===Ge?void 0:Ge.textCardIcon)||"đŦ",voiceCardTitle:(null===(Ye=e.landing)||void 0===Ye?void 0:Ye.voiceCardTitle)||null,textCardTitle:(null===(Je=e.landing)||void 0===Je?void 0:Je.textCardTitle)||null},e.landing),header:Ue({title:(null===($e=e.header)||void 0===$e?void 0:$e.title)||"Chat Assistant",showTitle:!1!==(null===(Xe=e.header)||void 0===Xe?void 0:Xe.showTitle),backgroundColor:(null===(Ze=e.header)||void 0===Ze?void 0:Ze.backgroundColor)||"#7C3AED",textColor:(null===(et=e.header)||void 0===et?void 0:et.textColor)||"#FFFFFF",showCloseButton:!1!==(null===(tt=e.header)||void 0===tt?void 0:tt.showCloseButton)},e.header),footer:Ue({show:!1!==(null===(nt=e.footer)||void 0===nt?void 0:nt.show),backgroundColor:(null===(ot=e.footer)||void 0===ot?void 0:ot.backgroundColor)||"#f9fafb",textColor:(null===(it=e.footer)||void 0===it?void 0:it.textColor)||"#9ca3af",hoverColor:(null===(rt=e.footer)||void 0===rt?void 0:rt.hoverColor)||"#7C3AED"},e.footer),tooltips:Ue({newChat:(null===(at=e.tooltips)||void 0===at?void 0:at.newChat)||null,back:(null===(st=e.tooltips)||void 0===st?void 0:st.back)||null,close:(null===(ct=e.tooltips)||void 0===ct?void 0:ct.close)||null,mute:(null===(lt=e.tooltips)||void 0===lt?void 0:lt.mute)||null,speaker:(null===(dt=e.tooltips)||void 0===dt?void 0:dt.speaker)||null,endCall:(null===(ut=e.tooltips)||void 0===ut?void 0:ut.endCall)||null},e.tooltips),messages:Ue({userBackgroundColor:(null===(ht=e.messages)||void 0===ht?void 0:ht.userBackgroundColor)||"#E5E7EB",agentBackgroundColor:(null===(pt=e.messages)||void 0===pt?void 0:pt.agentBackgroundColor)||"#F3F4F6",systemBackgroundColor:(null===(gt=e.messages)||void 0===gt?void 0:gt.systemBackgroundColor)||"#DCFCE7",errorBackgroundColor:(null===(mt=e.messages)||void 0===mt?void 0:mt.errorBackgroundColor)||"#FEE2E2",textColor:(null===(vt=e.messages)||void 0===vt?void 0:vt.textColor)||"#1F2937",fontSize:(null===(ft=e.messages)||void 0===ft?void 0:ft.fontSize)||"14px",borderRadius:(null===(yt=e.messages)||void 0===yt?void 0:yt.borderRadius)||8},e.messages),animation:Ue({enableHover:!1!==(null===(xt=e.animation)||void 0===xt?void 0:xt.enableHover),enablePulse:!1!==(null===(bt=e.animation)||void 0===bt?void 0:bt.enablePulse),enableSlide:!1!==(null===(wt=e.animation)||void 0===wt?void 0:wt.enableSlide),duration:(null===(St=e.animation)||void 0===St?void 0:St.duration)||.3},e.animation),behavior:Ue({autoOpen:(null===(Ct=e.behavior)||void 0===Ct?void 0:Ct.autoOpen)||!1,startOpen:(null===(kt=e.behavior)||void 0===kt?void 0:kt.startOpen)||!1,hidden:(null===(Pt=e.behavior)||void 0===Pt?void 0:Pt.hidden)||!1,autoConnect:(null===(Et=e.behavior)||void 0===Et?void 0:Et.autoConnect)||!1,showWelcomeMessage:!1!==(null===(Tt=e.behavior)||void 0===Tt?void 0:Tt.showWelcomeMessage),welcomeMessage:(null===(It=e.behavior)||void 0===It?void 0:It.welcomeMessage)||"Hello! How can I help you today?",enableVoiceMode:void 0===(null===(At=e.behavior)||void 0===At?void 0:At.enableVoiceMode)||e.behavior.enableVoiceMode,mode:(null===(Rt=e.behavior)||void 0===Rt?void 0:Rt.mode)||"unified"},e.behavior),accessibility:Ue({ariaLabel:(null===(Dt=e.accessibility)||void 0===Dt?void 0:Dt.ariaLabel)||"Chat Assistant",ariaDescription:(null===(Ft=e.accessibility)||void 0===Ft?void 0:Ft.ariaDescription)||"Click to open chat assistant",keyboardNavigation:!1!==(null===(Bt=e.accessibility)||void 0===Bt?void 0:Bt.keyboardNavigation)},e.accessibility),customStyles:e.customStyles||"",useShadowDOM:!1!==e.useShadowDOM,variables:e.variables||{},forceConversationId:e.forceConversationId,onConversationStart:e.onConversationStart,onConversationEnd:e.onConversationEnd,onBargeIn:e.onBargeIn,onAudioStartPlaying:e.onAudioStartPlaying,onAudioStoppedPlaying:e.onAudioStoppedPlaying,onSubtitleDisplay:e.onSubtitleDisplay,primaryColor:Mt},"string"==typeof e.position?{positionString:e.position}:{})}setupEventHandlers(){this.sdk.on("domainError",e=>{this.textInterface.showError(e),this.textInterface.stopStreamingState()}),this.sdk.on("error",e=>{e&&("DOMAIN_NOT_WHITELISTED"===e.message||e.message&&e.message.includes("Domain not whitelisted"))||(this.textInterface.showError(e.message||e),this.textInterface.stopStreamingState())}),this.sdk.on("chunk",e=>{this.textInterface.appendStreamingChunk(e)}),this.sdk.on("done",e=>{var{text:t}=e;this.textInterface.finalizeStreaming(t)})}createShadowHost(){var e=document.getElementById("ttp-widget-shadow-host");e&&e.remove();var t=document.createElement("div");t.id="ttp-widget-shadow-host",t.style.cssText="position: fixed; z-index: 10000; pointer-events: none; top: 0; left: 0; width: 100%; height: 100%; overflow: visible;",this.shadowRoot=t.attachShadow({mode:"open"}),document.body.appendChild(t)}createRegularContainer(){var e=document.getElementById("ttp-widget-container");e&&e.remove();var t=document.createElement("div");t.id="ttp-widget-container",t.style.cssText="position: fixed; z-index: 10000; pointer-events: none; top: 0; left: 0; width: 100%; height: 100%; overflow: visible;",document.body.appendChild(t),this.regularContainer=t}createWidget(){this.container||(this.config.useShadowDOM?(this.createShadowHost(),this.container=this.shadowRoot):(this.createRegularContainer(),this.container=this.regularContainer,this.shadowRoot=document));var e;e=this.config.useShadowDOM?"\n :host {\n all: initial;\n display: block;\n pointer-events: none;\n }\n img {\n max-width: none !important;\n }\n #text-chat-button img {\n width: 28px !important;\n height: 28px !important;\n }\n #text-chat-button {\n pointer-events: auto;\n }\n #text-chat-panel {\n pointer-events: auto;\n }\n ":'\n /* Reset only problematic inherited styles, not all styles */\n #text-chat-button,\n #text-chat-panel,\n #text-chat-panel * {\n box-sizing: border-box;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n }\n \n /* Prevent theme CSS from affecting images */\n #text-chat-button img,\n #text-chat-panel img {\n max-width: none !important;\n width: auto;\n height: auto;\n }\n \n #text-chat-button img {\n width: 28px !important;\n height: 28px !important;\n }\n \n /* Ensure button and panel can receive clicks */\n #text-chat-button,\n #text-chat-panel {\n pointer-events: auto;\n }\n \n /* Reset any inherited text styles that might break layout */\n #text-chat-panel {\n text-align: left;\n line-height: normal;\n letter-spacing: normal;\n word-spacing: normal;\n text-transform: none;\n text-indent: 0;\n text-shadow: none;\n white-space: normal;\n }\n \n /* Ensure flexbox works properly */\n #text-chat-panel .widget-shell,\n #text-chat-panel .panel-inner,\n #text-chat-panel .widget-container,\n #text-chat-panel .landing-screen,\n #text-chat-panel .voice-interface,\n #text-chat-panel .text-interface,\n #text-chat-panel .widget-header,\n #text-chat-panel .mode-selection {\n display: flex;\n }\n \n #text-chat-panel .widget-shell,\n #text-chat-panel .panel-inner,\n #text-chat-panel .widget-container,\n #text-chat-panel .landing-screen,\n #text-chat-panel .voice-interface,\n #text-chat-panel .text-interface {\n flex-direction: column;\n }\n \n #text-chat-panel .mode-selection {\n flex-direction: row;\n }\n \n /* Ensure proper stacking */\n #text-chat-button {\n z-index: 10001 !important;\n }\n \n #text-chat-panel {\n z-index: 10000 !important;\n }\n ';var t=this.generateWidgetHTML();if(this.config.useShadowDOM){var n="\n <style>".concat(e,"</style>\n ").concat(t,"\n ");this.shadowRoot.innerHTML=n}else this.injectStylesIntoHead(e),this.container.innerHTML=t;this.setupWidgetEvents();var o=this.shadowRoot.getElementById("text-chat-panel");o&&(this.config.behavior.startOpen||this.config.behavior.autoOpen)&&(this.isOpen=!0,o.classList.add("open"))}injectStylesIntoHead(e){var t,n,o=document.getElementById("ttp-widget-styles");o&&o.remove();var i={small:50,medium:60,large:70,xl:80}[null===(t=this.config.button)||void 0===t?void 0:t.size]||60,r={small:20,medium:28,large:36,xl:44}[null===(n=this.config.icon)||void 0===n?void 0:n.size]||28,a=this.generatePositionStyles(),s=this.generateCSS(a,i,r),c=document.createElement("style");c.id="ttp-widget-styles",c.textContent=e+"\n"+s,this.config.customStyles&&(c.textContent+="\n"+this.config.customStyles),document.head.appendChild(c)}generateWidgetHTML(){this.config.position;var e,t,n,o,i=this.config.button,r=this.config.icon,a=(this.config.panel,this.config.header),s=(this.config.animation,{small:50,medium:60,large:70,xl:80}[i.size]||60),c={small:20,medium:28,large:36,xl:44}[r.size]||28,l=this.generatePositionStyles(),d=this.generateIconHTML(c),u=this.config.behavior.mode||"unified",h="unified"===u,p="unified"===u||"voice-only"===u,g="unified"===u||"text-only"===u,m=e=>{var t=this.config.language||"en";return(this.translations[t]||this.translations.en)[e]||e},v=e=>{var t,n=null===(t=this.config.tooltips)||void 0===t?void 0:t[e];return null!=n?n:{newChat:m("newChat"),back:m("back"),close:m("close"),mute:m("mute"),speaker:m("speaker"),endCall:m("endCall")}[e]||""},f=this.config.useShadowDOM?"\n <style>\n ".concat(this.generateCSS(l,s,c),"\n ").concat(this.config.customStyles,"\n </style>\n "):"";return"\n ".concat(f,"\n \n ").concat(this.config.behavior.hidden?"":'\n <button id="text-chat-button" \n aria-label="'.concat(this.config.accessibility.ariaLabel,'"\n aria-description="').concat(this.config.accessibility.ariaDescription,'">\n ').concat(d,"\n </button>\n "),'\n \n <div id="text-chat-panel">\n <div class="widget-shell">\n <div class="panel-inner widget-container" style="direction: ').concat(this.config.direction,';">\n <div class="widget-header" style="background: ').concat(a.backgroundColor,"; color: ").concat(a.textColor,';">\n <div>\n ').concat(a.showTitle?'<div class="header-title">'.concat(a.title,"</div>"):"",'\n <div class="header-status">\n <span class="status-dot"></span>\n <span>').concat(m("online"),'</span>\n </div>\n </div>\n \n <div style="display: flex; gap: 12px; align-items: center;">\n \x3c!-- New Chat Button (hide on landing screen, show otherwise) --\x3e\n <button class="header-icon new-chat-btn" id="newChatBtn" title="').concat(v("newChat"),'" style="').concat(h?"display: none;":"",'">\n <span style="font-size: 18px; font-weight: bold;">+</span>\n </button>\n \n \x3c!-- Back Button (only show in unified mode) --\x3e\n ').concat("unified"===u?'<button class="header-icon back-btn" id="backBtn" title="'.concat(v("back"),'" style="display: none;">\n <span style="font-size: 16px;">âš</span>\n </button>'):"","\n \n \x3c!-- Close Button --\x3e\n ").concat(a.showCloseButton?'<button class="header-icon close-btn" id="closeBtn" title="'+v("close")+'"><span style="font-size: 18px; font-weight: bold;">Ã</span></button>':"","\n </div>\n </div>\n\n ").concat(h?'\n <div class="landing-screen" id="landingScreen">\n <div class="landing-logo">'.concat((null===(e=this.config.landing)||void 0===e?void 0:e.logo)||"đ¤",'</div>\n <div class="landing-title">').concat((null===(t=this.config.landing)||void 0===t?void 0:t.title)||m("landingTitle"),'</div>\n <div class="mode-selection">\n ').concat(p?'<div class="mode-card voice" id="mode-card-voice">\n <div class="mode-card-icon">đ¤</div>\n <div class="mode-card-title">'.concat((null===(n=this.config.landing)||void 0===n?void 0:n.voiceCardTitle)||m("voiceCall"),"</div>\n </div>"):"","\n ").concat(g?'<div class="mode-card text" id="mode-card-text">\n <div class="mode-card-icon">đŦ</div>\n <div class="mode-card-title">'.concat((null===(o=this.config.landing)||void 0===o?void 0:o.textCardTitle)||m("textChat"),"</div>\n </div>"):"","\n </div>\n </div>"):"","\n\n ").concat(p?this.voiceInterface.generateHTML():"","\n ").concat(g?this.textInterface.generateHTML():"","\n ").concat(this.generateFooterHTML(),"\n </div>\n </div>\n </div>\n ")}generateFooterHTML(){var e=this.config.footer;if(!e.show)return"";var t=encodeURIComponent(window.location.hostname||"widget"),n="https://talktopc.com?ref=widget&source=".concat(t);return'\n <div class="widget-footer" style="\n height: 36px;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n background-color: '.concat(e.backgroundColor,';\n border-top: 1px solid #e5e7eb;\n flex-shrink: 0;\n ">\n <a \n href="').concat(n,'" \n target="_blank" \n rel="noopener noreferrer"\n aria-label="Visit TalkToPC website"\n class="footer-brand-link"\n style="\n display: flex;\n flex-direction: column;\n align-items: center;\n text-decoration: none;\n color: ').concat(e.textColor,';\n transition: color 0.2s ease;\n "\n onmouseover="this.style.color=\'').concat(e.hoverColor,"'\"\n onmouseout=\"this.style.color='").concat(e.textColor,'\'"\n >\n <span style="font-size: 11px; line-height: 1.3;">\n ⥠Powered by <strong>TalkToPC</strong>\n </span>\n <span style="font-size: 9px; opacity: 0.7; line-height: 1.2;">\n https://talktopc.com\n </span>\n </a>\n </div>\n ')}generatePositionStyles(){var e=this.config.position,t=e.offset||{x:20,y:20},n="";return"top"===e.vertical?n+="top: ".concat(t.y,"px;"):"bottom"===e.vertical?n+="bottom: ".concat(t.y,"px;"):"center"===e.vertical&&(n+="top: 50%; transform: translateY(-50%);"),"left"===e.horizontal?n+="left: ".concat(t.x,"px;"):"right"===e.horizontal?n+="right: ".concat(t.x,"px;"):"center"===e.horizontal&&(n+="left: 50%; transform: translateX(-50%);"),n}generateIconHTML(e){var t=this.config.icon;switch(t.type){case"custom":return'<img src="'.concat(t.customImage,'" alt="Chat Assistant" style="width: ').concat(e,"px; height: ").concat(e,'px; object-fit: contain;" />');case"emoji":return'<span style="font-size: '.concat(e,'px; line-height: 1;">').concat(t.emoji,"</span>");case"text":return'<span style="font-size: '.concat(Math.floor(.6*e),'px; font-weight: bold; color: white;">').concat(t.text,"</span>");case"microphone":default:return'<svg viewBox="0 0 24 24" style="width: '.concat(e,"px; height: ").concat(e,'px; fill: white;">\n <path d="M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"/>\n <path d="M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"/>\n </svg>');case"chat":return'<svg viewBox="0 0 24 24" style="width: '.concat(e,"px; height: ").concat(e,'px; fill: white;">\n <path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"/>\n </svg>')}}generateCSS(e,t,n){var o,i,r,a,s,c,l,d,u,h,p,g=this.config.button,m=this.config.icon,v=this.config.panel,f=this.config.header,y=(this.config.messages,this.config.animation),x=this.config.behavior.mode||"unified",b="unified"===x||"voice-only"===x,w="unified"===x||"text-only"===x,S=!1===this.config.useShadowDOM?" !important":"",C=f.backgroundColor;return'\n /* MOBILE FIRST - Default styles for all devices */\n #text-chat-widget {\n position: fixed !important;\n z-index: 10000;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n /* Mobile defaults */\n right: 10px;\n bottom: 10px;\n left: auto;\n top: auto;\n }\n \n /* Desktop positioning (only on larger screens) */\n @media (min-width: 769px) {\n #text-chat-widget {\n '.concat(e,"\n right: ").concat("right"===this.config.position.horizontal?"20px":"auto",";\n left: ").concat("left"===this.config.position.horizontal?"20px":"auto",";\n bottom: ").concat("bottom"===this.config.position.vertical?"20px":"auto",";\n top: ").concat("top"===this.config.position.vertical?"20px":"auto",";\n }\n }\n \n /* Mobile override (force mobile positioning) */\n @media (max-width: 768px) {\n #text-chat-widget {\n right: 10px !important;\n bottom: 10px !important;\n left: auto !important;\n top: auto !important;\n transform: none !important;\n }\n }\n \n @media (max-width: 480px) {\n #text-chat-widget {\n right: 8px !important;\n bottom: 8px !important;\n left: auto !important;\n top: auto !important;\n }\n }\n \n #text-chat-button {\n position: fixed;\n ").concat("bottom"===this.config.position.vertical?"bottom: ".concat((null===(o=this.config.position.offset)||void 0===o?void 0:o.y)||20,"px;"):"top: ".concat((null===(i=this.config.position.offset)||void 0===i?void 0:i.y)||20,"px;"),"\n ").concat("right"===this.config.position.horizontal?"right: ".concat((null===(r=this.config.position.offset)||void 0===r?void 0:r.x)||20,"px;"):"left: ".concat((null===(a=this.config.position.offset)||void 0===a?void 0:a.x)||20,"px;"),"\n width: ").concat(t,"px;\n height: ").concat(t,"px;\n border-radius: ").concat("circle"===g.shape?"50%":"square"===g.shape?"0":"12px",";\n background: ").concat(g.backgroundColor||m.backgroundColor||"#7C3AED",";\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all ").concat(y.duration,"s ease;\n box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);\n touch-action: manipulation;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n user-select: none;\n min-width: 44px;\n min-height: 44px;\n z-index: 10001;\n }\n \n @media (max-width: 768px) {\n #text-chat-widget {\n right: 10px !important;\n bottom: 10px !important;\n left: auto !important;\n top: auto !important;\n transform: none !important;\n }\n \n #text-chat-button {\n right: 10px !important;\n bottom: 10px !important;\n left: auto !important;\n top: auto !important;\n width: 56px !important;\n height: 56px !important;\n min-width: 56px !important;\n min-height: 56px !important;\n max-width: 56px !important;\n max-height: 56px !important;\n }\n \n #text-chat-panel {\n position: fixed !important;\n left: 10px !important;\n right: 10px !important;\n bottom: 92px !important; /* 56px button + 20px gap + 16px footer */\n top: 60px !important; /* Add top spacing */\n width: auto !important;\n max-width: none !important;\n height: auto !important; /* Change from max-height to auto */\n max-height: none !important; /* Remove max-height */\n transform: none !important;\n margin: 0 !important;\n }\n \n #text-chat-panel .widget-header {\n padding: 10px 14px;\n min-height: 56px;\n }\n \n #text-chat-panel .header-title {\n font-size: 15px;\n }\n \n #text-chat-panel .header-icon {\n width: 40px;\n height: 40px;\n min-width: 40px;\n min-height: 40px;\n }\n \n #text-chat-input {\n font-size: 16px !important; /* Prevents iOS zoom on focus */\n padding: 12px 16px !important;\n min-height: 48px !important;\n }\n \n #text-chat-send {\n min-width: 48px !important;\n min-height: 48px !important;\n width: 48px !important;\n height: 48px !important;\n }\n \n .landing-screen {\n padding: 16px;\n }\n \n .landing-logo {\n font-size: 40px;\n }\n \n .landing-title {\n font-size: 18px;\n margin-bottom: 16px;\n }\n \n .mode-selection {\n flex-direction: column;\n gap: 12px;\n align-items: center;\n }\n \n .mode-card {\n max-width: 100%;\n width: 100%;\n padding: 16px;\n }\n \n .mode-card-icon {\n width: 50px;\n height: 50px;\n font-size: 28px;\n }\n \n .mode-card-title {\n font-size: 14px;\n }\n }\n \n @media (max-width: 480px) {\n #text-chat-widget {\n right: 8px !important;\n bottom: 8px !important;\n left: auto !important;\n top: auto !important;\n }\n \n #text-chat-button {\n right: 8px !important;\n bottom: 8px !important;\n left: auto !important;\n top: auto !important;\n width: 54px !important;\n height: 54px !important;\n min-width: 54px !important;\n min-height: 54px !important;\n }\n \n #text-chat-panel {\n left: 8px !important;\n right: 8px !important;\n bottom: 86px !important; /* 54px button + 20px gap + 12px footer */\n top: 50px !important; /* Add top spacing for very small screens */\n height: auto !important;\n max-height: none !important;\n }\n \n #text-chat-panel .widget-header {\n padding: 8px 12px;\n min-height: 52px;\n }\n \n #text-chat-panel .header-title {\n font-size: 14px;\n }\n \n .landing-logo {\n font-size: 36px;\n }\n \n .landing-title {\n font-size: 16px;\n }\n }\n \n ").concat(y.enableHover?"\n #text-chat-button:hover {\n ".concat(g.hoverColor?"background: ".concat(g.hoverColor,";"):"","\n transform: scale(1.05);\n box-shadow: 0 8px 20px rgba(102, 126, 234, 0.5);\n }\n "):"","\n \n #text-chat-panel {\n display: none").concat(S,";\n position: fixed;\n bottom: calc(").concat(t,"px + 20px + 20px); /* Button + gap + reduced footer offset */\n ").concat("right"===this.config.position.horizontal?"right: 20px;":"left: 20px;","\n width: ").concat(v.width,"px;\n max-width: calc(100vw - 40px);\n height: ").concat(v.height,"px;\n max-height: calc(100vh - ").concat(t,"px - 40px - 20px); /* Account for footer height */\n background: transparent;\n border-radius: ").concat(v.borderRadius,"px;\n border: none;\n flex-direction: column;\n overflow: hidden;\n ").concat(v.backdropFilter?"backdrop-filter: ".concat(v.backdropFilter,";"):"","\n ").concat(y.enableSlide?"transition: all ".concat(y.duration,"s ease;"):"","\n box-sizing: border-box;\n }\n \n #text-chat-panel.open {\n display: flex").concat(S,";\n ").concat(y.enableSlide?"transform: translateY(0); opacity: 1;":"","\n }\n\n /* Shell for gradient border/background */\n .widget-shell { width: 100%; height: 100%; padding: 0; border-radius: ").concat(v.borderRadius,"px; background: transparent; box-shadow: 0 20px 60px rgba(0,0,0,0.15); overflow: hidden; display: flex; flex-direction: column; box-sizing: border-box; }\n .panel-inner { width: 100%; height: 100%; background: #ffffff; border-radius: ").concat(v.borderRadius,"px; border: ").concat(v.border,"; overflow: hidden; display:flex; flex-direction: column; padding: 0; box-sizing: border-box; max-width: 100%; }\n\n /* New structure styles matching provided design */\n #text-chat-panel .widget-container {\n width: 100%; height: 100%; min-height: 0; background: #FFFFFF; overflow: hidden; display: flex; flex-direction: column; border-radius: ").concat(v.borderRadius,"px;\n container-type: size;\n }\n \n /* Ensure content areas can scroll when height is constrained */\n #text-chat-panel .widget-container > .landing-screen,\n #text-chat-panel .widget-container > .voice-interface,\n #text-chat-panel .widget-container > .text-interface {\n flex: 1;\n min-height: 0;\n overflow-y: auto;\n overflow-x: hidden;\n }\n \n /* Header should not scroll */\n #text-chat-panel .widget-header {\n padding: 12px 16px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n border-top-left-radius: ").concat(v.borderRadius,"px;\n border-top-right-radius: ").concat(v.borderRadius,"px;\n flex-shrink: 0;\n min-height: 60px;\n box-sizing: border-box;\n }\n #text-chat-panel .header-title { font-size: 16px; font-weight: 600; }\n #text-chat-panel .header-status { display: flex; align-items: center; gap: 8px; font-size: 12px; opacity: 0.9; }\n #text-chat-panel .status-dot { width: 8px; height: 8px; background: #4ade80; border-radius: 50%; animation: pulse 2s ease-in-out infinite; }\n @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }\n /* Header icon buttons */\n .header-icon {\n background: rgba(255, 255, 255, 0.2);\n border: none;\n color: white;\n width: 36px;\n height: 36px;\n min-width: 36px;\n min-height: 36px;\n border-radius: 50%;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background 0.2s;\n flex-shrink: 0;\n font-size: 16px;\n padding: 0;\n box-sizing: border-box;\n }\n \n .header-icon:hover {\n background: rgba(255, 255, 255, 0.3);\n }\n \n .header-icon svg {\n pointer-events: none;\n stroke: white;\n fill: none;\n }\n \n .back-btn.visible {\n display: flex !important;\n }\n\n /* Landing and mode selection (shown only if voice enabled) */\n .landing-screen { \n display: none").concat(S,"; \n flex: 1; \n padding: 20px; \n background: ").concat((null===(s=this.config.landing)||void 0===s?void 0:s.backgroundColor)||"linear-gradient(180deg, #f8fafc 0%, #e0e7ff 100%)","; \n align-items: center; \n justify-content: flex-start; \n flex-direction: column; \n gap: 16px; \n overflow-y: auto; \n min-height: 0; \n }\n .landing-screen.active { display: flex").concat(S,"; }\n .landing-logo { font-size: 48px; }\n .landing-title { \n font-size: 20px; \n color: ").concat((null===(c=this.config.landing)||void 0===c?void 0:c.titleColor)||"#1e293b","; \n font-weight: 700; \n margin-bottom: 20px; \n text-align: center;\n width: 100%;\n }\n .mode-selection { display: flex; gap: 16px; width: 100%; justify-content: center; }\n .mode-card { \n flex: 1; \n max-width: 180px; \n background: ").concat((null===(l=this.config.landing)||void 0===l?void 0:l.modeCardBackgroundColor)||"#FFFFFF","; \n border: 2px solid ").concat((null===(d=this.config.landing)||void 0===d?void 0:d.modeCardBorderColor)||"#E2E8F0","; \n border-radius: 20px; \n padding: 20px 12px; \n cursor: pointer; \n display: flex; \n flex-direction: column; \n align-items: center; \n gap: 8px; \n transition: transform ").concat(y.duration,"s ease, box-shadow ").concat(y.duration,"s ease, border-color ").concat(y.duration,"s ease; \n box-shadow: 0 4px 12px rgba(0,0,0,0.05); \n }\n .mode-card:hover { \n transform: translateY(-6px); \n box-shadow: 0 12px 24px rgba(102, 126, 234, 0.2); \n border-color: ").concat((null===(u=this.config.landing)||void 0===u?void 0:u.modeCardHoverBorderColor)||C,"; \n }\n .mode-card-icon { \n width: 60px; \n height: 60px; \n display: flex; \n align-items: center; \n justify-content: center; \n border-radius: 50%; \n background: ").concat((null===(h=this.config.landing)||void 0===h?void 0:h.modeCardIconBackgroundColor)||C,"; \n color: #fff; \n font-size: 32px; \n }\n .mode-card-title { \n color: ").concat((null===(p=this.config.landing)||void 0===p?void 0:p.modeCardTitleColor)||"#111827","; \n font-weight: 600; \n text-align: center;\n width: 100%;\n }\n\n ").concat(b?this.voiceInterface.generateCSS():"","\n ").concat(w?this.textInterface.generateCSS():"","\n \n /* Footer Branding */\n .widget-footer {\n box-sizing: border-box;\n }\n \n .footer-brand-link {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n \n .footer-brand-link:hover {\n opacity: 0.9;\n }\n \n @media (max-width: 768px) {\n .widget-footer {\n height: 32px;\n }\n .widget-footer span {\n font-size: 10px;\n }\n .widget-footer span:last-child {\n font-size: 8px;\n }\n }\n \n #text-chat-send-hint {\n text-align: center;\n line-height: 1.4;\n }\n \n .agent-thinking {\n font-style: italic;\n color: #6B7280;\n }\n ")}setupWidgetEvents(){if(this.shadowRoot){var e=this.shadowRoot.getElementById("text-chat-button");e&&(e.onclick=()=>this.togglePanel());var t=this.shadowRoot.getElementById("closeBtn");t&&(t.onclick=()=>this.togglePanel());var n=this.config.behavior.mode||"unified",o="unified"===n,i="unified"===n||"voice-only"===n,r="unified"===n||"text-only"===n,a=this.shadowRoot.getElementById("backBtn"),s=this.shadowRoot.getElementById("landingScreen"),c=this.shadowRoot.getElementById("mode-card-voice"),l=this.shadowRoot.getElementById("mode-card-text"),d=this.shadowRoot.getElementById("textInterface"),u=this.shadowRoot.getElementById("voiceInterface");a&&(a.onclick=()=>this.showLanding()),o?(c&&(c.onclick=()=>this.showVoice()),l&&(l.onclick=()=>this.showText()),"text"===this.currentView?(s&&s.classList.remove("active"),d&&d.classList.add("active"),u&&u.classList.remove("active"),a&&"unified"===n&&a.classList.add("visible"),h&&(h.style.display="")):"voice"===this.currentView?(s&&s.classList.remove("active"),d&&d.classList.remove("active"),u&&u.classList.add("active"),a&&"unified"===n&&a.classList.add("visible"),h&&(h.style.display="none")):(this.currentView="landing",s&&s.classList.add("active"),d&&d.classList.remove("active"),u&&u.classList.remove("active"),a&&"unified"===n&&a.classList.remove("visible"))):"voice-only"===n?(u&&u.classList.add("active"),d&&d.classList.remove("active"),s&&s.classList.remove("active")):"text-only"===n&&(d&&d.classList.add("active"),u&&u.classList.remove("active"),s&&s.classList.remove("active")),i&&(console.log("âī¸ Setting up voice interface event handlers"),this.voiceInterface.setupEventHandlers()),r&&(console.log("âī¸ Setting up text interface event handlers"),this.textInterface.setupEventHandlers());var h=this.shadowRoot.getElementById("newChatBtn");h&&(h.onclick=()=>this.textInterface.startNewChat(),o&&(h.style.display="none")),this.config.accessibility.keyboardNavigation&&this.setupKeyboardNavigation()}}startNewChat(){this.textInterface.startNewChat()}showLanding(){if(this.shadowRoot&&"unified"===(this.config.behavior.mode||"unified")){this.currentView="landing";var e=this.shadowRoot.getElementById("landingScreen"),t=this.shadowRoot.getElementById("textInterface"),n=this.shadowRoot.getElementById("voiceInterface"),o=this.shadowRoot.getElementById("backBtn"),i=this.shadowRoot.getElementById("newChatBtn");e&&e.classList.add("active"),t&&t.classList.remove("active"),n&&n.classList.remove("active"),o&&o.classList.remove("visible"),i&&(i.style.display="none")}}showText(){if(this.shadowRoot){this.currentView="text";var e=this.shadowRoot.getElementById("landingScreen"),t=this.shadowRoot.getElementById("voiceInterface"),n=this.shadowRoot.getElementById("backBtn"),o=this.shadowRoot.getElementById("newChatBtn");e&&e.classList.remove("active"),t&&t.classList.remove("active"),this.textInterface.show();var i=this.config.behavior.mode||"unified";n&&"unified"===i&&n.classList.add("visible"),o&&(o.style.display="")}}showVoice(){if(this.shadowRoot){this.currentView="voice";var e=this.shadowRoot.getElementById("landingScreen"),t=this.shadowRoot.getElementById("textInterface"),n=this.shadowRoot.getElementById("voiceInterface"),o=this.shadowRoot.getElementById("backBtn"),i=this.shadowRoot.getElementById("newChatBtn");e&&e.classList.remove("active"),t&&t.classList.remove("active"),n&&n.classList.add("active");var r=this.config.behavior.mode||"unified";o&&"unified"===r&&o.classList.add("visible"),i&&(i.style.display="none")}}setupKeyboardNavigation(){document.addEventListener("keydown",e=>{"Escape"===e.key&&this.isOpen&&this.togglePanel()})}togglePanel(){if(this.shadowRoot){this.isOpen=!this.isOpen;var e=this.shadowRoot.getElementById("text-chat-panel");e&&e.classList.toggle("open"),this.isOpen&&setTimeout(()=>{var e=this.shadowRoot.getElementById("messageInput");e&&e.focus()},100),this.isOpen&&!this.isActive&&this.config.behavior.autoConnect&&this.startChat()}}startChat(){var e=this;return Oe(function*(){e.isActive=!0,e.textInterface.setActive(!0)})()}sendMessage(){var e=this;return Oe(function*(){yield e.textInterface.sendMessage()})()}updateSendButtonState(){this.textInterface.updateSendButtonState()}getSignedUrl(){var e=this;return Oe(function*(){if(e.config.signedUrl)return e.config.signedUrl;if(!e.config.agentId)throw new Error("agentId is required when signedUrl is not provided");var t=e.config.websocketUrl||"wss://backend.talktopc.com/ws/conv",n=new URLSearchParams;return n.append("agentId",e.config.agentId),e.config.appId&&n.append("appId",e.config.appId),!1!==e.config.demo&&n.append("demo","true"),"".concat(t,"?").concat(n.toString())})()}addMessage(e,t){this.textInterface.addMessage(e,t)}beginStreaming(){this.textInterface.beginStreaming()}appendStreamingChunk(e){this.textInterface.appendStreamingChunk(e)}finalizeStreaming(e){this.textInterface.finalizeStreaming(e)}stopStreamingState(){this.textInterface.stopStreamingState()}showError(e){this.textInterface.showError(e)}updateStatus(e){}updateConfig(e){var t,n,o,i,r,a,s,c,l,d=Ue({},this.config);e.panel&&(d.panel=Ue(Ue({},this.config.panel),e.panel)),e.voice&&(d.voice=Ue(Ue({},this.config.voice),e.voice),e.voice.micButtonHint&&(d.voice.micButtonHint=Ue(Ue({},null===(c=this.config.voice)||void 0===c?void 0:c.micButtonHint),e.voice.micButtonHint))),e.text&&(d.text=Ue(Ue({},this.config.text),e.text),e.text.sendButtonHint&&(d.text.sendButtonHint=Ue(Ue({},null===(l=this.config.text)||void 0===l?void 0:l.sendButtonHint),e.text.sendButtonHint))),void 0!==e.language&&(d.language=e.language),void 0!==e.language&&(["he","ar"].includes(e.language)?d.direction="rtl":void 0===e.direction&&(d.direction="ltr")),e.translations&&(d.translations=e.translations,this.translations=e.translations),e.button&&(d.button=Ue(Ue({},this.config.button),e.button)),e.header&&(d.header=Ue(Ue({},this.config.header),e.header)),e.icon&&(d.icon=Ue(Ue({},this.config.icon),e.icon)),e.messages&&(d.messages=Ue(Ue({},this.config.messages),e.messages)),e.animation&&(d.animation=Ue(Ue({},this.config.animation),e.animation)),e.behavior&&(d.behavior=Ue(Ue({},this.config.behavior),e.behavior)),e.accessibility&&(d.accessibility=Ue(Ue({},this.config.accessibility),e.accessibility)),e.tooltips&&(d.tooltips=Ue(Ue({},this.config.tooltips),e.tooltips)),e.landing&&(d.landing=Ue(Ue({},this.config.landing),e.landing)),e.footer&&(d.footer=Ue(Ue({},this.config.footer),e.footer)),void 0!==e.direction&&void 0===d.direction&&(d.direction=e.direction),void 0!==e.primaryColor&&(d.primaryColor=e.primaryColor),d.onConversationStart=void 0!==e.onConversationStart?e.onConversationStart:this.config.onConversationStart,d.onConversationEnd=void 0!==e.onConversationEnd?e.onConversationEnd:this.config.onConversationEnd,d.onBargeIn=void 0!==e.onBargeIn?e.onBargeIn:this.config.onBargeIn,d.onAudioStartPlaying=void 0!==e.onAudioStartPlaying?e.onAudioStartPlaying:this.config.onAudioStartPlaying,d.onAudioStoppedPlaying=void 0!==e.onAudioStoppedPlaying?e.onAudioStoppedPlaying:this.config.onAudioStoppedPlaying,d.onSubtitleDisplay=void 0!==e.onSubtitleDisplay?e.onSubtitleDisplay:this.config.onSubtitleDisplay,void 0!==e.useShadowDOM&&(d.useShadowDOM=e.useShadowDOM),Object.keys(e).forEach(t=>{["panel","button","header","footer","icon","messages","direction","voice","text","animation","behavior","accessibility","language","tooltips","landing","primaryColor","useShadowDOM","onConversationStart","onConversationEnd","onBargeIn","onAudioStartPlaying","onAudioStoppedPlaying","onSubtitleDisplay"].includes(t)||(d[t]=e[t])}),null===(t=this.config)||void 0===t||t.language;var u=!1!==(null===(n=this.config)||void 0===n?void 0:n.useShadowDOM);if(this.config=this.mergeWithDefaults(d),!1!==this.config.useShadowDOM===u&&this.container){var h=document.getElementById("ttp-widget-shadow-host");h&&!this.config.useShadowDOM&&h.remove();var p=document.getElementById("ttp-widget-container");if(p&&this.config.useShadowDOM&&p.remove(),this.config.useShadowDOM)if(this.shadowRoot)this.container=this.shadowRoot;else{var g=document.getElementById("ttp-widget-shadow-host");g?(this.shadowRoot=g.shadowRoot,this.container=this.shadowRoot):(this.createShadowHost(),this.container=this.shadowRoot)}else{if(this.regularContainer)this.container=this.regularContainer;else{var m=document.getElementById("ttp-widget-container");m?(this.regularContainer=m,this.container=m):(this.createRegularContainer(),this.container=this.regularContainer)}this.shadowRoot=document}}else{var v=document.getElementById("ttp-widget-shadow-host");v&&v.remove();var f=document.getElementById("ttp-widget-container");if(f&&f.remove(),!1===u){var y=document.getElementById("ttp-widget-styles");y&&y.remove()}this.config.useShadowDOM?(this.createShadowHost(),this.container=this.shadowRoot):(this.createRegularContainer(),this.container=this.regularContainer,this.shadowRoot=document)}var x=this.config.language||"en",b=Ue(Ue(Ue({},this.config),this.config.voice),{},{language:x,translations:this.translations,shadowRoot:this.shadowRoot,outputContainer:(null===(o=this.config.voice)||void 0===o?void 0:o.outputContainer)||"raw",outputEncoding:(null===(i=this.config.voice)||void 0===i?void 0:i.outputEncoding)||"pcm",outputSampleRate:(null===(r=this.config.voice)||void 0===r?void 0:r.outputSampleRate)||44100,outputChannels:(null===(a=this.config.voice)||void 0===a?void 0:a.outputChannels)||1,outputBitDepth:(null===(s=this.config.voice)||void 0===s?void 0:s.outputBitDepth)||16,onConversationStart:this.config.onConversationStart,onConversationEnd:this.config.onConversationEnd,onBargeIn:this.config.onBargeIn,onAudioStartPlaying:this.config.onAudioStartPlaying,onAudioStoppedPlaying:this.config.onAudioStoppedPlaying,onSubtitleDisplay:this.config.onSubtitleDisplay});this.voiceInterface=new Ae(b);var w=Ue(Ue(Ue({},this.config),this.config.text),{},{language:x,translations:this.translations,shadowRoot:this.shadowRoot});this.textInterface=new Fe(w,this.sdk),this.createWidget(),this.textInterface&&this.textInterface.updateInputAttributes&&this.textInterface.updateInputAttributes()}destroy(){var e=document.getElementById("ttp-widget-shadow-host");e&&e.remove();var t=document.getElementById("ttp-widget-container");t&&t.remove();var n=document.getElementById("ttp-widget-styles");n&&n.remove(),this.sdk&&this.sdk.destroy(),this.voiceInterface&&this.voiceInterface.destroy()}startVoiceCall(){var e=this;return Oe(function*(){yield e.voiceInterface.startVoiceCall(),e._flushPendingClientTools()})()}endVoiceCall(){this.voiceInterface.endVoiceCall()}toggleMute(){this.voiceInterface.toggleMute()}toggleSpeaker(){this.voiceInterface.toggleSpeaker()}registerToolHandler(e,t){var n;return null!==(n=this.voiceInterface)&&void 0!==n&&n.sdk?this.voiceInterface.sdk.registerToolHandler(e,t):(this._pendingClientTools=this._pendingClientTools||[],this._pendingClientTools.push({name:e,handler:t}),console.warn("TTPChatWidget: Tool handler queued - voice interface SDK not ready yet"),this._flushPendingClientTools(),this)}unregisterToolHandler(e){var t;return null!==(t=this.voiceInterface)&&void 0!==t&&t.sdk?this.voiceInterface.sdk.unregisterToolHandler(e):(this._pendingClientTools&&(this._pendingClientTools=this._pendingClientTools.filter(t=>t.name!==e)),this)}hasToolHandler(e){var t;return!(null===(t=this.voiceInterface)||void 0===t||!t.sdk)&&this.voiceInterface.sdk.hasToolHandler(e)}getRegisteredTools(){var e;return null!==(e=this.voiceInterface)&&void 0!==e&&e.sdk?this.voiceInterface.sdk.getRegisteredTools():this._pendingClientTools?this._pendingClientTools.map(e=>e.name):[]}_flushPendingClientTools(){var e;this._pendingClientTools&&null!==(e=this.voiceInterface)&&void 0!==e&&e.sdk&&(this._pendingClientTools.forEach(e=>{var{name:t,handler:n}=e;this.voiceInterface.sdk.registerToolHandler(t,n)}),this._pendingClientTools=null,console.log("TTPChatWidget: Flushed pending client tools"))}registerClientTool(e,t){return this.registerToolHandler(e,t)}unregisterClientTool(e){return this.unregisterToolHandler(e)}hasClientTool(e){return this.hasToolHandler(e)}getRegisteredClientTools(){return this.getRegisteredTools()}}var He="2.18.0";const Le={VoiceSDK_v2:H,TextChatSDK:q,WebSocketManager:J,AudioRecorder:Z,AudioPlayer:ne,EventEmitter:L,VoiceButton:ce,VanillaVoiceButton:pe,AgentSDK:ve,TTPChatWidget:ze,VERSION:He};export{ve as AgentSDK,ne as AudioPlayer,Z as AudioRecorder,L as EventEmitter,s as MicPermissionModals,a as MicPermissionUtils,ze as TTPChatWidget,q as TextChatSDK,He as VERSION,pe as VanillaVoiceButton,ce as VoiceButton,H as VoiceSDK_v2,J as WebSocketManager,Le as default};
|
|
2
|
+
import{useEffect as A,useRef as e,useState as t}from"react";var n={354:function(A){A.exports=function(){var A=function(e,t){return A=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(A,e){A.__proto__=e}||function(A,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(A[t]=e[t])},A(e,t)};function e(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}A(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var t=function(){return t=Object.assign||function(A){for(var e,t=1,n=arguments.length;t<n;t++)for(var o in e=arguments[t])Object.prototype.hasOwnProperty.call(e,o)&&(A[o]=e[o]);return A},t.apply(this,arguments)};function n(A,e,t,n){return new(t||(t=Promise))(function(o,r){function i(A){try{a(n.next(A))}catch(A){r(A)}}function s(A){try{a(n.throw(A))}catch(A){r(A)}}function a(A){var e;A.done?o(A.value):(e=A.value,e instanceof t?e:new t(function(A){A(e)})).then(i,s)}a((n=n.apply(A,e||[])).next())})}function o(A,e){var t,n,o,r,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function s(r){return function(s){return function(r){if(t)throw new TypeError("Generator is already executing.");for(;i;)try{if(t=1,n&&(o=2&r[0]?n.return:r[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,r[1])).done)return o;switch(n=0,o&&(r=[2&r[0],o.value]),r[0]){case 0:case 1:o=r;break;case 4:return i.label++,{value:r[1],done:!1};case 5:i.label++,n=r[1],r=[0];continue;case 7:r=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==r[0]&&2!==r[0])){i=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]<o[3])){i.label=r[1];break}if(6===r[0]&&i.label<o[1]){i.label=o[1],o=r;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(r);break}o[2]&&i.ops.pop(),i.trys.pop();continue}r=e.call(A,i)}catch(A){r=[6,A],n=0}finally{t=o=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,s])}}}function r(A,e,t){if(t||2===arguments.length)for(var n,o=0,r=e.length;o<r;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return A.concat(n||e)}for(var i=function(){function A(A,e,t,n){this.left=A,this.top=e,this.width=t,this.height=n}return A.prototype.add=function(e,t,n,o){return new A(this.left+e,this.top+t,this.width+n,this.height+o)},A.fromClientRect=function(e,t){return new A(t.left+e.windowBounds.left,t.top+e.windowBounds.top,t.width,t.height)},A.fromDOMRectList=function(e,t){var n=Array.from(t).find(function(A){return 0!==A.width});return n?new A(n.left+e.windowBounds.left,n.top+e.windowBounds.top,n.width,n.height):A.EMPTY},A.EMPTY=new A(0,0,0,0),A}(),s=function(A,e){return i.fromClientRect(A,e.getBoundingClientRect())},a=function(A){for(var e=[],t=0,n=A.length;t<n;){var o=A.charCodeAt(t++);if(o>=55296&&o<=56319&&t<n){var r=A.charCodeAt(t++);56320==(64512&r)?e.push(((1023&o)<<10)+(1023&r)+65536):(e.push(o),t--)}else e.push(o)}return e},c=function(){for(var A=[],e=0;e<arguments.length;e++)A[e]=arguments[e];if(String.fromCodePoint)return String.fromCodePoint.apply(String,A);var t=A.length;if(!t)return"";for(var n=[],o=-1,r="";++o<t;){var i=A[o];i<=65535?n.push(i):(i-=65536,n.push(55296+(i>>10),i%1024+56320)),(o+1===t||n.length>16384)&&(r+=String.fromCharCode.apply(String,n),n.length=0)}return r},l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d="undefined"==typeof Uint8Array?[]:new Uint8Array(256),u=0;u<64;u++)d[l.charCodeAt(u)]=u;for(var g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",B="undefined"==typeof Uint8Array?[]:new Uint8Array(256),h=0;h<64;h++)B[g.charCodeAt(h)]=h;for(var p=function(A,e,t){return A.slice?A.slice(e,t):new Uint16Array(Array.prototype.slice.call(A,e,t))},w=function(){function A(A,e,t,n,o,r){this.initialValue=A,this.errorValue=e,this.highStart=t,this.highValueIndex=n,this.index=o,this.data=r}return A.prototype.get=function(A){var e;if(A>=0){if(A<55296||A>56319&&A<=65535)return e=((e=this.index[A>>5])<<2)+(31&A),this.data[e];if(A<=65535)return e=((e=this.index[2048+(A-55296>>5)])<<2)+(31&A),this.data[e];if(A<this.highStart)return e=2080+(A>>11),e=this.index[e],e+=A>>5&63,e=((e=this.index[e])<<2)+(31&A),this.data[e];if(A<=1114111)return this.data[this.highValueIndex]}return this.errorValue},A}(),f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",C="undefined"==typeof Uint8Array?[]:new Uint8Array(256),m=0;m<64;m++)C[f.charCodeAt(m)]=m;var v=10,Q=13,F=15,U=17,y=18,b=19,E=20,x=21,I=22,H=24,S=25,D=26,K=27,T=28,k=30,L=32,P=33,R=34,O=35,M=37,V=38,N=39,G=40,_=42,W=[9001,65288],J="Ã",X="Ãˇ",Y=function(A){var e,t,n,o=function(A){var e,t,n,o,r,i=.75*A.length,s=A.length,a=0;"="===A[A.length-1]&&(i--,"="===A[A.length-2]&&i--);var c="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.slice?new ArrayBuffer(i):new Array(i),l=Array.isArray(c)?c:new Uint8Array(c);for(e=0;e<s;e+=4)t=B[A.charCodeAt(e)],n=B[A.charCodeAt(e+1)],o=B[A.charCodeAt(e+2)],r=B[A.charCodeAt(e+3)],l[a++]=t<<2|n>>4,l[a++]=(15&n)<<4|o>>2,l[a++]=(3&o)<<6|63&r;return c}(A),r=Array.isArray(o)?function(A){for(var e=A.length,t=[],n=0;n<e;n+=4)t.push(A[n+3]<<24|A[n+2]<<16|A[n+1]<<8|A[n]);return t}(o):new Uint32Array(o),i=Array.isArray(o)?function(A){for(var e=A.length,t=[],n=0;n<e;n+=2)t.push(A[n+1]<<8|A[n]);return t}(o):new Uint16Array(o),s=p(i,12,r[4]/2),a=2===r[5]?p(i,(24+r[4])/2):(e=r,t=Math.ceil((24+r[4])/4),e.slice?e.slice(t,n):new Uint32Array(Array.prototype.slice.call(e,t,n)));return new w(r[0],r[1],r[2],r[3],s,a)}("KwAAAAAAAAAACA4AUD0AADAgAAACAAAAAAAIABAAGABAAEgAUABYAGAAaABgAGgAYgBqAF8AZwBgAGgAcQB5AHUAfQCFAI0AlQCdAKIAqgCyALoAYABoAGAAaABgAGgAwgDKAGAAaADGAM4A0wDbAOEA6QDxAPkAAQEJAQ8BFwF1AH0AHAEkASwBNAE6AUIBQQFJAVEBWQFhAWgBcAF4ATAAgAGGAY4BlQGXAZ8BpwGvAbUBvQHFAc0B0wHbAeMB6wHxAfkBAQIJAvEBEQIZAiECKQIxAjgCQAJGAk4CVgJeAmQCbAJ0AnwCgQKJApECmQKgAqgCsAK4ArwCxAIwAMwC0wLbAjAA4wLrAvMC+AIAAwcDDwMwABcDHQMlAy0DNQN1AD0DQQNJA0kDSQNRA1EDVwNZA1kDdQB1AGEDdQBpA20DdQN1AHsDdQCBA4kDkQN1AHUAmQOhA3UAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AKYDrgN1AHUAtgO+A8YDzgPWAxcD3gPjA+sD8wN1AHUA+wMDBAkEdQANBBUEHQQlBCoEFwMyBDgEYABABBcDSARQBFgEYARoBDAAcAQzAXgEgASIBJAEdQCXBHUAnwSnBK4EtgS6BMIEyAR1AHUAdQB1AHUAdQCVANAEYABgAGAAYABgAGAAYABgANgEYADcBOQEYADsBPQE/AQEBQwFFAUcBSQFLAU0BWQEPAVEBUsFUwVbBWAAYgVgAGoFcgV6BYIFigWRBWAAmQWfBaYFYABgAGAAYABgAKoFYACxBbAFuQW6BcEFwQXHBcEFwQXPBdMF2wXjBeoF8gX6BQIGCgYSBhoGIgYqBjIGOgZgAD4GRgZMBmAAUwZaBmAAYABgAGAAYABgAGAAYABgAGAAYABgAGIGYABpBnAGYABgAGAAYABgAGAAYABgAGAAYAB4Bn8GhQZgAGAAYAB1AHcDFQSLBmAAYABgAJMGdQA9A3UAmwajBqsGqwaVALMGuwbDBjAAywbSBtIG1QbSBtIG0gbSBtIG0gbdBuMG6wbzBvsGAwcLBxMHAwcbByMHJwcsBywHMQcsB9IGOAdAB0gHTgfSBkgHVgfSBtIG0gbSBtIG0gbSBtIG0gbSBiwHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAdgAGAALAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAdbB2MHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsB2kH0gZwB64EdQB1AHUAdQB1AHUAdQB1AHUHfQdgAIUHjQd1AHUAlQedB2AAYAClB6sHYACzB7YHvgfGB3UAzgfWBzMB3gfmB1EB7gf1B/0HlQENAQUIDQh1ABUIHQglCBcDLQg1CD0IRQhNCEEDUwh1AHUAdQBbCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIcAh3CHoIMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIgggwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAALAcsBywHLAcsBywHLAcsBywHLAcsB4oILAcsB44I0gaWCJ4Ipgh1AHUAqgiyCHUAdQB1AHUAdQB1AHUAdQB1AHUAtwh8AXUAvwh1AMUIyQjRCNkI4AjoCHUAdQB1AO4I9gj+CAYJDgkTCS0HGwkjCYIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiAAIAAAAFAAYABgAGIAXwBgAHEAdQBFAJUAogCyAKAAYABgAEIA4ABGANMA4QDxAMEBDwE1AFwBLAE6AQEBUQF4QkhCmEKoQrhCgAHIQsAB0MLAAcABwAHAAeDC6ABoAHDCwMMAAcABwAHAAdDDGMMAAcAB6MM4wwjDWMNow3jDaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAEjDqABWw6bDqABpg6gAaABoAHcDvwOPA+gAaABfA/8DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DpcPAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcAB9cPKwkyCToJMAB1AHUAdQBCCUoJTQl1AFUJXAljCWcJawkwADAAMAAwAHMJdQB2CX4JdQCECYoJjgmWCXUAngkwAGAAYABxAHUApgn3A64JtAl1ALkJdQDACTAAMAAwADAAdQB1AHUAdQB1AHUAdQB1AHUAowYNBMUIMAAwADAAMADICcsJ0wnZCRUE4QkwAOkJ8An4CTAAMAB1AAAKvwh1AAgKDwoXCh8KdQAwACcKLgp1ADYKqAmICT4KRgowADAAdQB1AE4KMAB1AFYKdQBeCnUAZQowADAAMAAwADAAMAAwADAAMAAVBHUAbQowADAAdQC5CXUKMAAwAHwBxAijBogEMgF9CoQKiASMCpQKmgqIBKIKqgquCogEDQG2Cr4KxgrLCjAAMADTCtsKCgHjCusK8Qr5CgELMAAwADAAMAB1AIsECQsRC3UANAEZCzAAMAAwADAAMAB1ACELKQswAHUANAExCzkLdQBBC0kLMABRC1kLMAAwADAAMAAwADAAdQBhCzAAMAAwAGAAYABpC3ELdwt/CzAAMACHC4sLkwubC58Lpwt1AK4Ltgt1APsDMAAwADAAMAAwADAAMAAwAL4LwwvLC9IL1wvdCzAAMADlC+kL8Qv5C/8LSQswADAAMAAwADAAMAAwADAAMAAHDDAAMAAwADAAMAAODBYMHgx1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1ACYMMAAwADAAdQB1AHUALgx1AHUAdQB1AHUAdQA2DDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AD4MdQBGDHUAdQB1AHUAdQB1AEkMdQB1AHUAdQB1AFAMMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQBYDHUAdQB1AF8MMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUA+wMVBGcMMAAwAHwBbwx1AHcMfwyHDI8MMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAYABgAJcMMAAwADAAdQB1AJ8MlQClDDAAMACtDCwHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsB7UMLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AA0EMAC9DDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAsBywHLAcsBywHLAcsBywHLQcwAMEMyAwsBywHLAcsBywHLAcsBywHLAcsBywHzAwwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1ANQM2QzhDDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMABgAGAAYABgAGAAYABgAOkMYADxDGAA+AwADQYNYABhCWAAYAAODTAAMAAwADAAFg1gAGAAHg37AzAAMAAwADAAYABgACYNYAAsDTQNPA1gAEMNPg1LDWAAYABgAGAAYABgAGAAYABgAGAAUg1aDYsGVglhDV0NcQBnDW0NdQ15DWAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAlQCBDZUAiA2PDZcNMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAnw2nDTAAMAAwADAAMAAwAHUArw23DTAAMAAwADAAMAAwADAAMAAwADAAMAB1AL8NMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAB1AHUAdQB1AHUAdQDHDTAAYABgAM8NMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAA1w11ANwNMAAwAD0B5A0wADAAMAAwADAAMADsDfQN/A0EDgwOFA4wABsOMAAwADAAMAAwADAAMAAwANIG0gbSBtIG0gbSBtIG0gYjDigOwQUuDsEFMw7SBjoO0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGQg5KDlIOVg7SBtIGXg5lDm0OdQ7SBtIGfQ6EDooOjQ6UDtIGmg6hDtIG0gaoDqwO0ga0DrwO0gZgAGAAYADEDmAAYAAkBtIGzA5gANIOYADaDokO0gbSBt8O5w7SBu8O0gb1DvwO0gZgAGAAxA7SBtIG0gbSBtIGYABgAGAAYAAED2AAsAUMD9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGFA8sBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAccD9IGLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHJA8sBywHLAcsBywHLAccDywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywPLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAc0D9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAccD9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGFA8sBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHPA/SBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gYUD0QPlQCVAJUAMAAwADAAMACVAJUAlQCVAJUAlQCVAEwPMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAA//8EAAQABAAEAAQABAAEAAQABAANAAMAAQABAAIABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQACgATABcAHgAbABoAHgAXABYAEgAeABsAGAAPABgAHABLAEsASwBLAEsASwBLAEsASwBLABgAGAAeAB4AHgATAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABYAGwASAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAWAA0AEQAeAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAFAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAJABYAGgAbABsAGwAeAB0AHQAeAE8AFwAeAA0AHgAeABoAGwBPAE8ADgBQAB0AHQAdAE8ATwAXAE8ATwBPABYAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAFAATwBAAE8ATwBPAEAATwBQAFAATwBQAB4AHgAeAB4AHgAeAB0AHQAdAB0AHgAdAB4ADgBQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgBQAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAJAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAkACQAJAAkACQAJAAkABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAFAAHgAeAB4AKwArAFAAUABQAFAAGABQACsAKwArACsAHgAeAFAAHgBQAFAAUAArAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUAAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAYAA0AKwArAB4AHgAbACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQADQAEAB4ABAAEAB4ABAAEABMABAArACsAKwArACsAKwArACsAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAKwArACsAKwBWAFYAVgBWAB4AHgArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AGgAaABoAGAAYAB4AHgAEAAQABAAEAAQABAAEAAQABAAEAAQAEwAEACsAEwATAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABLAEsASwBLAEsASwBLAEsASwBLABoAGQAZAB4AUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABMAUAAEAAQABAAEAAQABAAEAB4AHgAEAAQABAAEAAQABABQAFAABAAEAB4ABAAEAAQABABQAFAASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUAAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAFAABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQAUABQAB4AHgAYABMAUAArACsABAAbABsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAFAABAAEAAQABAAEAFAABAAEAAQAUAAEAAQABAAEAAQAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAArACsAHgArAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAUAAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAABAAEAA0ADQBLAEsASwBLAEsASwBLAEsASwBLAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUAArACsAKwBQAFAAUABQACsAKwAEAFAABAAEAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABABQACsAKwArACsAKwArACsAKwAEACsAKwArACsAUABQACsAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUAAaABoAUABQAFAAUABQAEwAHgAbAFAAHgAEACsAKwAEAAQABAArAFAAUABQAFAAUABQACsAKwArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQACsAUABQACsAKwAEACsABAAEAAQABAAEACsAKwArACsABAAEACsAKwAEAAQABAArACsAKwAEACsAKwArACsAKwArACsAUABQAFAAUAArAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLAAQABABQAFAAUAAEAB4AKwArACsAKwArACsAKwArACsAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQACsAKwAEAFAABAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAArACsAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAB4AGwArACsAKwArACsAKwArAFAABAAEAAQABAAEAAQAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABAArACsAKwArACsAKwArAAQABAAEACsAKwArACsAUABQACsAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAB4AUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAAQAUAArAFAAUABQAFAAUABQACsAKwArAFAAUABQACsAUABQAFAAUAArACsAKwBQAFAAKwBQACsAUABQACsAKwArAFAAUAArACsAKwBQAFAAUAArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArAAQABAAEAAQABAArACsAKwAEAAQABAArAAQABAAEAAQAKwArAFAAKwArACsAKwArACsABAArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAHgAeAB4AHgAeAB4AGwAeACsAKwArACsAKwAEAAQABAAEAAQAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAUAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAAEACsAKwArACsAKwArACsABAAEACsAUABQAFAAKwArACsAKwArAFAAUAAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKwAOAFAAUABQAFAAUABQAFAAHgBQAAQABAAEAA4AUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAKwArAAQAUAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAAEACsAKwArACsAKwArACsABAAEACsAKwArACsAKwArACsAUAArAFAAUAAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwBQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAFAABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQABABQAB4AKwArACsAKwBQAFAAUAAEAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQABoAUABQAFAAUABQAFAAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQACsAUAArACsAUABQAFAAUABQAFAAUAArACsAKwAEACsAKwArACsABAAEAAQABAAEAAQAKwAEACsABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArAAQABAAeACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAXAAqACoAKgAqACoAKgAqACsAKwArACsAGwBcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAeAEsASwBLAEsASwBLAEsASwBLAEsADQANACsAKwArACsAKwBcAFwAKwBcACsAXABcAFwAXABcACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAXAArAFwAXABcAFwAXABcAFwAXABcAFwAKgBcAFwAKgAqACoAKgAqACoAKgAqACoAXAArACsAXABcAFwAXABcACsAXAArACoAKgAqACoAKgAqACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwBcAFwAXABcAFAADgAOAA4ADgAeAA4ADgAJAA4ADgANAAkAEwATABMAEwATAAkAHgATAB4AHgAeAAQABAAeAB4AHgAeAB4AHgBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQAFAADQAEAB4ABAAeAAQAFgARABYAEQAEAAQAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQADQAEAAQABAAEAAQADQAEAAQAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAA0ADQAeAB4AHgAeAB4AHgAEAB4AHgAeAB4AHgAeACsAHgAeAA4ADgANAA4AHgAeAB4AHgAeAAkACQArACsAKwArACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgBcAEsASwBLAEsASwBLAEsASwBLAEsADQANAB4AHgAeAB4AXABcAFwAXABcAFwAKgAqACoAKgBcAFwAXABcACoAKgAqAFwAKgAqACoAXABcACoAKgAqACoAKgAqACoAXABcAFwAKgAqACoAKgBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKgAqAFwAKgBLAEsASwBLAEsASwBLAEsASwBLACoAKgAqACoAKgAqAFAAUABQAFAAUABQACsAUAArACsAKwArACsAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgBQAFAAUABQAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAKwBQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsABAAEAAQAHgANAB4AHgAeAB4AHgAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUAArACsADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAWABEAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAA0ADQANAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAANAA0AKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUAArAAQABAArACsAKwArACsAKwArACsAKwArACsAKwBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqAA0ADQAVAFwADQAeAA0AGwBcACoAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwAeAB4AEwATAA0ADQAOAB4AEwATAB4ABAAEAAQACQArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUAAEAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAHgArACsAKwATABMASwBLAEsASwBLAEsASwBLAEsASwBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAArACsAXABcAFwAXABcACsAKwArACsAKwArACsAKwArACsAKwBcAFwAXABcAFwAXABcAFwAXABcAFwAXAArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAXAArACsAKwAqACoAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAArACsAHgAeAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKwAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKwArAAQASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArACoAKgAqACoAKgAqACoAXAAqACoAKgAqACoAKgArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABABQAFAAUABQAFAAUABQACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwANAA0AHgANAA0ADQANAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQAHgAeAB4AHgAeAB4AHgAeAB4AKwArACsABAAEAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwAeAB4AHgAeAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArAA0ADQANAA0ADQBLAEsASwBLAEsASwBLAEsASwBLACsAKwArAFAAUABQAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAA0ADQBQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUAAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArAAQABAAEAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAAQAUABQAFAAUABQAFAABABQAFAABAAEAAQAUAArACsAKwArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAKwBQACsAUAArAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAFAAUABQACsAHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQACsAKwAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQACsAHgAeAB4AHgAeAB4AHgAOAB4AKwANAA0ADQANAA0ADQANAAkADQANAA0ACAAEAAsABAAEAA0ACQANAA0ADAAdAB0AHgAXABcAFgAXABcAFwAWABcAHQAdAB4AHgAUABQAFAANAAEAAQAEAAQABAAEAAQACQAaABoAGgAaABoAGgAaABoAHgAXABcAHQAVABUAHgAeAB4AHgAeAB4AGAAWABEAFQAVABUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ADQAeAA0ADQANAA0AHgANAA0ADQAHAB4AHgAeAB4AKwAEAAQABAAEAAQABAAEAAQABAAEAFAAUAArACsATwBQAFAAUABQAFAAHgAeAB4AFgARAE8AUABPAE8ATwBPAFAAUABQAFAAUAAeAB4AHgAWABEAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArABsAGwAbABsAGwAbABsAGgAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGgAbABsAGwAbABoAGwAbABoAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAHgAeAFAAGgAeAB0AHgBQAB4AGgAeAB4AHgAeAB4AHgAeAB4AHgBPAB4AUAAbAB4AHgBQAFAAUABQAFAAHgAeAB4AHQAdAB4AUAAeAFAAHgBQAB4AUABPAFAAUAAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAHgBQAFAAUABQAE8ATwBQAFAAUABQAFAATwBQAFAATwBQAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAFAAUABQAFAATwBPAE8ATwBPAE8ATwBPAE8ATwBQAFAAUABQAFAAUABQAFAAUAAeAB4AUABQAFAAUABPAB4AHgArACsAKwArAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHQAdAB4AHgAeAB0AHQAeAB4AHQAeAB4AHgAdAB4AHQAbABsAHgAdAB4AHgAeAB4AHQAeAB4AHQAdAB0AHQAeAB4AHQAeAB0AHgAdAB0AHQAdAB0AHQAeAB0AHgAeAB4AHgAeAB0AHQAdAB0AHgAeAB4AHgAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHgAeAB0AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAeAB0AHQAdAB0AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAeAB4AHgAdAB4AHgAeAB4AHgAeAB4AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAWABEAHgAeAB4AHgAeAB4AHQAeAB4AHgAeAB4AHgAeACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAWABEAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAFAAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAeAB4AHQAdAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHQAdAB4AHgAeAB4AHQAdAB0AHgAeAB0AHgAeAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlAB4AHQAdAB4AHgAdAB4AHgAeAB4AHQAdAB4AHgAeAB4AJQAlAB0AHQAlAB4AJQAlACUAIAAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAeAB4AHgAeAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAdAB0AHQAeAB0AJQAdAB0AHgAdAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAdAB0AHQAdACUAHgAlACUAJQAdACUAJQAdAB0AHQAlACUAHQAdACUAHQAdACUAJQAlAB4AHQAeAB4AHgAeAB0AHQAlAB0AHQAdAB0AHQAdACUAJQAlACUAJQAdACUAJQAgACUAHQAdACUAJQAlACUAJQAlACUAJQAeAB4AHgAlACUAIAAgACAAIAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AFwAXABcAFwAXABcAHgATABMAJQAeAB4AHgAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAFgARABYAEQAWABEAFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAEAAQABAAeAB4AKwArACsAKwArABMADQANAA0AUAATAA0AUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUAANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAA0ADQANAA0ADQANAA0ADQAeAA0AFgANAB4AHgAXABcAHgAeABcAFwAWABEAFgARABYAEQAWABEADQANAA0ADQATAFAADQANAB4ADQANAB4AHgAeAB4AHgAMAAwADQANAA0AHgANAA0AFgANAA0ADQANAA0ADQANAA0AHgANAB4ADQANAB4AHgAeACsAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArAA0AEQARACUAJQBHAFcAVwAWABEAFgARABYAEQAWABEAFgARACUAJQAWABEAFgARABYAEQAWABEAFQAWABEAEQAlAFcAVwBXAFcAVwBXAFcAVwBXAAQABAAEAAQABAAEACUAVwBXAFcAVwA2ACUAJQBXAFcAVwBHAEcAJQAlACUAKwBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBRAFcAUQBXAFEAVwBXAFcAVwBXAFcAUQBXAFcAVwBXAFcAVwBRAFEAKwArAAQABAAVABUARwBHAFcAFQBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBRAFcAVwBXAFcAVwBXAFEAUQBXAFcAVwBXABUAUQBHAEcAVwArACsAKwArACsAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwAlACUAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACsAKwArACsAKwArACsAKwArACsAKwArAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBPAE8ATwBPAE8ATwBPAE8AJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADQATAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABLAEsASwBLAEsASwBLAEsASwBLAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAABAAEAAQABAAeAAQABAAEAAQABAAEAAQABAAEAAQAHgBQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUABQAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAeAA0ADQANAA0ADQArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAB4AHgAeAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAAQAUABQAFAABABQAFAAUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAeAB4AHgAeAAQAKwArACsAUABQAFAAUABQAFAAHgAeABoAHgArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADgAOABMAEwArACsAKwArACsAKwArACsABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwANAA0ASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUAAeAB4AHgBQAA4AUABQAAQAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAA0ADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArAB4AWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYACsAKwArAAQAHgAeAB4AHgAeAB4ADQANAA0AHgAeAB4AHgArAFAASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArAB4AHgBcAFwAXABcAFwAKgBcAFwAXABcAFwAXABcAFwAXABcAEsASwBLAEsASwBLAEsASwBLAEsAXABcAFwAXABcACsAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArAFAAUABQAAQAUABQAFAAUABQAFAAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAHgANAA0ADQBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAXAAqACoAKgBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAKgAqACoAXABcACoAKgBcAFwAXABcAFwAKgAqAFwAKgBcACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcACoAKgBQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAA0ADQBQAFAAUAAEAAQAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQADQAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAVABVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBUAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVACsAKwArACsAKwArACsAKwArACsAKwArAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAKwArACsAKwBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAKwArACsAKwAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAKwArACsAKwArAFYABABWAFYAVgBWAFYAVgBWAFYAVgBWAB4AVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgArAFYAVgBWAFYAVgArAFYAKwBWAFYAKwBWAFYAKwBWAFYAVgBWAFYAVgBWAFYAVgBWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAEQAWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAaAB4AKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAGAARABEAGAAYABMAEwAWABEAFAArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACUAJQAlACUAJQAWABEAFgARABYAEQAWABEAFgARABYAEQAlACUAFgARACUAJQAlACUAJQAlACUAEQAlABEAKwAVABUAEwATACUAFgARABYAEQAWABEAJQAlACUAJQAlACUAJQAlACsAJQAbABoAJQArACsAKwArAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAcAKwATACUAJQAbABoAJQAlABYAEQAlACUAEQAlABEAJQBXAFcAVwBXAFcAVwBXAFcAVwBXABUAFQAlACUAJQATACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXABYAJQARACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAWACUAEQAlABYAEQARABYAEQARABUAVwBRAFEAUQBRAFEAUQBRAFEAUQBRAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcARwArACsAVwBXAFcAVwBXAFcAKwArAFcAVwBXAFcAVwBXACsAKwBXAFcAVwBXAFcAVwArACsAVwBXAFcAKwArACsAGgAbACUAJQAlABsAGwArAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwAEAAQABAAQAB0AKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsADQANAA0AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAAQAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAA0AUABQAFAAUAArACsAKwArAFAAUABQAFAAUABQAFAAUAANAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAKwArAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUAArACsAKwBQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAUABQAFAAUABQAAQABAAEACsABAAEACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAKwBQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEACsAKwArACsABABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAA0ADQANAA0ADQANAA0ADQAeACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAArACsAKwArAFAAUABQAFAAUAANAA0ADQANAA0ADQAUACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsADQANAA0ADQANAA0ADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAAQABAAEAAQAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArAAQABAANACsAKwBQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAB4AHgAeAB4AHgArACsAKwArACsAKwAEAAQABAAEAAQABAAEAA0ADQAeAB4AHgAeAB4AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwAeACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsASwBLAEsASwBLAEsASwBLAEsASwANAA0ADQANAFAABAAEAFAAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAeAA4AUAArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAADQANAB4ADQAEAAQABAAEAB4ABAAEAEsASwBLAEsASwBLAEsASwBLAEsAUAAOAFAADQANAA0AKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAANAA0AHgANAA0AHgAEACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAA0AKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsABAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQACsABAAEAFAABAAEAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABAArACsAUAArACsAKwArACsAKwAEACsAKwArACsAKwBQAFAAUABQAFAABAAEACsAKwAEAAQABAAEAAQABAAEACsAKwArAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAQABABQAFAAUABQAA0ADQANAA0AHgBLAEsASwBLAEsASwBLAEsASwBLAA0ADQArAB4ABABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAFAAUAAeAFAAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAArACsABAAEAAQABAAEAAQABAAEAAQADgANAA0AEwATAB4AHgAeAA0ADQANAA0ADQANAA0ADQANAA0ADQANAA0ADQANAFAAUABQAFAABAAEACsAKwAEAA0ADQAeAFAAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKwArACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBcAFwADQANAA0AKgBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAKwArAFAAKwArAFAAUABQAFAAUABQAFAAUAArAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQAKwAEAAQAKwArAAQABAAEAAQAUAAEAFAABAAEAA0ADQANACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAArACsABAAEAAQABAAEAAQABABQAA4AUAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAFAABAAEAAQABAAOAB4ADQANAA0ADQAOAB4ABAArACsAKwArACsAKwArACsAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAA0ADQANAFAADgAOAA4ADQANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAAQABAAEAFAADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwAOABMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAArACsAKwAEACsABAAEACsABAAEAAQABAAEAAQABABQAAQAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAKwBQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQAKwAEAAQAKwAEAAQABAAEAAQAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAaABoAGgAaAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABIAEgAQwBDAEMAUABQAFAAUABDAFAAUABQAEgAQwBIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABDAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwAJAAkACQAJAAkACQAJABYAEQArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwANAA0AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAANACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAA0ADQANAB4AHgAeAB4AHgAeAFAAUABQAFAADQAeACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAANAA0AHgAeACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwAEAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAARwBHABUARwAJACsAKwArACsAKwArACsAKwArACsAKwAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACsAKwArACsAKwArACsAKwBXAFcAVwBXAFcAVwBXAFcAVwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUQBRAFEAKwArACsAKwArACsAKwArACsAKwArACsAKwBRAFEAUQBRACsAKwArACsAKwArACsAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArACsAHgAEAAQADQAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAAQABAAEAAQABAAeAB4AHgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4AHgAEAAQABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQAHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwBQAFAAKwArAFAAKwArAFAAUAArACsAUABQAFAAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAUAArAFAAUABQAFAAUABQAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAHgAeAFAAUABQAFAAUAArAFAAKwArACsAUABQAFAAUABQAFAAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeACsAKwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4ABAAeAB4AHgAeAB4AHgAeAB4AHgAeAAQAHgAeAA0ADQANAA0AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAAQAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArAAQABAAEAAQABAAEAAQAKwAEAAQAKwAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwBQAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArABsAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArAB4AHgAeAB4ABAAEAAQABAAEAAQABABQACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArABYAFgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAGgBQAFAAUAAaAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAKwBQACsAKwBQACsAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwBQACsAUAArACsAKwArACsAKwBQACsAKwArACsAUAArAFAAKwBQACsAUABQAFAAKwBQAFAAKwBQACsAKwBQACsAUAArAFAAKwBQACsAUAArAFAAUAArAFAAKwArAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUAArAFAAUABQAFAAKwBQACsAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAKwBQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8AJQAlACUAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB4AHgAeACUAJQAlAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAlACUAJQAlACUAHgAlACUAJQAlACUAIAAgACAAJQAlACAAJQAlACAAIAAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACEAIQAhACEAIQAlACUAIAAgACUAJQAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAIAAlACUAJQAlACAAIAAgACUAIAAgACAAJQAlACUAJQAlACUAJQAgACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAlAB4AJQAeACUAJQAlACUAJQAgACUAJQAlACUAHgAlAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACAAIAAgACUAJQAlACAAIAAgACAAIAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABcAFwAXABUAFQAVAB4AHgAeAB4AJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAgACUAJQAgACUAJQAlACUAJQAlACUAJQAgACAAIAAgACAAIAAgACAAJQAlACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAgACAAIAAgACAAIAAgACAAIAAgACUAJQAgACAAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAlACAAIAAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAgACAAIAAlACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACUAVwBXACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAA=="),z=[k,36],j=[1,2,3,5],Z=[v,8],q=[K,D],$=j.concat(Z),AA=[V,N,G,R,O],eA=[F,Q],tA=function(A,e,t,n){var o=n[t];if(Array.isArray(A)?-1!==A.indexOf(o):A===o)for(var r=t;r<=n.length;){if((a=n[++r])===e)return!0;if(a!==v)break}if(o===v)for(r=t;r>0;){var i=n[--r];if(Array.isArray(A)?-1!==A.indexOf(i):A===i)for(var s=t;s<=n.length;){var a;if((a=n[++s])===e)return!0;if(a!==v)break}if(i!==v)break}return!1},nA=function(A,e){for(var t=A;t>=0;){var n=e[t];if(n!==v)return n;t--}return 0},oA=function(A,e,t,n,o){if(0===t[n])return J;var r=n-1;if(Array.isArray(o)&&!0===o[r])return J;var i=r-1,s=r+1,a=e[r],c=i>=0?e[i]:0,l=e[s];if(2===a&&3===l)return J;if(-1!==j.indexOf(a))return"!";if(-1!==j.indexOf(l))return J;if(-1!==Z.indexOf(l))return J;if(8===nA(r,e))return X;if(11===Y.get(A[r]))return J;if((a===L||a===P)&&11===Y.get(A[s]))return J;if(7===a||7===l)return J;if(9===a)return J;if(-1===[v,Q,F].indexOf(a)&&9===l)return J;if(-1!==[U,y,b,H,T].indexOf(l))return J;if(nA(r,e)===I)return J;if(tA(23,I,r,e))return J;if(tA([U,y],x,r,e))return J;if(tA(12,12,r,e))return J;if(a===v)return X;if(23===a||23===l)return J;if(16===l||16===a)return X;if(-1!==[Q,F,x].indexOf(l)||14===a)return J;if(36===c&&-1!==eA.indexOf(a))return J;if(a===T&&36===l)return J;if(l===E)return J;if(-1!==z.indexOf(l)&&a===S||-1!==z.indexOf(a)&&l===S)return J;if(a===K&&-1!==[M,L,P].indexOf(l)||-1!==[M,L,P].indexOf(a)&&l===D)return J;if(-1!==z.indexOf(a)&&-1!==q.indexOf(l)||-1!==q.indexOf(a)&&-1!==z.indexOf(l))return J;if(-1!==[K,D].indexOf(a)&&(l===S||-1!==[I,F].indexOf(l)&&e[s+1]===S)||-1!==[I,F].indexOf(a)&&l===S||a===S&&-1!==[S,T,H].indexOf(l))return J;if(-1!==[S,T,H,U,y].indexOf(l))for(var d=r;d>=0;){if((u=e[d])===S)return J;if(-1===[T,H].indexOf(u))break;d--}if(-1!==[K,D].indexOf(l))for(d=-1!==[U,y].indexOf(a)?i:r;d>=0;){var u;if((u=e[d])===S)return J;if(-1===[T,H].indexOf(u))break;d--}if(V===a&&-1!==[V,N,R,O].indexOf(l)||-1!==[N,R].indexOf(a)&&-1!==[N,G].indexOf(l)||-1!==[G,O].indexOf(a)&&l===G)return J;if(-1!==AA.indexOf(a)&&-1!==[E,D].indexOf(l)||-1!==AA.indexOf(l)&&a===K)return J;if(-1!==z.indexOf(a)&&-1!==z.indexOf(l))return J;if(a===H&&-1!==z.indexOf(l))return J;if(-1!==z.concat(S).indexOf(a)&&l===I&&-1===W.indexOf(A[s])||-1!==z.concat(S).indexOf(l)&&a===y)return J;if(41===a&&41===l){for(var g=t[r],B=1;g>0&&41===e[--g];)B++;if(B%2!=0)return J}return a===L&&l===P?J:X},rA=function(A,e){e||(e={lineBreak:"normal",wordBreak:"normal"});var t=function(A,e){void 0===e&&(e="strict");var t=[],n=[],o=[];return A.forEach(function(A,r){var i=Y.get(A);if(i>50?(o.push(!0),i-=50):o.push(!1),-1!==["normal","auto","loose"].indexOf(e)&&-1!==[8208,8211,12316,12448].indexOf(A))return n.push(r),t.push(16);if(4===i||11===i){if(0===r)return n.push(r),t.push(k);var s=t[r-1];return-1===$.indexOf(s)?(n.push(n[r-1]),t.push(s)):(n.push(r),t.push(k))}return n.push(r),31===i?t.push("strict"===e?x:M):i===_||29===i?t.push(k):43===i?A>=131072&&A<=196605||A>=196608&&A<=262141?t.push(M):t.push(k):void t.push(i)}),[n,t,o]}(A,e.lineBreak),n=t[0],o=t[1],r=t[2];"break-all"!==e.wordBreak&&"break-word"!==e.wordBreak||(o=o.map(function(A){return-1!==[S,k,_].indexOf(A)?M:A}));var i="keep-all"===e.wordBreak?r.map(function(e,t){return e&&A[t]>=19968&&A[t]<=40959}):void 0;return[n,o,i]},iA=function(){function A(A,e,t,n){this.codePoints=A,this.required="!"===e,this.start=t,this.end=n}return A.prototype.slice=function(){return c.apply(void 0,this.codePoints.slice(this.start,this.end))},A}(),sA=45,aA=43,cA=-1,lA=function(A){return A>=48&&A<=57},dA=function(A){return lA(A)||A>=65&&A<=70||A>=97&&A<=102},uA=function(A){return 10===A||9===A||32===A},gA=function(A){return function(A){return function(A){return A>=97&&A<=122}(A)||function(A){return A>=65&&A<=90}(A)}(A)||function(A){return A>=128}(A)||95===A},BA=function(A){return gA(A)||lA(A)||A===sA},hA=function(A){return A>=0&&A<=8||11===A||A>=14&&A<=31||127===A},pA=function(A,e){return 92===A&&10!==e},wA=function(A,e,t){return A===sA?gA(e)||pA(e,t):!!gA(A)||!(92!==A||!pA(A,e))},fA=function(A,e,t){return A===aA||A===sA?!!lA(e)||46===e&&lA(t):lA(46===A?e:A)},CA=function(A){var e=0,t=1;A[e]!==aA&&A[e]!==sA||(A[e]===sA&&(t=-1),e++);for(var n=[];lA(A[e]);)n.push(A[e++]);var o=n.length?parseInt(c.apply(void 0,n),10):0;46===A[e]&&e++;for(var r=[];lA(A[e]);)r.push(A[e++]);var i=r.length,s=i?parseInt(c.apply(void 0,r),10):0;69!==A[e]&&101!==A[e]||e++;var a=1;A[e]!==aA&&A[e]!==sA||(A[e]===sA&&(a=-1),e++);for(var l=[];lA(A[e]);)l.push(A[e++]);var d=l.length?parseInt(c.apply(void 0,l),10):0;return t*(o+s*Math.pow(10,-i))*Math.pow(10,a*d)},mA={type:2},vA={type:3},QA={type:4},FA={type:13},UA={type:8},yA={type:21},bA={type:9},EA={type:10},xA={type:11},IA={type:12},HA={type:14},SA={type:23},DA={type:1},KA={type:25},TA={type:24},kA={type:26},LA={type:27},PA={type:28},RA={type:29},OA={type:31},MA={type:32},VA=function(){function A(){this._value=[]}return A.prototype.write=function(A){this._value=this._value.concat(a(A))},A.prototype.read=function(){for(var A=[],e=this.consumeToken();e!==MA;)A.push(e),e=this.consumeToken();return A},A.prototype.consumeToken=function(){var A=this.consumeCodePoint();switch(A){case 34:return this.consumeStringToken(34);case 35:var e=this.peekCodePoint(0),t=this.peekCodePoint(1),n=this.peekCodePoint(2);if(BA(e)||pA(t,n)){var o=wA(e,t,n)?2:1;return{type:5,value:this.consumeName(),flags:o}}break;case 36:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),FA;break;case 39:return this.consumeStringToken(39);case 40:return mA;case 41:return vA;case 42:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),HA;break;case aA:if(fA(A,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(A),this.consumeNumericToken();break;case 44:return QA;case sA:var r=A,i=this.peekCodePoint(0),s=this.peekCodePoint(1);if(fA(r,i,s))return this.reconsumeCodePoint(A),this.consumeNumericToken();if(wA(r,i,s))return this.reconsumeCodePoint(A),this.consumeIdentLikeToken();if(i===sA&&62===s)return this.consumeCodePoint(),this.consumeCodePoint(),TA;break;case 46:if(fA(A,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(A),this.consumeNumericToken();break;case 47:if(42===this.peekCodePoint(0))for(this.consumeCodePoint();;){var a=this.consumeCodePoint();if(42===a&&47===(a=this.consumeCodePoint()))return this.consumeToken();if(a===cA)return this.consumeToken()}break;case 58:return kA;case 59:return LA;case 60:if(33===this.peekCodePoint(0)&&this.peekCodePoint(1)===sA&&this.peekCodePoint(2)===sA)return this.consumeCodePoint(),this.consumeCodePoint(),KA;break;case 64:var l=this.peekCodePoint(0),d=this.peekCodePoint(1),u=this.peekCodePoint(2);if(wA(l,d,u))return{type:7,value:this.consumeName()};break;case 91:return PA;case 92:if(pA(A,this.peekCodePoint(0)))return this.reconsumeCodePoint(A),this.consumeIdentLikeToken();break;case 93:return RA;case 61:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),UA;break;case 123:return xA;case 125:return IA;case 117:case 85:var g=this.peekCodePoint(0),B=this.peekCodePoint(1);return g!==aA||!dA(B)&&63!==B||(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(A),this.consumeIdentLikeToken();case 124:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),bA;if(124===this.peekCodePoint(0))return this.consumeCodePoint(),yA;break;case 126:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),EA;break;case cA:return MA}return uA(A)?(this.consumeWhiteSpace(),OA):lA(A)?(this.reconsumeCodePoint(A),this.consumeNumericToken()):gA(A)?(this.reconsumeCodePoint(A),this.consumeIdentLikeToken()):{type:6,value:c(A)}},A.prototype.consumeCodePoint=function(){var A=this._value.shift();return void 0===A?-1:A},A.prototype.reconsumeCodePoint=function(A){this._value.unshift(A)},A.prototype.peekCodePoint=function(A){return A>=this._value.length?-1:this._value[A]},A.prototype.consumeUnicodeRangeToken=function(){for(var A=[],e=this.consumeCodePoint();dA(e)&&A.length<6;)A.push(e),e=this.consumeCodePoint();for(var t=!1;63===e&&A.length<6;)A.push(e),e=this.consumeCodePoint(),t=!0;if(t)return{type:30,start:parseInt(c.apply(void 0,A.map(function(A){return 63===A?48:A})),16),end:parseInt(c.apply(void 0,A.map(function(A){return 63===A?70:A})),16)};var n=parseInt(c.apply(void 0,A),16);if(this.peekCodePoint(0)===sA&&dA(this.peekCodePoint(1))){this.consumeCodePoint(),e=this.consumeCodePoint();for(var o=[];dA(e)&&o.length<6;)o.push(e),e=this.consumeCodePoint();return{type:30,start:n,end:parseInt(c.apply(void 0,o),16)}}return{type:30,start:n,end:n}},A.prototype.consumeIdentLikeToken=function(){var A=this.consumeName();return"url"===A.toLowerCase()&&40===this.peekCodePoint(0)?(this.consumeCodePoint(),this.consumeUrlToken()):40===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:19,value:A}):{type:20,value:A}},A.prototype.consumeUrlToken=function(){var A=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===cA)return{type:22,value:""};var e=this.peekCodePoint(0);if(39===e||34===e){var t=this.consumeStringToken(this.consumeCodePoint());return 0===t.type&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===cA||41===this.peekCodePoint(0))?(this.consumeCodePoint(),{type:22,value:t.value}):(this.consumeBadUrlRemnants(),SA)}for(;;){var n=this.consumeCodePoint();if(n===cA||41===n)return{type:22,value:c.apply(void 0,A)};if(uA(n))return this.consumeWhiteSpace(),this.peekCodePoint(0)===cA||41===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:22,value:c.apply(void 0,A)}):(this.consumeBadUrlRemnants(),SA);if(34===n||39===n||40===n||hA(n))return this.consumeBadUrlRemnants(),SA;if(92===n){if(!pA(n,this.peekCodePoint(0)))return this.consumeBadUrlRemnants(),SA;A.push(this.consumeEscapedCodePoint())}else A.push(n)}},A.prototype.consumeWhiteSpace=function(){for(;uA(this.peekCodePoint(0));)this.consumeCodePoint()},A.prototype.consumeBadUrlRemnants=function(){for(;;){var A=this.consumeCodePoint();if(41===A||A===cA)return;pA(A,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},A.prototype.consumeStringSlice=function(A){for(var e="";A>0;){var t=Math.min(5e4,A);e+=c.apply(void 0,this._value.splice(0,t)),A-=t}return this._value.shift(),e},A.prototype.consumeStringToken=function(A){for(var e="",t=0;;){var n=this._value[t];if(n===cA||void 0===n||n===A)return{type:0,value:e+=this.consumeStringSlice(t)};if(10===n)return this._value.splice(0,t),DA;if(92===n){var o=this._value[t+1];o!==cA&&void 0!==o&&(10===o?(e+=this.consumeStringSlice(t),t=-1,this._value.shift()):pA(n,o)&&(e+=this.consumeStringSlice(t),e+=c(this.consumeEscapedCodePoint()),t=-1))}t++}},A.prototype.consumeNumber=function(){var A=[],e=4,t=this.peekCodePoint(0);for(t!==aA&&t!==sA||A.push(this.consumeCodePoint());lA(this.peekCodePoint(0));)A.push(this.consumeCodePoint());t=this.peekCodePoint(0);var n=this.peekCodePoint(1);if(46===t&&lA(n))for(A.push(this.consumeCodePoint(),this.consumeCodePoint()),e=8;lA(this.peekCodePoint(0));)A.push(this.consumeCodePoint());t=this.peekCodePoint(0),n=this.peekCodePoint(1);var o=this.peekCodePoint(2);if((69===t||101===t)&&((n===aA||n===sA)&&lA(o)||lA(n)))for(A.push(this.consumeCodePoint(),this.consumeCodePoint()),e=8;lA(this.peekCodePoint(0));)A.push(this.consumeCodePoint());return[CA(A),e]},A.prototype.consumeNumericToken=function(){var A=this.consumeNumber(),e=A[0],t=A[1],n=this.peekCodePoint(0),o=this.peekCodePoint(1),r=this.peekCodePoint(2);return wA(n,o,r)?{type:15,number:e,flags:t,unit:this.consumeName()}:37===n?(this.consumeCodePoint(),{type:16,number:e,flags:t}):{type:17,number:e,flags:t}},A.prototype.consumeEscapedCodePoint=function(){var A=this.consumeCodePoint();if(dA(A)){for(var e=c(A);dA(this.peekCodePoint(0))&&e.length<6;)e+=c(this.consumeCodePoint());uA(this.peekCodePoint(0))&&this.consumeCodePoint();var t=parseInt(e,16);return 0===t||function(A){return A>=55296&&A<=57343}(t)||t>1114111?65533:t}return A===cA?65533:A},A.prototype.consumeName=function(){for(var A="";;){var e=this.consumeCodePoint();if(BA(e))A+=c(e);else{if(!pA(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),A;A+=c(this.consumeEscapedCodePoint())}}},A}(),NA=function(){function A(A){this._tokens=A}return A.create=function(e){var t=new VA;return t.write(e),new A(t.read())},A.parseValue=function(e){return A.create(e).parseComponentValue()},A.parseValues=function(e){return A.create(e).parseComponentValues()},A.prototype.parseComponentValue=function(){for(var A=this.consumeToken();31===A.type;)A=this.consumeToken();if(32===A.type)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(A);var e=this.consumeComponentValue();do{A=this.consumeToken()}while(31===A.type);if(32===A.type)return e;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},A.prototype.parseComponentValues=function(){for(var A=[];;){var e=this.consumeComponentValue();if(32===e.type)return A;A.push(e),A.push()}},A.prototype.consumeComponentValue=function(){var A=this.consumeToken();switch(A.type){case 11:case 28:case 2:return this.consumeSimpleBlock(A.type);case 19:return this.consumeFunction(A)}return A},A.prototype.consumeSimpleBlock=function(A){for(var e={type:A,values:[]},t=this.consumeToken();;){if(32===t.type||ZA(t,A))return e;this.reconsumeToken(t),e.values.push(this.consumeComponentValue()),t=this.consumeToken()}},A.prototype.consumeFunction=function(A){for(var e={name:A.value,values:[],type:18};;){var t=this.consumeToken();if(32===t.type||3===t.type)return e;this.reconsumeToken(t),e.values.push(this.consumeComponentValue())}},A.prototype.consumeToken=function(){var A=this._tokens.shift();return void 0===A?MA:A},A.prototype.reconsumeToken=function(A){this._tokens.unshift(A)},A}(),GA=function(A){return 15===A.type},_A=function(A){return 17===A.type},WA=function(A){return 20===A.type},JA=function(A){return 0===A.type},XA=function(A,e){return WA(A)&&A.value===e},YA=function(A){return 31!==A.type},zA=function(A){return 31!==A.type&&4!==A.type},jA=function(A){var e=[],t=[];return A.forEach(function(A){if(4===A.type){if(0===t.length)throw new Error("Error parsing function args, zero tokens for arg");return e.push(t),void(t=[])}31!==A.type&&t.push(A)}),t.length&&e.push(t),e},ZA=function(A,e){return 11===e&&12===A.type||28===e&&29===A.type||2===e&&3===A.type},qA=function(A){return 17===A.type||15===A.type},$A=function(A){return 16===A.type||qA(A)},Ae=function(A){return A.length>1?[A[0],A[1]]:[A[0]]},ee={type:17,number:0,flags:4},te={type:16,number:50,flags:4},ne={type:16,number:100,flags:4},oe=function(A,e,t){var n=A[0],o=A[1];return[re(n,e),re(void 0!==o?o:n,t)]},re=function(A,e){if(16===A.type)return A.number/100*e;if(GA(A))switch(A.unit){case"rem":case"em":return 16*A.number;default:return A.number}return A.number},ie="grad",se="turn",ae=function(A,e){if(15===e.type)switch(e.unit){case"deg":return Math.PI*e.number/180;case ie:return Math.PI/200*e.number;case"rad":return e.number;case se:return 2*Math.PI*e.number}throw new Error("Unsupported angle type")},ce=function(A){return 15===A.type&&("deg"===A.unit||A.unit===ie||"rad"===A.unit||A.unit===se)},le=function(A){switch(A.filter(WA).map(function(A){return A.value}).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[ee,ee];case"to top":case"bottom":return de(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[ee,ne];case"to right":case"left":return de(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[ne,ne];case"to bottom":case"top":return de(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[ne,ee];case"to left":case"right":return de(270)}return 0},de=function(A){return Math.PI*A/180},ue=function(A,e){if(18===e.type){var t=me[e.name];if(void 0===t)throw new Error('Attempting to parse an unsupported color function "'+e.name+'"');return t(A,e.values)}if(5===e.type){if(3===e.value.length){var n=e.value.substring(0,1),o=e.value.substring(1,2),r=e.value.substring(2,3);return he(parseInt(n+n,16),parseInt(o+o,16),parseInt(r+r,16),1)}if(4===e.value.length){n=e.value.substring(0,1),o=e.value.substring(1,2),r=e.value.substring(2,3);var i=e.value.substring(3,4);return he(parseInt(n+n,16),parseInt(o+o,16),parseInt(r+r,16),parseInt(i+i,16)/255)}if(6===e.value.length)return n=e.value.substring(0,2),o=e.value.substring(2,4),r=e.value.substring(4,6),he(parseInt(n,16),parseInt(o,16),parseInt(r,16),1);if(8===e.value.length)return n=e.value.substring(0,2),o=e.value.substring(2,4),r=e.value.substring(4,6),i=e.value.substring(6,8),he(parseInt(n,16),parseInt(o,16),parseInt(r,16),parseInt(i,16)/255)}if(20===e.type){var s=Qe[e.value.toUpperCase()];if(void 0!==s)return s}return Qe.TRANSPARENT},ge=function(A){return!(255&A)},Be=function(A){var e=255&A,t=255&A>>8,n=255&A>>16,o=255&A>>24;return e<255?"rgba("+o+","+n+","+t+","+e/255+")":"rgb("+o+","+n+","+t+")"},he=function(A,e,t,n){return(A<<24|e<<16|t<<8|Math.round(255*n))>>>0},pe=function(A,e){if(17===A.type)return A.number;if(16===A.type){var t=3===e?1:255;return 3===e?A.number/100*t:Math.round(A.number/100*t)}return 0},we=function(A,e){var t=e.filter(zA);if(3===t.length){var n=t.map(pe),o=n[0],r=n[1],i=n[2];return he(o,r,i,1)}if(4===t.length){var s=t.map(pe),a=(o=s[0],r=s[1],i=s[2],s[3]);return he(o,r,i,a)}return 0};function fe(A,e,t){return t<0&&(t+=1),t>=1&&(t-=1),t<1/6?(e-A)*t*6+A:t<.5?e:t<2/3?6*(e-A)*(2/3-t)+A:A}var Ce=function(A,e){var t=e.filter(zA),n=t[0],o=t[1],r=t[2],i=t[3],s=(17===n.type?de(n.number):ae(A,n))/(2*Math.PI),a=$A(o)?o.number/100:0,c=$A(r)?r.number/100:0,l=void 0!==i&&$A(i)?re(i,1):1;if(0===a)return he(255*c,255*c,255*c,1);var d=c<=.5?c*(a+1):c+a-c*a,u=2*c-d,g=fe(u,d,s+1/3),B=fe(u,d,s),h=fe(u,d,s-1/3);return he(255*g,255*B,255*h,l)},me={hsl:Ce,hsla:Ce,rgb:we,rgba:we},ve=function(A,e){return ue(A,NA.create(e).parseComponentValue())},Qe={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},Fe={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(A,e){return e.map(function(A){if(WA(A))switch(A.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},Ue={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},ye=function(A,e){var t=ue(A,e[0]),n=e[1];return n&&$A(n)?{color:t,stop:n}:{color:t,stop:null}},be=function(A,e){var t=A[0],n=A[A.length-1];null===t.stop&&(t.stop=ee),null===n.stop&&(n.stop=ne);for(var o=[],r=0,i=0;i<A.length;i++){var s=A[i].stop;if(null!==s){var a=re(s,e);a>r?o.push(a):o.push(r),r=a}else o.push(null)}var c=null;for(i=0;i<o.length;i++){var l=o[i];if(null===l)null===c&&(c=i);else if(null!==c){for(var d=i-c,u=(l-o[c-1])/(d+1),g=1;g<=d;g++)o[c+g-1]=u*g;c=null}}return A.map(function(A,t){return{color:A.color,stop:Math.max(Math.min(1,o[t]/e),0)}})},Ee=function(A,e,t){var n="number"==typeof A?A:function(A,e,t){var n=e/2,o=t/2,r=re(A[0],e)-n,i=o-re(A[1],t);return(Math.atan2(i,r)+2*Math.PI)%(2*Math.PI)}(A,e,t),o=Math.abs(e*Math.sin(n))+Math.abs(t*Math.cos(n)),r=e/2,i=t/2,s=o/2,a=Math.sin(n-Math.PI/2)*s,c=Math.cos(n-Math.PI/2)*s;return[o,r-c,r+c,i-a,i+a]},xe=function(A,e){return Math.sqrt(A*A+e*e)},Ie=function(A,e,t,n,o){return[[0,0],[0,e],[A,0],[A,e]].reduce(function(A,e){var r=e[0],i=e[1],s=xe(t-r,n-i);return(o?s<A.optimumDistance:s>A.optimumDistance)?{optimumCorner:e,optimumDistance:s}:A},{optimumDistance:o?1/0:-1/0,optimumCorner:null}).optimumCorner},He=function(A,e){var t=de(180),n=[];return jA(e).forEach(function(e,o){if(0===o){var r=e[0];if(20===r.type&&-1!==["top","left","right","bottom"].indexOf(r.value))return void(t=le(e));if(ce(r))return void(t=(ae(A,r)+de(270))%de(360))}var i=ye(A,e);n.push(i)}),{angle:t,stops:n,type:1}},Se="closest-side",De="farthest-side",Ke="closest-corner",Te="farthest-corner",ke="circle",Le="ellipse",Pe="cover",Re="contain",Oe=function(A,e){var t=0,n=3,o=[],r=[];return jA(e).forEach(function(e,i){var s=!0;if(0===i?s=e.reduce(function(A,e){if(WA(e))switch(e.value){case"center":return r.push(te),!1;case"top":case"left":return r.push(ee),!1;case"right":case"bottom":return r.push(ne),!1}else if($A(e)||qA(e))return r.push(e),!1;return A},s):1===i&&(s=e.reduce(function(A,e){if(WA(e))switch(e.value){case ke:return t=0,!1;case Le:return t=1,!1;case Re:case Se:return n=0,!1;case De:return n=1,!1;case Ke:return n=2,!1;case Pe:case Te:return n=3,!1}else if(qA(e)||$A(e))return Array.isArray(n)||(n=[]),n.push(e),!1;return A},s)),s){var a=ye(A,e);o.push(a)}}),{size:n,shape:t,stops:o,position:r,type:2}},Me=function(A,e){if(22===e.type){var t={url:e.value,type:0};return A.cache.addImage(e.value),t}if(18===e.type){var n=Ne[e.name];if(void 0===n)throw new Error('Attempting to parse an unsupported image function "'+e.name+'"');return n(A,e.values)}throw new Error("Unsupported image type "+e.type)};var Ve,Ne={"linear-gradient":function(A,e){var t=de(180),n=[];return jA(e).forEach(function(e,o){if(0===o){var r=e[0];if(20===r.type&&"to"===r.value)return void(t=le(e));if(ce(r))return void(t=ae(A,r))}var i=ye(A,e);n.push(i)}),{angle:t,stops:n,type:1}},"-moz-linear-gradient":He,"-ms-linear-gradient":He,"-o-linear-gradient":He,"-webkit-linear-gradient":He,"radial-gradient":function(A,e){var t=0,n=3,o=[],r=[];return jA(e).forEach(function(e,i){var s=!0;if(0===i){var a=!1;s=e.reduce(function(A,e){if(a)if(WA(e))switch(e.value){case"center":return r.push(te),A;case"top":case"left":return r.push(ee),A;case"right":case"bottom":return r.push(ne),A}else($A(e)||qA(e))&&r.push(e);else if(WA(e))switch(e.value){case ke:return t=0,!1;case Le:return t=1,!1;case"at":return a=!0,!1;case Se:return n=0,!1;case Pe:case De:return n=1,!1;case Re:case Ke:return n=2,!1;case Te:return n=3,!1}else if(qA(e)||$A(e))return Array.isArray(n)||(n=[]),n.push(e),!1;return A},s)}if(s){var c=ye(A,e);o.push(c)}}),{size:n,shape:t,stops:o,position:r,type:2}},"-moz-radial-gradient":Oe,"-ms-radial-gradient":Oe,"-o-radial-gradient":Oe,"-webkit-radial-gradient":Oe,"-webkit-gradient":function(A,e){var t=de(180),n=[],o=1;return jA(e).forEach(function(e,t){var r=e[0];if(0===t){if(WA(r)&&"linear"===r.value)return void(o=1);if(WA(r)&&"radial"===r.value)return void(o=2)}if(18===r.type)if("from"===r.name){var i=ue(A,r.values[0]);n.push({stop:ee,color:i})}else if("to"===r.name)i=ue(A,r.values[0]),n.push({stop:ne,color:i});else if("color-stop"===r.name){var s=r.values.filter(zA);if(2===s.length){i=ue(A,s[1]);var a=s[0];_A(a)&&n.push({stop:{type:16,number:100*a.number,flags:a.flags},color:i})}}}),1===o?{angle:(t+de(180))%de(360),stops:n,type:o}:{size:3,shape:0,stops:n,position:[],type:o}}},Ge={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(A,e){if(0===e.length)return[];var t=e[0];return 20===t.type&&"none"===t.value?[]:e.filter(function(A){return zA(A)&&function(A){return!(20===A.type&&"none"===A.value||18===A.type&&!Ne[A.name])}(A)}).map(function(e){return Me(A,e)})}},_e={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(A,e){return e.map(function(A){if(WA(A))switch(A.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},We={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(A,e){return jA(e).map(function(A){return A.filter($A)}).map(Ae)}},Je={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(A,e){return jA(e).map(function(A){return A.filter(WA).map(function(A){return A.value}).join(" ")}).map(Xe)}},Xe=function(A){switch(A){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;default:return 0}};!function(A){A.AUTO="auto",A.CONTAIN="contain",A.COVER="cover"}(Ve||(Ve={}));var Ye,ze={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(A,e){return jA(e).map(function(A){return A.filter(je)})}},je=function(A){return WA(A)||$A(A)},Ze=function(A){return{name:"border-"+A+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},qe=Ze("top"),$e=Ze("right"),At=Ze("bottom"),et=Ze("left"),tt=function(A){return{name:"border-radius-"+A,initialValue:"0 0",prefix:!1,type:1,parse:function(A,e){return Ae(e.filter($A))}}},nt=tt("top-left"),ot=tt("top-right"),rt=tt("bottom-right"),it=tt("bottom-left"),st=function(A){return{name:"border-"+A+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(A,e){switch(e){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},at=st("top"),ct=st("right"),lt=st("bottom"),dt=st("left"),ut=function(A){return{name:"border-"+A+"-width",initialValue:"0",type:0,prefix:!1,parse:function(A,e){return GA(e)?e.number:0}}},gt=ut("top"),Bt=ut("right"),ht=ut("bottom"),pt=ut("left"),wt={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},ft={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(A,e){return"rtl"===e?1:0}},Ct={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(A,e){return e.filter(WA).reduce(function(A,e){return A|mt(e.value)},0)}},mt=function(A){switch(A){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},vt={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(A,e){switch(e){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},Qt={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(A,e){return 20===e.type&&"normal"===e.value?0:17===e.type||15===e.type?e.number:0}};!function(A){A.NORMAL="normal",A.STRICT="strict"}(Ye||(Ye={}));var Ft,Ut={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(A,e){return"strict"===e?Ye.STRICT:Ye.NORMAL}},yt={name:"line-height",initialValue:"normal",prefix:!1,type:4},bt=function(A,e){return WA(A)&&"normal"===A.value?1.2*e:17===A.type?e*A.number:$A(A)?re(A,e):e},Et={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(A,e){return 20===e.type&&"none"===e.value?null:Me(A,e)}},xt={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(A,e){return"inside"===e?0:1}},It={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(A,e){switch(e){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;default:return-1}}},Ht=function(A){return{name:"margin-"+A,initialValue:"0",prefix:!1,type:4}},St=Ht("top"),Dt=Ht("right"),Kt=Ht("bottom"),Tt=Ht("left"),kt={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(A,e){return e.filter(WA).map(function(A){switch(A.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;default:return 0}})}},Lt={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(A,e){return"break-word"===e?"break-word":"normal"}},Pt=function(A){return{name:"padding-"+A,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},Rt=Pt("top"),Ot=Pt("right"),Mt=Pt("bottom"),Vt=Pt("left"),Nt={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(A,e){switch(e){case"right":return 2;case"center":case"justify":return 1;default:return 0}}},Gt={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(A,e){switch(e){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},_t={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(A,e){return 1===e.length&&XA(e[0],"none")?[]:jA(e).map(function(e){for(var t={color:Qe.TRANSPARENT,offsetX:ee,offsetY:ee,blur:ee},n=0,o=0;o<e.length;o++){var r=e[o];qA(r)?(0===n?t.offsetX=r:1===n?t.offsetY=r:t.blur=r,n++):t.color=ue(A,r)}return t})}},Wt={name:"text-transform",initialValue:"none",prefix:!1,type:2,parse:function(A,e){switch(e){case"uppercase":return 2;case"lowercase":return 1;case"capitalize":return 3}return 0}},Jt={name:"transform",initialValue:"none",prefix:!0,type:0,parse:function(A,e){if(20===e.type&&"none"===e.value)return null;if(18===e.type){var t=Xt[e.name];if(void 0===t)throw new Error('Attempting to parse an unsupported transform function "'+e.name+'"');return t(e.values)}return null}},Xt={matrix:function(A){var e=A.filter(function(A){return 17===A.type}).map(function(A){return A.number});return 6===e.length?e:null},matrix3d:function(A){var e=A.filter(function(A){return 17===A.type}).map(function(A){return A.number}),t=e[0],n=e[1];e[2],e[3];var o=e[4],r=e[5];e[6],e[7],e[8],e[9],e[10],e[11];var i=e[12],s=e[13];return e[14],e[15],16===e.length?[t,n,o,r,i,s]:null}},Yt={type:16,number:50,flags:4},zt=[Yt,Yt],jt={name:"transform-origin",initialValue:"50% 50%",prefix:!0,type:1,parse:function(A,e){var t=e.filter($A);return 2!==t.length?zt:[t[0],t[1]]}},Zt={name:"visible",initialValue:"none",prefix:!1,type:2,parse:function(A,e){switch(e){case"hidden":return 1;case"collapse":return 2;default:return 0}}};!function(A){A.NORMAL="normal",A.BREAK_ALL="break-all",A.KEEP_ALL="keep-all"}(Ft||(Ft={}));for(var qt={name:"word-break",initialValue:"normal",prefix:!1,type:2,parse:function(A,e){switch(e){case"break-all":return Ft.BREAK_ALL;case"keep-all":return Ft.KEEP_ALL;default:return Ft.NORMAL}}},$t={name:"z-index",initialValue:"auto",prefix:!1,type:0,parse:function(A,e){if(20===e.type)return{auto:!0,order:0};if(_A(e))return{auto:!1,order:e.number};throw new Error("Invalid z-index number parsed")}},An={name:"time",parse:function(A,e){if(15===e.type)switch(e.unit.toLowerCase()){case"s":return 1e3*e.number;case"ms":return e.number}throw new Error("Unsupported time type")}},en={name:"opacity",initialValue:"1",type:0,prefix:!1,parse:function(A,e){return _A(e)?e.number:1}},tn={name:"text-decoration-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},nn={name:"text-decoration-line",initialValue:"none",prefix:!1,type:1,parse:function(A,e){return e.filter(WA).map(function(A){switch(A.value){case"underline":return 1;case"overline":return 2;case"line-through":return 3;case"none":return 4}return 0}).filter(function(A){return 0!==A})}},on={name:"font-family",initialValue:"",prefix:!1,type:1,parse:function(A,e){var t=[],n=[];return e.forEach(function(A){switch(A.type){case 20:case 0:t.push(A.value);break;case 17:t.push(A.number.toString());break;case 4:n.push(t.join(" ")),t.length=0}}),t.length&&n.push(t.join(" ")),n.map(function(A){return-1===A.indexOf(" ")?A:"'"+A+"'"})}},rn={name:"font-size",initialValue:"0",prefix:!1,type:3,format:"length"},sn={name:"font-weight",initialValue:"normal",type:0,prefix:!1,parse:function(A,e){return _A(e)?e.number:WA(e)&&"bold"===e.value?700:400}},an={name:"font-variant",initialValue:"none",type:1,prefix:!1,parse:function(A,e){return e.filter(WA).map(function(A){return A.value})}},cn={name:"font-style",initialValue:"normal",prefix:!1,type:2,parse:function(A,e){switch(e){case"oblique":return"oblique";case"italic":return"italic";default:return"normal"}}},ln=function(A,e){return 0!==(A&e)},dn={name:"content",initialValue:"none",type:1,prefix:!1,parse:function(A,e){if(0===e.length)return[];var t=e[0];return 20===t.type&&"none"===t.value?[]:e}},un={name:"counter-increment",initialValue:"none",prefix:!0,type:1,parse:function(A,e){if(0===e.length)return null;var t=e[0];if(20===t.type&&"none"===t.value)return null;for(var n=[],o=e.filter(YA),r=0;r<o.length;r++){var i=o[r],s=o[r+1];if(20===i.type){var a=s&&_A(s)?s.number:1;n.push({counter:i.value,increment:a})}}return n}},gn={name:"counter-reset",initialValue:"none",prefix:!0,type:1,parse:function(A,e){if(0===e.length)return[];for(var t=[],n=e.filter(YA),o=0;o<n.length;o++){var r=n[o],i=n[o+1];if(WA(r)&&"none"!==r.value){var s=i&&_A(i)?i.number:0;t.push({counter:r.value,reset:s})}}return t}},Bn={name:"duration",initialValue:"0s",prefix:!1,type:1,parse:function(A,e){return e.filter(GA).map(function(e){return An.parse(A,e)})}},hn={name:"quotes",initialValue:"none",prefix:!0,type:1,parse:function(A,e){if(0===e.length)return null;var t=e[0];if(20===t.type&&"none"===t.value)return null;var n=[],o=e.filter(JA);if(o.length%2!=0)return null;for(var r=0;r<o.length;r+=2){var i=o[r].value,s=o[r+1].value;n.push({open:i,close:s})}return n}},pn=function(A,e,t){if(!A)return"";var n=A[Math.min(e,A.length-1)];return n?t?n.open:n.close:""},wn={name:"box-shadow",initialValue:"none",type:1,prefix:!1,parse:function(A,e){return 1===e.length&&XA(e[0],"none")?[]:jA(e).map(function(e){for(var t={color:255,offsetX:ee,offsetY:ee,blur:ee,spread:ee,inset:!1},n=0,o=0;o<e.length;o++){var r=e[o];XA(r,"inset")?t.inset=!0:qA(r)?(0===n?t.offsetX=r:1===n?t.offsetY=r:2===n?t.blur=r:t.spread=r,n++):t.color=ue(A,r)}return t})}},fn={name:"paint-order",initialValue:"normal",prefix:!1,type:1,parse:function(A,e){var t=[];return e.filter(WA).forEach(function(A){switch(A.value){case"stroke":t.push(1);break;case"fill":t.push(0);break;case"markers":t.push(2)}}),[0,1,2].forEach(function(A){-1===t.indexOf(A)&&t.push(A)}),t}},Cn={name:"-webkit-text-stroke-color",initialValue:"currentcolor",prefix:!1,type:3,format:"color"},mn={name:"-webkit-text-stroke-width",initialValue:"0",type:0,prefix:!1,parse:function(A,e){return GA(e)?e.number:0}},vn=function(){function A(A,e){var t,n;this.animationDuration=Un(A,Bn,e.animationDuration),this.backgroundClip=Un(A,Fe,e.backgroundClip),this.backgroundColor=Un(A,Ue,e.backgroundColor),this.backgroundImage=Un(A,Ge,e.backgroundImage),this.backgroundOrigin=Un(A,_e,e.backgroundOrigin),this.backgroundPosition=Un(A,We,e.backgroundPosition),this.backgroundRepeat=Un(A,Je,e.backgroundRepeat),this.backgroundSize=Un(A,ze,e.backgroundSize),this.borderTopColor=Un(A,qe,e.borderTopColor),this.borderRightColor=Un(A,$e,e.borderRightColor),this.borderBottomColor=Un(A,At,e.borderBottomColor),this.borderLeftColor=Un(A,et,e.borderLeftColor),this.borderTopLeftRadius=Un(A,nt,e.borderTopLeftRadius),this.borderTopRightRadius=Un(A,ot,e.borderTopRightRadius),this.borderBottomRightRadius=Un(A,rt,e.borderBottomRightRadius),this.borderBottomLeftRadius=Un(A,it,e.borderBottomLeftRadius),this.borderTopStyle=Un(A,at,e.borderTopStyle),this.borderRightStyle=Un(A,ct,e.borderRightStyle),this.borderBottomStyle=Un(A,lt,e.borderBottomStyle),this.borderLeftStyle=Un(A,dt,e.borderLeftStyle),this.borderTopWidth=Un(A,gt,e.borderTopWidth),this.borderRightWidth=Un(A,Bt,e.borderRightWidth),this.borderBottomWidth=Un(A,ht,e.borderBottomWidth),this.borderLeftWidth=Un(A,pt,e.borderLeftWidth),this.boxShadow=Un(A,wn,e.boxShadow),this.color=Un(A,wt,e.color),this.direction=Un(A,ft,e.direction),this.display=Un(A,Ct,e.display),this.float=Un(A,vt,e.cssFloat),this.fontFamily=Un(A,on,e.fontFamily),this.fontSize=Un(A,rn,e.fontSize),this.fontStyle=Un(A,cn,e.fontStyle),this.fontVariant=Un(A,an,e.fontVariant),this.fontWeight=Un(A,sn,e.fontWeight),this.letterSpacing=Un(A,Qt,e.letterSpacing),this.lineBreak=Un(A,Ut,e.lineBreak),this.lineHeight=Un(A,yt,e.lineHeight),this.listStyleImage=Un(A,Et,e.listStyleImage),this.listStylePosition=Un(A,xt,e.listStylePosition),this.listStyleType=Un(A,It,e.listStyleType),this.marginTop=Un(A,St,e.marginTop),this.marginRight=Un(A,Dt,e.marginRight),this.marginBottom=Un(A,Kt,e.marginBottom),this.marginLeft=Un(A,Tt,e.marginLeft),this.opacity=Un(A,en,e.opacity);var o=Un(A,kt,e.overflow);this.overflowX=o[0],this.overflowY=o[o.length>1?1:0],this.overflowWrap=Un(A,Lt,e.overflowWrap),this.paddingTop=Un(A,Rt,e.paddingTop),this.paddingRight=Un(A,Ot,e.paddingRight),this.paddingBottom=Un(A,Mt,e.paddingBottom),this.paddingLeft=Un(A,Vt,e.paddingLeft),this.paintOrder=Un(A,fn,e.paintOrder),this.position=Un(A,Gt,e.position),this.textAlign=Un(A,Nt,e.textAlign),this.textDecorationColor=Un(A,tn,null!==(t=e.textDecorationColor)&&void 0!==t?t:e.color),this.textDecorationLine=Un(A,nn,null!==(n=e.textDecorationLine)&&void 0!==n?n:e.textDecoration),this.textShadow=Un(A,_t,e.textShadow),this.textTransform=Un(A,Wt,e.textTransform),this.transform=Un(A,Jt,e.transform),this.transformOrigin=Un(A,jt,e.transformOrigin),this.visibility=Un(A,Zt,e.visibility),this.webkitTextStrokeColor=Un(A,Cn,e.webkitTextStrokeColor),this.webkitTextStrokeWidth=Un(A,mn,e.webkitTextStrokeWidth),this.wordBreak=Un(A,qt,e.wordBreak),this.zIndex=Un(A,$t,e.zIndex)}return A.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&0===this.visibility},A.prototype.isTransparent=function(){return ge(this.backgroundColor)},A.prototype.isTransformed=function(){return null!==this.transform},A.prototype.isPositioned=function(){return 0!==this.position},A.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},A.prototype.isFloating=function(){return 0!==this.float},A.prototype.isInlineLevel=function(){return ln(this.display,4)||ln(this.display,33554432)||ln(this.display,268435456)||ln(this.display,536870912)||ln(this.display,67108864)||ln(this.display,134217728)},A}(),Qn=function(A,e){this.content=Un(A,dn,e.content),this.quotes=Un(A,hn,e.quotes)},Fn=function(A,e){this.counterIncrement=Un(A,un,e.counterIncrement),this.counterReset=Un(A,gn,e.counterReset)},Un=function(A,e,t){var n=new VA,o=null!=t?t.toString():e.initialValue;n.write(o);var r=new NA(n.read());switch(e.type){case 2:var i=r.parseComponentValue();return e.parse(A,WA(i)?i.value:e.initialValue);case 0:return e.parse(A,r.parseComponentValue());case 1:return e.parse(A,r.parseComponentValues());case 4:return r.parseComponentValue();case 3:switch(e.format){case"angle":return ae(A,r.parseComponentValue());case"color":return ue(A,r.parseComponentValue());case"image":return Me(A,r.parseComponentValue());case"length":var s=r.parseComponentValue();return qA(s)?s:ee;case"length-percentage":var a=r.parseComponentValue();return $A(a)?a:ee;case"time":return An.parse(A,r.parseComponentValue())}}},yn=function(A,e){var t=function(A){switch(A.getAttribute("data-html2canvas-debug")){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}}(A);return 1===t||e===t},bn=function(A,e){this.context=A,this.textNodes=[],this.elements=[],this.flags=0,yn(e,3),this.styles=new vn(A,window.getComputedStyle(e,null)),So(e)&&(this.styles.animationDuration.some(function(A){return A>0})&&(e.style.animationDuration="0s"),null!==this.styles.transform&&(e.style.transform="none")),this.bounds=s(this.context,e),yn(e,4)&&(this.flags|=16)},En="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",xn="undefined"==typeof Uint8Array?[]:new Uint8Array(256),In=0;In<64;In++)xn[En.charCodeAt(In)]=In;for(var Hn=function(A,e,t){return A.slice?A.slice(e,t):new Uint16Array(Array.prototype.slice.call(A,e,t))},Sn=function(){function A(A,e,t,n,o,r){this.initialValue=A,this.errorValue=e,this.highStart=t,this.highValueIndex=n,this.index=o,this.data=r}return A.prototype.get=function(A){var e;if(A>=0){if(A<55296||A>56319&&A<=65535)return e=((e=this.index[A>>5])<<2)+(31&A),this.data[e];if(A<=65535)return e=((e=this.index[2048+(A-55296>>5)])<<2)+(31&A),this.data[e];if(A<this.highStart)return e=2080+(A>>11),e=this.index[e],e+=A>>5&63,e=((e=this.index[e])<<2)+(31&A),this.data[e];if(A<=1114111)return this.data[this.highValueIndex]}return this.errorValue},A}(),Dn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Kn="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Tn=0;Tn<64;Tn++)Kn[Dn.charCodeAt(Tn)]=Tn;var kn,Ln=8,Pn=9,Rn=11,On=12,Mn=function(){for(var A=[],e=0;e<arguments.length;e++)A[e]=arguments[e];if(String.fromCodePoint)return String.fromCodePoint.apply(String,A);var t=A.length;if(!t)return"";for(var n=[],o=-1,r="";++o<t;){var i=A[o];i<=65535?n.push(i):(i-=65536,n.push(55296+(i>>10),i%1024+56320)),(o+1===t||n.length>16384)&&(r+=String.fromCharCode.apply(String,n),n.length=0)}return r},Vn=function(A){var e,t,n,o=function(A){var e,t,n,o,r,i=.75*A.length,s=A.length,a=0;"="===A[A.length-1]&&(i--,"="===A[A.length-2]&&i--);var c="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.slice?new ArrayBuffer(i):new Array(i),l=Array.isArray(c)?c:new Uint8Array(c);for(e=0;e<s;e+=4)t=xn[A.charCodeAt(e)],n=xn[A.charCodeAt(e+1)],o=xn[A.charCodeAt(e+2)],r=xn[A.charCodeAt(e+3)],l[a++]=t<<2|n>>4,l[a++]=(15&n)<<4|o>>2,l[a++]=(3&o)<<6|63&r;return c}(A),r=Array.isArray(o)?function(A){for(var e=A.length,t=[],n=0;n<e;n+=4)t.push(A[n+3]<<24|A[n+2]<<16|A[n+1]<<8|A[n]);return t}(o):new Uint32Array(o),i=Array.isArray(o)?function(A){for(var e=A.length,t=[],n=0;n<e;n+=2)t.push(A[n+1]<<8|A[n]);return t}(o):new Uint16Array(o),s=Hn(i,12,r[4]/2),a=2===r[5]?Hn(i,(24+r[4])/2):(e=r,t=Math.ceil((24+r[4])/4),e.slice?e.slice(t,n):new Uint32Array(Array.prototype.slice.call(e,t,n)));return new Sn(r[0],r[1],r[2],r[3],s,a)}("AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAMDvwAIAAgAJAIIAAgACAAIAAgACAAIAAgACwMTAwgACAB9BOsEGwMjAwgAKwMyAwsFYgE3A/MEPwMIAEUDTQNRAwgAWQOsAGEDCAAIAAgACAAIAAgACABpAzQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFIQUoBSwFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACAAIAAwAAgACAAIAAgACAAIAAgACAAIAAAARABIAAgACAAIABQASAAIAAgAIABwAEAAjgCIABsAqAC2AL0AigDQAtwC+IJIQqVAZUBWQqVAZUBlQGVAZUBlQGrC5UBlQGVAZUBlQGVAZUBlQGVAXsKlQGVAbAK6wsrDGUMpQzlDJUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAfAKAAuZA64AtwCJALoC6ADwAAgAuACgA/oEpgO6AqsD+AAIAAgAswMIAAgACAAIAIkAuwP5AfsBwwPLAwgACAAIAAgACADRA9kDCAAIAOED6QMIAAgACAAIAAgACADuA/YDCAAIAP4DyQAIAAgABgQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwaKBYoF0wQ3Bj4GigWKBYoFigWKBYoFigWKBYoFigWKBYoFigUIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWLBf///////wQABAAEAAQABAAEAAQABAAEAAQAAwAEAAQAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAQADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUAAAAFAAUAAAAFAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAQAAAAUABQAFAAUABQAFAAAAAAAFAAUAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAFAAUAAQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAAABwAHAAcAAAAHAAcABwAFAAEAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAcABwAFAAUAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQABAAAAAAAAAAAAAAAFAAUABQAFAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAHAAcAAAAHAAcAAAAAAAUABQAHAAUAAQAHAAEABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwABAAUABQAFAAUAAAAAAAAAAAAAAAEAAQABAAEAAQABAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABQANAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAABQAHAAUABQAFAAAAAAAAAAcABQAFAAUABQAFAAQABAAEAAQABAAEAAQABAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUAAAAFAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAUAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAcABwAFAAcABwAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUABwAHAAUABQAFAAUAAAAAAAcABwAAAAAABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAAAAAAAAAAABQAFAAAAAAAFAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAFAAUABQAFAAUAAAAFAAUABwAAAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABwAFAAUABQAFAAAAAAAHAAcAAAAAAAcABwAFAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAAAAAAAAAHAAcABwAAAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAUABQAFAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAHAAcABQAHAAcAAAAFAAcABwAAAAcABwAFAAUAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAFAAcABwAFAAUABQAAAAUAAAAHAAcABwAHAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAHAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUAAAAFAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAUAAAAFAAUAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABwAFAAUABQAFAAUABQAAAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABQAFAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAFAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAHAAUABQAFAAUABQAFAAUABwAHAAcABwAHAAcABwAHAAUABwAHAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABwAHAAcABwAFAAUABwAHAAcAAAAAAAAAAAAHAAcABQAHAAcABwAHAAcABwAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAUABQAFAAUABQAFAAUAAAAFAAAABQAAAAAABQAFAAUABQAFAAUABQAFAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAUABQAFAAUABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABwAFAAcABwAHAAcABwAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAUABQAFAAUABwAHAAUABQAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABQAFAAcABwAHAAUABwAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAcABQAFAAUABQAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAAAAAABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAUABQAHAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAFAAUABQAFAAcABwAFAAUABwAHAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAcABwAFAAUABwAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABQAAAAAABQAFAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAcABwAAAAAAAAAAAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAcABwAFAAcABwAAAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAFAAUABQAAAAUABQAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABwAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAHAAcABQAHAAUABQAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAAABwAHAAAAAAAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAFAAUABwAFAAcABwAFAAcABQAFAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAAAAAABwAHAAcABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAFAAcABwAFAAUABQAFAAUABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAUABQAFAAcABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABQAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAAAAAAFAAUABwAHAAcABwAFAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAHAAUABQAFAAUABQAFAAUABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAABQAAAAUABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAHAAcAAAAFAAUAAAAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABQAFAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAABQAFAAUABQAFAAUABQAAAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAFAAUABQAFAAUADgAOAA4ADgAOAA4ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAMAAwADAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAAAAAAAAAAAAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAAAAAAAAAAAAsADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwACwAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAADgAOAA4AAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAAAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4AAAAOAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAAAAAAAAAAAA4AAAAOAAAAAAAAAAAADgAOAA4AAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA="),Nn="Ã",Gn=function(A){return Vn.get(A)},_n=function(A,e,t){var n=t-2,o=e[n],r=e[t-1],i=e[t];if(2===r&&3===i)return Nn;if(2===r||3===r||4===r)return"Ãˇ";if(2===i||3===i||4===i)return"Ãˇ";if(r===Ln&&-1!==[Ln,Pn,Rn,On].indexOf(i))return Nn;if(!(r!==Rn&&r!==Pn||i!==Pn&&10!==i))return Nn;if((r===On||10===r)&&10===i)return Nn;if(13===i||5===i)return Nn;if(7===i)return Nn;if(1===r)return Nn;if(13===r&&14===i){for(;5===o;)o=e[--n];if(14===o)return Nn}if(15===r&&15===i){for(var s=0;15===o;)s++,o=e[--n];if(s%2==0)return Nn}return"Ãˇ"},Wn=function(A){var e=function(A){for(var e=[],t=0,n=A.length;t<n;){var o=A.charCodeAt(t++);if(o>=55296&&o<=56319&&t<n){var r=A.charCodeAt(t++);56320==(64512&r)?e.push(((1023&o)<<10)+(1023&r)+65536):(e.push(o),t--)}else e.push(o)}return e}(A),t=e.length,n=0,o=0,r=e.map(Gn);return{next:function(){if(n>=t)return{done:!0,value:null};for(var A=Nn;n<t&&(A=_n(0,r,++n))===Nn;);if(A!==Nn||n===t){var i=Mn.apply(null,e.slice(o,n));return o=n,{value:i,done:!1}}return{done:!0,value:null}}}},Jn=function(A){return 0===A[0]&&255===A[1]&&0===A[2]&&255===A[3]},Xn=function(A,e,t,n,o){var r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),s=document.createElementNS(r,"foreignObject");return i.setAttributeNS(null,"width",A.toString()),i.setAttributeNS(null,"height",e.toString()),s.setAttributeNS(null,"width","100%"),s.setAttributeNS(null,"height","100%"),s.setAttributeNS(null,"x",t.toString()),s.setAttributeNS(null,"y",n.toString()),s.setAttributeNS(null,"externalResourcesRequired","true"),i.appendChild(s),s.appendChild(o),i},Yn=function(A){return new Promise(function(e,t){var n=new Image;n.onload=function(){return e(n)},n.onerror=t,n.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent((new XMLSerializer).serializeToString(A))})},zn={get SUPPORT_RANGE_BOUNDS(){var A=function(A){if(A.createRange){var e=A.createRange();if(e.getBoundingClientRect){var t=A.createElement("boundtest");t.style.height="123px",t.style.display="block",A.body.appendChild(t),e.selectNode(t);var n=e.getBoundingClientRect(),o=Math.round(n.height);if(A.body.removeChild(t),123===o)return!0}}return!1}(document);return Object.defineProperty(zn,"SUPPORT_RANGE_BOUNDS",{value:A}),A},get SUPPORT_WORD_BREAKING(){var A=zn.SUPPORT_RANGE_BOUNDS&&function(A){var e=A.createElement("boundtest");e.style.width="50px",e.style.display="block",e.style.fontSize="12px",e.style.letterSpacing="0px",e.style.wordSpacing="0px",A.body.appendChild(e);var t=A.createRange();e.innerHTML="function"==typeof"".repeat?"👨".repeat(10):"";var n=e.firstChild,o=a(n.data).map(function(A){return c(A)}),r=0,i={},s=o.every(function(A,e){t.setStart(n,r),t.setEnd(n,r+A.length);var o=t.getBoundingClientRect();r+=A.length;var s=o.x>i.x||o.y>i.y;return i=o,0===e||s});return A.body.removeChild(e),s}(document);return Object.defineProperty(zn,"SUPPORT_WORD_BREAKING",{value:A}),A},get SUPPORT_SVG_DRAWING(){var A=function(A){var e=new Image,t=A.createElement("canvas"),n=t.getContext("2d");if(!n)return!1;e.src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";try{n.drawImage(e,0,0),t.toDataURL()}catch(A){return!1}return!0}(document);return Object.defineProperty(zn,"SUPPORT_SVG_DRAWING",{value:A}),A},get SUPPORT_FOREIGNOBJECT_DRAWING(){var A="function"==typeof Array.from&&"function"==typeof window.fetch?function(A){var e=A.createElement("canvas"),t=100;e.width=t,e.height=t;var n=e.getContext("2d");if(!n)return Promise.reject(!1);n.fillStyle="rgb(0, 255, 0)",n.fillRect(0,0,t,t);var o=new Image,r=e.toDataURL();o.src=r;var i=Xn(t,t,0,0,o);return n.fillStyle="red",n.fillRect(0,0,t,t),Yn(i).then(function(e){n.drawImage(e,0,0);var o=n.getImageData(0,0,t,t).data;n.fillStyle="red",n.fillRect(0,0,t,t);var i=A.createElement("div");return i.style.backgroundImage="url("+r+")",i.style.height=t+"px",Jn(o)?Yn(Xn(t,t,0,0,i)):Promise.reject(!1)}).then(function(A){return n.drawImage(A,0,0),Jn(n.getImageData(0,0,t,t).data)}).catch(function(){return!1})}(document):Promise.resolve(!1);return Object.defineProperty(zn,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:A}),A},get SUPPORT_CORS_IMAGES(){var A=void 0!==(new Image).crossOrigin;return Object.defineProperty(zn,"SUPPORT_CORS_IMAGES",{value:A}),A},get SUPPORT_RESPONSE_TYPE(){var A="string"==typeof(new XMLHttpRequest).responseType;return Object.defineProperty(zn,"SUPPORT_RESPONSE_TYPE",{value:A}),A},get SUPPORT_CORS_XHR(){var A="withCredentials"in new XMLHttpRequest;return Object.defineProperty(zn,"SUPPORT_CORS_XHR",{value:A}),A},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var A=!("undefined"==typeof Intl||!Intl.Segmenter);return Object.defineProperty(zn,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:A}),A}},jn=function(A,e){this.text=A,this.bounds=e},Zn=function(A,e){var t=e.ownerDocument;if(t){var n=t.createElement("html2canvaswrapper");n.appendChild(e.cloneNode(!0));var o=e.parentNode;if(o){o.replaceChild(n,e);var r=s(A,n);return n.firstChild&&o.replaceChild(n.firstChild,n),r}}return i.EMPTY},qn=function(A,e,t){var n=A.ownerDocument;if(!n)throw new Error("Node has no owner document");var o=n.createRange();return o.setStart(A,e),o.setEnd(A,e+t),o},$n=function(A){if(zn.SUPPORT_NATIVE_TEXT_SEGMENTATION){var e=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(e.segment(A)).map(function(A){return A.segment})}return function(A){for(var e,t=Wn(A),n=[];!(e=t.next()).done;)e.value&&n.push(e.value.slice());return n}(A)},Ao=function(A,e){return 0!==e.letterSpacing?$n(A):function(A,e){if(zn.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(t.segment(A)).map(function(A){return A.segment})}return to(A,e)}(A,e)},eo=[32,160,4961,65792,65793,4153,4241],to=function(A,e){for(var t,n=function(A,e){var t=a(A),n=rA(t,e),o=n[0],r=n[1],i=n[2],s=t.length,c=0,l=0;return{next:function(){if(l>=s)return{done:!0,value:null};for(var A=J;l<s&&(A=oA(t,r,o,++l,i))===J;);if(A!==J||l===s){var e=new iA(t,A,c,l);return c=l,{value:e,done:!1}}return{done:!0,value:null}}}}(A,{lineBreak:e.lineBreak,wordBreak:"break-word"===e.overflowWrap?"break-word":e.wordBreak}),o=[],r=function(){if(t.value){var A=t.value.slice(),e=a(A),n="";e.forEach(function(A){-1===eo.indexOf(A)?n+=c(A):(n.length&&o.push(n),o.push(c(A)),n="")}),n.length&&o.push(n)}};!(t=n.next()).done;)r();return o},no=function(A,e,t){this.text=oo(e.data,t.textTransform),this.textBounds=function(A,e,t,n){var o=Ao(e,t),r=[],s=0;return o.forEach(function(e){if(t.textDecorationLine.length||e.trim().length>0)if(zn.SUPPORT_RANGE_BOUNDS){var o=qn(n,s,e.length).getClientRects();if(o.length>1){var a=$n(e),c=0;a.forEach(function(e){r.push(new jn(e,i.fromDOMRectList(A,qn(n,c+s,e.length).getClientRects()))),c+=e.length})}else r.push(new jn(e,i.fromDOMRectList(A,o)))}else{var l=n.splitText(e.length);r.push(new jn(e,Zn(A,n))),n=l}else zn.SUPPORT_RANGE_BOUNDS||(n=n.splitText(e.length));s+=e.length}),r}(A,this.text,t,e)},oo=function(A,e){switch(e){case 1:return A.toLowerCase();case 3:return A.replace(ro,io);case 2:return A.toUpperCase();default:return A}},ro=/(^|\s|:|-|\(|\))([a-z])/g,io=function(A,e,t){return A.length>0?e+t.toUpperCase():A},so=function(A){function t(e,t){var n=A.call(this,e,t)||this;return n.src=t.currentSrc||t.src,n.intrinsicWidth=t.naturalWidth,n.intrinsicHeight=t.naturalHeight,n.context.cache.addImage(n.src),n}return e(t,A),t}(bn),ao=function(A){function t(e,t){var n=A.call(this,e,t)||this;return n.canvas=t,n.intrinsicWidth=t.width,n.intrinsicHeight=t.height,n}return e(t,A),t}(bn),co=function(A){function t(e,t){var n=A.call(this,e,t)||this,o=new XMLSerializer,r=s(e,t);return t.setAttribute("width",r.width+"px"),t.setAttribute("height",r.height+"px"),n.svg="data:image/svg+xml,"+encodeURIComponent(o.serializeToString(t)),n.intrinsicWidth=t.width.baseVal.value,n.intrinsicHeight=t.height.baseVal.value,n.context.cache.addImage(n.svg),n}return e(t,A),t}(bn),lo=function(A){function t(e,t){var n=A.call(this,e,t)||this;return n.value=t.value,n}return e(t,A),t}(bn),uo=function(A){function t(e,t){var n=A.call(this,e,t)||this;return n.start=t.start,n.reversed="boolean"==typeof t.reversed&&!0===t.reversed,n}return e(t,A),t}(bn),go=[{type:15,flags:0,unit:"px",number:3}],Bo=[{type:16,flags:0,number:50}],ho="checkbox",po="radio",wo="password",fo=707406591,Co=function(A){function t(e,t){var n,o,r,s=A.call(this,e,t)||this;switch(s.type=t.type.toLowerCase(),s.checked=t.checked,s.value=0===(r=(o=t).type===wo?new Array(o.value.length+1).join("âĸ"):o.value).length?o.placeholder||"":r,s.type!==ho&&s.type!==po||(s.styles.backgroundColor=3739148031,s.styles.borderTopColor=s.styles.borderRightColor=s.styles.borderBottomColor=s.styles.borderLeftColor=2779096575,s.styles.borderTopWidth=s.styles.borderRightWidth=s.styles.borderBottomWidth=s.styles.borderLeftWidth=1,s.styles.borderTopStyle=s.styles.borderRightStyle=s.styles.borderBottomStyle=s.styles.borderLeftStyle=1,s.styles.backgroundClip=[0],s.styles.backgroundOrigin=[0],s.bounds=(n=s.bounds).width>n.height?new i(n.left+(n.width-n.height)/2,n.top,n.height,n.height):n.width<n.height?new i(n.left,n.top+(n.height-n.width)/2,n.width,n.width):n),s.type){case ho:s.styles.borderTopRightRadius=s.styles.borderTopLeftRadius=s.styles.borderBottomRightRadius=s.styles.borderBottomLeftRadius=go;break;case po:s.styles.borderTopRightRadius=s.styles.borderTopLeftRadius=s.styles.borderBottomRightRadius=s.styles.borderBottomLeftRadius=Bo}return s}return e(t,A),t}(bn),mo=function(A){function t(e,t){var n=A.call(this,e,t)||this,o=t.options[t.selectedIndex||0];return n.value=o&&o.text||"",n}return e(t,A),t}(bn),vo=function(A){function t(e,t){var n=A.call(this,e,t)||this;return n.value=t.value,n}return e(t,A),t}(bn),Qo=function(A){function t(e,t){var n=A.call(this,e,t)||this;n.src=t.src,n.width=parseInt(t.width,10)||0,n.height=parseInt(t.height,10)||0,n.backgroundColor=n.styles.backgroundColor;try{if(t.contentWindow&&t.contentWindow.document&&t.contentWindow.document.documentElement){n.tree=bo(e,t.contentWindow.document.documentElement);var o=t.contentWindow.document.documentElement?ve(e,getComputedStyle(t.contentWindow.document.documentElement).backgroundColor):Qe.TRANSPARENT,r=t.contentWindow.document.body?ve(e,getComputedStyle(t.contentWindow.document.body).backgroundColor):Qe.TRANSPARENT;n.backgroundColor=ge(o)?ge(r)?n.styles.backgroundColor:r:o}}catch(A){}return n}return e(t,A),t}(bn),Fo=["OL","UL","MENU"],Uo=function(A,e,t,n){for(var o=e.firstChild,r=void 0;o;o=r)if(r=o.nextSibling,Io(o)&&o.data.trim().length>0)t.textNodes.push(new no(A,o,t.styles));else if(Ho(o))if(Wo(o)&&o.assignedNodes)o.assignedNodes().forEach(function(e){return Uo(A,e,t,n)});else{var i=yo(A,o);i.styles.isVisible()&&(Eo(o,i,n)?i.flags|=4:xo(i.styles)&&(i.flags|=2),-1!==Fo.indexOf(o.tagName)&&(i.flags|=8),t.elements.push(i),o.slot,o.shadowRoot?Uo(A,o.shadowRoot,i,n):Go(o)||Lo(o)||_o(o)||Uo(A,o,i,n))}},yo=function(A,e){return Mo(e)?new so(A,e):Ro(e)?new ao(A,e):Lo(e)?new co(A,e):Ko(e)?new lo(A,e):To(e)?new uo(A,e):ko(e)?new Co(A,e):_o(e)?new mo(A,e):Go(e)?new vo(A,e):Vo(e)?new Qo(A,e):new bn(A,e)},bo=function(A,e){var t=yo(A,e);return t.flags|=4,Uo(A,e,t,t),t},Eo=function(A,e,t){return e.styles.isPositionedWithZIndex()||e.styles.opacity<1||e.styles.isTransformed()||Po(A)&&t.styles.isTransparent()},xo=function(A){return A.isPositioned()||A.isFloating()},Io=function(A){return A.nodeType===Node.TEXT_NODE},Ho=function(A){return A.nodeType===Node.ELEMENT_NODE},So=function(A){return Ho(A)&&void 0!==A.style&&!Do(A)},Do=function(A){return"object"==typeof A.className},Ko=function(A){return"LI"===A.tagName},To=function(A){return"OL"===A.tagName},ko=function(A){return"INPUT"===A.tagName},Lo=function(A){return"svg"===A.tagName},Po=function(A){return"BODY"===A.tagName},Ro=function(A){return"CANVAS"===A.tagName},Oo=function(A){return"VIDEO"===A.tagName},Mo=function(A){return"IMG"===A.tagName},Vo=function(A){return"IFRAME"===A.tagName},No=function(A){return"STYLE"===A.tagName},Go=function(A){return"TEXTAREA"===A.tagName},_o=function(A){return"SELECT"===A.tagName},Wo=function(A){return"SLOT"===A.tagName},Jo=function(A){return A.tagName.indexOf("-")>0},Xo=function(){function A(){this.counters={}}return A.prototype.getCounterValue=function(A){var e=this.counters[A];return e&&e.length?e[e.length-1]:1},A.prototype.getCounterValues=function(A){return this.counters[A]||[]},A.prototype.pop=function(A){var e=this;A.forEach(function(A){return e.counters[A].pop()})},A.prototype.parse=function(A){var e=this,t=A.counterIncrement,n=A.counterReset,o=!0;null!==t&&t.forEach(function(A){var t=e.counters[A.counter];t&&0!==A.increment&&(o=!1,t.length||t.push(1),t[Math.max(0,t.length-1)]+=A.increment)});var r=[];return o&&n.forEach(function(A){var t=e.counters[A.counter];r.push(A.counter),t||(t=e.counters[A.counter]=[]),t.push(A.reset)}),r},A}(),Yo={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},zo={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Õ","Õ","Õ","Õ","Õ","Õ","Õ","Õ","Õ","Õ","Õ","Õ","Õ","Õ","Õ","Õ
","Õ","Õ","Õ","Õ","Õ","Ôŋ","Ôž","ÔŊ","Ôŧ","Ôģ","Ôē","Ôš","Ô¸","Ôˇ","Ôļ","Ôĩ","Ô´","Ôŗ","Ô˛","Ôą"]},jo={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["××ŗ","××ŗ","××ŗ","××ŗ","××ŗ","××ŗ","××ŗ","××ŗ","××ŗ","××ŗ","×Ē","׊","ר","×§","×Ļ","פ","×ĸ","ץ","× ","×","×","×","××","××","××","××","××","×","×","×","×","×","×","×","×","×","×"]},Zo={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["áĩ","á°","á¯","á´","áŽ","á","áŦ","áĢ","áĒ","áŠ","á¨","á§","áĻ","áĨ","á¤","áŗ","áĸ","áĄ","á ","á","á","á","á˛","á","á","á","á","á","á","áą","á","á","á","á","á","á","á"]},qo=function(A,e,t,n,o,r){return A<e||A>t?sr(A,o,r.length>0):n.integers.reduce(function(e,t,o){for(;A>=t;)A-=t,e+=n.values[o];return e},"")+r},$o=function(A,e,t,n){var o="";do{t||A--,o=n(A)+o,A/=e}while(A*e>=e);return o},Ar=function(A,e,t,n,o){var r=t-e+1;return(A<0?"-":"")+($o(Math.abs(A),r,n,function(A){return c(Math.floor(A%r)+e)})+o)},er=function(A,e,t){void 0===t&&(t=". ");var n=e.length;return $o(Math.abs(A),n,!1,function(A){return e[Math.floor(A%n)]})+t},tr=function(A,e,t,n,o,r){if(A<-9999||A>9999)return sr(A,4,o.length>0);var i=Math.abs(A),s=o;if(0===i)return e[0]+s;for(var a=0;i>0&&a<=4;a++){var c=i%10;0===c&&ln(r,1)&&""!==s?s=e[c]+s:c>1||1===c&&0===a||1===c&&1===a&&ln(r,2)||1===c&&1===a&&ln(r,4)&&A>100||1===c&&a>1&&ln(r,8)?s=e[c]+(a>0?t[a-1]:"")+s:1===c&&a>0&&(s=t[a-1]+s),i=Math.floor(i/10)}return(A<0?n:"")+s},nr="åįžåčŦ",or="æžäŊ°äģčŦ",rr="ãã¤ããš",ir="ë§ė´ëė¤",sr=function(A,e,t){var n=t?". ":"",o=t?"ã":"",r=t?", ":"",i=t?" ":"";switch(e){case 0:return"âĸ"+i;case 1:return"âĻ"+i;case 2:return"âž"+i;case 5:var s=Ar(A,48,57,!0,n);return s.length<4?"0"+s:s;case 4:return er(A,"ãä¸äēä¸åäēå
ä¸å
Ģäš",o);case 6:return qo(A,1,3999,Yo,3,n).toLowerCase();case 7:return qo(A,1,3999,Yo,3,n);case 8:return Ar(A,945,969,!1,n);case 9:return Ar(A,97,122,!1,n);case 10:return Ar(A,65,90,!1,n);case 11:return Ar(A,1632,1641,!0,n);case 12:case 49:return qo(A,1,9999,zo,3,n);case 35:return qo(A,1,9999,zo,3,n).toLowerCase();case 13:return Ar(A,2534,2543,!0,n);case 14:case 30:return Ar(A,6112,6121,!0,n);case 15:return er(A,"åä¸å¯
å¯čž°åˇŗåæĒįŗé
æäēĨ",o);case 16:return er(A,"į˛äšä¸ä¸æåˇąåēčžåŖŦį¸",o);case 17:case 48:return tr(A,"éļä¸äēä¸åäēå
ä¸å
Ģäš",nr,"č˛ ",o,14);case 47:return tr(A,"éļåŖšč˛ŗåčäŧ鏿æį",or,"č˛ ",o,15);case 42:return tr(A,"éļä¸äēä¸åäēå
ä¸å
Ģäš",nr,"č´",o,14);case 41:return tr(A,"éļåŖšč´°åčäŧéææį",or,"č´",o,15);case 26:return tr(A,"ãä¸äēä¸åäēå
ä¸å
Ģäš","åįžåä¸",rr,o,0);case 25:return tr(A,"éļåŖąåŧååäŧå
ä¸å
Ģäš","æžįžåä¸",rr,o,7);case 31:return tr(A,"ėėŧė´ėŧėŦė¤ėĄėš íęĩŦ","ėë°ąė˛ë§",ir,r,7);case 33:return tr(A,"éļä¸äēä¸åäēå
ä¸å
Ģäš","åįžåčŦ",ir,r,0);case 32:return tr(A,"éļåŖšč˛ŗååäēå
ä¸å
Ģäš","æžįžå",ir,r,7);case 18:return Ar(A,2406,2415,!0,n);case 20:return qo(A,1,19999,Zo,3,n);case 21:return Ar(A,2790,2799,!0,n);case 22:return Ar(A,2662,2671,!0,n);case 22:return qo(A,1,10999,jo,3,n);case 23:return er(A,"ãããããããããããããããããĄã¤ãĻã¨ãĒãĢãŦããŽã¯ã˛ãĩã¸ãģãžãŋãããããããããããããããã");case 24:return er(A,"ããã¯ãĢãģã¸ã¨ãĄããŦããããããããã¤ããĒãããããŽããããžããĩãããĻããããããŋããã˛ããã");case 27:return Ar(A,3302,3311,!0,n);case 28:return er(A,"ãĸã¤ãĻã¨ãĒãĢãã¯ãąãŗãĩãˇãšãģãŊãŋããããããããããããããããã ãĄãĸã¤ãĻã¨ãŠãĒãĢãŦãã¯ã°ãąã˛ãŗ",o);case 29:return er(A,"ã¤ããããããããĒããĢã˛ã¯ãĢã¨ãŋãŦãŊããããŠã ãĻã°ããĒã¯ã¤ããąããŗã¨ããĸãĩããĻãĄããˇãąããĸãģãš",o);case 34:return Ar(A,3792,3801,!0,n);case 37:return Ar(A,6160,6169,!0,n);case 38:return Ar(A,4160,4169,!0,n);case 39:return Ar(A,2918,2927,!0,n);case 40:return Ar(A,1776,1785,!0,n);case 43:return Ar(A,3046,3055,!0,n);case 44:return Ar(A,3174,3183,!0,n);case 45:return Ar(A,3664,3673,!0,n);case 46:return Ar(A,3872,3881,!0,n);default:return Ar(A,48,57,!0,n)}},ar="data-html2canvas-ignore",cr=function(){function A(A,e,t){if(this.context=A,this.options=t,this.scrolledElements=[],this.referenceElement=e,this.counters=new Xo,this.quoteDepth=0,!e.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(e.ownerDocument.documentElement,!1)}return A.prototype.toIFrame=function(A,e){var t=this,r=dr(A,e);if(!r.contentWindow)return Promise.reject("Unable to find iframe window");var i=A.defaultView.pageXOffset,s=A.defaultView.pageYOffset,a=r.contentWindow,c=a.document,l=Br(r).then(function(){return n(t,void 0,void 0,function(){var A,t;return o(this,function(n){switch(n.label){case 0:return this.scrolledElements.forEach(Cr),a&&(a.scrollTo(e.left,e.top),!/(iPad|iPhone|iPod)/g.test(navigator.userAgent)||a.scrollY===e.top&&a.scrollX===e.left||(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(a.scrollX-e.left,a.scrollY-e.top,0,0))),A=this.options.onclone,void 0===(t=this.clonedReferenceElement)?[2,Promise.reject("Error finding the "+this.referenceElement.nodeName+" in the cloned document")]:c.fonts&&c.fonts.ready?[4,c.fonts.ready]:[3,2];case 1:n.sent(),n.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,gr(c)]:[3,4];case 3:n.sent(),n.label=4;case 4:return"function"==typeof A?[2,Promise.resolve().then(function(){return A(c,t)}).then(function(){return r})]:[2,r]}})})});return c.open(),c.write(wr(document.doctype)+"<html></html>"),fr(this.referenceElement.ownerDocument,i,s),c.replaceChild(c.adoptNode(this.documentElement),c.documentElement),c.close(),l},A.prototype.createElementClone=function(A){if(yn(A,2),Ro(A))return this.createCanvasClone(A);if(Oo(A))return this.createVideoClone(A);if(No(A))return this.createStyleClone(A);var e=A.cloneNode(!1);return Mo(e)&&(Mo(A)&&A.currentSrc&&A.currentSrc!==A.src&&(e.src=A.currentSrc,e.srcset=""),"lazy"===e.loading&&(e.loading="eager")),Jo(e)?this.createCustomElementClone(e):e},A.prototype.createCustomElementClone=function(A){var e=document.createElement("html2canvascustomelement");return pr(A.style,e),e},A.prototype.createStyleClone=function(A){try{var e=A.sheet;if(e&&e.cssRules){var t=[].slice.call(e.cssRules,0).reduce(function(A,e){return e&&"string"==typeof e.cssText?A+e.cssText:A},""),n=A.cloneNode(!1);return n.textContent=t,n}}catch(A){if(this.context.logger.error("Unable to access cssRules property",A),"SecurityError"!==A.name)throw A}return A.cloneNode(!1)},A.prototype.createCanvasClone=function(A){var e;if(this.options.inlineImages&&A.ownerDocument){var t=A.ownerDocument.createElement("img");try{return t.src=A.toDataURL(),t}catch(e){this.context.logger.info("Unable to inline canvas contents, canvas is tainted",A)}}var n=A.cloneNode(!1);try{n.width=A.width,n.height=A.height;var o=A.getContext("2d"),r=n.getContext("2d");if(r)if(!this.options.allowTaint&&o)r.putImageData(o.getImageData(0,0,A.width,A.height),0,0);else{var i=null!==(e=A.getContext("webgl2"))&&void 0!==e?e:A.getContext("webgl");if(i){var s=i.getContextAttributes();!1===(null==s?void 0:s.preserveDrawingBuffer)&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",A)}r.drawImage(A,0,0)}return n}catch(e){this.context.logger.info("Unable to clone canvas as it is tainted",A)}return n},A.prototype.createVideoClone=function(A){var e=A.ownerDocument.createElement("canvas");e.width=A.offsetWidth,e.height=A.offsetHeight;var t=e.getContext("2d");try{return t&&(t.drawImage(A,0,0,e.width,e.height),this.options.allowTaint||t.getImageData(0,0,e.width,e.height)),e}catch(e){this.context.logger.info("Unable to clone video as it is tainted",A)}var n=A.ownerDocument.createElement("canvas");return n.width=A.offsetWidth,n.height=A.offsetHeight,n},A.prototype.appendChildNode=function(A,e,t){Ho(e)&&("SCRIPT"===e.tagName||e.hasAttribute(ar)||"function"==typeof this.options.ignoreElements&&this.options.ignoreElements(e))||this.options.copyStyles&&Ho(e)&&No(e)||A.appendChild(this.cloneNode(e,t))},A.prototype.cloneChildNodes=function(A,e,t){for(var n=this,o=A.shadowRoot?A.shadowRoot.firstChild:A.firstChild;o;o=o.nextSibling)if(Ho(o)&&Wo(o)&&"function"==typeof o.assignedNodes){var r=o.assignedNodes();r.length&&r.forEach(function(A){return n.appendChildNode(e,A,t)})}else this.appendChildNode(e,o,t)},A.prototype.cloneNode=function(A,e){if(Io(A))return document.createTextNode(A.data);if(!A.ownerDocument)return A.cloneNode(!1);var t=A.ownerDocument.defaultView;if(t&&Ho(A)&&(So(A)||Do(A))){var n=this.createElementClone(A);n.style.transitionProperty="none";var o=t.getComputedStyle(A),r=t.getComputedStyle(A,":before"),i=t.getComputedStyle(A,":after");this.referenceElement===A&&So(n)&&(this.clonedReferenceElement=n),Po(n)&&Fr(n);var s=this.counters.parse(new Fn(this.context,o)),a=this.resolvePseudoContent(A,n,r,kn.BEFORE);Jo(A)&&(e=!0),Oo(A)||this.cloneChildNodes(A,n,e),a&&n.insertBefore(a,n.firstChild);var c=this.resolvePseudoContent(A,n,i,kn.AFTER);return c&&n.appendChild(c),this.counters.pop(s),(o&&(this.options.copyStyles||Do(A))&&!Vo(A)||e)&&pr(o,n),0===A.scrollTop&&0===A.scrollLeft||this.scrolledElements.push([n,A.scrollLeft,A.scrollTop]),(Go(A)||_o(A))&&(Go(n)||_o(n))&&(n.value=A.value),n}return A.cloneNode(!1)},A.prototype.resolvePseudoContent=function(A,e,t,n){var o=this;if(t){var r=t.content,i=e.ownerDocument;if(i&&r&&"none"!==r&&"-moz-alt-content"!==r&&"none"!==t.display){this.counters.parse(new Fn(this.context,t));var s=new Qn(this.context,t),a=i.createElement("html2canvaspseudoelement");pr(t,a),s.content.forEach(function(e){if(0===e.type)a.appendChild(i.createTextNode(e.value));else if(22===e.type){var t=i.createElement("img");t.src=e.value,t.style.opacity="1",a.appendChild(t)}else if(18===e.type){if("attr"===e.name){var n=e.values.filter(WA);n.length&&a.appendChild(i.createTextNode(A.getAttribute(n[0].value)||""))}else if("counter"===e.name){var r=e.values.filter(zA),c=r[0],l=r[1];if(c&&WA(c)){var d=o.counters.getCounterValue(c.value),u=l&&WA(l)?It.parse(o.context,l.value):3;a.appendChild(i.createTextNode(sr(d,u,!1)))}}else if("counters"===e.name){var g=e.values.filter(zA),B=(c=g[0],g[1]);if(l=g[2],c&&WA(c)){var h=o.counters.getCounterValues(c.value),p=l&&WA(l)?It.parse(o.context,l.value):3,w=B&&0===B.type?B.value:"",f=h.map(function(A){return sr(A,p,!1)}).join(w);a.appendChild(i.createTextNode(f))}}}else if(20===e.type)switch(e.value){case"open-quote":a.appendChild(i.createTextNode(pn(s.quotes,o.quoteDepth++,!0)));break;case"close-quote":a.appendChild(i.createTextNode(pn(s.quotes,--o.quoteDepth,!1)));break;default:a.appendChild(i.createTextNode(e.value))}}),a.className=mr+" "+vr;var c=n===kn.BEFORE?" "+mr:" "+vr;return Do(e)?e.className.baseValue+=c:e.className+=c,a}}},A.destroy=function(A){return!!A.parentNode&&(A.parentNode.removeChild(A),!0)},A}();!function(A){A[A.BEFORE=0]="BEFORE",A[A.AFTER=1]="AFTER"}(kn||(kn={}));var lr,dr=function(A,e){var t=A.createElement("iframe");return t.className="html2canvas-container",t.style.visibility="hidden",t.style.position="fixed",t.style.left="-10000px",t.style.top="0px",t.style.border="0",t.width=e.width.toString(),t.height=e.height.toString(),t.scrolling="no",t.setAttribute(ar,"true"),A.body.appendChild(t),t},ur=function(A){return new Promise(function(e){A.complete?e():A.src?(A.onload=e,A.onerror=e):e()})},gr=function(A){return Promise.all([].slice.call(A.images,0).map(ur))},Br=function(A){return new Promise(function(e,t){var n=A.contentWindow;if(!n)return t("No window assigned for iframe");var o=n.document;n.onload=A.onload=function(){n.onload=A.onload=null;var t=setInterval(function(){o.body.childNodes.length>0&&"complete"===o.readyState&&(clearInterval(t),e(A))},50)}})},hr=["all","d","content"],pr=function(A,e){for(var t=A.length-1;t>=0;t--){var n=A.item(t);-1===hr.indexOf(n)&&e.style.setProperty(n,A.getPropertyValue(n))}return e},wr=function(A){var e="";return A&&(e+="<!DOCTYPE ",A.name&&(e+=A.name),A.internalSubset&&(e+=A.internalSubset),A.publicId&&(e+='"'+A.publicId+'"'),A.systemId&&(e+='"'+A.systemId+'"'),e+=">"),e},fr=function(A,e,t){A&&A.defaultView&&(e!==A.defaultView.pageXOffset||t!==A.defaultView.pageYOffset)&&A.defaultView.scrollTo(e,t)},Cr=function(A){var e=A[0],t=A[1],n=A[2];e.scrollLeft=t,e.scrollTop=n},mr="___html2canvas___pseudoelement_before",vr="___html2canvas___pseudoelement_after",Qr='{\n content: "" !important;\n display: none !important;\n}',Fr=function(A){Ur(A,"."+mr+":before"+Qr+"\n ."+vr+":after"+Qr)},Ur=function(A,e){var t=A.ownerDocument;if(t){var n=t.createElement("style");n.textContent=e,A.appendChild(n)}},yr=function(){function A(){}return A.getOrigin=function(e){var t=A._link;return t?(t.href=e,t.href=t.href,t.protocol+t.hostname+t.port):"about:blank"},A.isSameOrigin=function(e){return A.getOrigin(e)===A._origin},A.setContext=function(e){A._link=e.document.createElement("a"),A._origin=A.getOrigin(e.location.href)},A._origin="about:blank",A}(),br=function(){function A(A,e){this.context=A,this._options=e,this._cache={}}return A.prototype.addImage=function(A){var e=Promise.resolve();return this.has(A)?e:Kr(A)||Hr(A)?((this._cache[A]=this.loadImage(A)).catch(function(){}),e):e},A.prototype.match=function(A){return this._cache[A]},A.prototype.loadImage=function(A){return n(this,void 0,void 0,function(){var e,t,n,r,i=this;return o(this,function(o){switch(o.label){case 0:return e=yr.isSameOrigin(A),t=!Sr(A)&&!0===this._options.useCORS&&zn.SUPPORT_CORS_IMAGES&&!e,n=!Sr(A)&&!e&&!Kr(A)&&"string"==typeof this._options.proxy&&zn.SUPPORT_CORS_XHR&&!t,e||!1!==this._options.allowTaint||Sr(A)||Kr(A)||n||t?(r=A,n?[4,this.proxy(r)]:[3,2]):[2];case 1:r=o.sent(),o.label=2;case 2:return this.context.logger.debug("Added image "+A.substring(0,256)),[4,new Promise(function(A,e){var n=new Image;n.onload=function(){return A(n)},n.onerror=e,(Dr(r)||t)&&(n.crossOrigin="anonymous"),n.src=r,!0===n.complete&&setTimeout(function(){return A(n)},500),i._options.imageTimeout>0&&setTimeout(function(){return e("Timed out ("+i._options.imageTimeout+"ms) loading image")},i._options.imageTimeout)})];case 3:return[2,o.sent()]}})})},A.prototype.has=function(A){return void 0!==this._cache[A]},A.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},A.prototype.proxy=function(A){var e=this,t=this._options.proxy;if(!t)throw new Error("No proxy defined");var n=A.substring(0,256);return new Promise(function(o,r){var i=zn.SUPPORT_RESPONSE_TYPE?"blob":"text",s=new XMLHttpRequest;s.onload=function(){if(200===s.status)if("text"===i)o(s.response);else{var A=new FileReader;A.addEventListener("load",function(){return o(A.result)},!1),A.addEventListener("error",function(A){return r(A)},!1),A.readAsDataURL(s.response)}else r("Failed to proxy resource "+n+" with status code "+s.status)},s.onerror=r;var a=t.indexOf("?")>-1?"&":"?";if(s.open("GET",""+t+a+"url="+encodeURIComponent(A)+"&responseType="+i),"text"!==i&&s instanceof XMLHttpRequest&&(s.responseType=i),e._options.imageTimeout){var c=e._options.imageTimeout;s.timeout=c,s.ontimeout=function(){return r("Timed out ("+c+"ms) proxying "+n)}}s.send()})},A}(),Er=/^data:image\/svg\+xml/i,xr=/^data:image\/.*;base64,/i,Ir=/^data:image\/.*/i,Hr=function(A){return zn.SUPPORT_SVG_DRAWING||!Tr(A)},Sr=function(A){return Ir.test(A)},Dr=function(A){return xr.test(A)},Kr=function(A){return"blob"===A.substr(0,4)},Tr=function(A){return"svg"===A.substr(-3).toLowerCase()||Er.test(A)},kr=function(){function A(A,e){this.type=0,this.x=A,this.y=e}return A.prototype.add=function(e,t){return new A(this.x+e,this.y+t)},A}(),Lr=function(A,e,t){return new kr(A.x+(e.x-A.x)*t,A.y+(e.y-A.y)*t)},Pr=function(){function A(A,e,t,n){this.type=1,this.start=A,this.startControl=e,this.endControl=t,this.end=n}return A.prototype.subdivide=function(e,t){var n=Lr(this.start,this.startControl,e),o=Lr(this.startControl,this.endControl,e),r=Lr(this.endControl,this.end,e),i=Lr(n,o,e),s=Lr(o,r,e),a=Lr(i,s,e);return t?new A(this.start,n,i,a):new A(a,s,r,this.end)},A.prototype.add=function(e,t){return new A(this.start.add(e,t),this.startControl.add(e,t),this.endControl.add(e,t),this.end.add(e,t))},A.prototype.reverse=function(){return new A(this.end,this.endControl,this.startControl,this.start)},A}(),Rr=function(A){return 1===A.type},Or=function(A){var e=A.styles,t=A.bounds,n=oe(e.borderTopLeftRadius,t.width,t.height),o=n[0],r=n[1],i=oe(e.borderTopRightRadius,t.width,t.height),s=i[0],a=i[1],c=oe(e.borderBottomRightRadius,t.width,t.height),l=c[0],d=c[1],u=oe(e.borderBottomLeftRadius,t.width,t.height),g=u[0],B=u[1],h=[];h.push((o+s)/t.width),h.push((g+l)/t.width),h.push((r+B)/t.height),h.push((a+d)/t.height);var p=Math.max.apply(Math,h);p>1&&(o/=p,r/=p,s/=p,a/=p,l/=p,d/=p,g/=p,B/=p);var w=t.width-s,f=t.height-d,C=t.width-l,m=t.height-B,v=e.borderTopWidth,Q=e.borderRightWidth,F=e.borderBottomWidth,U=e.borderLeftWidth,y=re(e.paddingTop,A.bounds.width),b=re(e.paddingRight,A.bounds.width),E=re(e.paddingBottom,A.bounds.width),x=re(e.paddingLeft,A.bounds.width);this.topLeftBorderDoubleOuterBox=o>0||r>0?Mr(t.left+U/3,t.top+v/3,o-U/3,r-v/3,lr.TOP_LEFT):new kr(t.left+U/3,t.top+v/3),this.topRightBorderDoubleOuterBox=o>0||r>0?Mr(t.left+w,t.top+v/3,s-Q/3,a-v/3,lr.TOP_RIGHT):new kr(t.left+t.width-Q/3,t.top+v/3),this.bottomRightBorderDoubleOuterBox=l>0||d>0?Mr(t.left+C,t.top+f,l-Q/3,d-F/3,lr.BOTTOM_RIGHT):new kr(t.left+t.width-Q/3,t.top+t.height-F/3),this.bottomLeftBorderDoubleOuterBox=g>0||B>0?Mr(t.left+U/3,t.top+m,g-U/3,B-F/3,lr.BOTTOM_LEFT):new kr(t.left+U/3,t.top+t.height-F/3),this.topLeftBorderDoubleInnerBox=o>0||r>0?Mr(t.left+2*U/3,t.top+2*v/3,o-2*U/3,r-2*v/3,lr.TOP_LEFT):new kr(t.left+2*U/3,t.top+2*v/3),this.topRightBorderDoubleInnerBox=o>0||r>0?Mr(t.left+w,t.top+2*v/3,s-2*Q/3,a-2*v/3,lr.TOP_RIGHT):new kr(t.left+t.width-2*Q/3,t.top+2*v/3),this.bottomRightBorderDoubleInnerBox=l>0||d>0?Mr(t.left+C,t.top+f,l-2*Q/3,d-2*F/3,lr.BOTTOM_RIGHT):new kr(t.left+t.width-2*Q/3,t.top+t.height-2*F/3),this.bottomLeftBorderDoubleInnerBox=g>0||B>0?Mr(t.left+2*U/3,t.top+m,g-2*U/3,B-2*F/3,lr.BOTTOM_LEFT):new kr(t.left+2*U/3,t.top+t.height-2*F/3),this.topLeftBorderStroke=o>0||r>0?Mr(t.left+U/2,t.top+v/2,o-U/2,r-v/2,lr.TOP_LEFT):new kr(t.left+U/2,t.top+v/2),this.topRightBorderStroke=o>0||r>0?Mr(t.left+w,t.top+v/2,s-Q/2,a-v/2,lr.TOP_RIGHT):new kr(t.left+t.width-Q/2,t.top+v/2),this.bottomRightBorderStroke=l>0||d>0?Mr(t.left+C,t.top+f,l-Q/2,d-F/2,lr.BOTTOM_RIGHT):new kr(t.left+t.width-Q/2,t.top+t.height-F/2),this.bottomLeftBorderStroke=g>0||B>0?Mr(t.left+U/2,t.top+m,g-U/2,B-F/2,lr.BOTTOM_LEFT):new kr(t.left+U/2,t.top+t.height-F/2),this.topLeftBorderBox=o>0||r>0?Mr(t.left,t.top,o,r,lr.TOP_LEFT):new kr(t.left,t.top),this.topRightBorderBox=s>0||a>0?Mr(t.left+w,t.top,s,a,lr.TOP_RIGHT):new kr(t.left+t.width,t.top),this.bottomRightBorderBox=l>0||d>0?Mr(t.left+C,t.top+f,l,d,lr.BOTTOM_RIGHT):new kr(t.left+t.width,t.top+t.height),this.bottomLeftBorderBox=g>0||B>0?Mr(t.left,t.top+m,g,B,lr.BOTTOM_LEFT):new kr(t.left,t.top+t.height),this.topLeftPaddingBox=o>0||r>0?Mr(t.left+U,t.top+v,Math.max(0,o-U),Math.max(0,r-v),lr.TOP_LEFT):new kr(t.left+U,t.top+v),this.topRightPaddingBox=s>0||a>0?Mr(t.left+Math.min(w,t.width-Q),t.top+v,w>t.width+Q?0:Math.max(0,s-Q),Math.max(0,a-v),lr.TOP_RIGHT):new kr(t.left+t.width-Q,t.top+v),this.bottomRightPaddingBox=l>0||d>0?Mr(t.left+Math.min(C,t.width-U),t.top+Math.min(f,t.height-F),Math.max(0,l-Q),Math.max(0,d-F),lr.BOTTOM_RIGHT):new kr(t.left+t.width-Q,t.top+t.height-F),this.bottomLeftPaddingBox=g>0||B>0?Mr(t.left+U,t.top+Math.min(m,t.height-F),Math.max(0,g-U),Math.max(0,B-F),lr.BOTTOM_LEFT):new kr(t.left+U,t.top+t.height-F),this.topLeftContentBox=o>0||r>0?Mr(t.left+U+x,t.top+v+y,Math.max(0,o-(U+x)),Math.max(0,r-(v+y)),lr.TOP_LEFT):new kr(t.left+U+x,t.top+v+y),this.topRightContentBox=s>0||a>0?Mr(t.left+Math.min(w,t.width+U+x),t.top+v+y,w>t.width+U+x?0:s-U+x,a-(v+y),lr.TOP_RIGHT):new kr(t.left+t.width-(Q+b),t.top+v+y),this.bottomRightContentBox=l>0||d>0?Mr(t.left+Math.min(C,t.width-(U+x)),t.top+Math.min(f,t.height+v+y),Math.max(0,l-(Q+b)),d-(F+E),lr.BOTTOM_RIGHT):new kr(t.left+t.width-(Q+b),t.top+t.height-(F+E)),this.bottomLeftContentBox=g>0||B>0?Mr(t.left+U+x,t.top+m,Math.max(0,g-(U+x)),B-(F+E),lr.BOTTOM_LEFT):new kr(t.left+U+x,t.top+t.height-(F+E))};!function(A){A[A.TOP_LEFT=0]="TOP_LEFT",A[A.TOP_RIGHT=1]="TOP_RIGHT",A[A.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",A[A.BOTTOM_LEFT=3]="BOTTOM_LEFT"}(lr||(lr={}));var Mr=function(A,e,t,n,o){var r=(Math.sqrt(2)-1)/3*4,i=t*r,s=n*r,a=A+t,c=e+n;switch(o){case lr.TOP_LEFT:return new Pr(new kr(A,c),new kr(A,c-s),new kr(a-i,e),new kr(a,e));case lr.TOP_RIGHT:return new Pr(new kr(A,e),new kr(A+i,e),new kr(a,c-s),new kr(a,c));case lr.BOTTOM_RIGHT:return new Pr(new kr(a,e),new kr(a,e+s),new kr(A+i,c),new kr(A,c));case lr.BOTTOM_LEFT:default:return new Pr(new kr(a,c),new kr(a-i,c),new kr(A,e+s),new kr(A,e))}},Vr=function(A){return[A.topLeftBorderBox,A.topRightBorderBox,A.bottomRightBorderBox,A.bottomLeftBorderBox]},Nr=function(A){return[A.topLeftPaddingBox,A.topRightPaddingBox,A.bottomRightPaddingBox,A.bottomLeftPaddingBox]},Gr=function(A,e,t){this.offsetX=A,this.offsetY=e,this.matrix=t,this.type=0,this.target=6},_r=function(A,e){this.path=A,this.target=e,this.type=1},Wr=function(A){this.opacity=A,this.type=2,this.target=6},Jr=function(A){return 1===A.type},Xr=function(A,e){return A.length===e.length&&A.some(function(A,t){return A===e[t]})},Yr=function(A){this.element=A,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]},zr=function(){function A(A,e){if(this.container=A,this.parent=e,this.effects=[],this.curves=new Or(this.container),this.container.styles.opacity<1&&this.effects.push(new Wr(this.container.styles.opacity)),null!==this.container.styles.transform){var t=this.container.bounds.left+this.container.styles.transformOrigin[0].number,n=this.container.bounds.top+this.container.styles.transformOrigin[1].number,o=this.container.styles.transform;this.effects.push(new Gr(t,n,o))}if(0!==this.container.styles.overflowX){var r=Vr(this.curves),i=Nr(this.curves);Xr(r,i)?this.effects.push(new _r(r,6)):(this.effects.push(new _r(r,2)),this.effects.push(new _r(i,4)))}}return A.prototype.getEffects=function(A){for(var e=-1===[2,3].indexOf(this.container.styles.position),t=this.parent,n=this.effects.slice(0);t;){var o=t.effects.filter(function(A){return!Jr(A)});if(e||0!==t.container.styles.position||!t.parent){if(n.unshift.apply(n,o),e=-1===[2,3].indexOf(t.container.styles.position),0!==t.container.styles.overflowX){var r=Vr(t.curves),i=Nr(t.curves);Xr(r,i)||n.unshift(new _r(i,6))}}else n.unshift.apply(n,o);t=t.parent}return n.filter(function(e){return ln(e.target,A)})},A}(),jr=function(A,e,t,n){A.container.elements.forEach(function(o){var r=ln(o.flags,4),i=ln(o.flags,2),s=new zr(o,A);ln(o.styles.display,2048)&&n.push(s);var a=ln(o.flags,8)?[]:n;if(r||i){var c=r||o.styles.isPositioned()?t:e,l=new Yr(s);if(o.styles.isPositioned()||o.styles.opacity<1||o.styles.isTransformed()){var d=o.styles.zIndex.order;if(d<0){var u=0;c.negativeZIndex.some(function(A,e){return d>A.element.container.styles.zIndex.order?(u=e,!1):u>0}),c.negativeZIndex.splice(u,0,l)}else if(d>0){var g=0;c.positiveZIndex.some(function(A,e){return d>=A.element.container.styles.zIndex.order?(g=e+1,!1):g>0}),c.positiveZIndex.splice(g,0,l)}else c.zeroOrAutoZIndexOrTransformedOrOpacity.push(l)}else o.styles.isFloating()?c.nonPositionedFloats.push(l):c.nonPositionedInlineLevel.push(l);jr(s,l,r?l:t,a)}else o.styles.isInlineLevel()?e.inlineLevel.push(s):e.nonInlineLevel.push(s),jr(s,e,t,a);ln(o.flags,8)&&Zr(o,a)})},Zr=function(A,e){for(var t=A instanceof uo?A.start:1,n=A instanceof uo&&A.reversed,o=0;o<e.length;o++){var r=e[o];r.container instanceof lo&&"number"==typeof r.container.value&&0!==r.container.value&&(t=r.container.value),r.listValue=sr(t,r.container.styles.listStyleType,!0),t+=n?-1:1}},qr=function(A,e){switch(e){case 0:return Ai(A.topLeftBorderBox,A.topLeftPaddingBox,A.topRightBorderBox,A.topRightPaddingBox);case 1:return Ai(A.topRightBorderBox,A.topRightPaddingBox,A.bottomRightBorderBox,A.bottomRightPaddingBox);case 2:return Ai(A.bottomRightBorderBox,A.bottomRightPaddingBox,A.bottomLeftBorderBox,A.bottomLeftPaddingBox);default:return Ai(A.bottomLeftBorderBox,A.bottomLeftPaddingBox,A.topLeftBorderBox,A.topLeftPaddingBox)}},$r=function(A,e){var t=[];return Rr(A)?t.push(A.subdivide(.5,!1)):t.push(A),Rr(e)?t.push(e.subdivide(.5,!0)):t.push(e),t},Ai=function(A,e,t,n){var o=[];return Rr(A)?o.push(A.subdivide(.5,!1)):o.push(A),Rr(t)?o.push(t.subdivide(.5,!0)):o.push(t),Rr(n)?o.push(n.subdivide(.5,!0).reverse()):o.push(n),Rr(e)?o.push(e.subdivide(.5,!1).reverse()):o.push(e),o},ei=function(A){var e=A.bounds,t=A.styles;return e.add(t.borderLeftWidth,t.borderTopWidth,-(t.borderRightWidth+t.borderLeftWidth),-(t.borderTopWidth+t.borderBottomWidth))},ti=function(A){var e=A.styles,t=A.bounds,n=re(e.paddingLeft,t.width),o=re(e.paddingRight,t.width),r=re(e.paddingTop,t.width),i=re(e.paddingBottom,t.width);return t.add(n+e.borderLeftWidth,r+e.borderTopWidth,-(e.borderRightWidth+e.borderLeftWidth+n+o),-(e.borderTopWidth+e.borderBottomWidth+r+i))},ni=function(A,e,t){var n=function(A,e){return 0===A?e.bounds:2===A?ti(e):ei(e)}(si(A.styles.backgroundOrigin,e),A),o=function(A,e){return 0===A?e.bounds:2===A?ti(e):ei(e)}(si(A.styles.backgroundClip,e),A),r=ii(si(A.styles.backgroundSize,e),t,n),i=r[0],s=r[1],a=oe(si(A.styles.backgroundPosition,e),n.width-i,n.height-s);return[ai(si(A.styles.backgroundRepeat,e),a,r,n,o),Math.round(n.left+a[0]),Math.round(n.top+a[1]),i,s]},oi=function(A){return WA(A)&&A.value===Ve.AUTO},ri=function(A){return"number"==typeof A},ii=function(A,e,t){var n=e[0],o=e[1],r=e[2],i=A[0],s=A[1];if(!i)return[0,0];if($A(i)&&s&&$A(s))return[re(i,t.width),re(s,t.height)];var a=ri(r);if(WA(i)&&(i.value===Ve.CONTAIN||i.value===Ve.COVER))return ri(r)?t.width/t.height<r!=(i.value===Ve.COVER)?[t.width,t.width/r]:[t.height*r,t.height]:[t.width,t.height];var c=ri(n),l=ri(o),d=c||l;if(oi(i)&&(!s||oi(s)))return c&&l?[n,o]:a||d?d&&a?[c?n:o*r,l?o:n/r]:[c?n:t.width,l?o:t.height]:[t.width,t.height];if(a){var u=0,g=0;return $A(i)?u=re(i,t.width):$A(s)&&(g=re(s,t.height)),oi(i)?u=g*r:s&&!oi(s)||(g=u/r),[u,g]}var B=null,h=null;if($A(i)?B=re(i,t.width):s&&$A(s)&&(h=re(s,t.height)),null===B||s&&!oi(s)||(h=c&&l?B/n*o:t.height),null!==h&&oi(i)&&(B=c&&l?h/o*n:t.width),null!==B&&null!==h)return[B,h];throw new Error("Unable to calculate background-size for element")},si=function(A,e){var t=A[e];return void 0===t?A[0]:t},ai=function(A,e,t,n,o){var r=e[0],i=e[1],s=t[0],a=t[1];switch(A){case 2:return[new kr(Math.round(n.left),Math.round(n.top+i)),new kr(Math.round(n.left+n.width),Math.round(n.top+i)),new kr(Math.round(n.left+n.width),Math.round(a+n.top+i)),new kr(Math.round(n.left),Math.round(a+n.top+i))];case 3:return[new kr(Math.round(n.left+r),Math.round(n.top)),new kr(Math.round(n.left+r+s),Math.round(n.top)),new kr(Math.round(n.left+r+s),Math.round(n.height+n.top)),new kr(Math.round(n.left+r),Math.round(n.height+n.top))];case 1:return[new kr(Math.round(n.left+r),Math.round(n.top+i)),new kr(Math.round(n.left+r+s),Math.round(n.top+i)),new kr(Math.round(n.left+r+s),Math.round(n.top+i+a)),new kr(Math.round(n.left+r),Math.round(n.top+i+a))];default:return[new kr(Math.round(o.left),Math.round(o.top)),new kr(Math.round(o.left+o.width),Math.round(o.top)),new kr(Math.round(o.left+o.width),Math.round(o.height+o.top)),new kr(Math.round(o.left),Math.round(o.height+o.top))]}},ci="Hidden Text",li=function(){function A(A){this._data={},this._document=A}return A.prototype.parseMetrics=function(A,e){var t=this._document.createElement("div"),n=this._document.createElement("img"),o=this._document.createElement("span"),r=this._document.body;t.style.visibility="hidden",t.style.fontFamily=A,t.style.fontSize=e,t.style.margin="0",t.style.padding="0",t.style.whiteSpace="nowrap",r.appendChild(t),n.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",n.width=1,n.height=1,n.style.margin="0",n.style.padding="0",n.style.verticalAlign="baseline",o.style.fontFamily=A,o.style.fontSize=e,o.style.margin="0",o.style.padding="0",o.appendChild(this._document.createTextNode(ci)),t.appendChild(o),t.appendChild(n);var i=n.offsetTop-o.offsetTop+2;t.removeChild(o),t.appendChild(this._document.createTextNode(ci)),t.style.lineHeight="normal",n.style.verticalAlign="super";var s=n.offsetTop-t.offsetTop+2;return r.removeChild(t),{baseline:i,middle:s}},A.prototype.getMetrics=function(A,e){var t=A+" "+e;return void 0===this._data[t]&&(this._data[t]=this.parseMetrics(A,e)),this._data[t]},A}(),di=function(A,e){this.context=A,this.options=e},ui=function(A){function t(e,t){var n=A.call(this,e,t)||this;return n._activeEffects=[],n.canvas=t.canvas?t.canvas:document.createElement("canvas"),n.ctx=n.canvas.getContext("2d"),t.canvas||(n.canvas.width=Math.floor(t.width*t.scale),n.canvas.height=Math.floor(t.height*t.scale),n.canvas.style.width=t.width+"px",n.canvas.style.height=t.height+"px"),n.fontMetrics=new li(document),n.ctx.scale(n.options.scale,n.options.scale),n.ctx.translate(-t.x,-t.y),n.ctx.textBaseline="bottom",n._activeEffects=[],n.context.logger.debug("Canvas renderer initialized ("+t.width+"x"+t.height+") with scale "+t.scale),n}return e(t,A),t.prototype.applyEffects=function(A){for(var e=this;this._activeEffects.length;)this.popEffect();A.forEach(function(A){return e.applyEffect(A)})},t.prototype.applyEffect=function(A){this.ctx.save(),function(A){return 2===A.type}(A)&&(this.ctx.globalAlpha=A.opacity),function(A){return 0===A.type}(A)&&(this.ctx.translate(A.offsetX,A.offsetY),this.ctx.transform(A.matrix[0],A.matrix[1],A.matrix[2],A.matrix[3],A.matrix[4],A.matrix[5]),this.ctx.translate(-A.offsetX,-A.offsetY)),Jr(A)&&(this.path(A.path),this.ctx.clip()),this._activeEffects.push(A)},t.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},t.prototype.renderStack=function(A){return n(this,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return A.element.container.styles.isVisible()?[4,this.renderStackContent(A)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})},t.prototype.renderNode=function(A){return n(this,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return ln(A.container.flags,16),A.container.styles.isVisible()?[4,this.renderNodeBackgroundAndBorders(A)]:[3,3];case 1:return e.sent(),[4,this.renderNodeContent(A)];case 2:e.sent(),e.label=3;case 3:return[2]}})})},t.prototype.renderTextWithLetterSpacing=function(A,e,t){var n=this;0===e?this.ctx.fillText(A.text,A.bounds.left,A.bounds.top+t):$n(A.text).reduce(function(e,o){return n.ctx.fillText(o,e,A.bounds.top+t),e+n.ctx.measureText(o).width},A.bounds.left)},t.prototype.createFontStyle=function(A){var e=A.fontVariant.filter(function(A){return"normal"===A||"small-caps"===A}).join(""),t=wi(A.fontFamily).join(", "),n=GA(A.fontSize)?""+A.fontSize.number+A.fontSize.unit:A.fontSize.number+"px";return[[A.fontStyle,e,A.fontWeight,n,t].join(" "),t,n]},t.prototype.renderTextNode=function(A,e){return n(this,void 0,void 0,function(){var t,n,r,i,s,a,c,l,d=this;return o(this,function(o){return t=this.createFontStyle(e),n=t[0],r=t[1],i=t[2],this.ctx.font=n,this.ctx.direction=1===e.direction?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",s=this.fontMetrics.getMetrics(r,i),a=s.baseline,c=s.middle,l=e.paintOrder,A.textBounds.forEach(function(A){l.forEach(function(t){switch(t){case 0:d.ctx.fillStyle=Be(e.color),d.renderTextWithLetterSpacing(A,e.letterSpacing,a);var n=e.textShadow;n.length&&A.text.trim().length&&(n.slice(0).reverse().forEach(function(t){d.ctx.shadowColor=Be(t.color),d.ctx.shadowOffsetX=t.offsetX.number*d.options.scale,d.ctx.shadowOffsetY=t.offsetY.number*d.options.scale,d.ctx.shadowBlur=t.blur.number,d.renderTextWithLetterSpacing(A,e.letterSpacing,a)}),d.ctx.shadowColor="",d.ctx.shadowOffsetX=0,d.ctx.shadowOffsetY=0,d.ctx.shadowBlur=0),e.textDecorationLine.length&&(d.ctx.fillStyle=Be(e.textDecorationColor||e.color),e.textDecorationLine.forEach(function(e){switch(e){case 1:d.ctx.fillRect(A.bounds.left,Math.round(A.bounds.top+a),A.bounds.width,1);break;case 2:d.ctx.fillRect(A.bounds.left,Math.round(A.bounds.top),A.bounds.width,1);break;case 3:d.ctx.fillRect(A.bounds.left,Math.ceil(A.bounds.top+c),A.bounds.width,1)}}));break;case 1:e.webkitTextStrokeWidth&&A.text.trim().length&&(d.ctx.strokeStyle=Be(e.webkitTextStrokeColor),d.ctx.lineWidth=e.webkitTextStrokeWidth,d.ctx.lineJoin=window.chrome?"miter":"round",d.ctx.strokeText(A.text,A.bounds.left,A.bounds.top+a)),d.ctx.strokeStyle="",d.ctx.lineWidth=0,d.ctx.lineJoin="miter"}})}),[2]})})},t.prototype.renderReplacedElement=function(A,e,t){if(t&&A.intrinsicWidth>0&&A.intrinsicHeight>0){var n=ti(A),o=Nr(e);this.path(o),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(t,0,0,A.intrinsicWidth,A.intrinsicHeight,n.left,n.top,n.width,n.height),this.ctx.restore()}},t.prototype.renderNodeContent=function(A){return n(this,void 0,void 0,function(){var e,n,r,s,a,c,l,d,u,g,B,h,p,w,f,C,m,v;return o(this,function(o){switch(o.label){case 0:this.applyEffects(A.getEffects(4)),e=A.container,n=A.curves,r=e.styles,s=0,a=e.textNodes,o.label=1;case 1:return s<a.length?(c=a[s],[4,this.renderTextNode(c,r)]):[3,4];case 2:o.sent(),o.label=3;case 3:return s++,[3,1];case 4:if(!(e instanceof so))return[3,8];o.label=5;case 5:return o.trys.push([5,7,,8]),[4,this.context.cache.match(e.src)];case 6:return f=o.sent(),this.renderReplacedElement(e,n,f),[3,8];case 7:return o.sent(),this.context.logger.error("Error loading image "+e.src),[3,8];case 8:if(e instanceof ao&&this.renderReplacedElement(e,n,e.canvas),!(e instanceof co))return[3,12];o.label=9;case 9:return o.trys.push([9,11,,12]),[4,this.context.cache.match(e.svg)];case 10:return f=o.sent(),this.renderReplacedElement(e,n,f),[3,12];case 11:return o.sent(),this.context.logger.error("Error loading svg "+e.svg.substring(0,255)),[3,12];case 12:return e instanceof Qo&&e.tree?[4,new t(this.context,{scale:this.options.scale,backgroundColor:e.backgroundColor,x:0,y:0,width:e.width,height:e.height}).render(e.tree)]:[3,14];case 13:l=o.sent(),e.width&&e.height&&this.ctx.drawImage(l,0,0,e.width,e.height,e.bounds.left,e.bounds.top,e.bounds.width,e.bounds.height),o.label=14;case 14:if(e instanceof Co&&(d=Math.min(e.bounds.width,e.bounds.height),e.type===ho?e.checked&&(this.ctx.save(),this.path([new kr(e.bounds.left+.39363*d,e.bounds.top+.79*d),new kr(e.bounds.left+.16*d,e.bounds.top+.5549*d),new kr(e.bounds.left+.27347*d,e.bounds.top+.44071*d),new kr(e.bounds.left+.39694*d,e.bounds.top+.5649*d),new kr(e.bounds.left+.72983*d,e.bounds.top+.23*d),new kr(e.bounds.left+.84*d,e.bounds.top+.34085*d),new kr(e.bounds.left+.39363*d,e.bounds.top+.79*d)]),this.ctx.fillStyle=Be(fo),this.ctx.fill(),this.ctx.restore()):e.type===po&&e.checked&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(e.bounds.left+d/2,e.bounds.top+d/2,d/4,0,2*Math.PI,!0),this.ctx.fillStyle=Be(fo),this.ctx.fill(),this.ctx.restore())),gi(e)&&e.value.length){switch(u=this.createFontStyle(r),m=u[0],g=u[1],B=this.fontMetrics.getMetrics(m,g).baseline,this.ctx.font=m,this.ctx.fillStyle=Be(r.color),this.ctx.textBaseline="alphabetic",this.ctx.textAlign=hi(e.styles.textAlign),v=ti(e),h=0,e.styles.textAlign){case 1:h+=v.width/2;break;case 2:h+=v.width}p=v.add(h,0,0,-v.height/2+1),this.ctx.save(),this.path([new kr(v.left,v.top),new kr(v.left+v.width,v.top),new kr(v.left+v.width,v.top+v.height),new kr(v.left,v.top+v.height)]),this.ctx.clip(),this.renderTextWithLetterSpacing(new jn(e.value,p),r.letterSpacing,B),this.ctx.restore(),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left"}if(!ln(e.styles.display,2048))return[3,20];if(null===e.styles.listStyleImage)return[3,19];if(0!==(w=e.styles.listStyleImage).type)return[3,18];f=void 0,C=w.url,o.label=15;case 15:return o.trys.push([15,17,,18]),[4,this.context.cache.match(C)];case 16:return f=o.sent(),this.ctx.drawImage(f,e.bounds.left-(f.width+10),e.bounds.top),[3,18];case 17:return o.sent(),this.context.logger.error("Error loading list-style-image "+C),[3,18];case 18:return[3,20];case 19:A.listValue&&-1!==e.styles.listStyleType&&(m=this.createFontStyle(r)[0],this.ctx.font=m,this.ctx.fillStyle=Be(r.color),this.ctx.textBaseline="middle",this.ctx.textAlign="right",v=new i(e.bounds.left,e.bounds.top+re(e.styles.paddingTop,e.bounds.width),e.bounds.width,bt(r.lineHeight,r.fontSize.number)/2+1),this.renderTextWithLetterSpacing(new jn(A.listValue,v),r.letterSpacing,bt(r.lineHeight,r.fontSize.number)/2+2),this.ctx.textBaseline="bottom",this.ctx.textAlign="left"),o.label=20;case 20:return[2]}})})},t.prototype.renderStackContent=function(A){return n(this,void 0,void 0,function(){var e,t,n,r,i,s,a,c,l,d,u,g,B,h,p;return o(this,function(o){switch(o.label){case 0:return ln(A.element.container.flags,16),[4,this.renderNodeBackgroundAndBorders(A.element)];case 1:o.sent(),e=0,t=A.negativeZIndex,o.label=2;case 2:return e<t.length?(p=t[e],[4,this.renderStack(p)]):[3,5];case 3:o.sent(),o.label=4;case 4:return e++,[3,2];case 5:return[4,this.renderNodeContent(A.element)];case 6:o.sent(),n=0,r=A.nonInlineLevel,o.label=7;case 7:return n<r.length?(p=r[n],[4,this.renderNode(p)]):[3,10];case 8:o.sent(),o.label=9;case 9:return n++,[3,7];case 10:i=0,s=A.nonPositionedFloats,o.label=11;case 11:return i<s.length?(p=s[i],[4,this.renderStack(p)]):[3,14];case 12:o.sent(),o.label=13;case 13:return i++,[3,11];case 14:a=0,c=A.nonPositionedInlineLevel,o.label=15;case 15:return a<c.length?(p=c[a],[4,this.renderStack(p)]):[3,18];case 16:o.sent(),o.label=17;case 17:return a++,[3,15];case 18:l=0,d=A.inlineLevel,o.label=19;case 19:return l<d.length?(p=d[l],[4,this.renderNode(p)]):[3,22];case 20:o.sent(),o.label=21;case 21:return l++,[3,19];case 22:u=0,g=A.zeroOrAutoZIndexOrTransformedOrOpacity,o.label=23;case 23:return u<g.length?(p=g[u],[4,this.renderStack(p)]):[3,26];case 24:o.sent(),o.label=25;case 25:return u++,[3,23];case 26:B=0,h=A.positiveZIndex,o.label=27;case 27:return B<h.length?(p=h[B],[4,this.renderStack(p)]):[3,30];case 28:o.sent(),o.label=29;case 29:return B++,[3,27];case 30:return[2]}})})},t.prototype.mask=function(A){this.ctx.beginPath(),this.ctx.moveTo(0,0),this.ctx.lineTo(this.canvas.width,0),this.ctx.lineTo(this.canvas.width,this.canvas.height),this.ctx.lineTo(0,this.canvas.height),this.ctx.lineTo(0,0),this.formatPath(A.slice(0).reverse()),this.ctx.closePath()},t.prototype.path=function(A){this.ctx.beginPath(),this.formatPath(A),this.ctx.closePath()},t.prototype.formatPath=function(A){var e=this;A.forEach(function(A,t){var n=Rr(A)?A.start:A;0===t?e.ctx.moveTo(n.x,n.y):e.ctx.lineTo(n.x,n.y),Rr(A)&&e.ctx.bezierCurveTo(A.startControl.x,A.startControl.y,A.endControl.x,A.endControl.y,A.end.x,A.end.y)})},t.prototype.renderRepeat=function(A,e,t,n){this.path(A),this.ctx.fillStyle=e,this.ctx.translate(t,n),this.ctx.fill(),this.ctx.translate(-t,-n)},t.prototype.resizeImage=function(A,e,t){var n;if(A.width===e&&A.height===t)return A;var o=(null!==(n=this.canvas.ownerDocument)&&void 0!==n?n:document).createElement("canvas");return o.width=Math.max(1,e),o.height=Math.max(1,t),o.getContext("2d").drawImage(A,0,0,A.width,A.height,0,0,e,t),o},t.prototype.renderBackgroundImage=function(A){return n(this,void 0,void 0,function(){var e,t,n,r,i,s;return o(this,function(a){switch(a.label){case 0:e=A.styles.backgroundImage.length-1,t=function(t){var r,i,s,a,c,l,d,u,g,B,h,p,w,f,C,m,v,Q,F,U,y,b,E,x,I,H,S,D,K,T,k;return o(this,function(o){switch(o.label){case 0:if(0!==t.type)return[3,5];r=void 0,i=t.url,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,n.context.cache.match(i)];case 2:return r=o.sent(),[3,4];case 3:return o.sent(),n.context.logger.error("Error loading background-image "+i),[3,4];case 4:return r&&(s=ni(A,e,[r.width,r.height,r.width/r.height]),m=s[0],b=s[1],E=s[2],F=s[3],U=s[4],f=n.ctx.createPattern(n.resizeImage(r,F,U),"repeat"),n.renderRepeat(m,f,b,E)),[3,6];case 5:1===t.type?(a=ni(A,e,[null,null,null]),m=a[0],b=a[1],E=a[2],F=a[3],U=a[4],c=Ee(t.angle,F,U),l=c[0],d=c[1],u=c[2],g=c[3],B=c[4],(h=document.createElement("canvas")).width=F,h.height=U,p=h.getContext("2d"),w=p.createLinearGradient(d,g,u,B),be(t.stops,l).forEach(function(A){return w.addColorStop(A.stop,Be(A.color))}),p.fillStyle=w,p.fillRect(0,0,F,U),F>0&&U>0&&(f=n.ctx.createPattern(h,"repeat"),n.renderRepeat(m,f,b,E))):function(A){return 2===A.type}(t)&&(C=ni(A,e,[null,null,null]),m=C[0],v=C[1],Q=C[2],F=C[3],U=C[4],y=0===t.position.length?[te]:t.position,b=re(y[0],F),E=re(y[y.length-1],U),x=function(A,e,t,n,o){var r=0,i=0;switch(A.size){case 0:0===A.shape?r=i=Math.min(Math.abs(e),Math.abs(e-n),Math.abs(t),Math.abs(t-o)):1===A.shape&&(r=Math.min(Math.abs(e),Math.abs(e-n)),i=Math.min(Math.abs(t),Math.abs(t-o)));break;case 2:if(0===A.shape)r=i=Math.min(xe(e,t),xe(e,t-o),xe(e-n,t),xe(e-n,t-o));else if(1===A.shape){var s=Math.min(Math.abs(t),Math.abs(t-o))/Math.min(Math.abs(e),Math.abs(e-n)),a=Ie(n,o,e,t,!0),c=a[0],l=a[1];i=s*(r=xe(c-e,(l-t)/s))}break;case 1:0===A.shape?r=i=Math.max(Math.abs(e),Math.abs(e-n),Math.abs(t),Math.abs(t-o)):1===A.shape&&(r=Math.max(Math.abs(e),Math.abs(e-n)),i=Math.max(Math.abs(t),Math.abs(t-o)));break;case 3:if(0===A.shape)r=i=Math.max(xe(e,t),xe(e,t-o),xe(e-n,t),xe(e-n,t-o));else if(1===A.shape){s=Math.max(Math.abs(t),Math.abs(t-o))/Math.max(Math.abs(e),Math.abs(e-n));var d=Ie(n,o,e,t,!1);c=d[0],l=d[1],i=s*(r=xe(c-e,(l-t)/s))}}return Array.isArray(A.size)&&(r=re(A.size[0],n),i=2===A.size.length?re(A.size[1],o):r),[r,i]}(t,b,E,F,U),I=x[0],H=x[1],I>0&&H>0&&(S=n.ctx.createRadialGradient(v+b,Q+E,0,v+b,Q+E,I),be(t.stops,2*I).forEach(function(A){return S.addColorStop(A.stop,Be(A.color))}),n.path(m),n.ctx.fillStyle=S,I!==H?(D=A.bounds.left+.5*A.bounds.width,K=A.bounds.top+.5*A.bounds.height,k=1/(T=H/I),n.ctx.save(),n.ctx.translate(D,K),n.ctx.transform(1,0,0,T,0,0),n.ctx.translate(-D,-K),n.ctx.fillRect(v,k*(Q-K)+K,F,U*k),n.ctx.restore()):n.ctx.fill())),o.label=6;case 6:return e--,[2]}})},n=this,r=0,i=A.styles.backgroundImage.slice(0).reverse(),a.label=1;case 1:return r<i.length?(s=i[r],[5,t(s)]):[3,4];case 2:a.sent(),a.label=3;case 3:return r++,[3,1];case 4:return[2]}})})},t.prototype.renderSolidBorder=function(A,e,t){return n(this,void 0,void 0,function(){return o(this,function(n){return this.path(qr(t,e)),this.ctx.fillStyle=Be(A),this.ctx.fill(),[2]})})},t.prototype.renderDoubleBorder=function(A,e,t,r){return n(this,void 0,void 0,function(){var n,i;return o(this,function(o){switch(o.label){case 0:return e<3?[4,this.renderSolidBorder(A,t,r)]:[3,2];case 1:return o.sent(),[2];case 2:return n=function(A,e){switch(e){case 0:return Ai(A.topLeftBorderBox,A.topLeftBorderDoubleOuterBox,A.topRightBorderBox,A.topRightBorderDoubleOuterBox);case 1:return Ai(A.topRightBorderBox,A.topRightBorderDoubleOuterBox,A.bottomRightBorderBox,A.bottomRightBorderDoubleOuterBox);case 2:return Ai(A.bottomRightBorderBox,A.bottomRightBorderDoubleOuterBox,A.bottomLeftBorderBox,A.bottomLeftBorderDoubleOuterBox);default:return Ai(A.bottomLeftBorderBox,A.bottomLeftBorderDoubleOuterBox,A.topLeftBorderBox,A.topLeftBorderDoubleOuterBox)}}(r,t),this.path(n),this.ctx.fillStyle=Be(A),this.ctx.fill(),i=function(A,e){switch(e){case 0:return Ai(A.topLeftBorderDoubleInnerBox,A.topLeftPaddingBox,A.topRightBorderDoubleInnerBox,A.topRightPaddingBox);case 1:return Ai(A.topRightBorderDoubleInnerBox,A.topRightPaddingBox,A.bottomRightBorderDoubleInnerBox,A.bottomRightPaddingBox);case 2:return Ai(A.bottomRightBorderDoubleInnerBox,A.bottomRightPaddingBox,A.bottomLeftBorderDoubleInnerBox,A.bottomLeftPaddingBox);default:return Ai(A.bottomLeftBorderDoubleInnerBox,A.bottomLeftPaddingBox,A.topLeftBorderDoubleInnerBox,A.topLeftPaddingBox)}}(r,t),this.path(i),this.ctx.fill(),[2]}})})},t.prototype.renderNodeBackgroundAndBorders=function(A){return n(this,void 0,void 0,function(){var e,t,n,r,i,s,a,c,l=this;return o(this,function(o){switch(o.label){case 0:return this.applyEffects(A.getEffects(2)),e=A.container.styles,t=!ge(e.backgroundColor)||e.backgroundImage.length,n=[{style:e.borderTopStyle,color:e.borderTopColor,width:e.borderTopWidth},{style:e.borderRightStyle,color:e.borderRightColor,width:e.borderRightWidth},{style:e.borderBottomStyle,color:e.borderBottomColor,width:e.borderBottomWidth},{style:e.borderLeftStyle,color:e.borderLeftColor,width:e.borderLeftWidth}],r=Bi(si(e.backgroundClip,0),A.curves),t||e.boxShadow.length?(this.ctx.save(),this.path(r),this.ctx.clip(),ge(e.backgroundColor)||(this.ctx.fillStyle=Be(e.backgroundColor),this.ctx.fill()),[4,this.renderBackgroundImage(A.container)]):[3,2];case 1:o.sent(),this.ctx.restore(),e.boxShadow.slice(0).reverse().forEach(function(e){l.ctx.save();var t,n,o,r,i,s=Vr(A.curves),a=e.inset?0:1e4,c=(t=s,n=-a+(e.inset?1:-1)*e.spread.number,o=(e.inset?1:-1)*e.spread.number,r=e.spread.number*(e.inset?-2:2),i=e.spread.number*(e.inset?-2:2),t.map(function(A,e){switch(e){case 0:return A.add(n,o);case 1:return A.add(n+r,o);case 2:return A.add(n+r,o+i);case 3:return A.add(n,o+i)}return A}));e.inset?(l.path(s),l.ctx.clip(),l.mask(c)):(l.mask(s),l.ctx.clip(),l.path(c)),l.ctx.shadowOffsetX=e.offsetX.number+a,l.ctx.shadowOffsetY=e.offsetY.number,l.ctx.shadowColor=Be(e.color),l.ctx.shadowBlur=e.blur.number,l.ctx.fillStyle=e.inset?Be(e.color):"rgba(0,0,0,1)",l.ctx.fill(),l.ctx.restore()}),o.label=2;case 2:i=0,s=0,a=n,o.label=3;case 3:return s<a.length?0!==(c=a[s]).style&&!ge(c.color)&&c.width>0?2!==c.style?[3,5]:[4,this.renderDashedDottedBorder(c.color,c.width,i,A.curves,2)]:[3,11]:[3,13];case 4:return o.sent(),[3,11];case 5:return 3!==c.style?[3,7]:[4,this.renderDashedDottedBorder(c.color,c.width,i,A.curves,3)];case 6:return o.sent(),[3,11];case 7:return 4!==c.style?[3,9]:[4,this.renderDoubleBorder(c.color,c.width,i,A.curves)];case 8:return o.sent(),[3,11];case 9:return[4,this.renderSolidBorder(c.color,i,A.curves)];case 10:o.sent(),o.label=11;case 11:i++,o.label=12;case 12:return s++,[3,3];case 13:return[2]}})})},t.prototype.renderDashedDottedBorder=function(A,e,t,r,i){return n(this,void 0,void 0,function(){var n,s,a,c,l,d,u,g,B,h,p,w,f,C,m,v;return o(this,function(o){return this.ctx.save(),n=function(A,e){switch(e){case 0:return $r(A.topLeftBorderStroke,A.topRightBorderStroke);case 1:return $r(A.topRightBorderStroke,A.bottomRightBorderStroke);case 2:return $r(A.bottomRightBorderStroke,A.bottomLeftBorderStroke);default:return $r(A.bottomLeftBorderStroke,A.topLeftBorderStroke)}}(r,t),s=qr(r,t),2===i&&(this.path(s),this.ctx.clip()),Rr(s[0])?(a=s[0].start.x,c=s[0].start.y):(a=s[0].x,c=s[0].y),Rr(s[1])?(l=s[1].end.x,d=s[1].end.y):(l=s[1].x,d=s[1].y),u=0===t||2===t?Math.abs(a-l):Math.abs(c-d),this.ctx.beginPath(),3===i?this.formatPath(n):this.formatPath(s.slice(0,2)),g=e<3?3*e:2*e,B=e<3?2*e:e,3===i&&(g=e,B=e),h=!0,u<=2*g?h=!1:u<=2*g+B?(g*=p=u/(2*g+B),B*=p):(w=Math.floor((u+B)/(g+B)),f=(u-w*g)/(w-1),B=(C=(u-(w+1)*g)/w)<=0||Math.abs(B-f)<Math.abs(B-C)?f:C),h&&(3===i?this.ctx.setLineDash([0,g+B]):this.ctx.setLineDash([g,B])),3===i?(this.ctx.lineCap="round",this.ctx.lineWidth=e):this.ctx.lineWidth=2*e+1.1,this.ctx.strokeStyle=Be(A),this.ctx.stroke(),this.ctx.setLineDash([]),2===i&&(Rr(s[0])&&(m=s[3],v=s[0],this.ctx.beginPath(),this.formatPath([new kr(m.end.x,m.end.y),new kr(v.start.x,v.start.y)]),this.ctx.stroke()),Rr(s[1])&&(m=s[1],v=s[2],this.ctx.beginPath(),this.formatPath([new kr(m.end.x,m.end.y),new kr(v.start.x,v.start.y)]),this.ctx.stroke())),this.ctx.restore(),[2]})})},t.prototype.render=function(A){return n(this,void 0,void 0,function(){var e;return o(this,function(t){switch(t.label){case 0:return this.options.backgroundColor&&(this.ctx.fillStyle=Be(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height)),n=new zr(A,null),o=new Yr(n),jr(n,o,o,r=[]),Zr(n.container,r),e=o,[4,this.renderStack(e)];case 1:return t.sent(),this.applyEffects([]),[2,this.canvas]}var n,o,r})})},t}(di),gi=function(A){return A instanceof vo||A instanceof mo||A instanceof Co&&A.type!==po&&A.type!==ho},Bi=function(A,e){switch(A){case 0:return Vr(e);case 2:return function(A){return[A.topLeftContentBox,A.topRightContentBox,A.bottomRightContentBox,A.bottomLeftContentBox]}(e);default:return Nr(e)}},hi=function(A){switch(A){case 1:return"center";case 2:return"right";default:return"left"}},pi=["-apple-system","system-ui"],wi=function(A){return/iPhone OS 15_(0|1)/.test(window.navigator.userAgent)?A.filter(function(A){return-1===pi.indexOf(A)}):A},fi=function(A){function t(e,t){var n=A.call(this,e,t)||this;return n.canvas=t.canvas?t.canvas:document.createElement("canvas"),n.ctx=n.canvas.getContext("2d"),n.options=t,n.canvas.width=Math.floor(t.width*t.scale),n.canvas.height=Math.floor(t.height*t.scale),n.canvas.style.width=t.width+"px",n.canvas.style.height=t.height+"px",n.ctx.scale(n.options.scale,n.options.scale),n.ctx.translate(-t.x,-t.y),n.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized ("+t.width+"x"+t.height+" at "+t.x+","+t.y+") with scale "+t.scale),n}return e(t,A),t.prototype.render=function(A){return n(this,void 0,void 0,function(){var e,t;return o(this,function(n){switch(n.label){case 0:return e=Xn(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,A),[4,Ci(e)];case 1:return t=n.sent(),this.options.backgroundColor&&(this.ctx.fillStyle=Be(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(t,-this.options.x*this.options.scale,-this.options.y*this.options.scale),[2,this.canvas]}})})},t}(di),Ci=function(A){return new Promise(function(e,t){var n=new Image;n.onload=function(){e(n)},n.onerror=t,n.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent((new XMLSerializer).serializeToString(A))})},mi=function(){function A(A){var e=A.id,t=A.enabled;this.id=e,this.enabled=t,this.start=Date.now()}return A.prototype.debug=function(){for(var A=[],e=0;e<arguments.length;e++)A[e]=arguments[e];this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.debug?console.debug.apply(console,r([this.id,this.getTime()+"ms"],A)):this.info.apply(this,A))},A.prototype.getTime=function(){return Date.now()-this.start},A.prototype.info=function(){for(var A=[],e=0;e<arguments.length;e++)A[e]=arguments[e];this.enabled&&"undefined"!=typeof window&&window.console&&"function"==typeof console.info&&console.info.apply(console,r([this.id,this.getTime()+"ms"],A))},A.prototype.warn=function(){for(var A=[],e=0;e<arguments.length;e++)A[e]=arguments[e];this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.warn?console.warn.apply(console,r([this.id,this.getTime()+"ms"],A)):this.info.apply(this,A))},A.prototype.error=function(){for(var A=[],e=0;e<arguments.length;e++)A[e]=arguments[e];this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.error?console.error.apply(console,r([this.id,this.getTime()+"ms"],A)):this.info.apply(this,A))},A.instances={},A}(),vi=function(){function A(e,t){var n;this.windowBounds=t,this.instanceName="#"+A.instanceCount++,this.logger=new mi({id:this.instanceName,enabled:e.logging}),this.cache=null!==(n=e.cache)&&void 0!==n?n:new br(this,e)}return A.instanceCount=1,A}();"undefined"!=typeof window&&yr.setContext(window);var Qi=function(A,e){return n(void 0,void 0,void 0,function(){var n,r,a,c,l,d,u,g,B,h,p,w,f,C,m,v,Q,F,U,y,b,E,x,I,H,S,D,K,T,k,L,P,R,O,M,V,N,G;return o(this,function(o){switch(o.label){case 0:if(!A||"object"!=typeof A)return[2,Promise.reject("Invalid element provided as first argument")];if(!(n=A.ownerDocument))throw new Error("Element is not attached to a Document");if(!(r=n.defaultView))throw new Error("Document is not attached to a Window");return a={allowTaint:null!==(E=e.allowTaint)&&void 0!==E&&E,imageTimeout:null!==(x=e.imageTimeout)&&void 0!==x?x:15e3,proxy:e.proxy,useCORS:null!==(I=e.useCORS)&&void 0!==I&&I},c=t({logging:null===(H=e.logging)||void 0===H||H,cache:e.cache},a),l={windowWidth:null!==(S=e.windowWidth)&&void 0!==S?S:r.innerWidth,windowHeight:null!==(D=e.windowHeight)&&void 0!==D?D:r.innerHeight,scrollX:null!==(K=e.scrollX)&&void 0!==K?K:r.pageXOffset,scrollY:null!==(T=e.scrollY)&&void 0!==T?T:r.pageYOffset},d=new i(l.scrollX,l.scrollY,l.windowWidth,l.windowHeight),u=new vi(c,d),g=null!==(k=e.foreignObjectRendering)&&void 0!==k&&k,B={allowTaint:null!==(L=e.allowTaint)&&void 0!==L&&L,onclone:e.onclone,ignoreElements:e.ignoreElements,inlineImages:g,copyStyles:g},u.logger.debug("Starting document clone with size "+d.width+"x"+d.height+" scrolled to "+-d.left+","+-d.top),h=new cr(u,A,B),(p=h.clonedReferenceElement)?[4,h.toIFrame(n,d)]:[2,Promise.reject("Unable to find element in cloned iframe")];case 1:return w=o.sent(),f=Po(p)||"HTML"===p.tagName?function(A){var e=A.body,t=A.documentElement;if(!e||!t)throw new Error("Unable to get document size");var n=Math.max(Math.max(e.scrollWidth,t.scrollWidth),Math.max(e.offsetWidth,t.offsetWidth),Math.max(e.clientWidth,t.clientWidth)),o=Math.max(Math.max(e.scrollHeight,t.scrollHeight),Math.max(e.offsetHeight,t.offsetHeight),Math.max(e.clientHeight,t.clientHeight));return new i(0,0,n,o)}(p.ownerDocument):s(u,p),C=f.width,m=f.height,v=f.left,Q=f.top,F=Fi(u,p,e.backgroundColor),U={canvas:e.canvas,backgroundColor:F,scale:null!==(R=null!==(P=e.scale)&&void 0!==P?P:r.devicePixelRatio)&&void 0!==R?R:1,x:(null!==(O=e.x)&&void 0!==O?O:0)+v,y:(null!==(M=e.y)&&void 0!==M?M:0)+Q,width:null!==(V=e.width)&&void 0!==V?V:Math.ceil(C),height:null!==(N=e.height)&&void 0!==N?N:Math.ceil(m)},g?(u.logger.debug("Document cloned, using foreign object rendering"),[4,new fi(u,U).render(p)]):[3,3];case 2:return y=o.sent(),[3,5];case 3:return u.logger.debug("Document cloned, element located at "+v+","+Q+" with size "+C+"x"+m+" using computed rendering"),u.logger.debug("Starting DOM parsing"),b=bo(u,p),F===b.styles.backgroundColor&&(b.styles.backgroundColor=Qe.TRANSPARENT),u.logger.debug("Starting renderer for element at "+U.x+","+U.y+" with size "+U.width+"x"+U.height),[4,new ui(u,U).render(b)];case 4:y=o.sent(),o.label=5;case 5:return(null===(G=e.removeContainer)||void 0===G||G)&&(cr.destroy(w)||u.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),u.logger.debug("Finished rendering"),[2,y]}})})},Fi=function(A,e,t){var n=e.ownerDocument,o=n.documentElement?ve(A,getComputedStyle(n.documentElement).backgroundColor):Qe.TRANSPARENT,r=n.body?ve(A,getComputedStyle(n.body).backgroundColor):Qe.TRANSPARENT,i="string"==typeof t?ve(A,t):null===t?Qe.TRANSPARENT:4294967295;return e===n.documentElement?ge(o)?ge(r)?i:r:o:i};return function(A,e){return void 0===e&&(e={}),Qi(A,e)}}()},698:(A,e)=>{var t=Symbol.for("react.transitional.element");function n(A,e,n){var o=null;if(void 0!==n&&(o=""+n),void 0!==e.key&&(o=""+e.key),"key"in e)for(var r in n={},e)"key"!==r&&(n[r]=e[r]);else n=e;return e=n.ref,{$$typeof:t,type:A,key:o,ref:void 0!==e?e:null,props:n}}Symbol.for("react.fragment"),e.jsx=n,e.jsxs=n},848:(A,e,t)=>{A.exports=t(698)}},o={};function r(A){var e=o[A];if(void 0!==e)return e.exports;var t=o[A]={exports:{}};return n[A].call(t.exports,t,t.exports,r),t.exports}r.n=A=>{var e=A&&A.__esModule?()=>A.default:()=>A;return r.d(e,{a:e}),e},r.d=(A,e)=>{for(var t in e)r.o(e,t)&&!r.o(A,t)&&Object.defineProperty(A,t,{enumerable:!0,get:e[t]})},r.o=(A,e)=>Object.prototype.hasOwnProperty.call(A,e),r.r=A=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(A,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(A,"__esModule",{value:!0})};var i={};r.r(i),r.d(i,{checkPermissionState:()=>xA,getDeviceInfo:()=>EA,getPermissionInstructions:()=>HA,openSettings:()=>SA});var s={};r.r(s),r.d(s,{showBlockedModal:()=>TA,showNoMicrophoneModal:()=>kA,showPrePromptModal:()=>KA});const a=class{constructor(){this.events={}}on(A,e){return this.events[A]||(this.events[A]=[]),this.events[A].push(e),this}off(A,e){return this.events[A]?(this.events[A]=this.events[A].filter(A=>A!==e),this):this}emit(A){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];return!!this.events[A]&&(this.events[A].forEach(A=>{A(...t)}),!0)}once(A,e){var t=this,n=function(){e(...arguments),t.off(A,n)};return this.on(A,n)}removeAllListeners(A){return A?delete this.events[A]:this.events={},this}},c=class{constructor(){this.name="PCM"}decode(A){if(A instanceof ArrayBuffer)return A;if(A instanceof Uint8Array)return A.buffer;throw new Error("Invalid PCM data type")}encode(A){return A}},l=class{constructor(){this.name="PCMU"}decode(A){for(var e=A instanceof Uint8Array?A:new Uint8Array(A),t=new Int16Array(e.length),n=0;n<e.length;n++)t[n]=this.mulawToLinear(e[n]);return t.buffer}encode(A){for(var e=A instanceof Int16Array?A:new Int16Array(A),t=new Uint8Array(e.length),n=0;n<e.length;n++)t[n]=this.linearToMulaw(e[n]);return t}mulawToLinear(A){var e=1<<3+(A>>4&7);return(128&A?-1:1)*(132+(15&A)*e+(e>>1)-4)}linearToMulaw(A){var e=A>>8&128;e&&(A=-A),A>32635&&(A=32635),A+=132;for(var t=7,n=16384;0===(A&n)&&t>0;t--,n>>=1);return 255&~(e|t<<4|A>>t+3&15)}},d=class{constructor(){this.name="PCMA"}decode(A){for(var e=A instanceof Uint8Array?A:new Uint8Array(A),t=new Int16Array(e.length),n=0;n<e.length;n++)t[n]=this.alawToLinear(e[n]);return t.buffer}encode(A){for(var e=A instanceof Int16Array?A:new Int16Array(A),t=new Uint8Array(e.length),n=0;n<e.length;n++)t[n]=this.linearToAlaw(e[n]);return t}alawToLinear(A){var e=(A^=85)>>4&7,t=15&A;return(128&A?-1:1)*(0===e?8+(t<<4):264+(t<<4)<<e-1)}linearToAlaw(A){var e,t,n=A>>8&128;if(n&&(A=-A),A>32635&&(A=32635),A<256)e=0,t=A>>4;else{e=7;for(var o=16384;0===(A&o)&&e>0;e--,o>>=1);t=A>>e+3&15}return 85^(n|e<<4|t)}};function u(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}function g(A){return function(){var e=this,t=arguments;return new Promise(function(n,o){var r=A.apply(e,t);function i(A){u(r,n,o,i,s,"next",A)}function s(A){u(r,n,o,i,s,"throw",A)}i(void 0)})}}const B=class extends a{constructor(){var A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.config=A,this.audioContext=null,this.audioQueue=[],this.isPlaying=!1,this.isProcessingQueue=!1,this.currentSource=null,this.outputFormat=null,this.nextStartTime=0,this.scheduledBuffers=0,this.scheduledSources=new Set,this.pcmChunkQueue=[],this.preparedBuffer=[],this.isProcessingPcmQueue=!1,this.isSchedulingFrames=!1,this.MAX_LOOKAHEAD_SECONDS=.02,this.pendingSentenceText=null,this.sentenceTimings=[],this.isCheckingTranscripts=!1,this.codecs={pcm:new c,pcmu:new l,pcma:new d},this.SUPPORTED_CONTAINERS=["wav","raw"],this.SUPPORTED_ENCODINGS=["pcm","pcmu","pcma"],this.SUPPORTED_SAMPLE_RATES=[8e3,16e3,22050,24e3,44100,48e3],this.SUPPORTED_BIT_DEPTHS=[8,16,24],this.SUPPORTED_CHANNELS=[1],console.log("đĩ AudioPlayer v2 initialized")}setOutputFormat(A){var e;this.validateFormat(A)||(console.warn("â ī¸ AudioPlayer: Invalid format, using defaults:",A),A=this.getDefaultFormat());var t=null===(e=this.outputFormat)||void 0===e?void 0:e.sampleRate,n=A.sampleRate;this.outputFormat=A,console.log("â
AudioPlayer v2: Format set:",A),this.audioContext&&t&&t!==n&&(console.warn("â ī¸ AudioPlayer: Sample rate changed, recreating AudioContext"),console.warn(" Old: ".concat(t,"Hz â New: ").concat(n,"Hz")),this.stopImmediate(),"closed"!==this.audioContext.state&&this.audioContext.close(),this.audioContext=null,console.log("âšī¸ AudioContext will be recreated on next audio chunk with correct sample rate")),this.audioContext||(this.initializeAudioContext(),this.audioContext&&"suspended"===this.audioContext.state&&this.audioContext.resume().then(()=>{console.log("â
AudioPlayer v2: AudioContext resumed and ready")}).catch(A=>{console.warn("â ī¸ AudioPlayer v2: Could not resume AudioContext:",A)}))}validateFormat(A){var e,t;if(!A)return!1;var n=null===(e=A.container)||void 0===e?void 0:e.toLowerCase(),o=null===(t=A.encoding)||void 0===t?void 0:t.toLowerCase();return n&&o&&this.SUPPORTED_CONTAINERS.includes(n)&&this.SUPPORTED_ENCODINGS.includes(o)&&this.SUPPORTED_SAMPLE_RATES.includes(A.sampleRate)&&this.SUPPORTED_BIT_DEPTHS.includes(A.bitDepth)&&(!A.channels||this.SUPPORTED_CHANNELS.includes(A.channels))}getDefaultFormat(){return{container:"raw",encoding:"pcm",sampleRate:16e3,channels:1,bitDepth:16}}playAudio(A){try{var e=this.createAudioBlob(A);this.audioQueue.push(e),this.isPlaying||this.isProcessingQueue||this.currentSource||setTimeout(()=>this.processQueue(),50)}catch(A){console.error("â AudioPlayer v2: Playback error:",A),this.emit("playbackError",A)}}playChunk(A){var e=this;return g(function*(){var t,n=e.prepareChunk(A);n?(e.preparedBuffer.push(n),e.isSchedulingFrames?setTimeout(()=>{e.preparedBuffer.length>0&&!e.isSchedulingFrames&&e.schedulePreparedFrames()},5):e.schedulePreparedFrames(),e.pcmChunkQueue.length>0&&!e.isProcessingPcmQueue&&e.processPcmQueue()):(console.error("â AudioPlayer: playChunk failed - prepareChunk returned null"),console.error(" pcmData length:",(null==A?void 0:A.byteLength)||"undefined"),console.error(" outputFormat:",e.outputFormat),console.error(" audioContext:",e.audioContext?"initialized":"not initialized"),console.error(" audioContext state:",(null===(t=e.audioContext)||void 0===t?void 0:t.state)||"N/A"),e.emit("playbackError",new Error("Failed to prepare PCM chunk for playback")))})()}prepareChunk(A){try{var e;if(!this.outputFormat)return console.error("â AudioPlayer: Cannot prepare chunk - outputFormat not set"),console.error(" Call setOutputFormat() before playing audio chunks"),null;if(this.audioContext||this.initializeAudioContext(),!this.audioContext)return console.error("â AudioPlayer: Cannot prepare chunk - AudioContext not available"),null;var t=A;if(A.byteLength%2!=0){console.warn("â ī¸ Odd PCM chunk size, padding:",A.byteLength);var n=new Uint8Array(A.byteLength+1);n.set(new Uint8Array(A),0),n[A.byteLength]=0,t=n.buffer}for(var o=new Int16Array(t),r=new Float32Array(o.length),i=1/32768,s=o.length,a=0;a<s;a++)r[a]=o[a]*i;var c=(null===(e=this.outputFormat)||void 0===e?void 0:e.sampleRate)||this.audioContext.sampleRate,l=this.audioContext.sampleRate,d=this.audioContext.createBuffer(1,r.length,c);d.getChannelData(0).set(r);var u=d.duration,g=r.length,B=u;return l!==c&&(B=g/l),{buffer:d,duration:B,sampleRate:c,contextSampleRate:l}}catch(A){return console.error("â AudioPlayer: Error preparing chunk:",A),null}}applyFadeOut(A){return A}schedulePreparedFrames(){var A=this;return g(function*(){if(!A.isSchedulingFrames){A.isSchedulingFrames=!0;var e=A.preparedBuffer.length,t=Math.min(e,5);0===t&&e>0&&(t=1);try{A.audioContext||A.initializeAudioContext();var n=0===A.scheduledBuffers&&!A.isPlaying;"suspended"===A.audioContext.state&&(yield A.audioContext.resume(),n&&(yield new Promise(A=>setTimeout(A,50)))),"running"!==A.audioContext.state&&(console.warn("AudioPlayer v2: AudioContext not in running state:",A.audioContext.state),"suspended"===A.audioContext.state&&(yield A.audioContext.resume(),n?yield new Promise(A=>setTimeout(A,50)):yield new Promise(A=>setTimeout(A,10))));for(var o=0,r=function*(){var e=A.preparedBuffer.shift();if(!e)return 1;var t=A.audioContext.createBufferSource();t.buffer=e.buffer,t.connect(A.audioContext.destination),A.scheduledSources.add(t);var n=A.audioContext.currentTime;if(0===A.scheduledBuffers)A.nextStartTime<n&&(A.nextStartTime=n+A.MAX_LOOKAHEAD_SECONDS),console.log("đĩ Starting playback with minimal delay:",A.nextStartTime);else{var r=n+A.MAX_LOOKAHEAD_SECONDS;A.nextStartTime<r&&(A.nextStartTime=r,console.warn("â ī¸ AudioPlayer: Fell behind schedule, adjusting nextStartTime to ".concat(A.nextStartTime.toFixed(4),"s")))}A.pendingSentenceText&&(A.sentenceTimings.push({startTime:A.nextStartTime,text:A.pendingSentenceText,displayed:!1}),console.log("đ AudioPlayer: Sentence scheduled at ".concat(A.nextStartTime.toFixed(3),'s: "').concat(A.pendingSentenceText.substring(0,40),'..."')),A.pendingSentenceText=null,A.isCheckingTranscripts||A.startTranscriptChecker()),t.start(A.nextStartTime),A.nextStartTime+=e.duration,A.nextStartTime=Math.round(1e6*A.nextStartTime)/1e6;var i=A.nextStartTime-e.duration;A.scheduledBuffers<5&&(console.log("đĩ AudioPlayer: Scheduled frame ".concat(A.scheduledBuffers+1," at ").concat(i.toFixed(4),"s, next at ").concat(A.nextStartTime.toFixed(4),"s")),console.log(" Duration: ".concat(e.duration.toFixed(4),"s (").concat((1e3*e.duration).toFixed(2),"ms), Queued: ").concat(A.preparedBuffer.length,", Scheduled: ").concat(A.scheduledBuffers))),A.scheduledBuffers++,o++,t.onended=()=>{if(A.scheduledSources.delete(t),A.scheduledBuffers--,0===A.scheduledBuffers&&0===A.preparedBuffer.length&&0===A.pcmChunkQueue.length)A.isPlaying=!1,A.isSchedulingFrames=!1,console.log("đ AudioPlayer: Emitting playbackStopped event (all buffers finished)"),A.emit("playbackStopped");else if(A.preparedBuffer.length>0)setTimeout(()=>{A.preparedBuffer.length>0&&!A.isSchedulingFrames&&A.schedulePreparedFrames()},0);else if(A.scheduledBuffers>0){var e=()=>{A.preparedBuffer.length>0&&!A.isSchedulingFrames&&A.scheduledBuffers>0?A.schedulePreparedFrames():A.scheduledBuffers>0&&setTimeout(e,10)};setTimeout(e,10)}},A.isPlaying||(A.isPlaying=!0,console.log("đĩ AudioPlayer: Emitting playbackStarted event"),A.emit("playbackStarted"))};A.preparedBuffer.length>0&&o<t&&!(yield*r()););A.isSchedulingFrames=!1,A.preparedBuffer.length>0&&requestAnimationFrame(()=>{A.preparedBuffer.length>0&&!A.isSchedulingFrames&&A.schedulePreparedFrames()}),A.scheduledBuffers>0&&setTimeout(()=>{A.preparedBuffer.length>0&&!A.isSchedulingFrames&&A.scheduledBuffers>0?A.schedulePreparedFrames():A.scheduledBuffers>0&&setTimeout(()=>{A.preparedBuffer.length>0&&!A.isSchedulingFrames&&A.scheduledBuffers>0&&A.schedulePreparedFrames()},10)},10)}catch(e){console.error("â AudioPlayer v2: Error scheduling frames:",e),A.emit("playbackError",e),A.isSchedulingFrames=!1}}})()}processPcmQueue(){var A=this;return g(function*(){if(!A.isProcessingPcmQueue){A.isProcessingPcmQueue=!0;try{A.audioContext||A.initializeAudioContext();var e=0===A.scheduledBuffers&&!A.isPlaying;for("suspended"===A.audioContext.state&&(yield A.audioContext.resume(),e&&(yield new Promise(A=>setTimeout(A,50)))),"running"!==A.audioContext.state&&(console.warn("AudioPlayer v2: AudioContext not in running state:",A.audioContext.state),"suspended"===A.audioContext.state&&(yield A.audioContext.resume(),e?yield new Promise(A=>setTimeout(A,50)):yield new Promise(A=>setTimeout(A,10))));A.pcmChunkQueue.length>0;){var t,n,o=A.pcmChunkQueue.shift();if(o){var r=o;if(o.byteLength%2!=0){console.warn("â ī¸ Odd PCM chunk size, padding:",o.byteLength);var i=new Uint8Array(o.byteLength+1);i.set(new Uint8Array(o),0),i[o.byteLength]=0,r=i.buffer}for(var s=new Int16Array(r),a=new Float32Array(s.length),c=1/32768,l=s.length,d=0;d<l;d++)a[d]=s[d]*c;var u=(null===(t=A.outputFormat)||void 0===t?void 0:t.sampleRate)||A.audioContext.sampleRate,g=A.audioContext.sampleRate;null!==(n=A.outputFormat)&&void 0!==n&&n.sampleRate?A.scheduledBuffers<3&&console.log("đĩ AudioPlayer: Creating buffer at ".concat(u,"Hz (AudioContext: ").concat(g,"Hz)")):console.warn("â ī¸ AudioPlayer: outputFormat.sampleRate not set! Using AudioContext sample rate:",g);var B=A.audioContext.createBuffer(1,a.length,u);B.getChannelData(0).set(a);var h=A.audioContext.createBufferSource();h.buffer=B,h.connect(A.audioContext.destination);var p=A.audioContext.currentTime;A.nextStartTime<p&&(A.nextStartTime=p,0===A.scheduledBuffers&&console.log("đĩ Starting playback at current time:",p));var w=B.duration,f=a.length,C=w;if(g!==u&&(C=f/g,A.scheduledBuffers<3&&(console.log("đ Resampling detected: ".concat(u,"Hz â ").concat(g,"Hz")),console.log(" Buffer duration: ".concat(w.toFixed(4),"s, Calculated: ").concat(C.toFixed(4),"s")))),h.start(A.nextStartTime),A.nextStartTime+=C,A.nextStartTime=Math.round(1e6*A.nextStartTime)/1e6,A.scheduledBuffers<3){var m=A.nextStartTime-C;console.log("đĩ AudioPlayer: Scheduled chunk ".concat(A.scheduledBuffers+1," at ").concat(m.toFixed(4),"s, next at ").concat(A.nextStartTime.toFixed(4),"s")),console.log(" Duration: ".concat(C.toFixed(4),"s (").concat((1e3*C).toFixed(2),"ms)"))}A.scheduledBuffers++,h.onended=()=>{A.scheduledBuffers--,0===A.scheduledBuffers&&0===A.pcmChunkQueue.length&&(A.isPlaying=!1,A.isProcessingPcmQueue=!1,A.emit("playbackStopped"))},A.isPlaying||(A.isPlaying=!0,A.emit("playbackStarted"))}}A.isProcessingPcmQueue=!1}catch(e){console.error("â AudioPlayer v2: Error playing chunk:",e),A.emit("playbackError",e),A.isProcessingPcmQueue=!1}}})()}createAudioBlob(A){var e=new Uint8Array(A);console.log("đĩ AudioPlayer: Processing ".concat(e.length," bytes")),console.log("đĩ AudioPlayer: Negotiated format:",this.outputFormat);var t=this.outputFormat&&this.outputFormat.container&&"wav"===this.outputFormat.container.toLowerCase(),n=this.outputFormat&&this.outputFormat.container&&"raw"===this.outputFormat.container.toLowerCase(),o=this.isWavFile(e);if(o&&console.log("đĩ AudioPlayer: Data has WAV header (RIFF)"),n&&o)return console.error("â AudioPlayer: CRITICAL MISMATCH!"),console.error(" Negotiated format: RAW"),console.error(" Actual data: WAV (RIFF header detected)"),console.error(" Backend is ignoring format request and sending WAV anyway."),console.warn("â ī¸ AudioPlayer: Processing as WAV to avoid playback failure, but UI configuration was bypassed."),this.handleWavFile(e);if(n&&!o)console.log("đĩ AudioPlayer: Processing as RAW data (as negotiated)");else{if(t&&o)return console.log("â
AudioPlayer: Processing as WAV file (matches negotiation)"),this.handleWavFile(e);if(t&&!o)return console.warn("â ī¸ AudioPlayer: Negotiated WAV but data lacks WAV header. Attempting WAV processing anyway."),this.handleWavFile(e);if(!this.outputFormat&&o)return console.log("đĩ AudioPlayer: No format negotiated, auto-detecting WAV"),this.handleWavFile(e);this.outputFormat||o||(console.warn("â ī¸ AudioPlayer: No format negotiated and data not WAV, using defaults"),this.outputFormat=this.getDefaultFormat())}return this.outputFormat||(console.warn("â ī¸ AudioPlayer: No format set, using defaults"),this.outputFormat=this.getDefaultFormat()),console.log("đĩ AudioPlayer: Processing as RAW data with encoding:",this.outputFormat.encoding),this.handleRawData(e)}isWavFile(A){return A.length>=44&&82===A[0]&&73===A[1]&&70===A[2]&&70===A[3]}handleWavFile(A){var e=this.parseWavHeader(A);if(console.log("đĩ WAV file detected:",{format:e.audioFormat,encoding:this.getEncodingName(e.audioFormat),sampleRate:e.sampleRate,channels:e.channels,bitDepth:e.bitsPerSample}),1===e.audioFormat)return console.log("â
PCM WAV - using directly"),new Blob([A],{type:"audio/wav"});var t=this.getCodecForWavFormat(e.audioFormat);if(!t)throw new Error("Unsupported WAV format code: ".concat(e.audioFormat));console.log("đ Non-PCM WAV - converting to PCM WAV");var n=A.slice(44),o=t.decode(n),r=this.createWavHeader(o.byteLength,e.sampleRate,e.channels,16);return new Blob([r,o],{type:"audio/wav"})}handleRawData(A){var e,t,n=this.outputFormat.encoding.toLowerCase(),o=this.getCodec(n);if(!o)throw new Error("No codec found for encoding: ".concat(n));if(console.log("đĩ AudioPlayer: Decoding ".concat(n.toUpperCase()," to PCM")),console.log("đĩ AudioPlayer: Input format - bitDepth: ".concat(this.outputFormat.bitDepth,", sampleRate: ").concat(this.outputFormat.sampleRate)),"pcm"===n){var r=this.outputFormat.bitDepth||16;A.length,24===r?(console.warn("â ī¸ AudioPlayer: Format says 24-bit PCM, but browser support is limited."),console.warn(" Treating as 16-bit PCM. If audio sounds wrong, backend should send 16-bit instead."),e=this.convert24BitTo16Bit(A),t=16):8===r?(console.log("đ AudioPlayer: Converting 8-bit PCM to 16-bit PCM"),e=this.convert8BitTo16Bit(A),t=16):(e=A.buffer,t=r,console.log("â
AudioPlayer: Using native ".concat(r,"-bit PCM (no conversion needed)")))}else e=o.decode(A),t=16,console.log("đ AudioPlayer: Decoded ".concat(n.toUpperCase()," to 16-bit PCM"));var i=this.createWavHeader(e.byteLength,this.outputFormat.sampleRate,this.outputFormat.channels,t);return new Blob([i,e],{type:"audio/wav"})}convert24BitTo16Bit(A){for(var e=Math.floor(A.length/3),t=new Int16Array(e),n=0;n<e;n++){var o=A[3*n],r=A[3*n+1],i=A[3*n+2],s=o|r<<8|(255&i)<<16;128&i&&(s|=4278190080),t[n]=Math.max(-32768,Math.min(32767,Math.round(s/256)))}return t.buffer}convert8BitTo16Bit(A){for(var e=A.length,t=new Int16Array(e),n=0;n<e;n++){var o=A[n];t[n]=256*(o-128)}return t.buffer}getCodec(A){var e={pcm:"pcm",linear:"pcm",l16:"pcm",pcmu:"pcmu",ulaw:"pcmu",mulaw:"pcmu",g711u:"pcmu",pcma:"pcma",alaw:"pcma",g711a:"pcma"}[A.toLowerCase()];return this.codecs[e]}getCodecForWavFormat(A){switch(A){case 1:return this.codecs.pcm;case 6:return this.codecs.pcma;case 7:return this.codecs.pcmu;default:return null}}getEncodingName(A){switch(A){case 1:return"PCM";case 6:return"A-law";case 7:return"Îŧ-law";default:return"Unknown (".concat(A,")")}}parseWavHeader(A){var e=new DataView(A.buffer,A.byteOffset,A.byteLength);return{audioFormat:e.getUint16(20,!0),channels:e.getUint16(22,!0),sampleRate:e.getUint32(24,!0),byteRate:e.getUint32(28,!0),blockAlign:e.getUint16(32,!0),bitsPerSample:e.getUint16(34,!0)}}createWavHeader(A,e,t,n){var o=new ArrayBuffer(44),r=new DataView(o);return r.setUint32(0,1380533830,!1),r.setUint32(4,36+A,!0),r.setUint32(8,1463899717,!1),r.setUint32(12,1718449184,!1),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,t,!0),r.setUint32(24,e,!0),r.setUint32(28,e*t*n/8,!0),r.setUint16(32,t*n/8,!0),r.setUint16(34,n,!0),r.setUint32(36,1684108385,!1),r.setUint32(40,A,!0),o}initializeAudioContext(){var A,e,t=(null===(A=this.outputFormat)||void 0===A?void 0:A.sampleRate)||44100;if(48e3!==t&&44100!==t&&(console.log("âšī¸ AudioPlayer: Backend requested ".concat(t,"Hz, but browser may resample")),console.log(" Consider requesting 44100Hz or 48000Hz from backend to avoid resampling and improve quality")),this.audioContext){var n=this.audioContext.sampleRate;if(!(Math.abs(n-t)>100))return;console.warn("â ī¸ AudioPlayer: AudioContext sample rate (".concat(n,"Hz) doesn't match format (").concat(t,"Hz), recreating...")),this.stopImmediate(),"closed"!==this.audioContext.state&&this.audioContext.close(),this.audioContext=null}console.log("đĩ AudioPlayer: Creating AudioContext at ".concat(t,"Hz (from outputFormat: ").concat((null===(e=this.outputFormat)||void 0===e?void 0:e.sampleRate)||"not set",")"));try{this.audioContext=new(window.AudioContext||window.webkitAudioContext)({sampleRate:t,latencyHint:"playback"}),console.log("â
AudioContext created at ".concat(this.audioContext.sampleRate,"Hz (requested: ").concat(t,"Hz)")),Math.abs(this.audioContext.sampleRate-t)>100?(console.error("â CRITICAL: Browser sample rate mismatch!"),console.error(" Requested: ".concat(t,"Hz")),console.error(" Got: ".concat(this.audioContext.sampleRate,"Hz")),console.error(" This WILL cause audio distortion/noise!"),console.error(" Solution: Backend should send ".concat(this.audioContext.sampleRate,"Hz audio instead"))):this.audioContext.sampleRate!==t&&(console.warn("â ī¸ Browser adjusted sample rate: ".concat(t,"Hz â ").concat(this.audioContext.sampleRate,"Hz")),console.warn(" Browser will automatically resample audio."))}catch(A){console.error("â Failed to create AudioContext:",A),this.audioContext=new(window.AudioContext||window.webkitAudioContext),console.log("âšī¸ Using browser default: ".concat(this.audioContext.sampleRate,"Hz"))}}processQueue(){var A=this;return g(function*(){if(!A.isProcessingQueue&&0!==A.audioQueue.length){A.isProcessingQueue=!0;var e=A.audioQueue.shift();if(e)try{var t=!A.isPlaying&&null===A.currentSource;A.audioContext||A.initializeAudioContext();var n=A.audioContext;"suspended"===n.state&&(yield n.resume(),t&&(yield new Promise(A=>setTimeout(A,50)))),"running"!==n.state&&(console.warn("AudioPlayer v2: AudioContext not in running state:",n.state),"suspended"===n.state&&(yield n.resume(),t?yield new Promise(A=>setTimeout(A,50)):yield new Promise(A=>setTimeout(A,10))));var o=yield e.arrayBuffer(),r=yield n.decodeAudioData(o),i=t&&!A.isPlaying&&null===A.currentSource,s=n.createBufferSource();s.buffer=r,s.connect(n.destination),A.currentSource=s,A.isPlaying=!0,i&&A.emit("playbackStarted"),s.onended=()=>{A.currentSource=null,A.isProcessingQueue=!1,A.audioQueue.length>0?setTimeout(()=>A.processQueue(),50):setTimeout(()=>{0!==A.audioQueue.length||A.currentSource||(A.isPlaying=!1,A.emit("playbackStopped"))},100)},s.start()}catch(e){console.error("â AudioPlayer v2: Error processing queue:",e),A.currentSource=null,A.emit("playbackError",e),A.audioQueue.length>0?(A.isProcessingQueue=!1,setTimeout(()=>A.processQueue(),100)):(A.isPlaying=!1,A.isProcessingQueue=!1,A.emit("playbackStopped"))}else A.isProcessingQueue=!1}})()}stop(){this.stopImmediate()}reset(){this.stop(),this.audioQueue=[],this.pcmChunkQueue=[]}stopImmediate(){var A=this.isPlaying||null!==this.currentSource||this.scheduledSources.size>0;if(console.log("đ AudioPlayer.stopImmediate() called"),console.log(" isPlaying:",this.isPlaying),console.log(" currentSource:",null!==this.currentSource),console.log(" scheduledSources.size:",this.scheduledSources.size),console.log(" scheduledBuffers:",this.scheduledBuffers),this.currentSource){try{console.log(" Stopping currentSource..."),this.currentSource.stop()}catch(A){console.log(" currentSource already stopped or error:",A.message)}this.currentSource=null}if(this.scheduledSources.size>0){console.log(" Stopping ".concat(this.scheduledSources.size," scheduled sources..."));var e=0;for(var t of this.scheduledSources)try{t.stop(),e++}catch(A){console.log(" Source already stopped or not started:",A.message)}console.log(" Stopped ".concat(e," sources")),this.scheduledSources.clear()}this.isPlaying=!1,this.isProcessingQueue=!1,this.audioQueue=[],this.pcmChunkQueue=[],this.preparedBuffer=[],this.isProcessingPcmQueue=!1,this.isSchedulingFrames=!1,this.nextStartTime=0,this.scheduledBuffers=0,this.clearTranscriptState(),A&&(console.log("đ AudioPlayer: Emitting playbackStopped event (stopImmediate called)"),this.emit("playbackStopped"))}markNewSentence(A){this.pendingSentenceText=A,console.log('đ AudioPlayer: New sentence marked: "'.concat(A.substring(0,40),'..."'))}startTranscriptChecker(){if(!this.isCheckingTranscripts){this.isCheckingTranscripts=!0,console.log("đ AudioPlayer: Transcript checker started");var A=()=>{if(this.isCheckingTranscripts&&this.audioContext){var e=this.audioContext.currentTime;for(var t of this.sentenceTimings)!t.displayed&&e>=t.startTime&&(t.displayed=!0,console.log("đ AudioPlayer: Display transcript at ".concat(e.toFixed(3),'s: "').concat(t.text.substring(0,40),'..."')),this.emit("transcriptDisplay",{text:t.text}));this.isPlaying||this.scheduledBuffers>0?requestAnimationFrame(A):(this.isCheckingTranscripts=!1,console.log("đ AudioPlayer: Transcript checker stopped"))}};requestAnimationFrame(A)}}clearTranscriptState(){this.pendingSentenceText=null,this.sentenceTimings=[],this.isCheckingTranscripts=!1,console.log("đ AudioPlayer: Transcript state cleared")}resumeAudioContext(){var A=this;return g(function*(){if(A.audioContext&&"closed"!==A.audioContext.state){if("suspended"===A.audioContext.state)try{yield A.audioContext.resume(),console.log("â
AudioPlayer v2: AudioContext resumed after mic permission")}catch(A){console.warn("â ī¸ AudioPlayer v2: Failed to resume AudioContext:",A)}}else yield A.initializeAudioContext()})()}getStatus(){return{isPlaying:this.isPlaying,isProcessingQueue:this.isProcessingQueue,queueLength:this.audioQueue.length,audioContextState:this.audioContext?this.audioContext.state:"closed",outputFormat:this.outputFormat,scheduledBuffers:this.scheduledBuffers,preparedBufferLength:this.preparedBuffer.length,scheduledSourcesCount:this.scheduledSources.size}}destroy(){this.stop(),this.audioContext&&"closed"!==this.audioContext.state&&(this.audioContext.close(),this.audioContext=null),this.removeAllListeners()}};function h(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}function p(A){return function(){var e=this,t=arguments;return new Promise(function(n,o){var r=A.apply(e,t);function i(A){h(r,n,o,i,s,"next",A)}function s(A){h(r,n,o,i,s,"throw",A)}i(void 0)})}}class w extends a{constructor(A){super(),this.config=A,this.audioContext=null,this.audioWorkletNode=null,this.mediaStream=null,this.isRecording=!1}getAudioProcessorPath(){if(this.config.audioProcessorPath)return this.config.audioProcessorPath;var A=document.getElementsByTagName("script");for(var e of A){var t=e.src;if(t&&(t.includes("agent-widget.js")||t.includes("ttp-agent-sdk")))try{var n=t.substring(0,t.lastIndexOf("/"));return"".concat(n,"/audio-processor.js")}catch(A){var o=t.substring(0,t.lastIndexOf("/"));return"".concat(o,"/audio-processor.js")}}return"https://cdn.talktopc.com/audio-processor.js"}start(){var A=this;return p(function*(){try{if("https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname){var e=new Error("Microphone access requires HTTPS. Please use https:// or test on localhost.");throw console.error("â AudioRecorder:",e.message),A.emit("error",e),e}if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){var t=new Error("getUserMedia is not supported in this browser. Please use a modern browser.");throw console.error("â AudioRecorder:",t.message),A.emit("error",t),t}console.log("đ¤ AudioRecorder: Requesting microphone access..."),A.mediaStream=yield navigator.mediaDevices.getUserMedia({audio:{sampleRate:A.config.sampleRate,channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),console.log("â
AudioRecorder: Microphone access granted"),A.audioContext=new(window.AudioContext||window.webkitAudioContext)({sampleRate:A.config.sampleRate}),"suspended"===A.audioContext.state&&(yield A.audioContext.resume());var n=A.getAudioProcessorPath();yield A.audioContext.audioWorklet.addModule(n),A.audioWorkletNode=new AudioWorkletNode(A.audioContext,"audio-processor"),A.audioContext.createMediaStreamSource(A.mediaStream).connect(A.audioWorkletNode),A.audioWorkletNode.port.onmessage=e=>{var{type:t,data:n}=e.data;"pcm_audio_data"===t&&A.emit("audioData",n)},A.audioWorkletNode.port.postMessage({type:"setForceContinuous",data:{enabled:!0}}),A.isRecording=!0,A.emit("recordingStarted")}catch(e){var o=e.message;"NotAllowedError"===e.name||"PermissionDeniedError"===e.name?(o="Microphone permission denied. Please allow microphone access in your browser settings and try again.",console.error("â AudioRecorder: Permission denied. User needs to grant microphone access.")):"NotFoundError"===e.name||"DevicesNotFoundError"===e.name?(o="No microphone found. Please connect a microphone and try again.",console.error("â AudioRecorder: No microphone device found.")):"NotReadableError"===e.name||"TrackStartError"===e.name?(o="Microphone is already in use by another application. Please close other apps using the microphone and try again.",console.error("â AudioRecorder: Microphone is busy or not readable.")):e.message&&e.message.includes("not allowed by the user agent")&&(o="Microphone access blocked. On mobile devices, please tap the recording button directly (not from an iframe or popup).",console.error("â AudioRecorder: User agent blocked microphone access. This often happens on mobile when not called from direct user interaction."));var r=new Error(o);throw r.name=e.name,r.originalError=e,console.error("â AudioRecorder: Failed to start recording:",r),A.emit("error",r),r}})()}stop(){var A=this;return p(function*(){if(A.isRecording)try{A.audioWorkletNode&&(A.audioWorkletNode.port.postMessage({type:"flush"}),yield new Promise(A=>setTimeout(A,100))),A.mediaStream&&(A.mediaStream.getTracks().forEach(A=>A.stop()),A.mediaStream=null),A.audioContext&&"closed"!==A.audioContext.state&&(yield A.audioContext.close(),A.audioContext=null),A.audioWorkletNode=null,A.isRecording=!1,A.emit("recordingStopped")}catch(e){throw A.emit("error",e),e}})()}getStatus(){return{isRecording:this.isRecording,audioContextState:this.audioContext?this.audioContext.state:"closed"}}destroy(){this.stop()}}class f{static extractPcmFromWav(A){var e=A instanceof Uint8Array?A:new Uint8Array(A);if(e.length<44)throw new Error("WAV data too short (< 44 bytes)");if("RIFF"!==String.fromCharCode(e[0],e[1],e[2],e[3]))throw new Error("Not a valid WAV file - missing RIFF header");if("WAVE"!==String.fromCharCode(e[8],e[9],e[10],e[11]))throw new Error("Not a valid WAV file - missing WAVE format");for(var t=e[22]|e[23]<<8,n=e[24]|e[25]<<8|e[26]<<16|e[27]<<24,o=e[34]|e[35]<<8,r=-1,i=12;i<e.length-8;i+=4){if("data"===String.fromCharCode(e[i],e[i+1],e[i+2],e[i+3])){r=i;break}i+=4+(e[i+4]|e[i+5]<<8|e[i+6]<<16|e[i+7]<<24)}if(-1===r)throw new Error("No data chunk found in WAV");var s=e[r+4]|e[r+5]<<8|e[r+6]<<16|e[r+7]<<24,a=r+8,c=Math.min(s,e.length-a);return{pcmData:e.slice(a,a+c).buffer,format:{sampleRate:n,channels:t,bitDepth:o}}}static isWavFile(A){return A.length>=44&&82===A[0]&&73===A[1]&&70===A[2]&&70===A[3]}static createWavHeader(A,e,t,n){var o=new ArrayBuffer(44),r=new DataView(o);return r.setUint32(0,1380533830,!1),r.setUint32(4,36+A,!0),r.setUint32(8,1463899717,!1),r.setUint32(12,1718449184,!1),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,t,!0),r.setUint32(24,e,!0),r.setUint32(28,e*t*n/8,!0),r.setUint16(32,t*n/8,!0),r.setUint16(34,n,!0),r.setUint32(36,1684108385,!1),r.setUint32(40,A,!0),o}static wrapPcmInWav(A,e){var t=f.createWavHeader(A.byteLength,e.sampleRate,e.channels||1,e.bitDepth||16),n=new Uint8Array(t.byteLength+A.byteLength);return n.set(new Uint8Array(t),0),n.set(new Uint8Array(A),t.byteLength),n.buffer}}const C=f,m=class{constructor(){this.codecs={pcm:new c,pcmu:new l,pcma:new d}}decodeToPcm(A,e){var t=null==e?void 0:e.toLowerCase();if(!t||"pcm"===t)return A instanceof ArrayBuffer?A:A instanceof Uint8Array?A.buffer:A;var n=this.codecs[t];if(!n)throw new Error("Unsupported encoding: ".concat(e));var o=A instanceof Uint8Array?A:new Uint8Array(A);return n.decode(o)}encodeFromPcm(A,e){var t=null==e?void 0:e.toLowerCase();if(!t||"pcm"===t)return A;var n=this.codecs[t];if(!n)throw new Error("Unsupported target encoding: ".concat(e));var o=n.encode(A);return o instanceof Uint8Array?o.buffer:o}getCodec(A){var e=null==A?void 0:A.toLowerCase();return this.codecs[e]||null}};class v{static convert(A,e,t){if(e===t)return A;if(8===e)throw new Error("Source bit depth cannot be 8-bit (only 16-bit or 24-bit supported)");var n=e/8,o=t/8,r=A.byteLength/n;if(new ArrayBuffer(r*o),16===e&&16===t)return A;if(24===e&&16===t)return v.convert24To16(A);if(16===e&&24===t)return v.convert16To24(A);if(16===e&&8===t)return v.convert16To8(A);if(24===e&&8===t)return v.convert24To8(A);throw new Error("Unsupported bit depth conversion: ".concat(e,"-bit â ").concat(t,"-bit"))}static convert24To16(A){for(var e=new Uint8Array(A),t=Math.floor(e.length/3),n=new Int16Array(t),o=0;o<t;o++){var r=e[3*o],i=e[3*o+1],s=e[3*o+2],a=r|i<<8|(255&s)<<16;128&s&&(a|=4278190080),n[o]=Math.max(-32768,Math.min(32767,Math.round(a/256)))}return n.buffer}static convert16To24(A){for(var e=new Int16Array(A),t=new Uint8Array(3*e.length),n=0;n<e.length;n++){var o=256*e[n];t[3*n]=255&o,t[3*n+1]=o>>8&255,t[3*n+2]=o>>16&255}return t.buffer}static convert16To8(A){for(var e=new Int16Array(A),t=new Uint8Array(e.length),n=0;n<e.length;n++){var o=e[n];t[n]=Math.max(0,Math.min(255,Math.round(o/256+128)))}return t.buffer}static convert24To8(A){var e=v.convert24To16(A);return v.convert16To8(e)}}const Q=v;function F(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}const U=class{static resample(A,e,t){return(n=function*(){if(e===t)return A;for(var n=new Int16Array(A),o=new Float32Array(n.length),r=1/32768,i=0;i<n.length;i++)o[i]=n[i]*r;var s=Math.ceil(o.length*t/e),a=new OfflineAudioContext(1,s,t),c=a.createBuffer(1,o.length,e);c.getChannelData(0).set(o);var l=a.createBufferSource();l.buffer=c,l.connect(a.destination),l.start();for(var d=(yield a.startRendering()).getChannelData(0),u=new Int16Array(d.length),g=0;g<d.length;g++){var B=Math.max(-1,Math.min(1,d[g]));u[g]=Math.round(32767*B)}return u.buffer},function(){var A=this,e=arguments;return new Promise(function(t,o){var r=n.apply(A,e);function i(A){F(r,t,o,i,s,"next",A)}function s(A){F(r,t,o,i,s,"throw",A)}i(void 0)})})();var n}};class y{static convert(A,e,t){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:16;if(e===t)return A;if(1===e&&1===t)return A;if(1===e&&2===t)return y.monoToStereo(A,n);if(2===e&&1===t)return y.stereoToMono(A,n);throw new Error("Unsupported channel conversion: ".concat(e," â ").concat(t))}static monoToStereo(A,e){for(var t=e/8,n=A.byteLength/t,o=new ArrayBuffer(n*t*2),r=new Uint8Array(A),i=new Uint8Array(o),s=0;s<n;s++)for(var a=s*t,c=s*t*2,l=0;l<t;l++)i[c+l]=r[a+l],i[c+t+l]=r[a+l];return o}static stereoToMono(A,e){var t=e/8,n=A.byteLength/(2*t),o=new ArrayBuffer(n*t),r=new Uint8Array(A),i=new Uint8Array(o);if(16===e)for(var s=0;s<n;s++){var a=s*t*2,c=a+t,l=(r[a]|r[a+1]<<8)<<16>>16,d=(r[c]|r[c+1]<<8)<<16>>16,u=Math.round((l+d)/2),g=s*t;i[g]=255&u,i[g+1]=u>>8&255}else for(var B=0;B<n;B++)for(var h=B*t*2,p=B*t,w=0;w<t;w++)i[p+w]=r[h+w];return o}}const b=y;function E(A,e){var t=Object.keys(A);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(A);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(A,e).enumerable})),t.push.apply(t,n)}return t}function x(A){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?E(Object(t),!0).forEach(function(e){I(A,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(A,Object.getOwnPropertyDescriptors(t)):E(Object(t)).forEach(function(e){Object.defineProperty(A,e,Object.getOwnPropertyDescriptor(t,e))})}return A}function I(A,e,t){return(e=function(A){var e=function(A){if("object"!=typeof A||!A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var t=e.call(A,"string");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(A)}(A);return"symbol"==typeof e?e:e+""}(e))in A?Object.defineProperty(A,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):A[e]=t,A}function H(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}const S=class{constructor(A,e){this.requestedFormat=A,this.actualFormat=e,this.encodingConverter=new m,this.conversionSteps=[],this._analyzeConversions()}_analyzeConversions(){this.conversionSteps=[],this.actualFormat.container!==this.requestedFormat.container&&("wav"===this.actualFormat.container?this.conversionSteps.push("extract_wav"):"wav"===this.requestedFormat.container&&this.conversionSteps.push("wrap_wav")),this.actualFormat.encoding!==this.requestedFormat.encoding&&("pcm"!==this.actualFormat.encoding&&this.conversionSteps.push("decode_encoding"),"pcm"!==this.requestedFormat.encoding&&this.conversionSteps.push("encode_encoding")),this.actualFormat.sampleRate!==this.requestedFormat.sampleRate&&this.conversionSteps.push("resample"),this.actualFormat.bitDepth!==this.requestedFormat.bitDepth&&this.conversionSteps.push("convert_bitdepth"),this.actualFormat.channels!==this.requestedFormat.channels&&this.conversionSteps.push("convert_channels")}needsConversion(){return this.conversionSteps.length>0}getConversionSteps(){var A=[];return this.conversionSteps.includes("extract_wav")&&A.push("Extract PCM from WAV (".concat(this.actualFormat.container," â raw)")),this.conversionSteps.includes("decode_encoding")&&A.push("Decode ".concat(this.actualFormat.encoding.toUpperCase()," â PCM")),this.conversionSteps.includes("resample")&&A.push("Resample ".concat(this.actualFormat.sampleRate,"Hz â ").concat(this.requestedFormat.sampleRate,"Hz")),this.conversionSteps.includes("convert_bitdepth")&&A.push("Convert bit depth ".concat(this.actualFormat.bitDepth,"-bit â ").concat(this.requestedFormat.bitDepth,"-bit")),this.conversionSteps.includes("convert_channels")&&A.push("Convert channels ".concat(this.actualFormat.channels," â ").concat(this.requestedFormat.channels)),this.conversionSteps.includes("encode_encoding")&&A.push("Encode PCM â ".concat(this.requestedFormat.encoding.toUpperCase())),this.conversionSteps.includes("wrap_wav")&&A.push("Wrap in WAV container (raw â ".concat(this.requestedFormat.container,")")),A}convert(A){var e,t=this;return(e=function*(){if(!t.needsConversion())return A instanceof ArrayBuffer?A:A.buffer;var e=A instanceof ArrayBuffer?A:A.buffer,n=x({},t.actualFormat);if(t.conversionSteps.includes("extract_wav")){var o=C.extractPcmFromWav(e);e=o.pcmData,n=x(x({},n),{},{container:"raw",sampleRate:o.format.sampleRate,channels:o.format.channels,bitDepth:o.format.bitDepth}),console.log("đ AudioFormatConverter: Extracted PCM from WAV",o.format)}if(t.conversionSteps.includes("decode_encoding")&&(e=t.encodingConverter.decodeToPcm(e,n.encoding),n.encoding="pcm",n.bitDepth=16,console.log("đ AudioFormatConverter: Decoded ".concat(t.actualFormat.encoding.toUpperCase()," â PCM"))),24===n.bitDepth&&n.bitDepth!==t.requestedFormat.bitDepth&&(t.conversionSteps.includes("resample")||t.conversionSteps.includes("convert_channels")||24!==t.requestedFormat.bitDepth)&&(e=Q.convert(e,24,16),n.bitDepth=16,console.log("đ AudioFormatConverter: Normalized 24-bit â 16-bit PCM")),t.conversionSteps.includes("resample")&&(e=yield U.resample(e,n.sampleRate,t.requestedFormat.sampleRate),n.sampleRate=t.requestedFormat.sampleRate,console.log("đ AudioFormatConverter: Resampled ".concat(t.actualFormat.sampleRate,"Hz â ").concat(t.requestedFormat.sampleRate,"Hz"))),t.conversionSteps.includes("convert_channels")&&(e=b.convert(e,n.channels,t.requestedFormat.channels,n.bitDepth),n.channels=t.requestedFormat.channels,console.log("đ AudioFormatConverter: Converted channels ".concat(t.actualFormat.channels," â ").concat(t.requestedFormat.channels))),t.conversionSteps.includes("convert_bitdepth")&&(e=Q.convert(e,n.bitDepth,t.requestedFormat.bitDepth),n.bitDepth=t.requestedFormat.bitDepth,console.log("đ AudioFormatConverter: Converted bit depth ".concat(t.actualFormat.bitDepth,"-bit â ").concat(t.requestedFormat.bitDepth,"-bit"))),t.conversionSteps.includes("encode_encoding")){var r=t.encodingConverter.encodeFromPcm(e,t.requestedFormat.encoding);e=r instanceof ArrayBuffer?r:r.buffer,n.encoding=t.requestedFormat.encoding,console.log("đ AudioFormatConverter: Encoded PCM â ".concat(t.requestedFormat.encoding.toUpperCase()))}return t.conversionSteps.includes("wrap_wav")&&(e=C.wrapPcmInWav(e,n),n.container="wav",console.log("đ AudioFormatConverter: Wrapped in WAV container")),console.log("â
AudioFormatConverter: Conversion complete"),e},function(){var A=this,t=arguments;return new Promise(function(n,o){var r=e.apply(A,t);function i(A){H(r,n,o,i,s,"next",A)}function s(A){H(r,n,o,i,s,"throw",A)}i(void 0)})})()}};function D(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}const K=class{constructor(A){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>null;this.handlers=new Map,this.sendMessage=A,this.getConversationId=e}registerHandler(A,e){if("function"!=typeof e)throw new Error("Handler for tool '".concat(A,"' must be a function"));this.handlers.set(A,e),console.log("đ§ ClientTools: Registered handler for '".concat(A,"'"))}unregisterHandler(A){this.handlers.delete(A),console.log("đ§ ClientTools: Unregistered handler for '".concat(A,"'"))}hasHandler(A){return this.handlers.has(A)}getRegisteredTools(){return Array.from(this.handlers.keys())}handleToolCall(A){var e,t=this;return(e=function*(){var{toolCallId:e,toolName:n,parameters:o}=A,r=Date.now(),i=(new Date).toISOString();console.log("đ§ ClientTools: [".concat(i,"] Received tool call '").concat(n,"' (id: ").concat(e,")")),console.log(" đ Full message received:",JSON.stringify(A,null,2)),console.log(" âąī¸ Start time: ".concat(r,"ms (").concat(new Date(r).toISOString(),")"));var s=t.handlers.get(n);if(!s)return console.warn("đ§ ClientTools: No handler registered for '".concat(n,"'")),void t.sendError(e,n,"No handler registered for tool '".concat(n,"'"),"NO_HANDLER",r);try{var a=yield s(o),c=Date.now()-r;console.log("đ§ ClientTools: Tool '".concat(n,"' completed in ").concat(c,"ms")),t.sendResult(e,n,a,c)}catch(A){var l,d,u=Date.now()-r;console.error("đ§ ClientTools: Tool '".concat(n,"' failed:"),A);var g="EXECUTION_ERROR";"NotAllowedError"===A.name||null!==(l=A.message)&&void 0!==l&&l.includes("permission")?g="PERMISSION_DENIED":("NotSupportedError"===A.name||null!==(d=A.message)&&void 0!==d&&d.includes("not supported"))&&(g="API_UNAVAILABLE"),t.sendError(e,n,A.message||"Unknown error",g,u)}},function(){var A=this,t=arguments;return new Promise(function(n,o){var r=e.apply(A,t);function i(A){D(r,n,o,i,s,"next",A)}function s(A){D(r,n,o,i,s,"throw",A)}i(void 0)})})()}sendResult(A,e,t,n){var o=this.getConversationId(),r=(new Date).toISOString(),i={t:"client_tool_result",toolCallId:A,toolName:e,conversationId:o,result:t,executionTimeMs:n};console.log("đ§ ClientTools: [".concat(r,"] Sending result for tool '").concat(e,"'")),console.log(" đ toolCallId: ".concat(A)),console.log(" đ conversationId: ".concat(o||"null")),console.log(" đ toolName: ".concat(e)),console.log(" đ result:",t),console.log(" đ Full message:",JSON.stringify(i,null,2)),this.sendMessage(i),console.log("â
ClientTools: Result message sent at ".concat(r))}sendError(A,e,t,n,o){var r="number"==typeof o?Date.now()-o:o,i=(new Date).toISOString(),s=this.getConversationId(),a={t:"client_tool_error",toolCallId:A,toolName:e,conversationId:s,error:t,errorCode:n,executionTimeMs:r};console.log("đ§ ClientTools: [".concat(i,"] Sending error for tool '").concat(e,"'")),console.log(" đ toolCallId: ".concat(A)),console.log(" đ conversationId: ".concat(s||"null")),console.log(" đ toolName: ".concat(e)),console.log(" đ error: ".concat(t,", errorCode: ").concat(n)),console.log(" đ Full message:",JSON.stringify(a,null,2)),this.sendMessage(a),console.log("â
ClientTools: Error message sent at ".concat(i))}setSendMessage(A){this.sendMessage=A}};var T=r(354),k=r.n(T);function L(A,e){var t=Object.keys(A);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(A);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(A,e).enumerable})),t.push.apply(t,n)}return t}function P(A){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?L(Object(t),!0).forEach(function(e){R(A,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(A,Object.getOwnPropertyDescriptors(t)):L(Object(t)).forEach(function(e){Object.defineProperty(A,e,Object.getOwnPropertyDescriptor(t,e))})}return A}function R(A,e,t){return(e=function(A){var e=function(A){if("object"!=typeof A||!A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var t=e.call(A,"string");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(A)}(A);return"symbol"==typeof e?e:e+""}(e))in A?Object.defineProperty(A,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):A[e]=t,A}function O(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}var M={useCORS:!0,allowTaint:!1,backgroundColor:"#ffffff",scale:1,logging:!1,imageTimeout:15e3};function V(){return N.apply(this,arguments)}function N(){var A;return A=function*(){var A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{selector:e=null,format:t="jpeg",quality:n=.85,scale:o=1,maxWidth:r=1280,maxHeight:i=1280,fullPage:s=!1}=A;console.log("đ¸ SDK Screenshot: Starting capture with options:",A);var a=Date.now();try{var c=document.body;if(e){var l=document.querySelector(e);if(!l)throw new Error("Element not found: ".concat(e));c=l,console.log("đ¸ SDK Screenshot: Capturing element: ".concat(e))}else console.log("đ¸ SDK Screenshot: Capturing entire page");var d=P(P({},M),{},{scale:o});s&&!e&&(d.windowHeight=document.documentElement.scrollHeight,d.height=document.documentElement.scrollHeight,d.y=0);var u=yield k()(c,d);console.log("đ¸ SDK Screenshot: Canvas created (".concat(u.width,"x").concat(u.height,")"));var g=u;(r||i)&&(g=function(A,e,t){var{width:n,height:o}=A,r=1;if(e&&n>e&&(r=Math.min(r,e/n)),t&&o>t&&(r=Math.min(r,t/o)),1===r)return A;var i=Math.round(n*r),s=Math.round(o*r),a=document.createElement("canvas");return a.width=i,a.height=s,a.getContext("2d").drawImage(A,0,0,i,s),a}(u,r,i),g!==u&&console.log("đ¸ SDK Screenshot: Resized to ".concat(g.width,"x").concat(g.height)));var B="jpeg"===t?"image/jpeg":"image/png",h=g.toDataURL(B,"jpeg"===t?n:void 0).split(",")[1],p=Date.now()-a;return console.log("đ¸ SDK Screenshot: Capture completed in ".concat(p,"ms")),console.log("đ¸ SDK Screenshot: Size: ".concat(Math.round(h.length/1024),"KB")),{image:h,mimeType:B,width:g.width,height:g.height,captureTimeMs:p,selector:e||"body"}}catch(A){throw console.error("đ¸ SDK Screenshot: Capture failed:",A),new Error("Screenshot capture failed: ".concat(A.message))}},N=function(){var e=this,t=arguments;return new Promise(function(n,o){var r=A.apply(e,t);function i(A){O(r,n,o,i,s,"next",A)}function s(A){O(r,n,o,i,s,"throw",A)}i(void 0)})},N.apply(this,arguments)}function G(A,e){var t=Object.keys(A);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(A);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(A,e).enumerable})),t.push.apply(t,n)}return t}function _(A){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?G(Object(t),!0).forEach(function(e){X(A,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(A,Object.getOwnPropertyDescriptors(t)):G(Object(t)).forEach(function(e){Object.defineProperty(A,e,Object.getOwnPropertyDescriptor(t,e))})}return A}function W(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}function J(A){return function(){var e=this,t=arguments;return new Promise(function(n,o){var r=A.apply(e,t);function i(A){W(r,n,o,i,s,"next",A)}function s(A){W(r,n,o,i,s,"throw",A)}i(void 0)})}}function X(A,e,t){return(e=function(A){var e=function(A){if("object"!=typeof A||!A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var t=e.call(A,"string");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(A)}(A);return"symbol"==typeof e?e:e+""}(e))in A?Object.defineProperty(A,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):A[e]=t,A}class Y extends a{constructor(){var A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.version="2.0.0",this.config={signedUrl:A.signedUrl||A.websocketUrl||"wss://speech.talktopc.com/ws/conv",websocketUrl:A.signedUrl||A.websocketUrl||"wss://speech.talktopc.com/ws/conv",agentId:A.agentId,appId:A.appId,sampleRate:A.sampleRate||16e3,channels:A.channels||1,bitDepth:A.bitDepth||16,audioProcessorPath:A.audioProcessorPath,outputContainer:A.outputContainer||this.getDefaultContainer(A),outputEncoding:A.outputEncoding||A.outputCodec||"pcm",outputSampleRate:A.outputSampleRate||16e3,outputChannels:A.outputChannels||1,outputBitDepth:A.outputBitDepth||16,outputFrameDurationMs:A.outputFrameDurationMs||600,outputCodec:A.outputCodec,agentSettingsOverride:A.agentSettingsOverride||null,variables:A.variables||null,autoReconnect:!1!==A.autoReconnect,protocolVersion:A.protocolVersion||2},this.isConnected=!1,this.hasEverConnected=!1,this.isRecording=!1,this.isPlaying=!1,this.isDestroyed=!1,this.outputAudioFormat=null,this.requestedOutputFormat=null,this.formatConverter=null,this.websocket=null,this.conversationId=null,this.transcriptQueue=[],this.currentPlayingSentenceId=null,this.audioFrameCount=0,this.audioPlayer=new B(this.config),this.audioRecorder=new w(this.config),this.setupAudioPlayerEvents(),this.setupAudioRecorderEvents(),this.clientToolsRegistry=new K(A=>this.sendMessage(A),()=>this.conversationId),this._registerBuiltInTools(),this.validateConfig(),this._setupPageUnloadHandler(),console.log("đĩ VoiceSDK v2 initialized:",{version:this.version,outputContainer:this.config.outputContainer,outputEncoding:this.config.outputEncoding,outputSampleRate:this.config.outputSampleRate})}_registerBuiltInTools(){var A=this;console.log("đ¸ VoiceSDK: _registerBuiltInTools() called"),console.log("đ¸ VoiceSDK: captureScreenshot available?",void 0!==V);try{if(void 0===V)return console.error("â VoiceSDK: captureScreenshot is undefined - import may have failed"),void console.error(" This will prevent capture_screen tool from working");console.log("đ¸ VoiceSDK: Registering capture_screen tool, captureScreenshot type:",typeof V),this.clientToolsRegistry.registerHandler("capture_screen",J(function*(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};console.log("đ¸ VoiceSDK: capture_screen tool called with params:",e);var{selector:t=null,format:n="jpeg",quality:o=.85,scale:r=1,fullPage:i=!1,maxWidth:s=1280,maxHeight:a=1280}=e;try{var c=yield V({selector:t,format:n,quality:o,scale:r,fullPage:i,maxWidth:s,maxHeight:a});return console.log("đ¸ VoiceSDK: Screenshot captured: ".concat(c.width,"x").concat(c.height,", ").concat(Math.round(c.image.length/1024),"KB")),A.emit("screenshotCaptured",{width:c.width,height:c.height,sizeKB:Math.round(c.image.length/1024),selector:c.selector}),c}catch(e){throw console.error("đ¸ VoiceSDK: Screenshot capture failed:",e),A.emit("screenshotError",{error:e.message}),e}})),console.log("đ¸ VoiceSDK: Built-in capture_screen tool registered")}catch(A){console.error("â VoiceSDK: Error registering built-in tools:",A),console.error(" Error details:",A.message,A.stack)}}getStoredConversationId(){try{if("undefined"==typeof sessionStorage)return console.warn("â ī¸ VoiceSDK v2: sessionStorage not available (private mode?)"),null;var A=sessionStorage.getItem(Y.RESUME_STORAGE_KEY);if(A){var e=JSON.parse(A);if(e&&e.conversationId)return console.log("đĻ VoiceSDK v2: Found stored conversationId:",e.conversationId),e.conversationId}return null}catch(A){return console.warn("â ī¸ VoiceSDK v2: Error reading sessionStorage:",A),null}}storeConversationId(A){if(A)try{if("undefined"==typeof sessionStorage)return void console.warn("â ī¸ VoiceSDK v2: sessionStorage not available (private mode?)");var e={},t=sessionStorage.getItem(Y.RESUME_STORAGE_KEY);if(t)try{e=JSON.parse(t)}catch(A){}e.conversationId=A,e.timestamp=Date.now(),e.fromPage=e.fromPage||window.location.pathname+window.location.search,sessionStorage.setItem(Y.RESUME_STORAGE_KEY,JSON.stringify(e)),console.log("đž VoiceSDK v2: Stored conversationId:",A)}catch(A){console.warn("â ī¸ VoiceSDK v2: Error writing to sessionStorage:",A)}}clearStoredConversationId(){try{if("undefined"==typeof sessionStorage)return;sessionStorage.removeItem(Y.RESUME_STORAGE_KEY),console.log("đī¸ VoiceSDK v2: Cleared stored conversationId")}catch(A){console.warn("â ī¸ VoiceSDK v2: Error clearing sessionStorage:",A)}}_getResumeState(){try{if("undefined"==typeof sessionStorage)return null;var A=sessionStorage.getItem(Y.RESUME_STORAGE_KEY);if(!A)return null;var e=JSON.parse(A),t=Date.now()-e.timestamp;return t>Y.RESUME_TTL_MS?(console.log("[VoiceSDK] Resume state expired:",t,"ms"),this._clearResumeState(),null):(console.log("[VoiceSDK] Found valid resume state:",e,"age:",t,"ms"),e)}catch(A){return console.warn("[VoiceSDK] Failed to get resume state:",A),null}}_clearResumeState(){try{if("undefined"==typeof sessionStorage)return;sessionStorage.removeItem(Y.RESUME_STORAGE_KEY)}catch(A){}}_setupPageUnloadHandler(){window.addEventListener("beforeunload",()=>{this.conversationId&&this.websocket&&this.websocket.readyState===WebSocket.OPEN&&this.storeConversationId(this.conversationId)}),document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&this.conversationId&&this.websocket&&this.websocket.readyState===WebSocket.OPEN&&this.storeConversationId(this.conversationId)})}checkAndResume(){var A=this._getResumeState();if(!A)return null;var e=window.location.pathname+window.location.search;return console.log("[VoiceSDK] Auto-resuming conversation:",A.conversationId),console.log("[VoiceSDK] Page change:",A.fromPage,"â",e),{conversationId:A.conversationId,fromPage:A.fromPage,toPage:e}}getDefaultContainer(A){return"wav"===A.outputCodec?"wav":"raw"}validateInputFormat(A){var e;if(!A)return"Input format is required";var t=null===(e=A.encoding)||void 0===e?void 0:e.toLowerCase();return t&&Y.SUPPORTED_INPUT_ENCODINGS.includes(t)?A.sampleRate&&Y.SUPPORTED_INPUT_SAMPLE_RATES.includes(A.sampleRate)?A.bitDepth&&Y.SUPPORTED_INPUT_BIT_DEPTHS.includes(A.bitDepth)?A.channels&&Y.SUPPORTED_INPUT_CHANNELS.includes(A.channels)?null:"Unsupported input channels: ".concat(A.channels,". Supported: ").concat(Y.SUPPORTED_INPUT_CHANNELS.join(", ")):"Unsupported input bit depth: ".concat(A.bitDepth,". Supported: ").concat(Y.SUPPORTED_INPUT_BIT_DEPTHS.join(", ")):"Unsupported input sample rate: ".concat(A.sampleRate,". Supported: ").concat(Y.SUPPORTED_INPUT_SAMPLE_RATES.join(", ")):"Unsupported input encoding: ".concat(A.encoding,". Supported: ").concat(Y.SUPPORTED_INPUT_ENCODINGS.join(", "))}validateOutputFormat(A){var e,t;if(!A)return"Output format is required";var n=null===(e=A.encoding)||void 0===e?void 0:e.toLowerCase();if(!n||!Y.SUPPORTED_OUTPUT_ENCODINGS.includes(n))return"Unsupported output encoding: ".concat(A.encoding,". Supported: ").concat(Y.SUPPORTED_OUTPUT_ENCODINGS.join(", "));if(!A.sampleRate||!Y.SUPPORTED_OUTPUT_SAMPLE_RATES.includes(A.sampleRate))return"Unsupported output sample rate: ".concat(A.sampleRate,". Supported: ").concat(Y.SUPPORTED_OUTPUT_SAMPLE_RATES.join(", "));if(!A.bitDepth||!Y.SUPPORTED_OUTPUT_BIT_DEPTHS.includes(A.bitDepth))return"Unsupported output bit depth: ".concat(A.bitDepth,". Supported: ").concat(Y.SUPPORTED_OUTPUT_BIT_DEPTHS.join(", "));if(!A.channels||!Y.SUPPORTED_OUTPUT_CHANNELS.includes(A.channels))return"Unsupported output channels: ".concat(A.channels,". Supported: ").concat(Y.SUPPORTED_OUTPUT_CHANNELS.join(", "));var o=null===(t=A.container)||void 0===t?void 0:t.toLowerCase();return o&&Y.SUPPORTED_OUTPUT_CONTAINERS.includes(o)?null:"Unsupported output container: ".concat(A.container,". Supported: ").concat(Y.SUPPORTED_OUTPUT_CONTAINERS.join(", "))}validateConfig(){var A={encoding:"pcm",sampleRate:this.config.sampleRate,channels:this.config.channels,bitDepth:this.config.bitDepth},e=this.validateInputFormat(A);if(e)return console.error("â VoiceSDK v2: Invalid input format:",e),void this.emit("error",new Error(e));var t={encoding:this.config.outputEncoding,sampleRate:this.config.outputSampleRate,channels:this.config.outputChannels,bitDepth:this.config.outputBitDepth,container:this.config.outputContainer},n=this.validateOutputFormat(t);if(n)return console.error("â VoiceSDK v2: Invalid output format:",n),void this.emit("error",new Error(n));console.log("â
VoiceSDK v2: Format validation passed")}setupAudioPlayerEvents(){this.audioPlayer.on("playbackStarted",()=>{this.isPlaying=!0,this.emit("playbackStarted"),this.isConnected?(console.log("đ¤ VoiceSDK v2: Sending audio_started_playing message to server"),this.sendMessage({t:"audio_started_playing"})):console.warn("â ī¸ VoiceSDK v2: Cannot send audio_started_playing - not connected")}),this.audioPlayer.on("transcriptDisplay",A=>{var e=this.currentPlayingSentenceId?this.currentPlayingSentenceId+1:1;this.currentPlayingSentenceId=e;var t={text:A.text,role:"assistant",sentenceId:e,final:!0,timestamp:Date.now()};console.log("đ VoiceSDK v2: Emitting synced transcriptDisplay from AudioPlayer:",t),this.emit("transcriptDisplay",t),this.emit("transcript",t)}),this.audioPlayer.on("playbackStopped",()=>{this.isPlaying=!1,this.emit("playbackStopped"),this.isConnected?(console.log("đ¤ VoiceSDK v2: Sending audio_stopped_playing message to server"),this.sendMessage({t:"audio_stopped_playing"})):console.warn("â ī¸ VoiceSDK v2: Cannot send audio_stopped_playing - not connected")}),this.audioPlayer.on("playbackError",A=>{this.emit("playbackError",A),this.emit("error",A)})}setupAudioRecorderEvents(){this.audioRecorder.on("recordingStarted",()=>{this.isRecording=!0,this.emit("recordingStarted")}),this.audioRecorder.on("recordingStopped",()=>{this.isRecording&&(this.isRecording=!1,this.emit("recordingStopped"),console.log("đ VoiceSDK v2: Recording stopped (from audioRecorder event)"))}),this.audioRecorder.on("audioData",A=>{this.isConnected&&this.sendBinary(A)}),this.audioRecorder.on("error",A=>{console.error("â AudioRecorder error:",A),this.emit("error",A)})}buildWebSocketUrl(){var A=this.config.signedUrl||this.config.websocketUrl,e=new URL(A,"wss://placeholder.com"),t=e.searchParams;this.config.agentId&&!t.has("agentId")&&t.append("agentId",this.config.agentId),this.config.appId&&!t.has("appId")&&t.append("appId",this.config.appId);var n=this.getStoredConversationId();n&&!t.has("conversationId")&&(t.append("conversationId",n),console.log("đ VoiceSDK v2: Attempting resume via query param:",n));var o=window.location.pathname+window.location.search;o&&!t.has("currentPage")&&t.append("currentPage",o);var r=t.toString();return r?"".concat(e.origin).concat(e.pathname,"?").concat(r):"".concat(e.origin).concat(e.pathname)}connect(){var A=this;return J(function*(){if(A.isDestroyed)return console.warn("VoiceSDK v2: Cannot connect - SDK is destroyed"),!1;if(A.isConnected)return console.warn("VoiceSDK v2: Already connected"),!0;try{var e=A.buildWebSocketUrl();return console.log("đ VoiceSDK v2: Connecting to",e),yield new Promise((t,n)=>{A.websocket=new WebSocket(e),A.websocket.onopen=()=>{console.log("â
VoiceSDK v2: WebSocket connected"),A.isConnected=!0,A.hasEverConnected=!0,A.clientToolsRegistry&&A.clientToolsRegistry.setSendMessage(e=>A.sendMessage(e)),A.sendHelloMessage(),A.emit("connected"),t(!0)},A.websocket.onerror=A=>{console.error("â VoiceSDK v2: WebSocket error:",A),n(A)},A.websocket.onclose=e=>{console.log("đ VoiceSDK v2: WebSocket closed:",e.code,e.reason),A.isConnected=!1,A.isRecording&&A.stopRecording().catch(A=>console.error("Error stopping recording:",A)),A.emit("disconnected",e),A.config.autoReconnect&&!A.isDestroyed&&A.hasEverConnected?(console.log("đ VoiceSDK v2: Auto-reconnecting in 3s..."),setTimeout(()=>{A.isDestroyed||A.isConnected||A.connect()},3e3)):A.config.autoReconnect&&!A.hasEverConnected&&console.log("â ī¸ VoiceSDK v2: Initial connection failed. Auto-reconnect disabled to prevent retry loop.")},A.websocket.onmessage=e=>{A.handleMessage(e)}})}catch(e){return console.error("đ VoiceSDK v2: Connection failed:",e),A.emit("error",e),!1}})()}sendHelloMessage(){if(this.isConnected){var A={encoding:"pcm",sampleRate:this.config.sampleRate,channels:this.config.channels,bitDepth:this.config.bitDepth},e={encoding:this.config.outputEncoding,sampleRate:this.config.outputSampleRate,channels:this.config.outputChannels,bitDepth:this.config.outputBitDepth,container:this.config.outputContainer},t=this.validateInputFormat(A);if(t)return console.error("â VoiceSDK v2: Cannot send hello - invalid input format:",t),void this.emit("error",new Error("Invalid input format: ".concat(t)));var n=this.validateOutputFormat(e);if(n)return console.error("â VoiceSDK v2: Cannot send hello - invalid output format:",n),void this.emit("error",new Error("Invalid output format: ".concat(n)));var o={t:"hello",v:this.config.protocolVersion,inputFormat:A,requestedOutputFormat:e,outputFrameDurationMs:this.config.outputFrameDurationMs};this.config.agentSettingsOverride&&(o.agentSettingsOverride=this.config.agentSettingsOverride),console.log("đ VoiceSDK v2: Checking variables:",{hasVariables:!!this.config.variables,variables:this.config.variables,keys:this.config.variables?Object.keys(this.config.variables):[]}),this.config.variables&&Object.keys(this.config.variables).length>0?(o.variables=this.config.variables,console.log("đ VoiceSDK v2: Including variables in hello:",Object.keys(this.config.variables))):console.log("â ī¸ VoiceSDK v2: Variables NOT included - condition failed"),console.log("đ¤ VoiceSDK v2: Sending hello:",{version:o.v,requestedFormat:o.requestedOutputFormat,variables:o.variables?Object.keys(o.variables):void 0}),console.log("đ¤ VoiceSDK v2: Requested output format:",{container:o.requestedOutputFormat.container,encoding:o.requestedOutputFormat.encoding,sampleRate:o.requestedOutputFormat.sampleRate,bitDepth:o.requestedOutputFormat.bitDepth}),console.log("đ¤ VoiceSDK v2: Full hello message being sent:",JSON.stringify(o,null,2));try{this.sendMessage(o)}catch(A){console.error("VoiceSDK v2: Failed to send hello:",A),this.emit("error",A)}}else console.warn("VoiceSDK v2: Cannot send hello - not connected")}handleMessage(A){if(A.data instanceof ArrayBuffer||A.data instanceof Blob)this.handleBinaryMessage(A.data);else try{var e=JSON.parse(A.data);switch("audio"!==e.t&&console.log("đĨ VoiceSDK v2: Received message type:",e.t,"Full message:",JSON.stringify(e).substring(0,200)),!this.conversationId&&e.conversationId&&(this.conversationId=e.conversationId,console.log("đ VoiceSDK v2: Captured conversationId from message:",this.conversationId),this.emit("conversationIdChanged",this.conversationId)),"audio"!==e.t&&console.log("đ¨ VoiceSDK v2: Received message type:",e.t,e),e.t){case"hello_ack":this.handleHelloAck(e);break;case"transcript":console.log("đ VoiceSDK v2: Processing transcript message:",e),this.handleTranscript(e);break;case"user_transcript":console.log("đ VoiceSDK v2: Received user_transcript:",e),this.emit("message",e);break;case"agent_response":if(console.log("đ VoiceSDK v2: Received agent_response:",e),(e.text||e.transcript)&&(console.log("đ VoiceSDK v2: agent_response contains transcript data:",e.text||e.transcript),e.sentenceId&&(e.text||e.transcript))){var t={t:"transcript",sentenceId:e.sentenceId,text:e.text||e.transcript,role:e.role||"assistant",final:!1!==e.final,timestamp:e.timestamp||Date.now()};console.log("đ VoiceSDK v2: Converting agent_response to transcript:",t),this.handleTranscript(t)}this.emit("message",e);break;case"error":this.emit("message",e);break;case"barge_in":this.emit("bargeIn",e),this.stopAudioPlayback();break;case"stop_playing":this.emit("stopPlaying",e),this.stopAudioPlayback();break;case"audio_start":console.log("đ VoiceSDK v2: Received audio_start with text:",e.text),e.text&&this.audioPlayer&&this.audioPlayer.markNewSentence(e.text),this.emit("message",e);break;case"client_tool_call":this.clientToolsRegistry.handleToolCall(e);break;case"hangup_ack":console.log("đ VoiceSDK v2: Hangup acknowledged by server"),this.websocket&&this.websocket.readyState===WebSocket.OPEN&&(this.websocket.close(1e3,"User hangup"),this.websocket=null),this.isConnected=!1,this.emit("hangupAcknowledged");break;default:if(console.log("VoiceSDK v2: Unknown message type:",e.t,"Full message:",JSON.stringify(e).substring(0,300)),(e.text||e.transcript||e.transcription)&&(console.log("đ VoiceSDK v2: Unknown message contains transcript-like data:",{text:e.text,transcript:e.transcript,transcription:e.transcription,sentenceId:e.sentenceId,role:e.role}),e.sentenceId&&(e.text||e.transcript||e.transcription))){var n={t:"transcript",sentenceId:e.sentenceId,text:e.text||e.transcript||e.transcription,role:e.role||"assistant",final:!1!==e.final,timestamp:e.timestamp||Date.now()};console.log("đ VoiceSDK v2: Attempting to process unknown message as transcript:",n),this.handleTranscript(n)}this.emit("message",e)}}catch(A){console.error("VoiceSDK v2: Error parsing message:",A)}}handleHelloAck(A){if(console.log("đĨ VoiceSDK v2: Received hello_ack:",{hasOutputFormat:!!A.outputAudioFormat,outputFormat:A.outputAudioFormat,hasConversationId:!!A.conversationId,messageType:A.t}),A.conversationId&&(this.conversationId=A.conversationId,console.log("đ VoiceSDK v2: Received conversationId:",this.conversationId),this.emit("conversationIdChanged",this.conversationId),this.storeConversationId(this.conversationId)),!0===A.resumed?(console.log("â
VoiceSDK v2: Conversation resumed successfully"),this.emit("callResumed",{conversationId:this.conversationId,timestamp:Date.now()})):!1===A.resumed&&A.resumeRejectedReason&&(console.warn("â ī¸ VoiceSDK v2: Resume rejected:",A.resumeRejectedReason),this.clearStoredConversationId(),this.emit("resumeRejected",{reason:A.resumeRejectedReason,conversationId:A.conversationId||null,timestamp:Date.now()})),A.outputAudioFormat){this.outputAudioFormat=A.outputAudioFormat,this.audioPlayer.setOutputFormat(A.outputAudioFormat),console.log("â
VoiceSDK v2: Format negotiated by server:",this.outputAudioFormat),this.requestedOutputFormat={container:this.config.outputContainer||"wav",encoding:this.config.outputEncoding||"pcm",sampleRate:this.config.outputSampleRate||16e3,bitDepth:this.config.outputBitDepth||16,channels:this.config.outputChannels||1};var e={container:this.outputAudioFormat.container||"unknown",encoding:this.outputAudioFormat.encoding||"unknown",sampleRate:this.outputAudioFormat.sampleRate||0,bitDepth:this.outputAudioFormat.bitDepth||0,channels:this.outputAudioFormat.channels||0},t=[];if(this.requestedOutputFormat.container!==e.container&&t.push('container: "'.concat(this.requestedOutputFormat.container,'" â "').concat(e.container,'"')),this.requestedOutputFormat.encoding!==e.encoding&&t.push('encoding: "'.concat(this.requestedOutputFormat.encoding,'" â "').concat(e.encoding,'"')),this.requestedOutputFormat.sampleRate!==e.sampleRate&&t.push("sampleRate: ".concat(this.requestedOutputFormat.sampleRate,"Hz â ").concat(e.sampleRate,"Hz")),this.requestedOutputFormat.bitDepth!==e.bitDepth&&t.push("bitDepth: ".concat(this.requestedOutputFormat.bitDepth,"-bit â ").concat(e.bitDepth,"-bit")),this.requestedOutputFormat.channels!==e.channels&&t.push("channels: ".concat(this.requestedOutputFormat.channels," â ").concat(e.channels)),t.length>0){console.warn("â ī¸ VoiceSDK v2: Format negotiation mismatch!"),console.warn(" Requested:",this.requestedOutputFormat),console.warn(" Negotiated:",e),console.warn(" Differences:",t.join(", "));try{if(this.formatConverter=new S(this.requestedOutputFormat,e),this.formatConverter.needsConversion()){var n=this.formatConverter.getConversionSteps();console.log("đ VoiceSDK v2: Format conversion enabled"),console.log(" Conversion steps:",n.join(", ")),console.log(" Audio will be automatically converted to requested format")}}catch(A){console.error("â VoiceSDK v2: Failed to create format converter:",A),console.warn(" Will use backend format without conversion"),this.formatConverter=null}}else console.log("â
VoiceSDK v2: Format perfectly matched!",e),this.formatConverter=null;this.emit("formatNegotiated",this.outputAudioFormat)}else{this.config.protocolVersion>=2?(console.warn("â ī¸ VoiceSDK v2: hello_ack received but no outputAudioFormat in response."),console.warn(" This may happen if:"),console.warn(" 1. Backend is not sending outputAudioFormat (check backend logs)"),console.warn(" 2. Hello message missing v2 fields (v, inputFormat, requestedOutputFormat)"),console.warn(" 3. Backend validation failed (check backend error logs)"),console.warn(" Using default format from config...")):console.log("â
VoiceSDK v2: Connected (v1 legacy mode)");var o={container:this.config.outputContainer||"wav",encoding:this.config.outputEncoding||"pcm",sampleRate:this.config.outputSampleRate||16e3,channels:this.config.outputChannels||1,bitDepth:this.config.outputBitDepth||16};this.outputAudioFormat=o,this.requestedOutputFormat=o,this.audioPlayer.setOutputFormat(o),this.formatConverter=null}}handleTranscript(A){if(A.sentenceId&&A.text){var e=A.sentenceId,t={text:A.text,role:A.role||"assistant",sentenceId:e,final:!1!==A.final,timestamp:A.timestamp||Date.now()};this.transcriptQueue.push(t),console.log("đ VoiceSDK v2: Received transcript for sentence",e,":",t.text),console.log(" Transcript queue length:",this.transcriptQueue.length),console.log(" Current playing sentence:",this.currentPlayingSentenceId),console.log("đ VoiceSDK v2: Displaying transcript for completed sentence",e),this.emit("transcriptDisplay",t),this.currentPlayingSentenceId=e,this.emit("transcript",t)}else console.warn("â ī¸ VoiceSDK v2: Invalid transcript message:",A)}handleBinaryMessage(A){var e=this;return J(function*(){var t,n=t=A instanceof Blob?yield A.arrayBuffer():A;if(e.formatConverter&&e.formatConverter.needsConversion())try{n=yield e.formatConverter.convert(t),console.log("â
VoiceSDK v2: Audio converted to requested format")}catch(A){console.error("â VoiceSDK v2: Format conversion failed:",A),console.warn(" Using backend format without conversion"),n=t}var o=e.formatConverter&&e.formatConverter.needsConversion()?e.requestedOutputFormat:e.outputAudioFormat||{container:e.config.outputContainer||"raw",encoding:e.config.outputEncoding||"pcm",sampleRate:e.config.outputSampleRate||16e3,bitDepth:e.config.outputBitDepth||16,channels:e.config.outputChannels||1},r=o.container||"raw",i=(o.encoding||"pcm").toLowerCase();if("raw"===r){var s=n;if("pcm"!==i){var a=e.audioPlayer.getCodec(i);if(a){var c=a.decode(new Uint8Array(n));s=c.buffer,console.log("đ VoiceSDK v2: Decoded ".concat(i.toUpperCase()," to PCM (").concat(c.byteLength," bytes)"))}else console.warn("â ī¸ VoiceSDK v2: No codec for ".concat(i,", treating as PCM"))}e.audioPlayer.outputFormat||(console.warn("â ī¸ VoiceSDK v2: outputFormat not set on AudioPlayer, setting from playbackFormat"),e.audioPlayer.setOutputFormat(o)),e.audioFrameCount++,e.audioPlayer.playChunk(s)}else e.audioFrameCount++,e.audioPlayer.playAudio(n)})()}sendMessage(A){if(!this.websocket||this.websocket.readyState!==WebSocket.OPEN)return console.warn("VoiceSDK v2: Cannot send message - not connected"),!1;try{var e=(new Date).toISOString(),t=this.websocket?this.websocket.readyState:"NO_WEBSOCKET",n=this.websocket?{0:"CONNECTING",1:"OPEN",2:"CLOSING",3:"CLOSED"}[t]:"NO_WEBSOCKET";if("client_tool_result"!==A.t&&"client_tool_error"!==A.t||(console.log("đ¤ VoiceSDK v2: [".concat(e,"] Sending tool ").concat(A.t)),console.log(" đ WebSocket state: ".concat(n," (").concat(t,")")),console.log(" đ toolCallId: ".concat(A.toolCallId)),console.log(" đ conversationId: ".concat(A.conversationId||"null")),console.log(" đ toolName: ".concat(A.toolName)),"client_tool_result"===A.t?console.log(" đ result:",A.result):console.log(" đ error: ".concat(A.error,", errorCode: ").concat(A.errorCode)),console.log(" đ Full message:",JSON.stringify(A,null,2))),!this.websocket||this.websocket.readyState!==WebSocket.OPEN)return console.error("â VoiceSDK v2: Cannot send message - WebSocket not open (state: ".concat(n,")")),!1;var o=JSON.stringify(A);return this.websocket.send(o),"client_tool_result"!==A.t&&"client_tool_error"!==A.t||console.log("â
VoiceSDK v2: [".concat(e,"] Tool ").concat(A.t," message sent successfully (").concat(o.length," bytes)")),!0}catch(A){return console.error("VoiceSDK v2: Error sending message:",A),this.emit("error",A),!1}}sendBinary(A){if(!this.websocket||this.websocket.readyState!==WebSocket.OPEN)return console.warn("VoiceSDK v2: Cannot send audio - not connected"),!1;try{return this.websocket.send(A),!0}catch(A){return console.error("VoiceSDK v2: Error sending audio:",A),this.emit("error",A),!1}}hangup(){if(this.websocket&&this.websocket.readyState===WebSocket.OPEN){console.log("đ VoiceSDK v2: Hanging up call..."),this.clearStoredConversationId(),this.stopRecording(),this.audioPlayer&&this.stopAudioPlayback();try{this.sendMessage({t:"hangup"}),setTimeout(()=>{this.websocket&&this.websocket.readyState===WebSocket.OPEN&&(this.websocket.close(1e3,"User hangup"),this.websocket=null),this.isConnected=!1},100)}catch(A){console.error("VoiceSDK v2: Error sending hangup message:",A),this.websocket&&(this.websocket.close(1e3,"User hangup"),this.websocket=null),this.isConnected=!1}}else console.warn("đ VoiceSDK v2: Cannot hangup - WebSocket not open")}startRecording(){var A=this;return J(function*(){if(!A.isConnected){var e=new Error("Not connected to voice server");throw A.emit("error",e),e}if(A.isRecording)return console.warn("VoiceSDK v2: Already recording"),!0;console.log("đ¤ VoiceSDK v2: Starting recording...");try{return console.log("đ¤ VoiceSDK v2: Requesting microphone permission (mobile-friendly)..."),yield A.audioRecorder.start(),yield A.audioPlayer.resumeAudioContext(),A.sendMessage({t:"start_continuous_mode",ttpId:A.generateTtpId()}),!0}catch(e){if(console.error("â VoiceSDK v2: Failed to start recording:",e),"NotAllowedError"===e.name||"PermissionDeniedError"===e.name){var t=new Error("Microphone permission denied. Please allow microphone access in your browser settings and try again.");t.name=e.name,t.originalError=e,A.emit("error",t)}else A.emit("error",e);return!1}})()}stopRecording(){var A=this;return J(function*(){if(!A.isRecording)return console.warn("VoiceSDK v2: Not recording"),!0;console.log("đ VoiceSDK v2: Stopping recording...");try{return A.sendMessage({t:"stop_continuous_mode",ttpId:A.generateTtpId()}),A.isRecording=!1,A.emit("recordingStopped"),console.log("đ VoiceSDK v2: Recording stopped (emitted before audioRecorder.stop())"),yield A.audioRecorder.stop(),A.stopAudioPlayback(),!0}catch(e){return console.error("VoiceSDK v2: Error stopping recording:",e),A.emit("error",e),!1}})()}toggleRecording(){var A=this;return J(function*(){return A.isRecording?yield A.stopRecording():yield A.startRecording()})()}clearTranscriptState(){this.currentPlayingSentenceId=null,console.log("đ VoiceSDK v2: Cleared transcript state")}stopAudioPlayback(){this.audioPlayer.stopImmediate(),this.clearTranscriptState()}handleBargeIn(){var A=this;return J(function*(){A.stopAudioPlayback(),A.isRecording||(yield A.startRecording())})()}getStatus(){return{version:this.version,isConnected:this.isConnected,isRecording:this.isRecording,isPlaying:this.isPlaying,outputFormat:this.outputAudioFormat,conversationId:this.conversationId,audioPlayer:this.audioPlayer.getStatus(),audioRecorder:this.audioRecorder.getStatus()}}updateConfig(A){this.config=_(_({},this.config),A)}generateTtpId(){return"sdk_"+Math.random().toString(36).substr(2,9)+"_"+Date.now()}registerToolHandler(A,e){return this.clientToolsRegistry.registerHandler(A,e)}unregisterToolHandler(A){return this.clientToolsRegistry.unregisterHandler(A)}hasToolHandler(A){return this.clientToolsRegistry.hasHandler(A)}getRegisteredTools(){return this.clientToolsRegistry.getRegisteredTools()}destroy(){this.isDestroyed||(console.log("đī¸ VoiceSDK v2: Destroying..."),this.isDestroyed=!0,this.isRecording&&this.stopRecording(),this.audioPlayer&&this.stopAudioPlayback(),this.websocket&&(this.websocket.close(),this.websocket=null),this.isConnected=!1,this.audioPlayer&&this.audioPlayer.destroy(),this.audioRecorder&&this.audioRecorder.destroy(),this.clientToolsRegistry&&this.clientToolsRegistry.getRegisteredTools().forEach(A=>this.clientToolsRegistry.unregisterHandler(A)),this.removeAllListeners())}}X(Y,"RESUME_STORAGE_KEY","voice_resume_state"),X(Y,"RESUME_TTL_MS",1e4),X(Y,"SUPPORTED_INPUT_ENCODINGS",["pcm","pcmu","pcma"]),X(Y,"SUPPORTED_INPUT_SAMPLE_RATES",[8e3,16e3,22050,24e3,44100,48e3]),X(Y,"SUPPORTED_INPUT_BIT_DEPTHS",[8,16,24]),X(Y,"SUPPORTED_INPUT_CHANNELS",[1]),X(Y,"SUPPORTED_OUTPUT_ENCODINGS",["pcm","pcmu","pcma"]),X(Y,"SUPPORTED_OUTPUT_SAMPLE_RATES",[8e3,16e3,22050,24e3,44100,48e3]),X(Y,"SUPPORTED_OUTPUT_BIT_DEPTHS",[8,16,24]),X(Y,"SUPPORTED_OUTPUT_CHANNELS",[1]),X(Y,"SUPPORTED_OUTPUT_CONTAINERS",["raw","wav"]);const z=Y;class j{constructor(){this.events={}}on(A,e){this.events[A]||(this.events[A]=[]),this.events[A].push(e)}off(A,e){this.events[A]&&(this.events[A]=this.events[A].filter(A=>A!==e))}emit(A){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];this.events[A]&&this.events[A].forEach(e=>{try{e(...t)}catch(e){console.error("Error in event listener for ".concat(A,":"),e)}})}removeAllListeners(A){A?delete this.events[A]:this.events={}}}function Z(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}function q(A,e){var t=Object.keys(A);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(A);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(A,e).enumerable})),t.push.apply(t,n)}return t}function $(A){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?q(Object(t),!0).forEach(function(e){AA(A,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(A,Object.getOwnPropertyDescriptors(t)):q(Object(t)).forEach(function(e){Object.defineProperty(A,e,Object.getOwnPropertyDescriptor(t,e))})}return A}function AA(A,e,t){return(e=function(A){var e=function(A){if("object"!=typeof A||!A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var t=e.call(A,"string");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(A)}(A);return"symbol"==typeof e?e:e+""}(e))in A?Object.defineProperty(A,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):A[e]=t,A}class eA extends j{constructor(){var A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super();var e=this.readScriptTagConfig();this.config=$({baseWsUrl:"wss://backend.talktopc.com/chat/websocket",appId:A.appId||e.appId,agentId:A.agentId||e.agentId,conversationId:void 0!==A.conversationId?A.conversationId:this.getPersistedConversationId(),forceConversationId:A.forceConversationId,queue:[],inFlight:!1},A),this.fullResponseBuffer=""}readScriptTagConfig(){try{var A=Array.from(document.getElementsByTagName("script")).reverse().find(A=>A.dataset&&(A.dataset.appId||A.dataset.agentId)||A.src&&A.src.includes("agent-widget"));return A?{appId:A.dataset.appId,agentId:A.dataset.agentId}:{}}catch(A){return{}}}buildWebSocketUrl(){var A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.config.baseWsUrl,e=new URLSearchParams;return this.config.appId&&e.append("appId",this.config.appId),this.config.agentId&&e.append("agentId",this.config.agentId),this.config.conversationId&&e.append("conversationId",this.config.conversationId),"".concat(A,"?").concat(e.toString())}sendMessage(A){var e,t=this;return(e=function*(){return new Promise((e,n)=>{if(A&&A.trim())if(t.config.appId&&t.config.agentId){var o={text:A,resolve:e,reject:n};t.config.inFlight?t.config.queue.push(o):t.executeTask(o)}else n(new Error("Missing appId or agentId"));else n(new Error("Message is empty"))})},function(){var A=this,t=arguments;return new Promise(function(n,o){var r=e.apply(A,t);function i(A){Z(r,n,o,i,s,"next",A)}function s(A){Z(r,n,o,i,s,"throw",A)}i(void 0)})})()}executeTask(A){if(this.config.inFlight=!0,this.fullResponseBuffer="",!this.config.conversationId){var e=this.getPersistedConversationId();e&&(this.config.conversationId=e,console.log("đ TextChatSDK hydrated conversationId from storage:",e))}var t=this.buildWebSocketUrl(this.config.baseWsUrl),n=this.config.baseWsUrl.endsWith("/websocket")?this.config.baseWsUrl.replace(/\/websocket$/,""):"".concat(this.config.baseWsUrl,"/websocket"),o=this.buildWebSocketUrl(n),r=!1,i=!1,s=null,a=e=>{if(!i)try{var t={message:A.text},n=this.config.forceConversationId||this.config.conversationId;n&&(t.conversationId=n,this.config.forceConversationId&&!this.config.conversationId&&(this.config.conversationId=n,this.persistConversationId(n))),console.log("đ TextChatSDK sending payload:",t,"conversationId in config:",this.config.conversationId),e.send(JSON.stringify(t)),i=!0}catch(t){A.reject(t),this.emit("error",t);try{e.close()}catch(A){}}},c=A=>()=>{this.config.conversationId?a(A):s=setTimeout(()=>a(A),200)},l=e=>t=>{try{try{console.log("đ [TextChatSDK] WS <= raw:",t.data)}catch(A){}var n=JSON.parse(t.data);try{console.log("đ [TextChatSDK] WS <= parsed:",n)}catch(A){}if("hello"===n.type&&n.conversationId){if(console.log("đ TextChatSDK received conversationId:",n.conversationId),this.config.conversationId=n.conversationId,this.persistConversationId(n.conversationId),this.emit&&this.emit("conversationIdChanged",n.conversationId),!i&&e&&1===e.readyState){if(s)try{clearTimeout(s)}catch(A){}a(e)}return}if(!this.config.conversationId&&n.conversationId&&(console.log("đ TextChatSDK captured conversationId from message:",n.conversationId),this.config.conversationId=n.conversationId,this.persistConversationId(n.conversationId)),"chunk"===n.type&&"string"==typeof n.content)this.fullResponseBuffer+=n.content,this.emit("chunk",n.content);else if("done"===n.type){try{var o=n.text||n.content||n.answer||n.message||"";o&&!this.fullResponseBuffer&&(this.fullResponseBuffer=o)}catch(A){}!this.config.conversationId&&n.conversationId&&(console.log("đ TextChatSDK captured conversationId from done:",n.conversationId),this.config.conversationId=n.conversationId),this.persistConversationId(this.config.conversationId),this.emit("done",{text:this.fullResponseBuffer}),A.resolve({conversationId:this.config.conversationId,fullText:this.fullResponseBuffer});try{e.close()}catch(A){}}else if("error"===n.type){var r=new Error(n.message||"Server error");this.emit("error",r),A.reject(r);try{e.close()}catch(A){}}}catch(A){}},d=e=>{if(1008===e.code&&e.reason&&(e.reason.includes("Domain not whitelisted")||e.reason.includes("domain")||e.reason.includes("whitelist"))){var t=new Error("DOMAIN_NOT_WHITELISTED");return t.reason=e.reason,t.code=e.code,this.emit("domainError",t),A.reject(t),this.config.inFlight=!1,void this.drainQueue()}this.config.inFlight=!1,this.drainQueue()},u=new WebSocket(t);u.onopen=c(u),u.onmessage=l(u),u.onerror=(e=>t=>{if(!r){r=!0;try{e.close()}catch(A){}var n=new WebSocket(o);return n.onopen=c(n),n.onmessage=l(n),n.onerror=e=>{this.emit("error",e),A.reject(e)},void(n.onclose=d)}this.emit("error",t),A.reject(t)})(u),u.onclose=d}drainQueue(){if(0!==this.config.queue.length&&!this.config.inFlight){var A=this.config.queue.shift();this.executeTask(A)}}persistConversationId(A){try{A&&localStorage.setItem("ttp_text_chat_conversation_id",A)}catch(A){}}getPersistedConversationId(){try{return localStorage.getItem("ttp_text_chat_conversation_id")||null}catch(A){return null}}updateConfig(A){this.config=$($({},this.config),A)}destroy(){this.config.queue=[],this.config.inFlight=!1,this.removeAllListeners()}}function tA(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}const nA=new class extends j{constructor(){super(),this.connections=new Map,this.connectionCounts=new Map,this.creatingConnections=new Set}getConnection(A){var e,t=this;return(e=function*(){if(t.connections.has(A)){var e=t.connections.get(A);return t.connectionCounts.set(A,(t.connectionCounts.get(A)||0)+1),e}if(t.creatingConnections&&t.creatingConnections.has(A))return new Promise(e=>{var n=()=>{if(t.connections.has(A)){var o=t.connections.get(A);t.connectionCounts.set(A,(t.connectionCounts.get(A)||0)+1),e(o)}else setTimeout(n,50)};n()});t.creatingConnections.add(A);var n=new WebSocket(A);return t.connections.set(A,n),t.connectionCounts.set(A,1),n.addEventListener("open",e=>{t.creatingConnections.delete(A),t.emit("open",e,A)}),n.addEventListener("close",e=>{t.creatingConnections.delete(A),t.connections.delete(A),t.connectionCounts.delete(A),t.emit("close",e,A)}),n.addEventListener("error",e=>{t.creatingConnections.delete(A),t.emit("error",e,A)}),n.addEventListener("message",e=>{t.emit("message",e,A)}),n},function(){var A=this,t=arguments;return new Promise(function(n,o){var r=e.apply(A,t);function i(A){tA(r,n,o,i,s,"next",A)}function s(A){tA(r,n,o,i,s,"throw",A)}i(void 0)})})()}releaseConnection(A){if(this.connections.has(A)){var e=this.connectionCounts.get(A)||0,t=Math.max(0,e-1);if(this.connectionCounts.set(A,t),0===t){var n=this.connections.get(A);n&&n.readyState===WebSocket.OPEN&&n.close(1e3,"No more subscribers"),this.connections.delete(A),this.connectionCounts.delete(A)}}}forceClose(A){if(this.connections.has(A)){var e=this.connections.get(A);e&&e.readyState===WebSocket.OPEN&&e.close(1e3,"Force close"),this.connections.delete(A),this.connectionCounts.delete(A)}}getConnectionStatus(A){return this.connections.has(A)?{exists:!0,readyState:this.connections.get(A).readyState,subscribers:this.connectionCounts.get(A)||0}:{exists:!1,readyState:null,subscribers:0}}getAllConnections(){var A={};for(var[e,t]of this.connections.entries())A[e]={readyState:t.readyState,subscribers:this.connectionCounts.get(e)||0};return A}clearAll(){for(var[A,e]of this.connections.entries())e&&e.readyState===WebSocket.OPEN&&e.close(1e3,"Clear all");this.connections.clear(),this.connectionCounts.clear(),this.creatingConnections.clear()}};function oA(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}class rA extends j{constructor(A){super(),this.config=A,this.ws=null,this.isConnected=!1,this.connectionId=null}connect(){var A,e=this;return(A=function*(){return new Promise((A,t)=>{try{e.connectionId=Date.now()+"_"+Math.random().toString(36).substr(2,9),e.connectResolve=A,e.connectReject=t;var n=e.config.signedUrl||e.config.websocketUrl;nA.getConnection(n,e.config).then(t=>{e.ws=t,e.setupEventListeners(),t.readyState===WebSocket.OPEN&&(e.isConnected=!0,e.emit("connected"),A(),e.connectResolve=null,e.connectReject=null)}).catch(A=>{console.error("đ WebSocketManager: Connection failed ".concat(e.connectionId),A),t(A),e.connectResolve=null,e.connectReject=null})}catch(A){console.error("đ WebSocketManager: Connection error ".concat(e.connectionId),A),t(A),e.connectResolve=null,e.connectReject=null}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var r=A.apply(e,t);function i(A){oA(r,n,o,i,s,"next",A)}function s(A){oA(r,n,o,i,s,"throw",A)}i(void 0)})})()}setupEventListeners(){if(this.ws){var A=(A,e)=>{e===(this.config.signedUrl||this.config.websocketUrl)&&(this.isConnected=!0,this.emit("connected"),this.connectResolve&&(this.connectResolve(),this.connectResolve=null,this.connectReject=null))},e=(A,e)=>{e===(this.config.signedUrl||this.config.websocketUrl)&&(this.isConnected=!1,this.emit("disconnected",A))},t=(A,e)=>{e===(this.config.signedUrl||this.config.websocketUrl)&&(this.emit("error",A),this.connectReject&&(this.connectReject(A),this.connectResolve=null,this.connectReject=null))},n=(A,e)=>{e===(this.config.signedUrl||this.config.websocketUrl)&&this.handleMessage(A)};nA.on("open",A),nA.on("close",e),nA.on("error",t),nA.on("message",n),this.eventHandlers={open:A,close:e,error:t,message:n}}}disconnect(){this.eventHandlers&&(nA.off("open",this.eventHandlers.open),nA.off("close",this.eventHandlers.close),nA.off("error",this.eventHandlers.error),nA.off("message",this.eventHandlers.message));var A=this.config.signedUrl||this.config.websocketUrl;A&&nA.releaseConnection(A),this.ws=null,this.isConnected=!1}sendMessage(A){if(this.isConnected&&this.ws)try{this.ws.send(JSON.stringify(A))}catch(A){console.warn("đ WebSocketManager: Failed to send message:",A.message)}}sendBinary(A){if(this.isConnected&&this.ws)try{this.ws.send(A)}catch(A){console.warn("đ WebSocketManager: Failed to send binary data:",A.message)}}handleMessage(A){if(A.data instanceof ArrayBuffer)this.emit("binaryAudio",A.data);else if(A.data instanceof Blob)A.data.arrayBuffer().then(A=>{this.emit("binaryAudio",A)}).catch(A=>{console.error("đ WebSocketManager: Error converting Blob to ArrayBuffer:",A)});else try{var e=JSON.parse(A.data);"barge_in_ack"!==e.t&&"stop_sending"!==e.t||this.emit("bargeIn",e),"stop_playing"===e.t&&this.emit("stopPlaying",e),this.emit("message",e)}catch(A){this.emit("error",A)}}getStatus(){return{isConnected:this.isConnected,readyState:this.ws?this.ws.readyState:null,connectionId:this.connectionId}}static getSingletonStatus(){return nA.getAllConnections()}static clearAllConnections(){nA.clearAll()}}function iA(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}function sA(A){return function(){var e=this,t=arguments;return new Promise(function(n,o){var r=A.apply(e,t);function i(A){iA(r,n,o,i,s,"next",A)}function s(A){iA(r,n,o,i,s,"throw",A)}i(void 0)})}}class aA extends j{constructor(A){super(),this.config=A,this.audioContext=null,this.audioWorkletNode=null,this.mediaStream=null,this.isRecording=!1}getAudioProcessorPath(){if(this.config.audioProcessorPath)return this.config.audioProcessorPath;var A=document.getElementsByTagName("script");for(var e of A){var t=e.src;if(t&&(t.includes("agent-widget.js")||t.includes("ttp-agent-sdk")))try{new URL(t);var n=t.substring(0,t.lastIndexOf("/"));return"".concat(n,"/audio-processor.js")}catch(A){var o=t.substring(0,t.lastIndexOf("/"));return"".concat(o,"/audio-processor.js")}}return"https://cdn.talktopc.com/audio-processor.js"}checkPermissionState(){return sA(function*(){try{if(navigator.permissions&&navigator.permissions.query)return(yield navigator.permissions.query({name:"microphone"})).state}catch(A){console.log("â ī¸ AudioRecorder: Permissions API not available or not supported for microphone")}return null})()}requestPermission(){var A=this;return sA(function*(){try{if("granted"===(yield A.checkPermissionState()))return console.log("â
AudioRecorder: Microphone permission already granted"),!0;console.log("đ¤ AudioRecorder: Requesting microphone permission...");var e=A.config.sampleRate||A.config.outputSampleRate||44100;return(yield navigator.mediaDevices.getUserMedia({audio:{sampleRate:e,channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})).getTracks().forEach(A=>A.stop()),console.log("â
AudioRecorder: Microphone permission granted"),!0}catch(A){return console.error("â AudioRecorder: Failed to get microphone permission:",A),!1}})()}start(){var A=this;return sA(function*(){try{console.log("đ¤ AudioRecorder: Requesting microphone access...");var e=yield A.checkPermissionState();e&&(console.log("đ AudioRecorder: Current permission state: ".concat(e)),"denied"===e&&console.warn('â ī¸ AudioRecorder: Permission state is "denied" - browser may not show prompt. User may need to change in browser settings.'));var t=A.config.sampleRate||A.config.outputSampleRate||44100;A.mediaStream=yield navigator.mediaDevices.getUserMedia({audio:{sampleRate:t,channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),A.audioContext=new(window.AudioContext||window.webkitAudioContext)({sampleRate:t}),"suspended"===A.audioContext.state&&(yield A.audioContext.resume());var n=A.getAudioProcessorPath();yield A.audioContext.audioWorklet.addModule(n),A.audioWorkletNode=new AudioWorkletNode(A.audioContext,"audio-processor",{processorOptions:{sampleRate:t,outputSampleRate:A.config.outputSampleRate}}),A.audioContext.createMediaStreamSource(A.mediaStream).connect(A.audioWorkletNode),A.audioWorkletNode.port.onmessage=e=>{var{type:t,data:n}=e.data;"pcm_audio_data"===t&&A.emit("audioData",n)},A.audioWorkletNode.port.postMessage({type:"setForceContinuous",data:{enabled:!0}}),console.log("â
AudioRecorder: Microphone access granted"),A.isRecording=!0,A.emit("recordingStarted")}catch(e){var o=e.message;if("NotAllowedError"===e.name||"PermissionDeniedError"===e.name){var r=yield A.checkPermissionState();"denied"===r?(o='Microphone access was blocked. To enable it: 1) Click the lock icon (đ) in your browser\'s address bar, 2) Find "Microphone" and change it to "Allow", 3) Refresh this page and try again.',console.error("â AudioRecorder: Permission explicitly denied. User must change in browser settings.")):"prompt"===r?(o='Microphone permission was denied. Click the "Voice Call" button again to see the permission prompt.',console.error('â AudioRecorder: Permission denied but state is "prompt" - user can try again.')):(o="Microphone permission was denied. Click the button again to retry, or enable microphone access in your browser settings (lock icon đ in address bar).",console.error("â AudioRecorder: Permission denied. User can try again or change in browser settings."))}else"NotFoundError"===e.name||"DevicesNotFoundError"===e.name?(o="No microphone found. Please connect a microphone and try again.",console.error("â AudioRecorder: No microphone device found.")):"NotReadableError"===e.name||"TrackStartError"===e.name?(o="Microphone is already in use by another application. Please close other apps using the microphone and try again.",console.error("â AudioRecorder: Microphone is busy or not readable.")):"SecurityError"!==e.name&&"PermissionDeniedError"!==e.name||(o="Microphone access blocked. On mobile devices, please tap the recording button directly (not from an iframe or popup).",console.error("â AudioRecorder: User agent blocked microphone access. This often happens on mobile when not called from direct user interaction."));var i=new Error(o);throw i.name=e.name,i.originalError=e,A.emit("error",i),i}})()}stop(){var A=this;return sA(function*(){if(A.isRecording)try{A.audioWorkletNode&&(A.audioWorkletNode.port.postMessage({type:"flush"}),yield new Promise(A=>setTimeout(A,100))),A.mediaStream&&(A.mediaStream.getTracks().forEach(A=>A.stop()),A.mediaStream=null),A.audioContext&&"closed"!==A.audioContext.state&&(yield A.audioContext.close(),A.audioContext=null),A.audioWorkletNode=null,A.isRecording=!1,A.emit("recordingStopped")}catch(e){throw A.emit("error",e),e}})()}getStatus(){return{isRecording:this.isRecording,audioContextState:this.audioContext?this.audioContext.state:"closed"}}destroy(){this.stop()}}function cA(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}function lA(A){return function(){var e=this,t=arguments;return new Promise(function(n,o){var r=A.apply(e,t);function i(A){cA(r,n,o,i,s,"next",A)}function s(A){cA(r,n,o,i,s,"throw",A)}i(void 0)})}}class dA extends j{constructor(A){super(),this.config=A,this.audioContext=null,this.audioQueue=[],this.isPlaying=!1,this.isProcessingQueue=!1,this.currentSource=null,this.audioContextReady=!1,this.initializeAudioContext().catch(()=>{})}initializeAudioContext(){var A=this;return lA(function*(){if(!A.audioContext||"closed"===A.audioContext.state)try{var e={sampleRate:A.config.sampleRate||A.config.outputSampleRate||44100};if(A.audioContext=new(window.AudioContext||window.webkitAudioContext)(e),"suspended"===A.audioContext.state&&(yield A.audioContext.resume()),"running"===A.audioContext.state)try{var t=A.audioContext.sampleRate,n=A.audioContext.createBuffer(1,.01*t,t),o=A.audioContext.createBufferSource();o.buffer=n,o.connect(A.audioContext.destination),o.start(0),o.stop(A.audioContext.currentTime+.01)}catch(A){console.debug("AudioPlayer: AudioContext warmup skipped:",A)}A.audioContextReady=!0}catch(e){console.warn("AudioPlayer: Failed to pre-initialize AudioContext:",e),A.audioContextReady=!1}})()}playAudio(A){try{var e=this.createAudioBlob(A);if(this.audioQueue.push(e),!this.isPlaying&&!this.isProcessingQueue&&!this.currentSource){var t=this.audioContextReady?0:50;setTimeout(()=>this.processQueue(),t)}}catch(A){this.emit("playbackError",A)}}createAudioBlob(A){var e=new Uint8Array(A);if(e.length>=4){if(82===e[0]&&73===e[1]&&70===e[2]&&70===e[3])return new Blob([A],{type:"audio/wav"});if(255===e[0]&&!(224&~e[1]))return new Blob([A],{type:"audio/mpeg"});if(79===e[0]&&103===e[1]&&103===e[2]&&83===e[3])return new Blob([A],{type:"audio/ogg"})}return new Blob([A],{type:"audio/wav"})}processQueue(){var A=this;return lA(function*(){if(!A.isProcessingQueue&&0!==A.audioQueue.length){A.isProcessingQueue=!0;var e=A.audioQueue.shift();if(e)try{var t=!A.isPlaying&&null===A.currentSource;A.audioContext&&"closed"!==A.audioContext.state||(yield A.initializeAudioContext());var n=A.audioContext;"suspended"===n.state&&(yield n.resume(),t&&(yield new Promise(A=>setTimeout(A,10)))),"running"!==n.state&&(console.warn("AudioPlayer: AudioContext not in running state:",n.state),"suspended"===n.state&&(yield n.resume(),yield new Promise(A=>setTimeout(A,10))));var o=yield e.arrayBuffer(),r=yield n.decodeAudioData(o),i=t&&!A.isPlaying&&null===A.currentSource,s=n.createBufferSource();s.buffer=r,s.connect(n.destination),A.currentSource=s,A.isPlaying=!0,i&&A.emit("playbackStarted"),s.onended=()=>{A.currentSource=null,A.isProcessingQueue=!1,A.audioQueue.length>0?setTimeout(()=>A.processQueue(),0):setTimeout(()=>{0!==A.audioQueue.length||A.currentSource||(A.isPlaying=!1,A.emit("playbackStopped"))},100)},s.start()}catch(e){A.currentSource=null,A.emit("playbackError",e),A.audioQueue.length>0?(A.isProcessingQueue=!1,setTimeout(()=>A.processQueue(),100)):(A.isPlaying=!1,A.isProcessingQueue=!1,A.emit("playbackStopped"))}else A.isProcessingQueue=!1}})()}stop(){this.stopImmediate()}stopImmediate(){var A=this.isPlaying||null!==this.currentSource;if(this.currentSource){try{this.currentSource.stop()}catch(A){}this.currentSource=null}this.isPlaying=!1,this.isProcessingQueue=!1,this.audioQueue=[],A&&this.emit("playbackStopped")}resumeAudioContext(){var A=this;return lA(function*(){if(A.audioContext&&"closed"!==A.audioContext.state){if("suspended"===A.audioContext.state)try{yield A.audioContext.resume(),console.log("â
AudioPlayer: AudioContext resumed after mic permission")}catch(A){console.warn("â ī¸ AudioPlayer: Failed to resume AudioContext:",A)}}else yield A.initializeAudioContext()})()}getStatus(){return{isPlaying:this.isPlaying,isProcessingQueue:this.isProcessingQueue,queueLength:this.audioQueue.length,audioContextState:this.audioContext?this.audioContext.state:"closed"}}destroy(){this.stop(),this.audioContext&&"closed"!==this.audioContext.state&&(this.audioContext.close(),this.audioContext=null),this.audioContextReady=!1}}var uA=r(848);function gA(A,e){var t=Object.keys(A);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(A);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(A,e).enumerable})),t.push.apply(t,n)}return t}function BA(A){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?gA(Object(t),!0).forEach(function(e){hA(A,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(A,Object.getOwnPropertyDescriptors(t)):gA(Object(t)).forEach(function(e){Object.defineProperty(A,e,Object.getOwnPropertyDescriptor(t,e))})}return A}function hA(A,e,t){return(e=function(A){var e=function(A){if("object"!=typeof A||!A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var t=e.call(A,"string");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(A)}(A);return"symbol"==typeof e?e:e+""}(e))in A?Object.defineProperty(A,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):A[e]=t,A}function pA(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}const wA=n=>{var{signedUrl:o,websocketUrl:r,agentId:i,appId:s,voice:a="default",language:c="en",autoReconnect:l=!0,agentSettingsOverride:d=null,onConnected:u,onDisconnected:g,onRecordingStarted:B,onRecordingStopped:h,onPlaybackStarted:p,onPlaybackStopped:w,onError:f,onMessage:C,onBargeIn:m,onStopPlaying:v,onStartConversation:Q,onEndConversation:F,className:U="",style:y={},children:b}=n,[E,x]=t(!1),[I,H]=t(!1),[S,D]=t(!1),[K,T]=t("Disconnected"),k=e(null);A(()=>{console.log("đī¸ VoiceButton: Creating VoiceSDK_v2 instance for ".concat(r||o)),k.current&&(console.log("đī¸ VoiceButton: Destroying existing VoiceSDK_v2 instance"),k.current.destroy(),k.current=null);var A=new z({signedUrl:r||o,websocketUrl:r||o,agentId:i,appId:s,voice:a,language:c,autoReconnect:l,agentSettingsOverride:d,onStartConversation:Q,onEndConversation:F});return A.on("connected",()=>{x(!0),T("Connected"),null==u||u()}),A.on("disconnected",()=>{x(!1),T("Disconnected"),null==g||g()}),A.on("recordingStarted",()=>{H(!0),null==B||B()}),A.on("recordingStopped",()=>{H(!1),null==h||h()}),A.on("playbackStarted",()=>{D(!0),null==p||p()}),A.on("playbackStopped",()=>{D(!1),null==w||w()}),A.on("error",A=>{null==f||f(A)}),A.on("message",A=>{null==C||C(A)}),A.on("bargeIn",A=>{null==m||m(A)}),A.on("stopPlaying",A=>{null==v||v(A)}),k.current=A,A.connect(),()=>{var A=o||r;console.log("đī¸ VoiceButton: Cleaning up VoiceSDK instance for ".concat(A)),k.current&&(k.current.destroy(),k.current=null)}},[o,r,i,s,a,c,d]);var L=function(){var A,e=(A=function*(){if(k.current)try{yield k.current.toggleRecording()}catch(A){console.error("Error toggling recording:",A)}},function(){var e=this,t=arguments;return new Promise(function(n,o){var r=A.apply(e,t);function i(A){pA(r,n,o,i,s,"next",A)}function s(A){pA(r,n,o,i,s,"throw",A)}i(void 0)})});return function(){return e.apply(this,arguments)}}(),P=(0,uA.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,uA.jsx)("div",{style:{fontSize:"20px"},children:I?"đ´":"đ¤"}),(0,uA.jsx)("div",{children:I?"Stop Listening":"Start Listening"})]});return(0,uA.jsx)("button",{className:"voice-button ".concat(I?"recording":""," ").concat(U),style:BA({padding:"12px 24px",border:"none",borderRadius:"8px",backgroundColor:I?"#dc3545":"#007bff",color:"white",cursor:"pointer",fontSize:"16px",fontWeight:"500",transition:"all 0.2s ease"},y),onClick:L,disabled:!E,children:b||P})};function fA(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}function CA(A){return function(){var e=this,t=arguments;return new Promise(function(n,o){var r=A.apply(e,t);function i(A){fA(r,n,o,i,s,"next",A)}function s(A){fA(r,n,o,i,s,"throw",A)}i(void 0)})}}function mA(A,e){var t=Object.keys(A);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(A);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(A,e).enumerable})),t.push.apply(t,n)}return t}function vA(A,e,t){return(e=function(A){var e=function(A){if("object"!=typeof A||!A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var t=e.call(A,"string");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(A)}(A);return"symbol"==typeof e?e:e+""}(e))in A?Object.defineProperty(A,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):A[e]=t,A}class QA{constructor(){var A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=function(A){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?mA(Object(t),!0).forEach(function(e){vA(A,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(A,Object.getOwnPropertyDescriptors(t)):mA(Object(t)).forEach(function(e){Object.defineProperty(A,e,Object.getOwnPropertyDescriptor(t,e))})}return A}({websocketUrl:A.websocketUrl||"wss://speech.talktopc.com/ws/conv",agentId:A.agentId,voice:A.voice||"default",language:A.language||"en",container:A.container||document.body,buttonText:A.buttonText||"Start Listening",buttonClass:A.buttonClass||"voice-button"},A),this.isConnected=!1,this.isRecording=!1,this.isPlaying=!1,this.voiceSDK=new z({signedUrl:this.options.websocketUrl||this.options.signedUrl,websocketUrl:this.options.websocketUrl||this.options.signedUrl,agentId:this.options.agentId,appId:this.options.appId,voice:this.options.voice,language:this.options.language}),this.setupEventListeners(),this.createButton(),this.connect()}setupEventListeners(){this.voiceSDK.on("connected",()=>{var A,e;this.isConnected=!0,this.updateButton(),null===(A=(e=this.options).onConnected)||void 0===A||A.call(e)}),this.voiceSDK.on("disconnected",()=>{var A,e;this.isConnected=!1,this.updateButton(),null===(A=(e=this.options).onDisconnected)||void 0===A||A.call(e)}),this.voiceSDK.on("recordingStarted",()=>{var A,e;this.isRecording=!0,this.updateButton(),null===(A=(e=this.options).onRecordingStarted)||void 0===A||A.call(e)}),this.voiceSDK.on("recordingStopped",()=>{var A,e;this.isRecording=!1,this.updateButton(),null===(A=(e=this.options).onRecordingStopped)||void 0===A||A.call(e)}),this.voiceSDK.on("playbackStarted",()=>{var A,e;this.isPlaying=!0,null===(A=(e=this.options).onPlaybackStarted)||void 0===A||A.call(e)}),this.voiceSDK.on("playbackStopped",()=>{var A,e;this.isPlaying=!1,null===(A=(e=this.options).onPlaybackStopped)||void 0===A||A.call(e)}),this.voiceSDK.on("error",A=>{var e,t;null===(e=(t=this.options).onError)||void 0===e||e.call(t,A)}),this.voiceSDK.on("message",A=>{var e,t;null===(e=(t=this.options).onMessage)||void 0===e||e.call(t,A)}),this.voiceSDK.on("bargeIn",A=>{var e,t;null===(e=(t=this.options).onBargeIn)||void 0===e||e.call(t,A)}),this.voiceSDK.on("stopPlaying",A=>{var e,t;null===(e=(t=this.options).onStopPlaying)||void 0===e||e.call(t,A)})}createButton(){this.button=document.createElement("button"),this.button.className=this.options.buttonClass,this.button.style.cssText="\n padding: 12px 24px;\n border: none;\n border-radius: 8px;\n background-color: #6c757d;\n color: white;\n cursor: pointer;\n font-size: 16px;\n font-weight: 500;\n transition: all 0.2s ease;\n display: flex;\n align-items: center;\n gap: 8px;\n ",this.button.addEventListener("click",()=>this.toggleRecording()),this.options.container.appendChild(this.button),this.updateButton()}updateButton(){if(this.button){var A=this.isRecording?"đ´":"đ¤",e=this.isRecording?"Stop Listening":"Start Listening";this.button.innerHTML='\n <span style="font-size: 20px;">'.concat(A,"</span>\n <span>").concat(e,"</span>\n "),this.button.disabled=!this.isConnected,this.button.style.backgroundColor=this.isRecording?"#dc3545":this.isConnected?"#007bff":"#6c757d"}}connect(){var A=this;return CA(function*(){try{yield A.voiceSDK.connect()}catch(A){console.error("Failed to connect:",A)}})()}toggleRecording(){var A=this;return CA(function*(){if(A.voiceSDK)try{yield A.voiceSDK.toggleRecording()}catch(A){console.error("Error toggling recording:",A)}})()}getStatus(){return{isConnected:this.isConnected,isRecording:this.isRecording,isPlaying:this.isPlaying}}updateConfig(A){this.voiceSDK.updateConfig(A)}destroy(){this.button&&this.button.parentNode&&this.button.parentNode.removeChild(this.button),this.voiceSDK&&this.voiceSDK.destroy()}}function FA(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}function UA(A){return function(){var e=this,t=arguments;return new Promise(function(n,o){var r=A.apply(e,t);function i(A){FA(r,n,o,i,s,"next",A)}function s(A){FA(r,n,o,i,s,"throw",A)}i(void 0)})}}class yA{constructor(A){console.log("đ AgentSDK v2.1.8 initialized with config:",A),this.config=A,this.voiceSDK=null,this.isConnected=!1,this.isListening=!1,this.wasListening=!1,this._resumeInfo=null,this.onConnected=()=>{},this.onDisconnected=()=>{},this.onError=A=>console.error("SDK Error:",A),this.onTranscript=A=>{},this.onAgentSpeaking=A=>{},this.onConversationStart=A.onConversationStart||(()=>{}),this.onConversationEnd=A.onConversationEnd||(()=>{}),this.onBargeIn=A.onBargeIn||(()=>{}),this.onAudioStartPlaying=A.onAudioStartPlaying||(()=>{}),this.onAudioStoppedPlaying=A.onAudioStoppedPlaying||(()=>{}),this.onSubtitleDisplay=A.onSubtitleDisplay||(()=>{})}checkResumeBeforeConnect(){try{var A=new z({signedUrl:"wss://placeholder",autoReconnect:!1,agentId:this.config.agentId,appId:this.config.appId,language:this.config.language||"en",protocolVersion:2}).checkAndResume();return A?(console.log("đ [AGENT SDK] Found resume state before connect:",A),this._resumeInfo=A,A):null}catch(A){return console.warn("â ī¸ [AGENT SDK] Error checking resume:",A),null}}connect(A){var e=this;return UA(function*(){try{if(!A)throw new Error("signedUrl is required");if(e.voiceSDK&&(console.log("đ AgentSDK: Cleaning up existing connection"),e.voiceSDK.destroy(),e.voiceSDK=null),e.voiceSDK=new z({signedUrl:A,autoReconnect:!1,agentId:e.config.agentId,appId:e.config.appId,language:e.config.language||"en",agentSettingsOverride:e.config.agentSettingsOverride,protocolVersion:2,outputContainer:e.config.outputContainer||"raw",outputEncoding:e.config.outputEncoding||"pcm",outputSampleRate:e.config.outputSampleRate||44100,outputChannels:e.config.outputChannels||1,outputBitDepth:e.config.outputBitDepth||16}),e._resumeInfo&&(console.log("đ [AGENT SDK] Using stored resume info:",e._resumeInfo),console.log(" From:",e._resumeInfo.fromPage,"â To:",e._resumeInfo.toPage)),e.voiceSDK.on("connected",()=>{e.isConnected=!0,e.onConnected()}),setTimeout(()=>{e.voiceSDK&&e.voiceSDK.isConnected&&!e.isConnected&&(e.isConnected=!0,e.onConnected())},10),e.voiceSDK.on("disconnected",A=>{if(e.isConnected=!1,A&&1008===A.code&&A.reason&&(A.reason.includes("Domain not whitelisted")||A.reason.includes("domain")||A.reason.includes("whitelist"))){var t=new Error("DOMAIN_NOT_WHITELISTED");t.reason=A.reason,t.code=A.code,e.onError(t)}if((e.isListening||e.wasListening)&&(console.log("đ¤ [AGENT SDK] disconnected event - calling onConversationEnd hook (isListening:",e.isListening,", wasListening:",e.wasListening,")"),e.onConversationEnd&&"function"==typeof e.onConversationEnd))try{e.onConversationEnd(),console.log("đ¤ [AGENT SDK] â
onConversationEnd hook called from disconnected event"),e.wasListening=!1}catch(A){console.error("đ¤ [AGENT SDK] â Error calling onConversationEnd from disconnected:",A)}e.onDisconnected()}),e.voiceSDK.on("domainError",A=>{e.onError(A)}),e.voiceSDK.on("error",A=>{e.onError(A)}),e.voiceSDK.on("message",A=>{e.handleWebSocketMessage(A)}),e.voiceSDK.on("recordingStarted",()=>{if(e.isListening=!0,e.wasListening=!0,e.onConversationStart&&"function"==typeof e.onConversationStart)try{e.onConversationStart()}catch(A){console.error("đ¤ [AGENT SDK] â Error calling onConversationStart:",A)}}),e.voiceSDK.on("recordingStopped",()=>{console.log("đ¤ [AGENT SDK] recordingStopped event received");var A=e.isListening;if(e.isListening=!1,A&&e.onConversationEnd&&"function"==typeof e.onConversationEnd)try{console.log("đ¤ [AGENT SDK] â
Calling onConversationEnd hook from recordingStopped"),e.onConversationEnd(),console.log("đ¤ [AGENT SDK] â
onConversationEnd hook called successfully"),e.wasListening=!1}catch(A){console.error("đ¤ [AGENT SDK] â Error calling onConversationEnd:",A)}}),e.voiceSDK.on("playbackStarted",()=>{e.onAgentSpeaking(!0),e.onAudioStartPlaying()}),e.voiceSDK.on("playbackStopped",()=>{e.onAgentSpeaking(!1),e.onAudioStoppedPlaying()}),e.voiceSDK.on("bargeIn",A=>{e.onBargeIn(A)}),e.voiceSDK.on("transcriptDisplay",A=>{console.log("đ [AGENT SDK] transcriptDisplay event received:",A),A&&A.text&&(console.log("đ [AGENT SDK] Calling onTranscript with text:",A.text),e.onTranscript&&"function"==typeof e.onTranscript?e.onTranscript(A.text):console.warn("đ [AGENT SDK] â ī¸ onTranscript is not a function!",typeof e.onTranscript)),e.onSubtitleDisplay(A)}),e._pendingToolHandlers&&e._pendingToolHandlers.size>0)for(var[t,n]of(console.log("đ§ AgentSDK: Registering ".concat(e._pendingToolHandlers.size," pending tool handlers")),e._pendingToolHandlers))e.voiceSDK.registerToolHandler(t,n);yield e.voiceSDK.connect()}catch(A){throw e.onError(A),A}})()}handleWebSocketMessage(A){switch(A.t||A.type){case"connected":case"hello_ack":console.log("Session started successfully");break;case"user_transcript":this.onTranscript(A.user_transcription||A.text||A.transcript);break;case"agent_response":case"barge_in":case"stop_playing":default:break;case"error":this.onError(new Error(A.message||A.error||"Unknown error"))}}startListening(){var A=this;return UA(function*(){if(console.log("đ¤ AgentSDK: startListening() called"),!A.voiceSDK)throw console.error("â AgentSDK: No voiceSDK instance available"),new Error("No voiceSDK instance available");try{console.log("đ¤ AgentSDK: Starting recording..."),yield A.voiceSDK.startRecording(),console.log("â
AgentSDK: Recording started successfully")}catch(A){throw console.error("â AgentSDK: Failed to start recording:",A),A}})()}stopListening(){this.voiceSDK&&this.voiceSDK.stopRecording()}hangup(){this.voiceSDK&&this.voiceSDK.hangup()}updateVariables(A){this.voiceSDK&&this.isConnected&&this.voiceSDK.sendMessage({t:"update_variables",variables:A})}disconnect(){this.voiceSDK&&(this.voiceSDK.destroy(),this.voiceSDK=null),this.isConnected=!1,this.isListening=!1}registerToolHandler(A,e){if(this.voiceSDK)return this.voiceSDK.registerToolHandler(A,e);this._pendingToolHandlers||(this._pendingToolHandlers=new Map),this._pendingToolHandlers.set(A,e),console.log("đ§ AgentSDK: Queued tool handler '".concat(A,"' for registration after connect"))}unregisterToolHandler(A){if(this.voiceSDK)return this.voiceSDK.unregisterToolHandler(A);this._pendingToolHandlers&&this._pendingToolHandlers.delete(A)}hasToolHandler(A){var e;return this.voiceSDK?this.voiceSDK.hasToolHandler(A):(null===(e=this._pendingToolHandlers)||void 0===e?void 0:e.has(A))||!1}getRegisteredTools(){return this.voiceSDK?this.voiceSDK.getRegisteredTools():this._pendingToolHandlers?Array.from(this._pendingToolHandlers.keys()):[]}}function bA(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}function EA(){var A=navigator.userAgent,e=/iPad|iPhone|iPod/.test(A)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,t=/Android/.test(A),n=/Mac/.test(A)&&!e,o=/Win/.test(A),r=/Chrome/.test(A)&&!/Edg|OPR/.test(A),i=/Safari/.test(A)&&!/Chrome/.test(A),s=/Firefox/.test(A),a=/Edg/.test(A),c=/SamsungBrowser/.test(A),l="unknown";e?l="safari":c?l="samsung":r?l="chrome":i?l="safari":s?l="firefox":a&&(l="edge");var d="unknown";return e?d="ios":t?d="android":n?d="mac":o&&(d="windows"),{platform:d,browser:l,isIOS:e,isAndroid:t,isMac:n,isWindows:o,isMobile:e||t,isDesktop:!e&&!t}}function xA(){return IA.apply(this,arguments)}function IA(){var A;return A=function*(){try{if(navigator.permissions&&navigator.permissions.query)return(yield navigator.permissions.query({name:"microphone"})).state}catch(A){console.log("â ī¸ MicPermissionUtils: Permissions API not available or not supported for microphone")}return"unknown"},IA=function(){var e=this,t=arguments;return new Promise(function(n,o){var r=A.apply(e,t);function i(A){bA(r,n,o,i,s,"next",A)}function s(A){bA(r,n,o,i,s,"throw",A)}i(void 0)})},IA.apply(this,arguments)}function HA(A){var{platform:e,browser:t}=A,n={ios:{title:"Enable Microphone on iPhone/iPad",icon:"đą",steps:["Tap the <strong>lock icon đ</strong>, <strong>information icon âšī¸</strong>, or <strong>AA icon</strong> in the address bar","Tap <strong>Website Settings</strong> or <strong>Permissions</strong>","Find <strong>Microphone</strong> and set it to <strong>Allow</strong>","Return to this page and refresh"],altTitle:"Alternative Method",altSteps:["Open the <strong>Settings</strong> app on your device","Scroll down and tap <strong>Safari</strong> (or your browser app)",'Tap <strong>Microphone</strong> under "Settings for Websites"',"Set it to <strong>Allow</strong> or <strong>Ask</strong>","Return to this page and refresh"],note:"On iOS, you can also change permissions in the browser address bar or in device Settings.",canOpenSettings:!0,settingsButtonText:"Open Settings App"},android_chrome:{title:"Enable Microphone in Chrome",icon:"đ¤",steps:["Tap the <strong>lock icon đ</strong>, <strong>information icon âšī¸</strong>, or <strong>settings icon âŽ</strong> in the address bar","Tap <strong>Permissions</strong>","Tap <strong>Microphone</strong>","Select <strong>Allow</strong>","The page will refresh automatically"],altTitle:"Alternative Method",altSteps:["Tap the <strong>⎠menu</strong> (three dots)","Tap <strong>Settings â Site settings â Microphone</strong>","Find this website and set to <strong>Allow</strong>"],canOpenSettings:!0,settingsButtonText:"Open App Settings"},android_firefox:{title:"Enable Microphone in Firefox",icon:"đĻ",steps:["Tap the <strong>lock icon đ</strong> or <strong>information icon âšī¸</strong> in the address bar","Tap <strong>Edit Site Permissions</strong>","Toggle <strong>Microphone</strong> to enabled","Refresh the page"],canOpenSettings:!1},android_samsung:{title:"Enable Microphone in Samsung Browser",icon:"đą",steps:["Tap the <strong>menu icon</strong> (three lines)","Tap <strong>Settings â Sites and downloads</strong>","Tap <strong>Site permissions â Microphone</strong>","Find this website and set to <strong>Allow</strong>","Return and refresh the page"],canOpenSettings:!1},desktop_chrome:{title:"Enable Microphone in Chrome",icon:"đ",steps:["Click the <strong>lock icon đ</strong> or <strong>information icon âšī¸</strong> in the address bar (left side)","Find <strong>Microphone</strong> in the dropdown menu",'Change it from "Block" to <strong>Allow</strong>',"Click the <strong>Refresh</strong> button or press F5"],showAddressBarHint:!0,canOpenSettings:!1},desktop_safari:{title:"Enable Microphone in Safari",icon:"đ§",steps:["Click <strong>Safari</strong> in the menu bar (top of screen)","Click <strong>Settings for This Website...</strong>","Find <strong>Microphone</strong> in the popup","Change it to <strong>Allow</strong>","Close settings and refresh the page"],canOpenSettings:!1},desktop_firefox:{title:"Enable Microphone in Firefox",icon:"đĻ",steps:["Click the <strong>lock icon đ</strong> in the address bar",'Click the <strong>X</strong> next to "Blocked" for Microphone',"Refresh the page (press F5)","Click <strong>Allow</strong> when prompted again"],note:"Firefox requires you to clear the block and then re-allow on the next prompt.",showAddressBarHint:!0,canOpenSettings:!1},desktop_edge:{title:"Enable Microphone in Edge",icon:"đ",steps:["Click the <strong>lock icon đ</strong> in the address bar","Find <strong>Microphone</strong> in the permissions list","Change it to <strong>Allow</strong>","Refresh the page"],showAddressBarHint:!0,canOpenSettings:!1},unknown:{title:"Enable Microphone Access",icon:"đ¤",steps:["Look for a <strong>lock icon đ</strong>, <strong>information icon âšī¸</strong>, or <strong>settings icon</strong> in your browser's address bar","Find the <strong>Microphone</strong> permission setting","Change it to <strong>Allow</strong>","Refresh this page"],canOpenSettings:!1}};return"ios"===e?n.ios:"android"===e?n["android_".concat(t)]||n.android_chrome:n["desktop_".concat(t)]||n.desktop_chrome}function SA(A){var{isIOS:e,isAndroid:t,browser:n}=A;if(e)try{return window.location.href="app-settings:",!0}catch(A){return console.warn("Could not open iOS settings:",A),!1}if(t&&"chrome"===n)try{return window.location.href="intent:#Intent;action=android.settings.APPLICATION_DETAILS_SETTINGS;data=package:com.android.chrome;end",!0}catch(A){return console.warn("Could not open Android settings:",A),!1}return!1}class DA{constructor(){this.overlay=null,this.modal=null}createOverlay(){var A=document.createElement("div");return A.className="mic-permission-overlay",A.style.cssText="\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.6);\n backdrop-filter: blur(4px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n padding: 20px;\n animation: mic-fadeIn 0.2s ease-out;\n ",document.getElementById("mic-permission-styles")||this.injectStyles(),A}injectStyles(){if(!document.getElementById("mic-permission-styles")){var A=document.createElement("style");A.id="mic-permission-styles",A.textContent="\n @keyframes mic-fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n \n @keyframes mic-slideUp {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n \n @keyframes mic-bounce {\n 0%, 100% { transform: translateY(0); }\n 50% { transform: translateY(-5px); }\n }\n \n .mic-permission-overlay {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.6);\n backdrop-filter: blur(4px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n padding: 20px;\n animation: mic-fadeIn 0.2s ease-out;\n }\n \n .mic-permission-modal {\n background: #ffffff;\n border-radius: 16px;\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);\n max-width: 480px;\n width: 100%;\n padding: 32px;\n position: relative;\n animation: mic-slideUp 0.3s ease-out;\n max-height: 90vh;\n overflow-y: auto;\n }\n \n .mic-permission-modal__close {\n position: absolute;\n top: 16px;\n right: 16px;\n background: none;\n border: none;\n font-size: 20px;\n cursor: pointer;\n color: #6b7280;\n width: 32px;\n height: 32px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background 0.2s;\n }\n \n .mic-permission-modal__close:hover {\n background: #e5e7eb;\n }\n \n .mic-permission-modal__icon {\n font-size: 48px;\n text-align: center;\n margin-bottom: 16px;\n }\n \n .mic-permission-modal__title {\n font-size: 24px;\n font-weight: 700;\n color: #111827;\n margin: 0 0 12px;\n line-height: 1.3;\n text-align: center;\n }\n \n .mic-permission-modal__description {\n color: #6b7280;\n font-size: 16px;\n line-height: 1.6;\n margin: 0 0 20px;\n text-align: center;\n }\n \n .mic-permission-modal__highlight {\n display: flex;\n align-items: center;\n gap: 12px;\n background: linear-gradient(135deg, #dbeafe, #ede9fe);\n padding: 16px 20px;\n border-radius: 8px;\n margin-bottom: 20px;\n border: 1px solid #bfdbfe;\n }\n \n .mic-permission-modal__highlight-icon {\n font-size: 24px;\n animation: mic-bounce 1s infinite;\n }\n \n .mic-permission-modal__status {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n background: #fef2f2;\n color: #ef4444;\n padding: 12px 16px;\n border-radius: 8px;\n margin-bottom: 20px;\n font-weight: 500;\n }\n \n .mic-permission-modal__note {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n background: #fffbeb;\n color: #92400e;\n padding: 12px 16px;\n border-radius: 8px;\n margin-bottom: 20px;\n font-size: 14px;\n line-height: 1.5;\n border: 1px solid #fde68a;\n }\n \n .mic-permission-modal__steps {\n margin-bottom: 20px;\n }\n \n .mic-permission-modal__steps h3 {\n font-size: 14px;\n font-weight: 600;\n color: #6b7280;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n margin: 0 0 12px;\n }\n \n .mic-permission-modal__steps ol {\n margin: 0;\n padding-left: 24px;\n counter-reset: step-counter;\n list-style: none;\n }\n \n .mic-permission-modal__steps li {\n position: relative;\n padding: 12px 0 12px 16px;\n border-left: 2px solid #e5e7eb;\n color: #111827;\n font-size: 15px;\n line-height: 1.5;\n counter-increment: step-counter;\n }\n \n .mic-permission-modal__steps li::before {\n content: counter(step-counter);\n position: absolute;\n left: -14px;\n top: 10px;\n width: 24px;\n height: 24px;\n background: #4f46e5;\n color: white;\n border-radius: 50%;\n font-size: 12px;\n font-weight: 600;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n \n .mic-permission-modal__steps li:last-child {\n border-left-color: transparent;\n }\n \n .mic-permission-modal__actions {\n display: flex;\n flex-direction: column;\n gap: 10px;\n margin-top: 24px;\n }\n \n .mic-permission-modal__btn {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 14px 24px;\n border-radius: 8px;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n border: none;\n width: 100%;\n }\n \n .mic-permission-modal__btn--primary {\n background: #4f46e5;\n color: white;\n }\n \n .mic-permission-modal__btn--primary:hover {\n background: #4338ca;\n transform: translateY(-1px);\n }\n \n .mic-permission-modal__btn--secondary {\n background: #e5e7eb;\n color: #111827;\n }\n \n .mic-permission-modal__btn--secondary:hover {\n background: #d1d5db;\n }\n \n .mic-permission-modal__footer {\n text-align: center;\n font-size: 13px;\n color: #6b7280;\n margin-top: 20px;\n margin-bottom: 0;\n }\n \n .mic-permission-modal__visual-guide {\n width: 100%;\n max-width: 380px;\n height: auto;\n margin: 20px auto;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);\n display: block;\n }\n \n .mic-permission-modal__visual-guide-container {\n text-align: center;\n margin: 20px 0;\n }\n \n @media (max-width: 480px) {\n .mic-permission-modal {\n padding: 24px 20px;\n margin: 10px;\n max-height: 85vh;\n }\n \n .mic-permission-modal__title {\n font-size: 20px;\n }\n \n .mic-permission-modal__icon {\n font-size: 40px;\n }\n \n .mic-permission-modal__visual-guide {\n max-width: 100%;\n }\n }\n ",document.head.appendChild(A)}}close(){this.overlay&&this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay),this.overlay=null,this.modal=null}show(){this.overlay&&this.modal&&document.body.appendChild(this.overlay)}}function KA(A,e){var t=new DA,n=t.createOverlay(),o=EA(),r=document.createElement("div");return r.className="mic-permission-modal",r.innerHTML='\n <div class="mic-permission-modal__icon">đ¤</div>\n <h2 class="mic-permission-modal__title">Enable Your Microphone</h2>\n <p class="mic-permission-modal__description">\n To start a voice call with our agent, we need access to your microphone.\n </p>\n <div class="mic-permission-modal__highlight">\n <span class="mic-permission-modal__highlight-icon">đ</span>\n <span>Please click <strong>"Allow"</strong> on the next popup</span>\n </div>\n '.concat(o.isIOS?'\n <div class="mic-permission-modal__note">\n <span>âšī¸</span>\n <span>On iPhone/iPad, you may need to allow microphone access in your device Settings.</span>\n </div>\n ':"",'\n <div class="mic-permission-modal__actions">\n <button class="mic-permission-modal__btn mic-permission-modal__btn--primary" data-action="accept">\n Continue\n </button>\n <button class="mic-permission-modal__btn mic-permission-modal__btn--secondary" data-action="cancel">\n Not Now\n </button>\n </div>\n '),n.appendChild(r),t.overlay=n,t.modal=r,r.querySelector('[data-action="accept"]').addEventListener("click",()=>{t.close(),A()}),r.querySelector('[data-action="cancel"]').addEventListener("click",()=>{t.close(),e()}),n.addEventListener("click",A=>{A.target===n&&(t.close(),e())}),t.show(),t}function TA(A,e){var t,n,o,r=new DA,i=r.createOverlay(),s=EA(),a=HA(s),c=document.createElement("div");c.className="mic-permission-modal";var l="";a.altSteps&&a.altSteps.length>0&&(l='\n <div style="margin-top: 20px; border-top: 1px solid #e5e7eb; padding-top: 16px;">\n <button class="mic-permission-modal__alt-toggle" style="background: none; border: none; color: #4f46e5; font-size: 14px; font-weight: 500; cursor: pointer; padding: 0; margin-bottom: 12px;">\n âŧ '.concat(a.altTitle||"Alternative method",'\n </button>\n <ol style="margin: 0; padding-left: 20px; display: none;">\n ').concat(a.altSteps.map(A=>'<li style="padding: 8px 0; font-size: 14px; color: #6b7280;">'.concat(A,"</li>")).join(""),"\n </ol>\n </div>\n "));var d=function(A){var{platform:e,browser:t}=A,n=document.getElementsByTagName("script"),o="";for(var r of n){var i=r.src;if(i&&(i.includes("agent-widget.js")||i.includes("ttp-agent-sdk")||i.includes("ttp-sdk-front")))try{new URL(i),o=i.substring(0,i.lastIndexOf("/"));break}catch(A){var s=i.match(/^(.*\/)[^\/]+$/);if(s){o=s[1];break}}}var a;if(a="ios"===e?"ios-settings.svg":"android"===e?"android-chrome.svg":"chrome"===t?"desktop-chrome.svg":"safari"===t?"desktop-safari.svg":"firefox"===t?"desktop-firefox.svg":"edge"===t?"desktop-edge.svg":"desktop-chrome.svg",!o||""===o||o.startsWith("/")){for(var c of n){var l=c.src;if(l&&(l.includes("cdn.talktopc.com")||l.includes("talktopc.com"))){if(l.includes("/ttp-agent-sdk/")||l.includes("/ttp-sdk-front/")){var d=l.match(/(https?:\/\/[^\/]+(?:\/[^\/]+)*)/);if(d){o=d[1].replace(/\/[^\/]+\.js$/,"");break}}if(!o&&(l.includes("cdn.talktopc.com")||l.includes("talktopc.com"))){o="https://cdn.talktopc.com/ttp-agent-sdk";break}}}if(!o||""===o)if(window.location.hostname.includes("cdn.talktopc.com")||window.location.hostname.includes("talktopc.com"))o="https://cdn.talktopc.com/ttp-agent-sdk";else{var u=window.location.pathname.split("/");u.pop(),(o=window.location.origin+u.join("/"))&&o!==window.location.origin||(o=window.location.origin)}}o=o.replace(/\/$/,"");var g="".concat(o,"/shared/mic-permission-assets/").concat(a);return"undefined"!=typeof console&&console.log&&console.log("[MicPermission] Visual guide path:",g,"Base path:",o,"Platform:",e,"Browser:",t),g}(s);c.innerHTML='\n <button class="mic-permission-modal__close" data-action="close">â</button>\n <div style="display: flex; align-items: center; gap: 12px; margin-bottom: 20px;">\n <span style="font-size: 32px;">'.concat(a.icon,'</span>\n <h2 class="mic-permission-modal__title" style="text-align: left; margin: 0;">').concat(a.title,'</h2>\n </div>\n <div class="mic-permission-modal__status">\n <span>đĢ</span>\n <span>Microphone access is currently blocked</span>\n </div>\n ').concat(a.note?'\n <div class="mic-permission-modal__note">\n <span>âšī¸</span>\n <span>'.concat(a.note,"</span>\n </div>\n "):"",'\n <div class="mic-permission-modal__visual-guide-container">\n <img src="').concat(d,'" alt="Visual guide for enabling microphone" class="mic-permission-modal__visual-guide" \n onerror="console.error(\'[MicPermission] Failed to load image:\', this.src); this.style.display=\'none\';" \n onload="console.log(\'[MicPermission] Image loaded successfully:\', this.src);" />\n </div>\n <div class="mic-permission-modal__steps">\n <h3>Follow these steps:</h3>\n <ol>\n ').concat(a.steps.map(A=>"<li>".concat(A,"</li>")).join(""),"\n </ol>\n </div>\n ").concat(l,'\n <div class="mic-permission-modal__actions">\n ').concat(a.canOpenSettings?'\n <button class="mic-permission-modal__btn mic-permission-modal__btn--primary" data-action="open-settings">\n '.concat(a.settingsButtonText||"Open Settings","\n </button>\n "):"","\n ").concat(a.showAddressBarHint?'\n <button class="mic-permission-modal__btn mic-permission-modal__btn--primary" data-action="show-hint">\n Show Me Where\n </button>\n ':"",'\n <button class="mic-permission-modal__btn mic-permission-modal__btn--secondary" data-action="refresh">\n đ Refresh Page\n </button>\n </div>\n <p class="mic-permission-modal__footer">\n After enabling microphone access, return here and click "Refresh Page"\n </p>\n '),i.appendChild(c),r.overlay=i,r.modal=c,null===(t=c.querySelector('[data-action="close"]'))||void 0===t||t.addEventListener("click",()=>{r.close(),A()}),null===(n=c.querySelector('[data-action="open-settings"]'))||void 0===n||n.addEventListener("click",()=>{SA(s)}),null===(o=c.querySelector('[data-action="refresh"]'))||void 0===o||o.addEventListener("click",()=>{window.location.reload()});var u=c.querySelector('[data-action="show-hint"]');u&&u.addEventListener("click",()=>{r.close(),A(),function(){var A=document.getElementById("mic-address-bar-hint");A&&A.remove(),EA();var e=document.getElementsByTagName("script"),t="";for(var n of e){var o=n.src;if(o&&(o.includes("agent-widget.js")||o.includes("ttp-agent-sdk")||o.includes("ttp-sdk-front")))try{new URL(o),t=o.substring(0,o.lastIndexOf("/"));break}catch(A){var r=o.match(/^(.*\/)[^\/]+$/);if(r){t=r[1];break}}}if(!t||""===t||t.startsWith("/")){for(var i of e){var s=i.src;if(s&&(s.includes("cdn.talktopc.com")||s.includes("talktopc.com"))){if(s.includes("/ttp-agent-sdk/")||s.includes("/ttp-sdk-front/")){var a=s.match(/(https?:\/\/[^\/]+(?:\/[^\/]+)*)/);if(a){t=a[1].replace(/\/[^\/]+\.js$/,"");break}}if(!t&&(s.includes("cdn.talktopc.com")||s.includes("talktopc.com"))){t="https://cdn.talktopc.com/ttp-agent-sdk";break}}}if(!t||""===t)if(window.location.hostname.includes("cdn.talktopc.com")||window.location.hostname.includes("talktopc.com"))t="https://cdn.talktopc.com/ttp-agent-sdk";else{var c=window.location.pathname.split("/");c.pop(),(t=window.location.origin+c.join("/"))&&t!==window.location.origin||(t=window.location.origin)}}t=t.replace(/\/$/,"");var l="".concat(t,"/shared/mic-permission-assets/address-bar-hint.svg"),d=document.createElement("div");d.id="mic-address-bar-hint",d.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n z-index: 10001;\n padding: 10px 20px;\n pointer-events: none;\n animation: mic-fadeIn 0.3s ease-out;\n display: flex;\n justify-content: center;\n ";var u=document.createElement("div");u.style.cssText="\n display: flex;\n align-items: center;\n gap: 12px;\n background: #f59e0b;\n color: white;\n padding: 12px 20px;\n border-radius: 0 0 8px 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n pointer-events: all;\n animation: mic-slideDown 0.3s ease-out;\n max-width: 540px;\n ";var g=document.createElement("div");g.style.cssText="\n flex-shrink: 0;\n ";var B=document.createElement("img");B.src=l,B.alt="Address bar hint",B.style.cssText="\n width: auto;\n height: 80px;\n display: block;\n ",B.onerror=()=>{g.style.display="none"},g.appendChild(B);var h=document.createElement("div");h.style.cssText="\n display: flex;\n flex-direction: column;\n gap: 4px;\n flex: 1;\n ";var p=document.createElement("div");p.style.cssText="\n font-size: 15px;\n font-weight: 500;\n ",p.innerHTML="Click the <strong>lock icon đ</strong>, <strong>information icon âšī¸</strong>, or <strong>settings icon âŽ</strong> in the address bar to enable microphone";var w=document.createElement("button");if(w.style.cssText="\n background: rgba(255, 255, 255, 0.2);\n border: none;\n color: white;\n width: 28px;\n height: 28px;\n border-radius: 50%;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n transition: background 0.2s;\n flex-shrink: 0;\n ",w.textContent="â",w.addEventListener("click",()=>{d.remove()}),w.addEventListener("mouseenter",()=>{w.style.background="rgba(255, 255, 255, 0.3)"}),w.addEventListener("mouseleave",()=>{w.style.background="rgba(255, 255, 255, 0.2)"}),!document.getElementById("mic-address-bar-hint-styles")){var f=document.createElement("style");f.id="mic-address-bar-hint-styles",f.textContent="\n @keyframes mic-slideDown {\n from {\n opacity: 0;\n transform: translateY(-100%);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n \n @keyframes mic-pointUp {\n 0%, 100% {\n transform: translate(0, 0);\n }\n 50% {\n transform: translate(-5px, -5px);\n }\n }\n ",document.head.appendChild(f)}h.appendChild(p),u.appendChild(g),u.appendChild(h),u.appendChild(w),d.appendChild(u),document.body.appendChild(d),setTimeout(()=>{d.parentNode&&(d.style.opacity="0",d.style.transition="opacity 0.3s ease-out",setTimeout(()=>{d.parentNode&&d.remove()},300))},1e4)}()});var g=c.querySelector(".mic-permission-modal__alt-toggle");if(g&&a.altSteps){var B=g.nextElementSibling;B&&(B.style.display="none",g.addEventListener("click",()=>{"none"===B.style.display?(B.style.display="block",g.innerHTML="âŧ ".concat(a.altTitle||"Alternative method")):(B.style.display="none",g.innerHTML="âļ ".concat(a.altTitle||"Alternative method"))}))}return i.addEventListener("click",e=>{e.target===i&&(r.close(),A())}),r.show(),r}function kA(A){var e=new DA,t=e.createOverlay(),n=document.createElement("div");return n.className="mic-permission-modal",n.innerHTML='\n <div class="mic-permission-modal__icon">đ¤â</div>\n <h2 class="mic-permission-modal__title">No Microphone Found</h2>\n <p class="mic-permission-modal__description">\n We couldn\'t detect a microphone on your device. Please make sure:\n </p>\n <ul style="list-style: none; padding: 0; margin: 0 0 24px;">\n <li style="padding: 10px 0 10px 32px; position: relative; color: #111827; border-bottom: 1px solid #e5e7eb;">\n <span style="position: absolute; left: 0; font-size: 18px;">â</span>\n Your microphone is properly connected\n </li>\n <li style="padding: 10px 0 10px 32px; position: relative; color: #111827; border-bottom: 1px solid #e5e7eb;">\n <span style="position: absolute; left: 0; font-size: 18px;">â</span>\n Your microphone is not muted at the hardware level\n </li>\n <li style="padding: 10px 0 10px 32px; position: relative; color: #111827;">\n <span style="position: absolute; left: 0; font-size: 18px;">â</span>\n No other app is exclusively using the microphone\n </li>\n </ul>\n <div class="mic-permission-modal__actions">\n <button class="mic-permission-modal__btn mic-permission-modal__btn--primary" data-action="retry">\n Retry\n </button>\n <button class="mic-permission-modal__btn mic-permission-modal__btn--secondary" data-action="close">\n Close\n </button>\n </div>\n ',t.appendChild(n),e.overlay=t,e.modal=n,n.querySelector('[data-action="retry"]').addEventListener("click",()=>{window.location.reload()}),n.querySelector('[data-action="close"]').addEventListener("click",()=>{e.close(),A()}),t.addEventListener("click",n=>{n.target===t&&(e.close(),A())}),e.show(),e}function LA(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}function PA(A){return function(){var e=this,t=arguments;return new Promise(function(n,o){var r=A.apply(e,t);function i(A){LA(r,n,o,i,s,"next",A)}function s(A){LA(r,n,o,i,s,"throw",A)}i(void 0)})}}class RA{constructor(A){this.config=A,this.audioStream=null,this.callStartTime=null,this.callTimerInterval=null,this.sdk=null,this.isActive=!1,this.shadowRoot=A.shadowRoot||document,this.sdk=new yA({agentId:A.agentId,appId:A.appId,signedUrl:A.signedUrl,agentSettingsOverride:A.agentSettingsOverride,variables:A.variables||{},language:A.language||"en",outputContainer:A.outputContainer,outputEncoding:A.outputEncoding,outputSampleRate:A.outputSampleRate,outputChannels:A.outputChannels,outputBitDepth:A.outputBitDepth,onConversationStart:A.onConversationStart,onConversationEnd:A.onConversationEnd,onBargeIn:A.onBargeIn,onAudioStartPlaying:A.onAudioStartPlaying,onAudioStoppedPlaying:A.onAudioStoppedPlaying,onSubtitleDisplay:A.onSubtitleDisplay}),this.setupSDKEventHandlers(),this.checkAndHandleResume()}checkAndHandleResume(){if(this._resumeInfo)return console.log("đ [VOICE INTERFACE] Returning cached resume info:",this._resumeInfo),this._resumeInfo;var A=this.sdk.checkResumeBeforeConnect();return A?(console.log("đ [WIDGET] Auto-resuming call:",A),console.log(" From:",A.fromPage,"â To:",A.toPage),this._resumeInfo=A,this.config.onResume&&this.config.onResume(A),A):null}setupSDKEventHandlers(){this.sdk.onTranscript=A=>{console.log("đ [VOICE INTERFACE] onTranscript called with text:",A),this.updateTranscript(A)},this.sdk.onAgentSpeaking=A=>{var e=this.shadowRoot.getElementById("voiceAvatarActive");e&&(A?e.classList.add("speaking"):e.classList.remove("speaking"))},this.sdk.onDisconnected=()=>{console.log("đ WebSocket disconnected, hanging up call..."),this.isActive&&(this.isActive=!1,this.endVoiceCall())},this.sdk.onError=A=>{console.error("â Voice SDK Error:",A),A&&("DOMAIN_NOT_WHITELISTED"===A.message||A.message&&A.message.includes("Domain not whitelisted"))?this.showDomainError():this.showError(A.message||A)}}t(A){var e,t,n=this.config.language||"en";return((null===(e=this.config.translations)||void 0===e?void 0:e[n])||(null===(t=this.config.translations)||void 0===t?void 0:t.en)||{})[A]||A}getText(A,e){return void 0!==this.config[A]&&null!==this.config[A]?this.config[A]:this.t(e)}getTooltip(A){var e,t=null===(e=this.config.tooltips)||void 0===e?void 0:e[A];return null!=t?t:{mute:this.t("mute"),speaker:this.t("speaker"),endCall:this.t("endCall")}[A]||""}generateHTML(){return'<div class="voice-interface" id="voiceInterface">\n \x3c!-- Before Call State --\x3e\n <div id="voiceIdleState">\n <div class="voice-avatar" id="voiceAvatar">đ¤</div>\n <div class="voice-status">\n <div class="voice-status-title">'.concat(this.getText("startCallTitle","clickToStartCall"),'</div>\n <div class="voice-status-subtitle">').concat(this.getText("startCallSubtitle","realTimeVoice"),'</div>\n </div>\n <button class="start-call-btn" id="startCallBtn">\n <svg width="32" height="32" viewBox="0 0 24 24" fill="currentColor">\n <path d="M20.01 15.38c-1.23 0-2.42-.2-3.53-.56-.35-.12-.74-.03-1.01.24l-1.57 1.97c-2.83-1.35-5.48-3.9-6.89-6.83l1.95-1.66c.27-.28.35-.67.24-1.02-.37-1.11-.56-2.3-.56-3.53 0-.54-.45-.99-.99-.99H4.19C3.65 3 3 3.24 3 3.99 3 13.28 10.73 21 20.01 21c.71 0 .99-.63.99-1.18v-3.45c0-.54-.45-.99-.99-.99z"/>\n </svg>\n <span>').concat(this.getText("startCallButtonText","startCall"),'</span>\n </button>\n </div>\n \x3c!-- During Call State --\x3e\n <div id="voiceActiveState" style="display: none;">\n <div class="voice-avatar-active" id="voiceAvatarActive">\n <div class="voice-rings">\n <div class="voice-ring"></div>\n <div class="voice-ring"></div>\n <div class="voice-ring"></div>\n </div>\n đ¤\n </div>\n <div class="voice-status">\n <div class="voice-status-title" id="voiceStatusTitleActive">').concat(this.t("listening"),'</div>\n <div class="voice-status-subtitle" id="voiceStatusSubtitleActive">').concat(this.t("speakFreely"),'</div>\n </div>\n <div class="voice-transcript">\n <div class="transcript-label">').concat(this.t("liveTranscript"),'</div>\n <div class="transcript-text empty" id="transcriptText">\n ').concat(this.t("transcriptWillAppear"),'\n </div>\n </div>\n <div class="voice-controls">\n <button class="voice-control-btn secondary" id="muteBtn" title="').concat(this.getTooltip("mute"),'">\n <svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="mute-icon">\n <path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/>\n <path d="M19 10v2a7 7 0 0 1-14 0v-2"/>\n <line x1="12" y1="19" x2="12" y2="23"/>\n <line x1="8" y1="23" x2="16" y2="23"/>\n <line x1="2" y1="2" x2="22" y2="22" class="mute-cross" style="display: none; stroke: #ef4444; stroke-width: 3.5;"/>\n </svg>\n </button>\n <button class="voice-control-btn primary active" id="endCallBtn" title="').concat(this.getTooltip("endCall"),'">\n <svg width="56" height="56" viewBox="0 0 24 24" fill="#ef4444">\n <rect x="6" y="6" width="12" height="12" rx="2"/>\n </svg>\n <div class="voice-timer" id="voiceTimer">00:00</div>\n </button>\n <button class="voice-control-btn secondary" id="speakerBtn" title="').concat(this.getTooltip("speaker"),'">\n <svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">\n <polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/>\n <path d="M19.07 4.93a10 10 0 0 1 0 14.14"/>\n <path d="M15.54 8.46a5 5 0 0 1 0 7.07"/>\n </svg>\n </button>\n </div>\n </div>\n </div>')}generateCSS(){var A=this.config.avatarBackgroundColor||"#667eea",e=this.config.avatarActiveBackgroundColor||this.config.avatarBackgroundColor||"#667eea",t=this.config.statusTitleColor||"#1e293b",n=this.config.statusSubtitleColor||"#64748b",o=this.config.startCallButtonColor||"#667eea",r=this.config.startCallButtonTextColor||"#FFFFFF",i=this.config.transcriptBackgroundColor||"#FFFFFF",s=this.config.transcriptTextColor||"#1e293b",a=this.config.transcriptLabelColor||"#94a3b8",c=this.config.controlButtonColor||"#FFFFFF",l=this.config.controlButtonSecondaryColor||"#64748b",d=(this.config.endCallButtonColor,!1===this.config.useShadowDOM?" !important":"");return"\n /* Voice Interface Styles - Ultra-compact for Wix iframes */\n .voice-interface { \n display: none".concat(d,"; \n flex: 1; \n flex-direction: column;\n align-items: center; \n justify-content: center; \n padding: 6px 10px 6px 10px; \n background: linear-gradient(180deg, #f8fafc 0%, #e0e7ff 100%);\n overflow: hidden;\n min-height: 0;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n }\n .voice-interface.active { display: flex").concat(d,'; }\n \n /* Voice States - Better scaling gaps */\n #voiceIdleState,\n #voiceActiveState {\n display: flex;\n flex-direction: column;\n align-items: center;\n width: 100%;\n height: 100%;\n min-height: 0;\n justify-content: center;\n overflow: hidden;\n flex: 1;\n box-sizing: border-box;\n gap: clamp(6px, 1.5vh, 12px);\n }\n \n #voiceActiveState[style*="display: none"] {\n display: none !important;\n }\n \n /* Voice Avatar - Scales better from small to large */\n .voice-avatar,\n .voice-avatar-active {\n width: clamp(80px, 18vh, 160px);\n height: clamp(80px, 18vh, 160px);\n aspect-ratio: 1;\n border-radius: 50%;\n background: linear-gradient(135deg, ').concat(A," 0%, ").concat(e," 100%);\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: clamp(40px, 9vh, 80px);\n margin: 0;\n box-shadow: 0 8px 30px rgba(102, 126, 234, 0.3);\n transition: all 0.3s ease;\n flex-shrink: 1;\n position: relative;\n }\n \n .voice-avatar-active {\n animation: avatarPulse 2s ease-in-out infinite;\n }\n \n @keyframes avatarPulse {\n 0%, 100% { \n transform: scale(1);\n }\n 50% { \n transform: scale(1.05);\n }\n }\n \n .voice-avatar-active.speaking {\n animation: avatarSpeak 0.5s ease-in-out infinite;\n }\n \n @keyframes avatarSpeak {\n 0%, 100% { transform: scale(1); }\n 50% { transform: scale(1.08); }\n }\n \n /* Voice Rings Animation */\n .voice-rings {\n position: absolute;\n width: 100%;\n height: 100%;\n border-radius: 50%;\n }\n \n .voice-ring {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n border: 2px solid rgba(102, 126, 234, 0.3);\n border-radius: 50%;\n opacity: 0;\n animation: ringExpand 2s ease-out infinite;\n }\n \n .voice-ring:nth-child(2) { animation-delay: 0.5s; }\n .voice-ring:nth-child(3) { animation-delay: 1s; }\n \n @keyframes ringExpand {\n 0% {\n width: 100%;\n height: 100%;\n opacity: 0.6;\n }\n 100% {\n width: 160%;\n height: 160%;\n opacity: 0;\n }\n }\n \n /* Voice Status - Scales with container */\n .voice-status {\n text-align: center;\n margin: 0;\n flex-shrink: 1;\n min-height: 0;\n }\n \n .voice-status-title {\n font-size: clamp(12px, 3vh, 20px);\n font-weight: 600;\n color: ").concat(t,";\n margin-bottom: clamp(2px, 0.5vh, 4px);\n line-height: 1.2;\n }\n \n .voice-status-subtitle {\n font-size: clamp(10px, 2vh, 14px);\n color: ").concat(n,";\n line-height: 1.2;\n }\n \n /* Start Call Button - Scales with container */\n .start-call-btn {\n margin: 0;\n width: min(280px, 70vw);\n height: clamp(48px, 8vh, 64px);\n border-radius: clamp(24px, 4vh, 32px);\n border: none;\n background: ").concat(o,";\n color: ").concat(r,";\n font-size: clamp(14px, 2.5vh, 18px);\n font-weight: 600;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: clamp(8px, 1.5vh, 12px);\n box-shadow: 0 12px 30px rgba(102, 126, 234, 0.4);\n transition: all 0.3s ease;\n flex-shrink: 0;\n }\n \n .start-call-btn svg {\n width: clamp(22px, 4vh, 32px);\n height: clamp(22px, 4vh, 32px);\n }\n \n .start-call-btn:hover {\n transform: translateY(-2px);\n box-shadow: 0 12px 28px rgba(102, 126, 234, 0.5);\n }\n \n .start-call-btn:active {\n transform: translateY(-1px);\n }\n \n /* Voice Transcript - Scales with container */\n .voice-transcript {\n background: ").concat(i,";\n padding: clamp(6px, 1.5vh, 12px);\n border-radius: 10px;\n width: min(360px, calc(100% - 40px));\n margin: 0;\n min-height: clamp(100px, 18vh, 140px);\n max-height: clamp(120px, 22vh, 160px);\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);\n flex-shrink: 1;\n overflow-y: auto;\n overflow-x: hidden;\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n }\n \n .transcript-label {\n font-size: clamp(8px, 1.4vh, 11px);\n color: ").concat(a,";\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.3px;\n margin-bottom: clamp(3px, 0.6vh, 6px);\n flex-shrink: 0;\n word-wrap: break-word;\n }\n \n .transcript-text {\n font-size: clamp(11px, 2vh, 15px);\n color: ").concat(s,";\n line-height: 1.4;\n flex: 1;\n overflow-y: auto;\n overflow-x: hidden;\n word-wrap: break-word;\n overflow-wrap: break-word;\n }\n \n .transcript-text.empty {\n color: #cbd5e1;\n font-style: italic;\n }\n \n /* Voice Controls - Scales with container */\n .voice-controls {\n display: flex;\n gap: clamp(8px, 1.8vh, 14px);\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n margin: 0;\n padding-top: clamp(5px, 1.2vh, 10px);\n }\n \n .voice-control-btn {\n width: clamp(48px, 9vh, 72px);\n height: clamp(48px, 9vh, 72px);\n aspect-ratio: 1;\n border-radius: 50%;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s;\n position: relative;\n flex-shrink: 0;\n }\n \n .voice-control-btn svg {\n width: 48%;\n height: 48%;\n }\n \n .voice-control-btn.primary {\n width: clamp(54px, 10vh, 80px);\n height: clamp(54px, 10vh, 80px);\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n box-shadow: 0 6px 18px rgba(102, 126, 234, 0.4);\n }\n \n .voice-control-btn.primary:hover {\n transform: scale(1.05);\n }\n \n .voice-control-btn.primary.active {\n background: white;\n animation: recordingPulse 1.5s ease-in-out infinite;\n }\n \n @keyframes recordingPulse {\n 0%, 100% { \n box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);\n }\n 50% { \n box-shadow: 0 6px 24px rgba(239, 68, 68, 0.7);\n }\n }\n \n .voice-control-btn.secondary {\n background: ").concat(c,";\n color: ").concat(l,";\n box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);\n }\n \n .voice-control-btn.secondary:hover {\n background: #f8fafc;\n transform: scale(1.05);\n }\n \n .voice-control-btn.secondary.muted {\n background: #f3f4f6;\n }\n \n .voice-control-btn.secondary.muted .mute-icon {\n stroke: #9ca3af !important;\n }\n \n .voice-timer {\n position: absolute;\n bottom: clamp(-18px, -3vh, -24px);\n font-size: clamp(9px, 1.6vh, 12px);\n color: #64748b;\n font-weight: 500;\n white-space: nowrap;\n }\n \n /* Mobile optimization */\n @media (max-width: 768px) {\n .voice-interface {\n padding: 6px 10px;\n }\n }\n \n @media (max-width: 480px) {\n .voice-interface {\n padding: 5px 8px;\n }\n }\n ")}setupEventHandlers(A){var e=this,t=this.shadowRoot.getElementById("startCallBtn"),n=this.shadowRoot.getElementById("endCallBtn"),o=this.shadowRoot.getElementById("muteBtn"),r=this.shadowRoot.getElementById("speakerBtn");t&&(t.onclick=()=>this.startVoiceCall()),n&&(n.onclick=()=>this.endVoiceCall()),o&&(o.onclick=()=>this.toggleMute()),r&&(r.onclick=()=>this.toggleSpeaker());var i=function(){var A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=e.shadowRoot.getElementById("voiceInterface");t&&t.classList.contains("active")&&t.clientHeight>100?(console.log("â
Interface is active and has proper dimensions, adjusting sizes (attempt",A+1,")"),e.adjustSizesForContainer(),0===A&&setTimeout(()=>e.adjustSizesForContainer(),500)):A<15?(console.log("âŗ Interface not ready yet (height:",null==t?void 0:t.clientHeight,"), retrying... (attempt",A+1,")"),setTimeout(()=>i(A+1),250)):(console.warn("â ī¸ Interface never became fully ready, adjusting sizes anyway"),e.adjustSizesForContainer())};setTimeout(()=>i(),200),window.addEventListener("resize",()=>{console.log("đ Window resized, re-adjusting sizes"),this.adjustSizesForContainer()})}getSignedUrl(){var A=this;return PA(function*(){if(A.config.signedUrl)return A.config.signedUrl;if(!A.config.agentId)throw new Error("agentId is required when signedUrl is not provided");var e=A.config.websocketUrl||"wss://speech.talktopc.com/ws/conv",t=new URLSearchParams;return t.append("agentId",A.config.agentId),A.config.appId&&t.append("appId",A.config.appId),!1!==A.config.demo&&t.append("demo","true"),"".concat(e,"?").concat(t.toString())})()}adjustSizesForContainer(){var A=this.shadowRoot.getElementById("voiceInterface");if(A){var e=A.clientHeight,t=A.clientWidth;console.log("đ Container size:",e,"x",t);var n,o,r,i,s,a,c,l,d,u=this.shadowRoot.getElementById("voiceIdleState"),g=this.shadowRoot.getElementById("voiceActiveState"),B=u&&"none"!==u.style.display,h=g&&"none"!==g.style.display;console.log("đī¸ Visible state - Idle:",B,"Active:",h),e<=350?(d=5,n=70,o=35,r=11,i=9,s=32,a=100,c=42,l=48):e<=450?(d=7,n=110,o=55,r=15,i=11,s=38,a=110,c=52,l=58):e<=550?(d=8,n=140,o=70,r=16,i=12,s=42,a=120,c=56,l=64):e<=700?(d=10,n=130,o=65,r=18,i=13,s=46,a=130,c=60,l=70):(d=12,n=150,o=75,r=20,i=14,s=50,a=140,c=66,l=76),this.shadowRoot.querySelectorAll("#voiceIdleState, #voiceActiveState").forEach(A=>{A.style.gap="".concat(d,"px")});var p=this.shadowRoot.querySelectorAll(".voice-avatar, .voice-avatar-active");console.log("đ¤ Found",p.length,"avatars, setting size to",n,"px"),p.forEach(A=>{A.style.width="".concat(n,"px"),A.style.height="".concat(n,"px"),A.style.fontSize="".concat(o,"px")}),this.shadowRoot.querySelectorAll(".voice-status-title").forEach(A=>A.style.fontSize="".concat(r,"px")),this.shadowRoot.querySelectorAll(".voice-status-subtitle").forEach(A=>A.style.fontSize="".concat(i,"px"));var w=this.shadowRoot.querySelector(".voice-transcript");w&&(w.style.minHeight="".concat(a,"px"),w.style.maxHeight="".concat(a,"px"),w.style.height="".concat(a,"px"),w.style.width="min(360px, ".concat(t-40,"px)"),w.style.boxSizing="border-box");var f=this.shadowRoot.querySelector(".transcript-label");f&&(f.style.fontSize="".concat(Math.max(8,r-4),"px"));var C=this.shadowRoot.querySelector(".transcript-text");C&&(C.style.fontSize="".concat(Math.max(10,r-2),"px")),this.shadowRoot.querySelectorAll(".voice-control-btn.secondary").forEach(A=>{A.style.width="".concat(c,"px"),A.style.height="".concat(c,"px");var e=A.querySelector("svg");if(e){var t=.65*c;e.style.setProperty("width","".concat(t,"px"),"important"),e.style.setProperty("height","".concat(t,"px"),"important"),e.style.setProperty("min-width","".concat(t,"px"),"important"),e.style.setProperty("min-height","".concat(t,"px"),"important")}});var m=this.shadowRoot.querySelector(".voice-control-btn.primary");if(m){m.style.width="".concat(l,"px"),m.style.height="".concat(l,"px");var v=m.querySelector("svg");if(v){var Q=.7*l;v.style.setProperty("width","".concat(Q,"px"),"important"),v.style.setProperty("height","".concat(Q,"px"),"important"),v.style.setProperty("min-width","".concat(Q,"px"),"important"),v.style.setProperty("min-height","".concat(Q,"px"),"important")}}var F=this.shadowRoot.querySelector(".start-call-btn");if(F){var U,y;e<=350?(U=48,y=14):e<=450?(U=52,y=15):e<=550?(U=58,y=17):e<=700?(U=62,y=18):(U=64,y=18),F.style.height="".concat(U,"px"),F.style.fontSize="".concat(y,"px");var b=F.querySelector("svg");if(b){var E=Math.max(22,.5*U);b.style.width="".concat(E,"px"),b.style.height="".concat(E,"px")}}console.log("â
Sizes adjusted - Avatar:",n,"Status:",s,"Transcript:",a,"Buttons:",c)}else console.warn("â ī¸ voiceInterface not found, skipping size adjustment")}startVoiceCall(){var A=this;return PA(function*(){if(A.isActive)console.log("â ī¸ Voice call already active");else{console.log("đ¤ Starting voice call...");var e=yield xA();if(console.log("đ Current permission state: ".concat(e)),"denied"!==e){if("prompt"===e||"unknown"===e)return console.log("đ Permission is in prompt state, showing pre-prompt modal..."),new Promise(e=>{KA(PA(function*(){console.log("â
Pre-prompt accepted, proceeding with voice call..."),yield A.proceedWithVoiceCall(),e()}),()=>{console.log("â Pre-prompt cancelled"),e()})});yield A.proceedWithVoiceCall()}else console.log("đĢ Permission is denied, showing blocked modal..."),EA(),TA(()=>{console.log("Blocked modal closed")})}})()}proceedWithVoiceCall(){var A=this;return PA(function*(){try{var e=A.shadowRoot.getElementById("voiceIdleState"),t=A.shadowRoot.getElementById("voiceActiveState"),n=A.shadowRoot.getElementById("voiceInterface");e&&(e.style.display="none"),t&&(t.style.display="flex"),setTimeout(()=>A.adjustSizesForContainer(),50),n&&(n.scrollTop=0);var o=EA(),r=yield xA();if(o.isMobile&&"granted"!==r){console.log("đą Mobile device detected - requesting mic permission before connecting..."),console.log("đ Current permission state: ".concat(r));try{var i=A.config.outputSampleRate||44100;(yield navigator.mediaDevices.getUserMedia({audio:{sampleRate:i,channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})).getTracks().forEach(A=>A.stop()),console.log("â
Microphone permission granted on mobile - proceeding with connection")}catch(e){return console.log("đĢ Permission denied on mobile, showing blocked modal..."),void TA(()=>{A.resetUIState()})}}var s=yield A.getSignedUrl();if(console.log("đ Got signed URL:",s),A.sdk&&A.sdk.isConnected){console.log("đ SDK already connected, disconnecting for clean retry...");try{A.sdk.disconnect(),yield new Promise(A=>setTimeout(A,100))}catch(A){console.warn("Warning: Error disconnecting existing connection:",A)}}var a=yield A.sdk.connect(s);console.log("â
Connected to WebSocket, connected:",a);for(var c=0;c<50&&!(A.sdk.isConnected&&A.sdk.voiceSDK&&A.sdk.voiceSDK.isConnected&&A.sdk.voiceSDK.websocket&&A.sdk.voiceSDK.websocket.readyState===WebSocket.OPEN);)yield new Promise(A=>setTimeout(A,100)),c++;A.sdk.isConnected&&A.sdk.voiceSDK&&A.sdk.voiceSDK.websocket&&A.sdk.voiceSDK.websocket.readyState===WebSocket.OPEN?(console.log("â
WebSocket ready, starting listening..."),yield A.sdk.startListening(),console.log("đ¤ Started listening"),A.isActive=!0,A.callStartTime=Date.now(),A.callTimerInterval=setInterval(()=>{var e=Date.now()-A.callStartTime,t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3),o=A.shadowRoot.getElementById("voiceTimer");o&&(o.textContent="".concat(t.toString().padStart(2,"0"),":").concat(n.toString().padStart(2,"0")))},1e3)):(console.warn("â ī¸ Connection not fully ready, but trying to start listening anyway..."),yield A.sdk.startListening(),console.log("đ¤ Started listening"),A.isActive=!0,A.callStartTime=Date.now(),A.callTimerInterval=setInterval(()=>{var e=Date.now()-A.callStartTime,t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3),o=A.shadowRoot.getElementById("voiceTimer");o&&(o.textContent="".concat(t.toString().padStart(2,"0"),":").concat(n.toString().padStart(2,"0")))},1e3)),console.log("â
Voice call started successfully")}catch(e){if(console.error("â Error starting voice call:",e),A.isActive=!1,A.callTimerInterval&&(clearInterval(A.callTimerInterval),A.callTimerInterval=null),A.sdk&&A.sdk.isConnected)try{A.sdk.disconnect()}catch(A){console.warn("Error disconnecting SDK on error:",A)}"NotAllowedError"===e.name||"PermissionDeniedError"===e.name?(EA(),TA(()=>{A.resetUIState()})):"NotFoundError"===e.name||"DevicesNotFoundError"===e.name?kA(()=>{A.resetUIState()}):(A.showError(e.message||e),A.resetUIState())}})()}resetUIState(){var A=this.shadowRoot.getElementById("voiceIdleState"),e=this.shadowRoot.getElementById("voiceActiveState");A&&(A.style.display="flex"),e&&(e.style.display="none")}endVoiceCall(){console.log("đ´ Ending voice call..."),this.sdk&&this.isActive&&(this.sdk.stopListening(),this.sdk.hangup(),this.isActive=!1),this.audioStream&&(this.audioStream.getTracks().forEach(A=>A.stop()),this.audioStream=null),this.callTimerInterval&&(clearInterval(this.callTimerInterval),this.callTimerInterval=null);var A=this.shadowRoot.getElementById("voiceIdleState"),e=this.shadowRoot.getElementById("voiceActiveState");A&&(A.style.display="flex"),e&&(e.style.display="none"),setTimeout(()=>this.adjustSizesForContainer(),50);var t=this.shadowRoot.getElementById("transcriptText");t&&(t.textContent=this.t("transcriptWillAppear"),t.classList.add("empty"));var n=this.shadowRoot.getElementById("voiceAvatarActive");n&&n.classList.remove("speaking"),console.log("â
Voice call ended")}updateTranscript(A){console.log("đ [VOICE INTERFACE] updateTranscript called with text:",A);var e=this.shadowRoot.getElementById("transcriptText");e?(console.log("đ [VOICE INTERFACE] Found transcript element, updating text"),e.textContent=A,e.classList.remove("empty")):console.warn("đ [VOICE INTERFACE] â ī¸ transcriptText element not found!")}showError(A){var e=this.shadowRoot.getElementById("transcriptText");e&&(e.textContent="".concat(this.t("error"),": ").concat(A),e.classList.remove("empty"))}showDomainError(){var A=this.shadowRoot.getElementById("transcriptText");if(A){var e=this.t("domainNotValidated"),t=this.t("domainErrorMessage");A.innerHTML='<div style="font-weight: 600; font-size: 16px; margin-bottom: 8px; color: #991B1B;">'.concat(e,'</div><div style="font-size: 14px; color: #991B1B; line-height: 1.5;">').concat(t,"</div>"),A.classList.remove("empty")}}toggleMute(){if(this.sdk&&this.isActive){var A=null;if(this.sdk.voiceSDK&&this.sdk.voiceSDK.audioRecorder&&this.sdk.voiceSDK.audioRecorder.mediaStream&&(A=this.sdk.voiceSDK.audioRecorder.mediaStream.getAudioTracks()[0]),!A&&this.audioStream&&(A=this.audioStream.getAudioTracks()[0]),A){A.enabled=!A.enabled;var e=this.shadowRoot.getElementById("muteBtn"),t=null==e?void 0:e.querySelector(".mute-icon"),n=null==e?void 0:e.querySelector(".mute-cross");e&&t&&n&&(A.enabled?(t.style.stroke="",n.style.display="none",e.classList.remove("muted")):(t.style.stroke="#9ca3af",n.style.display="block",e.classList.add("muted"))),console.log(A.enabled?"đ Unmuted":"đ Muted")}else console.warn("â ī¸ No audio track available for mute toggle")}}toggleSpeaker(){console.log("đ Speaker toggle")}destroy(){this.isActive&&this.endVoiceCall(),this.audioStream&&(this.audioStream.getTracks().forEach(A=>A.stop()),this.audioStream=null),this.callTimerInterval&&(clearInterval(this.callTimerInterval),this.callTimerInterval=null),this.sdk&&(this.sdk.disconnect(),this.sdk=null)}}function OA(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}function MA(A){return function(){var e=this,t=arguments;return new Promise(function(n,o){var r=A.apply(e,t);function i(A){OA(r,n,o,i,s,"next",A)}function s(A){OA(r,n,o,i,s,"throw",A)}i(void 0)})}}class VA{constructor(A,e){this.config=A,this.sdk=e,this.streamingEl=null,this.hasStartedStreaming=!1,this.isActive=!1,this.shadowRoot=A.shadowRoot||document,this.eventHandlers={autoResize:null,keydown:null},this.eventHandlersSetup=!1}t(A){var e,t,n=this.config.language||"en";return((null===(e=this.config.translations)||void 0===e?void 0:e[n])||(null===(t=this.config.translations)||void 0===t?void 0:t.en)||{})[A]||A}generateHTML(){var A,e,t,n,o,r,i,s,a,c=this.config.inputPlaceholder||(null===(A=this.config.panel)||void 0===A?void 0:A.inputPlaceholder)||this.t("typeMessage")||"Type your message...";return'<div class="text-interface" id="textInterface">\n <div class="messages-container" id="messagesContainer">\n <div class="empty-state">\n <div class="empty-state-icon">đŦ</div>\n <div class="empty-state-title">'.concat(this.t("hello"),'</div>\n <div class="empty-state-text">').concat(this.t("sendMessage"),'</div>\n </div>\n </div>\n <div class="input-container">\n <div class="input-wrapper" style="flex:1;">\n <textarea class="message-input" id="messageInput" placeholder="').concat(c,'" rows="1" dir="').concat(this.config.direction||"ltr",'"></textarea>\n </div>\n <button class="send-button" id="sendButton" aria-label="').concat(this.t("sendMessageAria"),'">').concat(this.config.sendButtonText||"â¤","</button>\n ").concat(null!==(e=this.config.sendButtonHint)&&void 0!==e&&e.text||null!==(t=this.config.panel)&&void 0!==t&&null!==(t=t.sendButtonHint)&&void 0!==t&&t.text?'\n <div class="send-button-hint" style="color: '.concat((null===(n=this.config.sendButtonHint)||void 0===n?void 0:n.color)||(null===(o=this.config.panel)||void 0===o||null===(o=o.sendButtonHint)||void 0===o?void 0:o.color)||"#6B7280","; font-size: ").concat((null===(r=this.config.sendButtonHint)||void 0===r?void 0:r.fontSize)||(null===(i=this.config.panel)||void 0===i||null===(i=i.sendButtonHint)||void 0===i?void 0:i.fontSize)||"12px",'; text-align: center; margin-top: 4px;">\n ').concat((null===(s=this.config.sendButtonHint)||void 0===s?void 0:s.text)||(null===(a=this.config.panel)||void 0===a||null===(a=a.sendButtonHint)||void 0===a?void 0:a.text),"\n </div>\n "):"","\n </div>\n </div>")}generateCSS(){var A,e,t,n,o,r,i,s,a,c,l,d,u,g=this.config.messages,B=(this.config.panel,this.config.animation,this.config.sendButtonColor||(null===(A=this.config.panel)||void 0===A?void 0:A.sendButtonColor)||"#7C3AED"),h=this.config.sendButtonHoverColor||(null===(e=this.config.panel)||void 0===e?void 0:e.sendButtonHoverColor)||"#6D28D9",p=this.config.sendButtonTextColor||(null===(t=this.config.panel)||void 0===t?void 0:t.sendButtonTextColor)||"#FFFFFF",w=(this.config.inputPlaceholder||null===(n=this.config.panel)||void 0===n||n.inputPlaceholder,this.config.inputBorderColor||(null===(o=this.config.panel)||void 0===o?void 0:o.inputBorderColor)||"#E5E7EB"),f=this.config.inputFocusColor||(null===(r=this.config.panel)||void 0===r?void 0:r.inputFocusColor)||"#7C3AED",C=this.config.inputBackgroundColor||(null===(i=this.config.panel)||void 0===i?void 0:i.inputBackgroundColor)||"#FFFFFF",m=this.config.inputTextColor||(null===(s=this.config.panel)||void 0===s?void 0:s.inputTextColor)||"#1F2937",v=this.config.inputFontSize||(null===(a=this.config.panel)||void 0===a?void 0:a.inputFontSize)||"14px",Q=this.config.inputBorderRadius||(null===(c=this.config.panel)||void 0===c?void 0:c.inputBorderRadius)||20,F=this.config.inputPadding||(null===(l=this.config.panel)||void 0===l?void 0:l.inputPadding)||"6px 14px",U=!1===this.config.useShadowDOM?" !important":"";return"\n /* Messages container using new classes */\n #messagesContainer { \n flex: 1; \n overflow-y: auto; \n overflow-x: hidden; \n padding: 20px; \n background: #f8fafc; \n display: flex; \n flex-direction: column; \n gap: 16px; \n min-height: 0; \n }\n .empty-state { \n flex: 1; \n display: flex; \n flex-direction: column; \n align-items: center; \n justify-content: center; \n gap: 12px; \n color: #64748b; \n text-align: center; \n padding: 20px; \n }\n .empty-state-icon { font-size: 48px; opacity: 0.3; }\n .empty-state-title { font-size: 20px; font-weight: 700; color: #334155; }\n .empty-state-text { font-size: 13px; max-width: 280px; }\n\n .text-interface { \n display: none".concat(U,"; \n flex: 1; \n flex-direction: column; \n min-height: 0; \n overflow: hidden; \n }\n .text-interface.active { display: flex").concat(U,"; }\n \n .message { \n display: flex; \n gap: 8px; \n padding: 4px 0; \n max-width: 100%; \n align-items: center; \n }\n .message.edge-left { flex-direction: row; }\n .message.edge-right { flex-direction: row-reverse; }\n .message-bubble { \n padding: 12px; \n border-radius: ").concat(g.borderRadius,"px; \n max-width: 80%; \n font-size: ").concat(g.fontSize,"; \n color: ").concat(g.textColor,"; \n word-wrap: break-word; \n text-align: ").concat("rtl"===this.config.direction?"right":"left","; \n direction: ").concat(this.config.direction||"ltr",";\n }\n .message.user { \n background: ").concat(g.userBackgroundColor,"; \n align-self: ").concat("rtl"===this.config.direction?"flex-start":"flex-end","; \n }\n .message.agent { \n background: ").concat(g.agentBackgroundColor,"; \n align-self: ").concat("rtl"===this.config.direction?"flex-end":"flex-start","; \n }\n .message .message-bubble { \n text-align: ").concat("rtl"===this.config.direction?"right":"left"," !important; \n }\n ").concat("rtl"===this.config.direction?"\n .message-bubble {\n text-align: right !important;\n }\n ":"","\n .message-avatar { \n width: 20px; \n height: 20px; \n display: flex; \n align-items: center; \n justify-content: center; \n flex-shrink: 0; \n color: inherit; \n font-size: 18px; \n line-height: 1; \n background: transparent; \n border: none; \n }\n .message-avatar.user { background: transparent; }\n .message-avatar.agent { background: transparent; }\n \n .message.system {\n background: ").concat(g.systemBackgroundColor,";\n align-self: flex-start;\n }\n .message.error {\n background: ").concat(g.errorBackgroundColor,";\n align-self: flex-start;\n }\n \n .input-container {\n display: flex;\n gap: 8px;\n padding: 12px 16px;\n background: #FFFFFF;\n border-top: 1px solid #E5E7EB;\n align-items: center;\n flex-shrink: 0;\n flex-direction: ").concat("rtl"===this.config.direction?"row-reverse":"row",";\n }\n \n .input-wrapper {\n position: relative;\n display: flex;\n align-items: center;\n }\n \n .message-input {\n width: 100%;\n min-height: 32px;\n max-height: 120px;\n padding: ").concat(F,";\n border: 1px solid ").concat(w,";\n border-radius: ").concat(Q,"px;\n font-size: ").concat(v,";\n font-family: inherit;\n line-height: 1.3;\n resize: none;\n overflow-y: auto;\n background: ").concat(C,";\n color: ").concat(m,";\n vertical-align: top;\n margin: 0;\n display: block;\n white-space: pre-wrap;\n word-wrap: break-word;\n text-align: ").concat("rtl"===this.config.direction?"right":"left",";\n direction: ").concat(this.config.direction||"ltr",";\n -webkit-appearance: none;\n appearance: none;\n box-sizing: border-box;\n }\n \n .message-input:focus {\n outline: none;\n border-color: ").concat(f,";\n background: ").concat("#FFFFFF"===C?"#FFFFFF":C,";\n box-shadow: 0 0 0 3px ").concat(f,"33;\n }\n \n .message-input::placeholder {\n color: #9CA3AF;\n text-align: ").concat("rtl"===this.config.direction?"right":"left",";\n }\n \n .send-button {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n border: none;\n background: ").concat(B,";\n color: ").concat(p,";\n font-size: ").concat(this.config.sendButtonFontSize||(null===(d=this.config.panel)||void 0===d?void 0:d.sendButtonFontSize)||"18px",";\n font-weight: ").concat(this.config.sendButtonFontWeight||(null===(u=this.config.panel)||void 0===u?void 0:u.sendButtonFontWeight)||"500",";\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n transition: all 0.2s ease;\n box-shadow: 0 4px 12px rgba(124, 60, 237, 0.3);\n }\n \n .send-button:hover:not(:disabled) {\n background: ").concat(h,";\n transform: scale(1.05);\n box-shadow: 0 6px 16px rgba(124, 60, 237, 0.4);\n }\n \n .send-button-hint {\n width: 100%;\n text-align: center;\n margin-top: 4px;\n }\n \n .send-button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n \n .typing-indicator {\n display: inline-flex;\n gap: 4px;\n align-items: center;\n }\n \n .typing-dot {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: #64748b;\n animation: typingDot 1.4s ease-in-out infinite;\n }\n \n .typing-dot:nth-child(2) { animation-delay: 0.2s; }\n .typing-dot:nth-child(3) { animation-delay: 0.4s; }\n \n @keyframes typingDot {\n 0%, 60%, 100% { transform: translateY(0); opacity: 0.7; }\n 30% { transform: translateY(-8px); opacity: 1; }\n }\n \n .error-message {\n padding: 12px;\n background: ").concat(g.errorBackgroundColor,";\n border-radius: ").concat(g.borderRadius,"px;\n color: #991B1B;\n font-size: ").concat(g.fontSize,";\n margin: 8px 0;\n }\n \n @media (max-width: 768px) {\n #messagesContainer {\n padding: 12px;\n gap: 12px;\n }\n \n .message-bubble {\n max-width: 85%;\n font-size: 14px;\n padding: 10px;\n }\n \n .text-input-container {\n padding: 10px;\n gap: 8px;\n }\n \n #text-chat-input {\n font-size: 16px !important; /* Prevents iOS zoom on focus */\n padding: 10px 14px;\n min-height: 44px;\n }\n \n #text-chat-send {\n min-width: 56px;\n min-height: 44px;\n width: 56px;\n height: 44px;\n }\n \n .empty-state-icon {\n font-size: 40px;\n }\n \n .empty-state-title {\n font-size: 18px;\n }\n \n .empty-state-text {\n font-size: 12px;\n }\n }\n \n @media (max-width: 480px) {\n #messagesContainer {\n padding: 10px;\n gap: 10px;\n }\n \n .message-bubble {\n max-width: 90%;\n font-size: 13px;\n padding: 8px;\n }\n \n .text-input-container {\n padding: 8px;\n }\n \n #text-chat-input {\n font-size: 16px !important;\n padding: 8px 12px;\n }\n }\n ")}setupEventHandlers(){var A=this.shadowRoot.getElementById("sendButton"),e=this.shadowRoot.getElementById("messageInput"),t=this.shadowRoot.getElementById("newChatBtn");if(A&&(A.onclick=()=>this.sendMessage()),t&&(t.onclick=()=>this.startNewChat()),this.updateInputAttributes(),e){e.style.height="32px",e.style.overflow="hidden";var n=()=>{e.style.height="auto";var A=Math.min(e.scrollHeight,120);e.style.height=A+"px",e.style.overflowY=A>=120?"auto":"hidden",A>=120&&setTimeout(()=>{e.scrollTop=e.scrollHeight},0)};e.addEventListener("input",n),e.addEventListener("keydown",A=>{"Enter"!==A.key||A.shiftKey?"Enter"===A.key&&A.shiftKey&&setTimeout(n,0):(A.preventDefault(),this.sendMessage())})}}startNewChat(){try{localStorage.removeItem("ttp_text_chat_conversation_id")}catch(A){}this.sdk&&(this.sdk.config.conversationId=null);var A=this.shadowRoot.getElementById("messagesContainer");A&&(A.innerHTML='\n <div class="empty-state">\n <div class="empty-state-icon">đŦ</div>\n <div class="empty-state-title">'.concat(this.t("hello"),'</div>\n <div class="empty-state-text">').concat(this.t("sendMessage"),"</div>\n </div>"));var e=this.shadowRoot.getElementById("messageInput");e&&e.focus()}updateInputAttributes(){var A=this.shadowRoot.getElementById("messageInput");if(A){var e,t=this.config.inputPlaceholder||(null===(e=this.config.panel)||void 0===e?void 0:e.inputPlaceholder)||this.t("typeMessage")||"Type your message...";A.placeholder=t,A.dir=this.config.direction||"ltr",A.style.textAlign="rtl"===this.config.direction?"right":"left"}}show(){var A=this.shadowRoot.getElementById("textInterface");A&&A.classList.add("active"),setTimeout(()=>{var A=this.shadowRoot.getElementById("messageInput");A&&A.focus()},50)}hide(){var A=this.shadowRoot.getElementById("textInterface");A&&A.classList.remove("active")}startChat(){var A=this;return MA(function*(){A.isActive=!0,A.updateSendButtonState()})()}sendMessage(){var A=this;return MA(function*(){var e=A.shadowRoot.getElementById("messageInput"),t=e.value.trim();if(t){A.isActive||(yield A.startChat()),A.addMessage("user",t),e.value="",e.style.height="32px",e.style.overflow="hidden";try{A.beginStreaming(),yield A.sdk.sendMessage(t)}catch(e){console.error("â Failed to send message:",e),e&&("DOMAIN_NOT_WHITELISTED"===e.message||e.message&&e.message.includes("Domain not whitelisted"))||A.showError(e),A.stopStreamingState()}}})()}updateSendButtonState(){var A=this.shadowRoot.getElementById("sendButton");A&&(A.disabled=!this.isActive)}addMessage(A,e){var t=this.shadowRoot.getElementById("messagesContainer");if(t){var n=t.querySelector(".empty-state");n&&n.remove();var o=document.createElement("div"),r="rtl"===this.config.direction?"user"===A?"edge-left":"edge-right":"user"===A?"edge-right":"edge-left";o.className="message ".concat(A," ").concat(r);var i=document.createElement("div");i.className="message-avatar ".concat(A),i.textContent="user"===A?"đ¤":"đ¤";var s=document.createElement("div");s.className="message-bubble",s.textContent=e,o.appendChild(i),o.appendChild(s),t.appendChild(o),t.scrollTop=t.scrollHeight}}beginStreaming(){var A=this.shadowRoot.getElementById("messagesContainer");if(A){this.stopStreamingState();var e=document.createElement("div"),t="rtl"===this.config.direction?"edge-right":"edge-left";e.className="message agent ".concat(t),e.id="agent-streaming";var n=document.createElement("div");n.className="message-avatar agent",n.textContent="đ¤";var o=document.createElement("div");o.className="message-bubble",o.innerHTML='<span class="typing-indicator"><span class="typing-dot"></span><span class="typing-dot"></span><span class="typing-dot"></span></span>',e.appendChild(n),e.appendChild(o),A.appendChild(e),this.streamingEl=o,this.hasStartedStreaming=!1,A.scrollTop=A.scrollHeight}}appendStreamingChunk(A){if(this.streamingEl){this.hasStartedStreaming||(this.streamingEl.textContent="",this.hasStartedStreaming=!0),this.streamingEl.textContent+=A;var e=this.shadowRoot.getElementById("messagesContainer");e&&(e.scrollTop=e.scrollHeight)}}finalizeStreaming(A){if(this.streamingEl){this.streamingEl.textContent=A||this.streamingEl.textContent;var e=this.shadowRoot.getElementById("agent-streaming");e&&(e.id=""),this.streamingEl=null}this.updateSendButtonState()}stopStreamingState(){var A=this.shadowRoot.getElementById("agent-streaming");A&&A.remove(),this.streamingEl=null,this.hasStartedStreaming=!1}showError(A){var e=this.shadowRoot.getElementById("messagesContainer");if(e){if(A&&("DOMAIN_NOT_WHITELISTED"===A.message||"string"==typeof A&&A.includes("DOMAIN_NOT_WHITELISTED")||A.message&&A.message.includes("Domain not whitelisted")||"string"==typeof A&&A.includes("Domain not whitelisted"))){var t,n=document.createElement("div");n.className="error-message",n.style.cssText="padding: 16px; margin: 12px; border-radius: 8px; background: "+((null===(t=this.config.messages)||void 0===t?void 0:t.errorBackgroundColor)||"#FEE2E2")+";";var o=document.createElement("div");o.style.cssText="font-weight: 600; font-size: 16px; margin-bottom: 8px; color: #991B1B;",o.textContent=this.t("domainNotValidated");var r=document.createElement("div");r.style.cssText="font-size: 14px; color: #991B1B; line-height: 1.5;",r.textContent=this.t("domainErrorMessage"),n.appendChild(o),n.appendChild(r),e.appendChild(n)}else{var i=document.createElement("div");i.className="error-message",i.textContent="string"==typeof A?A:(null==A?void 0:A.message)||A,e.appendChild(i)}e.scrollTop=e.scrollHeight}}setActive(A){this.isActive=A,this.updateSendButtonState()}}const NA={en:{landingTitle:"How would you like to communicate?",voiceCall:"Voice Call",textChat:"Text Chat",clickToStartCall:"Click to Start Call",realTimeVoice:"Real-time voice conversation",startCall:"Start Call",listening:"Listening...",speakFreely:"Speak freely",liveTranscript:"Live Transcript",transcriptWillAppear:"Transcript will appear here during the call...",mute:"Mute",speaker:"Speaker",endCall:"End Call",hello:"Hello! How can I help?",sendMessage:"Send a message to get started",online:"Online",newChat:"New Chat",back:"Back",close:"Close",error:"Error",typeMessage:"Type your message...",sendMessageAria:"Send message",domainNotValidated:"Domain not validated",domainErrorMessage:"This domain is not whitelisted. Please contact the administrator to whitelist your website URL."},he:{landingTitle:"××× ×Ēר×Ļ× ××Ēק׊ר?",voiceCall:"׊××× ×§××××Ē",textChat:"×Ļ'×× ×קץ×",clickToStartCall:"×××Ĩ ×××Ē×××Ē ×Š×××",realTimeVoice:"׊××× ×§××××Ē ×××× ×××Ē",startCall:"××Ē×× ×Š×××",listening:"×ק׊××...",speakFreely:"××ר ×××פ׊×××Ē",liveTranscript:"×Ē×××× ×××× ×××Ē",transcriptWillAppear:"××Ē×××× ××פ××ĸ ××× ××××× ×׊×××...",mute:"×׊×Ē×§",speaker:"ר××§××",endCall:"ץ××× ×Š×××",hello:"׊×××! ××× ×פ׊ר ××ĸ××ר?",sendMessage:"׊×× ××××ĸ× ×× ×ĸ××ר ×××Ļ× ×§××× ×׊××× ×××× ×××Ē",online:"××§×××",newChat:"×Ļ'×× ××׊",back:"×××ר",close:"ץ××ר",error:"׊××××",typeMessage:"××§×× ××××ĸ×...",sendMessageAria:"׊×× ××××ĸ×",domainNotValidated:"×××××× ×× ×××××Ē",domainErrorMessage:"×××××× ×× ×× ×ר׊×××Ē ×××ר׊××. ×× × ×¤× × ××× ×× ×××ĸר××Ē ××× ×××ץ××Ŗ ××Ē ××Ē×××Ē ×××Ēר ׊×× ×ר׊×××."},ar:{landingTitle:"ŲŲŲ ØĒØąŲØ¯ Ø§ŲØĒŲØ§ØĩŲØ",voiceCall:"Ų
ŲØ§ŲŲ
ØŠ ØĩŲØĒŲØŠ",textChat:"Ø¯ØąØ¯Ø´ØŠ ŲØĩŲØŠ",clickToStartCall:"اŲŲØą ŲØ¨Ø¯ØĄ اŲŲ
ŲØ§ŲŲ
ØŠ",realTimeVoice:"Ų
ØØ§Ø¯ØĢØŠ ØĩŲØĒŲØŠ ŲŲ Ø§ŲŲŲØĒ Ø§ŲŲØšŲŲ",startCall:"Ø§Ø¨Ø¯ØŖ اŲŲ
ŲØ§ŲŲ
ØŠ",listening:"Ø§ŲØ§ØŗØĒŲ
اؚ...",speakFreely:"ØĒŲŲŲ
Ø¨ØØąŲØŠ",liveTranscript:"ŲØĩ Ų
Ø¨Ø§Ø´Øą",transcriptWillAppear:"ØŗŲØ¸ŲØą اŲŲØĩ ŲŲØ§ ØŖØĢŲØ§ØĄ اŲŲ
ŲØ§ŲŲ
ØŠ...",mute:"ŲØĒŲ
Ø§ŲØĩŲØĒ",speaker:"Ų
ŲØ¨Øą Ø§ŲØĩŲØĒ",endCall:"ØĨŲŲØ§ØĄ اŲŲ
ŲØ§ŲŲ
ØŠ",hello:"Ų
ØąØØ¨Ø§! ŲŲŲ ŲŲ
ŲŲŲŲ Ø§ŲŲ
ØŗØ§ØšØ¯ØŠØ",sendMessage:"ØŖØąØŗŲ ØąØŗØ§ŲØŠ ŲŲØ¨Ø¯ØĄ",online:"Ų
ØĒØĩŲ",newChat:"Ų
ØØ§Ø¯ØĢØŠ ØŦØ¯ŲØ¯ØŠ",back:"ØąØŦŲØš",close:"ØĨØēŲØ§Ų",error:"ØŽØˇØŖ",typeMessage:"Ø§ŲØĒØ¨ ØąØŗØ§ŲØŠ...",sendMessageAria:"ØĨØąØŗØ§Ų ØąØŗØ§ŲØŠ",domainNotValidated:"اŲŲØˇØ§Ų ØēŲØą Ų
ØšØĒŲ
د",domainErrorMessage:"ŲØ°Ø§ اŲŲØˇØ§Ų ØēŲØą Ų
ØŗŲ
ŲØ بŲ. ŲØąØŦŲ Ø§ŲØ§ØĒØĩØ§Ų Ø¨Ø§ŲŲ
ØŗØ¤ŲŲ ŲØĨØļØ§ŲØŠ ØšŲŲØ§Ų Ų
Ųب𠨧ŲŲŲØ¨ Ø§ŲØŽØ§Øĩ Ø¨Ų ØĨŲŲ Ø§ŲŲØ§ØĻŲ
ØŠ."},ru:{landingTitle:"ĐаĐē Đ˛Ņ Ņ
ĐžŅиŅĐĩ ОйŅаŅŅŅŅ?",voiceCall:"ĐĐžĐģĐžŅОвОК СвОĐŊĐžĐē",textChat:"ĐĸĐĩĐēŅŅОвŅĐš ŅаŅ",clickToStartCall:"ĐаĐļĐŧиŅĐĩ, ŅŅĐžĐąŅ ĐŊаŅаŅŅ ĐˇĐ˛ĐžĐŊĐžĐē",realTimeVoice:"ĐĐžĐģĐžŅОвОК ŅĐ°ĐˇĐŗĐžĐ˛ĐžŅ Đ˛ ŅĐĩаĐģŅĐŊĐžĐŧ вŅĐĩĐŧĐĩĐŊи",startCall:"ĐаŅаŅŅ ĐˇĐ˛ĐžĐŊĐžĐē",listening:"ĐĄĐģŅŅаŅ...",speakFreely:"ĐОвОŅиŅĐĩ ŅвОйОдĐŊĐž",liveTranscript:"ĐĐ¸Đ˛Đ°Ņ ŅŅаĐŊŅĐēŅиĐŋŅиŅ",transcriptWillAppear:"ĐĸŅаĐŊŅĐēŅиĐŋŅĐ¸Ņ ĐŋĐžŅвиŅŅŅ ĐˇĐ´ĐĩŅŅ Đ˛Đž вŅĐĩĐŧŅ ĐˇĐ˛ĐžĐŊĐēа...",mute:"ĐŅĐēĐģŅŅиŅŅ ĐˇĐ˛ŅĐē",speaker:"ĐиĐŊаĐŧиĐē",endCall:"ĐавĐĩŅŅиŅŅ ĐˇĐ˛ĐžĐŊĐžĐē",hello:"ĐŅивĐĩŅ! ĐаĐē Ņ ĐŧĐžĐŗŅ ĐŋĐžĐŧĐžŅŅ?",sendMessage:"ĐŅĐŋŅавŅŅĐĩ ŅООйŅĐĩĐŊиĐĩ Đ´ĐģŅ ĐŊаŅаĐģа",online:"Đ ŅĐĩŅи",newChat:"ĐОвŅĐš ŅаŅ",back:"ĐаСад",close:"ĐаĐēŅŅŅŅ",error:"ĐŅийĐēа",typeMessage:"ĐвĐĩдиŅĐĩ ŅООйŅĐĩĐŊиĐĩ...",sendMessageAria:"ĐŅĐŋŅавиŅŅ ŅООйŅĐĩĐŊиĐĩ",domainNotValidated:"ĐĐžĐŧĐĩĐŊ ĐŊĐĩ ĐŋŅОвĐĩŅĐĩĐŊ",domainErrorMessage:"ĐŅĐžŅ Đ´ĐžĐŧĐĩĐŊ ĐŊĐĩ в ĐąĐĩĐģĐžĐŧ ŅĐŋиŅĐēĐĩ. ĐĐžĐļаĐģŅĐšŅŅа, ŅвŅĐļиŅĐĩŅŅ Ņ Đ°Đ´ĐŧиĐŊиŅŅŅаŅĐžŅĐžĐŧ, ŅŅĐžĐąŅ Đ´ĐžĐąĐ°Đ˛Đ¸ŅŅ URL ваŅĐĩĐŗĐž вĐĩĐą-ŅаКŅа в ŅĐŋиŅĐžĐē."},es:{landingTitle:"ÂŋCÃŗmo te gustarÃa comunicarte?",voiceCall:"Llamada de voz",textChat:"Chat de texto",clickToStartCall:"Haz clic para iniciar la llamada",realTimeVoice:"ConversaciÃŗn de voz en tiempo real",startCall:"Iniciar llamada",listening:"Escuchando...",speakFreely:"Habla libremente",liveTranscript:"TranscripciÃŗn en vivo",transcriptWillAppear:"La transcripciÃŗn aparecerÃĄ aquà durante la llamada...",mute:"Silenciar",speaker:"Altavoz",endCall:"Terminar llamada",hello:"ÂĄHola! ÂŋCÃŗmo puedo ayudarte?",sendMessage:"EnvÃa un mensaje para comenzar",online:"En lÃnea",newChat:"Nuevo chat",back:"AtrÃĄs",close:"Cerrar",error:"Error",typeMessage:"Escribe un mensaje...",sendMessageAria:"Enviar mensaje",domainNotValidated:"Dominio no validado",domainErrorMessage:"Este dominio no estÃĄ en la lista blanca. Por favor, contacte al administrador para agregar la URL de su sitio web a la lista."},fr:{landingTitle:"Comment souhaitez-vous communiquer?",voiceCall:"Appel vocal",textChat:"Chat texte",clickToStartCall:"Cliquez pour dÊmarrer l'appel",realTimeVoice:"Conversation vocale en temps rÊel",startCall:"DÊmarrer l'appel",listening:"Ãcoute...",speakFreely:"Parlez librement",liveTranscript:"TranscripciÃŗn en direct",transcriptWillAppear:"La transcription apparaÃŽtra ici pendant l'appel...",mute:"Muet",speaker:"Haut-parleur",endCall:"Terminer l'appel",hello:"Bonjour! Comment puis-je vous aider?",sendMessage:"Envoyez un message pour commencer",online:"En ligne",newChat:"Nouveau chat",back:"Retour",close:"Fermer",error:"Erreur",typeMessage:"Tapez votre message...",sendMessageAria:"Envoyer un message",domainNotValidated:"Domaine non validÊ",domainErrorMessage:"Ce domaine n'est pas sur la liste blanche. Veuillez contacter l'administrateur pour ajouter l'URL de votre site Web à la liste."},de:{landingTitle:"Wie mÃļchten Sie kommunizieren?",voiceCall:"Sprachanruf",textChat:"Text-Chat",clickToStartCall:"Klicken Sie, um den Anruf zu starten",realTimeVoice:"Sprachanruf in Echtzeit",startCall:"Anruf starten",listening:"HÃļren...",speakFreely:"Sprechen Sie frei",liveTranscript:"Live-Transkription",transcriptWillAppear:"Die Transkription erscheint hier während des Anrufs...",mute:"Stumm",speaker:"Lautsprecher",endCall:"Anruf beenden",hello:"Hallo! Wie kann ich helfen?",sendMessage:"Senden Sie eine Nachricht zum Starten",online:"Online",newChat:"Neuer Chat",back:"ZurÃŧck",close:"SchlieÃen",error:"Fehler",typeMessage:"Geben Sie eine Nachricht ein...",sendMessageAria:"Nachricht senden",domainNotValidated:"Domain nicht validiert",domainErrorMessage:"Diese Domain steht nicht auf der Whitelist. Bitte kontaktieren Sie den Administrator, um die URL Ihrer Website zur Liste hinzuzufÃŧgen."}};function GA(A,e,t,n,o,r,i){try{var s=A[r](i),a=s.value}catch(A){return void t(A)}s.done?e(a):Promise.resolve(a).then(n,o)}function _A(A){return function(){var e=this,t=arguments;return new Promise(function(n,o){var r=A.apply(e,t);function i(A){GA(r,n,o,i,s,"next",A)}function s(A){GA(r,n,o,i,s,"throw",A)}i(void 0)})}}function WA(A,e){var t=Object.keys(A);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(A);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(A,e).enumerable})),t.push.apply(t,n)}return t}function JA(A){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?WA(Object(t),!0).forEach(function(e){XA(A,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(A,Object.getOwnPropertyDescriptors(t)):WA(Object(t)).forEach(function(e){Object.defineProperty(A,e,Object.getOwnPropertyDescriptor(t,e))})}return A}function XA(A,e,t){return(e=function(A){var e=function(A){if("object"!=typeof A||!A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var t=e.call(A,"string");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(A)}(A);return"symbol"==typeof e?e:e+""}(e))in A?Object.defineProperty(A,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):A[e]=t,A}class YA{constructor(){var A,e,t,n,o,r,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.config=this.mergeWithDefaults(i),this.sdk=new eA(this.config),this.isOpen=!1,this.isActive=!1,this.translations=NA,this.currentView="landing",this.shadowRoot=null,this.container=null,this._pendingClientTools=null,this.config.useShadowDOM?(this.createShadowHost(),this.container=this.shadowRoot):(this.createRegularContainer(),this.container=this.regularContainer,this.shadowRoot=document);var s=JA(JA(JA({},this.config),this.config.voice),{},{language:(null===(A=this.config.voice)||void 0===A?void 0:A.language)||this.config.language||"en",signedUrl:this.config.signedUrl,agentSettingsOverride:this.config.agentSettingsOverride,translations:this.translations,shadowRoot:this.shadowRoot,outputContainer:(null===(e=this.config.voice)||void 0===e?void 0:e.outputContainer)||"raw",outputEncoding:(null===(t=this.config.voice)||void 0===t?void 0:t.outputEncoding)||"pcm",outputSampleRate:(null===(n=this.config.voice)||void 0===n?void 0:n.outputSampleRate)||44100,outputChannels:(null===(o=this.config.voice)||void 0===o?void 0:o.outputChannels)||1,outputBitDepth:(null===(r=this.config.voice)||void 0===r?void 0:r.outputBitDepth)||16,onConversationStart:this.config.onConversationStart,onConversationEnd:this.config.onConversationEnd,onBargeIn:this.config.onBargeIn,onAudioStartPlaying:this.config.onAudioStartPlaying,onAudioStoppedPlaying:this.config.onAudioStoppedPlaying,onSubtitleDisplay:this.config.onSubtitleDisplay});this.voiceInterface=new RA(s);var a=JA(JA(JA({},this.config),this.config.text),{},{translations:this.translations,shadowRoot:this.shadowRoot});if(this.textInterface=new VA(a,this.sdk),this.createWidget(),this.setupEventHandlers(),this.config.behavior.startOpen||this.config.behavior.autoOpen){var c,l=null===(c=this.shadowRoot)||void 0===c?void 0:c.getElementById("text-chat-panel");l&&(this.isOpen=!0,l.classList.add("open"))}this.checkAndHandleResume()}checkAndHandleResume(){var A=this.voiceInterface.checkAndHandleResume();A&&(console.log("đ [WIDGET] Auto-resuming call from page navigation"),console.log(" From:",A.fromPage,"â To:",A.toPage),this.open(),this.showVoice(),setTimeout(()=>{this.startVoiceCall().then(()=>{console.log("â
[WIDGET] Auto-resumed call successfully")}).catch(A=>{console.error("â [WIDGET] Failed to auto-resume call:",A)})},100))}open(){var A;if(!this.isOpen){var e=null===(A=this.shadowRoot)||void 0===A?void 0:A.getElementById("text-chat-panel");e&&(this.isOpen=!0,e.classList.add("open"))}}mergeWithDefaults(A){var e,t,n,o,r,i,s,a,c,l,d,u,g,B,h,p,w,f,C,m,v,Q,F,U,y,b,E,x,I,H,S,D,K,T,k,L,P,R,O,M,V,N,G,_,W,J,X,Y,z,j,Z,q,$,AA,eA,tA,nA,oA,rA,iA,sA,aA,cA,lA,dA,uA,gA,BA,hA,pA,wA,fA,CA,mA,vA,QA,FA,UA,yA,bA,EA,xA,IA,HA,SA,DA,KA,TA,kA,LA,PA,RA,OA,MA,VA,NA,GA,_A,WA,XA,YA,zA,jA,ZA,qA,$A,Ae,ee,te,ne,oe,re,ie,se,ae,ce,le,de,ue,ge,Be,he,pe,we,fe,Ce,me,ve,Qe,Fe,Ue,ye,be,Ee,xe,Ie,He,Se,De,Ke,Te=A.position||"bottom-right";if("string"==typeof Te){var ke=Te.split("-");Te={vertical:ke[0]||"bottom",horizontal:ke[1]||"right",offset:A.positionOffset||{x:20,y:20}}}var Le=A.primaryColor||(null===(e=A.button)||void 0===e?void 0:e.primaryColor)||(null===(t=A.button)||void 0===t?void 0:t.backgroundColor)||"#FFFFFF",Pe=(null===(n=A.header)||void 0===n?void 0:n.backgroundColor)||"#7C3AED";return JA({agentId:A.agentId,appId:A.appId,signedUrl:A.signedUrl,agentSettingsOverride:A.agentSettingsOverride,demo:!1!==A.demo,direction:A.direction||"ltr",language:A.language||"en",icon:JA({type:(null===(o=A.icon)||void 0===o?void 0:o.type)||"custom",customImage:(null===(r=A.icon)||void 0===r?void 0:r.customImage)||"https://talktopc.com/logo192.png",emoji:(null===(i=A.icon)||void 0===i?void 0:i.emoji)||"đ¤",text:(null===(s=A.icon)||void 0===s?void 0:s.text)||"AI",size:(null===(a=A.icon)||void 0===a?void 0:a.size)||"medium",backgroundColor:(null===(c=A.icon)||void 0===c?void 0:c.backgroundColor)||"#FFFFFF"},A.icon),position:JA({vertical:Te.vertical||"bottom",horizontal:Te.horizontal||"right",offset:Te.offset||{x:20,y:20}},"object"==typeof A.position?A.position:{}),button:JA({size:(null===(l=A.button)||void 0===l?void 0:l.size)||"medium",shape:(null===(d=A.button)||void 0===d?void 0:d.shape)||"circle",backgroundColor:(null===(u=A.button)||void 0===u?void 0:u.backgroundColor)||(null===(g=A.icon)||void 0===g?void 0:g.backgroundColor)||"#FFFFFF",hoverColor:(null===(B=A.button)||void 0===B?void 0:B.hoverColor)||"#D3D3D3",shadow:!1!==(null===(h=A.button)||void 0===h?void 0:h.shadow),shadowColor:(null===(p=A.button)||void 0===p?void 0:p.shadowColor)||"rgba(0,0,0,0.15)",primaryColor:(null===(w=A.button)||void 0===w?void 0:w.backgroundColor)||(null===(f=A.icon)||void 0===f?void 0:f.backgroundColor)||"#FFFFFF"},A.button),panel:JA({width:(null===(C=A.panel)||void 0===C?void 0:C.width)||350,height:(null===(m=A.panel)||void 0===m?void 0:m.height)||500,borderRadius:(null===(v=A.panel)||void 0===v?void 0:v.borderRadius)||12,backgroundColor:(null===(Q=A.panel)||void 0===Q?void 0:Q.backgroundColor)||"#FFFFFF",backdropFilter:(null===(F=A.panel)||void 0===F?void 0:F.backdropFilter)||null,border:(null===(U=A.panel)||void 0===U?void 0:U.border)||"1px solid #E5E7EB"},A.panel),voice:JA({micButtonColor:(null===(y=A.voice)||void 0===y?void 0:y.micButtonColor)||(null===(b=A.panel)||void 0===b?void 0:b.micButtonColor)||Le,micButtonActiveColor:(null===(E=A.voice)||void 0===E?void 0:E.micButtonActiveColor)||(null===(x=A.panel)||void 0===x?void 0:x.micButtonActiveColor)||"#EF4444",micButtonHint:JA(JA({text:(null===(I=A.voice)||void 0===I||null===(I=I.micButtonHint)||void 0===I?void 0:I.text)||(null===(H=A.panel)||void 0===H||null===(H=H.micButtonHint)||void 0===H?void 0:H.text)||"Click the button to start voice conversation",color:(null===(S=A.voice)||void 0===S||null===(S=S.micButtonHint)||void 0===S?void 0:S.color)||(null===(D=A.panel)||void 0===D||null===(D=D.micButtonHint)||void 0===D?void 0:D.color)||"#6B7280",fontSize:(null===(K=A.voice)||void 0===K||null===(K=K.micButtonHint)||void 0===K?void 0:K.fontSize)||(null===(T=A.panel)||void 0===T||null===(T=T.micButtonHint)||void 0===T?void 0:T.fontSize)||"12px"},null===(k=A.voice)||void 0===k?void 0:k.micButtonHint),null===(L=A.panel)||void 0===L?void 0:L.micButtonHint),avatarBackgroundColor:(null===(P=A.voice)||void 0===P?void 0:P.avatarBackgroundColor)||"#667eea",avatarActiveBackgroundColor:(null===(R=A.voice)||void 0===R?void 0:R.avatarActiveBackgroundColor)||"#667eea",statusTitleColor:(null===(O=A.voice)||void 0===O?void 0:O.statusTitleColor)||"#1e293b",statusSubtitleColor:(null===(M=A.voice)||void 0===M?void 0:M.statusSubtitleColor)||"#64748b",startCallButtonColor:(null===(V=A.voice)||void 0===V?void 0:V.startCallButtonColor)||"#667eea",startCallButtonTextColor:(null===(N=A.voice)||void 0===N?void 0:N.startCallButtonTextColor)||"#FFFFFF",startCallTitle:(null===(G=A.voice)||void 0===G?void 0:G.startCallTitle)||null,startCallSubtitle:(null===(_=A.voice)||void 0===_?void 0:_.startCallSubtitle)||null,startCallButtonText:(null===(W=A.voice)||void 0===W?void 0:W.startCallButtonText)||null,transcriptBackgroundColor:(null===(J=A.voice)||void 0===J?void 0:J.transcriptBackgroundColor)||"#FFFFFF",transcriptTextColor:(null===(X=A.voice)||void 0===X?void 0:X.transcriptTextColor)||"#1e293b",transcriptLabelColor:(null===(Y=A.voice)||void 0===Y?void 0:Y.transcriptLabelColor)||"#94a3b8",controlButtonColor:(null===(z=A.voice)||void 0===z?void 0:z.controlButtonColor)||"#FFFFFF",controlButtonSecondaryColor:(null===(j=A.voice)||void 0===j?void 0:j.controlButtonSecondaryColor)||"#64748b",endCallButtonColor:(null===(Z=A.voice)||void 0===Z?void 0:Z.endCallButtonColor)||"#ef4444",language:(null===(q=A.voice)||void 0===q?void 0:q.language)||A.language||"en"},A.voice),text:JA({sendButtonColor:(null===($=A.text)||void 0===$?void 0:$.sendButtonColor)||(null===(AA=A.panel)||void 0===AA?void 0:AA.sendButtonColor)||"#7C3AED",sendButtonHoverColor:(null===(eA=A.text)||void 0===eA?void 0:eA.sendButtonHoverColor)||(null===(tA=A.panel)||void 0===tA?void 0:tA.sendButtonHoverColor)||"#6D28D9",sendButtonActiveColor:(null===(nA=A.text)||void 0===nA?void 0:nA.sendButtonActiveColor)||(null===(oA=A.panel)||void 0===oA?void 0:oA.sendButtonActiveColor)||"#6D28D9",sendButtonText:(null===(rA=A.text)||void 0===rA?void 0:rA.sendButtonText)||(null===(iA=A.panel)||void 0===iA?void 0:iA.sendButtonText)||"â¤",sendButtonTextColor:(null===(sA=A.text)||void 0===sA?void 0:sA.sendButtonTextColor)||(null===(aA=A.panel)||void 0===aA?void 0:aA.sendButtonTextColor)||"#FFFFFF",sendButtonFontSize:(null===(cA=A.text)||void 0===cA?void 0:cA.sendButtonFontSize)||(null===(lA=A.panel)||void 0===lA?void 0:lA.sendButtonFontSize)||"18px",sendButtonFontWeight:(null===(dA=A.text)||void 0===dA?void 0:dA.sendButtonFontWeight)||(null===(uA=A.panel)||void 0===uA?void 0:uA.sendButtonFontWeight)||"500",sendButtonHint:JA(JA({text:(null===(gA=A.text)||void 0===gA||null===(gA=gA.sendButtonHint)||void 0===gA?void 0:gA.text)||(null===(BA=A.panel)||void 0===BA||null===(BA=BA.sendButtonHint)||void 0===BA?void 0:BA.text)||"",color:(null===(hA=A.text)||void 0===hA||null===(hA=hA.sendButtonHint)||void 0===hA?void 0:hA.color)||(null===(pA=A.panel)||void 0===pA||null===(pA=pA.sendButtonHint)||void 0===pA?void 0:pA.color)||"#6B7280",fontSize:(null===(wA=A.text)||void 0===wA||null===(wA=wA.sendButtonHint)||void 0===wA?void 0:wA.fontSize)||(null===(fA=A.panel)||void 0===fA||null===(fA=fA.sendButtonHint)||void 0===fA?void 0:fA.fontSize)||"12px"},null===(CA=A.text)||void 0===CA?void 0:CA.sendButtonHint),null===(mA=A.panel)||void 0===mA?void 0:mA.sendButtonHint),inputPlaceholder:(null===(vA=A.text)||void 0===vA?void 0:vA.inputPlaceholder)||(null===(QA=A.panel)||void 0===QA?void 0:QA.inputPlaceholder)||"Type your message...",inputBorderColor:(null===(FA=A.text)||void 0===FA?void 0:FA.inputBorderColor)||(null===(UA=A.panel)||void 0===UA?void 0:UA.inputBorderColor)||"#E5E7EB",inputFocusColor:(null===(yA=A.text)||void 0===yA?void 0:yA.inputFocusColor)||(null===(bA=A.panel)||void 0===bA?void 0:bA.inputFocusColor)||"#7C3AED",inputBackgroundColor:(null===(EA=A.text)||void 0===EA?void 0:EA.inputBackgroundColor)||(null===(xA=A.panel)||void 0===xA?void 0:xA.inputBackgroundColor)||"#FFFFFF",inputTextColor:(null===(IA=A.text)||void 0===IA?void 0:IA.inputTextColor)||(null===(HA=A.panel)||void 0===HA?void 0:HA.inputTextColor)||"#1F2937",inputFontSize:(null===(SA=A.text)||void 0===SA?void 0:SA.inputFontSize)||(null===(DA=A.panel)||void 0===DA?void 0:DA.inputFontSize)||"14px",inputBorderRadius:(null===(KA=A.text)||void 0===KA?void 0:KA.inputBorderRadius)||(null===(TA=A.panel)||void 0===TA?void 0:TA.inputBorderRadius)||20,inputPadding:(null===(kA=A.text)||void 0===kA?void 0:kA.inputPadding)||(null===(LA=A.panel)||void 0===LA?void 0:LA.inputPadding)||"6px 14px"},A.text),landing:JA({backgroundColor:(null===(PA=A.landing)||void 0===PA?void 0:PA.backgroundColor)||"linear-gradient(180deg, #f8fafc 0%, #e0e7ff 100%)",logo:(null===(RA=A.landing)||void 0===RA?void 0:RA.logo)||"đ¤",title:(null===(OA=A.landing)||void 0===OA?void 0:OA.title)||null,titleColor:(null===(MA=A.landing)||void 0===MA?void 0:MA.titleColor)||"#1e293b",modeCardBackgroundColor:(null===(VA=A.landing)||void 0===VA?void 0:VA.modeCardBackgroundColor)||"#FFFFFF",modeCardBorderColor:(null===(NA=A.landing)||void 0===NA?void 0:NA.modeCardBorderColor)||"#E2E8F0",modeCardHoverBorderColor:(null===(GA=A.landing)||void 0===GA?void 0:GA.modeCardHoverBorderColor)||Pe,modeCardIconBackgroundColor:(null===(_A=A.landing)||void 0===_A?void 0:_A.modeCardIconBackgroundColor)||Pe,modeCardTitleColor:(null===(WA=A.landing)||void 0===WA?void 0:WA.modeCardTitleColor)||"#111827",voiceCardIcon:(null===(XA=A.landing)||void 0===XA?void 0:XA.voiceCardIcon)||"đ¤",textCardIcon:(null===(YA=A.landing)||void 0===YA?void 0:YA.textCardIcon)||"đŦ",voiceCardTitle:(null===(zA=A.landing)||void 0===zA?void 0:zA.voiceCardTitle)||null,textCardTitle:(null===(jA=A.landing)||void 0===jA?void 0:jA.textCardTitle)||null},A.landing),header:JA({title:(null===(ZA=A.header)||void 0===ZA?void 0:ZA.title)||"Chat Assistant",showTitle:!1!==(null===(qA=A.header)||void 0===qA?void 0:qA.showTitle),backgroundColor:(null===($A=A.header)||void 0===$A?void 0:$A.backgroundColor)||"#7C3AED",textColor:(null===(Ae=A.header)||void 0===Ae?void 0:Ae.textColor)||"#FFFFFF",showCloseButton:!1!==(null===(ee=A.header)||void 0===ee?void 0:ee.showCloseButton)},A.header),footer:JA({show:!1!==(null===(te=A.footer)||void 0===te?void 0:te.show),backgroundColor:(null===(ne=A.footer)||void 0===ne?void 0:ne.backgroundColor)||"#f9fafb",textColor:(null===(oe=A.footer)||void 0===oe?void 0:oe.textColor)||"#9ca3af",hoverColor:(null===(re=A.footer)||void 0===re?void 0:re.hoverColor)||"#7C3AED"},A.footer),tooltips:JA({newChat:(null===(ie=A.tooltips)||void 0===ie?void 0:ie.newChat)||null,back:(null===(se=A.tooltips)||void 0===se?void 0:se.back)||null,close:(null===(ae=A.tooltips)||void 0===ae?void 0:ae.close)||null,mute:(null===(ce=A.tooltips)||void 0===ce?void 0:ce.mute)||null,speaker:(null===(le=A.tooltips)||void 0===le?void 0:le.speaker)||null,endCall:(null===(de=A.tooltips)||void 0===de?void 0:de.endCall)||null},A.tooltips),messages:JA({userBackgroundColor:(null===(ue=A.messages)||void 0===ue?void 0:ue.userBackgroundColor)||"#E5E7EB",agentBackgroundColor:(null===(ge=A.messages)||void 0===ge?void 0:ge.agentBackgroundColor)||"#F3F4F6",systemBackgroundColor:(null===(Be=A.messages)||void 0===Be?void 0:Be.systemBackgroundColor)||"#DCFCE7",errorBackgroundColor:(null===(he=A.messages)||void 0===he?void 0:he.errorBackgroundColor)||"#FEE2E2",textColor:(null===(pe=A.messages)||void 0===pe?void 0:pe.textColor)||"#1F2937",fontSize:(null===(we=A.messages)||void 0===we?void 0:we.fontSize)||"14px",borderRadius:(null===(fe=A.messages)||void 0===fe?void 0:fe.borderRadius)||8},A.messages),animation:JA({enableHover:!1!==(null===(Ce=A.animation)||void 0===Ce?void 0:Ce.enableHover),enablePulse:!1!==(null===(me=A.animation)||void 0===me?void 0:me.enablePulse),enableSlide:!1!==(null===(ve=A.animation)||void 0===ve?void 0:ve.enableSlide),duration:(null===(Qe=A.animation)||void 0===Qe?void 0:Qe.duration)||.3},A.animation),behavior:JA({autoOpen:(null===(Fe=A.behavior)||void 0===Fe?void 0:Fe.autoOpen)||!1,startOpen:(null===(Ue=A.behavior)||void 0===Ue?void 0:Ue.startOpen)||!1,hidden:(null===(ye=A.behavior)||void 0===ye?void 0:ye.hidden)||!1,autoConnect:(null===(be=A.behavior)||void 0===be?void 0:be.autoConnect)||!1,showWelcomeMessage:!1!==(null===(Ee=A.behavior)||void 0===Ee?void 0:Ee.showWelcomeMessage),welcomeMessage:(null===(xe=A.behavior)||void 0===xe?void 0:xe.welcomeMessage)||"Hello! How can I help you today?",enableVoiceMode:void 0===(null===(Ie=A.behavior)||void 0===Ie?void 0:Ie.enableVoiceMode)||A.behavior.enableVoiceMode,mode:(null===(He=A.behavior)||void 0===He?void 0:He.mode)||"unified"},A.behavior),accessibility:JA({ariaLabel:(null===(Se=A.accessibility)||void 0===Se?void 0:Se.ariaLabel)||"Chat Assistant",ariaDescription:(null===(De=A.accessibility)||void 0===De?void 0:De.ariaDescription)||"Click to open chat assistant",keyboardNavigation:!1!==(null===(Ke=A.accessibility)||void 0===Ke?void 0:Ke.keyboardNavigation)},A.accessibility),customStyles:A.customStyles||"",useShadowDOM:!1!==A.useShadowDOM,variables:A.variables||{},forceConversationId:A.forceConversationId,onConversationStart:A.onConversationStart,onConversationEnd:A.onConversationEnd,onBargeIn:A.onBargeIn,onAudioStartPlaying:A.onAudioStartPlaying,onAudioStoppedPlaying:A.onAudioStoppedPlaying,onSubtitleDisplay:A.onSubtitleDisplay,primaryColor:Le},"string"==typeof A.position?{positionString:A.position}:{})}setupEventHandlers(){this.sdk.on("domainError",A=>{this.textInterface.showError(A),this.textInterface.stopStreamingState()}),this.sdk.on("error",A=>{A&&("DOMAIN_NOT_WHITELISTED"===A.message||A.message&&A.message.includes("Domain not whitelisted"))||(this.textInterface.showError(A.message||A),this.textInterface.stopStreamingState())}),this.sdk.on("chunk",A=>{this.textInterface.appendStreamingChunk(A)}),this.sdk.on("done",A=>{var{text:e}=A;this.textInterface.finalizeStreaming(e)})}createShadowHost(){var A=document.getElementById("ttp-widget-shadow-host");A&&A.remove();var e=document.createElement("div");e.id="ttp-widget-shadow-host",e.style.cssText="position: fixed; z-index: 10000; pointer-events: none; top: 0; left: 0; width: 100%; height: 100%; overflow: visible;",this.shadowRoot=e.attachShadow({mode:"open"}),document.body.appendChild(e)}createRegularContainer(){var A=document.getElementById("ttp-widget-container");A&&A.remove();var e=document.createElement("div");e.id="ttp-widget-container",e.style.cssText="position: fixed; z-index: 10000; pointer-events: none; top: 0; left: 0; width: 100%; height: 100%; overflow: visible;",document.body.appendChild(e),this.regularContainer=e}createWidget(){this.container||(this.config.useShadowDOM?(this.createShadowHost(),this.container=this.shadowRoot):(this.createRegularContainer(),this.container=this.regularContainer,this.shadowRoot=document));var A;A=this.config.useShadowDOM?"\n :host {\n all: initial;\n display: block;\n pointer-events: none;\n }\n img {\n max-width: none !important;\n }\n #text-chat-button img {\n width: 28px !important;\n height: 28px !important;\n }\n #text-chat-button {\n pointer-events: auto;\n }\n #text-chat-panel {\n pointer-events: auto;\n }\n ":'\n /* Reset only problematic inherited styles, not all styles */\n #text-chat-button,\n #text-chat-panel,\n #text-chat-panel * {\n box-sizing: border-box;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n }\n \n /* Prevent theme CSS from affecting images */\n #text-chat-button img,\n #text-chat-panel img {\n max-width: none !important;\n width: auto;\n height: auto;\n }\n \n #text-chat-button img {\n width: 28px !important;\n height: 28px !important;\n }\n \n /* Ensure button and panel can receive clicks */\n #text-chat-button,\n #text-chat-panel {\n pointer-events: auto;\n }\n \n /* Reset any inherited text styles that might break layout */\n #text-chat-panel {\n text-align: left;\n line-height: normal;\n letter-spacing: normal;\n word-spacing: normal;\n text-transform: none;\n text-indent: 0;\n text-shadow: none;\n white-space: normal;\n }\n \n /* Ensure flexbox works properly */\n #text-chat-panel .widget-shell,\n #text-chat-panel .panel-inner,\n #text-chat-panel .widget-container,\n #text-chat-panel .landing-screen,\n #text-chat-panel .voice-interface,\n #text-chat-panel .text-interface,\n #text-chat-panel .widget-header,\n #text-chat-panel .mode-selection {\n display: flex;\n }\n \n #text-chat-panel .widget-shell,\n #text-chat-panel .panel-inner,\n #text-chat-panel .widget-container,\n #text-chat-panel .landing-screen,\n #text-chat-panel .voice-interface,\n #text-chat-panel .text-interface {\n flex-direction: column;\n }\n \n #text-chat-panel .mode-selection {\n flex-direction: row;\n }\n \n /* Ensure proper stacking */\n #text-chat-button {\n z-index: 10001 !important;\n }\n \n #text-chat-panel {\n z-index: 10000 !important;\n }\n ';var e=this.generateWidgetHTML();if(this.config.useShadowDOM){var t="\n <style>".concat(A,"</style>\n ").concat(e,"\n ");this.shadowRoot.innerHTML=t}else this.injectStylesIntoHead(A),this.container.innerHTML=e;this.setupWidgetEvents();var n=this.shadowRoot.getElementById("text-chat-panel");n&&(this.config.behavior.startOpen||this.config.behavior.autoOpen)&&(this.isOpen=!0,n.classList.add("open"))}injectStylesIntoHead(A){var e,t,n=document.getElementById("ttp-widget-styles");n&&n.remove();var o={small:50,medium:60,large:70,xl:80}[null===(e=this.config.button)||void 0===e?void 0:e.size]||60,r={small:20,medium:28,large:36,xl:44}[null===(t=this.config.icon)||void 0===t?void 0:t.size]||28,i=this.generatePositionStyles(),s=this.generateCSS(i,o,r),a=document.createElement("style");a.id="ttp-widget-styles",a.textContent=A+"\n"+s,this.config.customStyles&&(a.textContent+="\n"+this.config.customStyles),document.head.appendChild(a)}generateWidgetHTML(){this.config.position;var A,e,t,n,o=this.config.button,r=this.config.icon,i=(this.config.panel,this.config.header),s=(this.config.animation,{small:50,medium:60,large:70,xl:80}[o.size]||60),a={small:20,medium:28,large:36,xl:44}[r.size]||28,c=this.generatePositionStyles(),l=this.generateIconHTML(a),d=this.config.behavior.mode||"unified",u="unified"===d,g="unified"===d||"voice-only"===d,B="unified"===d||"text-only"===d,h=A=>{var e=this.config.language||"en";return(this.translations[e]||this.translations.en)[A]||A},p=A=>{var e,t=null===(e=this.config.tooltips)||void 0===e?void 0:e[A];return null!=t?t:{newChat:h("newChat"),back:h("back"),close:h("close"),mute:h("mute"),speaker:h("speaker"),endCall:h("endCall")}[A]||""},w=this.config.useShadowDOM?"\n <style>\n ".concat(this.generateCSS(c,s,a),"\n ").concat(this.config.customStyles,"\n </style>\n "):"";return"\n ".concat(w,"\n \n ").concat(this.config.behavior.hidden?"":'\n <button id="text-chat-button" \n aria-label="'.concat(this.config.accessibility.ariaLabel,'"\n aria-description="').concat(this.config.accessibility.ariaDescription,'">\n ').concat(l,"\n </button>\n "),'\n \n <div id="text-chat-panel">\n <div class="widget-shell">\n <div class="panel-inner widget-container" style="direction: ').concat(this.config.direction,';">\n <div class="widget-header" style="background: ').concat(i.backgroundColor,"; color: ").concat(i.textColor,';">\n <div>\n ').concat(i.showTitle?'<div class="header-title">'.concat(i.title,"</div>"):"",'\n <div class="header-status">\n <span class="status-dot"></span>\n <span>').concat(h("online"),'</span>\n </div>\n </div>\n \n <div style="display: flex; gap: 12px; align-items: center;">\n \x3c!-- New Chat Button (hide on landing screen, show otherwise) --\x3e\n <button class="header-icon new-chat-btn" id="newChatBtn" title="').concat(p("newChat"),'" style="').concat(u?"display: none;":"",'">\n <span style="font-size: 18px; font-weight: bold;">+</span>\n </button>\n \n \x3c!-- Back Button (only show in unified mode) --\x3e\n ').concat("unified"===d?'<button class="header-icon back-btn" id="backBtn" title="'.concat(p("back"),'" style="display: none;">\n <span style="font-size: 16px;">âš</span>\n </button>'):"","\n \n \x3c!-- Close Button --\x3e\n ").concat(i.showCloseButton?'<button class="header-icon close-btn" id="closeBtn" title="'+p("close")+'"><span style="font-size: 18px; font-weight: bold;">Ã</span></button>':"","\n </div>\n </div>\n\n ").concat(u?'\n <div class="landing-screen" id="landingScreen">\n <div class="landing-logo">'.concat((null===(A=this.config.landing)||void 0===A?void 0:A.logo)||"đ¤",'</div>\n <div class="landing-title">').concat((null===(e=this.config.landing)||void 0===e?void 0:e.title)||h("landingTitle"),'</div>\n <div class="mode-selection">\n ').concat(g?'<div class="mode-card voice" id="mode-card-voice">\n <div class="mode-card-icon">đ¤</div>\n <div class="mode-card-title">'.concat((null===(t=this.config.landing)||void 0===t?void 0:t.voiceCardTitle)||h("voiceCall"),"</div>\n </div>"):"","\n ").concat(B?'<div class="mode-card text" id="mode-card-text">\n <div class="mode-card-icon">đŦ</div>\n <div class="mode-card-title">'.concat((null===(n=this.config.landing)||void 0===n?void 0:n.textCardTitle)||h("textChat"),"</div>\n </div>"):"","\n </div>\n </div>"):"","\n\n ").concat(g?this.voiceInterface.generateHTML():"","\n ").concat(B?this.textInterface.generateHTML():"","\n ").concat(this.generateFooterHTML(),"\n </div>\n </div>\n </div>\n ")}generateFooterHTML(){var A=this.config.footer;if(!A.show)return"";var e=encodeURIComponent(window.location.hostname||"widget"),t="https://talktopc.com?ref=widget&source=".concat(e);return'\n <div class="widget-footer" style="\n height: 36px;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n background-color: '.concat(A.backgroundColor,';\n border-top: 1px solid #e5e7eb;\n flex-shrink: 0;\n ">\n <a \n href="').concat(t,'" \n target="_blank" \n rel="noopener noreferrer"\n aria-label="Visit TalkToPC website"\n class="footer-brand-link"\n style="\n display: flex;\n flex-direction: column;\n align-items: center;\n text-decoration: none;\n color: ').concat(A.textColor,';\n transition: color 0.2s ease;\n "\n onmouseover="this.style.color=\'').concat(A.hoverColor,"'\"\n onmouseout=\"this.style.color='").concat(A.textColor,'\'"\n >\n <span style="font-size: 11px; line-height: 1.3;">\n ⥠Powered by <strong>TalkToPC</strong>\n </span>\n <span style="font-size: 9px; opacity: 0.7; line-height: 1.2;">\n https://talktopc.com\n </span>\n </a>\n </div>\n ')}generatePositionStyles(){var A=this.config.position,e=A.offset||{x:20,y:20},t="";return"top"===A.vertical?t+="top: ".concat(e.y,"px;"):"bottom"===A.vertical?t+="bottom: ".concat(e.y,"px;"):"center"===A.vertical&&(t+="top: 50%; transform: translateY(-50%);"),"left"===A.horizontal?t+="left: ".concat(e.x,"px;"):"right"===A.horizontal?t+="right: ".concat(e.x,"px;"):"center"===A.horizontal&&(t+="left: 50%; transform: translateX(-50%);"),t}generateIconHTML(A){var e=this.config.icon;switch(e.type){case"custom":return'<img src="'.concat(e.customImage,'" alt="Chat Assistant" style="width: ').concat(A,"px; height: ").concat(A,'px; object-fit: contain;" />');case"emoji":return'<span style="font-size: '.concat(A,'px; line-height: 1;">').concat(e.emoji,"</span>");case"text":return'<span style="font-size: '.concat(Math.floor(.6*A),'px; font-weight: bold; color: white;">').concat(e.text,"</span>");case"microphone":default:return'<svg viewBox="0 0 24 24" style="width: '.concat(A,"px; height: ").concat(A,'px; fill: white;">\n <path d="M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"/>\n <path d="M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"/>\n </svg>');case"chat":return'<svg viewBox="0 0 24 24" style="width: '.concat(A,"px; height: ").concat(A,'px; fill: white;">\n <path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"/>\n </svg>')}}generateCSS(A,e,t){var n,o,r,i,s,a,c,l,d,u,g,B=this.config.button,h=this.config.icon,p=this.config.panel,w=this.config.header,f=(this.config.messages,this.config.animation),C=this.config.behavior.mode||"unified",m="unified"===C||"voice-only"===C,v="unified"===C||"text-only"===C,Q=!1===this.config.useShadowDOM?" !important":"",F=w.backgroundColor;return'\n /* MOBILE FIRST - Default styles for all devices */\n #text-chat-widget {\n position: fixed !important;\n z-index: 10000;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n /* Mobile defaults */\n right: 10px;\n bottom: 10px;\n left: auto;\n top: auto;\n }\n \n /* Desktop positioning (only on larger screens) */\n @media (min-width: 769px) {\n #text-chat-widget {\n '.concat(A,"\n right: ").concat("right"===this.config.position.horizontal?"20px":"auto",";\n left: ").concat("left"===this.config.position.horizontal?"20px":"auto",";\n bottom: ").concat("bottom"===this.config.position.vertical?"20px":"auto",";\n top: ").concat("top"===this.config.position.vertical?"20px":"auto",";\n }\n }\n \n /* Mobile override (force mobile positioning) */\n @media (max-width: 768px) {\n #text-chat-widget {\n right: 10px !important;\n bottom: 10px !important;\n left: auto !important;\n top: auto !important;\n transform: none !important;\n }\n }\n \n @media (max-width: 480px) {\n #text-chat-widget {\n right: 8px !important;\n bottom: 8px !important;\n left: auto !important;\n top: auto !important;\n }\n }\n \n #text-chat-button {\n position: fixed;\n ").concat("bottom"===this.config.position.vertical?"bottom: ".concat((null===(n=this.config.position.offset)||void 0===n?void 0:n.y)||20,"px;"):"top: ".concat((null===(o=this.config.position.offset)||void 0===o?void 0:o.y)||20,"px;"),"\n ").concat("right"===this.config.position.horizontal?"right: ".concat((null===(r=this.config.position.offset)||void 0===r?void 0:r.x)||20,"px;"):"left: ".concat((null===(i=this.config.position.offset)||void 0===i?void 0:i.x)||20,"px;"),"\n width: ").concat(e,"px;\n height: ").concat(e,"px;\n border-radius: ").concat("circle"===B.shape?"50%":"square"===B.shape?"0":"12px",";\n background: ").concat(B.backgroundColor||h.backgroundColor||"#7C3AED",";\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all ").concat(f.duration,"s ease;\n box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);\n touch-action: manipulation;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n user-select: none;\n min-width: 44px;\n min-height: 44px;\n z-index: 10001;\n }\n \n @media (max-width: 768px) {\n #text-chat-widget {\n right: 10px !important;\n bottom: 10px !important;\n left: auto !important;\n top: auto !important;\n transform: none !important;\n }\n \n #text-chat-button {\n right: 10px !important;\n bottom: 10px !important;\n left: auto !important;\n top: auto !important;\n width: 56px !important;\n height: 56px !important;\n min-width: 56px !important;\n min-height: 56px !important;\n max-width: 56px !important;\n max-height: 56px !important;\n }\n \n #text-chat-panel {\n position: fixed !important;\n left: 10px !important;\n right: 10px !important;\n bottom: 92px !important; /* 56px button + 20px gap + 16px footer */\n top: 60px !important; /* Add top spacing */\n width: auto !important;\n max-width: none !important;\n height: auto !important; /* Change from max-height to auto */\n max-height: none !important; /* Remove max-height */\n transform: none !important;\n margin: 0 !important;\n }\n \n #text-chat-panel .widget-header {\n padding: 10px 14px;\n min-height: 56px;\n }\n \n #text-chat-panel .header-title {\n font-size: 15px;\n }\n \n #text-chat-panel .header-icon {\n width: 40px;\n height: 40px;\n min-width: 40px;\n min-height: 40px;\n }\n \n #text-chat-input {\n font-size: 16px !important; /* Prevents iOS zoom on focus */\n padding: 12px 16px !important;\n min-height: 48px !important;\n }\n \n #text-chat-send {\n min-width: 48px !important;\n min-height: 48px !important;\n width: 48px !important;\n height: 48px !important;\n }\n \n .landing-screen {\n padding: 16px;\n }\n \n .landing-logo {\n font-size: 40px;\n }\n \n .landing-title {\n font-size: 18px;\n margin-bottom: 16px;\n }\n \n .mode-selection {\n flex-direction: column;\n gap: 12px;\n align-items: center;\n }\n \n .mode-card {\n max-width: 100%;\n width: 100%;\n padding: 16px;\n }\n \n .mode-card-icon {\n width: 50px;\n height: 50px;\n font-size: 28px;\n }\n \n .mode-card-title {\n font-size: 14px;\n }\n }\n \n @media (max-width: 480px) {\n #text-chat-widget {\n right: 8px !important;\n bottom: 8px !important;\n left: auto !important;\n top: auto !important;\n }\n \n #text-chat-button {\n right: 8px !important;\n bottom: 8px !important;\n left: auto !important;\n top: auto !important;\n width: 54px !important;\n height: 54px !important;\n min-width: 54px !important;\n min-height: 54px !important;\n }\n \n #text-chat-panel {\n left: 8px !important;\n right: 8px !important;\n bottom: 86px !important; /* 54px button + 20px gap + 12px footer */\n top: 50px !important; /* Add top spacing for very small screens */\n height: auto !important;\n max-height: none !important;\n }\n \n #text-chat-panel .widget-header {\n padding: 8px 12px;\n min-height: 52px;\n }\n \n #text-chat-panel .header-title {\n font-size: 14px;\n }\n \n .landing-logo {\n font-size: 36px;\n }\n \n .landing-title {\n font-size: 16px;\n }\n }\n \n ").concat(f.enableHover?"\n #text-chat-button:hover {\n ".concat(B.hoverColor?"background: ".concat(B.hoverColor,";"):"","\n transform: scale(1.05);\n box-shadow: 0 8px 20px rgba(102, 126, 234, 0.5);\n }\n "):"","\n \n #text-chat-panel {\n display: none").concat(Q,";\n position: fixed;\n bottom: calc(").concat(e,"px + 20px + 20px); /* Button + gap + reduced footer offset */\n ").concat("right"===this.config.position.horizontal?"right: 20px;":"left: 20px;","\n width: ").concat(p.width,"px;\n max-width: calc(100vw - 40px);\n height: ").concat(p.height,"px;\n max-height: calc(100vh - ").concat(e,"px - 40px - 20px); /* Account for footer height */\n background: transparent;\n border-radius: ").concat(p.borderRadius,"px;\n border: none;\n flex-direction: column;\n overflow: hidden;\n ").concat(p.backdropFilter?"backdrop-filter: ".concat(p.backdropFilter,";"):"","\n ").concat(f.enableSlide?"transition: all ".concat(f.duration,"s ease;"):"","\n box-sizing: border-box;\n }\n \n #text-chat-panel.open {\n display: flex").concat(Q,";\n ").concat(f.enableSlide?"transform: translateY(0); opacity: 1;":"","\n }\n\n /* Shell for gradient border/background */\n .widget-shell { width: 100%; height: 100%; padding: 0; border-radius: ").concat(p.borderRadius,"px; background: transparent; box-shadow: 0 20px 60px rgba(0,0,0,0.15); overflow: hidden; display: flex; flex-direction: column; box-sizing: border-box; }\n .panel-inner { width: 100%; height: 100%; background: #ffffff; border-radius: ").concat(p.borderRadius,"px; border: ").concat(p.border,"; overflow: hidden; display:flex; flex-direction: column; padding: 0; box-sizing: border-box; max-width: 100%; }\n\n /* New structure styles matching provided design */\n #text-chat-panel .widget-container {\n width: 100%; height: 100%; min-height: 0; background: #FFFFFF; overflow: hidden; display: flex; flex-direction: column; border-radius: ").concat(p.borderRadius,"px;\n container-type: size;\n }\n \n /* Ensure content areas can scroll when height is constrained */\n #text-chat-panel .widget-container > .landing-screen,\n #text-chat-panel .widget-container > .voice-interface,\n #text-chat-panel .widget-container > .text-interface {\n flex: 1;\n min-height: 0;\n overflow-y: auto;\n overflow-x: hidden;\n }\n \n /* Header should not scroll */\n #text-chat-panel .widget-header {\n padding: 12px 16px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n border-top-left-radius: ").concat(p.borderRadius,"px;\n border-top-right-radius: ").concat(p.borderRadius,"px;\n flex-shrink: 0;\n min-height: 60px;\n box-sizing: border-box;\n }\n #text-chat-panel .header-title { font-size: 16px; font-weight: 600; }\n #text-chat-panel .header-status { display: flex; align-items: center; gap: 8px; font-size: 12px; opacity: 0.9; }\n #text-chat-panel .status-dot { width: 8px; height: 8px; background: #4ade80; border-radius: 50%; animation: pulse 2s ease-in-out infinite; }\n @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }\n /* Header icon buttons */\n .header-icon {\n background: rgba(255, 255, 255, 0.2);\n border: none;\n color: white;\n width: 36px;\n height: 36px;\n min-width: 36px;\n min-height: 36px;\n border-radius: 50%;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background 0.2s;\n flex-shrink: 0;\n font-size: 16px;\n padding: 0;\n box-sizing: border-box;\n }\n \n .header-icon:hover {\n background: rgba(255, 255, 255, 0.3);\n }\n \n .header-icon svg {\n pointer-events: none;\n stroke: white;\n fill: none;\n }\n \n .back-btn.visible {\n display: flex !important;\n }\n\n /* Landing and mode selection (shown only if voice enabled) */\n .landing-screen { \n display: none").concat(Q,"; \n flex: 1; \n padding: 20px; \n background: ").concat((null===(s=this.config.landing)||void 0===s?void 0:s.backgroundColor)||"linear-gradient(180deg, #f8fafc 0%, #e0e7ff 100%)","; \n align-items: center; \n justify-content: flex-start; \n flex-direction: column; \n gap: 16px; \n overflow-y: auto; \n min-height: 0; \n }\n .landing-screen.active { display: flex").concat(Q,"; }\n .landing-logo { font-size: 48px; }\n .landing-title { \n font-size: 20px; \n color: ").concat((null===(a=this.config.landing)||void 0===a?void 0:a.titleColor)||"#1e293b","; \n font-weight: 700; \n margin-bottom: 20px; \n text-align: center;\n width: 100%;\n }\n .mode-selection { display: flex; gap: 16px; width: 100%; justify-content: center; }\n .mode-card { \n flex: 1; \n max-width: 180px; \n background: ").concat((null===(c=this.config.landing)||void 0===c?void 0:c.modeCardBackgroundColor)||"#FFFFFF","; \n border: 2px solid ").concat((null===(l=this.config.landing)||void 0===l?void 0:l.modeCardBorderColor)||"#E2E8F0","; \n border-radius: 20px; \n padding: 20px 12px; \n cursor: pointer; \n display: flex; \n flex-direction: column; \n align-items: center; \n gap: 8px; \n transition: transform ").concat(f.duration,"s ease, box-shadow ").concat(f.duration,"s ease, border-color ").concat(f.duration,"s ease; \n box-shadow: 0 4px 12px rgba(0,0,0,0.05); \n }\n .mode-card:hover { \n transform: translateY(-6px); \n box-shadow: 0 12px 24px rgba(102, 126, 234, 0.2); \n border-color: ").concat((null===(d=this.config.landing)||void 0===d?void 0:d.modeCardHoverBorderColor)||F,"; \n }\n .mode-card-icon { \n width: 60px; \n height: 60px; \n display: flex; \n align-items: center; \n justify-content: center; \n border-radius: 50%; \n background: ").concat((null===(u=this.config.landing)||void 0===u?void 0:u.modeCardIconBackgroundColor)||F,"; \n color: #fff; \n font-size: 32px; \n }\n .mode-card-title { \n color: ").concat((null===(g=this.config.landing)||void 0===g?void 0:g.modeCardTitleColor)||"#111827","; \n font-weight: 600; \n text-align: center;\n width: 100%;\n }\n\n ").concat(m?this.voiceInterface.generateCSS():"","\n ").concat(v?this.textInterface.generateCSS():"","\n \n /* Footer Branding */\n .widget-footer {\n box-sizing: border-box;\n }\n \n .footer-brand-link {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n \n .footer-brand-link:hover {\n opacity: 0.9;\n }\n \n @media (max-width: 768px) {\n .widget-footer {\n height: 32px;\n }\n .widget-footer span {\n font-size: 10px;\n }\n .widget-footer span:last-child {\n font-size: 8px;\n }\n }\n \n #text-chat-send-hint {\n text-align: center;\n line-height: 1.4;\n }\n \n .agent-thinking {\n font-style: italic;\n color: #6B7280;\n }\n ")}setupWidgetEvents(){if(this.shadowRoot){var A=this.shadowRoot.getElementById("text-chat-button");A&&(A.onclick=()=>this.togglePanel());var e=this.shadowRoot.getElementById("closeBtn");e&&(e.onclick=()=>this.togglePanel());var t=this.config.behavior.mode||"unified",n="unified"===t,o="unified"===t||"voice-only"===t,r="unified"===t||"text-only"===t,i=this.shadowRoot.getElementById("backBtn"),s=this.shadowRoot.getElementById("landingScreen"),a=this.shadowRoot.getElementById("mode-card-voice"),c=this.shadowRoot.getElementById("mode-card-text"),l=this.shadowRoot.getElementById("textInterface"),d=this.shadowRoot.getElementById("voiceInterface");i&&(i.onclick=()=>this.showLanding()),n?(a&&(a.onclick=()=>this.showVoice()),c&&(c.onclick=()=>this.showText()),"text"===this.currentView?(s&&s.classList.remove("active"),l&&l.classList.add("active"),d&&d.classList.remove("active"),i&&"unified"===t&&i.classList.add("visible"),u&&(u.style.display="")):"voice"===this.currentView?(s&&s.classList.remove("active"),l&&l.classList.remove("active"),d&&d.classList.add("active"),i&&"unified"===t&&i.classList.add("visible"),u&&(u.style.display="none")):(this.currentView="landing",s&&s.classList.add("active"),l&&l.classList.remove("active"),d&&d.classList.remove("active"),i&&"unified"===t&&i.classList.remove("visible"))):"voice-only"===t?(d&&d.classList.add("active"),l&&l.classList.remove("active"),s&&s.classList.remove("active")):"text-only"===t&&(l&&l.classList.add("active"),d&&d.classList.remove("active"),s&&s.classList.remove("active")),o&&(console.log("âī¸ Setting up voice interface event handlers"),this.voiceInterface.setupEventHandlers()),r&&(console.log("âī¸ Setting up text interface event handlers"),this.textInterface.setupEventHandlers());var u=this.shadowRoot.getElementById("newChatBtn");u&&(u.onclick=()=>this.textInterface.startNewChat(),n&&(u.style.display="none")),this.config.accessibility.keyboardNavigation&&this.setupKeyboardNavigation()}}startNewChat(){this.textInterface.startNewChat()}showLanding(){if(this.shadowRoot&&"unified"===(this.config.behavior.mode||"unified")){this.currentView="landing";var A=this.shadowRoot.getElementById("landingScreen"),e=this.shadowRoot.getElementById("textInterface"),t=this.shadowRoot.getElementById("voiceInterface"),n=this.shadowRoot.getElementById("backBtn"),o=this.shadowRoot.getElementById("newChatBtn");A&&A.classList.add("active"),e&&e.classList.remove("active"),t&&t.classList.remove("active"),n&&n.classList.remove("visible"),o&&(o.style.display="none")}}showText(){if(this.shadowRoot){this.currentView="text";var A=this.shadowRoot.getElementById("landingScreen"),e=this.shadowRoot.getElementById("voiceInterface"),t=this.shadowRoot.getElementById("backBtn"),n=this.shadowRoot.getElementById("newChatBtn");A&&A.classList.remove("active"),e&&e.classList.remove("active"),this.textInterface.show();var o=this.config.behavior.mode||"unified";t&&"unified"===o&&t.classList.add("visible"),n&&(n.style.display="")}}showVoice(){if(this.shadowRoot){this.currentView="voice";var A=this.shadowRoot.getElementById("landingScreen"),e=this.shadowRoot.getElementById("textInterface"),t=this.shadowRoot.getElementById("voiceInterface"),n=this.shadowRoot.getElementById("backBtn"),o=this.shadowRoot.getElementById("newChatBtn");A&&A.classList.remove("active"),e&&e.classList.remove("active"),t&&t.classList.add("active");var r=this.config.behavior.mode||"unified";n&&"unified"===r&&n.classList.add("visible"),o&&(o.style.display="none")}}setupKeyboardNavigation(){document.addEventListener("keydown",A=>{"Escape"===A.key&&this.isOpen&&this.togglePanel()})}togglePanel(){if(this.shadowRoot){this.isOpen=!this.isOpen;var A=this.shadowRoot.getElementById("text-chat-panel");A&&A.classList.toggle("open"),this.isOpen&&setTimeout(()=>{var A=this.shadowRoot.getElementById("messageInput");A&&A.focus()},100),this.isOpen&&!this.isActive&&this.config.behavior.autoConnect&&this.startChat()}}startChat(){var A=this;return _A(function*(){A.isActive=!0,A.textInterface.setActive(!0)})()}sendMessage(){var A=this;return _A(function*(){yield A.textInterface.sendMessage()})()}updateSendButtonState(){this.textInterface.updateSendButtonState()}getSignedUrl(){var A=this;return _A(function*(){if(A.config.signedUrl)return A.config.signedUrl;if(!A.config.agentId)throw new Error("agentId is required when signedUrl is not provided");var e=A.config.websocketUrl||"wss://backend.talktopc.com/ws/conv",t=new URLSearchParams;return t.append("agentId",A.config.agentId),A.config.appId&&t.append("appId",A.config.appId),!1!==A.config.demo&&t.append("demo","true"),"".concat(e,"?").concat(t.toString())})()}addMessage(A,e){this.textInterface.addMessage(A,e)}beginStreaming(){this.textInterface.beginStreaming()}appendStreamingChunk(A){this.textInterface.appendStreamingChunk(A)}finalizeStreaming(A){this.textInterface.finalizeStreaming(A)}stopStreamingState(){this.textInterface.stopStreamingState()}showError(A){this.textInterface.showError(A)}updateStatus(A){}updateConfig(A){var e,t,n,o,r,i,s,a,c,l=JA({},this.config);A.panel&&(l.panel=JA(JA({},this.config.panel),A.panel)),A.voice&&(l.voice=JA(JA({},this.config.voice),A.voice),A.voice.micButtonHint&&(l.voice.micButtonHint=JA(JA({},null===(a=this.config.voice)||void 0===a?void 0:a.micButtonHint),A.voice.micButtonHint))),A.text&&(l.text=JA(JA({},this.config.text),A.text),A.text.sendButtonHint&&(l.text.sendButtonHint=JA(JA({},null===(c=this.config.text)||void 0===c?void 0:c.sendButtonHint),A.text.sendButtonHint))),void 0!==A.language&&(l.language=A.language),void 0!==A.language&&(["he","ar"].includes(A.language)?l.direction="rtl":void 0===A.direction&&(l.direction="ltr")),A.translations&&(l.translations=A.translations,this.translations=A.translations),A.button&&(l.button=JA(JA({},this.config.button),A.button)),A.header&&(l.header=JA(JA({},this.config.header),A.header)),A.icon&&(l.icon=JA(JA({},this.config.icon),A.icon)),A.messages&&(l.messages=JA(JA({},this.config.messages),A.messages)),A.animation&&(l.animation=JA(JA({},this.config.animation),A.animation)),A.behavior&&(l.behavior=JA(JA({},this.config.behavior),A.behavior)),A.accessibility&&(l.accessibility=JA(JA({},this.config.accessibility),A.accessibility)),A.tooltips&&(l.tooltips=JA(JA({},this.config.tooltips),A.tooltips)),A.landing&&(l.landing=JA(JA({},this.config.landing),A.landing)),A.footer&&(l.footer=JA(JA({},this.config.footer),A.footer)),void 0!==A.direction&&void 0===l.direction&&(l.direction=A.direction),void 0!==A.primaryColor&&(l.primaryColor=A.primaryColor),l.onConversationStart=void 0!==A.onConversationStart?A.onConversationStart:this.config.onConversationStart,l.onConversationEnd=void 0!==A.onConversationEnd?A.onConversationEnd:this.config.onConversationEnd,l.onBargeIn=void 0!==A.onBargeIn?A.onBargeIn:this.config.onBargeIn,l.onAudioStartPlaying=void 0!==A.onAudioStartPlaying?A.onAudioStartPlaying:this.config.onAudioStartPlaying,l.onAudioStoppedPlaying=void 0!==A.onAudioStoppedPlaying?A.onAudioStoppedPlaying:this.config.onAudioStoppedPlaying,l.onSubtitleDisplay=void 0!==A.onSubtitleDisplay?A.onSubtitleDisplay:this.config.onSubtitleDisplay,void 0!==A.useShadowDOM&&(l.useShadowDOM=A.useShadowDOM),Object.keys(A).forEach(e=>{["panel","button","header","footer","icon","messages","direction","voice","text","animation","behavior","accessibility","language","tooltips","landing","primaryColor","useShadowDOM","onConversationStart","onConversationEnd","onBargeIn","onAudioStartPlaying","onAudioStoppedPlaying","onSubtitleDisplay"].includes(e)||(l[e]=A[e])}),null===(e=this.config)||void 0===e||e.language;var d=!1!==(null===(t=this.config)||void 0===t?void 0:t.useShadowDOM);if(this.config=this.mergeWithDefaults(l),!1!==this.config.useShadowDOM===d&&this.container){var u=document.getElementById("ttp-widget-shadow-host");u&&!this.config.useShadowDOM&&u.remove();var g=document.getElementById("ttp-widget-container");if(g&&this.config.useShadowDOM&&g.remove(),this.config.useShadowDOM)if(this.shadowRoot)this.container=this.shadowRoot;else{var B=document.getElementById("ttp-widget-shadow-host");B?(this.shadowRoot=B.shadowRoot,this.container=this.shadowRoot):(this.createShadowHost(),this.container=this.shadowRoot)}else{if(this.regularContainer)this.container=this.regularContainer;else{var h=document.getElementById("ttp-widget-container");h?(this.regularContainer=h,this.container=h):(this.createRegularContainer(),this.container=this.regularContainer)}this.shadowRoot=document}}else{var p=document.getElementById("ttp-widget-shadow-host");p&&p.remove();var w=document.getElementById("ttp-widget-container");if(w&&w.remove(),!1===d){var f=document.getElementById("ttp-widget-styles");f&&f.remove()}this.config.useShadowDOM?(this.createShadowHost(),this.container=this.shadowRoot):(this.createRegularContainer(),this.container=this.regularContainer,this.shadowRoot=document)}var C=this.config.language||"en",m=JA(JA(JA({},this.config),this.config.voice),{},{language:C,translations:this.translations,shadowRoot:this.shadowRoot,outputContainer:(null===(n=this.config.voice)||void 0===n?void 0:n.outputContainer)||"raw",outputEncoding:(null===(o=this.config.voice)||void 0===o?void 0:o.outputEncoding)||"pcm",outputSampleRate:(null===(r=this.config.voice)||void 0===r?void 0:r.outputSampleRate)||44100,outputChannels:(null===(i=this.config.voice)||void 0===i?void 0:i.outputChannels)||1,outputBitDepth:(null===(s=this.config.voice)||void 0===s?void 0:s.outputBitDepth)||16,onConversationStart:this.config.onConversationStart,onConversationEnd:this.config.onConversationEnd,onBargeIn:this.config.onBargeIn,onAudioStartPlaying:this.config.onAudioStartPlaying,onAudioStoppedPlaying:this.config.onAudioStoppedPlaying,onSubtitleDisplay:this.config.onSubtitleDisplay});this.voiceInterface=new RA(m);var v=JA(JA(JA({},this.config),this.config.text),{},{language:C,translations:this.translations,shadowRoot:this.shadowRoot});this.textInterface=new VA(v,this.sdk),this.createWidget(),this.textInterface&&this.textInterface.updateInputAttributes&&this.textInterface.updateInputAttributes()}destroy(){var A=document.getElementById("ttp-widget-shadow-host");A&&A.remove();var e=document.getElementById("ttp-widget-container");e&&e.remove();var t=document.getElementById("ttp-widget-styles");t&&t.remove(),this.sdk&&this.sdk.destroy(),this.voiceInterface&&this.voiceInterface.destroy()}startVoiceCall(){var A=this;return _A(function*(){yield A.voiceInterface.startVoiceCall(),A._flushPendingClientTools()})()}endVoiceCall(){this.voiceInterface.endVoiceCall()}toggleMute(){this.voiceInterface.toggleMute()}toggleSpeaker(){this.voiceInterface.toggleSpeaker()}registerToolHandler(A,e){var t;return null!==(t=this.voiceInterface)&&void 0!==t&&t.sdk?this.voiceInterface.sdk.registerToolHandler(A,e):(this._pendingClientTools=this._pendingClientTools||[],this._pendingClientTools.push({name:A,handler:e}),console.warn("TTPChatWidget: Tool handler queued - voice interface SDK not ready yet"),this._flushPendingClientTools(),this)}unregisterToolHandler(A){var e;return null!==(e=this.voiceInterface)&&void 0!==e&&e.sdk?this.voiceInterface.sdk.unregisterToolHandler(A):(this._pendingClientTools&&(this._pendingClientTools=this._pendingClientTools.filter(e=>e.name!==A)),this)}hasToolHandler(A){var e;return!(null===(e=this.voiceInterface)||void 0===e||!e.sdk)&&this.voiceInterface.sdk.hasToolHandler(A)}getRegisteredTools(){var A;return null!==(A=this.voiceInterface)&&void 0!==A&&A.sdk?this.voiceInterface.sdk.getRegisteredTools():this._pendingClientTools?this._pendingClientTools.map(A=>A.name):[]}_flushPendingClientTools(){var A;this._pendingClientTools&&null!==(A=this.voiceInterface)&&void 0!==A&&A.sdk&&(this._pendingClientTools.forEach(A=>{var{name:e,handler:t}=A;this.voiceInterface.sdk.registerToolHandler(e,t)}),this._pendingClientTools=null,console.log("TTPChatWidget: Flushed pending client tools"))}registerClientTool(A,e){return this.registerToolHandler(A,e)}unregisterClientTool(A){return this.unregisterToolHandler(A)}hasClientTool(A){return this.hasToolHandler(A)}getRegisteredClientTools(){return this.getRegisteredTools()}}var zA="2.18.0";const jA={VoiceSDK_v2:z,TextChatSDK:eA,WebSocketManager:rA,AudioRecorder:aA,AudioPlayer:dA,EventEmitter:j,VoiceButton:wA,VanillaVoiceButton:QA,AgentSDK:yA,TTPChatWidget:YA,VERSION:zA};export{yA as AgentSDK,dA as AudioPlayer,aA as AudioRecorder,j as EventEmitter,s as MicPermissionModals,i as MicPermissionUtils,YA as TTPChatWidget,eA as TextChatSDK,zA as VERSION,QA as VanillaVoiceButton,wA as VoiceButton,z as VoiceSDK_v2,rA as WebSocketManager,jA as default};
|
|
3
3
|
//# sourceMappingURL=agent-widget.esm.js.map
|