ttp-agent-sdk 2.2.7 → 2.2.8

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.
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see agent-widget.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.TTPAgentSDK=t():e.TTPAgentSDK=t()}(window,()=>(()=>{"use strict";var e={"./node_modules/react/cjs/react-jsx-runtime.development.js":(e,t,n)=>{!function(){function e(t){if(null==t)return null;if("function"==typeof t)return t.$$typeof===O?null:t.displayName||t.name||null;if("string"==typeof t)return t;switch(t){case v:return"Fragment";case y:return"Profiler";case h:return"StrictMode";case k:return"Suspense";case x:return"SuspenseList";case j:return"Activity"}if("object"==typeof t)switch("number"==typeof t.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case g:return"Portal";case m:return t.displayName||"Context";case b:return(t._context.displayName||"Context")+".Consumer";case w:var n=t.render;return(t=t.displayName)||(t=""!==(t=n.displayName||n.name||"")?"ForwardRef("+t+")":"ForwardRef"),t;case S:return null!==(n=t.displayName||null)?n:e(t.type)||"Memo";case C:n=t._payload,t=t._init;try{return e(t(n))}catch(e){}}return null}function o(e){return""+e}function r(e){try{o(e);var t=!1}catch(e){t=!0}if(t){var n=(t=console).error,r="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",r),o(e)}}function i(t){if(t===v)return"<>";if("object"==typeof t&&null!==t&&t.$$typeof===C)return"<...>";try{var n=e(t);return n?"<"+n+">":"<...>"}catch(e){return"<...>"}}function a(){return Error("react-stack-top-frame")}function c(){var t=e(this.type);return P[t]||(P[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),void 0!==(t=this.props.ref)?t:null}function s(t,n,o,i,a,s){var u,f=n.children;if(void 0!==f)if(i)if(T(f)){for(i=0;i<f.length;i++)l(f[i]);Object.freeze&&Object.freeze(f)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else l(f);if(I.call(n,"key")){f=e(t);var g=Object.keys(n).filter(function(e){return"key"!==e});i=0<g.length?"{key: someKey, "+g.join(": ..., ")+": ...}":"{key: someKey}",R[f+i]||(g=0<g.length?"{"+g.join(": ..., ")+": ...}":"{}",console.error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',i,f,g,f),R[f+i]=!0)}if(f=null,void 0!==o&&(r(o),f=""+o),function(e){if(I.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(n)&&(r(n.key),f=""+n.key),"key"in n)for(var v in o={},n)"key"!==v&&(o[v]=n[v]);else o=n;return f&&function(e,t){function n(){d||(d=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}(o,"function"==typeof t?t.displayName||t.name||"Unknown":t),function(e,t,n,o,r,i){var a=n.ref;return e={$$typeof:p,type:e,key:t,props:n,_owner:o},null!==(void 0!==a?a:null)?Object.defineProperty(e,"ref",{enumerable:!1,get:c}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:r}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(t,f,o,null===(u=E.A)?null:u.getOwner(),a,s)}function l(e){u(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===C&&("fulfilled"===e._payload.status?u(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function u(e){return"object"==typeof e&&null!==e&&e.$$typeof===p}var d,f=n("./node_modules/react/index.js"),p=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),h=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),m=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),j=Symbol.for("react.activity"),O=Symbol.for("react.client.reference"),E=f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=Object.prototype.hasOwnProperty,T=Array.isArray,B=console.createTask?console.createTask:function(){return null},P={},_=(f={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(f,a)(),F=B(i(a)),R={};t.Fragment=v,t.jsx=function(e,t,n){var o=1e4>E.recentlyCreatedOwnerStacks++;return s(e,t,n,!1,o?Error("react-stack-top-frame"):_,o?B(i(e)):F)},t.jsxs=function(e,t,n){var o=1e4>E.recentlyCreatedOwnerStacks++;return s(e,t,n,!0,o?Error("react-stack-top-frame"):_,o?B(i(e)):F)}}()},"./node_modules/react/cjs/react.development.js":(e,t,n)=>{e=n.nmd(e),function(){function n(e,t){Object.defineProperty(r.prototype,e,{get:function(){console.warn("%s(...) is deprecated in plain JavaScript React classes. %s",t[0],t[1])}})}function o(e,t){var n=(e=(e=e.constructor)&&(e.displayName||e.name)||"ReactClass")+"."+t;W[n]||(console.error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",t,e),W[n]=!0)}function r(e,t,n){this.props=e,this.context=t,this.refs=$,this.updater=n||V}function i(){}function a(e,t,n){this.props=e,this.context=t,this.refs=$,this.updater=n||V}function c(){}function s(e){return""+e}function l(e){try{s(e);var t=!1}catch(e){t=!0}if(t){var n=(t=console).error,o="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",o),s(e)}}function u(e){if(null==e)return null;if("function"==typeof e)return e.$$typeof===X?null:e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case _:return"Fragment";case R:return"Profiler";case F:return"StrictMode";case L:return"Suspense";case z:return"SuspenseList";case N:return"Activity"}if("object"==typeof e)switch("number"==typeof e.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case P:return"Portal";case D:return e.displayName||"Context";case A:return(e._context.displayName||"Context")+".Consumer";case M:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case H:return null!==(t=e.displayName||null)?t:u(e.type)||"Memo";case U:t=e._payload,e=e._init;try{return u(e(t))}catch(e){}}return null}function d(e){if(e===_)return"<>";if("object"==typeof e&&null!==e&&e.$$typeof===U)return"<...>";try{var t=u(e);return t?"<"+t+">":"<...>"}catch(e){return"<...>"}}function f(){var e=Z.A;return null===e?null:e.getOwner()}function p(){return Error("react-stack-top-frame")}function g(e){if(ee.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}function v(){var e=u(this.type);return ne[e]||(ne[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),void 0!==(e=this.props.ref)?e:null}function h(e,t,n,o,r,i){var a=n.ref;return e={$$typeof:B,type:e,key:t,props:n,_owner:o},null!==(void 0!==a?a:null)?Object.defineProperty(e,"ref",{enumerable:!1,get:v}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:r}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function y(e){b(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===U&&("fulfilled"===e._payload.status?b(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function b(e){return"object"==typeof e&&null!==e&&e.$$typeof===B}function m(e,t){return"object"==typeof e&&null!==e&&null!=e.key?(l(e.key),n=""+e.key,o={"=":"=0",":":"=2"},"$"+n.replace(/[=:]/g,function(e){return o[e]})):t.toString(36);var n,o}function w(e,t,n,o,r){var i=typeof e;"undefined"!==i&&"boolean"!==i||(e=null);var a,s,u,d=!1;if(null===e)d=!0;else switch(i){case"bigint":case"string":case"number":d=!0;break;case"object":switch(e.$$typeof){case B:case P:d=!0;break;case U:return w((d=e._init)(e._payload),t,n,o,r)}}if(d){r=r(d=e);var f=""===o?"."+m(d,0):o;return J(r)?(n="",null!=f&&(n=f.replace(ae,"$&/")+"/"),w(r,t,n,"",function(e){return e})):null!=r&&(b(r)&&(null!=r.key&&(d&&d.key===r.key||l(r.key)),a=r,s=n+(null==r.key||d&&d.key===r.key?"":(""+r.key).replace(ae,"$&/")+"/")+f,s=h(a.type,s,a.props,a._owner,a._debugStack,a._debugTask),a._store&&(s._store.validated=a._store.validated),n=s,""!==o&&null!=d&&b(d)&&null==d.key&&d._store&&!d._store.validated&&(n._store.validated=2),r=n),t.push(r)),1}if(d=0,f=""===o?".":o+":",J(e))for(var p=0;p<e.length;p++)d+=w(o=e[p],t,n,i=f+m(o,p),r);else if("function"==typeof(p=null===(u=e)||"object"!=typeof u?null:"function"==typeof(u=K&&u[K]||u["@@iterator"])?u:null))for(p===e.entries&&(ie||console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),ie=!0),e=p.call(e),p=0;!(o=e.next()).done;)d+=w(o=o.value,t,n,i=f+m(o,p++),r);else if("object"===i){if("function"==typeof e.then)return w(function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch("string"==typeof e.status?e.then(c,c):(e.status="pending",e.then(function(t){"pending"===e.status&&(e.status="fulfilled",e.value=t)},function(t){"pending"===e.status&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}(e),t,n,o,r);throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return d}function k(e,t,n){if(null==e)return e;var o=[],r=0;return w(e,o,"","",function(e){return t.call(n,e,r++)}),o}function x(e){if(-1===e._status){var t=e._ioInfo;null!=t&&(t.start=t.end=performance.now());var n=(t=e._result)();if(n.then(function(t){if(0===e._status||-1===e._status){e._status=1,e._result=t;var o=e._ioInfo;null!=o&&(o.end=performance.now()),void 0===n.status&&(n.status="fulfilled",n.value=t)}},function(t){if(0===e._status||-1===e._status){e._status=2,e._result=t;var o=e._ioInfo;null!=o&&(o.end=performance.now()),void 0===n.status&&(n.status="rejected",n.reason=t)}}),null!=(t=e._ioInfo)){t.value=n;var o=n.displayName;"string"==typeof o&&(t.name=o)}-1===e._status&&(e._status=0,e._result=n)}if(1===e._status)return void 0===(t=e._result)&&console.error("lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))\n\nDid you accidentally put curly braces around the import?",t),"default"in t||console.error("lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))",t),t.default;throw e._result}function S(){var e=Z.H;return null===e&&console.error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."),e}function C(){Z.asyncTransitions--}function j(t){if(null===le)try{var n=("require"+Math.random()).slice(0,7);le=(e&&e[n]).call(e,"timers").setImmediate}catch(e){le=function(e){!1===se&&(se=!0,"undefined"==typeof MessageChannel&&console.error("This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."));var t=new MessageChannel;t.port1.onmessage=e,t.port2.postMessage(void 0)}}return le(t)}function O(e){return 1<e.length&&"function"==typeof AggregateError?new AggregateError(e):e[0]}function E(e,t){t!==ue-1&&console.error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "),ue=t}function I(e,t,n){var o=Z.actQueue;if(null!==o)if(0!==o.length)try{return T(o),void j(function(){return I(e,t,n)})}catch(e){Z.thrownErrors.push(e)}else Z.actQueue=null;0<Z.thrownErrors.length?(o=O(Z.thrownErrors),Z.thrownErrors.length=0,n(o)):t(e)}function T(e){if(!fe){fe=!0;var t=0;try{for(;t<e.length;t++)for(var n=e[t];;){Z.didUsePromise=!1;var o=n(!1);if(null===o)break;if(Z.didUsePromise)return e[t]=n,void e.splice(0,t);n=o}e.length=0}catch(n){e.splice(0,t+1),Z.thrownErrors.push(n)}finally{fe=!1}}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var B=Symbol.for("react.transitional.element"),P=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),F=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),D=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),K=Symbol.iterator,W={},V={isMounted:function(){return!1},enqueueForceUpdate:function(e){o(e,"forceUpdate")},enqueueReplaceState:function(e){o(e,"replaceState")},enqueueSetState:function(e){o(e,"setState")}},G=Object.assign,$={};Object.freeze($),r.prototype.isReactComponent={},r.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},r.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};var q={isMounted:["isMounted","Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],replaceState:["replaceState","Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]};for(ge in q)q.hasOwnProperty(ge)&&n(ge,q[ge]);i.prototype=r.prototype,(q=a.prototype=new i).constructor=a,G(q,r.prototype),q.isPureReactComponent=!0;var Q,Y,J=Array.isArray,X=Symbol.for("react.client.reference"),Z={H:null,A:null,T:null,S:null,actQueue:null,asyncTransitions:0,isBatchingLegacy:!1,didScheduleLegacyUpdate:!1,didUsePromise:!1,thrownErrors:[],getCurrentStack:null,recentlyCreatedOwnerStacks:0},ee=Object.prototype.hasOwnProperty,te=console.createTask?console.createTask:function(){return null},ne={},oe=(q={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(q,p)(),re=te(d(p)),ie=!1,ae=/\/+/g,ce="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},se=!1,le=null,ue=0,de=!1,fe=!1,pe="function"==typeof queueMicrotask?function(e){queueMicrotask(function(){return queueMicrotask(e)})}:j;q=Object.freeze({__proto__:null,c:function(e){return S().useMemoCache(e)}});var ge={map:k,forEach:function(e,t,n){k(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return k(e,function(){t++}),t},toArray:function(e){return k(e,function(e){return e})||[]},only:function(e){if(!b(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};t.Activity=N,t.Children=ge,t.Component=r,t.Fragment=_,t.Profiler=R,t.PureComponent=a,t.StrictMode=F,t.Suspense=L,t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Z,t.__COMPILER_RUNTIME=q,t.act=function(e){var t=Z.actQueue,n=ue;ue++;var o=Z.actQueue=null!==t?t:[],r=!1;try{var i=e()}catch(e){Z.thrownErrors.push(e)}if(0<Z.thrownErrors.length)throw E(0,n),e=O(Z.thrownErrors),Z.thrownErrors.length=0,e;if(null!==i&&"object"==typeof i&&"function"==typeof i.then){var a=i;return pe(function(){r||de||(de=!0,console.error("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"))}),{then:function(e,t){r=!0,a.then(function(r){if(E(0,n),0===n){try{T(o),j(function(){return I(r,e,t)})}catch(e){Z.thrownErrors.push(e)}if(0<Z.thrownErrors.length){var i=O(Z.thrownErrors);Z.thrownErrors.length=0,t(i)}}else e(r)},function(e){E(0,n),0<Z.thrownErrors.length?(e=O(Z.thrownErrors),Z.thrownErrors.length=0,t(e)):t(e)})}}}var c=i;if(E(0,n),0===n&&(T(o),0!==o.length&&pe(function(){r||de||(de=!0,console.error("A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"))}),Z.actQueue=null),0<Z.thrownErrors.length)throw e=O(Z.thrownErrors),Z.thrownErrors.length=0,e;return{then:function(e,t){r=!0,0===n?(Z.actQueue=o,j(function(){return I(c,e,t)})):e(c)}}},t.cache=function(e){return function(){return e.apply(null,arguments)}},t.cacheSignal=function(){return null},t.captureOwnerStack=function(){var e=Z.getCurrentStack;return null===e?null:e()},t.cloneElement=function(e,t,n){if(null==e)throw Error("The argument must be a React element, but you passed "+e+".");var o,r=G({},e.props),i=e.key,a=e._owner;if(null!=t)for(c in(o=!(ee.call(t,"ref")&&(o=Object.getOwnPropertyDescriptor(t,"ref").get)&&o.isReactWarning)&&void 0!==t.ref)&&(a=f()),g(t)&&(l(t.key),i=""+t.key),t)!ee.call(t,c)||"key"===c||"__self"===c||"__source"===c||"ref"===c&&void 0===t.ref||(r[c]=t[c]);var c=arguments.length-2;if(1===c)r.children=n;else if(1<c){o=Array(c);for(var s=0;s<c;s++)o[s]=arguments[s+2];r.children=o}for(r=h(e.type,i,r,a,e._debugStack,e._debugTask),i=2;i<arguments.length;i++)y(arguments[i]);return r},t.createContext=function(e){return(e={$$typeof:D,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider=e,e.Consumer={$$typeof:A,_context:e},e._currentRenderer=null,e._currentRenderer2=null,e},t.createElement=function(e,t,n){for(var o=2;o<arguments.length;o++)y(arguments[o]);o={};var r=null;if(null!=t)for(s in Y||!("__self"in t)||"key"in t||(Y=!0,console.warn("Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform")),g(t)&&(l(t.key),r=""+t.key),t)ee.call(t,s)&&"key"!==s&&"__self"!==s&&"__source"!==s&&(o[s]=t[s]);var i=arguments.length-2;if(1===i)o.children=n;else if(1<i){for(var a=Array(i),c=0;c<i;c++)a[c]=arguments[c+2];Object.freeze&&Object.freeze(a),o.children=a}if(e&&e.defaultProps)for(s in i=e.defaultProps)void 0===o[s]&&(o[s]=i[s]);r&&function(e,t){function n(){Q||(Q=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}(o,"function"==typeof e?e.displayName||e.name||"Unknown":e);var s=1e4>Z.recentlyCreatedOwnerStacks++;return h(e,r,o,f(),s?Error("react-stack-top-frame"):oe,s?te(d(e)):re)},t.createRef=function(){var e={current:null};return Object.seal(e),e},t.forwardRef=function(e){null!=e&&e.$$typeof===H?console.error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."):"function"!=typeof e?console.error("forwardRef requires a render function but was given %s.",null===e?"null":typeof e):0!==e.length&&2!==e.length&&console.error("forwardRef render functions accept exactly two parameters: props and ref. %s",1===e.length?"Did you forget to use the ref parameter?":"Any additional parameter will be undefined."),null!=e&&null!=e.defaultProps&&console.error("forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?");var t,n={$$typeof:M,render:e};return Object.defineProperty(n,"displayName",{enumerable:!1,configurable:!0,get:function(){return t},set:function(n){t=n,e.name||e.displayName||(Object.defineProperty(e,"name",{value:n}),e.displayName=n)}}),n},t.isValidElement=b,t.lazy=function(e){var t={$$typeof:U,_payload:e={_status:-1,_result:e},_init:x},n={name:"lazy",start:-1,end:-1,value:null,owner:null,debugStack:Error("react-stack-top-frame"),debugTask:console.createTask?console.createTask("lazy()"):null};return e._ioInfo=n,t._debugInfo=[{awaited:n}],t},t.memo=function(e,t){var n;return null==e&&console.error("memo: The first argument must be a component. Instead received: %s",null===e?"null":typeof e),t={$$typeof:H,type:e,compare:void 0===t?null:t},Object.defineProperty(t,"displayName",{enumerable:!1,configurable:!0,get:function(){return n},set:function(t){n=t,e.name||e.displayName||(Object.defineProperty(e,"name",{value:t}),e.displayName=t)}}),t},t.startTransition=function(e){var t=Z.T,n={};n._updatedFibers=new Set,Z.T=n;try{var o=e(),r=Z.S;null!==r&&r(n,o),"object"==typeof o&&null!==o&&"function"==typeof o.then&&(Z.asyncTransitions++,o.then(C,C),o.then(c,ce))}catch(e){ce(e)}finally{null===t&&n._updatedFibers&&(e=n._updatedFibers.size,n._updatedFibers.clear(),10<e&&console.warn("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.")),null!==t&&null!==n.types&&(null!==t.types&&t.types!==n.types&&console.error("We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."),t.types=n.types),Z.T=t}},t.unstable_useCacheRefresh=function(){return S().useCacheRefresh()},t.use=function(e){return S().use(e)},t.useActionState=function(e,t,n){return S().useActionState(e,t,n)},t.useCallback=function(e,t){return S().useCallback(e,t)},t.useContext=function(e){var t=S();return e.$$typeof===A&&console.error("Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"),t.useContext(e)},t.useDebugValue=function(e,t){return S().useDebugValue(e,t)},t.useDeferredValue=function(e,t){return S().useDeferredValue(e,t)},t.useEffect=function(e,t){return null==e&&console.warn("React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"),S().useEffect(e,t)},t.useEffectEvent=function(e){return S().useEffectEvent(e)},t.useId=function(){return S().useId()},t.useImperativeHandle=function(e,t,n){return S().useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return null==e&&console.warn("React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"),S().useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return null==e&&console.warn("React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"),S().useLayoutEffect(e,t)},t.useMemo=function(e,t){return S().useMemo(e,t)},t.useOptimistic=function(e,t){return S().useOptimistic(e,t)},t.useReducer=function(e,t,n){return S().useReducer(e,t,n)},t.useRef=function(e){return S().useRef(e)},t.useState=function(e){return S().useState(e)},t.useSyncExternalStore=function(e,t,n){return S().useSyncExternalStore(e,t,n)},t.useTransition=function(){return S().useTransition()},t.version="19.2.0","undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()},"./node_modules/react/index.js":(e,t,n)=>{e.exports=n("./node_modules/react/cjs/react.development.js")},"./node_modules/react/jsx-runtime.js":(e,t,n)=>{e.exports=n("./node_modules/react/cjs/react-jsx-runtime.development.js")},"./src/core/AudioPlayer.js":(e,t,n)=>{function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function r(){var e,t,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.toStringTag||"@@toStringTag";function c(n,o,r,a){var c=o&&o.prototype instanceof l?o:l,u=Object.create(c.prototype);return i(u,"_invoke",function(n,o,r){var i,a,c,l=0,u=r||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,a=0,c=e,f.n=n,s}};function p(n,o){for(a=n,c=o,t=0;!d&&l&&!r&&t<u.length;t++){var r,i=u[t],p=f.p,g=i[2];n>3?(r=g===o)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=p&&((r=n<2&&p<i[1])?(a=0,f.v=o,f.n=i[1]):p<g&&(r=n<3||i[0]>o||o>g)&&(i[4]=n,i[5]=o,f.n=g,a=0))}if(r||n>1)return s;throw d=!0,o}return function(r,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&p(u,g),a=u,c=g;(t=a<2?e:c)||!d;){i||(a?a<3?(a>1&&(f.n=-1),p(a,c)):f.n=c:f.v=c);try{if(l=2,i){if(a||(r="next"),t=i[r]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),a=1);i=e}else if((t=(d=f.n<0)?c:n.call(o,f))!==s)break}catch(t){i=e,a=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,r,a),!0),u}var s={};function l(){}function u(){}function d(){}t=Object.getPrototypeOf;var f=[][o]?t(t([][o]())):(i(t={},o,function(){return this}),t),p=d.prototype=l.prototype=Object.create(f);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,i(e,a,"GeneratorFunction")),e.prototype=Object.create(p),e}return u.prototype=d,i(p,"constructor",d),i(d,"constructor",u),u.displayName="GeneratorFunction",i(d,a,"GeneratorFunction"),i(p),i(p,a,"Generator"),i(p,o,function(){return this}),i(p,"toString",function(){return"[object Generator]"}),(r=function(){return{w:c,m:g}})()}function i(e,t,n,o){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}i=function(e,t,n,o){function a(t,n){i(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},i(e,t,n,o)}function a(e,t,n,o,r,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(o,r)}function c(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,s(o.key),o)}}function s(e){var t=function(e){if("object"!=o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==o(t)?t:t+""}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}n.r(t),n.d(t,{default:()=>f});var f=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=function(e,t,n){return t=u(t),function(e,t){if(t&&("object"==o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,n||[],u(e).constructor):t.apply(e,n))}(this,t)).config=e,n.audioContext=null,n.audioQueue=[],n.isPlaying=!1,n.isProcessingQueue=!1,n.currentSource=null,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}(t,e),n=t,i=[{key:"playAudio",value:function(e){var t=this;try{var n=this.createAudioBlob(e);this.audioQueue.push(n),this.isPlaying||this.isProcessingQueue||this.currentSource||setTimeout(function(){return t.processQueue()},50)}catch(e){this.emit("playbackError",e)}}},{key:"createAudioBlob",value:function(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"})}},{key:"processQueue",value:(s=r().m(function e(){var t,n,o,i,a,c,s,l,u=this;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!this.isProcessingQueue&&0!==this.audioQueue.length){e.n=1;break}return e.a(2);case 1:if(this.isProcessingQueue=!0,t=this.audioQueue.shift()){e.n=2;break}return this.isProcessingQueue=!1,e.a(2);case 2:if(e.p=2,n=!this.isPlaying&&null===this.currentSource,this.audioContext||(this.audioContext=new(window.AudioContext||window.webkitAudioContext)),"suspended"!==(o=this.audioContext).state){e.n=3;break}return e.n=3,o.resume();case 3:return e.n=4,t.arrayBuffer();case 4:return i=e.v,e.n=5,o.decodeAudioData(i);case 5:a=e.v,c=n&&!this.isPlaying&&null===this.currentSource,(s=o.createBufferSource()).buffer=a,s.connect(o.destination),this.currentSource=s,this.isPlaying=!0,c&&this.emit("playbackStarted"),s.onended=function(){u.currentSource=null,u.isProcessingQueue=!1,u.audioQueue.length>0?setTimeout(function(){return u.processQueue()},50):setTimeout(function(){0!==u.audioQueue.length||u.currentSource||(u.isPlaying=!1,u.emit("playbackStopped"))},100)},s.start(),e.n=7;break;case 6:e.p=6,l=e.v,this.currentSource=null,this.emit("playbackError",l),this.audioQueue.length>0?(this.isProcessingQueue=!1,setTimeout(function(){return u.processQueue()},100)):(this.isPlaying=!1,this.isProcessingQueue=!1,this.emit("playbackStopped"));case 7:return e.a(2)}},e,this,[[2,6]])}),f=function(){var e=this,t=arguments;return new Promise(function(n,o){var r=s.apply(e,t);function i(e){a(r,n,o,i,c,"next",e)}function c(e){a(r,n,o,i,c,"throw",e)}i(void 0)})},function(){return f.apply(this,arguments)})},{key:"stop",value:function(){this.stopImmediate()}},{key:"stopImmediate",value:function(){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")}},{key:"getStatus",value:function(){return{isPlaying:this.isPlaying,isProcessingQueue:this.isProcessingQueue,queueLength:this.audioQueue.length,audioContextState:this.audioContext?this.audioContext.state:"closed"}}},{key:"destroy",value:function(){this.stop(),this.audioContext&&"closed"!==this.audioContext.state&&(this.audioContext.close(),this.audioContext=null)}}],i&&c(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,i,s,f}(n("./src/core/EventEmitter.js").default)},"./src/core/AudioRecorder.js":(e,t,n)=>{function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function r(){var e,t,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.toStringTag||"@@toStringTag";function c(n,o,r,a){var c=o&&o.prototype instanceof l?o:l,u=Object.create(c.prototype);return i(u,"_invoke",function(n,o,r){var i,a,c,l=0,u=r||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,a=0,c=e,f.n=n,s}};function p(n,o){for(a=n,c=o,t=0;!d&&l&&!r&&t<u.length;t++){var r,i=u[t],p=f.p,g=i[2];n>3?(r=g===o)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=p&&((r=n<2&&p<i[1])?(a=0,f.v=o,f.n=i[1]):p<g&&(r=n<3||i[0]>o||o>g)&&(i[4]=n,i[5]=o,f.n=g,a=0))}if(r||n>1)return s;throw d=!0,o}return function(r,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&p(u,g),a=u,c=g;(t=a<2?e:c)||!d;){i||(a?a<3?(a>1&&(f.n=-1),p(a,c)):f.n=c:f.v=c);try{if(l=2,i){if(a||(r="next"),t=i[r]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),a=1);i=e}else if((t=(d=f.n<0)?c:n.call(o,f))!==s)break}catch(t){i=e,a=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,r,a),!0),u}var s={};function l(){}function u(){}function d(){}t=Object.getPrototypeOf;var f=[][o]?t(t([][o]())):(i(t={},o,function(){return this}),t),p=d.prototype=l.prototype=Object.create(f);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,i(e,a,"GeneratorFunction")),e.prototype=Object.create(p),e}return u.prototype=d,i(p,"constructor",d),i(d,"constructor",u),u.displayName="GeneratorFunction",i(d,a,"GeneratorFunction"),i(p),i(p,a,"Generator"),i(p,o,function(){return this}),i(p,"toString",function(){return"[object Generator]"}),(r=function(){return{w:c,m:g}})()}function i(e,t,n,o){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}i=function(e,t,n,o){function a(t,n){i(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},i(e,t,n,o)}function a(e,t,n,o,r,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(o,r)}function c(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var i=e.apply(t,n);function c(e){a(i,o,r,c,s,"next",e)}function s(e){a(i,o,r,c,s,"throw",e)}c(void 0)})}}function s(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,l(o.key),o)}}function l(e){var t=function(e){if("object"!=o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==o(t)?t:t+""}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(u=function(){return!!e})()}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function f(e,t){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},f(e,t)}n.r(t),n.d(t,{default:()=>p});var p=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=function(e,t,n){return t=d(t),function(e,t){if(t&&("object"==o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,u()?Reflect.construct(t,n||[],d(e).constructor):t.apply(e,n))}(this,t)).config=e,n.audioContext=null,n.audioWorkletNode=null,n.mediaStream=null,n.isRecording=!1,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&f(e,t)}(t,e),n=t,i=[{key:"start",value:(l=c(r().m(function e(){var t,n=this;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,navigator.mediaDevices.getUserMedia({audio:{sampleRate:this.config.sampleRate,channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});case 1:if(this.mediaStream=e.v,this.audioContext=new(window.AudioContext||window.webkitAudioContext)({sampleRate:this.config.sampleRate}),"suspended"!==this.audioContext.state){e.n=2;break}return e.n=2,this.audioContext.resume();case 2:return e.n=3,this.audioContext.audioWorklet.addModule("/audio-processor.js");case 3:this.audioWorkletNode=new AudioWorkletNode(this.audioContext,"audio-processor"),this.audioContext.createMediaStreamSource(this.mediaStream).connect(this.audioWorkletNode),this.audioWorkletNode.port.onmessage=function(e){var t=e.data,o=t.type,r=t.data;"pcm_audio_data"===o&&n.emit("audioData",r)},this.audioWorkletNode.port.postMessage({type:"setForceContinuous",data:{enabled:!0}}),this.isRecording=!0,this.emit("recordingStarted"),e.n=5;break;case 4:throw e.p=4,t=e.v,this.emit("error",t),t;case 5:return e.a(2)}},e,this,[[0,4]])})),function(){return l.apply(this,arguments)})},{key:"stop",value:(a=c(r().m(function e(){var t;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.isRecording){e.n=1;break}return e.a(2);case 1:if(e.p=1,!this.audioWorkletNode){e.n=2;break}return this.audioWorkletNode.port.postMessage({type:"flush"}),e.n=2,new Promise(function(e){return setTimeout(e,100)});case 2:if(this.mediaStream&&(this.mediaStream.getTracks().forEach(function(e){return e.stop()}),this.mediaStream=null),!this.audioContext||"closed"===this.audioContext.state){e.n=4;break}return e.n=3,this.audioContext.close();case 3:this.audioContext=null;case 4:this.audioWorkletNode=null,this.isRecording=!1,this.emit("recordingStopped"),e.n=6;break;case 5:throw e.p=5,t=e.v,this.emit("error",t),t;case 6:return e.a(2)}},e,this,[[1,5]])})),function(){return a.apply(this,arguments)})},{key:"getStatus",value:function(){return{isRecording:this.isRecording,audioContextState:this.audioContext?this.audioContext.state:"closed"}}},{key:"destroy",value:function(){this.stop()}}],i&&s(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,i,a,l}(n("./src/core/EventEmitter.js").default)},"./src/core/EventEmitter.js":(e,t,n)=>{function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function r(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,i(o.key),o)}}function i(e){var t=function(e){if("object"!=o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==o(t)?t:t+""}n.r(t),n.d(t,{default:()=>a});var a=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.events={}},t=[{key:"on",value:function(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}},{key:"off",value:function(e,t){this.events[e]&&(this.events[e]=this.events[e].filter(function(e){return e!==t}))}},{key:"emit",value:function(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(function(t){try{t.apply(void 0,n)}catch(t){console.error("Error in event listener for ".concat(e,":"),t)}})}},{key:"removeAllListeners",value:function(e){e?delete this.events[e]:this.events={}}}],t&&r(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}()},"./src/core/TextChatSDK.js":(e,t,n)=>{function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function r(){var e,t,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.toStringTag||"@@toStringTag";function c(n,o,r,a){var c=o&&o.prototype instanceof l?o:l,u=Object.create(c.prototype);return i(u,"_invoke",function(n,o,r){var i,a,c,l=0,u=r||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,a=0,c=e,f.n=n,s}};function p(n,o){for(a=n,c=o,t=0;!d&&l&&!r&&t<u.length;t++){var r,i=u[t],p=f.p,g=i[2];n>3?(r=g===o)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=p&&((r=n<2&&p<i[1])?(a=0,f.v=o,f.n=i[1]):p<g&&(r=n<3||i[0]>o||o>g)&&(i[4]=n,i[5]=o,f.n=g,a=0))}if(r||n>1)return s;throw d=!0,o}return function(r,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&p(u,g),a=u,c=g;(t=a<2?e:c)||!d;){i||(a?a<3?(a>1&&(f.n=-1),p(a,c)):f.n=c:f.v=c);try{if(l=2,i){if(a||(r="next"),t=i[r]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),a=1);i=e}else if((t=(d=f.n<0)?c:n.call(o,f))!==s)break}catch(t){i=e,a=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,r,a),!0),u}var s={};function l(){}function u(){}function d(){}t=Object.getPrototypeOf;var f=[][o]?t(t([][o]())):(i(t={},o,function(){return this}),t),p=d.prototype=l.prototype=Object.create(f);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,i(e,a,"GeneratorFunction")),e.prototype=Object.create(p),e}return u.prototype=d,i(p,"constructor",d),i(d,"constructor",u),u.displayName="GeneratorFunction",i(d,a,"GeneratorFunction"),i(p),i(p,a,"Generator"),i(p,o,function(){return this}),i(p,"toString",function(){return"[object Generator]"}),(r=function(){return{w:c,m:g}})()}function i(e,t,n,o){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}i=function(e,t,n,o){function a(t,n){i(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},i(e,t,n,o)}function a(e,t,n,o,r,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(o,r)}function c(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 s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach(function(t){l(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function l(e,t,n){return(t=d(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,d(o.key),o)}}function d(e){var t=function(e){if("object"!=o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==o(t)?t:t+""}function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}function p(e){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},p(e)}function g(e,t){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},g(e,t)}n.r(t),n.d(t,{default:()=>v});var v=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=(e=function(e,t,n){return t=p(t),function(e,t){if(t&&("object"==o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,f()?Reflect.construct(t,n||[],p(e).constructor):t.apply(e,n))}(this,t)).readScriptTagConfig();return e.config=s({baseWsUrl:"wss://backend.talktopc.com/chat/websocket",appId:n.appId||r.appId,agentId:n.agentId||r.agentId,conversationId:void 0!==n.conversationId?n.conversationId:e.getPersistedConversationId(),forceConversationId:n.forceConversationId,queue:[],inFlight:!1},n),e.fullResponseBuffer="",e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&g(e,t)}(t,e),n=t,i=[{key:"readScriptTagConfig",value:function(){try{var e=Array.from(document.getElementsByTagName("script")).reverse().find(function(e){return 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{}}}},{key:"buildWebSocketUrl",value:function(){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())}},{key:"sendMessage",value:(c=r().m(function e(t){var n=this;return r().w(function(e){for(;;)if(0===e.n)return e.a(2,new Promise(function(e,o){if(t&&t.trim())if(n.config.appId&&n.config.agentId){var r={text:t,resolve:e,reject:o};n.config.inFlight?n.config.queue.push(r):n.executeTask(r)}else o(new Error("Missing appId or agentId"));else o(new Error("Message is empty"))}))},e)}),l=function(){var e=this,t=arguments;return new Promise(function(n,o){var r=c.apply(e,t);function i(e){a(r,n,o,i,s,"next",e)}function s(e){a(r,n,o,i,s,"throw",e)}i(void 0)})},function(e){return l.apply(this,arguments)})},{key:"executeTask",value:function(e){var t=this;if(this.config.inFlight=!0,this.fullResponseBuffer="",!this.config.conversationId){var n=this.getPersistedConversationId();n&&(this.config.conversationId=n,console.log("🔍 TextChatSDK hydrated conversationId from storage:",n))}var o,r=this.buildWebSocketUrl(this.config.baseWsUrl),i=this.config.baseWsUrl.endsWith("/websocket")?this.config.baseWsUrl.replace(/\/websocket$/,""):"".concat(this.config.baseWsUrl,"/websocket"),a=this.buildWebSocketUrl(i),c=!1,s=!1,l=null,u=function(n){if(!s)try{var o={message:e.text},r=t.config.forceConversationId||t.config.conversationId;r&&(o.conversationId=r,t.config.forceConversationId&&!t.config.conversationId&&(t.config.conversationId=r,t.persistConversationId(r))),console.log("🔍 TextChatSDK sending payload:",o,"conversationId in config:",t.config.conversationId),n.send(JSON.stringify(o)),s=!0}catch(o){e.reject(o),t.emit("error",o);try{n.close()}catch(e){}}},d=function(e){return function(){t.config.conversationId?u(e):l=setTimeout(function(){return u(e)},200)}},f=function(n){return function(o){try{try{console.log("🔎 [TextChatSDK] WS <= raw:",o.data)}catch(e){}var r=JSON.parse(o.data);try{console.log("🔎 [TextChatSDK] WS <= parsed:",r)}catch(e){}if("hello"===r.type&&r.conversationId){if(console.log("🔍 TextChatSDK received conversationId:",r.conversationId),t.config.conversationId=r.conversationId,t.persistConversationId(r.conversationId),t.emit&&t.emit("conversationIdChanged",r.conversationId),!s&&n&&1===n.readyState){if(l)try{clearTimeout(l)}catch(e){}u(n)}return}if(!t.config.conversationId&&r.conversationId&&(console.log("🔍 TextChatSDK captured conversationId from message:",r.conversationId),t.config.conversationId=r.conversationId,t.persistConversationId(r.conversationId)),"chunk"===r.type&&"string"==typeof r.content)t.fullResponseBuffer+=r.content,t.emit("chunk",r.content);else if("done"===r.type){try{var i=r.text||r.content||r.answer||r.message||"";i&&!t.fullResponseBuffer&&(t.fullResponseBuffer=i)}catch(e){}!t.config.conversationId&&r.conversationId&&(console.log("🔍 TextChatSDK captured conversationId from done:",r.conversationId),t.config.conversationId=r.conversationId),t.persistConversationId(t.config.conversationId),t.emit("done",{text:t.fullResponseBuffer}),e.resolve({conversationId:t.config.conversationId,fullText:t.fullResponseBuffer});try{n.close()}catch(e){}}else if("error"===r.type){var a=new Error(r.message||"Server error");t.emit("error",a),e.reject(a);try{n.close()}catch(e){}}}catch(e){}}},p=function(){t.config.inFlight=!1,t.drainQueue()},g=new WebSocket(r);g.onopen=d(g),g.onmessage=f(g),g.onerror=(o=g,function(n){if(!c){c=!0;try{o.close()}catch(e){}var r=new WebSocket(a);return r.onopen=d(r),r.onmessage=f(r),r.onerror=function(n){t.emit("error",n),e.reject(n)},void(r.onclose=p)}t.emit("error",n),e.reject(n)}),g.onclose=p}},{key:"drainQueue",value:function(){if(0!==this.config.queue.length&&!this.config.inFlight){var e=this.config.queue.shift();this.executeTask(e)}}},{key:"persistConversationId",value:function(e){try{e&&localStorage.setItem("ttp_text_chat_conversation_id",e)}catch(e){}}},{key:"getPersistedConversationId",value:function(){try{return localStorage.getItem("ttp_text_chat_conversation_id")||null}catch(e){return null}}},{key:"updateConfig",value:function(e){this.config=s(s({},this.config),e)}},{key:"destroy",value:function(){this.config.queue=[],this.config.inFlight=!1,this.removeAllListeners()}}],i&&u(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,i,c,l}(n("./src/core/EventEmitter.js").default)},"./src/core/VoiceSDK.js":(e,t,n)=>{n.r(t),n.d(t,{default:()=>w});var o=n("./src/core/EventEmitter.js"),r=n("./src/core/WebSocketManager.js"),i=n("./src/core/AudioRecorder.js"),a=n("./src/core/AudioPlayer.js");function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function s(){var e,t,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function i(n,o,r,i){var s=o&&o.prototype instanceof c?o:c,u=Object.create(s.prototype);return l(u,"_invoke",function(n,o,r){var i,c,s,l=0,u=r||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,c=0,s=e,f.n=n,a}};function p(n,o){for(c=n,s=o,t=0;!d&&l&&!r&&t<u.length;t++){var r,i=u[t],p=f.p,g=i[2];n>3?(r=g===o)&&(s=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=p&&((r=n<2&&p<i[1])?(c=0,f.v=o,f.n=i[1]):p<g&&(r=n<3||i[0]>o||o>g)&&(i[4]=n,i[5]=o,f.n=g,c=0))}if(r||n>1)return a;throw d=!0,o}return function(r,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&p(u,g),c=u,s=g;(t=c<2?e:s)||!d;){i||(c?c<3?(c>1&&(f.n=-1),p(c,s)):f.n=s:f.v=s);try{if(l=2,i){if(c||(r="next"),t=i[r]){if(!(t=t.call(i,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(s=TypeError("The iterator does not provide a '"+r+"' method"),c=1);i=e}else if((t=(d=f.n<0)?s:n.call(o,f))!==a)break}catch(t){i=e,c=1,s=t}finally{l=1}}return{value:t,done:d}}}(n,r,i),!0),u}var a={};function c(){}function u(){}function d(){}t=Object.getPrototypeOf;var f=[][o]?t(t([][o]())):(l(t={},o,function(){return this}),t),p=d.prototype=c.prototype=Object.create(f);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,l(e,r,"GeneratorFunction")),e.prototype=Object.create(p),e}return u.prototype=d,l(p,"constructor",d),l(d,"constructor",u),u.displayName="GeneratorFunction",l(d,r,"GeneratorFunction"),l(p),l(p,r,"Generator"),l(p,o,function(){return this}),l(p,"toString",function(){return"[object Generator]"}),(s=function(){return{w:i,m:g}})()}function l(e,t,n,o){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}l=function(e,t,n,o){function i(t,n){l(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},l(e,t,n,o)}function u(e,t,n,o,r,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(o,r)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var i=e.apply(t,n);function a(e){u(i,o,r,a,c,"next",e)}function c(e){u(i,o,r,a,c,"throw",e)}a(void 0)})}}function f(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 p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f(Object(n),!0).forEach(function(t){g(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function g(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,h(o.key),o)}}function h(e){var t=function(e){if("object"!=c(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=c(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==c(t)?t:t+""}function y(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(y=function(){return!!e})()}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}function m(e,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m(e,t)}var w=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(e=function(e,t,n){return t=b(t),function(e,t){if(t&&("object"==c(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,y()?Reflect.construct(t,n||[],b(e).constructor):t.apply(e,n))}(this,t)).config=p({websocketUrl:n.websocketUrl||"wss://speech.talktopc.com/ws/conv",agentId:n.agentId,appId:n.appId,ttpId:n.ttpId,voice:n.voice||"default",language:n.language||"en",sampleRate:n.sampleRate||16e3},n),e.isConnected=!1,e.isRecording=!1,e.isPlaying=!1,e.isDestroyed=!1,e.webSocketManager=new r.default(p(p({},e.config),{},{autoReconnect:!1!==e.config.autoReconnect})),e.audioRecorder=new i.default(e.config),e.audioPlayer=new a.default(e.config),e.setupEventHandlers(),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&m(e,t)}(t,e),n=t,o=[{key:"setupEventHandlers",value:function(){var e=this;this.webSocketManager.on("connected",function(){e.isConnected=!0,e.sendHelloMessage(),e.emit("connected")}),this.webSocketManager.on("disconnected",function(t){e.isConnected=!1,e.isRecording&&e.stopRecording().catch(function(e){console.error("VoiceSDK: Error stopping recording on disconnect:",e)}),e.emit("disconnected",t)}),this.webSocketManager.on("error",function(t){e.emit("error",t)}),this.webSocketManager.on("message",function(t){if("greeting_audio"===t.t&&t.data)try{for(var n=atob(t.data),o=new Uint8Array(n.length),r=0;r<n.length;r++)o[r]=n.charCodeAt(r);e.audioPlayer.playAudio(o),e.emit("greetingStarted")}catch(e){console.error("VoiceSDK: Error playing greeting audio:",e)}else e.emit("message",t)}),this.webSocketManager.on("binaryAudio",function(t){e.audioPlayer.playAudio(t)}),this.webSocketManager.on("bargeIn",function(t){e.emit("bargeIn",t)}),this.webSocketManager.on("stopPlaying",function(t){e.emit("stopPlaying",t),e.audioPlayer.stopImmediate()}),this.audioRecorder.on("recordingStarted",function(){e.isRecording=!0,e.isPlaying&&(e.audioPlayer.stopImmediate(),e.isConnected&&e.webSocketManager.sendMessage({t:"barge_in"})),e.emit("recordingStarted")}),this.audioRecorder.on("recordingStopped",function(){e.isRecording=!1,e.emit("recordingStopped")}),this.audioRecorder.on("audioData",function(t){e.isConnected&&e.webSocketManager.sendBinary(t)}),this.audioPlayer.on("playbackStarted",function(){e.isPlaying=!0,e.emit("playbackStarted"),e.isConnected&&e.webSocketManager.sendMessage({t:"audio_started_playing"})}),this.audioPlayer.on("playbackStopped",function(){e.isPlaying=!1,e.emit("playbackStopped"),e.isConnected&&e.webSocketManager.sendMessage({t:"audio_stopped_playing"})}),this.audioPlayer.on("playbackError",function(t){e.emit("playbackError",t)})}},{key:"connect",value:(w=d(s().m(function e(){var t,n;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!this.isDestroyed){e.n=1;break}return console.warn("VoiceSDK: Cannot connect - SDK is destroyed"),e.a(2,!1);case 1:return e.p=1,t=this.buildWebSocketUrl(),this.webSocketManager.config.websocketUrl=t,e.n=2,this.webSocketManager.connect();case 2:return e.a(2,!0);case 3:return e.p=3,n=e.v,console.error("🔌 VoiceSDK: Connection failed with error:",n),this.emit("error",n),e.a(2,!1)}},e,this,[[1,3]])})),function(){return w.apply(this,arguments)})},{key:"buildWebSocketUrl",value:function(){var e=this.config.websocketUrl,t=new URLSearchParams;if(this.config.agentId&&t.append("agentId",this.config.agentId),this.config.appId&&t.append("appId",this.config.appId),this.config.voice&&"default"!==this.config.voice&&t.append("voice",this.config.voice),this.config.language&&"en"!==this.config.language&&t.append("language",this.config.language),t.toString()){var n=e.includes("?")?"&":"?";e+=n+t.toString()}return e}},{key:"disconnect",value:function(){this.isDestroyed||(this.stopRecording(),this.webSocketManager.disconnect())}},{key:"resetReconnectionAttempts",value:function(){this.isDestroyed||this.webSocketManager.resetReconnectionAttempts()}},{key:"reconnect",value:(h=d(s().m(function e(){return s().w(function(e){for(;;)switch(e.n){case 0:if(!this.isDestroyed){e.n=1;break}return e.a(2,!1);case 1:return this.disconnect(),this.resetReconnectionAttempts(),e.n=2,this.connect();case 2:return e.a(2,e.v)}},e,this)})),function(){return h.apply(this,arguments)})},{key:"startRecording",value:(g=d(s().m(function e(){var t;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.isConnected){e.n=1;break}throw new Error("Not connected to voice server");case 1:return e.p=1,this.webSocketManager.sendMessage({t:"start_continuous_mode",ttpId:this.generateTtpId(),voice:this.config.voice,language:this.config.language}),e.n=2,this.audioRecorder.start();case 2:return e.a(2,!0);case 3:return e.p=3,t=e.v,console.error("❌ VoiceSDK: Failed to start recording:",t),this.emit("error",t),e.a(2,!1)}},e,this,[[1,3]])})),function(){return g.apply(this,arguments)})},{key:"stopRecording",value:(f=d(s().m(function e(){var t;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.isRecording){e.n=1;break}return e.a(2);case 1:return e.p=1,this.webSocketManager.sendMessage({t:"stop_continuous_mode",ttpId:this.generateTtpId()}),e.n=2,this.audioRecorder.stop();case 2:return this.audioPlayer.stopImmediate(),e.a(2,!0);case 3:return e.p=3,t=e.v,this.emit("error",t),e.a(2,!1)}},e,this,[[1,3]])})),function(){return f.apply(this,arguments)})},{key:"toggleRecording",value:(u=d(s().m(function e(){return s().w(function(e){for(;;)switch(e.n){case 0:if(!this.isRecording){e.n=2;break}return e.n=1,this.stopRecording();case 1:case 3:return e.a(2,e.v);case 2:return e.n=3,this.startRecording();case 4:return e.a(2)}},e,this)})),function(){return u.apply(this,arguments)})},{key:"stopAudioPlayback",value:function(){this.audioPlayer.stopImmediate()}},{key:"handleBargeIn",value:(l=d(s().m(function e(){return s().w(function(e){for(;;)switch(e.n){case 0:if(this.stopAudioPlayback(),this.isRecording){e.n=1;break}return e.n=1,this.startRecording();case 1:return e.a(2)}},e,this)})),function(){return l.apply(this,arguments)})},{key:"getStatus",value:function(){return{isConnected:this.isConnected,isRecording:this.isRecording,isPlaying:this.isPlaying}}},{key:"updateConfig",value:function(e){this.config=p(p({},this.config),e)}},{key:"generateTtpId",value:function(){return"sdk_"+Math.random().toString(36).substr(2,9)+"_"+Date.now()}},{key:"sendHelloMessage",value:function(){if(this.isConnected){var e={t:"hello"};this.config.appId?e.appId=this.config.appId:this.config.ttpId?e.ttpId=this.config.ttpId:e.ttpId=this.generateTtpId();try{this.webSocketManager.sendMessage(e)}catch(e){console.error("VoiceSDK: Failed to send hello message:",e),this.emit("error",e)}}else console.warn("VoiceSDK: Cannot send hello message - not connected")}},{key:"destroy",value:function(){this.isDestroyed||(this.disconnect(),this.isDestroyed=!0,this.audioRecorder.destroy(),this.audioPlayer.destroy(),this.removeAllListeners())}}],o&&v(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,o,l,u,f,g,h,w}(o.default)},"./src/core/WebSocketManager.js":(e,t,n)=>{n.r(t),n.d(t,{default:()=>g});var o=n("./src/core/EventEmitter.js"),r=n("./src/core/WebSocketSingleton.js");function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function a(){var e,t,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function i(n,o,r,i){var a=o&&o.prototype instanceof l?o:l,u=Object.create(a.prototype);return c(u,"_invoke",function(n,o,r){var i,a,c,l=0,u=r||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,a=0,c=e,f.n=n,s}};function p(n,o){for(a=n,c=o,t=0;!d&&l&&!r&&t<u.length;t++){var r,i=u[t],p=f.p,g=i[2];n>3?(r=g===o)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=p&&((r=n<2&&p<i[1])?(a=0,f.v=o,f.n=i[1]):p<g&&(r=n<3||i[0]>o||o>g)&&(i[4]=n,i[5]=o,f.n=g,a=0))}if(r||n>1)return s;throw d=!0,o}return function(r,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&p(u,g),a=u,c=g;(t=a<2?e:c)||!d;){i||(a?a<3?(a>1&&(f.n=-1),p(a,c)):f.n=c:f.v=c);try{if(l=2,i){if(a||(r="next"),t=i[r]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),a=1);i=e}else if((t=(d=f.n<0)?c:n.call(o,f))!==s)break}catch(t){i=e,a=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,r,i),!0),u}var s={};function l(){}function u(){}function d(){}t=Object.getPrototypeOf;var f=[][o]?t(t([][o]())):(c(t={},o,function(){return this}),t),p=d.prototype=l.prototype=Object.create(f);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,c(e,r,"GeneratorFunction")),e.prototype=Object.create(p),e}return u.prototype=d,c(p,"constructor",d),c(d,"constructor",u),u.displayName="GeneratorFunction",c(d,r,"GeneratorFunction"),c(p),c(p,r,"Generator"),c(p,o,function(){return this}),c(p,"toString",function(){return"[object Generator]"}),(a=function(){return{w:i,m:g}})()}function c(e,t,n,o){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}c=function(e,t,n,o){function i(t,n){c(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},c(e,t,n,o)}function s(e,t,n,o,r,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(o,r)}function l(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,u(o.key),o)}}function u(e){var t=function(e){if("object"!=i(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==i(t)?t:t+""}function d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(d=function(){return!!e})()}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}function p(e,t){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},p(e,t)}var g=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=function(e,t,n){return t=f(t),function(e,t){if(t&&("object"==i(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,d()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}(this,t)).config=e,n.ws=null,n.isConnected=!1,n.connectionId=null,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}(t,e),n=t,o=[{key:"connect",value:(u=a().m(function e(){var t=this;return a().w(function(e){for(;;)if(0===e.n)return e.a(2,new Promise(function(e,n){try{t.connectionId=Date.now()+"_"+Math.random().toString(36).substr(2,9),t.connectResolve=e,t.connectReject=n,r.default.getConnection(t.config.websocketUrl,t.config).then(function(n){t.ws=n,t.setupEventListeners(),n.readyState===WebSocket.OPEN&&(t.isConnected=!0,t.emit("connected"),e(),t.connectResolve=null,t.connectReject=null)}).catch(function(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}}))},e)}),g=function(){var e=this,t=arguments;return new Promise(function(n,o){var r=u.apply(e,t);function i(e){s(r,n,o,i,a,"next",e)}function a(e){s(r,n,o,i,a,"throw",e)}i(void 0)})},function(){return g.apply(this,arguments)})},{key:"setupEventListeners",value:function(){var e=this;if(this.ws){var t=function(t,n){n===e.config.websocketUrl&&(e.isConnected=!0,e.emit("connected"),e.connectResolve&&(e.connectResolve(),e.connectResolve=null,e.connectReject=null))},n=function(t,n){n===e.config.websocketUrl&&(e.isConnected=!1,e.emit("disconnected",t))},o=function(t,n){n===e.config.websocketUrl&&(e.emit("error",t),e.connectReject&&(e.connectReject(t),e.connectResolve=null,e.connectReject=null))},i=function(t,n){n===e.config.websocketUrl&&e.handleMessage(t)};r.default.on("open",t),r.default.on("close",n),r.default.on("error",o),r.default.on("message",i),this.eventHandlers={open:t,close:n,error:o,message:i}}}},{key:"disconnect",value:function(){this.eventHandlers&&(r.default.off("open",this.eventHandlers.open),r.default.off("close",this.eventHandlers.close),r.default.off("error",this.eventHandlers.error),r.default.off("message",this.eventHandlers.message)),this.config.websocketUrl&&r.default.releaseConnection(this.config.websocketUrl),this.ws=null,this.isConnected=!1}},{key:"sendMessage",value:function(e){if(this.isConnected&&this.ws)try{this.ws.send(JSON.stringify(e))}catch(e){console.warn("🔌 WebSocketManager: Failed to send message:",e.message)}}},{key:"sendBinary",value:function(e){if(this.isConnected&&this.ws)try{this.ws.send(e)}catch(e){console.warn("🔌 WebSocketManager: Failed to send binary data:",e.message)}}},{key:"handleMessage",value:function(e){var t=this;if(e.data instanceof ArrayBuffer)this.emit("binaryAudio",e.data);else if(e.data instanceof Blob)e.data.arrayBuffer().then(function(e){t.emit("binaryAudio",e)}).catch(function(e){console.error("🔌 WebSocketManager: Error converting Blob to ArrayBuffer:",e)});else try{var n=JSON.parse(e.data);"barge_in_ack"!==n.t&&"stop_sending"!==n.t||this.emit("bargeIn",n),"stop_playing"===n.t&&this.emit("stopPlaying",n),this.emit("message",n)}catch(e){this.emit("error",e)}}},{key:"getStatus",value:function(){return{isConnected:this.isConnected,readyState:this.ws?this.ws.readyState:null,connectionId:this.connectionId}}}],c=[{key:"getSingletonStatus",value:function(){return r.default.getAllConnections()}},{key:"clearAllConnections",value:function(){r.default.clearAll()}}],o&&l(n.prototype,o),c&&l(n,c),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,o,c,u,g}(o.default)},"./src/core/WebSocketSingleton.js":(e,t,n)=>{function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,r,i,a,c=[],s=!0,l=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(o=i.call(n)).done)&&(c.push(o.value),c.length!==t);s=!0);}catch(e){l=!0,r=e}finally{try{if(!s&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw r}}return c}}(e,t)||a(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=a(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,r=function(){};return{s:r,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,c=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return c=e.done,e},e:function(e){s=!0,i=e},f:function(){try{c||null==n.return||n.return()}finally{if(s)throw i}}}}function a(e,t){if(e){if("string"==typeof e)return c(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function s(){var e,t,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function i(n,o,r,i){var s=o&&o.prototype instanceof c?o:c,u=Object.create(s.prototype);return l(u,"_invoke",function(n,o,r){var i,c,s,l=0,u=r||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,c=0,s=e,f.n=n,a}};function p(n,o){for(c=n,s=o,t=0;!d&&l&&!r&&t<u.length;t++){var r,i=u[t],p=f.p,g=i[2];n>3?(r=g===o)&&(s=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=p&&((r=n<2&&p<i[1])?(c=0,f.v=o,f.n=i[1]):p<g&&(r=n<3||i[0]>o||o>g)&&(i[4]=n,i[5]=o,f.n=g,c=0))}if(r||n>1)return a;throw d=!0,o}return function(r,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&p(u,g),c=u,s=g;(t=c<2?e:s)||!d;){i||(c?c<3?(c>1&&(f.n=-1),p(c,s)):f.n=s:f.v=s);try{if(l=2,i){if(c||(r="next"),t=i[r]){if(!(t=t.call(i,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(s=TypeError("The iterator does not provide a '"+r+"' method"),c=1);i=e}else if((t=(d=f.n<0)?s:n.call(o,f))!==a)break}catch(t){i=e,c=1,s=t}finally{l=1}}return{value:t,done:d}}}(n,r,i),!0),u}var a={};function c(){}function u(){}function d(){}t=Object.getPrototypeOf;var f=[][o]?t(t([][o]())):(l(t={},o,function(){return this}),t),p=d.prototype=c.prototype=Object.create(f);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,l(e,r,"GeneratorFunction")),e.prototype=Object.create(p),e}return u.prototype=d,l(p,"constructor",d),l(d,"constructor",u),u.displayName="GeneratorFunction",l(d,r,"GeneratorFunction"),l(p),l(p,r,"Generator"),l(p,o,function(){return this}),l(p,"toString",function(){return"[object Generator]"}),(s=function(){return{w:i,m:g}})()}function l(e,t,n,o){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}l=function(e,t,n,o){function i(t,n){l(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},l(e,t,n,o)}function u(e,t,n,o,r,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(o,r)}function d(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,f(o.key),o)}}function f(e){var t=function(e){if("object"!=o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==o(t)?t:t+""}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(p=function(){return!!e})()}function g(e){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},g(e)}function v(e,t){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},v(e,t)}n.r(t),n.d(t,{default:()=>h});const h=new(function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(e=function(e,t,n){return t=g(t),function(e,t){if(t&&("object"==o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,p()?Reflect.construct(t,n||[],g(e).constructor):t.apply(e,n))}(this,t)).connections=new Map,e.connectionCounts=new Map,e.creatingConnections=new Set,e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&v(e,t)}(t,e),n=t,a=[{key:"getConnection",value:(c=s().m(function e(t){var n,o,r=this;return s().w(function(e){for(;;)switch(e.n){case 0:if(!this.connections.has(t)){e.n=1;break}return n=this.connections.get(t),this.connectionCounts.set(t,(this.connectionCounts.get(t)||0)+1),e.a(2,n);case 1:if(!this.creatingConnections||!this.creatingConnections.has(t)){e.n=2;break}return e.a(2,new Promise(function(e){var n=function(){if(r.connections.has(t)){var o=r.connections.get(t);r.connectionCounts.set(t,(r.connectionCounts.get(t)||0)+1),e(o)}else setTimeout(n,50)};n()}));case 2:return this.creatingConnections.add(t),o=new WebSocket(t),this.connections.set(t,o),this.connectionCounts.set(t,1),o.addEventListener("open",function(e){r.creatingConnections.delete(t),r.emit("open",e,t)}),o.addEventListener("close",function(e){r.creatingConnections.delete(t),r.connections.delete(t),r.connectionCounts.delete(t),r.emit("close",e,t)}),o.addEventListener("error",function(e){r.creatingConnections.delete(t),r.emit("error",e,t)}),o.addEventListener("message",function(e){r.emit("message",e,t)}),e.a(2,o)}},e,this)}),l=function(){var e=this,t=arguments;return new Promise(function(n,o){var r=c.apply(e,t);function i(e){u(r,n,o,i,a,"next",e)}function a(e){u(r,n,o,i,a,"throw",e)}i(void 0)})},function(e){return l.apply(this,arguments)})},{key:"releaseConnection",value:function(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)}}}},{key:"forceClose",value:function(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)}}},{key:"getConnectionStatus",value:function(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}}},{key:"getAllConnections",value:function(){var e,t={},n=i(this.connections.entries());try{for(n.s();!(e=n.n()).done;){var o=r(e.value,2),a=o[0],c=o[1];t[a]={readyState:c.readyState,subscribers:this.connectionCounts.get(a)||0}}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"clearAll",value:function(){var e,t=i(this.connections.entries());try{for(t.s();!(e=t.n()).done;){var n=r(e.value,2),o=(n[0],n[1]);o&&o.readyState===WebSocket.OPEN&&o.close(1e3,"Clear all")}}catch(e){t.e(e)}finally{t.f()}this.connections.clear(),this.connectionCounts.clear(),this.creatingConnections.clear()}}],a&&d(n.prototype,a),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,a,c,l}(n("./src/core/EventEmitter.js").default))},"./src/index.js":(e,t,n)=>{n.r(t),n.d(t,{AgentSDK:()=>d.AgentSDK,AgentWidget:()=>d.AgentWidget,AudioPlayer:()=>c.default,AudioRecorder:()=>a.default,EventEmitter:()=>s.default,TextChatSDK:()=>r.default,TextChatWidget:()=>f.TextChatWidget,VERSION:()=>p,VanillaVoiceButton:()=>u.default,VoiceButton:()=>l.default,VoiceSDK:()=>o.default,WebSocketManager:()=>i.default,default:()=>g});var o=n("./src/core/VoiceSDK.js"),r=n("./src/core/TextChatSDK.js"),i=n("./src/core/WebSocketManager.js"),a=n("./src/core/AudioRecorder.js"),c=n("./src/core/AudioPlayer.js"),s=n("./src/core/EventEmitter.js"),l=n("./src/react/VoiceButton.jsx"),u=n("./src/vanilla/VoiceButton.js"),d=n("./src/legacy/AgentSDK.js"),f=n("./src/legacy/TextChatWidget.js"),p="2.0.0";const g={VoiceSDK:o.default,TextChatSDK:r.default,WebSocketManager:i.default,AudioRecorder:a.default,AudioPlayer:c.default,EventEmitter:s.default,VoiceButton:l.default,VanillaVoiceButton:u.default,AgentSDK:d.AgentSDK,AgentWidget:d.AgentWidget,TextChatWidget:f.TextChatWidget,VERSION:p}},"./src/legacy/AgentSDK.js":(e,t,n)=>{n.r(t),n.d(t,{AgentSDK:()=>h,AgentWidget:()=>y});var o=n("./src/index.js");function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function i(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 a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach(function(t){c(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function c(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(){var e,t,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function i(n,o,r,i){var s=o&&o.prototype instanceof c?o:c,u=Object.create(s.prototype);return l(u,"_invoke",function(n,o,r){var i,c,s,l=0,u=r||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,c=0,s=e,f.n=n,a}};function p(n,o){for(c=n,s=o,t=0;!d&&l&&!r&&t<u.length;t++){var r,i=u[t],p=f.p,g=i[2];n>3?(r=g===o)&&(s=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=p&&((r=n<2&&p<i[1])?(c=0,f.v=o,f.n=i[1]):p<g&&(r=n<3||i[0]>o||o>g)&&(i[4]=n,i[5]=o,f.n=g,c=0))}if(r||n>1)return a;throw d=!0,o}return function(r,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&p(u,g),c=u,s=g;(t=c<2?e:s)||!d;){i||(c?c<3?(c>1&&(f.n=-1),p(c,s)):f.n=s:f.v=s);try{if(l=2,i){if(c||(r="next"),t=i[r]){if(!(t=t.call(i,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(s=TypeError("The iterator does not provide a '"+r+"' method"),c=1);i=e}else if((t=(d=f.n<0)?s:n.call(o,f))!==a)break}catch(t){i=e,c=1,s=t}finally{l=1}}return{value:t,done:d}}}(n,r,i),!0),u}var a={};function c(){}function u(){}function d(){}t=Object.getPrototypeOf;var f=[][o]?t(t([][o]())):(l(t={},o,function(){return this}),t),p=d.prototype=c.prototype=Object.create(f);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,l(e,r,"GeneratorFunction")),e.prototype=Object.create(p),e}return u.prototype=d,l(p,"constructor",d),l(d,"constructor",u),u.displayName="GeneratorFunction",l(d,r,"GeneratorFunction"),l(p),l(p,r,"Generator"),l(p,o,function(){return this}),l(p,"toString",function(){return"[object Generator]"}),(s=function(){return{w:i,m:g}})()}function l(e,t,n,o){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}l=function(e,t,n,o){function i(t,n){l(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},l(e,t,n,o)}function u(e,t,n,o,r,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(o,r)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var i=e.apply(t,n);function a(e){u(i,o,r,a,c,"next",e)}function c(e){u(i,o,r,a,c,"throw",e)}a(void 0)})}}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,v(o.key),o)}}function g(e,t,n){return t&&p(e.prototype,t),n&&p(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function v(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}var h=function(){return g(function e(t){f(this,e),console.log("🚀 AgentSDK v2.1.8 initialized with config:",t),this.config=t,this.voiceSDK=null,this.isConnected=!1,this.isListening=!1,this.onConnected=function(){},this.onDisconnected=function(){},this.onError=function(e){return console.error("SDK Error:",e)},this.onTranscript=function(e){},this.onAgentSpeaking=function(e){}},[{key:"connect",value:(t=d(s().m(function e(t){var n,r=this;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,t){e.n=1;break}throw new Error("signedUrl is required");case 1:return this.voiceSDK&&(console.log("🔌 AgentSDK: Cleaning up existing connection"),this.voiceSDK.destroy(),this.voiceSDK=null),this.voiceSDK=new o.VoiceSDK({websocketUrl:t,autoReconnect:!1,agentId:this.config.agentId,appId:this.config.appId,language:this.config.language||"en"}),this.voiceSDK.on("connected",function(){r.isConnected=!0,r.onConnected()}),this.voiceSDK.on("disconnected",function(){r.isConnected=!1,r.onDisconnected()}),this.voiceSDK.on("error",function(e){r.onError(e)}),this.voiceSDK.on("message",function(e){r.handleWebSocketMessage(e)}),this.voiceSDK.on("recordingStarted",function(){r.isListening=!0}),this.voiceSDK.on("recordingStopped",function(){r.isListening=!1}),this.voiceSDK.on("playbackStarted",function(){r.onAgentSpeaking(!0)}),this.voiceSDK.on("playbackStopped",function(){r.onAgentSpeaking(!1)}),e.n=2,this.voiceSDK.connect();case 2:e.n=4;break;case 3:throw e.p=3,n=e.v,this.onError(n),n;case 4:return e.a(2)}},e,this,[[0,3]])})),function(e){return t.apply(this,arguments)})},{key:"handleWebSocketMessage",value:function(e){switch(e.type){case"connected":console.log("Session started successfully");break;case"user_transcript":this.onTranscript(e.user_transcription||e.text);break;case"agent_response":case"barge_in":case"stop_playing":break;case"error":this.onError(new Error(e.message))}}},{key:"startListening",value:(e=d(s().m(function e(){var t;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(console.log("🎤 AgentSDK: startListening() called"),!this.voiceSDK){e.n=5;break}return e.p=1,console.log("🎤 AgentSDK: Starting recording..."),e.n=2,this.voiceSDK.startRecording();case 2:console.log("✅ AgentSDK: Recording started successfully"),e.n=4;break;case 3:throw e.p=3,t=e.v,console.error("❌ AgentSDK: Failed to start recording:",t),t;case 4:e.n=6;break;case 5:throw console.error("❌ AgentSDK: No voiceSDK instance available"),new Error("No voiceSDK instance available");case 6:return e.a(2)}},e,this,[[1,3]])})),function(){return e.apply(this,arguments)})},{key:"stopListening",value:function(){this.voiceSDK&&this.voiceSDK.stopRecording()}},{key:"updateVariables",value:function(e){this.voiceSDK&&this.isConnected&&this.voiceSDK.webSocketManager.sendMessage({t:"update_variables",variables:e})}},{key:"disconnect",value:function(){this.voiceSDK&&(this.voiceSDK.destroy(),this.voiceSDK=null),this.isConnected=!1,this.isListening=!1}}]);var e,t}(),y=function(){return g(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(f(this,e),this.config=this.mergeWithDefaults(t),this.sdk=new h(this.config),this.isOpen=!1,this.isActive=!1,this.setupEventHandlers(),this.createWidget(),this.config.behavior.startOpen||this.config.behavior.autoOpen){var n=document.getElementById("agent-panel");n&&(this.isOpen=!0,n.classList.add("open"))}},[{key:"mergeWithDefaults",value:function(e){var t,n,o,i,c,s,l,u,d,f,p,g,v,h,y,b,m,w,k,x,S,C,j,O,E,I,T,B,P,_,F,R,A,D,M,L,z,H,U,N,K,W,V,G,$,q,Q,Y,J,X,Z,ee,te,ne,oe=e.position||"bottom-right";if("string"==typeof oe){var re=oe.split("-");oe={vertical:re[0]||"bottom",horizontal:re[1]||"right",offset:e.positionOffset||{x:20,y:20}}}var ie=e.primaryColor||(null===(t=e.button)||void 0===t?void 0:t.primaryColor)||"#4F46E5";return a({agentId:e.agentId,appId:e.appId,getSessionUrl:e.getSessionUrl,websocketUrl:e.websocketUrl,demo:!1!==e.demo,direction:e.direction||"ltr",icon:a({type:(null===(n=e.icon)||void 0===n?void 0:n.type)||"microphone",customImage:(null===(o=e.icon)||void 0===o?void 0:o.customImage)||null,emoji:(null===(i=e.icon)||void 0===i?void 0:i.emoji)||"🎤",text:(null===(c=e.icon)||void 0===c?void 0:c.text)||"AI",size:(null===(s=e.icon)||void 0===s?void 0:s.size)||"medium",backgroundColor:(null===(l=e.icon)||void 0===l?void 0:l.backgroundColor)||null},e.icon),position:a({vertical:oe.vertical||"bottom",horizontal:oe.horizontal||"right",offset:oe.offset||{x:20,y:20}},"object"===r(e.position)?e.position:{}),button:a({size:(null===(u=e.button)||void 0===u?void 0:u.size)||"medium",shape:(null===(d=e.button)||void 0===d?void 0:d.shape)||"circle",backgroundColor:(null===(f=e.button)||void 0===f?void 0:f.backgroundColor)||(null===(p=e.icon)||void 0===p?void 0:p.backgroundColor)||ie,hoverColor:(null===(g=e.button)||void 0===g?void 0:g.hoverColor)||"#7C3AED",shadow:!1!==(null===(v=e.button)||void 0===v?void 0:v.shadow),shadowColor:(null===(h=e.button)||void 0===h?void 0:h.shadowColor)||"rgba(0,0,0,0.15)",primaryColor:(null===(y=e.button)||void 0===y?void 0:y.backgroundColor)||(null===(b=e.icon)||void 0===b?void 0:b.backgroundColor)||ie},e.button),panel:a({width:(null===(m=e.panel)||void 0===m?void 0:m.width)||350,height:(null===(w=e.panel)||void 0===w?void 0:w.height)||500,borderRadius:(null===(k=e.panel)||void 0===k?void 0:k.borderRadius)||12,backgroundColor:(null===(x=e.panel)||void 0===x?void 0:x.backgroundColor)||"#FFFFFF",backdropFilter:(null===(S=e.panel)||void 0===S?void 0:S.backdropFilter)||null,border:(null===(C=e.panel)||void 0===C?void 0:C.border)||"1px solid rgba(0,0,0,0.1)",micButtonColor:(null===(j=e.panel)||void 0===j?void 0:j.micButtonColor)||ie,micButtonActiveColor:(null===(O=e.panel)||void 0===O?void 0:O.micButtonActiveColor)||"#EF4444",micButtonHint:a({text:(null===(E=e.panel)||void 0===E||null===(E=E.micButtonHint)||void 0===E?void 0:E.text)||"Click the button to start voice conversation",color:(null===(I=e.panel)||void 0===I||null===(I=I.micButtonHint)||void 0===I?void 0:I.color)||"#6B7280",fontSize:(null===(T=e.panel)||void 0===T||null===(T=T.micButtonHint)||void 0===T?void 0:T.fontSize)||"12px"},null===(B=e.panel)||void 0===B?void 0:B.micButtonHint)},e.panel),header:a({title:(null===(P=e.header)||void 0===P?void 0:P.title)||"Voice Assistant",showTitle:!1!==(null===(_=e.header)||void 0===_?void 0:_.showTitle),backgroundColor:(null===(F=e.header)||void 0===F?void 0:F.backgroundColor)||(null===(R=e.button)||void 0===R?void 0:R.backgroundColor)||ie,textColor:(null===(A=e.header)||void 0===A?void 0:A.textColor)||"#FFFFFF",showCloseButton:!1!==(null===(D=e.header)||void 0===D?void 0:D.showCloseButton)},e.header),messages:a({userBackgroundColor:(null===(M=e.messages)||void 0===M?void 0:M.userBackgroundColor)||"#E5E7EB",agentBackgroundColor:(null===(L=e.messages)||void 0===L?void 0:L.agentBackgroundColor)||"#F3F4F6",systemBackgroundColor:(null===(z=e.messages)||void 0===z?void 0:z.systemBackgroundColor)||"#DCFCE7",errorBackgroundColor:(null===(H=e.messages)||void 0===H?void 0:H.errorBackgroundColor)||"#FEE2E2",textColor:(null===(U=e.messages)||void 0===U?void 0:U.textColor)||"#1F2937",fontSize:(null===(N=e.messages)||void 0===N?void 0:N.fontSize)||"14px",borderRadius:(null===(K=e.messages)||void 0===K?void 0:K.borderRadius)||8},e.messages),animation:a({enableHover:!1!==(null===(W=e.animation)||void 0===W?void 0:W.enableHover),enablePulse:!1!==(null===(V=e.animation)||void 0===V?void 0:V.enablePulse),enableSlide:!1!==(null===(G=e.animation)||void 0===G?void 0:G.enableSlide),duration:(null===($=e.animation)||void 0===$?void 0:$.duration)||.3},e.animation),behavior:a({autoOpen:(null===(q=e.behavior)||void 0===q?void 0:q.autoOpen)||!1,startOpen:(null===(Q=e.behavior)||void 0===Q?void 0:Q.startOpen)||!1,hidden:(null===(Y=e.behavior)||void 0===Y?void 0:Y.hidden)||!1,autoConnect:(null===(J=e.behavior)||void 0===J?void 0:J.autoConnect)||!1,showWelcomeMessage:!1!==(null===(X=e.behavior)||void 0===X?void 0:X.showWelcomeMessage),welcomeMessage:(null===(Z=e.behavior)||void 0===Z?void 0:Z.welcomeMessage)||"Hello! How can I help you today?"},e.behavior),accessibility:a({ariaLabel:(null===(ee=e.accessibility)||void 0===ee?void 0:ee.ariaLabel)||"Voice Assistant",ariaDescription:(null===(te=e.accessibility)||void 0===te?void 0:te.ariaDescription)||"Click to open voice assistant",keyboardNavigation:!1!==(null===(ne=e.accessibility)||void 0===ne?void 0:ne.keyboardNavigation)},e.accessibility),customStyles:e.customStyles||"",variables:e.variables||{},primaryColor:ie},"string"==typeof e.position?{positionString:e.position}:{})}},{key:"setupEventHandlers",value:function(){var e=this;this.sdk.onConnected=function(){e.updateStatus("connected"),e.config.behavior.showWelcomeMessage&&e.addMessage("system",e.config.behavior.welcomeMessage)},this.sdk.onDisconnected=function(){e.updateStatus("disconnected"),e.isActive=!1,e.updateMicButtonState(!1),e.showError("Conversation ended. Click to start a new conversation.")},this.sdk.onError=function(t){e.showError(t.message)},this.sdk.onTranscript=function(t){e.addMessage("user",t)},this.sdk.onAgentSpeaking=function(t){t?e.showAgentThinking():e.hideAgentThinking()}}},{key:"createWidget",value:function(){var e=document.createElement("div");if(e.id="agent-widget",e.innerHTML=this.generateWidgetHTML(),document.body.appendChild(e),this.setupWidgetEvents(),this.config.behavior.startOpen||this.config.behavior.autoOpen){var t=document.getElementById("agent-panel");t&&(this.isOpen=!0,t.classList.add("open"))}}},{key:"generateWidgetHTML",value:function(){this.config.position;var e=this.config.button,t=this.config.icon,n=this.config.panel,o=this.config.header,r=(this.config.animation,{small:50,medium:60,large:70,xl:80}[e.size]||60),i={small:20,medium:28,large:36,xl:44}[t.size]||28,a=this.generatePositionStyles(),c=this.generateIconHTML(i);return"\n <style>\n ".concat(this.generateCSS(a,r,i),"\n ").concat(this.config.customStyles,"\n </style>\n \n ").concat(this.config.behavior.hidden?"":'\n <button id="agent-button" \n aria-label="'.concat(this.config.accessibility.ariaLabel,'"\n aria-description="').concat(this.config.accessibility.ariaDescription,'">\n ').concat(c,"\n </button>\n "),'\n \n <div id="agent-panel">\n ').concat(o.showTitle?'\n <div id="agent-header" style="direction: '.concat(this.config.direction,';">\n ').concat("rtl"===this.config.direction?"\n ".concat(o.showCloseButton?'<button id="agent-close">&times;</button>':"",'\n <h3 style="margin: 0; color: ').concat(o.textColor,';">').concat(o.title,"</h3>\n "):'\n <h3 style="margin: 0; color: '.concat(o.textColor,';">').concat(o.title,"</h3>\n ").concat(o.showCloseButton?'<button id="agent-close">&times;</button>':"","\n "),"\n </div>\n "):"",'\n \n <div id="agent-messages"></div>\n \n <div id="agent-controls">\n <div style="display: flex; flex-direction: column; align-items: center; gap: 8px;">\n <button id="agent-mic-button" \n aria-label="Start/Stop Voice Recording">\n ').concat(c,"\n </button>\n ").concat(n.micButtonHint.text&&n.micButtonHint.text.trim()?'\n <div id="agent-mic-hint" style="color: '.concat(n.micButtonHint.color,"; font-size: ").concat(n.micButtonHint.fontSize,'; text-align: center; max-width: 200px;">\n ').concat(n.micButtonHint.text,"\n </div>\n "):"","\n </div>\n </div>\n </div>\n ")}},{key:"generatePositionStyles",value:function(){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}},{key:"generateIconHTML",value:function(e){var t=this.config.icon;switch(t.type){case"custom":return'<img src="'.concat(t.customImage,'" alt="Voice 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>");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>')}}},{key:"generateCSS",value:function(e,t,n){var o=this.config.button,r=this.config.panel,i=this.config.header,a=this.config.messages,c=this.config.animation,s=o.backgroundColor||o.primaryColor,l=i.backgroundColor,u=r.micButtonColor||o.primaryColor,d=r.micButtonActiveColor||"#EF4444";return"\n #agent-widget {\n position: fixed;\n ".concat(e,'\n z-index: 10000;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n -webkit-transform: translateZ(0);\n transform: translateZ(0);\n will-change: transform;\n }\n \n #agent-button {\n width: ').concat(t,"px;\n height: ").concat(t,"px;\n border-radius: ").concat("circle"===o.shape?"50%":"square"===o.shape?"0":"12px",";\n background: ").concat(s,";\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all ").concat(c.duration,"s ease;\n ").concat(o.shadow?"box-shadow: 0 4px 12px ".concat(o.shadowColor,";"):"","\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 }\n \n @media (max-width: 768px) {\n #agent-button {\n min-width: 56px;\n min-height: 56px;\n }\n }\n \n ").concat(c.enableHover?"\n #agent-button:hover {\n background: ".concat(o.hoverColor,";\n transform: scale(1.05);\n ").concat(o.shadow?"box-shadow: 0 8px 20px ".concat(o.shadowColor,";"):"","\n }\n "):"","\n \n #agent-panel {\n display: none;\n position: absolute;\n bottom: ").concat(this.config.behavior.hidden?20:t+20,"px;\n ").concat("right"===this.config.position.horizontal?"right: 0;":"left: 0;","\n width: ").concat(r.width,"px;\n height: ").concat(r.height,"px;\n background: ").concat(r.backgroundColor,";\n border-radius: ").concat(r.borderRadius,"px;\n border: ").concat(r.border,";\n flex-direction: column;\n overflow: hidden;\n ").concat(r.backdropFilter?"backdrop-filter: ".concat(r.backdropFilter,";"):"","\n ").concat(c.enableSlide?"transition: all ".concat(c.duration,"s ease;"):"","\n }\n \n #agent-panel.open {\n display: flex;\n ").concat(c.enableSlide?"transform: translateY(0); opacity: 1;":"","\n }\n \n #agent-header {\n background: ").concat(l,";\n color: ").concat(i.textColor,";\n padding: 16px;\n display: flex;\n flex-direction: ").concat("rtl"===this.config.direction?"row-reverse":"row",";\n justify-content: space-between;\n align-items: center;\n border-radius: ").concat(r.borderRadius,"px ").concat(r.borderRadius,"px 0 0;\n direction: ").concat(this.config.direction,";\n }\n \n #agent-header h3 {\n margin: 0;\n flex: 1;\n text-align: ").concat("rtl"===this.config.direction?"right":"left",";\n }\n \n #agent-close {\n background: none;\n border: none;\n color: ").concat(i.textColor,";\n cursor: pointer;\n font-size: 24px;\n padding: 0;\n width: 24px;\n height: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n \n #agent-messages {\n flex: 1;\n overflow-y: auto;\n padding: 16px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n \n .message {\n padding: 12px;\n border-radius: ").concat(a.borderRadius,"px;\n max-width: 80%;\n font-size: ").concat(a.fontSize,";\n color: ").concat(a.textColor,";\n }\n \n .message.user {\n background: ").concat(a.userBackgroundColor,";\n align-self: flex-end;\n }\n \n .message.agent {\n background: ").concat(a.agentBackgroundColor,";\n align-self: flex-start;\n }\n \n .message.system {\n background: ").concat(a.systemBackgroundColor,";\n align-self: flex-start;\n font-style: italic;\n }\n \n .error-message {\n background: ").concat(a.errorBackgroundColor,";\n color: #991B1B;\n padding: 12px;\n border-radius: ").concat(a.borderRadius,"px;\n margin: 8px;\n }\n \n #agent-controls {\n padding: 16px;\n border-top: 1px solid #E5E7EB;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n \n #agent-controls > div {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n }\n \n #agent-mic-hint {\n text-align: center;\n line-height: 1.4;\n }\n \n #agent-mic-button {\n width: ").concat(t,"px;\n height: ").concat(t,"px;\n border-radius: ").concat("circle"===o.shape?"50%":"square"===o.shape?"0":"12px",";\n border: none;\n background: ").concat(u,";\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all ").concat(c.duration,"s ease;\n }\n \n #agent-mic-button.active {\n background: ").concat(d,";\n ").concat(c.enablePulse?"\n animation: pulse 1.5s infinite;\n ":"","\n }\n \n ").concat(c.enablePulse?"\n @keyframes pulse {\n 0%, 100% { transform: scale(1); }\n 50% { transform: scale(1.05); }\n }\n ":"","\n \n .agent-thinking {\n font-style: italic;\n color: #6B7280;\n }\n ")}},{key:"setupWidgetEvents",value:function(){var e=this,t=document.getElementById("agent-button");t&&(t.onclick=function(){return e.togglePanel()});var n=document.getElementById("agent-close");n&&(n.onclick=function(){return e.togglePanel()}),document.getElementById("agent-mic-button").onclick=function(){return e.toggleVoice()},this.config.accessibility.keyboardNavigation&&this.setupKeyboardNavigation()}},{key:"setupKeyboardNavigation",value:function(){var e=this;document.addEventListener("keydown",function(t){"Escape"===t.key&&e.isOpen&&e.togglePanel()})}},{key:"togglePanel",value:function(){this.isOpen=!this.isOpen,document.getElementById("agent-panel").classList.toggle("open")}},{key:"toggleVoice",value:(t=d(s().m(function e(){var t,n,o,r;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.isActive){e.n=13;break}return e.p=1,console.log("🎤 Starting voice session..."),e.n=2,this.getSignedUrl();case 2:return t=e.v,console.log("🔗 Got signed URL:",t),e.n=3,this.sdk.connect(t);case 3:n=e.v,console.log("✅ Connected to WebSocket, connected:",n),o=0;case 4:if(this.sdk.isConnected||!(o<50)){e.n=6;break}return e.n=5,new Promise(function(e){return setTimeout(e,100)});case 5:o++,e.n=4;break;case 6:if(!this.sdk.isConnected){e.n=8;break}return console.log("✅ WebSocket ready, starting listening..."),e.n=7,this.sdk.startListening();case 7:console.log("🎤 Started listening"),this.isActive=!0,this.updateMicButtonState(!0),this.addMessage("system","🎤 Listening... Click mic to stop"),e.n=10;break;case 8:return console.warn("⚠️ Connection not fully ready, but trying to start listening anyway..."),e.n=9,this.sdk.startListening();case 9:console.log("🎤 Started listening"),this.isActive=!0,this.updateMicButtonState(!0),this.addMessage("system","🎤 Listening... Click mic to stop");case 10:e.n=12;break;case 11:e.p=11,r=e.v,console.error("❌ Failed to start:",r),this.showError(r.message);case 12:e.n=14;break;case 13:console.log("🔇 Stopping voice session..."),this.sdk.stopListening(),this.sdk.disconnect(),this.isActive=!1,this.updateMicButtonState(!1),this.addMessage("system","🔇 Stopped listening");case 14:return e.a(2)}},e,this,[[1,11]])})),function(){return t.apply(this,arguments)})},{key:"updateMicButtonState",value:function(e){var t=document.getElementById("agent-mic-button");if(t)if(this.config.icon.size,e){if(t.classList.add("active"),t.title="Click to stop listening","microphone"===this.config.icon.type||"custom"===this.config.icon.type){var n=t.querySelector("svg")||t.querySelector("img");n&&"svg"===n.tagName&&(n.innerHTML='\n <rect x="6" y="6" width="12" height="12" rx="2"/>\n <path d="M9 9h6"/>\n ')}}else if(t.classList.remove("active"),t.title="Click to start listening","microphone"===this.config.icon.type){var o=t.querySelector("svg");o&&(o.innerHTML='\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 ')}}},{key:"getSignedUrl",value:(e=d(s().m(function e(){var t,n,o,r,i,a,c;return s().w(function(e){for(;;)switch(e.n){case 0:if(this.config.getSessionUrl){e.n=2;break}if(this.config.agentId){e.n=1;break}throw new Error("agentId is required");case 1:return t=this.config.websocketUrl||"wss://speech.talktopc.com/ws/conv",(n=new URLSearchParams).append("agentId",this.config.agentId),this.config.appId&&n.append("appId",this.config.appId),!1!==this.config.demo&&n.append("demo","true"),e.a(2,"".concat(t,"?").concat(n.toString()));case 2:if("string"!=typeof this.config.getSessionUrl){e.n=6;break}return o={agentId:this.config.agentId,variables:this.config.variables||{}},this.config.appId&&(o.appId=this.config.appId),e.n=3,fetch(this.config.getSessionUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});case 3:if((r=e.v).ok){e.n=4;break}throw new Error("Failed to get session URL: ".concat(r.statusText));case 4:return e.n=5,r.json();case 5:return i=e.v,e.a(2,i.signedUrl||i.wsUrl||i.url);case 6:if("function"!=typeof this.config.getSessionUrl){e.n=8;break}return a={agentId:this.config.agentId,variables:this.config.variables||{}},this.config.appId&&(a.appId=this.config.appId),e.n=7,this.config.getSessionUrl(a);case 7:return c=e.v,e.a(2,"string"==typeof c?c:c.signedUrl||c.wsUrl||c.url);case 8:throw new Error("getSessionUrl must be a string (backend URL), a function, or omitted (for direct connection with agentId/appId)");case 9:return e.a(2)}},e,this)})),function(){return e.apply(this,arguments)})},{key:"addMessage",value:function(e,t){var n=document.getElementById("agent-messages"),o=document.createElement("div");o.className="message ".concat(e),o.textContent=t,n.appendChild(o),n.scrollTop=n.scrollHeight}},{key:"showAgentThinking",value:function(){var e=document.getElementById("agent-messages"),t=document.createElement("div");t.className="message agent agent-thinking",t.id="thinking-indicator",t.textContent="Agent is speaking...",e.appendChild(t),e.scrollTop=e.scrollHeight}},{key:"hideAgentThinking",value:function(){var e=document.getElementById("thinking-indicator");e&&e.remove()}},{key:"showError",value:function(e){var t=document.getElementById("agent-messages"),n=document.createElement("div");n.className="error-message",n.textContent=e,t.appendChild(n)}},{key:"updateStatus",value:function(e){}},{key:"updateConfig",value:function(e){var t,n=a({},this.config);e.panel&&(n.panel=a(a({},this.config.panel),e.panel),e.panel.micButtonHint&&(n.panel.micButtonHint=a(a({},null===(t=this.config.panel)||void 0===t?void 0:t.micButtonHint),e.panel.micButtonHint))),e.button&&(n.button=a(a({},this.config.button),e.button)),e.header&&(n.header=a(a({},this.config.header),e.header)),e.icon&&(n.icon=a(a({},this.config.icon),e.icon)),e.messages&&(n.messages=a(a({},this.config.messages),e.messages)),void 0!==e.direction&&(n.direction=e.direction),Object.keys(e).forEach(function(t){["panel","button","header","icon","messages","direction"].includes(t)||(n[t]=e[t])}),this.config=this.mergeWithDefaults(n);var o=document.getElementById("agent-widget");o&&o.remove(),this.createWidget()}},{key:"destroy",value:function(){var e=document.getElementById("agent-widget");e&&e.remove(),this.sdk&&this.sdk.disconnect()}}]);var e,t}()},"./src/legacy/TextChatWidget.js":(e,t,n)=>{n.r(t),n.d(t,{TextChatWidget:()=>y});var o=n("./src/core/TextChatSDK.js"),r=n("./src/legacy/VoiceInterface.js"),i=n("./src/legacy/TextInterface.js"),a=n("./src/legacy/widget-translations.js");function c(){var e,t,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function i(n,o,r,i){var c=o&&o.prototype instanceof l?o:l,u=Object.create(c.prototype);return s(u,"_invoke",function(n,o,r){var i,c,s,l=0,u=r||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,c=0,s=e,f.n=n,a}};function p(n,o){for(c=n,s=o,t=0;!d&&l&&!r&&t<u.length;t++){var r,i=u[t],p=f.p,g=i[2];n>3?(r=g===o)&&(s=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=p&&((r=n<2&&p<i[1])?(c=0,f.v=o,f.n=i[1]):p<g&&(r=n<3||i[0]>o||o>g)&&(i[4]=n,i[5]=o,f.n=g,c=0))}if(r||n>1)return a;throw d=!0,o}return function(r,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&p(u,g),c=u,s=g;(t=c<2?e:s)||!d;){i||(c?c<3?(c>1&&(f.n=-1),p(c,s)):f.n=s:f.v=s);try{if(l=2,i){if(c||(r="next"),t=i[r]){if(!(t=t.call(i,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(s=TypeError("The iterator does not provide a '"+r+"' method"),c=1);i=e}else if((t=(d=f.n<0)?s:n.call(o,f))!==a)break}catch(t){i=e,c=1,s=t}finally{l=1}}return{value:t,done:d}}}(n,r,i),!0),u}var a={};function l(){}function u(){}function d(){}t=Object.getPrototypeOf;var f=[][o]?t(t([][o]())):(s(t={},o,function(){return this}),t),p=d.prototype=l.prototype=Object.create(f);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,s(e,r,"GeneratorFunction")),e.prototype=Object.create(p),e}return u.prototype=d,s(p,"constructor",d),s(d,"constructor",u),u.displayName="GeneratorFunction",s(d,r,"GeneratorFunction"),s(p),s(p,r,"Generator"),s(p,o,function(){return this}),s(p,"toString",function(){return"[object Generator]"}),(c=function(){return{w:i,m:g}})()}function s(e,t,n,o){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}s=function(e,t,n,o){function i(t,n){s(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},s(e,t,n,o)}function l(e,t,n,o,r,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(o,r)}function u(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var i=e.apply(t,n);function a(e){l(i,o,r,a,c,"next",e)}function c(e){l(i,o,r,a,c,"throw",e)}a(void 0)})}}function d(e){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d(e)}function f(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 p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f(Object(n),!0).forEach(function(t){g(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function g(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,h(o.key),o)}}function h(e){var t=function(e){if("object"!=d(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=d(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==d(t)?t:t+""}var y=function(){return e=function e(){var t,n,c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.config=this.mergeWithDefaults(c),this.sdk=new o.default(this.config),this.isOpen=!1,this.isActive=!1,this.translations=a.default;var s=p(p(p({},this.config),this.config.voice),{},{language:(null===(t=this.config.voice)||void 0===t?void 0:t.language)||this.config.language||"en",websocketUrl:(null===(n=this.config.voice)||void 0===n?void 0:n.websocketUrl)||this.config.websocketUrl||"wss://speech.talktopc.com/ws/conv",translations:this.translations});this.voiceInterface=new r.VoiceInterface(s);var l=p(p(p({},this.config),this.config.text),{},{translations:this.translations});if(this.textInterface=new i.TextInterface(l,this.sdk),this.setupEventHandlers(),this.createWidget(),this.config.behavior.startOpen||this.config.behavior.autoOpen){var u=document.getElementById("text-chat-panel");u&&(this.isOpen=!0,u.classList.add("open"))}},t=[{key:"mergeWithDefaults",value:function(e){var t,n,o,r,i,a,c,s,l,u,f,g,v,h,y,b,m,w,k,x,S,C,j,O,E,I,T,B,P,_,F,R,A,D,M,L,z,H,U,N,K,W,V,G,$,q,Q,Y,J,X,Z,ee,te,ne,oe,re,ie,ae,ce,se,le,ue,de,fe,pe,ge,ve,he,ye,be,me,we,ke,xe,Se,Ce,je,Oe,Ee,Ie,Te,Be,Pe,_e,Fe,Re,Ae,De,Me,Le,ze,He,Ue,Ne,Ke,We,Ve,Ge,$e,qe,Qe,Ye,Je,Xe,Ze,et,tt,nt,ot,rt,it,at,ct,st,lt,ut,dt,ft,pt,gt,vt,ht,yt,bt,mt,wt,kt,xt,St,Ct,jt,Ot,Et,It,Tt=e.position||"bottom-right";if("string"==typeof Tt){var Bt=Tt.split("-");Tt={vertical:Bt[0]||"bottom",horizontal:Bt[1]||"right",offset:e.positionOffset||{x:20,y:20}}}var Pt=e.primaryColor||(null===(t=e.button)||void 0===t?void 0:t.primaryColor)||(null===(n=e.button)||void 0===n?void 0:n.backgroundColor)||"#7C3AED",_t=(null===(o=e.header)||void 0===o?void 0:o.backgroundColor)||(null===(r=e.button)||void 0===r?void 0:r.backgroundColor)||Pt;return p({agentId:e.agentId,appId:e.appId,getSessionUrl:e.getSessionUrl,websocketUrl:e.websocketUrl,demo:!1!==e.demo,direction:e.direction||"ltr",language:e.language||"en",icon:p({type:(null===(i=e.icon)||void 0===i?void 0:i.type)||"chat",customImage:(null===(a=e.icon)||void 0===a?void 0:a.customImage)||null,emoji:(null===(c=e.icon)||void 0===c?void 0:c.emoji)||"💬",text:(null===(s=e.icon)||void 0===s?void 0:s.text)||"AI",size:(null===(l=e.icon)||void 0===l?void 0:l.size)||"medium",backgroundColor:(null===(u=e.icon)||void 0===u?void 0:u.backgroundColor)||null},e.icon),position:p({vertical:Tt.vertical||"bottom",horizontal:Tt.horizontal||"right",offset:Tt.offset||{x:20,y:20}},"object"===d(e.position)?e.position:{}),button:p({size:(null===(f=e.button)||void 0===f?void 0:f.size)||"medium",shape:(null===(g=e.button)||void 0===g?void 0:g.shape)||"circle",backgroundColor:(null===(v=e.button)||void 0===v?void 0:v.backgroundColor)||(null===(h=e.icon)||void 0===h?void 0:h.backgroundColor)||Pt,hoverColor:(null===(y=e.button)||void 0===y?void 0:y.hoverColor)||"#7C3AED",shadow:!1!==(null===(b=e.button)||void 0===b?void 0:b.shadow),shadowColor:(null===(m=e.button)||void 0===m?void 0:m.shadowColor)||"rgba(0,0,0,0.15)",primaryColor:(null===(w=e.button)||void 0===w?void 0:w.backgroundColor)||(null===(k=e.icon)||void 0===k?void 0:k.backgroundColor)||Pt},e.button),panel:p({width:(null===(x=e.panel)||void 0===x?void 0:x.width)||350,height:(null===(S=e.panel)||void 0===S?void 0:S.height)||500,borderRadius:(null===(C=e.panel)||void 0===C?void 0:C.borderRadius)||12,backgroundColor:(null===(j=e.panel)||void 0===j?void 0:j.backgroundColor)||"#FFFFFF",backdropFilter:(null===(O=e.panel)||void 0===O?void 0:O.backdropFilter)||null,border:(null===(E=e.panel)||void 0===E?void 0:E.border)||"1px solid rgba(0,0,0,0.1)"},e.panel),voice:p({micButtonColor:(null===(I=e.voice)||void 0===I?void 0:I.micButtonColor)||(null===(T=e.panel)||void 0===T?void 0:T.micButtonColor)||Pt,micButtonActiveColor:(null===(B=e.voice)||void 0===B?void 0:B.micButtonActiveColor)||(null===(P=e.panel)||void 0===P?void 0:P.micButtonActiveColor)||"#EF4444",micButtonHint:p(p({text:(null===(_=e.voice)||void 0===_||null===(_=_.micButtonHint)||void 0===_?void 0:_.text)||(null===(F=e.panel)||void 0===F||null===(F=F.micButtonHint)||void 0===F?void 0:F.text)||"Click the button to start voice conversation",color:(null===(R=e.voice)||void 0===R||null===(R=R.micButtonHint)||void 0===R?void 0:R.color)||(null===(A=e.panel)||void 0===A||null===(A=A.micButtonHint)||void 0===A?void 0:A.color)||"#6B7280",fontSize:(null===(D=e.voice)||void 0===D||null===(D=D.micButtonHint)||void 0===D?void 0:D.fontSize)||(null===(M=e.panel)||void 0===M||null===(M=M.micButtonHint)||void 0===M?void 0:M.fontSize)||"12px"},null===(L=e.voice)||void 0===L?void 0:L.micButtonHint),null===(z=e.panel)||void 0===z?void 0:z.micButtonHint),avatarBackgroundColor:(null===(H=e.voice)||void 0===H?void 0:H.avatarBackgroundColor)||"#667eea",avatarActiveBackgroundColor:(null===(U=e.voice)||void 0===U?void 0:U.avatarActiveBackgroundColor)||"#667eea",statusTitleColor:(null===(N=e.voice)||void 0===N?void 0:N.statusTitleColor)||"#1e293b",statusSubtitleColor:(null===(K=e.voice)||void 0===K?void 0:K.statusSubtitleColor)||"#64748b",startCallButtonColor:(null===(W=e.voice)||void 0===W?void 0:W.startCallButtonColor)||"#667eea",startCallButtonTextColor:(null===(V=e.voice)||void 0===V?void 0:V.startCallButtonTextColor)||"#FFFFFF",transcriptBackgroundColor:(null===(G=e.voice)||void 0===G?void 0:G.transcriptBackgroundColor)||"#FFFFFF",transcriptTextColor:(null===($=e.voice)||void 0===$?void 0:$.transcriptTextColor)||"#1e293b",transcriptLabelColor:(null===(q=e.voice)||void 0===q?void 0:q.transcriptLabelColor)||"#94a3b8",controlButtonColor:(null===(Q=e.voice)||void 0===Q?void 0:Q.controlButtonColor)||"#FFFFFF",controlButtonSecondaryColor:(null===(Y=e.voice)||void 0===Y?void 0:Y.controlButtonSecondaryColor)||"#64748b",endCallButtonColor:(null===(J=e.voice)||void 0===J?void 0:J.endCallButtonColor)||"#ef4444",language:(null===(X=e.voice)||void 0===X?void 0:X.language)||e.language||"en",websocketUrl:(null===(Z=e.voice)||void 0===Z?void 0:Z.websocketUrl)||e.websocketUrl},e.voice),text:p({sendButtonColor:(null===(ee=e.text)||void 0===ee?void 0:ee.sendButtonColor)||(null===(te=e.panel)||void 0===te?void 0:te.sendButtonColor)||"#7C3AED",sendButtonHoverColor:(null===(ne=e.text)||void 0===ne?void 0:ne.sendButtonHoverColor)||(null===(oe=e.panel)||void 0===oe?void 0:oe.sendButtonHoverColor)||"#6D28D9",sendButtonActiveColor:(null===(re=e.text)||void 0===re?void 0:re.sendButtonActiveColor)||(null===(ie=e.panel)||void 0===ie?void 0:ie.sendButtonActiveColor)||"#6D28D9",sendButtonText:(null===(ae=e.text)||void 0===ae?void 0:ae.sendButtonText)||(null===(ce=e.panel)||void 0===ce?void 0:ce.sendButtonText)||"➤",sendButtonTextColor:(null===(se=e.text)||void 0===se?void 0:se.sendButtonTextColor)||(null===(le=e.panel)||void 0===le?void 0:le.sendButtonTextColor)||"#FFFFFF",sendButtonFontSize:(null===(ue=e.text)||void 0===ue?void 0:ue.sendButtonFontSize)||(null===(de=e.panel)||void 0===de?void 0:de.sendButtonFontSize)||"18px",sendButtonFontWeight:(null===(fe=e.text)||void 0===fe?void 0:fe.sendButtonFontWeight)||(null===(pe=e.panel)||void 0===pe?void 0:pe.sendButtonFontWeight)||"500",sendButtonHint:p(p({text:(null===(ge=e.text)||void 0===ge||null===(ge=ge.sendButtonHint)||void 0===ge?void 0:ge.text)||(null===(ve=e.panel)||void 0===ve||null===(ve=ve.sendButtonHint)||void 0===ve?void 0:ve.text)||"",color:(null===(he=e.text)||void 0===he||null===(he=he.sendButtonHint)||void 0===he?void 0:he.color)||(null===(ye=e.panel)||void 0===ye||null===(ye=ye.sendButtonHint)||void 0===ye?void 0:ye.color)||"#6B7280",fontSize:(null===(be=e.text)||void 0===be||null===(be=be.sendButtonHint)||void 0===be?void 0:be.fontSize)||(null===(me=e.panel)||void 0===me||null===(me=me.sendButtonHint)||void 0===me?void 0:me.fontSize)||"12px"},null===(we=e.text)||void 0===we?void 0:we.sendButtonHint),null===(ke=e.panel)||void 0===ke?void 0:ke.sendButtonHint),inputPlaceholder:(null===(xe=e.text)||void 0===xe?void 0:xe.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===(je=e.panel)||void 0===je?void 0:je.inputBorderColor)||"#E5E7EB",inputFocusColor:(null===(Oe=e.text)||void 0===Oe?void 0:Oe.inputFocusColor)||(null===(Ee=e.panel)||void 0===Ee?void 0:Ee.inputFocusColor)||"#7C3AED",inputBackgroundColor:(null===(Ie=e.text)||void 0===Ie?void 0:Ie.inputBackgroundColor)||(null===(Te=e.panel)||void 0===Te?void 0:Te.inputBackgroundColor)||"#FFFFFF",inputTextColor:(null===(Be=e.text)||void 0===Be?void 0:Be.inputTextColor)||(null===(Pe=e.panel)||void 0===Pe?void 0:Pe.inputTextColor)||"#1F2937",inputFontSize:(null===(_e=e.text)||void 0===_e?void 0:_e.inputFontSize)||(null===(Fe=e.panel)||void 0===Fe?void 0:Fe.inputFontSize)||"14px",inputBorderRadius:(null===(Re=e.text)||void 0===Re?void 0:Re.inputBorderRadius)||(null===(Ae=e.panel)||void 0===Ae?void 0:Ae.inputBorderRadius)||20,inputPadding:(null===(De=e.text)||void 0===De?void 0:De.inputPadding)||(null===(Me=e.panel)||void 0===Me?void 0:Me.inputPadding)||"6px 14px"},e.text),landing:p({backgroundColor:(null===(Le=e.landing)||void 0===Le?void 0:Le.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===(Ue=e.landing)||void 0===Ue?void 0:Ue.titleColor)||"#1e293b",modeCardBackgroundColor:(null===(Ne=e.landing)||void 0===Ne?void 0:Ne.modeCardBackgroundColor)||"#FFFFFF",modeCardBorderColor:(null===(Ke=e.landing)||void 0===Ke?void 0:Ke.modeCardBorderColor)||"#E2E8F0",modeCardHoverBorderColor:(null===(We=e.landing)||void 0===We?void 0:We.modeCardHoverBorderColor)||_t,modeCardIconBackgroundColor:(null===(Ve=e.landing)||void 0===Ve?void 0:Ve.modeCardIconBackgroundColor)||_t,modeCardTitleColor:(null===(Ge=e.landing)||void 0===Ge?void 0:Ge.modeCardTitleColor)||"#111827",voiceCardIcon:(null===($e=e.landing)||void 0===$e?void 0:$e.voiceCardIcon)||"🎤",textCardIcon:(null===(qe=e.landing)||void 0===qe?void 0:qe.textCardIcon)||"💬"},e.landing),header:p({title:(null===(Qe=e.header)||void 0===Qe?void 0:Qe.title)||"Chat Assistant",showTitle:!1!==(null===(Ye=e.header)||void 0===Ye?void 0:Ye.showTitle),backgroundColor:(null===(Je=e.header)||void 0===Je?void 0:Je.backgroundColor)||(null===(Xe=e.button)||void 0===Xe?void 0:Xe.backgroundColor)||"#7C3AED",textColor:(null===(Ze=e.header)||void 0===Ze?void 0:Ze.textColor)||"#FFFFFF",showCloseButton:!1!==(null===(et=e.header)||void 0===et?void 0:et.showCloseButton)},e.header),tooltips:p({newChat:(null===(tt=e.tooltips)||void 0===tt?void 0:tt.newChat)||null,back:(null===(nt=e.tooltips)||void 0===nt?void 0:nt.back)||null,close:(null===(ot=e.tooltips)||void 0===ot?void 0:ot.close)||null,mute:(null===(rt=e.tooltips)||void 0===rt?void 0:rt.mute)||null,speaker:(null===(it=e.tooltips)||void 0===it?void 0:it.speaker)||null,endCall:(null===(at=e.tooltips)||void 0===at?void 0:at.endCall)||null},e.tooltips),messages:p({userBackgroundColor:(null===(ct=e.messages)||void 0===ct?void 0:ct.userBackgroundColor)||"#E5E7EB",agentBackgroundColor:(null===(st=e.messages)||void 0===st?void 0:st.agentBackgroundColor)||"#F3F4F6",systemBackgroundColor:(null===(lt=e.messages)||void 0===lt?void 0:lt.systemBackgroundColor)||"#DCFCE7",errorBackgroundColor:(null===(ut=e.messages)||void 0===ut?void 0:ut.errorBackgroundColor)||"#FEE2E2",textColor:(null===(dt=e.messages)||void 0===dt?void 0:dt.textColor)||"#1F2937",fontSize:(null===(ft=e.messages)||void 0===ft?void 0:ft.fontSize)||"14px",borderRadius:(null===(pt=e.messages)||void 0===pt?void 0:pt.borderRadius)||8},e.messages),animation:p({enableHover:!1!==(null===(gt=e.animation)||void 0===gt?void 0:gt.enableHover),enablePulse:!1!==(null===(vt=e.animation)||void 0===vt?void 0:vt.enablePulse),enableSlide:!1!==(null===(ht=e.animation)||void 0===ht?void 0:ht.enableSlide),duration:(null===(yt=e.animation)||void 0===yt?void 0:yt.duration)||.3},e.animation),behavior:p({autoOpen:(null===(bt=e.behavior)||void 0===bt?void 0:bt.autoOpen)||!1,startOpen:(null===(mt=e.behavior)||void 0===mt?void 0:mt.startOpen)||!1,hidden:(null===(wt=e.behavior)||void 0===wt?void 0:wt.hidden)||!1,autoConnect:(null===(kt=e.behavior)||void 0===kt?void 0:kt.autoConnect)||!1,showWelcomeMessage:!1!==(null===(xt=e.behavior)||void 0===xt?void 0:xt.showWelcomeMessage),welcomeMessage:(null===(St=e.behavior)||void 0===St?void 0:St.welcomeMessage)||"Hello! How can I help you today?",enableVoiceMode:void 0===(null===(Ct=e.behavior)||void 0===Ct?void 0:Ct.enableVoiceMode)||e.behavior.enableVoiceMode,mode:(null===(jt=e.behavior)||void 0===jt?void 0:jt.mode)||"unified"},e.behavior),accessibility:p({ariaLabel:(null===(Ot=e.accessibility)||void 0===Ot?void 0:Ot.ariaLabel)||"Chat Assistant",ariaDescription:(null===(Et=e.accessibility)||void 0===Et?void 0:Et.ariaDescription)||"Click to open chat assistant",keyboardNavigation:!1!==(null===(It=e.accessibility)||void 0===It?void 0:It.keyboardNavigation)},e.accessibility),customStyles:e.customStyles||"",variables:e.variables||{},forceConversationId:e.forceConversationId,primaryColor:Pt},"string"==typeof e.position?{positionString:e.position}:{})}},{key:"setupEventHandlers",value:function(){var e=this;this.sdk.on("error",function(t){e.textInterface.showError(t.message||t),e.textInterface.stopStreamingState()}),this.sdk.on("chunk",function(t){e.textInterface.appendStreamingChunk(t)}),this.sdk.on("done",function(t){var n=t.text;e.textInterface.finalizeStreaming(n)})}},{key:"createWidget",value:function(){var e=document.createElement("div");if(e.id="text-chat-widget",e.innerHTML=this.generateWidgetHTML(),document.body.appendChild(e),this.setupWidgetEvents(),this.config.behavior.startOpen||this.config.behavior.autoOpen){var t=document.getElementById("text-chat-panel");t&&(this.isOpen=!0,t.classList.add("open"))}}},{key:"generateWidgetHTML",value:function(){var e=this,t=(this.config.position,this.config.button),n=this.config.icon,o=(this.config.panel,this.config.header),r=(this.config.animation,{small:50,medium:60,large:70,xl:80}[t.size]||60),i={small:20,medium:28,large:36,xl:44}[n.size]||28,a=this.generatePositionStyles(),c=this.generateIconHTML(i),s=this.config.behavior.mode||"unified",l="unified"===s,u="unified"===s||"voice-only"===s,d="unified"===s||"text-only"===s,f=function(t){var n=e.config.language||"en";return(e.translations[n]||e.translations.en)[t]||t},p=function(t){var n,o=null===(n=e.config.tooltips)||void 0===n?void 0:n[t];return null!=o?o:{newChat:f("newChat"),back:f("back"),close:f("close"),mute:f("mute"),speaker:f("speaker"),endCall:f("endCall")}[t]||""};return"\n <style>\n ".concat(this.generateCSS(a,r,i),"\n ").concat(this.config.customStyles,"\n </style>\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(c,"\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(o.backgroundColor,"; color: ").concat(o.textColor,';">\n <div>\n ').concat(o.showTitle?'<div class="header-title">'.concat(o.title,"</div>"):"",'\n <div class="header-status">\n <span class="status-dot"></span>\n <span>').concat(f("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(l?"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"===s?'<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(o.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(l?'\n <div class="landing-screen" id="landingScreen">\n <div class="landing-logo">🤖</div>\n <div class="landing-title">'.concat(f("landingTitle"),'</div>\n <div class="mode-selection">\n ').concat(u?'<div class="mode-card voice" id="mode-card-voice">\n <div class="mode-card-icon">🎤</div>\n <div class="mode-card-title">'.concat(f("voiceCall"),"</div>\n </div>"):"","\n ").concat(d?'<div class="mode-card text" id="mode-card-text">\n <div class="mode-card-icon">💬</div>\n <div class="mode-card-title">'.concat(f("textChat"),"</div>\n </div>"):"","\n </div>\n </div>"):"","\n\n ").concat(u?this.voiceInterface.generateHTML():"","\n ").concat(d?this.textInterface.generateHTML():"","\n </div>\n </div>\n </div>\n ")}},{key:"generatePositionStyles",value:function(){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}},{key:"generateIconHTML",value:function(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>");default: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>')}}},{key:"generateCSS",value:function(e,t,n){var o,r,i,a,c,s,l,u=this.config.button,d=this.config.panel,f=this.config.header,p=(this.config.messages,this.config.animation),g=(u.backgroundColor||u.primaryColor,f.backgroundColor),v=(d.sendButtonColor||u.primaryColor,d.sendButtonHoverColor,d.sendButtonActiveColor,this.config.behavior.mode||"unified"),h="unified"===v||"voice-only"===v,y="unified"===v||"text-only"===v;return"\n #text-chat-widget {\n position: fixed;\n ".concat(e,'\n z-index: 10000;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n -webkit-transform: translateZ(0);\n transform: translateZ(0);\n will-change: transform;\n }\n \n #text-chat-button {\n width: ').concat(t,"px;\n height: ").concat(t,"px;\n border-radius: ").concat("circle"===u.shape?"50%":"square"===u.shape?"0":"12px",";\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all ").concat(p.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 }\n \n @media (max-width: 768px) {\n #text-chat-button {\n min-width: 56px;\n min-height: 56px;\n }\n \n #text-chat-panel {\n width: calc(100vw - 20px) !important;\n max-width: ").concat(d.width,"px;\n max-height: calc(100vh - 120px) !important;\n left: 10px !important;\n right: 10px !important;\n }\n \n #text-chat-input {\n font-size: 16px !important; /* Prevents iOS zoom on focus */\n }\n \n #text-chat-send {\n min-width: 60px;\n min-height: 44px;\n }\n }\n \n ").concat(p.enableHover?"\n #text-chat-button:hover {\n background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);\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;\n position: fixed;\n bottom: calc(").concat(t,"px + 20px);\n ").concat("right"===this.config.position.horizontal?"right: 20px;":"left: 20px;","\n width: ").concat(d.width,"px;\n max-width: calc(100vw - 40px);\n height: ").concat(d.height,"px;\n max-height: calc(100vh - ").concat(t,"px - 40px);\n background: transparent;\n border-radius: ").concat(d.borderRadius,"px;\n border: none;\n flex-direction: column;\n overflow: hidden;\n ").concat(d.backdropFilter?"backdrop-filter: ".concat(d.backdropFilter,";"):"","\n ").concat(p.enableSlide?"transition: all ".concat(p.duration,"s ease;"):"","\n }\n \n #text-chat-panel.open {\n display: flex;\n ").concat(p.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(d.borderRadius,"px; background: transparent; box-shadow: 0 20px 60px rgba(0,0,0,0.15); overflow: hidden; display: flex; flex-direction: column; }\n .panel-inner { width: 100%; height: 100%; background: #ffffff; border-radius: ").concat(d.borderRadius,"px; overflow: hidden; display:flex; flex-direction: column; padding: 0; box-sizing: border-box; }\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(d.borderRadius,"px;\n }\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(d.borderRadius,"px;\n border-top-right-radius: ").concat(d.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; \n flex: 1; \n padding: 20px; \n background: ").concat((null===(o=this.config.landing)||void 0===o?void 0:o.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; }\n .landing-logo { font-size: 48px; }\n .landing-title { \n font-size: 20px; \n color: ").concat((null===(r=this.config.landing)||void 0===r?void 0:r.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===(i=this.config.landing)||void 0===i?void 0:i.modeCardBackgroundColor)||"#FFFFFF","; \n border: 2px solid ").concat((null===(a=this.config.landing)||void 0===a?void 0:a.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(p.duration,"s ease, box-shadow ").concat(p.duration,"s ease, border-color ").concat(p.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===(c=this.config.landing)||void 0===c?void 0:c.modeCardHoverBorderColor)||g,"; \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===(s=this.config.landing)||void 0===s?void 0:s.modeCardIconBackgroundColor)||g,"; \n color: #fff; \n font-size: 32px; \n }\n .mode-card-title { \n color: ").concat((null===(l=this.config.landing)||void 0===l?void 0:l.modeCardTitleColor)||"#111827","; \n font-weight: 600; \n text-align: center;\n width: 100%;\n }\n\n ").concat(h?this.voiceInterface.generateCSS():"","\n ").concat(y?this.textInterface.generateCSS():"","\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 ")}},{key:"setupWidgetEvents",value:function(){var e=this,t=document.getElementById("text-chat-button");t&&(t.onclick=function(){return e.togglePanel()});var n=document.getElementById("closeBtn");n&&(n.onclick=function(){return e.togglePanel()});var o=this.config.behavior.mode||"unified",r="unified"===o,i="unified"===o||"voice-only"===o,a="unified"===o||"text-only"===o,c=document.getElementById("backBtn"),s=document.getElementById("landingScreen"),l=document.getElementById("mode-card-voice"),u=document.getElementById("mode-card-text"),d=document.getElementById("textInterface"),f=document.getElementById("voiceInterface");c&&(c.onclick=function(){return e.showLanding()}),r?(l&&(l.onclick=function(){return e.showVoice()}),u&&(u.onclick=function(){return e.showText()}),s&&s.classList.add("active"),d&&d.classList.remove("active"),f&&f.classList.remove("active"),c&&"unified"===o&&c.classList.remove("visible")):"voice-only"===o?(f&&f.classList.add("active"),d&&d.classList.remove("active"),s&&s.classList.remove("active")):"text-only"===o&&(d&&d.classList.add("active"),f&&f.classList.remove("active"),s&&s.classList.remove("active")),i&&this.voiceInterface.setupEventHandlers(),a&&this.textInterface.setupEventHandlers();var p=document.getElementById("newChatBtn");p&&(p.onclick=function(){return e.textInterface.startNewChat()},r&&(p.style.display="none")),this.config.accessibility.keyboardNavigation&&this.setupKeyboardNavigation()}},{key:"startNewChat",value:function(){this.textInterface.startNewChat()}},{key:"showLanding",value:function(){if("unified"===(this.config.behavior.mode||"unified")){var e=document.getElementById("landingScreen"),t=document.getElementById("textInterface"),n=document.getElementById("voiceInterface"),o=document.getElementById("backBtn"),r=document.getElementById("newChatBtn");e&&e.classList.add("active"),t&&t.classList.remove("active"),n&&n.classList.remove("active"),o&&o.classList.remove("visible"),r&&(r.style.display="none")}}},{key:"showText",value:function(){var e=document.getElementById("landingScreen"),t=document.getElementById("voiceInterface"),n=document.getElementById("backBtn"),o=document.getElementById("newChatBtn");e&&e.classList.remove("active"),t&&t.classList.remove("active"),this.textInterface.show();var r=this.config.behavior.mode||"unified";n&&"unified"===r&&n.classList.add("visible"),o&&(o.style.display="")}},{key:"showVoice",value:function(){var e=document.getElementById("landingScreen"),t=document.getElementById("textInterface"),n=document.getElementById("voiceInterface"),o=document.getElementById("backBtn"),r=document.getElementById("newChatBtn");e&&e.classList.remove("active"),t&&t.classList.remove("active"),n&&n.classList.add("active");var i=this.config.behavior.mode||"unified";o&&"unified"===i&&o.classList.add("visible"),r&&(r.style.display="")}},{key:"setupKeyboardNavigation",value:function(){var e=this;document.addEventListener("keydown",function(t){"Escape"===t.key&&e.isOpen&&e.togglePanel()})}},{key:"togglePanel",value:function(){this.isOpen=!this.isOpen,document.getElementById("text-chat-panel").classList.toggle("open"),this.isOpen&&setTimeout(function(){var e=document.getElementById("messageInput");e&&e.focus()},100),this.isOpen&&!this.isActive&&this.config.behavior.autoConnect&&this.startChat()}},{key:"startChat",value:(f=u(c().m(function e(){return c().w(function(e){for(;;)switch(e.n){case 0:this.isActive=!0,this.textInterface.setActive(!0);case 1:return e.a(2)}},e,this)})),function(){return f.apply(this,arguments)})},{key:"sendMessage",value:(l=u(c().m(function e(){return c().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.textInterface.sendMessage();case 1:return e.a(2)}},e,this)})),function(){return l.apply(this,arguments)})},{key:"updateSendButtonState",value:function(){this.textInterface.updateSendButtonState()}},{key:"getSignedUrl",value:(s=u(c().m(function e(){var t,n,o,r,i,a,s;return c().w(function(e){for(;;)switch(e.n){case 0:if(this.config.getSessionUrl){e.n=2;break}if(this.config.agentId){e.n=1;break}throw new Error("agentId is required");case 1:return t=this.config.websocketUrl||"wss://backend.talktopc.com/ws/conv",(n=new URLSearchParams).append("agentId",this.config.agentId),this.config.appId&&n.append("appId",this.config.appId),!1!==this.config.demo&&n.append("demo","true"),e.a(2,"".concat(t,"?").concat(n.toString()));case 2:if("string"!=typeof this.config.getSessionUrl){e.n=6;break}return o={agentId:this.config.agentId,variables:this.config.variables||{}},this.config.appId&&(o.appId=this.config.appId),e.n=3,fetch(this.config.getSessionUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});case 3:if((r=e.v).ok){e.n=4;break}throw new Error("Failed to get session URL: ".concat(r.statusText));case 4:return e.n=5,r.json();case 5:return i=e.v,e.a(2,i.signedUrl||i.wsUrl||i.url);case 6:if("function"!=typeof this.config.getSessionUrl){e.n=8;break}return a={agentId:this.config.agentId,variables:this.config.variables||{}},this.config.appId&&(a.appId=this.config.appId),e.n=7,this.config.getSessionUrl(a);case 7:return s=e.v,e.a(2,"string"==typeof s?s:s.signedUrl||s.wsUrl||s.url);case 8:throw new Error("getSessionUrl must be a string (backend URL), a function, or omitted (for direct connection with agentId/appId)");case 9:return e.a(2)}},e,this)})),function(){return s.apply(this,arguments)})},{key:"addMessage",value:function(e,t){this.textInterface.addMessage(e,t)}},{key:"beginStreaming",value:function(){this.textInterface.beginStreaming()}},{key:"appendStreamingChunk",value:function(e){this.textInterface.appendStreamingChunk(e)}},{key:"finalizeStreaming",value:function(e){this.textInterface.finalizeStreaming(e)}},{key:"stopStreamingState",value:function(){this.textInterface.stopStreamingState()}},{key:"showError",value:function(e){this.textInterface.showError(e)}},{key:"updateStatus",value:function(e){}},{key:"updateConfig",value:function(e){var t,n,o,a,c=p({},this.config);e.panel&&(c.panel=p(p({},this.config.panel),e.panel)),e.voice&&(c.voice=p(p({},this.config.voice),e.voice),e.voice.micButtonHint&&(c.voice.micButtonHint=p(p({},null===(o=this.config.voice)||void 0===o?void 0:o.micButtonHint),e.voice.micButtonHint))),e.text&&(c.text=p(p({},this.config.text),e.text),e.text.sendButtonHint&&(c.text.sendButtonHint=p(p({},null===(a=this.config.text)||void 0===a?void 0:a.sendButtonHint),e.text.sendButtonHint))),void 0!==e.language&&(c.language=e.language),void 0!==e.language&&(["he","ar"].includes(e.language)?c.direction="rtl":void 0===e.direction&&(c.direction="ltr")),e.translations&&(c.translations=e.translations,this.translations=e.translations),e.button&&(c.button=p(p({},this.config.button),e.button)),e.header&&(c.header=p(p({},this.config.header),e.header)),e.icon&&(c.icon=p(p({},this.config.icon),e.icon)),e.messages&&(c.messages=p(p({},this.config.messages),e.messages)),e.animation&&(c.animation=p(p({},this.config.animation),e.animation)),e.behavior&&(c.behavior=p(p({},this.config.behavior),e.behavior)),e.accessibility&&(c.accessibility=p(p({},this.config.accessibility),e.accessibility)),e.tooltips&&(c.tooltips=p(p({},this.config.tooltips),e.tooltips)),e.landing&&(c.landing=p(p({},this.config.landing),e.landing)),void 0!==e.direction&&void 0===c.direction&&(c.direction=e.direction),void 0!==e.primaryColor&&(c.primaryColor=e.primaryColor),Object.keys(e).forEach(function(t){["panel","button","header","icon","messages","direction","voice","text","animation","behavior","accessibility","language","tooltips","landing","primaryColor"].includes(t)||(c[t]=e[t])}),null===(t=this.config)||void 0===t||t.language,this.config=this.mergeWithDefaults(c);var s=this.config.language||"en",l=p(p(p({},this.config),this.config.voice),{},{language:s,websocketUrl:(null===(n=this.config.voice)||void 0===n?void 0:n.websocketUrl)||this.config.websocketUrl||"wss://speech.talktopc.com/ws/conv",translations:this.translations});this.voiceInterface=new r.VoiceInterface(l);var u=p(p(p({},this.config),this.config.text),{},{language:s,translations:this.translations});this.textInterface=new i.TextInterface(u,this.sdk);var d=document.getElementById("text-chat-widget");d&&d.remove(),this.createWidget(),this.textInterface&&this.textInterface.updateInputAttributes&&this.textInterface.updateInputAttributes()}},{key:"destroy",value:function(){var e=document.getElementById("text-chat-widget");e&&e.remove(),this.sdk&&this.sdk.destroy(),this.voiceInterface&&this.voiceInterface.destroy()}},{key:"startVoiceCall",value:(n=u(c().m(function e(){return c().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.voiceInterface.startVoiceCall();case 1:return e.a(2)}},e,this)})),function(){return n.apply(this,arguments)})},{key:"endVoiceCall",value:function(){this.voiceInterface.endVoiceCall()}},{key:"toggleMute",value:function(){this.voiceInterface.toggleMute()}},{key:"toggleSpeaker",value:function(){this.voiceInterface.toggleSpeaker()}}],t&&v(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n,s,l,f}()},"./src/legacy/TextInterface.js":(e,t,n)=>{function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function r(){var e,t,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.toStringTag||"@@toStringTag";function c(n,o,r,a){var c=o&&o.prototype instanceof l?o:l,u=Object.create(c.prototype);return i(u,"_invoke",function(n,o,r){var i,a,c,l=0,u=r||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,a=0,c=e,f.n=n,s}};function p(n,o){for(a=n,c=o,t=0;!d&&l&&!r&&t<u.length;t++){var r,i=u[t],p=f.p,g=i[2];n>3?(r=g===o)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=p&&((r=n<2&&p<i[1])?(a=0,f.v=o,f.n=i[1]):p<g&&(r=n<3||i[0]>o||o>g)&&(i[4]=n,i[5]=o,f.n=g,a=0))}if(r||n>1)return s;throw d=!0,o}return function(r,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&p(u,g),a=u,c=g;(t=a<2?e:c)||!d;){i||(a?a<3?(a>1&&(f.n=-1),p(a,c)):f.n=c:f.v=c);try{if(l=2,i){if(a||(r="next"),t=i[r]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),a=1);i=e}else if((t=(d=f.n<0)?c:n.call(o,f))!==s)break}catch(t){i=e,a=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,r,a),!0),u}var s={};function l(){}function u(){}function d(){}t=Object.getPrototypeOf;var f=[][o]?t(t([][o]())):(i(t={},o,function(){return this}),t),p=d.prototype=l.prototype=Object.create(f);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,i(e,a,"GeneratorFunction")),e.prototype=Object.create(p),e}return u.prototype=d,i(p,"constructor",d),i(d,"constructor",u),u.displayName="GeneratorFunction",i(d,a,"GeneratorFunction"),i(p),i(p,a,"Generator"),i(p,o,function(){return this}),i(p,"toString",function(){return"[object Generator]"}),(r=function(){return{w:c,m:g}})()}function i(e,t,n,o){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}i=function(e,t,n,o){function a(t,n){i(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},i(e,t,n,o)}function a(e,t,n,o,r,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(o,r)}function c(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var i=e.apply(t,n);function c(e){a(i,o,r,c,s,"next",e)}function s(e){a(i,o,r,c,s,"throw",e)}c(void 0)})}}function s(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,l(o.key),o)}}function l(e){var t=function(e){if("object"!=o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==o(t)?t:t+""}n.r(t),n.d(t,{TextInterface:()=>u});var u=function(){return e=function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.config=t,this.sdk=n,this.streamingEl=null,this.hasStartedStreaming=!1,this.isActive=!1},t=[{key:"t",value:function(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}},{key:"generateHTML",value:function(){var e,t,n,o,r,i,a,c,s,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===(r=this.config.panel)||void 0===r||null===(r=r.sendButtonHint)||void 0===r?void 0:r.color)||"#6B7280","; font-size: ").concat((null===(i=this.config.sendButtonHint)||void 0===i?void 0:i.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===(c=this.config.sendButtonHint)||void 0===c?void 0:c.text)||(null===(s=this.config.panel)||void 0===s||null===(s=s.sendButtonHint)||void 0===s?void 0:s.text),"\n </div>\n "):"","\n </div>\n </div>")}},{key:"generateCSS",value:function(){var e,t,n,o,r,i,a,c,s,l,u,d,f,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"),v=this.config.sendButtonHoverColor||(null===(t=this.config.panel)||void 0===t?void 0:t.sendButtonHoverColor)||"#6D28D9",h=this.config.sendButtonTextColor||(null===(n=this.config.panel)||void 0===n?void 0:n.sendButtonTextColor)||"#FFFFFF",y=(this.config.inputPlaceholder||null===(o=this.config.panel)||void 0===o||o.inputPlaceholder,this.config.inputBorderColor||(null===(r=this.config.panel)||void 0===r?void 0:r.inputBorderColor)||"#E5E7EB"),b=this.config.inputFocusColor||(null===(i=this.config.panel)||void 0===i?void 0:i.inputFocusColor)||"#7C3AED",m=this.config.inputBackgroundColor||(null===(a=this.config.panel)||void 0===a?void 0:a.inputBackgroundColor)||"#FFFFFF",w=this.config.inputTextColor||(null===(c=this.config.panel)||void 0===c?void 0:c.inputTextColor)||"#1F2937",k=this.config.inputFontSize||(null===(s=this.config.panel)||void 0===s?void 0:s.inputFontSize)||"14px",x=this.config.inputBorderRadius||(null===(l=this.config.panel)||void 0===l?void 0:l.inputBorderRadius)||20,S=this.config.inputPadding||(null===(u=this.config.panel)||void 0===u?void 0:u.inputPadding)||"6px 14px";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; \n flex: 1; \n flex-direction: column; \n min-height: 0; \n overflow: hidden; \n }\n .text-interface.active { display: flex; }\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","; \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(S,";\n border: 1px solid ").concat(y,";\n border-radius: ").concat(x,"px;\n font-size: ").concat(k,";\n font-family: inherit;\n line-height: 1.3;\n resize: none;\n overflow-y: auto;\n background: ").concat(m,";\n color: ").concat(w,";\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(b,";\n background: ").concat("#FFFFFF"===m?"#FFFFFF":m,";\n box-shadow: 0 0 0 3px ").concat(b,"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(h,";\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===(f=this.config.panel)||void 0===f?void 0:f.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(v,";\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 ")}},{key:"setupEventHandlers",value:function(){var e=this,t=document.getElementById("sendButton"),n=document.getElementById("messageInput"),o=document.getElementById("newChatBtn");if(t&&(t.onclick=function(){return e.sendMessage()}),o&&(o.onclick=function(){return e.startNewChat()}),this.updateInputAttributes(),n){n.style.height="32px",n.style.overflow="hidden";var r=function(){n.style.height="auto";var e=Math.min(n.scrollHeight,120);n.style.height=e+"px",n.style.overflowY=e>=120?"auto":"hidden",e>=120&&setTimeout(function(){n.scrollTop=n.scrollHeight},0)};n.addEventListener("input",r),n.addEventListener("keydown",function(t){"Enter"!==t.key||t.shiftKey?"Enter"===t.key&&t.shiftKey&&setTimeout(r,0):(t.preventDefault(),e.sendMessage())})}}},{key:"startNewChat",value:function(){try{localStorage.removeItem("ttp_text_chat_conversation_id")}catch(e){}this.sdk&&(this.sdk.config.conversationId=null);var e=document.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=document.getElementById("messageInput");t&&t.focus()}},{key:"updateInputAttributes",value:function(){var e=document.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"}}},{key:"show",value:function(){var e=document.getElementById("textInterface");e&&e.classList.add("active"),setTimeout(function(){var e=document.getElementById("messageInput");e&&e.focus()},50)}},{key:"hide",value:function(){var e=document.getElementById("textInterface");e&&e.classList.remove("active")}},{key:"startChat",value:(o=c(r().m(function e(){return r().w(function(e){for(;;)switch(e.n){case 0:this.isActive=!0,this.updateSendButtonState();case 1:return e.a(2)}},e,this)})),function(){return o.apply(this,arguments)})},{key:"sendMessage",value:(n=c(r().m(function e(){var t,n,o;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=document.getElementById("messageInput"),n=t.value.trim()){e.n=1;break}return e.a(2);case 1:if(this.isActive){e.n=2;break}return e.n=2,this.startChat();case 2:return this.addMessage("user",n),t.value="",t.style.height="32px",t.style.overflow="hidden",e.p=3,this.beginStreaming(),e.n=4,this.sdk.sendMessage(n);case 4:e.n=6;break;case 5:e.p=5,o=e.v,console.error("❌ Failed to send message:",o),this.showError(o.message),this.stopStreamingState();case 6:return e.a(2)}},e,this,[[3,5]])})),function(){return n.apply(this,arguments)})},{key:"updateSendButtonState",value:function(){var e=document.getElementById("sendButton");e&&(e.disabled=!this.isActive)}},{key:"addMessage",value:function(e,t){var n=document.getElementById("messagesContainer");if(n){var o=n.querySelector(".empty-state");o&&o.remove();var r=document.createElement("div"),i="rtl"===this.config.direction?"user"===e?"edge-left":"edge-right":"user"===e?"edge-right":"edge-left";r.className="message ".concat(e," ").concat(i);var a=document.createElement("div");a.className="message-avatar ".concat(e),a.textContent="user"===e?"👤":"🤖";var c=document.createElement("div");c.className="message-bubble",c.textContent=t,r.appendChild(a),r.appendChild(c),n.appendChild(r),n.scrollTop=n.scrollHeight}}},{key:"beginStreaming",value:function(){var e=document.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 r=document.createElement("div");r.className="message-bubble",r.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(r),e.appendChild(t),this.streamingEl=r,this.hasStartedStreaming=!1,e.scrollTop=e.scrollHeight}}},{key:"appendStreamingChunk",value:function(e){if(this.streamingEl){this.hasStartedStreaming||(this.streamingEl.textContent="",this.hasStartedStreaming=!0),this.streamingEl.textContent+=e;var t=document.getElementById("messagesContainer");t&&(t.scrollTop=t.scrollHeight)}}},{key:"finalizeStreaming",value:function(e){if(this.streamingEl){this.streamingEl.textContent=e||this.streamingEl.textContent;var t=document.getElementById("agent-streaming");t&&(t.id=""),this.streamingEl=null}this.updateSendButtonState()}},{key:"stopStreamingState",value:function(){var e=document.getElementById("agent-streaming");e&&e.remove(),this.streamingEl=null,this.hasStartedStreaming=!1}},{key:"showError",value:function(e){var t=document.getElementById("messagesContainer");if(t){var n=document.createElement("div");n.className="error-message",n.textContent=e,t.appendChild(n),t.scrollTop=t.scrollHeight}}},{key:"setActive",value:function(e){this.isActive=e,this.updateSendButtonState()}}],t&&s(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n,o}()},"./src/legacy/VoiceInterface.js":(e,t,n)=>{n.r(t),n.d(t,{VoiceInterface:()=>d});var o=n("./src/index.js");function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function i(){var e,t,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function c(n,o,r,i){var c=o&&o.prototype instanceof l?o:l,u=Object.create(c.prototype);return a(u,"_invoke",function(n,o,r){var i,a,c,l=0,u=r||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,a=0,c=e,f.n=n,s}};function p(n,o){for(a=n,c=o,t=0;!d&&l&&!r&&t<u.length;t++){var r,i=u[t],p=f.p,g=i[2];n>3?(r=g===o)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=p&&((r=n<2&&p<i[1])?(a=0,f.v=o,f.n=i[1]):p<g&&(r=n<3||i[0]>o||o>g)&&(i[4]=n,i[5]=o,f.n=g,a=0))}if(r||n>1)return s;throw d=!0,o}return function(r,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&p(u,g),a=u,c=g;(t=a<2?e:c)||!d;){i||(a?a<3?(a>1&&(f.n=-1),p(a,c)):f.n=c:f.v=c);try{if(l=2,i){if(a||(r="next"),t=i[r]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),a=1);i=e}else if((t=(d=f.n<0)?c:n.call(o,f))!==s)break}catch(t){i=e,a=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,r,i),!0),u}var s={};function l(){}function u(){}function d(){}t=Object.getPrototypeOf;var f=[][o]?t(t([][o]())):(a(t={},o,function(){return this}),t),p=d.prototype=l.prototype=Object.create(f);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,a(e,r,"GeneratorFunction")),e.prototype=Object.create(p),e}return u.prototype=d,a(p,"constructor",d),a(d,"constructor",u),u.displayName="GeneratorFunction",a(d,r,"GeneratorFunction"),a(p),a(p,r,"Generator"),a(p,o,function(){return this}),a(p,"toString",function(){return"[object Generator]"}),(i=function(){return{w:c,m:g}})()}function a(e,t,n,o){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}a=function(e,t,n,o){function i(t,n){a(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},a(e,t,n,o)}function c(e,t,n,o,r,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(o,r)}function s(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var i=e.apply(t,n);function a(e){c(i,o,r,a,s,"next",e)}function s(e){c(i,o,r,a,s,"throw",e)}a(void 0)})}}function l(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,u(o.key),o)}}function u(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}var d=function(){return e=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.config=t,this.audioStream=null,this.callStartTime=null,this.callTimerInterval=null,this.sdk=null,this.isActive=!1,this.sdk=new o.AgentSDK({agentId:t.agentId,appId:t.appId,getSessionUrl:t.getSessionUrl,websocketUrl:t.websocketUrl,variables:t.variables||{},language:t.language||"en"}),this.setupSDKEventHandlers()},t=[{key:"setupSDKEventHandlers",value:function(){var e=this;this.sdk.onTranscript=function(t){e.updateTranscript(t)},this.sdk.onAgentSpeaking=function(e){var t=document.getElementById("voiceAvatarActive");t&&(e?t.classList.add("speaking"):t.classList.remove("speaking"))},this.sdk.onError=function(t){console.error("❌ Voice SDK Error:",t),e.showError(t.message||t)}}},{key:"t",value:function(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}},{key:"getTooltip",value:function(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]||""}},{key:"generateHTML",value:function(){return'<div class="voice-interface" id="voiceInterface">\n \x3c!-- Before Call State --\x3e\n <div id="voiceIdleState" style="display: flex; flex-direction: column; align-items: center; width: 100%;">\n <div class="voice-avatar" id="voiceAvatar">\n 🤖\n </div>\n <div class="voice-status">\n <div class="voice-status-title">'.concat(this.t("clickToStartCall"),'</div>\n <div class="voice-status-subtitle">').concat(this.t("realTimeVoice"),'</div>\n </div>\n \x3c!-- BIG START CALL BUTTON --\x3e\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.t("startCall"),'</span>\n </button>\n </div>\n \x3c!-- During Call State --\x3e\n <div id="voiceActiveState" style="display: none; flex-direction: column; align-items: center; width: 100%; height: 100%; justify-content: flex-start; overflow: hidden; padding-top: 10px;">\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>')}},{key:"generateCSS",value:function(){var e=this.config.avatarBackgroundColor||"#667eea",t=this.config.avatarActiveBackgroundColor||this.config.avatarBackgroundColor||"#667eea",n=this.config.statusTitleColor||"#1e293b",o=this.config.statusSubtitleColor||"#64748b",r=this.config.startCallButtonColor||"#667eea",i=this.config.startCallButtonTextColor||"#FFFFFF",a=this.config.transcriptBackgroundColor||"#FFFFFF",c=this.config.transcriptTextColor||"#1e293b",s=this.config.transcriptLabelColor||"#94a3b8",l=this.config.controlButtonColor||"#FFFFFF",u=this.config.controlButtonSecondaryColor||"#64748b",d=this.config.endCallButtonColor||"#ef4444";return"\n /* Voice Interface Styles */\n .voice-interface { \n display: none; \n flex: 1; \n flex-direction: column;\n align-items: center; \n justify-content: flex-start; \n padding: 10px 20px 20px 20px; \n background: linear-gradient(180deg, #f8fafc 0%, #e0e7ff 100%);\n overflow: hidden;\n min-height: 0;\n }\n .voice-interface.active { display: flex; }\n \n /* Voice Avatar (idle state) */\n .voice-avatar {\n width: 120px;\n height: 120px;\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: 56px;\n margin-top: 10px;\n margin-bottom: 16px;\n box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);\n transition: all 0.3s ease;\n flex-shrink: 0;\n }\n \n /* Voice Avatar (active state with animations) */\n .voice-avatar-active {\n width: 120px;\n height: 120px;\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: 56px;\n margin-top: 10px;\n margin-bottom: 16px;\n position: relative;\n box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);\n animation: avatarPulse 2s ease-in-out infinite;\n flex-shrink: 0;\n }\n \n @keyframes avatarPulse {\n 0%, 100% { \n transform: scale(1);\n box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);\n }\n 50% { \n transform: scale(1.05);\n box-shadow: 0 15px 50px rgba(102, 126, 234, 0.5);\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 */\n .voice-status {\n text-align: center;\n margin-bottom: 10px;\n flex-shrink: 0;\n }\n \n .voice-status-title {\n font-size: 18px;\n font-weight: 600;\n color: ").concat(n,";\n margin-bottom: 4px;\n }\n \n .voice-status-subtitle {\n font-size: 12px;\n color: ").concat(o,";\n }\n \n /* Start Call Button */\n .start-call-btn {\n margin-top: 20px;\n width: 200px;\n height: 56px;\n border-radius: 28px;\n border: none;\n background: ").concat(r,";\n color: ").concat(i,";\n font-size: 18px;\n font-weight: 600;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 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:hover {\n transform: translateY(-4px);\n box-shadow: 0 16px 40px rgba(102, 126, 234, 0.5);\n }\n \n .start-call-btn:active {\n transform: translateY(-2px);\n }\n \n /* Voice Transcript */\n .voice-transcript {\n background: ").concat(a,";\n padding: 12px;\n border-radius: 12px;\n max-width: 300px;\n width: 100%;\n margin-bottom: 12px;\n min-height: 50px;\n max-height: 90px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);\n flex-shrink: 1;\n overflow-y: auto;\n }\n \n .transcript-label {\n font-size: 10px;\n color: ").concat(s,";\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n margin-bottom: 6px;\n }\n \n .transcript-text {\n font-size: 14px;\n color: ").concat(c,";\n line-height: 1.5;\n min-height: 30px;\n }\n \n .transcript-text.empty {\n color: #cbd5e1;\n font-style: italic;\n }\n \n /* Voice Controls */\n .voice-controls {\n display: flex;\n gap: 12px;\n align-items: center;\n flex-shrink: 0;\n }\n \n .voice-control-btn {\n width: 72px;\n height: 72px;\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.primary {\n width: 80px;\n height: 80px;\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);\n }\n \n .voice-control-btn.primary:hover {\n transform: scale(1.05);\n box-shadow: 0 10px 25px rgba(102, 126, 234, 0.5);\n }\n \n .voice-control-btn.primary.active {\n background: ").concat("#ef4444"===d?"white":l,";\n animation: recordingPulse 1.5s ease-in-out infinite;\n box-shadow: 0 8px 20px ").concat("#ef4444"===d?"rgba(239, 68, 68, 0.4)":"rgba(0, 0, 0, 0.2)",";\n }\n \n @keyframes recordingPulse {\n 0%, 100% { \n box-shadow: 0 8px 20px rgba(239, 68, 68, 0.4);\n }\n 50% { \n box-shadow: 0 8px 30px rgba(239, 68, 68, 0.7);\n }\n }\n \n .voice-control-btn.secondary {\n background: ").concat(l,";\n color: ").concat(u,";\n box-shadow: 0 4px 12px 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: -24px;\n font-size: 12px;\n color: #64748b;\n font-weight: 500;\n }\n ")}},{key:"setupEventHandlers",value:function(e){var t=this,n=document.getElementById("startCallBtn"),o=document.getElementById("endCallBtn"),r=document.getElementById("muteBtn"),i=document.getElementById("speakerBtn");n&&(n.onclick=function(){return t.startVoiceCall()}),o&&(o.onclick=function(){return t.endVoiceCall()}),r&&(r.onclick=function(){return t.toggleMute()}),i&&(i.onclick=function(){return t.toggleSpeaker()})}},{key:"getSignedUrl",value:(r=s(i().m(function e(){var t,n,o,r,a,c,s;return i().w(function(e){for(;;)switch(e.n){case 0:if(this.config.getSessionUrl){e.n=2;break}if(this.config.agentId){e.n=1;break}throw new Error("agentId is required");case 1:return t=this.config.websocketUrl||"wss://speech.talktopc.com/ws/conv",(n=new URLSearchParams).append("agentId",this.config.agentId),this.config.appId&&n.append("appId",this.config.appId),!1!==this.config.demo&&n.append("demo","true"),e.a(2,"".concat(t,"?").concat(n.toString()));case 2:if("string"!=typeof this.config.getSessionUrl){e.n=6;break}return o={agentId:this.config.agentId,variables:this.config.variables||{}},this.config.appId&&(o.appId=this.config.appId),e.n=3,fetch(this.config.getSessionUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});case 3:if((r=e.v).ok){e.n=4;break}throw new Error("Failed to get session URL: ".concat(r.statusText));case 4:return e.n=5,r.json();case 5:return a=e.v,e.a(2,a.signedUrl||a.wsUrl||a.url);case 6:if("function"!=typeof this.config.getSessionUrl){e.n=8;break}return c={agentId:this.config.agentId,variables:this.config.variables||{}},this.config.appId&&(c.appId=this.config.appId),e.n=7,this.config.getSessionUrl(c);case 7:return s=e.v,e.a(2,"string"==typeof s?s:s.signedUrl||s.wsUrl||s.url);case 8:throw new Error("getSessionUrl must be a string (backend URL), a function, or omitted (for direct connection with agentId/appId)");case 9:return e.a(2)}},e,this)})),function(){return r.apply(this,arguments)})},{key:"startVoiceCall",value:(n=s(i().m(function e(){var t,n,o,r,a,c,s,l,u,d=this;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!this.isActive){e.n=1;break}return console.log("⚠️ Voice call already active"),e.a(2);case 1:return console.log("🎤 Starting voice call..."),e.p=2,t=document.getElementById("voiceIdleState"),n=document.getElementById("voiceActiveState"),o=document.getElementById("voiceInterface"),t&&(t.style.display="none"),n&&(n.style.display="flex"),o&&(o.scrollTop=0),e.n=3,this.getSignedUrl();case 3:return r=e.v,console.log("🔗 Got signed URL:",r),e.n=4,this.sdk.connect(r);case 4:a=e.v,console.log("✅ Connected to WebSocket, connected:",a),c=0;case 5:if(this.sdk.isConnected||!(c<50)){e.n=7;break}return e.n=6,new Promise(function(e){return setTimeout(e,100)});case 6:c++,e.n=5;break;case 7:if(!this.sdk.isConnected){e.n=9;break}return console.log("✅ WebSocket ready, starting listening..."),e.n=8,this.sdk.startListening();case 8:console.log("🎤 Started listening"),this.isActive=!0,this.callStartTime=Date.now(),this.callTimerInterval=setInterval(function(){var e=Date.now()-d.callStartTime,t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3),o=document.getElementById("voiceTimer");o&&(o.textContent="".concat(t.toString().padStart(2,"0"),":").concat(n.toString().padStart(2,"0")))},1e3),e.n=11;break;case 9:return console.warn("⚠️ Connection not fully ready, but trying to start listening anyway..."),e.n=10,this.sdk.startListening();case 10:console.log("🎤 Started listening"),this.isActive=!0,this.callStartTime=Date.now(),this.callTimerInterval=setInterval(function(){var e=Date.now()-d.callStartTime,t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3),o=document.getElementById("voiceTimer");o&&(o.textContent="".concat(t.toString().padStart(2,"0"),":").concat(n.toString().padStart(2,"0")))},1e3);case 11:console.log("✅ Voice call started successfully"),e.n=13;break;case 12:e.p=12,u=e.v,console.error("❌ Error starting voice call:",u),this.showError(u.message||u),s=document.getElementById("voiceIdleState"),l=document.getElementById("voiceActiveState"),s&&(s.style.display="flex"),l&&(l.style.display="none");case 13:return e.a(2)}},e,this,[[2,12]])})),function(){return n.apply(this,arguments)})},{key:"endVoiceCall",value:function(){console.log("🔴 Ending voice call..."),this.sdk&&this.isActive&&(this.sdk.stopListening(),this.sdk.disconnect(),this.isActive=!1),this.audioStream&&(this.audioStream.getTracks().forEach(function(e){return e.stop()}),this.audioStream=null),this.callTimerInterval&&(clearInterval(this.callTimerInterval),this.callTimerInterval=null);var e=document.getElementById("voiceIdleState"),t=document.getElementById("voiceActiveState");e&&(e.style.display="flex"),t&&(t.style.display="none");var n=document.getElementById("transcriptText");n&&(n.textContent=this.t("transcriptWillAppear"),n.classList.add("empty"));var o=document.getElementById("voiceAvatarActive");o&&o.classList.remove("speaking"),console.log("✅ Voice call ended")}},{key:"updateTranscript",value:function(e){var t=document.getElementById("transcriptText");t&&(t.textContent=e,t.classList.remove("empty"))}},{key:"showError",value:function(e){var t=document.getElementById("transcriptText");t&&(t.textContent="".concat(this.t("error"),": ").concat(e),t.classList.remove("empty"))}},{key:"toggleMute",value:function(){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=document.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")}}},{key:"toggleSpeaker",value:function(){console.log("🔊 Speaker toggle")}},{key:"destroy",value:function(){this.isActive&&this.endVoiceCall(),this.audioStream&&(this.audioStream.getTracks().forEach(function(e){return e.stop()}),this.audioStream=null),this.callTimerInterval&&(clearInterval(this.callTimerInterval),this.callTimerInterval=null),this.sdk&&(this.sdk.disconnect(),this.sdk=null)}}],t&&l(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n,r}()},"./src/legacy/widget-translations.js":(e,t,n)=>{n.r(t),n.d(t,{default:()=>o});const o={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"},he:{landingTitle:"איך תרצה לתקשר?",voiceCall:"שיחה קולית",textChat:"צ'אט טקסט",clickToStartCall:"לחץ להתחלת שיחה",realTimeVoice:"שיחה קולית בזמן אמת",startCall:"התחל שיחה",listening:"מקשיב...",speakFreely:"דבר בחופשיות",liveTranscript:"תמלול בזמן אמת",transcriptWillAppear:"התמלול יופיע כאן במהלך השיחה...",mute:"השתק",speaker:"רמקול",endCall:"סיים שיחה",hello:"שלום! איך אפשר לעזור?",sendMessage:"שלח הודעה או עבור למצב קולי לשיחה בזמן אמת",online:"מקוון",newChat:"צ'אט חדש",back:"חזור",close:"סגור",error:"שגיאה",typeMessage:"הקלד הודעה...",sendMessageAria:"שלח הודעה"},ar:{landingTitle:"كيف تريد التواصل؟",voiceCall:"مكالمة صوتية",textChat:"دردشة نصية",clickToStartCall:"انقر لبدء المكالمة",realTimeVoice:"محادثة صوتية في الوقت الفعلي",startCall:"ابدأ المكالمة",listening:"الاستماع...",speakFreely:"تكلم بحرية",liveTranscript:"نص مباشر",transcriptWillAppear:"سيظهر النص هنا أثناء المكالمة...",mute:"كتم الصوت",speaker:"مكبر الصوت",endCall:"إنهاء المكالمة",hello:"مرحبا! كيف يمكنني المساعدة؟",sendMessage:"أرسل رسالة للبدء",online:"متصل",newChat:"محادثة جديدة",back:"رجوع",close:"إغلاق",error:"خطأ",typeMessage:"اكتب رسالة...",sendMessageAria:"إرسال رسالة"},ru:{landingTitle:"Как вы хотите общаться?",voiceCall:"Голосовой звонок",textChat:"Текстовый чат",clickToStartCall:"Нажмите, чтобы начать звонок",realTimeVoice:"Голосовой разговор в реальном времени",startCall:"Начать звонок",listening:"Слушаю...",speakFreely:"Говорите свободно",liveTranscript:"Живая транскрипция",transcriptWillAppear:"Транскрипция появится здесь во время звонка...",mute:"Отключить звук",speaker:"Динамик",endCall:"Завершить звонок",hello:"Привет! Как я могу помочь?",sendMessage:"Отправьте сообщение для начала",online:"В сети",newChat:"Новый чат",back:"Назад",close:"Закрыть",error:"Ошибка",typeMessage:"Введите сообщение...",sendMessageAria:"Отправить сообщение"},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"},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"},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"}}},"./src/react/VoiceButton.jsx":(e,t,n)=>{n.r(t),n.d(t,{default:()=>v});var o=n("./node_modules/react/index.js"),r=n("./src/core/VoiceSDK.js"),i=n("./node_modules/react/jsx-runtime.js");function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function c(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 s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach(function(t){l(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function l(e,t,n){return(t=function(e){var t=function(e){if("object"!=a(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=a(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==a(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(){var e,t,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function i(n,o,r,i){var s=o&&o.prototype instanceof c?o:c,l=Object.create(s.prototype);return d(l,"_invoke",function(n,o,r){var i,c,s,l=0,u=r||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,c=0,s=e,f.n=n,a}};function p(n,o){for(c=n,s=o,t=0;!d&&l&&!r&&t<u.length;t++){var r,i=u[t],p=f.p,g=i[2];n>3?(r=g===o)&&(s=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=p&&((r=n<2&&p<i[1])?(c=0,f.v=o,f.n=i[1]):p<g&&(r=n<3||i[0]>o||o>g)&&(i[4]=n,i[5]=o,f.n=g,c=0))}if(r||n>1)return a;throw d=!0,o}return function(r,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&p(u,g),c=u,s=g;(t=c<2?e:s)||!d;){i||(c?c<3?(c>1&&(f.n=-1),p(c,s)):f.n=s:f.v=s);try{if(l=2,i){if(c||(r="next"),t=i[r]){if(!(t=t.call(i,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(s=TypeError("The iterator does not provide a '"+r+"' method"),c=1);i=e}else if((t=(d=f.n<0)?s:n.call(o,f))!==a)break}catch(t){i=e,c=1,s=t}finally{l=1}}return{value:t,done:d}}}(n,r,i),!0),l}var a={};function c(){}function s(){}function l(){}t=Object.getPrototypeOf;var f=[][o]?t(t([][o]())):(d(t={},o,function(){return this}),t),p=l.prototype=c.prototype=Object.create(f);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,d(e,r,"GeneratorFunction")),e.prototype=Object.create(p),e}return s.prototype=l,d(p,"constructor",l),d(l,"constructor",s),s.displayName="GeneratorFunction",d(l,r,"GeneratorFunction"),d(p),d(p,r,"Generator"),d(p,o,function(){return this}),d(p,"toString",function(){return"[object Generator]"}),(u=function(){return{w:i,m:g}})()}function d(e,t,n,o){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}d=function(e,t,n,o){function i(t,n){d(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},d(e,t,n,o)}function f(e,t,n,o,r,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(o,r)}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,r,i,a,c=[],s=!0,l=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(o=i.call(n)).done)&&(c.push(o.value),c.length!==t);s=!0);}catch(e){l=!0,r=e}finally{try{if(!s&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw r}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return g(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?g(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}const v=function(e){var t=e.websocketUrl,n=e.agentId,a=e.voice,c=void 0===a?"default":a,l=e.language,d=void 0===l?"en":l,g=e.autoReconnect,v=void 0===g||g,h=e.onConnected,y=e.onDisconnected,b=e.onRecordingStarted,m=e.onRecordingStopped,w=e.onPlaybackStarted,k=e.onPlaybackStopped,x=e.onError,S=e.onMessage,C=e.onBargeIn,j=e.onStopPlaying,O=e.className,E=void 0===O?"":O,I=e.style,T=void 0===I?{}:I,B=e.children,P=p((0,o.useState)(!1),2),_=P[0],F=P[1],R=p((0,o.useState)(!1),2),A=R[0],D=R[1],M=p((0,o.useState)(!1),2),L=(M[0],M[1]),z=p((0,o.useState)("Disconnected"),2),H=(z[0],z[1]),U=(0,o.useRef)(null);(0,o.useEffect)(function(){console.log("🎙️ VoiceButton: Creating VoiceSDK instance for ".concat(t)),U.current&&(console.log("🎙️ VoiceButton: Destroying existing VoiceSDK instance"),U.current.destroy(),U.current=null);var e=new r.default({websocketUrl:t,agentId:n,voice:c,language:d,autoReconnect:v});return e.on("connected",function(){F(!0),H("Connected"),null==h||h()}),e.on("disconnected",function(){F(!1),H("Disconnected"),null==y||y()}),e.on("recordingStarted",function(){D(!0),null==b||b()}),e.on("recordingStopped",function(){D(!1),null==m||m()}),e.on("playbackStarted",function(){L(!0),null==w||w()}),e.on("playbackStopped",function(){L(!1),null==k||k()}),e.on("error",function(e){null==x||x(e)}),e.on("message",function(e){null==S||S(e)}),e.on("bargeIn",function(e){null==C||C(e)}),e.on("stopPlaying",function(e){null==j||j(e)}),U.current=e,e.connect(),function(){console.log("🎙️ VoiceButton: Cleaning up VoiceSDK instance for ".concat(t)),U.current&&(U.current.destroy(),U.current=null)}},[t,n,c,d]);var N=function(){var e,t=(e=u().m(function e(){var t;return u().w(function(e){for(;;)switch(e.p=e.n){case 0:if(U.current){e.n=1;break}return e.a(2);case 1:return e.p=1,e.n=2,U.current.toggleRecording();case 2:e.n=4;break;case 3:e.p=3,t=e.v,console.error("Error toggling recording:",t);case 4:return e.a(2)}},e,null,[[1,3]])}),function(){var t=this,n=arguments;return new Promise(function(o,r){var i=e.apply(t,n);function a(e){f(i,o,r,a,c,"next",e)}function c(e){f(i,o,r,a,c,"throw",e)}a(void 0)})});return function(){return t.apply(this,arguments)}}(),K=(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,i.jsx)("div",{style:{fontSize:"20px"},children:A?"🔴":"🎤"}),(0,i.jsx)("div",{children:A?"Stop Listening":"Start Listening"})]});return(0,i.jsx)("button",{className:"voice-button ".concat(A?"recording":""," ").concat(E),style:s({padding:"12px 24px",border:"none",borderRadius:"8px",backgroundColor:A?"#dc3545":"#007bff",color:"white",cursor:"pointer",fontSize:"16px",fontWeight:"500",transition:"all 0.2s ease"},T),onClick:N,disabled:!_,children:B||K})}},"./src/vanilla/VoiceButton.js":(e,t,n)=>{n.r(t),n.d(t,{default:()=>p});var o=n("./src/core/VoiceSDK.js");function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function i(){var e,t,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function c(n,o,r,i){var c=o&&o.prototype instanceof l?o:l,u=Object.create(c.prototype);return a(u,"_invoke",function(n,o,r){var i,a,c,l=0,u=r||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,a=0,c=e,f.n=n,s}};function p(n,o){for(a=n,c=o,t=0;!d&&l&&!r&&t<u.length;t++){var r,i=u[t],p=f.p,g=i[2];n>3?(r=g===o)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=p&&((r=n<2&&p<i[1])?(a=0,f.v=o,f.n=i[1]):p<g&&(r=n<3||i[0]>o||o>g)&&(i[4]=n,i[5]=o,f.n=g,a=0))}if(r||n>1)return s;throw d=!0,o}return function(r,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&p(u,g),a=u,c=g;(t=a<2?e:c)||!d;){i||(a?a<3?(a>1&&(f.n=-1),p(a,c)):f.n=c:f.v=c);try{if(l=2,i){if(a||(r="next"),t=i[r]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),a=1);i=e}else if((t=(d=f.n<0)?c:n.call(o,f))!==s)break}catch(t){i=e,a=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,r,i),!0),u}var s={};function l(){}function u(){}function d(){}t=Object.getPrototypeOf;var f=[][o]?t(t([][o]())):(a(t={},o,function(){return this}),t),p=d.prototype=l.prototype=Object.create(f);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,a(e,r,"GeneratorFunction")),e.prototype=Object.create(p),e}return u.prototype=d,a(p,"constructor",d),a(d,"constructor",u),u.displayName="GeneratorFunction",a(d,r,"GeneratorFunction"),a(p),a(p,r,"Generator"),a(p,o,function(){return this}),a(p,"toString",function(){return"[object Generator]"}),(i=function(){return{w:c,m:g}})()}function a(e,t,n,o){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}a=function(e,t,n,o){function i(t,n){a(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},a(e,t,n,o)}function c(e,t,n,o,r,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(o,r)}function s(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var i=e.apply(t,n);function a(e){c(i,o,r,a,s,"next",e)}function s(e){c(i,o,r,a,s,"throw",e)}a(void 0)})}}function l(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 u(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function d(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,f(o.key),o)}}function f(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}var p=function(){return e=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.options=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach(function(t){u(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({websocketUrl:t.websocketUrl||"wss://speech.talktopc.com/ws/conv",agentId:t.agentId,voice:t.voice||"default",language:t.language||"en",container:t.container||document.body,buttonText:t.buttonText||"Start Listening",buttonClass:t.buttonClass||"voice-button"},t),this.isConnected=!1,this.isRecording=!1,this.isPlaying=!1,this.voiceSDK=new o.default({websocketUrl:this.options.websocketUrl,agentId:this.options.agentId,voice:this.options.voice,language:this.options.language}),this.setupEventListeners(),this.createButton(),this.connect()},t=[{key:"setupEventListeners",value:function(){var e=this;this.voiceSDK.on("connected",function(){var t,n;e.isConnected=!0,e.updateButton(),null===(t=(n=e.options).onConnected)||void 0===t||t.call(n)}),this.voiceSDK.on("disconnected",function(){var t,n;e.isConnected=!1,e.updateButton(),null===(t=(n=e.options).onDisconnected)||void 0===t||t.call(n)}),this.voiceSDK.on("recordingStarted",function(){var t,n;e.isRecording=!0,e.updateButton(),null===(t=(n=e.options).onRecordingStarted)||void 0===t||t.call(n)}),this.voiceSDK.on("recordingStopped",function(){var t,n;e.isRecording=!1,e.updateButton(),null===(t=(n=e.options).onRecordingStopped)||void 0===t||t.call(n)}),this.voiceSDK.on("playbackStarted",function(){var t,n;e.isPlaying=!0,null===(t=(n=e.options).onPlaybackStarted)||void 0===t||t.call(n)}),this.voiceSDK.on("playbackStopped",function(){var t,n;e.isPlaying=!1,null===(t=(n=e.options).onPlaybackStopped)||void 0===t||t.call(n)}),this.voiceSDK.on("error",function(t){var n,o;null===(n=(o=e.options).onError)||void 0===n||n.call(o,t)}),this.voiceSDK.on("message",function(t){var n,o;null===(n=(o=e.options).onMessage)||void 0===n||n.call(o,t)}),this.voiceSDK.on("bargeIn",function(t){var n,o;null===(n=(o=e.options).onBargeIn)||void 0===n||n.call(o,t)}),this.voiceSDK.on("stopPlaying",function(t){var n,o;null===(n=(o=e.options).onStopPlaying)||void 0===n||n.call(o,t)})}},{key:"createButton",value:function(){var e=this;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",function(){return e.toggleRecording()}),this.options.container.appendChild(this.button),this.updateButton()}},{key:"updateButton",value:function(){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"}}},{key:"connect",value:(r=s(i().m(function e(){var t;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,this.voiceSDK.connect();case 1:e.n=3;break;case 2:e.p=2,t=e.v,console.error("Failed to connect:",t);case 3:return e.a(2)}},e,this,[[0,2]])})),function(){return r.apply(this,arguments)})},{key:"toggleRecording",value:(n=s(i().m(function e(){var t;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.voiceSDK){e.n=1;break}return e.a(2);case 1:return e.p=1,e.n=2,this.voiceSDK.toggleRecording();case 2:e.n=4;break;case 3:e.p=3,t=e.v,console.error("Error toggling recording:",t);case 4:return e.a(2)}},e,this,[[1,3]])})),function(){return n.apply(this,arguments)})},{key:"getStatus",value:function(){return{isConnected:this.isConnected,isRecording:this.isRecording,isPlaying:this.isPlaying}}},{key:"updateConfig",value:function(e){this.voiceSDK.updateConfig(e)}},{key:"destroy",value:function(){this.button&&this.button.parentNode&&this.button.parentNode.removeChild(this.button),this.voiceSDK&&this.voiceSDK.destroy()}}],t&&d(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n,r}()}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={id:o,loaded:!1,exports:{}};return e[o](i,i.exports,n),i.loaded=!0,i.exports}return n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),n("./src/index.js")})());
2
+ !function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.TTPAgentSDK=n():t.TTPAgentSDK=n()}(window,()=>(()=>{"use strict";var t={540:(t,n,e)=>{t.exports=e(869)},698:(t,n)=>{var e=Symbol.for("react.transitional.element");function o(t,n,o){var i=null;if(void 0!==o&&(i=""+o),void 0!==n.key&&(i=""+n.key),"key"in n)for(var r in o={},n)"key"!==r&&(o[r]=n[r]);else o=n;return n=o.ref,{$$typeof:e,type:t,key:i,ref:void 0!==n?n:null,props:o}}Symbol.for("react.fragment"),n.jsx=o,n.jsxs=o},848:(t,n,e)=>{t.exports=e(698)},869:(t,n)=>{Symbol.for("react.transitional.element"),Symbol.for("react.portal"),Symbol.for("react.fragment"),Symbol.for("react.strict_mode"),Symbol.for("react.profiler"),Symbol.for("react.consumer"),Symbol.for("react.context"),Symbol.for("react.forward_ref"),Symbol.for("react.suspense"),Symbol.for("react.memo"),Symbol.for("react.lazy"),Symbol.for("react.activity"),Symbol.iterator;var e={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},o=Object.assign,i={};function r(t,n,o){this.props=t,this.context=n,this.refs=i,this.updater=o||e}function a(){}function c(t,n,o){this.props=t,this.context=n,this.refs=i,this.updater=o||e}r.prototype.isReactComponent={},r.prototype.setState=function(t,n){if("object"!=typeof t&&"function"!=typeof t&&null!=t)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,n,"setState")},r.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")},a.prototype=r.prototype;var s=c.prototype=new a;s.constructor=c,o(s,r.prototype),s.isPureReactComponent=!0;Array.isArray;var l={H:null,A:null,T:null,S:null};Object.prototype.hasOwnProperty;"function"==typeof reportError&&reportError;n.useEffect=function(t,n){return l.H.useEffect(t,n)},n.useRef=function(t){return l.H.useRef(t)},n.useState=function(t){return l.H.useState(t)}}},n={};function e(o){var i=n[o];if(void 0!==i)return i.exports;var r=n[o]={exports:{}};return t[o](r,r.exports,e),r.exports}e.d=(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},e.o=(t,n)=>Object.prototype.hasOwnProperty.call(t,n),e.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function r(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,a(o.key),o)}}function a(t){var n=function(t){if("object"!=i(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var e=n.call(t,"string");if("object"!=i(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==i(n)?n:n+""}e.r(o),e.d(o,{AgentSDK:()=>cn,AgentWidget:()=>sn,AudioPlayer:()=>Z,AudioRecorder:()=>K,EventEmitter:()=>c,TextChatSDK:()=>Ot,TextChatWidget:()=>zn,VERSION:()=>Rn,VanillaVoiceButton:()=>qt,VoiceButton:()=>Rt,VoiceSDK:()=>pt,WebSocketManager:()=>T,default:()=>_n});var c=function(){return t=function t(){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.events={}},n=[{key:"on",value:function(t,n){this.events[t]||(this.events[t]=[]),this.events[t].push(n)}},{key:"off",value:function(t,n){this.events[t]&&(this.events[t]=this.events[t].filter(function(t){return t!==n}))}},{key:"emit",value:function(t){for(var n=arguments.length,e=new Array(n>1?n-1:0),o=1;o<n;o++)e[o-1]=arguments[o];this.events[t]&&this.events[t].forEach(function(n){try{n.apply(void 0,e)}catch(n){console.error("Error in event listener for ".concat(t,":"),n)}})}},{key:"removeAllListeners",value:function(t){t?delete this.events[t]:this.events={}}}],n&&r(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n}();function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function l(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var o,i,r,a,c=[],s=!0,l=!1;try{if(r=(e=e.call(t)).next,0===n){if(Object(e)!==e)return;s=!1}else for(;!(s=(o=r.call(e)).done)&&(c.push(o.value),c.length!==n);s=!0);}catch(t){l=!0,i=t}finally{try{if(!s&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(l)throw i}}return c}}(t,n)||d(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=d(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var o=0,i=function(){};return{s:i,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,a=!0,c=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){c=!0,r=t},f:function(){try{a||null==e.return||e.return()}finally{if(c)throw r}}}}function d(t,n){if(t){if("string"==typeof t)return p(t,n);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?p(t,n):void 0}}function p(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,o=Array(n);e<n;e++)o[e]=t[e];return o}function f(){var t,n,e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",i=e.toStringTag||"@@toStringTag";function r(e,o,i,r){var s=o&&o.prototype instanceof c?o:c,l=Object.create(s.prototype);return g(l,"_invoke",function(e,o,i){var r,c,s,l=0,u=i||[],d=!1,p={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(n,e){return r=n,c=0,s=t,p.n=e,a}};function f(e,o){for(c=e,s=o,n=0;!d&&l&&!i&&n<u.length;n++){var i,r=u[n],f=p.p,g=r[2];e>3?(i=g===o)&&(s=r[(c=r[4])?5:(c=3,3)],r[4]=r[5]=t):r[0]<=f&&((i=e<2&&f<r[1])?(c=0,p.v=o,p.n=r[1]):f<g&&(i=e<3||r[0]>o||o>g)&&(r[4]=e,r[5]=o,p.n=g,c=0))}if(i||e>1)return a;throw d=!0,o}return function(i,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&f(u,g),c=u,s=g;(n=c<2?t:s)||!d;){r||(c?c<3?(c>1&&(p.n=-1),f(c,s)):p.n=s:p.v=s);try{if(l=2,r){if(c||(i="next"),n=r[i]){if(!(n=n.call(r,s)))throw TypeError("iterator result is not an object");if(!n.done)return n;s=n.value,c<2&&(c=0)}else 1===c&&(n=r.return)&&n.call(r),c<2&&(s=TypeError("The iterator does not provide a '"+i+"' method"),c=1);r=t}else if((n=(d=p.n<0)?s:e.call(o,p))!==a)break}catch(n){r=t,c=1,s=n}finally{l=1}}return{value:n,done:d}}}(e,i,r),!0),l}var a={};function c(){}function s(){}function l(){}n=Object.getPrototypeOf;var u=[][o]?n(n([][o]())):(g(n={},o,function(){return this}),n),d=l.prototype=c.prototype=Object.create(u);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,g(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return s.prototype=l,g(d,"constructor",l),g(l,"constructor",s),s.displayName="GeneratorFunction",g(l,i,"GeneratorFunction"),g(d),g(d,i,"Generator"),g(d,o,function(){return this}),g(d,"toString",function(){return"[object Generator]"}),(f=function(){return{w:r,m:p}})()}function g(t,n,e,o){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}g=function(t,n,e,o){function r(n,e){g(t,n,function(t){return this._invoke(n,e,t)})}n?i?i(t,n,{value:e,enumerable:!o,configurable:!o,writable:!o}):t[n]=e:(r("next",0),r("throw",1),r("return",2))},g(t,n,e,o)}function h(t,n,e,o,i,r,a){try{var c=t[r](a),s=c.value}catch(t){return void e(t)}c.done?n(s):Promise.resolve(s).then(o,i)}function v(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,m(o.key),o)}}function m(t){var n=function(t){if("object"!=s(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var e=n.call(t,"string");if("object"!=s(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==s(n)?n:n+""}function y(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(y=function(){return!!t})()}function b(t){return b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},b(t)}function x(t,n){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},x(t,n)}const w=new(function(t){function n(){var t;return function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n),(t=function(t,n,e){return n=b(n),function(t,n){if(n&&("object"==s(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,y()?Reflect.construct(n,e||[],b(t).constructor):n.apply(t,e))}(this,n)).connections=new Map,t.connectionCounts=new Map,t.creatingConnections=new Set,t}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),n&&x(t,n)}(n,t),e=n,o=[{key:"getConnection",value:(i=f().m(function t(n){var e,o,i=this;return f().w(function(t){for(;;)switch(t.n){case 0:if(!this.connections.has(n)){t.n=1;break}return e=this.connections.get(n),this.connectionCounts.set(n,(this.connectionCounts.get(n)||0)+1),t.a(2,e);case 1:if(!this.creatingConnections||!this.creatingConnections.has(n)){t.n=2;break}return t.a(2,new Promise(function(t){var e=function(){if(i.connections.has(n)){var o=i.connections.get(n);i.connectionCounts.set(n,(i.connectionCounts.get(n)||0)+1),t(o)}else setTimeout(e,50)};e()}));case 2:return this.creatingConnections.add(n),o=new WebSocket(n),this.connections.set(n,o),this.connectionCounts.set(n,1),o.addEventListener("open",function(t){i.creatingConnections.delete(n),i.emit("open",t,n)}),o.addEventListener("close",function(t){i.creatingConnections.delete(n),i.connections.delete(n),i.connectionCounts.delete(n),i.emit("close",t,n)}),o.addEventListener("error",function(t){i.creatingConnections.delete(n),i.emit("error",t,n)}),o.addEventListener("message",function(t){i.emit("message",t,n)}),t.a(2,o)}},t,this)}),r=function(){var t=this,n=arguments;return new Promise(function(e,o){var r=i.apply(t,n);function a(t){h(r,e,o,a,c,"next",t)}function c(t){h(r,e,o,a,c,"throw",t)}a(void 0)})},function(t){return r.apply(this,arguments)})},{key:"releaseConnection",value:function(t){if(this.connections.has(t)){var n=this.connectionCounts.get(t)||0,e=Math.max(0,n-1);if(this.connectionCounts.set(t,e),0===e){var o=this.connections.get(t);o&&o.readyState===WebSocket.OPEN&&o.close(1e3,"No more subscribers"),this.connections.delete(t),this.connectionCounts.delete(t)}}}},{key:"forceClose",value:function(t){if(this.connections.has(t)){var n=this.connections.get(t);n&&n.readyState===WebSocket.OPEN&&n.close(1e3,"Force close"),this.connections.delete(t),this.connectionCounts.delete(t)}}},{key:"getConnectionStatus",value:function(t){return this.connections.has(t)?{exists:!0,readyState:this.connections.get(t).readyState,subscribers:this.connectionCounts.get(t)||0}:{exists:!1,readyState:null,subscribers:0}}},{key:"getAllConnections",value:function(){var t,n={},e=u(this.connections.entries());try{for(e.s();!(t=e.n()).done;){var o=l(t.value,2),i=o[0],r=o[1];n[i]={readyState:r.readyState,subscribers:this.connectionCounts.get(i)||0}}}catch(t){e.e(t)}finally{e.f()}return n}},{key:"clearAll",value:function(){var t,n=u(this.connections.entries());try{for(n.s();!(t=n.n()).done;){var e=l(t.value,2),o=(e[0],e[1]);o&&o.readyState===WebSocket.OPEN&&o.close(1e3,"Clear all")}}catch(t){n.e(t)}finally{n.f()}this.connections.clear(),this.connectionCounts.clear(),this.creatingConnections.clear()}}],o&&v(e.prototype,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,o,i,r}(c));function k(t){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},k(t)}function S(){var t,n,e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",i=e.toStringTag||"@@toStringTag";function r(e,o,i,r){var s=o&&o.prototype instanceof c?o:c,l=Object.create(s.prototype);return C(l,"_invoke",function(e,o,i){var r,c,s,l=0,u=i||[],d=!1,p={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(n,e){return r=n,c=0,s=t,p.n=e,a}};function f(e,o){for(c=e,s=o,n=0;!d&&l&&!i&&n<u.length;n++){var i,r=u[n],f=p.p,g=r[2];e>3?(i=g===o)&&(s=r[(c=r[4])?5:(c=3,3)],r[4]=r[5]=t):r[0]<=f&&((i=e<2&&f<r[1])?(c=0,p.v=o,p.n=r[1]):f<g&&(i=e<3||r[0]>o||o>g)&&(r[4]=e,r[5]=o,p.n=g,c=0))}if(i||e>1)return a;throw d=!0,o}return function(i,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&f(u,g),c=u,s=g;(n=c<2?t:s)||!d;){r||(c?c<3?(c>1&&(p.n=-1),f(c,s)):p.n=s:p.v=s);try{if(l=2,r){if(c||(i="next"),n=r[i]){if(!(n=n.call(r,s)))throw TypeError("iterator result is not an object");if(!n.done)return n;s=n.value,c<2&&(c=0)}else 1===c&&(n=r.return)&&n.call(r),c<2&&(s=TypeError("The iterator does not provide a '"+i+"' method"),c=1);r=t}else if((n=(d=p.n<0)?s:e.call(o,p))!==a)break}catch(n){r=t,c=1,s=n}finally{l=1}}return{value:n,done:d}}}(e,i,r),!0),l}var a={};function c(){}function s(){}function l(){}n=Object.getPrototypeOf;var u=[][o]?n(n([][o]())):(C(n={},o,function(){return this}),n),d=l.prototype=c.prototype=Object.create(u);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,C(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return s.prototype=l,C(d,"constructor",l),C(l,"constructor",s),s.displayName="GeneratorFunction",C(l,i,"GeneratorFunction"),C(d),C(d,i,"Generator"),C(d,o,function(){return this}),C(d,"toString",function(){return"[object Generator]"}),(S=function(){return{w:r,m:p}})()}function C(t,n,e,o){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}C=function(t,n,e,o){function r(n,e){C(t,n,function(t){return this._invoke(n,e,t)})}n?i?i(t,n,{value:e,enumerable:!o,configurable:!o,writable:!o}):t[n]=e:(r("next",0),r("throw",1),r("return",2))},C(t,n,e,o)}function O(t,n,e,o,i,r,a){try{var c=t[r](a),s=c.value}catch(t){return void e(t)}c.done?n(s):Promise.resolve(s).then(o,i)}function I(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,B(o.key),o)}}function B(t){var n=function(t){if("object"!=k(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var e=n.call(t,"string");if("object"!=k(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==k(n)?n:n+""}function j(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(j=function(){return!!t})()}function E(t){return E=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},E(t)}function P(t,n){return P=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},P(t,n)}var T=function(t){function n(t){var e;return function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n),(e=function(t,n,e){return n=E(n),function(t,n){if(n&&("object"==k(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,j()?Reflect.construct(n,e||[],E(t).constructor):n.apply(t,e))}(this,n)).config=t,e.ws=null,e.isConnected=!1,e.connectionId=null,e}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),n&&P(t,n)}(n,t),e=n,o=[{key:"connect",value:(r=S().m(function t(){var n=this;return S().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,e){try{n.connectionId=Date.now()+"_"+Math.random().toString(36).substr(2,9),n.connectResolve=t,n.connectReject=e,w.getConnection(n.config.websocketUrl,n.config).then(function(e){n.ws=e,n.setupEventListeners(),e.readyState===WebSocket.OPEN&&(n.isConnected=!0,n.emit("connected"),t(),n.connectResolve=null,n.connectReject=null)}).catch(function(t){console.error("🔌 WebSocketManager: Connection failed ".concat(n.connectionId),t),e(t),n.connectResolve=null,n.connectReject=null})}catch(t){console.error("🔌 WebSocketManager: Connection error ".concat(n.connectionId),t),e(t),n.connectResolve=null,n.connectReject=null}}))},t)}),a=function(){var t=this,n=arguments;return new Promise(function(e,o){var i=r.apply(t,n);function a(t){O(i,e,o,a,c,"next",t)}function c(t){O(i,e,o,a,c,"throw",t)}a(void 0)})},function(){return a.apply(this,arguments)})},{key:"setupEventListeners",value:function(){var t=this;if(this.ws){var n=function(n,e){e===t.config.websocketUrl&&(t.isConnected=!0,t.emit("connected"),t.connectResolve&&(t.connectResolve(),t.connectResolve=null,t.connectReject=null))},e=function(n,e){e===t.config.websocketUrl&&(t.isConnected=!1,t.emit("disconnected",n))},o=function(n,e){e===t.config.websocketUrl&&(t.emit("error",n),t.connectReject&&(t.connectReject(n),t.connectResolve=null,t.connectReject=null))},i=function(n,e){e===t.config.websocketUrl&&t.handleMessage(n)};w.on("open",n),w.on("close",e),w.on("error",o),w.on("message",i),this.eventHandlers={open:n,close:e,error:o,message:i}}}},{key:"disconnect",value:function(){this.eventHandlers&&(w.off("open",this.eventHandlers.open),w.off("close",this.eventHandlers.close),w.off("error",this.eventHandlers.error),w.off("message",this.eventHandlers.message)),this.config.websocketUrl&&w.releaseConnection(this.config.websocketUrl),this.ws=null,this.isConnected=!1}},{key:"sendMessage",value:function(t){if(this.isConnected&&this.ws)try{this.ws.send(JSON.stringify(t))}catch(t){console.warn("🔌 WebSocketManager: Failed to send message:",t.message)}}},{key:"sendBinary",value:function(t){if(this.isConnected&&this.ws)try{this.ws.send(t)}catch(t){console.warn("🔌 WebSocketManager: Failed to send binary data:",t.message)}}},{key:"handleMessage",value:function(t){var n=this;if(t.data instanceof ArrayBuffer)this.emit("binaryAudio",t.data);else if(t.data instanceof Blob)t.data.arrayBuffer().then(function(t){n.emit("binaryAudio",t)}).catch(function(t){console.error("🔌 WebSocketManager: Error converting Blob to ArrayBuffer:",t)});else try{var e=JSON.parse(t.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(t){this.emit("error",t)}}},{key:"getStatus",value:function(){return{isConnected:this.isConnected,readyState:this.ws?this.ws.readyState:null,connectionId:this.connectionId}}}],i=[{key:"getSingletonStatus",value:function(){return w.getAllConnections()}},{key:"clearAllConnections",value:function(){w.clearAll()}}],o&&I(e.prototype,o),i&&I(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,o,i,r,a}(c);function F(t){return F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},F(t)}function A(){var t,n,e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",i=e.toStringTag||"@@toStringTag";function r(e,o,i,r){var s=o&&o.prototype instanceof c?o:c,l=Object.create(s.prototype);return D(l,"_invoke",function(e,o,i){var r,c,s,l=0,u=i||[],d=!1,p={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(n,e){return r=n,c=0,s=t,p.n=e,a}};function f(e,o){for(c=e,s=o,n=0;!d&&l&&!i&&n<u.length;n++){var i,r=u[n],f=p.p,g=r[2];e>3?(i=g===o)&&(s=r[(c=r[4])?5:(c=3,3)],r[4]=r[5]=t):r[0]<=f&&((i=e<2&&f<r[1])?(c=0,p.v=o,p.n=r[1]):f<g&&(i=e<3||r[0]>o||o>g)&&(r[4]=e,r[5]=o,p.n=g,c=0))}if(i||e>1)return a;throw d=!0,o}return function(i,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&f(u,g),c=u,s=g;(n=c<2?t:s)||!d;){r||(c?c<3?(c>1&&(p.n=-1),f(c,s)):p.n=s:p.v=s);try{if(l=2,r){if(c||(i="next"),n=r[i]){if(!(n=n.call(r,s)))throw TypeError("iterator result is not an object");if(!n.done)return n;s=n.value,c<2&&(c=0)}else 1===c&&(n=r.return)&&n.call(r),c<2&&(s=TypeError("The iterator does not provide a '"+i+"' method"),c=1);r=t}else if((n=(d=p.n<0)?s:e.call(o,p))!==a)break}catch(n){r=t,c=1,s=n}finally{l=1}}return{value:n,done:d}}}(e,i,r),!0),l}var a={};function c(){}function s(){}function l(){}n=Object.getPrototypeOf;var u=[][o]?n(n([][o]())):(D(n={},o,function(){return this}),n),d=l.prototype=c.prototype=Object.create(u);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,D(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return s.prototype=l,D(d,"constructor",l),D(l,"constructor",s),s.displayName="GeneratorFunction",D(l,i,"GeneratorFunction"),D(d),D(d,i,"Generator"),D(d,o,function(){return this}),D(d,"toString",function(){return"[object Generator]"}),(A=function(){return{w:r,m:p}})()}function D(t,n,e,o){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}D=function(t,n,e,o){function r(n,e){D(t,n,function(t){return this._invoke(n,e,t)})}n?i?i(t,n,{value:e,enumerable:!o,configurable:!o,writable:!o}):t[n]=e:(r("next",0),r("throw",1),r("return",2))},D(t,n,e,o)}function M(t,n,e,o,i,r,a){try{var c=t[r](a),s=c.value}catch(t){return void e(t)}c.done?n(s):Promise.resolve(s).then(o,i)}function z(t){return function(){var n=this,e=arguments;return new Promise(function(o,i){var r=t.apply(n,e);function a(t){M(r,o,i,a,c,"next",t)}function c(t){M(r,o,i,a,c,"throw",t)}a(void 0)})}}function R(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,_(o.key),o)}}function _(t){var n=function(t){if("object"!=F(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var e=n.call(t,"string");if("object"!=F(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==F(n)?n:n+""}function H(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(H=function(){return!!t})()}function L(t){return L=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},L(t)}function U(t,n){return U=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},U(t,n)}var K=function(t){function n(t){var e;return function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n),(e=function(t,n,e){return n=L(n),function(t,n){if(n&&("object"==F(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,H()?Reflect.construct(n,e||[],L(t).constructor):n.apply(t,e))}(this,n)).config=t,e.audioContext=null,e.audioWorkletNode=null,e.mediaStream=null,e.isRecording=!1,e}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),n&&U(t,n)}(n,t),e=n,o=[{key:"start",value:(r=z(A().m(function t(){var n,e=this;return A().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,navigator.mediaDevices.getUserMedia({audio:{sampleRate:this.config.sampleRate,channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});case 1:if(this.mediaStream=t.v,this.audioContext=new(window.AudioContext||window.webkitAudioContext)({sampleRate:this.config.sampleRate}),"suspended"!==this.audioContext.state){t.n=2;break}return t.n=2,this.audioContext.resume();case 2:return t.n=3,this.audioContext.audioWorklet.addModule("/audio-processor.js");case 3:this.audioWorkletNode=new AudioWorkletNode(this.audioContext,"audio-processor"),this.audioContext.createMediaStreamSource(this.mediaStream).connect(this.audioWorkletNode),this.audioWorkletNode.port.onmessage=function(t){var n=t.data,o=n.type,i=n.data;"pcm_audio_data"===o&&e.emit("audioData",i)},this.audioWorkletNode.port.postMessage({type:"setForceContinuous",data:{enabled:!0}}),this.isRecording=!0,this.emit("recordingStarted"),t.n=5;break;case 4:throw t.p=4,n=t.v,this.emit("error",n),n;case 5:return t.a(2)}},t,this,[[0,4]])})),function(){return r.apply(this,arguments)})},{key:"stop",value:(i=z(A().m(function t(){var n;return A().w(function(t){for(;;)switch(t.p=t.n){case 0:if(this.isRecording){t.n=1;break}return t.a(2);case 1:if(t.p=1,!this.audioWorkletNode){t.n=2;break}return this.audioWorkletNode.port.postMessage({type:"flush"}),t.n=2,new Promise(function(t){return setTimeout(t,100)});case 2:if(this.mediaStream&&(this.mediaStream.getTracks().forEach(function(t){return t.stop()}),this.mediaStream=null),!this.audioContext||"closed"===this.audioContext.state){t.n=4;break}return t.n=3,this.audioContext.close();case 3:this.audioContext=null;case 4:this.audioWorkletNode=null,this.isRecording=!1,this.emit("recordingStopped"),t.n=6;break;case 5:throw t.p=5,n=t.v,this.emit("error",n),n;case 6:return t.a(2)}},t,this,[[1,5]])})),function(){return i.apply(this,arguments)})},{key:"getStatus",value:function(){return{isRecording:this.isRecording,audioContextState:this.audioContext?this.audioContext.state:"closed"}}},{key:"destroy",value:function(){this.stop()}}],o&&R(e.prototype,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,o,i,r}(c);function W(t){return W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},W(t)}function N(){var t,n,e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",i=e.toStringTag||"@@toStringTag";function r(e,o,i,r){var s=o&&o.prototype instanceof c?o:c,l=Object.create(s.prototype);return G(l,"_invoke",function(e,o,i){var r,c,s,l=0,u=i||[],d=!1,p={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(n,e){return r=n,c=0,s=t,p.n=e,a}};function f(e,o){for(c=e,s=o,n=0;!d&&l&&!i&&n<u.length;n++){var i,r=u[n],f=p.p,g=r[2];e>3?(i=g===o)&&(s=r[(c=r[4])?5:(c=3,3)],r[4]=r[5]=t):r[0]<=f&&((i=e<2&&f<r[1])?(c=0,p.v=o,p.n=r[1]):f<g&&(i=e<3||r[0]>o||o>g)&&(r[4]=e,r[5]=o,p.n=g,c=0))}if(i||e>1)return a;throw d=!0,o}return function(i,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&f(u,g),c=u,s=g;(n=c<2?t:s)||!d;){r||(c?c<3?(c>1&&(p.n=-1),f(c,s)):p.n=s:p.v=s);try{if(l=2,r){if(c||(i="next"),n=r[i]){if(!(n=n.call(r,s)))throw TypeError("iterator result is not an object");if(!n.done)return n;s=n.value,c<2&&(c=0)}else 1===c&&(n=r.return)&&n.call(r),c<2&&(s=TypeError("The iterator does not provide a '"+i+"' method"),c=1);r=t}else if((n=(d=p.n<0)?s:e.call(o,p))!==a)break}catch(n){r=t,c=1,s=n}finally{l=1}}return{value:n,done:d}}}(e,i,r),!0),l}var a={};function c(){}function s(){}function l(){}n=Object.getPrototypeOf;var u=[][o]?n(n([][o]())):(G(n={},o,function(){return this}),n),d=l.prototype=c.prototype=Object.create(u);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,G(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return s.prototype=l,G(d,"constructor",l),G(l,"constructor",s),s.displayName="GeneratorFunction",G(l,i,"GeneratorFunction"),G(d),G(d,i,"Generator"),G(d,o,function(){return this}),G(d,"toString",function(){return"[object Generator]"}),(N=function(){return{w:r,m:p}})()}function G(t,n,e,o){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}G=function(t,n,e,o){function r(n,e){G(t,n,function(t){return this._invoke(n,e,t)})}n?i?i(t,n,{value:e,enumerable:!o,configurable:!o,writable:!o}):t[n]=e:(r("next",0),r("throw",1),r("return",2))},G(t,n,e,o)}function V(t,n,e,o,i,r,a){try{var c=t[r](a),s=c.value}catch(t){return void e(t)}c.done?n(s):Promise.resolve(s).then(o,i)}function q(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,Q(o.key),o)}}function Q(t){var n=function(t){if("object"!=W(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var e=n.call(t,"string");if("object"!=W(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==W(n)?n:n+""}function Y(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Y=function(){return!!t})()}function J(t){return J=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},J(t)}function $(t,n){return $=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},$(t,n)}var Z=function(t){function n(t){var e;return function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n),(e=function(t,n,e){return n=J(n),function(t,n){if(n&&("object"==W(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Y()?Reflect.construct(n,e||[],J(t).constructor):n.apply(t,e))}(this,n)).config=t,e.audioContext=null,e.audioQueue=[],e.isPlaying=!1,e.isProcessingQueue=!1,e.currentSource=null,e}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),n&&$(t,n)}(n,t),e=n,o=[{key:"playAudio",value:function(t){var n=this;try{var e=this.createAudioBlob(t);this.audioQueue.push(e),this.isPlaying||this.isProcessingQueue||this.currentSource||setTimeout(function(){return n.processQueue()},50)}catch(t){this.emit("playbackError",t)}}},{key:"createAudioBlob",value:function(t){var n=new Uint8Array(t);if(n.length>=4){if(82===n[0]&&73===n[1]&&70===n[2]&&70===n[3])return new Blob([t],{type:"audio/wav"});if(255===n[0]&&!(224&~n[1]))return new Blob([t],{type:"audio/mpeg"});if(79===n[0]&&103===n[1]&&103===n[2]&&83===n[3])return new Blob([t],{type:"audio/ogg"})}return new Blob([t],{type:"audio/wav"})}},{key:"processQueue",value:(i=N().m(function t(){var n,e,o,i,r,a,c,s,l=this;return N().w(function(t){for(;;)switch(t.p=t.n){case 0:if(!this.isProcessingQueue&&0!==this.audioQueue.length){t.n=1;break}return t.a(2);case 1:if(this.isProcessingQueue=!0,n=this.audioQueue.shift()){t.n=2;break}return this.isProcessingQueue=!1,t.a(2);case 2:if(t.p=2,e=!this.isPlaying&&null===this.currentSource,this.audioContext||(this.audioContext=new(window.AudioContext||window.webkitAudioContext)),"suspended"!==(o=this.audioContext).state){t.n=3;break}return t.n=3,o.resume();case 3:return t.n=4,n.arrayBuffer();case 4:return i=t.v,t.n=5,o.decodeAudioData(i);case 5:r=t.v,a=e&&!this.isPlaying&&null===this.currentSource,(c=o.createBufferSource()).buffer=r,c.connect(o.destination),this.currentSource=c,this.isPlaying=!0,a&&this.emit("playbackStarted"),c.onended=function(){l.currentSource=null,l.isProcessingQueue=!1,l.audioQueue.length>0?setTimeout(function(){return l.processQueue()},50):setTimeout(function(){0!==l.audioQueue.length||l.currentSource||(l.isPlaying=!1,l.emit("playbackStopped"))},100)},c.start(),t.n=7;break;case 6:t.p=6,s=t.v,this.currentSource=null,this.emit("playbackError",s),this.audioQueue.length>0?(this.isProcessingQueue=!1,setTimeout(function(){return l.processQueue()},100)):(this.isPlaying=!1,this.isProcessingQueue=!1,this.emit("playbackStopped"));case 7:return t.a(2)}},t,this,[[2,6]])}),r=function(){var t=this,n=arguments;return new Promise(function(e,o){var r=i.apply(t,n);function a(t){V(r,e,o,a,c,"next",t)}function c(t){V(r,e,o,a,c,"throw",t)}a(void 0)})},function(){return r.apply(this,arguments)})},{key:"stop",value:function(){this.stopImmediate()}},{key:"stopImmediate",value:function(){var t=this.isPlaying||null!==this.currentSource;if(this.currentSource){try{this.currentSource.stop()}catch(t){}this.currentSource=null}this.isPlaying=!1,this.isProcessingQueue=!1,this.audioQueue=[],t&&this.emit("playbackStopped")}},{key:"getStatus",value:function(){return{isPlaying:this.isPlaying,isProcessingQueue:this.isProcessingQueue,queueLength:this.audioQueue.length,audioContextState:this.audioContext?this.audioContext.state:"closed"}}},{key:"destroy",value:function(){this.stop(),this.audioContext&&"closed"!==this.audioContext.state&&(this.audioContext.close(),this.audioContext=null)}}],o&&q(e.prototype,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,o,i,r}(c);function X(t){return X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},X(t)}function tt(){var t,n,e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",i=e.toStringTag||"@@toStringTag";function r(e,o,i,r){var s=o&&o.prototype instanceof c?o:c,l=Object.create(s.prototype);return nt(l,"_invoke",function(e,o,i){var r,c,s,l=0,u=i||[],d=!1,p={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(n,e){return r=n,c=0,s=t,p.n=e,a}};function f(e,o){for(c=e,s=o,n=0;!d&&l&&!i&&n<u.length;n++){var i,r=u[n],f=p.p,g=r[2];e>3?(i=g===o)&&(s=r[(c=r[4])?5:(c=3,3)],r[4]=r[5]=t):r[0]<=f&&((i=e<2&&f<r[1])?(c=0,p.v=o,p.n=r[1]):f<g&&(i=e<3||r[0]>o||o>g)&&(r[4]=e,r[5]=o,p.n=g,c=0))}if(i||e>1)return a;throw d=!0,o}return function(i,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&f(u,g),c=u,s=g;(n=c<2?t:s)||!d;){r||(c?c<3?(c>1&&(p.n=-1),f(c,s)):p.n=s:p.v=s);try{if(l=2,r){if(c||(i="next"),n=r[i]){if(!(n=n.call(r,s)))throw TypeError("iterator result is not an object");if(!n.done)return n;s=n.value,c<2&&(c=0)}else 1===c&&(n=r.return)&&n.call(r),c<2&&(s=TypeError("The iterator does not provide a '"+i+"' method"),c=1);r=t}else if((n=(d=p.n<0)?s:e.call(o,p))!==a)break}catch(n){r=t,c=1,s=n}finally{l=1}}return{value:n,done:d}}}(e,i,r),!0),l}var a={};function c(){}function s(){}function l(){}n=Object.getPrototypeOf;var u=[][o]?n(n([][o]())):(nt(n={},o,function(){return this}),n),d=l.prototype=c.prototype=Object.create(u);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,nt(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return s.prototype=l,nt(d,"constructor",l),nt(l,"constructor",s),s.displayName="GeneratorFunction",nt(l,i,"GeneratorFunction"),nt(d),nt(d,i,"Generator"),nt(d,o,function(){return this}),nt(d,"toString",function(){return"[object Generator]"}),(tt=function(){return{w:r,m:p}})()}function nt(t,n,e,o){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}nt=function(t,n,e,o){function r(n,e){nt(t,n,function(t){return this._invoke(n,e,t)})}n?i?i(t,n,{value:e,enumerable:!o,configurable:!o,writable:!o}):t[n]=e:(r("next",0),r("throw",1),r("return",2))},nt(t,n,e,o)}function et(t,n,e,o,i,r,a){try{var c=t[r](a),s=c.value}catch(t){return void e(t)}c.done?n(s):Promise.resolve(s).then(o,i)}function ot(t){return function(){var n=this,e=arguments;return new Promise(function(o,i){var r=t.apply(n,e);function a(t){et(r,o,i,a,c,"next",t)}function c(t){et(r,o,i,a,c,"throw",t)}a(void 0)})}}function it(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);n&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),e.push.apply(e,o)}return e}function rt(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{};n%2?it(Object(e),!0).forEach(function(n){at(t,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):it(Object(e)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}return t}function at(t,n,e){return(n=st(n))in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function ct(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,st(o.key),o)}}function st(t){var n=function(t){if("object"!=X(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var e=n.call(t,"string");if("object"!=X(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==X(n)?n:n+""}function lt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(lt=function(){return!!t})()}function ut(t){return ut=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ut(t)}function dt(t,n){return dt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},dt(t,n)}var pt=function(t){function n(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n),(t=function(t,n,e){return n=ut(n),function(t,n){if(n&&("object"==X(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,lt()?Reflect.construct(n,e||[],ut(t).constructor):n.apply(t,e))}(this,n)).config=rt({websocketUrl:e.websocketUrl||"wss://speech.talktopc.com/ws/conv",agentId:e.agentId,appId:e.appId,ttpId:e.ttpId,voice:e.voice||"default",language:e.language||"en",sampleRate:e.sampleRate||16e3},e),t.isConnected=!1,t.isRecording=!1,t.isPlaying=!1,t.isDestroyed=!1,t.webSocketManager=new T(rt(rt({},t.config),{},{autoReconnect:!1!==t.config.autoReconnect})),t.audioRecorder=new K(t.config),t.audioPlayer=new Z(t.config),t.setupEventHandlers(),t}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),n&&dt(t,n)}(n,t),e=n,o=[{key:"setupEventHandlers",value:function(){var t=this;this.webSocketManager.on("connected",function(){t.isConnected=!0,t.sendHelloMessage(),t.emit("connected")}),this.webSocketManager.on("disconnected",function(n){t.isConnected=!1,t.isRecording&&t.stopRecording().catch(function(t){console.error("VoiceSDK: Error stopping recording on disconnect:",t)}),t.emit("disconnected",n)}),this.webSocketManager.on("error",function(n){t.emit("error",n)}),this.webSocketManager.on("message",function(n){if("greeting_audio"===n.t&&n.data)try{for(var e=atob(n.data),o=new Uint8Array(e.length),i=0;i<e.length;i++)o[i]=e.charCodeAt(i);t.audioPlayer.playAudio(o),t.emit("greetingStarted")}catch(t){console.error("VoiceSDK: Error playing greeting audio:",t)}else t.emit("message",n)}),this.webSocketManager.on("binaryAudio",function(n){t.audioPlayer.playAudio(n)}),this.webSocketManager.on("bargeIn",function(n){t.emit("bargeIn",n)}),this.webSocketManager.on("stopPlaying",function(n){t.emit("stopPlaying",n),t.audioPlayer.stopImmediate()}),this.audioRecorder.on("recordingStarted",function(){t.isRecording=!0,t.isPlaying&&(t.audioPlayer.stopImmediate(),t.isConnected&&t.webSocketManager.sendMessage({t:"barge_in"})),t.emit("recordingStarted")}),this.audioRecorder.on("recordingStopped",function(){t.isRecording=!1,t.emit("recordingStopped")}),this.audioRecorder.on("audioData",function(n){t.isConnected&&t.webSocketManager.sendBinary(n)}),this.audioPlayer.on("playbackStarted",function(){t.isPlaying=!0,t.emit("playbackStarted"),t.isConnected&&t.webSocketManager.sendMessage({t:"audio_started_playing"})}),this.audioPlayer.on("playbackStopped",function(){t.isPlaying=!1,t.emit("playbackStopped"),t.isConnected&&t.webSocketManager.sendMessage({t:"audio_stopped_playing"})}),this.audioPlayer.on("playbackError",function(n){t.emit("playbackError",n)})}},{key:"connect",value:(l=ot(tt().m(function t(){var n,e;return tt().w(function(t){for(;;)switch(t.p=t.n){case 0:if(!this.isDestroyed){t.n=1;break}return console.warn("VoiceSDK: Cannot connect - SDK is destroyed"),t.a(2,!1);case 1:return t.p=1,n=this.buildWebSocketUrl(),this.webSocketManager.config.websocketUrl=n,t.n=2,this.webSocketManager.connect();case 2:return t.a(2,!0);case 3:return t.p=3,e=t.v,console.error("🔌 VoiceSDK: Connection failed with error:",e),this.emit("error",e),t.a(2,!1)}},t,this,[[1,3]])})),function(){return l.apply(this,arguments)})},{key:"buildWebSocketUrl",value:function(){var t=this.config.websocketUrl,n=new URLSearchParams;if(this.config.agentId&&n.append("agentId",this.config.agentId),this.config.appId&&n.append("appId",this.config.appId),this.config.voice&&"default"!==this.config.voice&&n.append("voice",this.config.voice),this.config.language&&"en"!==this.config.language&&n.append("language",this.config.language),n.toString()){var e=t.includes("?")?"&":"?";t+=e+n.toString()}return t}},{key:"disconnect",value:function(){this.isDestroyed||(this.stopRecording(),this.webSocketManager.disconnect())}},{key:"resetReconnectionAttempts",value:function(){this.isDestroyed||this.webSocketManager.resetReconnectionAttempts()}},{key:"reconnect",value:(s=ot(tt().m(function t(){return tt().w(function(t){for(;;)switch(t.n){case 0:if(!this.isDestroyed){t.n=1;break}return t.a(2,!1);case 1:return this.disconnect(),this.resetReconnectionAttempts(),t.n=2,this.connect();case 2:return t.a(2,t.v)}},t,this)})),function(){return s.apply(this,arguments)})},{key:"startRecording",value:(c=ot(tt().m(function t(){var n;return tt().w(function(t){for(;;)switch(t.p=t.n){case 0:if(this.isConnected){t.n=1;break}throw new Error("Not connected to voice server");case 1:return t.p=1,this.webSocketManager.sendMessage({t:"start_continuous_mode",ttpId:this.generateTtpId(),voice:this.config.voice,language:this.config.language}),t.n=2,this.audioRecorder.start();case 2:return t.a(2,!0);case 3:return t.p=3,n=t.v,console.error("❌ VoiceSDK: Failed to start recording:",n),this.emit("error",n),t.a(2,!1)}},t,this,[[1,3]])})),function(){return c.apply(this,arguments)})},{key:"stopRecording",value:(a=ot(tt().m(function t(){var n;return tt().w(function(t){for(;;)switch(t.p=t.n){case 0:if(this.isRecording){t.n=1;break}return t.a(2);case 1:return t.p=1,this.webSocketManager.sendMessage({t:"stop_continuous_mode",ttpId:this.generateTtpId()}),t.n=2,this.audioRecorder.stop();case 2:return this.audioPlayer.stopImmediate(),t.a(2,!0);case 3:return t.p=3,n=t.v,this.emit("error",n),t.a(2,!1)}},t,this,[[1,3]])})),function(){return a.apply(this,arguments)})},{key:"toggleRecording",value:(r=ot(tt().m(function t(){return tt().w(function(t){for(;;)switch(t.n){case 0:if(!this.isRecording){t.n=2;break}return t.n=1,this.stopRecording();case 1:case 3:return t.a(2,t.v);case 2:return t.n=3,this.startRecording();case 4:return t.a(2)}},t,this)})),function(){return r.apply(this,arguments)})},{key:"stopAudioPlayback",value:function(){this.audioPlayer.stopImmediate()}},{key:"handleBargeIn",value:(i=ot(tt().m(function t(){return tt().w(function(t){for(;;)switch(t.n){case 0:if(this.stopAudioPlayback(),this.isRecording){t.n=1;break}return t.n=1,this.startRecording();case 1:return t.a(2)}},t,this)})),function(){return i.apply(this,arguments)})},{key:"getStatus",value:function(){return{isConnected:this.isConnected,isRecording:this.isRecording,isPlaying:this.isPlaying}}},{key:"updateConfig",value:function(t){this.config=rt(rt({},this.config),t)}},{key:"generateTtpId",value:function(){return"sdk_"+Math.random().toString(36).substr(2,9)+"_"+Date.now()}},{key:"sendHelloMessage",value:function(){if(this.isConnected){var t={t:"hello"};this.config.appId?t.appId=this.config.appId:this.config.ttpId?t.ttpId=this.config.ttpId:t.ttpId=this.generateTtpId();try{this.webSocketManager.sendMessage(t)}catch(t){console.error("VoiceSDK: Failed to send hello message:",t),this.emit("error",t)}}else console.warn("VoiceSDK: Cannot send hello message - not connected")}},{key:"destroy",value:function(){this.isDestroyed||(this.disconnect(),this.isDestroyed=!0,this.audioRecorder.destroy(),this.audioPlayer.destroy(),this.removeAllListeners())}}],o&&ct(e.prototype,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,o,i,r,a,c,s,l}(c);function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function gt(){var t,n,e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",i=e.toStringTag||"@@toStringTag";function r(e,o,i,r){var s=o&&o.prototype instanceof c?o:c,l=Object.create(s.prototype);return ht(l,"_invoke",function(e,o,i){var r,c,s,l=0,u=i||[],d=!1,p={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(n,e){return r=n,c=0,s=t,p.n=e,a}};function f(e,o){for(c=e,s=o,n=0;!d&&l&&!i&&n<u.length;n++){var i,r=u[n],f=p.p,g=r[2];e>3?(i=g===o)&&(s=r[(c=r[4])?5:(c=3,3)],r[4]=r[5]=t):r[0]<=f&&((i=e<2&&f<r[1])?(c=0,p.v=o,p.n=r[1]):f<g&&(i=e<3||r[0]>o||o>g)&&(r[4]=e,r[5]=o,p.n=g,c=0))}if(i||e>1)return a;throw d=!0,o}return function(i,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&f(u,g),c=u,s=g;(n=c<2?t:s)||!d;){r||(c?c<3?(c>1&&(p.n=-1),f(c,s)):p.n=s:p.v=s);try{if(l=2,r){if(c||(i="next"),n=r[i]){if(!(n=n.call(r,s)))throw TypeError("iterator result is not an object");if(!n.done)return n;s=n.value,c<2&&(c=0)}else 1===c&&(n=r.return)&&n.call(r),c<2&&(s=TypeError("The iterator does not provide a '"+i+"' method"),c=1);r=t}else if((n=(d=p.n<0)?s:e.call(o,p))!==a)break}catch(n){r=t,c=1,s=n}finally{l=1}}return{value:n,done:d}}}(e,i,r),!0),l}var a={};function c(){}function s(){}function l(){}n=Object.getPrototypeOf;var u=[][o]?n(n([][o]())):(ht(n={},o,function(){return this}),n),d=l.prototype=c.prototype=Object.create(u);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,ht(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return s.prototype=l,ht(d,"constructor",l),ht(l,"constructor",s),s.displayName="GeneratorFunction",ht(l,i,"GeneratorFunction"),ht(d),ht(d,i,"Generator"),ht(d,o,function(){return this}),ht(d,"toString",function(){return"[object Generator]"}),(gt=function(){return{w:r,m:p}})()}function ht(t,n,e,o){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}ht=function(t,n,e,o){function r(n,e){ht(t,n,function(t){return this._invoke(n,e,t)})}n?i?i(t,n,{value:e,enumerable:!o,configurable:!o,writable:!o}):t[n]=e:(r("next",0),r("throw",1),r("return",2))},ht(t,n,e,o)}function vt(t,n,e,o,i,r,a){try{var c=t[r](a),s=c.value}catch(t){return void e(t)}c.done?n(s):Promise.resolve(s).then(o,i)}function mt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);n&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),e.push.apply(e,o)}return e}function yt(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{};n%2?mt(Object(e),!0).forEach(function(n){bt(t,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):mt(Object(e)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}return t}function bt(t,n,e){return(n=wt(n))in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function xt(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,wt(o.key),o)}}function wt(t){var n=function(t){if("object"!=ft(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var e=n.call(t,"string");if("object"!=ft(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ft(n)?n:n+""}function kt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(kt=function(){return!!t})()}function St(t){return St=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},St(t)}function Ct(t,n){return Ct=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},Ct(t,n)}var Ot=function(t){function n(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n);var o=(t=function(t,n,e){return n=St(n),function(t,n){if(n&&("object"==ft(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,kt()?Reflect.construct(n,e||[],St(t).constructor):n.apply(t,e))}(this,n)).readScriptTagConfig();return t.config=yt({baseWsUrl:"wss://backend.talktopc.com/chat/websocket",appId:e.appId||o.appId,agentId:e.agentId||o.agentId,conversationId:void 0!==e.conversationId?e.conversationId:t.getPersistedConversationId(),forceConversationId:e.forceConversationId,queue:[],inFlight:!1},e),t.fullResponseBuffer="",t}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),n&&Ct(t,n)}(n,t),e=n,o=[{key:"readScriptTagConfig",value:function(){try{var t=Array.from(document.getElementsByTagName("script")).reverse().find(function(t){return t.dataset&&(t.dataset.appId||t.dataset.agentId)||t.src&&t.src.includes("agent-widget")});return t?{appId:t.dataset.appId,agentId:t.dataset.agentId}:{}}catch(t){return{}}}},{key:"buildWebSocketUrl",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.config.baseWsUrl,n=new URLSearchParams;return this.config.appId&&n.append("appId",this.config.appId),this.config.agentId&&n.append("agentId",this.config.agentId),this.config.conversationId&&n.append("conversationId",this.config.conversationId),"".concat(t,"?").concat(n.toString())}},{key:"sendMessage",value:(i=gt().m(function t(n){var e=this;return gt().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){if(n&&n.trim())if(e.config.appId&&e.config.agentId){var i={text:n,resolve:t,reject:o};e.config.inFlight?e.config.queue.push(i):e.executeTask(i)}else o(new Error("Missing appId or agentId"));else o(new Error("Message is empty"))}))},t)}),r=function(){var t=this,n=arguments;return new Promise(function(e,o){var r=i.apply(t,n);function a(t){vt(r,e,o,a,c,"next",t)}function c(t){vt(r,e,o,a,c,"throw",t)}a(void 0)})},function(t){return r.apply(this,arguments)})},{key:"executeTask",value:function(t){var n=this;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 o,i=this.buildWebSocketUrl(this.config.baseWsUrl),r=this.config.baseWsUrl.endsWith("/websocket")?this.config.baseWsUrl.replace(/\/websocket$/,""):"".concat(this.config.baseWsUrl,"/websocket"),a=this.buildWebSocketUrl(r),c=!1,s=!1,l=null,u=function(e){if(!s)try{var o={message:t.text},i=n.config.forceConversationId||n.config.conversationId;i&&(o.conversationId=i,n.config.forceConversationId&&!n.config.conversationId&&(n.config.conversationId=i,n.persistConversationId(i))),console.log("🔍 TextChatSDK sending payload:",o,"conversationId in config:",n.config.conversationId),e.send(JSON.stringify(o)),s=!0}catch(o){t.reject(o),n.emit("error",o);try{e.close()}catch(t){}}},d=function(t){return function(){n.config.conversationId?u(t):l=setTimeout(function(){return u(t)},200)}},p=function(e){return function(o){try{try{console.log("🔎 [TextChatSDK] WS <= raw:",o.data)}catch(t){}var i=JSON.parse(o.data);try{console.log("🔎 [TextChatSDK] WS <= parsed:",i)}catch(t){}if("hello"===i.type&&i.conversationId){if(console.log("🔍 TextChatSDK received conversationId:",i.conversationId),n.config.conversationId=i.conversationId,n.persistConversationId(i.conversationId),n.emit&&n.emit("conversationIdChanged",i.conversationId),!s&&e&&1===e.readyState){if(l)try{clearTimeout(l)}catch(t){}u(e)}return}if(!n.config.conversationId&&i.conversationId&&(console.log("🔍 TextChatSDK captured conversationId from message:",i.conversationId),n.config.conversationId=i.conversationId,n.persistConversationId(i.conversationId)),"chunk"===i.type&&"string"==typeof i.content)n.fullResponseBuffer+=i.content,n.emit("chunk",i.content);else if("done"===i.type){try{var r=i.text||i.content||i.answer||i.message||"";r&&!n.fullResponseBuffer&&(n.fullResponseBuffer=r)}catch(t){}!n.config.conversationId&&i.conversationId&&(console.log("🔍 TextChatSDK captured conversationId from done:",i.conversationId),n.config.conversationId=i.conversationId),n.persistConversationId(n.config.conversationId),n.emit("done",{text:n.fullResponseBuffer}),t.resolve({conversationId:n.config.conversationId,fullText:n.fullResponseBuffer});try{e.close()}catch(t){}}else if("error"===i.type){var a=new Error(i.message||"Server error");n.emit("error",a),t.reject(a);try{e.close()}catch(t){}}}catch(t){}}},f=function(){n.config.inFlight=!1,n.drainQueue()},g=new WebSocket(i);g.onopen=d(g),g.onmessage=p(g),g.onerror=(o=g,function(e){if(!c){c=!0;try{o.close()}catch(t){}var i=new WebSocket(a);return i.onopen=d(i),i.onmessage=p(i),i.onerror=function(e){n.emit("error",e),t.reject(e)},void(i.onclose=f)}n.emit("error",e),t.reject(e)}),g.onclose=f}},{key:"drainQueue",value:function(){if(0!==this.config.queue.length&&!this.config.inFlight){var t=this.config.queue.shift();this.executeTask(t)}}},{key:"persistConversationId",value:function(t){try{t&&localStorage.setItem("ttp_text_chat_conversation_id",t)}catch(t){}}},{key:"getPersistedConversationId",value:function(){try{return localStorage.getItem("ttp_text_chat_conversation_id")||null}catch(t){return null}}},{key:"updateConfig",value:function(t){this.config=yt(yt({},this.config),t)}},{key:"destroy",value:function(){this.config.queue=[],this.config.inFlight=!1,this.removeAllListeners()}}],o&&xt(e.prototype,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,o,i,r}(c),It=e(540),Bt=e(848);function jt(t){return jt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jt(t)}function Et(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);n&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),e.push.apply(e,o)}return e}function Pt(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{};n%2?Et(Object(e),!0).forEach(function(n){Tt(t,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Et(Object(e)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}return t}function Tt(t,n,e){return(n=function(t){var n=function(t){if("object"!=jt(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var e=n.call(t,"string");if("object"!=jt(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==jt(n)?n:n+""}(n))in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function Ft(){var t,n,e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",i=e.toStringTag||"@@toStringTag";function r(e,o,i,r){var s=o&&o.prototype instanceof c?o:c,l=Object.create(s.prototype);return At(l,"_invoke",function(e,o,i){var r,c,s,l=0,u=i||[],d=!1,p={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(n,e){return r=n,c=0,s=t,p.n=e,a}};function f(e,o){for(c=e,s=o,n=0;!d&&l&&!i&&n<u.length;n++){var i,r=u[n],f=p.p,g=r[2];e>3?(i=g===o)&&(s=r[(c=r[4])?5:(c=3,3)],r[4]=r[5]=t):r[0]<=f&&((i=e<2&&f<r[1])?(c=0,p.v=o,p.n=r[1]):f<g&&(i=e<3||r[0]>o||o>g)&&(r[4]=e,r[5]=o,p.n=g,c=0))}if(i||e>1)return a;throw d=!0,o}return function(i,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&f(u,g),c=u,s=g;(n=c<2?t:s)||!d;){r||(c?c<3?(c>1&&(p.n=-1),f(c,s)):p.n=s:p.v=s);try{if(l=2,r){if(c||(i="next"),n=r[i]){if(!(n=n.call(r,s)))throw TypeError("iterator result is not an object");if(!n.done)return n;s=n.value,c<2&&(c=0)}else 1===c&&(n=r.return)&&n.call(r),c<2&&(s=TypeError("The iterator does not provide a '"+i+"' method"),c=1);r=t}else if((n=(d=p.n<0)?s:e.call(o,p))!==a)break}catch(n){r=t,c=1,s=n}finally{l=1}}return{value:n,done:d}}}(e,i,r),!0),l}var a={};function c(){}function s(){}function l(){}n=Object.getPrototypeOf;var u=[][o]?n(n([][o]())):(At(n={},o,function(){return this}),n),d=l.prototype=c.prototype=Object.create(u);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,At(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return s.prototype=l,At(d,"constructor",l),At(l,"constructor",s),s.displayName="GeneratorFunction",At(l,i,"GeneratorFunction"),At(d),At(d,i,"Generator"),At(d,o,function(){return this}),At(d,"toString",function(){return"[object Generator]"}),(Ft=function(){return{w:r,m:p}})()}function At(t,n,e,o){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}At=function(t,n,e,o){function r(n,e){At(t,n,function(t){return this._invoke(n,e,t)})}n?i?i(t,n,{value:e,enumerable:!o,configurable:!o,writable:!o}):t[n]=e:(r("next",0),r("throw",1),r("return",2))},At(t,n,e,o)}function Dt(t,n,e,o,i,r,a){try{var c=t[r](a),s=c.value}catch(t){return void e(t)}c.done?n(s):Promise.resolve(s).then(o,i)}function Mt(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var o,i,r,a,c=[],s=!0,l=!1;try{if(r=(e=e.call(t)).next,0===n){if(Object(e)!==e)return;s=!1}else for(;!(s=(o=r.call(e)).done)&&(c.push(o.value),c.length!==n);s=!0);}catch(t){l=!0,i=t}finally{try{if(!s&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(l)throw i}}return c}}(t,n)||function(t,n){if(t){if("string"==typeof t)return zt(t,n);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?zt(t,n):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function zt(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,o=Array(n);e<n;e++)o[e]=t[e];return o}const Rt=function(t){var n=t.websocketUrl,e=t.agentId,o=t.voice,i=void 0===o?"default":o,r=t.language,a=void 0===r?"en":r,c=t.autoReconnect,s=void 0===c||c,l=t.onConnected,u=t.onDisconnected,d=t.onRecordingStarted,p=t.onRecordingStopped,f=t.onPlaybackStarted,g=t.onPlaybackStopped,h=t.onError,v=t.onMessage,m=t.onBargeIn,y=t.onStopPlaying,b=t.className,x=void 0===b?"":b,w=t.style,k=void 0===w?{}:w,S=t.children,C=Mt((0,It.useState)(!1),2),O=C[0],I=C[1],B=Mt((0,It.useState)(!1),2),j=B[0],E=B[1],P=Mt((0,It.useState)(!1),2),T=(P[0],P[1]),F=Mt((0,It.useState)("Disconnected"),2),A=(F[0],F[1]),D=(0,It.useRef)(null);(0,It.useEffect)(function(){console.log("🎙️ VoiceButton: Creating VoiceSDK instance for ".concat(n)),D.current&&(console.log("🎙️ VoiceButton: Destroying existing VoiceSDK instance"),D.current.destroy(),D.current=null);var t=new pt({websocketUrl:n,agentId:e,voice:i,language:a,autoReconnect:s});return t.on("connected",function(){I(!0),A("Connected"),null==l||l()}),t.on("disconnected",function(){I(!1),A("Disconnected"),null==u||u()}),t.on("recordingStarted",function(){E(!0),null==d||d()}),t.on("recordingStopped",function(){E(!1),null==p||p()}),t.on("playbackStarted",function(){T(!0),null==f||f()}),t.on("playbackStopped",function(){T(!1),null==g||g()}),t.on("error",function(t){null==h||h(t)}),t.on("message",function(t){null==v||v(t)}),t.on("bargeIn",function(t){null==m||m(t)}),t.on("stopPlaying",function(t){null==y||y(t)}),D.current=t,t.connect(),function(){console.log("🎙️ VoiceButton: Cleaning up VoiceSDK instance for ".concat(n)),D.current&&(D.current.destroy(),D.current=null)}},[n,e,i,a]);var M=function(){var t,n=(t=Ft().m(function t(){var n;return Ft().w(function(t){for(;;)switch(t.p=t.n){case 0:if(D.current){t.n=1;break}return t.a(2);case 1:return t.p=1,t.n=2,D.current.toggleRecording();case 2:t.n=4;break;case 3:t.p=3,n=t.v,console.error("Error toggling recording:",n);case 4:return t.a(2)}},t,null,[[1,3]])}),function(){var n=this,e=arguments;return new Promise(function(o,i){var r=t.apply(n,e);function a(t){Dt(r,o,i,a,c,"next",t)}function c(t){Dt(r,o,i,a,c,"throw",t)}a(void 0)})});return function(){return n.apply(this,arguments)}}(),z=(0,Bt.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,Bt.jsx)("div",{style:{fontSize:"20px"},children:j?"🔴":"🎤"}),(0,Bt.jsx)("div",{children:j?"Stop Listening":"Start Listening"})]});return(0,Bt.jsx)("button",{className:"voice-button ".concat(j?"recording":""," ").concat(x),style:Pt({padding:"12px 24px",border:"none",borderRadius:"8px",backgroundColor:j?"#dc3545":"#007bff",color:"white",cursor:"pointer",fontSize:"16px",fontWeight:"500",transition:"all 0.2s ease"},k),onClick:M,disabled:!O,children:S||z})};function _t(t){return _t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_t(t)}function Ht(){var t,n,e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",i=e.toStringTag||"@@toStringTag";function r(e,o,i,r){var s=o&&o.prototype instanceof c?o:c,l=Object.create(s.prototype);return Lt(l,"_invoke",function(e,o,i){var r,c,s,l=0,u=i||[],d=!1,p={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(n,e){return r=n,c=0,s=t,p.n=e,a}};function f(e,o){for(c=e,s=o,n=0;!d&&l&&!i&&n<u.length;n++){var i,r=u[n],f=p.p,g=r[2];e>3?(i=g===o)&&(s=r[(c=r[4])?5:(c=3,3)],r[4]=r[5]=t):r[0]<=f&&((i=e<2&&f<r[1])?(c=0,p.v=o,p.n=r[1]):f<g&&(i=e<3||r[0]>o||o>g)&&(r[4]=e,r[5]=o,p.n=g,c=0))}if(i||e>1)return a;throw d=!0,o}return function(i,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&f(u,g),c=u,s=g;(n=c<2?t:s)||!d;){r||(c?c<3?(c>1&&(p.n=-1),f(c,s)):p.n=s:p.v=s);try{if(l=2,r){if(c||(i="next"),n=r[i]){if(!(n=n.call(r,s)))throw TypeError("iterator result is not an object");if(!n.done)return n;s=n.value,c<2&&(c=0)}else 1===c&&(n=r.return)&&n.call(r),c<2&&(s=TypeError("The iterator does not provide a '"+i+"' method"),c=1);r=t}else if((n=(d=p.n<0)?s:e.call(o,p))!==a)break}catch(n){r=t,c=1,s=n}finally{l=1}}return{value:n,done:d}}}(e,i,r),!0),l}var a={};function c(){}function s(){}function l(){}n=Object.getPrototypeOf;var u=[][o]?n(n([][o]())):(Lt(n={},o,function(){return this}),n),d=l.prototype=c.prototype=Object.create(u);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,Lt(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return s.prototype=l,Lt(d,"constructor",l),Lt(l,"constructor",s),s.displayName="GeneratorFunction",Lt(l,i,"GeneratorFunction"),Lt(d),Lt(d,i,"Generator"),Lt(d,o,function(){return this}),Lt(d,"toString",function(){return"[object Generator]"}),(Ht=function(){return{w:r,m:p}})()}function Lt(t,n,e,o){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Lt=function(t,n,e,o){function r(n,e){Lt(t,n,function(t){return this._invoke(n,e,t)})}n?i?i(t,n,{value:e,enumerable:!o,configurable:!o,writable:!o}):t[n]=e:(r("next",0),r("throw",1),r("return",2))},Lt(t,n,e,o)}function Ut(t,n,e,o,i,r,a){try{var c=t[r](a),s=c.value}catch(t){return void e(t)}c.done?n(s):Promise.resolve(s).then(o,i)}function Kt(t){return function(){var n=this,e=arguments;return new Promise(function(o,i){var r=t.apply(n,e);function a(t){Ut(r,o,i,a,c,"next",t)}function c(t){Ut(r,o,i,a,c,"throw",t)}a(void 0)})}}function Wt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);n&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),e.push.apply(e,o)}return e}function Nt(t,n,e){return(n=Vt(n))in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function Gt(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,Vt(o.key),o)}}function Vt(t){var n=function(t){if("object"!=_t(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var e=n.call(t,"string");if("object"!=_t(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_t(n)?n:n+""}var qt=function(){return t=function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.options=function(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{};n%2?Wt(Object(e),!0).forEach(function(n){Nt(t,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Wt(Object(e)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}return t}({websocketUrl:n.websocketUrl||"wss://speech.talktopc.com/ws/conv",agentId:n.agentId,voice:n.voice||"default",language:n.language||"en",container:n.container||document.body,buttonText:n.buttonText||"Start Listening",buttonClass:n.buttonClass||"voice-button"},n),this.isConnected=!1,this.isRecording=!1,this.isPlaying=!1,this.voiceSDK=new pt({websocketUrl:this.options.websocketUrl,agentId:this.options.agentId,voice:this.options.voice,language:this.options.language}),this.setupEventListeners(),this.createButton(),this.connect()},n=[{key:"setupEventListeners",value:function(){var t=this;this.voiceSDK.on("connected",function(){var n,e;t.isConnected=!0,t.updateButton(),null===(n=(e=t.options).onConnected)||void 0===n||n.call(e)}),this.voiceSDK.on("disconnected",function(){var n,e;t.isConnected=!1,t.updateButton(),null===(n=(e=t.options).onDisconnected)||void 0===n||n.call(e)}),this.voiceSDK.on("recordingStarted",function(){var n,e;t.isRecording=!0,t.updateButton(),null===(n=(e=t.options).onRecordingStarted)||void 0===n||n.call(e)}),this.voiceSDK.on("recordingStopped",function(){var n,e;t.isRecording=!1,t.updateButton(),null===(n=(e=t.options).onRecordingStopped)||void 0===n||n.call(e)}),this.voiceSDK.on("playbackStarted",function(){var n,e;t.isPlaying=!0,null===(n=(e=t.options).onPlaybackStarted)||void 0===n||n.call(e)}),this.voiceSDK.on("playbackStopped",function(){var n,e;t.isPlaying=!1,null===(n=(e=t.options).onPlaybackStopped)||void 0===n||n.call(e)}),this.voiceSDK.on("error",function(n){var e,o;null===(e=(o=t.options).onError)||void 0===e||e.call(o,n)}),this.voiceSDK.on("message",function(n){var e,o;null===(e=(o=t.options).onMessage)||void 0===e||e.call(o,n)}),this.voiceSDK.on("bargeIn",function(n){var e,o;null===(e=(o=t.options).onBargeIn)||void 0===e||e.call(o,n)}),this.voiceSDK.on("stopPlaying",function(n){var e,o;null===(e=(o=t.options).onStopPlaying)||void 0===e||e.call(o,n)})}},{key:"createButton",value:function(){var t=this;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",function(){return t.toggleRecording()}),this.options.container.appendChild(this.button),this.updateButton()}},{key:"updateButton",value:function(){if(this.button){var t=this.isRecording?"🔴":"🎤",n=this.isRecording?"Stop Listening":"Start Listening";this.button.innerHTML='\n <span style="font-size: 20px;">'.concat(t,"</span>\n <span>").concat(n,"</span>\n "),this.button.disabled=!this.isConnected,this.button.style.backgroundColor=this.isRecording?"#dc3545":this.isConnected?"#007bff":"#6c757d"}}},{key:"connect",value:(o=Kt(Ht().m(function t(){var n;return Ht().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,this.voiceSDK.connect();case 1:t.n=3;break;case 2:t.p=2,n=t.v,console.error("Failed to connect:",n);case 3:return t.a(2)}},t,this,[[0,2]])})),function(){return o.apply(this,arguments)})},{key:"toggleRecording",value:(e=Kt(Ht().m(function t(){var n;return Ht().w(function(t){for(;;)switch(t.p=t.n){case 0:if(this.voiceSDK){t.n=1;break}return t.a(2);case 1:return t.p=1,t.n=2,this.voiceSDK.toggleRecording();case 2:t.n=4;break;case 3:t.p=3,n=t.v,console.error("Error toggling recording:",n);case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return e.apply(this,arguments)})},{key:"getStatus",value:function(){return{isConnected:this.isConnected,isRecording:this.isRecording,isPlaying:this.isPlaying}}},{key:"updateConfig",value:function(t){this.voiceSDK.updateConfig(t)}},{key:"destroy",value:function(){this.button&&this.button.parentNode&&this.button.parentNode.removeChild(this.button),this.voiceSDK&&this.voiceSDK.destroy()}}],n&&Gt(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,e,o}();function Qt(t){return Qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Qt(t)}function Yt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);n&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),e.push.apply(e,o)}return e}function Jt(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{};n%2?Yt(Object(e),!0).forEach(function(n){$t(t,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Yt(Object(e)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}return t}function $t(t,n,e){return(n=an(n))in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function Zt(){var t,n,e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",i=e.toStringTag||"@@toStringTag";function r(e,o,i,r){var s=o&&o.prototype instanceof c?o:c,l=Object.create(s.prototype);return Xt(l,"_invoke",function(e,o,i){var r,c,s,l=0,u=i||[],d=!1,p={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(n,e){return r=n,c=0,s=t,p.n=e,a}};function f(e,o){for(c=e,s=o,n=0;!d&&l&&!i&&n<u.length;n++){var i,r=u[n],f=p.p,g=r[2];e>3?(i=g===o)&&(s=r[(c=r[4])?5:(c=3,3)],r[4]=r[5]=t):r[0]<=f&&((i=e<2&&f<r[1])?(c=0,p.v=o,p.n=r[1]):f<g&&(i=e<3||r[0]>o||o>g)&&(r[4]=e,r[5]=o,p.n=g,c=0))}if(i||e>1)return a;throw d=!0,o}return function(i,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&f(u,g),c=u,s=g;(n=c<2?t:s)||!d;){r||(c?c<3?(c>1&&(p.n=-1),f(c,s)):p.n=s:p.v=s);try{if(l=2,r){if(c||(i="next"),n=r[i]){if(!(n=n.call(r,s)))throw TypeError("iterator result is not an object");if(!n.done)return n;s=n.value,c<2&&(c=0)}else 1===c&&(n=r.return)&&n.call(r),c<2&&(s=TypeError("The iterator does not provide a '"+i+"' method"),c=1);r=t}else if((n=(d=p.n<0)?s:e.call(o,p))!==a)break}catch(n){r=t,c=1,s=n}finally{l=1}}return{value:n,done:d}}}(e,i,r),!0),l}var a={};function c(){}function s(){}function l(){}n=Object.getPrototypeOf;var u=[][o]?n(n([][o]())):(Xt(n={},o,function(){return this}),n),d=l.prototype=c.prototype=Object.create(u);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,Xt(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return s.prototype=l,Xt(d,"constructor",l),Xt(l,"constructor",s),s.displayName="GeneratorFunction",Xt(l,i,"GeneratorFunction"),Xt(d),Xt(d,i,"Generator"),Xt(d,o,function(){return this}),Xt(d,"toString",function(){return"[object Generator]"}),(Zt=function(){return{w:r,m:p}})()}function Xt(t,n,e,o){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Xt=function(t,n,e,o){function r(n,e){Xt(t,n,function(t){return this._invoke(n,e,t)})}n?i?i(t,n,{value:e,enumerable:!o,configurable:!o,writable:!o}):t[n]=e:(r("next",0),r("throw",1),r("return",2))},Xt(t,n,e,o)}function tn(t,n,e,o,i,r,a){try{var c=t[r](a),s=c.value}catch(t){return void e(t)}c.done?n(s):Promise.resolve(s).then(o,i)}function nn(t){return function(){var n=this,e=arguments;return new Promise(function(o,i){var r=t.apply(n,e);function a(t){tn(r,o,i,a,c,"next",t)}function c(t){tn(r,o,i,a,c,"throw",t)}a(void 0)})}}function en(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function on(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,an(o.key),o)}}function rn(t,n,e){return n&&on(t.prototype,n),e&&on(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function an(t){var n=function(t){if("object"!=Qt(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var e=n.call(t,"string");if("object"!=Qt(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Qt(n)?n:n+""}var cn=function(){return rn(function t(n){en(this,t),console.log("🚀 AgentSDK v2.1.8 initialized with config:",n),this.config=n,this.voiceSDK=null,this.isConnected=!1,this.isListening=!1,this.onConnected=function(){},this.onDisconnected=function(){},this.onError=function(t){return console.error("SDK Error:",t)},this.onTranscript=function(t){},this.onAgentSpeaking=function(t){}},[{key:"connect",value:(n=nn(Zt().m(function t(n){var e,o=this;return Zt().w(function(t){for(;;)switch(t.p=t.n){case 0:if(t.p=0,n){t.n=1;break}throw new Error("signedUrl is required");case 1:return this.voiceSDK&&(console.log("🔌 AgentSDK: Cleaning up existing connection"),this.voiceSDK.destroy(),this.voiceSDK=null),this.voiceSDK=new pt({websocketUrl:n,autoReconnect:!1,agentId:this.config.agentId,appId:this.config.appId,language:this.config.language||"en"}),this.voiceSDK.on("connected",function(){o.isConnected=!0,o.onConnected()}),this.voiceSDK.on("disconnected",function(){o.isConnected=!1,o.onDisconnected()}),this.voiceSDK.on("error",function(t){o.onError(t)}),this.voiceSDK.on("message",function(t){o.handleWebSocketMessage(t)}),this.voiceSDK.on("recordingStarted",function(){o.isListening=!0}),this.voiceSDK.on("recordingStopped",function(){o.isListening=!1}),this.voiceSDK.on("playbackStarted",function(){o.onAgentSpeaking(!0)}),this.voiceSDK.on("playbackStopped",function(){o.onAgentSpeaking(!1)}),t.n=2,this.voiceSDK.connect();case 2:t.n=4;break;case 3:throw t.p=3,e=t.v,this.onError(e),e;case 4:return t.a(2)}},t,this,[[0,3]])})),function(t){return n.apply(this,arguments)})},{key:"handleWebSocketMessage",value:function(t){switch(t.type){case"connected":console.log("Session started successfully");break;case"user_transcript":this.onTranscript(t.user_transcription||t.text);break;case"agent_response":case"barge_in":case"stop_playing":break;case"error":this.onError(new Error(t.message))}}},{key:"startListening",value:(t=nn(Zt().m(function t(){var n;return Zt().w(function(t){for(;;)switch(t.p=t.n){case 0:if(console.log("🎤 AgentSDK: startListening() called"),!this.voiceSDK){t.n=5;break}return t.p=1,console.log("🎤 AgentSDK: Starting recording..."),t.n=2,this.voiceSDK.startRecording();case 2:console.log("✅ AgentSDK: Recording started successfully"),t.n=4;break;case 3:throw t.p=3,n=t.v,console.error("❌ AgentSDK: Failed to start recording:",n),n;case 4:t.n=6;break;case 5:throw console.error("❌ AgentSDK: No voiceSDK instance available"),new Error("No voiceSDK instance available");case 6:return t.a(2)}},t,this,[[1,3]])})),function(){return t.apply(this,arguments)})},{key:"stopListening",value:function(){this.voiceSDK&&this.voiceSDK.stopRecording()}},{key:"updateVariables",value:function(t){this.voiceSDK&&this.isConnected&&this.voiceSDK.webSocketManager.sendMessage({t:"update_variables",variables:t})}},{key:"disconnect",value:function(){this.voiceSDK&&(this.voiceSDK.destroy(),this.voiceSDK=null),this.isConnected=!1,this.isListening=!1}}]);var t,n}(),sn=function(){return rn(function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(en(this,t),this.config=this.mergeWithDefaults(n),this.sdk=new cn(this.config),this.isOpen=!1,this.isActive=!1,this.setupEventHandlers(),this.createWidget(),this.config.behavior.startOpen||this.config.behavior.autoOpen){var e=document.getElementById("agent-panel");e&&(this.isOpen=!0,e.classList.add("open"))}},[{key:"mergeWithDefaults",value:function(t){var n,e,o,i,r,a,c,s,l,u,d,p,f,g,h,v,m,y,b,x,w,k,S,C,O,I,B,j,E,P,T,F,A,D,M,z,R,_,H,L,U,K,W,N,G,V,q,Q,Y,J,$,Z,X,tt,nt=t.position||"bottom-right";if("string"==typeof nt){var et=nt.split("-");nt={vertical:et[0]||"bottom",horizontal:et[1]||"right",offset:t.positionOffset||{x:20,y:20}}}var ot=t.primaryColor||(null===(n=t.button)||void 0===n?void 0:n.primaryColor)||"#4F46E5";return Jt({agentId:t.agentId,appId:t.appId,getSessionUrl:t.getSessionUrl,websocketUrl:t.websocketUrl,demo:!1!==t.demo,direction:t.direction||"ltr",icon:Jt({type:(null===(e=t.icon)||void 0===e?void 0:e.type)||"microphone",customImage:(null===(o=t.icon)||void 0===o?void 0:o.customImage)||null,emoji:(null===(i=t.icon)||void 0===i?void 0:i.emoji)||"🎤",text:(null===(r=t.icon)||void 0===r?void 0:r.text)||"AI",size:(null===(a=t.icon)||void 0===a?void 0:a.size)||"medium",backgroundColor:(null===(c=t.icon)||void 0===c?void 0:c.backgroundColor)||null},t.icon),position:Jt({vertical:nt.vertical||"bottom",horizontal:nt.horizontal||"right",offset:nt.offset||{x:20,y:20}},"object"===Qt(t.position)?t.position:{}),button:Jt({size:(null===(s=t.button)||void 0===s?void 0:s.size)||"medium",shape:(null===(l=t.button)||void 0===l?void 0:l.shape)||"circle",backgroundColor:(null===(u=t.button)||void 0===u?void 0:u.backgroundColor)||(null===(d=t.icon)||void 0===d?void 0:d.backgroundColor)||ot,hoverColor:(null===(p=t.button)||void 0===p?void 0:p.hoverColor)||"#7C3AED",shadow:!1!==(null===(f=t.button)||void 0===f?void 0:f.shadow),shadowColor:(null===(g=t.button)||void 0===g?void 0:g.shadowColor)||"rgba(0,0,0,0.15)",primaryColor:(null===(h=t.button)||void 0===h?void 0:h.backgroundColor)||(null===(v=t.icon)||void 0===v?void 0:v.backgroundColor)||ot},t.button),panel:Jt({width:(null===(m=t.panel)||void 0===m?void 0:m.width)||350,height:(null===(y=t.panel)||void 0===y?void 0:y.height)||500,borderRadius:(null===(b=t.panel)||void 0===b?void 0:b.borderRadius)||12,backgroundColor:(null===(x=t.panel)||void 0===x?void 0:x.backgroundColor)||"#FFFFFF",backdropFilter:(null===(w=t.panel)||void 0===w?void 0:w.backdropFilter)||null,border:(null===(k=t.panel)||void 0===k?void 0:k.border)||"1px solid rgba(0,0,0,0.1)",micButtonColor:(null===(S=t.panel)||void 0===S?void 0:S.micButtonColor)||ot,micButtonActiveColor:(null===(C=t.panel)||void 0===C?void 0:C.micButtonActiveColor)||"#EF4444",micButtonHint:Jt({text:(null===(O=t.panel)||void 0===O||null===(O=O.micButtonHint)||void 0===O?void 0:O.text)||"Click the button to start voice conversation",color:(null===(I=t.panel)||void 0===I||null===(I=I.micButtonHint)||void 0===I?void 0:I.color)||"#6B7280",fontSize:(null===(B=t.panel)||void 0===B||null===(B=B.micButtonHint)||void 0===B?void 0:B.fontSize)||"12px"},null===(j=t.panel)||void 0===j?void 0:j.micButtonHint)},t.panel),header:Jt({title:(null===(E=t.header)||void 0===E?void 0:E.title)||"Voice Assistant",showTitle:!1!==(null===(P=t.header)||void 0===P?void 0:P.showTitle),backgroundColor:(null===(T=t.header)||void 0===T?void 0:T.backgroundColor)||(null===(F=t.button)||void 0===F?void 0:F.backgroundColor)||ot,textColor:(null===(A=t.header)||void 0===A?void 0:A.textColor)||"#FFFFFF",showCloseButton:!1!==(null===(D=t.header)||void 0===D?void 0:D.showCloseButton)},t.header),messages:Jt({userBackgroundColor:(null===(M=t.messages)||void 0===M?void 0:M.userBackgroundColor)||"#E5E7EB",agentBackgroundColor:(null===(z=t.messages)||void 0===z?void 0:z.agentBackgroundColor)||"#F3F4F6",systemBackgroundColor:(null===(R=t.messages)||void 0===R?void 0:R.systemBackgroundColor)||"#DCFCE7",errorBackgroundColor:(null===(_=t.messages)||void 0===_?void 0:_.errorBackgroundColor)||"#FEE2E2",textColor:(null===(H=t.messages)||void 0===H?void 0:H.textColor)||"#1F2937",fontSize:(null===(L=t.messages)||void 0===L?void 0:L.fontSize)||"14px",borderRadius:(null===(U=t.messages)||void 0===U?void 0:U.borderRadius)||8},t.messages),animation:Jt({enableHover:!1!==(null===(K=t.animation)||void 0===K?void 0:K.enableHover),enablePulse:!1!==(null===(W=t.animation)||void 0===W?void 0:W.enablePulse),enableSlide:!1!==(null===(N=t.animation)||void 0===N?void 0:N.enableSlide),duration:(null===(G=t.animation)||void 0===G?void 0:G.duration)||.3},t.animation),behavior:Jt({autoOpen:(null===(V=t.behavior)||void 0===V?void 0:V.autoOpen)||!1,startOpen:(null===(q=t.behavior)||void 0===q?void 0:q.startOpen)||!1,hidden:(null===(Q=t.behavior)||void 0===Q?void 0:Q.hidden)||!1,autoConnect:(null===(Y=t.behavior)||void 0===Y?void 0:Y.autoConnect)||!1,showWelcomeMessage:!1!==(null===(J=t.behavior)||void 0===J?void 0:J.showWelcomeMessage),welcomeMessage:(null===($=t.behavior)||void 0===$?void 0:$.welcomeMessage)||"Hello! How can I help you today?"},t.behavior),accessibility:Jt({ariaLabel:(null===(Z=t.accessibility)||void 0===Z?void 0:Z.ariaLabel)||"Voice Assistant",ariaDescription:(null===(X=t.accessibility)||void 0===X?void 0:X.ariaDescription)||"Click to open voice assistant",keyboardNavigation:!1!==(null===(tt=t.accessibility)||void 0===tt?void 0:tt.keyboardNavigation)},t.accessibility),customStyles:t.customStyles||"",variables:t.variables||{},primaryColor:ot},"string"==typeof t.position?{positionString:t.position}:{})}},{key:"setupEventHandlers",value:function(){var t=this;this.sdk.onConnected=function(){t.updateStatus("connected"),t.config.behavior.showWelcomeMessage&&t.addMessage("system",t.config.behavior.welcomeMessage)},this.sdk.onDisconnected=function(){t.updateStatus("disconnected"),t.isActive=!1,t.updateMicButtonState(!1),t.showError("Conversation ended. Click to start a new conversation.")},this.sdk.onError=function(n){t.showError(n.message)},this.sdk.onTranscript=function(n){t.addMessage("user",n)},this.sdk.onAgentSpeaking=function(n){n?t.showAgentThinking():t.hideAgentThinking()}}},{key:"createWidget",value:function(){var t=document.createElement("div");if(t.id="agent-widget",t.innerHTML=this.generateWidgetHTML(),document.body.appendChild(t),this.setupWidgetEvents(),this.config.behavior.startOpen||this.config.behavior.autoOpen){var n=document.getElementById("agent-panel");n&&(this.isOpen=!0,n.classList.add("open"))}}},{key:"generateWidgetHTML",value:function(){this.config.position;var t=this.config.button,n=this.config.icon,e=this.config.panel,o=this.config.header,i=(this.config.animation,{small:50,medium:60,large:70,xl:80}[t.size]||60),r={small:20,medium:28,large:36,xl:44}[n.size]||28,a=this.generatePositionStyles(),c=this.generateIconHTML(r);return"\n <style>\n ".concat(this.generateCSS(a,i,r),"\n ").concat(this.config.customStyles,"\n </style>\n \n ").concat(this.config.behavior.hidden?"":'\n <button id="agent-button" \n aria-label="'.concat(this.config.accessibility.ariaLabel,'"\n aria-description="').concat(this.config.accessibility.ariaDescription,'">\n ').concat(c,"\n </button>\n "),'\n \n <div id="agent-panel">\n ').concat(o.showTitle?'\n <div id="agent-header" style="direction: '.concat(this.config.direction,';">\n ').concat("rtl"===this.config.direction?"\n ".concat(o.showCloseButton?'<button id="agent-close">&times;</button>':"",'\n <h3 style="margin: 0; color: ').concat(o.textColor,';">').concat(o.title,"</h3>\n "):'\n <h3 style="margin: 0; color: '.concat(o.textColor,';">').concat(o.title,"</h3>\n ").concat(o.showCloseButton?'<button id="agent-close">&times;</button>':"","\n "),"\n </div>\n "):"",'\n \n <div id="agent-messages"></div>\n \n <div id="agent-controls">\n <div style="display: flex; flex-direction: column; align-items: center; gap: 8px;">\n <button id="agent-mic-button" \n aria-label="Start/Stop Voice Recording">\n ').concat(c,"\n </button>\n ").concat(e.micButtonHint.text&&e.micButtonHint.text.trim()?'\n <div id="agent-mic-hint" style="color: '.concat(e.micButtonHint.color,"; font-size: ").concat(e.micButtonHint.fontSize,'; text-align: center; max-width: 200px;">\n ').concat(e.micButtonHint.text,"\n </div>\n "):"","\n </div>\n </div>\n </div>\n ")}},{key:"generatePositionStyles",value:function(){var t=this.config.position,n=t.offset||{x:20,y:20},e="";return"top"===t.vertical?e+="top: ".concat(n.y,"px;"):"bottom"===t.vertical?e+="bottom: ".concat(n.y,"px;"):"center"===t.vertical&&(e+="top: 50%; transform: translateY(-50%);"),"left"===t.horizontal?e+="left: ".concat(n.x,"px;"):"right"===t.horizontal?e+="right: ".concat(n.x,"px;"):"center"===t.horizontal&&(e+="left: 50%; transform: translateX(-50%);"),e}},{key:"generateIconHTML",value:function(t){var n=this.config.icon;switch(n.type){case"custom":return'<img src="'.concat(n.customImage,'" alt="Voice Assistant" style="width: ').concat(t,"px; height: ").concat(t,'px; object-fit: contain;" />');case"emoji":return'<span style="font-size: '.concat(t,'px; line-height: 1;">').concat(n.emoji,"</span>");case"text":return'<span style="font-size: '.concat(Math.floor(.6*t),'px; font-weight: bold; color: white;">').concat(n.text,"</span>");default:return'<svg viewBox="0 0 24 24" style="width: '.concat(t,"px; height: ").concat(t,'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>')}}},{key:"generateCSS",value:function(t,n,e){var o=this.config.button,i=this.config.panel,r=this.config.header,a=this.config.messages,c=this.config.animation,s=o.backgroundColor||o.primaryColor,l=r.backgroundColor,u=i.micButtonColor||o.primaryColor,d=i.micButtonActiveColor||"#EF4444";return"\n #agent-widget {\n position: fixed;\n ".concat(t,'\n z-index: 10000;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n -webkit-transform: translateZ(0);\n transform: translateZ(0);\n will-change: transform;\n }\n \n @media (max-width: 768px) {\n #agent-widget {\n ').concat("right"===this.config.position.horizontal||"string"==typeof this.config.position&&this.config.position.includes("right")?"right: 10px; left: auto;":"left: 10px; right: auto;","\n ").concat("bottom"===this.config.position.vertical||"string"==typeof this.config.position&&this.config.position.includes("bottom")?"bottom: 10px; top: auto;":"top"===this.config.position.vertical||"string"==typeof this.config.position&&this.config.position.includes("top")?"top: 10px; bottom: auto;":"","\n }\n }\n \n @media (max-width: 480px) {\n #agent-widget {\n ").concat("right"===this.config.position.horizontal||"string"==typeof this.config.position&&this.config.position.includes("right")?"right: 5px; left: auto;":"left: 5px; right: auto;","\n ").concat("bottom"===this.config.position.vertical||"string"==typeof this.config.position&&this.config.position.includes("bottom")?"bottom: 5px; top: auto;":"top"===this.config.position.vertical||"string"==typeof this.config.position&&this.config.position.includes("top")?"top: 5px; bottom: auto;":"","\n }\n }\n \n #agent-button {\n width: ").concat(n,"px;\n height: ").concat(n,"px;\n border-radius: ").concat("circle"===o.shape?"50%":"square"===o.shape?"0":"12px",";\n background: ").concat(s,";\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all ").concat(c.duration,"s ease;\n ").concat(o.shadow?"box-shadow: 0 4px 12px ".concat(o.shadowColor,";"):"","\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 }\n \n @media (max-width: 768px) {\n #agent-button {\n min-width: 56px;\n min-height: 56px;\n box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);\n }\n \n #agent-panel {\n position: fixed !important;\n width: calc(100vw - 20px) !important;\n max-width: calc(100vw - 20px) !important;\n max-height: calc(100vh - 80px) !important;\n left: 10px !important;\n right: 10px !important;\n bottom: calc(").concat(n,"px + 10px) !important;\n top: auto !important;\n transform: none !important;\n margin: 0 !important;\n }\n \n #agent-header {\n padding: 12px 14px;\n min-height: 56px;\n }\n \n #agent-header h3 {\n font-size: 15px;\n }\n \n #agent-close {\n width: 32px;\n height: 32px;\n min-width: 32px;\n min-height: 32px;\n font-size: 20px;\n }\n \n #agent-messages {\n padding: 12px;\n gap: 10px;\n }\n \n .message {\n padding: 10px;\n font-size: 14px;\n max-width: 85%;\n }\n \n #agent-controls {\n padding: 12px;\n }\n \n #agent-mic-button {\n min-width: 56px;\n min-height: 56px;\n width: 56px;\n height: 56px;\n }\n \n #agent-mic-hint {\n font-size: 12px;\n padding: 8px;\n }\n }\n \n @media (max-width: 480px) {\n #agent-button {\n min-width: 60px;\n min-height: 60px;\n }\n \n #agent-panel {\n position: fixed !important;\n width: calc(100vw - 10px) !important;\n max-width: calc(100vw - 10px) !important;\n left: 5px !important;\n right: 5px !important;\n max-height: calc(100vh - 70px) !important;\n bottom: calc(").concat(n,"px + 5px) !important;\n top: auto !important;\n transform: none !important;\n margin: 0 !important;\n }\n \n #agent-header {\n padding: 10px 12px;\n min-height: 52px;\n }\n \n #agent-header h3 {\n font-size: 14px;\n }\n \n #agent-messages {\n padding: 10px;\n }\n \n .message {\n font-size: 13px;\n max-width: 90%;\n padding: 8px;\n }\n \n #agent-mic-button {\n min-width: 60px;\n min-height: 60px;\n width: 60px;\n height: 60px;\n }\n }\n \n ").concat(c.enableHover?"\n #agent-button:hover {\n background: ".concat(o.hoverColor,";\n transform: scale(1.05);\n ").concat(o.shadow?"box-shadow: 0 8px 20px ".concat(o.shadowColor,";"):"","\n }\n "):"","\n \n #agent-panel {\n display: none;\n position: absolute;\n bottom: ").concat(this.config.behavior.hidden?20:n+20,"px;\n ").concat("right"===this.config.position.horizontal?"right: 0;":"left: 0;","\n width: ").concat(i.width,"px;\n height: ").concat(i.height,"px;\n background: ").concat(i.backgroundColor,";\n border-radius: ").concat(i.borderRadius,"px;\n border: ").concat(i.border,";\n flex-direction: column;\n overflow: hidden;\n ").concat(i.backdropFilter?"backdrop-filter: ".concat(i.backdropFilter,";"):"","\n ").concat(c.enableSlide?"transition: all ".concat(c.duration,"s ease;"):"","\n }\n \n #agent-panel.open {\n display: flex;\n ").concat(c.enableSlide?"transform: translateY(0); opacity: 1;":"","\n }\n \n #agent-header {\n background: ").concat(l,";\n color: ").concat(r.textColor,";\n padding: 16px;\n display: flex;\n flex-direction: ").concat("rtl"===this.config.direction?"row-reverse":"row",";\n justify-content: space-between;\n align-items: center;\n border-radius: ").concat(i.borderRadius,"px ").concat(i.borderRadius,"px 0 0;\n direction: ").concat(this.config.direction,";\n }\n \n #agent-header h3 {\n margin: 0;\n flex: 1;\n text-align: ").concat("rtl"===this.config.direction?"right":"left",";\n }\n \n #agent-close {\n background: none;\n border: none;\n color: ").concat(r.textColor,";\n cursor: pointer;\n font-size: 24px;\n padding: 0;\n width: 24px;\n height: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n \n #agent-messages {\n flex: 1;\n overflow-y: auto;\n padding: 16px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n \n .message {\n padding: 12px;\n border-radius: ").concat(a.borderRadius,"px;\n max-width: 80%;\n font-size: ").concat(a.fontSize,";\n color: ").concat(a.textColor,";\n }\n \n .message.user {\n background: ").concat(a.userBackgroundColor,";\n align-self: flex-end;\n }\n \n .message.agent {\n background: ").concat(a.agentBackgroundColor,";\n align-self: flex-start;\n }\n \n .message.system {\n background: ").concat(a.systemBackgroundColor,";\n align-self: flex-start;\n font-style: italic;\n }\n \n .error-message {\n background: ").concat(a.errorBackgroundColor,";\n color: #991B1B;\n padding: 12px;\n border-radius: ").concat(a.borderRadius,"px;\n margin: 8px;\n }\n \n #agent-controls {\n padding: 16px;\n border-top: 1px solid #E5E7EB;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n \n #agent-controls > div {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n }\n \n #agent-mic-hint {\n text-align: center;\n line-height: 1.4;\n }\n \n #agent-mic-button {\n width: ").concat(n,"px;\n height: ").concat(n,"px;\n border-radius: ").concat("circle"===o.shape?"50%":"square"===o.shape?"0":"12px",";\n border: none;\n background: ").concat(u,";\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all ").concat(c.duration,"s ease;\n }\n \n #agent-mic-button.active {\n background: ").concat(d,";\n ").concat(c.enablePulse?"\n animation: pulse 1.5s infinite;\n ":"","\n }\n \n ").concat(c.enablePulse?"\n @keyframes pulse {\n 0%, 100% { transform: scale(1); }\n 50% { transform: scale(1.05); }\n }\n ":"","\n \n .agent-thinking {\n font-style: italic;\n color: #6B7280;\n }\n ")}},{key:"setupWidgetEvents",value:function(){var t=this,n=document.getElementById("agent-button");n&&(n.onclick=function(){return t.togglePanel()});var e=document.getElementById("agent-close");e&&(e.onclick=function(){return t.togglePanel()}),document.getElementById("agent-mic-button").onclick=function(){return t.toggleVoice()},this.config.accessibility.keyboardNavigation&&this.setupKeyboardNavigation()}},{key:"setupKeyboardNavigation",value:function(){var t=this;document.addEventListener("keydown",function(n){"Escape"===n.key&&t.isOpen&&t.togglePanel()})}},{key:"togglePanel",value:function(){this.isOpen=!this.isOpen,document.getElementById("agent-panel").classList.toggle("open")}},{key:"toggleVoice",value:(n=nn(Zt().m(function t(){var n,e,o,i;return Zt().w(function(t){for(;;)switch(t.p=t.n){case 0:if(this.isActive){t.n=13;break}return t.p=1,console.log("🎤 Starting voice session..."),t.n=2,this.getSignedUrl();case 2:return n=t.v,console.log("🔗 Got signed URL:",n),t.n=3,this.sdk.connect(n);case 3:e=t.v,console.log("✅ Connected to WebSocket, connected:",e),o=0;case 4:if(this.sdk.isConnected||!(o<50)){t.n=6;break}return t.n=5,new Promise(function(t){return setTimeout(t,100)});case 5:o++,t.n=4;break;case 6:if(!this.sdk.isConnected){t.n=8;break}return console.log("✅ WebSocket ready, starting listening..."),t.n=7,this.sdk.startListening();case 7:console.log("🎤 Started listening"),this.isActive=!0,this.updateMicButtonState(!0),this.addMessage("system","🎤 Listening... Click mic to stop"),t.n=10;break;case 8:return console.warn("⚠️ Connection not fully ready, but trying to start listening anyway..."),t.n=9,this.sdk.startListening();case 9:console.log("🎤 Started listening"),this.isActive=!0,this.updateMicButtonState(!0),this.addMessage("system","🎤 Listening... Click mic to stop");case 10:t.n=12;break;case 11:t.p=11,i=t.v,console.error("❌ Failed to start:",i),this.showError(i.message);case 12:t.n=14;break;case 13:console.log("🔇 Stopping voice session..."),this.sdk.stopListening(),this.sdk.disconnect(),this.isActive=!1,this.updateMicButtonState(!1),this.addMessage("system","🔇 Stopped listening");case 14:return t.a(2)}},t,this,[[1,11]])})),function(){return n.apply(this,arguments)})},{key:"updateMicButtonState",value:function(t){var n=document.getElementById("agent-mic-button");if(n)if(this.config.icon.size,t){if(n.classList.add("active"),n.title="Click to stop listening","microphone"===this.config.icon.type||"custom"===this.config.icon.type){var e=n.querySelector("svg")||n.querySelector("img");e&&"svg"===e.tagName&&(e.innerHTML='\n <rect x="6" y="6" width="12" height="12" rx="2"/>\n <path d="M9 9h6"/>\n ')}}else if(n.classList.remove("active"),n.title="Click to start listening","microphone"===this.config.icon.type){var o=n.querySelector("svg");o&&(o.innerHTML='\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 ')}}},{key:"getSignedUrl",value:(t=nn(Zt().m(function t(){var n,e,o,i,r,a,c;return Zt().w(function(t){for(;;)switch(t.n){case 0:if(this.config.getSessionUrl){t.n=2;break}if(this.config.agentId){t.n=1;break}throw new Error("agentId is required");case 1:return n=this.config.websocketUrl||"wss://speech.talktopc.com/ws/conv",(e=new URLSearchParams).append("agentId",this.config.agentId),this.config.appId&&e.append("appId",this.config.appId),!1!==this.config.demo&&e.append("demo","true"),t.a(2,"".concat(n,"?").concat(e.toString()));case 2:if("string"!=typeof this.config.getSessionUrl){t.n=6;break}return o={agentId:this.config.agentId,variables:this.config.variables||{}},this.config.appId&&(o.appId=this.config.appId),t.n=3,fetch(this.config.getSessionUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});case 3:if((i=t.v).ok){t.n=4;break}throw new Error("Failed to get session URL: ".concat(i.statusText));case 4:return t.n=5,i.json();case 5:return r=t.v,t.a(2,r.signedUrl||r.wsUrl||r.url);case 6:if("function"!=typeof this.config.getSessionUrl){t.n=8;break}return a={agentId:this.config.agentId,variables:this.config.variables||{}},this.config.appId&&(a.appId=this.config.appId),t.n=7,this.config.getSessionUrl(a);case 7:return c=t.v,t.a(2,"string"==typeof c?c:c.signedUrl||c.wsUrl||c.url);case 8:throw new Error("getSessionUrl must be a string (backend URL), a function, or omitted (for direct connection with agentId/appId)");case 9:return t.a(2)}},t,this)})),function(){return t.apply(this,arguments)})},{key:"addMessage",value:function(t,n){var e=document.getElementById("agent-messages"),o=document.createElement("div");o.className="message ".concat(t),o.textContent=n,e.appendChild(o),e.scrollTop=e.scrollHeight}},{key:"showAgentThinking",value:function(){var t=document.getElementById("agent-messages"),n=document.createElement("div");n.className="message agent agent-thinking",n.id="thinking-indicator",n.textContent="Agent is speaking...",t.appendChild(n),t.scrollTop=t.scrollHeight}},{key:"hideAgentThinking",value:function(){var t=document.getElementById("thinking-indicator");t&&t.remove()}},{key:"showError",value:function(t){var n=document.getElementById("agent-messages"),e=document.createElement("div");e.className="error-message",e.textContent=t,n.appendChild(e)}},{key:"updateStatus",value:function(t){}},{key:"updateConfig",value:function(t){var n,e=Jt({},this.config);t.panel&&(e.panel=Jt(Jt({},this.config.panel),t.panel),t.panel.micButtonHint&&(e.panel.micButtonHint=Jt(Jt({},null===(n=this.config.panel)||void 0===n?void 0:n.micButtonHint),t.panel.micButtonHint))),t.button&&(e.button=Jt(Jt({},this.config.button),t.button)),t.header&&(e.header=Jt(Jt({},this.config.header),t.header)),t.icon&&(e.icon=Jt(Jt({},this.config.icon),t.icon)),t.messages&&(e.messages=Jt(Jt({},this.config.messages),t.messages)),void 0!==t.direction&&(e.direction=t.direction),Object.keys(t).forEach(function(n){["panel","button","header","icon","messages","direction"].includes(n)||(e[n]=t[n])}),this.config=this.mergeWithDefaults(e);var o=document.getElementById("agent-widget");o&&o.remove(),this.createWidget()}},{key:"destroy",value:function(){var t=document.getElementById("agent-widget");t&&t.remove(),this.sdk&&this.sdk.disconnect()}}]);var t,n}();function ln(t){return ln="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ln(t)}function un(){var t,n,e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",i=e.toStringTag||"@@toStringTag";function r(e,o,i,r){var s=o&&o.prototype instanceof c?o:c,l=Object.create(s.prototype);return dn(l,"_invoke",function(e,o,i){var r,c,s,l=0,u=i||[],d=!1,p={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(n,e){return r=n,c=0,s=t,p.n=e,a}};function f(e,o){for(c=e,s=o,n=0;!d&&l&&!i&&n<u.length;n++){var i,r=u[n],f=p.p,g=r[2];e>3?(i=g===o)&&(s=r[(c=r[4])?5:(c=3,3)],r[4]=r[5]=t):r[0]<=f&&((i=e<2&&f<r[1])?(c=0,p.v=o,p.n=r[1]):f<g&&(i=e<3||r[0]>o||o>g)&&(r[4]=e,r[5]=o,p.n=g,c=0))}if(i||e>1)return a;throw d=!0,o}return function(i,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&f(u,g),c=u,s=g;(n=c<2?t:s)||!d;){r||(c?c<3?(c>1&&(p.n=-1),f(c,s)):p.n=s:p.v=s);try{if(l=2,r){if(c||(i="next"),n=r[i]){if(!(n=n.call(r,s)))throw TypeError("iterator result is not an object");if(!n.done)return n;s=n.value,c<2&&(c=0)}else 1===c&&(n=r.return)&&n.call(r),c<2&&(s=TypeError("The iterator does not provide a '"+i+"' method"),c=1);r=t}else if((n=(d=p.n<0)?s:e.call(o,p))!==a)break}catch(n){r=t,c=1,s=n}finally{l=1}}return{value:n,done:d}}}(e,i,r),!0),l}var a={};function c(){}function s(){}function l(){}n=Object.getPrototypeOf;var u=[][o]?n(n([][o]())):(dn(n={},o,function(){return this}),n),d=l.prototype=c.prototype=Object.create(u);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,dn(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return s.prototype=l,dn(d,"constructor",l),dn(l,"constructor",s),s.displayName="GeneratorFunction",dn(l,i,"GeneratorFunction"),dn(d),dn(d,i,"Generator"),dn(d,o,function(){return this}),dn(d,"toString",function(){return"[object Generator]"}),(un=function(){return{w:r,m:p}})()}function dn(t,n,e,o){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}dn=function(t,n,e,o){function r(n,e){dn(t,n,function(t){return this._invoke(n,e,t)})}n?i?i(t,n,{value:e,enumerable:!o,configurable:!o,writable:!o}):t[n]=e:(r("next",0),r("throw",1),r("return",2))},dn(t,n,e,o)}function pn(t,n,e,o,i,r,a){try{var c=t[r](a),s=c.value}catch(t){return void e(t)}c.done?n(s):Promise.resolve(s).then(o,i)}function fn(t){return function(){var n=this,e=arguments;return new Promise(function(o,i){var r=t.apply(n,e);function a(t){pn(r,o,i,a,c,"next",t)}function c(t){pn(r,o,i,a,c,"throw",t)}a(void 0)})}}function gn(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,hn(o.key),o)}}function hn(t){var n=function(t){if("object"!=ln(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var e=n.call(t,"string");if("object"!=ln(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ln(n)?n:n+""}var vn=function(){return t=function t(n){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.config=n,this.audioStream=null,this.callStartTime=null,this.callTimerInterval=null,this.sdk=null,this.isActive=!1,this.sdk=new cn({agentId:n.agentId,appId:n.appId,getSessionUrl:n.getSessionUrl,websocketUrl:n.websocketUrl,variables:n.variables||{},language:n.language||"en"}),this.setupSDKEventHandlers()},n=[{key:"setupSDKEventHandlers",value:function(){var t=this;this.sdk.onTranscript=function(n){t.updateTranscript(n)},this.sdk.onAgentSpeaking=function(t){var n=document.getElementById("voiceAvatarActive");n&&(t?n.classList.add("speaking"):n.classList.remove("speaking"))},this.sdk.onError=function(n){console.error("❌ Voice SDK Error:",n),t.showError(n.message||n)}}},{key:"t",value:function(t){var n,e,o=this.config.language||"en";return((null===(n=this.config.translations)||void 0===n?void 0:n[o])||(null===(e=this.config.translations)||void 0===e?void 0:e.en)||{})[t]||t}},{key:"getTooltip",value:function(t){var n,e=null===(n=this.config.tooltips)||void 0===n?void 0:n[t];return null!=e?e:{mute:this.t("mute"),speaker:this.t("speaker"),endCall:this.t("endCall")}[t]||""}},{key:"generateHTML",value:function(){return'<div class="voice-interface" id="voiceInterface">\n \x3c!-- Before Call State --\x3e\n <div id="voiceIdleState" style="display: flex; flex-direction: column; align-items: center; width: 100%;">\n <div class="voice-avatar" id="voiceAvatar">\n 🤖\n </div>\n <div class="voice-status">\n <div class="voice-status-title">'.concat(this.t("clickToStartCall"),'</div>\n <div class="voice-status-subtitle">').concat(this.t("realTimeVoice"),'</div>\n </div>\n \x3c!-- BIG START CALL BUTTON --\x3e\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.t("startCall"),'</span>\n </button>\n </div>\n \x3c!-- During Call State --\x3e\n <div id="voiceActiveState" style="display: none; flex-direction: column; align-items: center; width: 100%; height: 100%; justify-content: flex-start; overflow: hidden; padding-top: 10px;">\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>')}},{key:"generateCSS",value:function(){var t=this.config.avatarBackgroundColor||"#667eea",n=this.config.avatarActiveBackgroundColor||this.config.avatarBackgroundColor||"#667eea",e=this.config.statusTitleColor||"#1e293b",o=this.config.statusSubtitleColor||"#64748b",i=this.config.startCallButtonColor||"#667eea",r=this.config.startCallButtonTextColor||"#FFFFFF",a=this.config.transcriptBackgroundColor||"#FFFFFF",c=this.config.transcriptTextColor||"#1e293b",s=this.config.transcriptLabelColor||"#94a3b8",l=this.config.controlButtonColor||"#FFFFFF",u=this.config.controlButtonSecondaryColor||"#64748b",d=this.config.endCallButtonColor||"#ef4444";return"\n /* Voice Interface Styles */\n .voice-interface { \n display: none; \n flex: 1; \n flex-direction: column;\n align-items: center; \n justify-content: flex-start; \n padding: 10px 20px 20px 20px; \n background: linear-gradient(180deg, #f8fafc 0%, #e0e7ff 100%);\n overflow: hidden;\n min-height: 0;\n }\n .voice-interface.active { display: flex; }\n \n /* Voice Avatar (idle state) */\n .voice-avatar {\n width: 120px;\n height: 120px;\n border-radius: 50%;\n background: linear-gradient(135deg, ".concat(t," 0%, ").concat(n," 100%);\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 56px;\n margin-top: 10px;\n margin-bottom: 16px;\n box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);\n transition: all 0.3s ease;\n flex-shrink: 0;\n }\n \n /* Voice Avatar (active state with animations) */\n .voice-avatar-active {\n width: 120px;\n height: 120px;\n border-radius: 50%;\n background: linear-gradient(135deg, ").concat(t," 0%, ").concat(n," 100%);\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 56px;\n margin-top: 10px;\n margin-bottom: 16px;\n position: relative;\n box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);\n animation: avatarPulse 2s ease-in-out infinite;\n flex-shrink: 0;\n }\n \n @keyframes avatarPulse {\n 0%, 100% { \n transform: scale(1);\n box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);\n }\n 50% { \n transform: scale(1.05);\n box-shadow: 0 15px 50px rgba(102, 126, 234, 0.5);\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 */\n .voice-status {\n text-align: center;\n margin-bottom: 10px;\n flex-shrink: 0;\n }\n \n .voice-status-title {\n font-size: 18px;\n font-weight: 600;\n color: ").concat(e,";\n margin-bottom: 4px;\n }\n \n .voice-status-subtitle {\n font-size: 12px;\n color: ").concat(o,";\n }\n \n /* Start Call Button */\n .start-call-btn {\n margin-top: 20px;\n width: 200px;\n height: 56px;\n border-radius: 28px;\n border: none;\n background: ").concat(i,";\n color: ").concat(r,";\n font-size: 18px;\n font-weight: 600;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 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:hover {\n transform: translateY(-4px);\n box-shadow: 0 16px 40px rgba(102, 126, 234, 0.5);\n }\n \n .start-call-btn:active {\n transform: translateY(-2px);\n }\n \n /* Voice Transcript */\n .voice-transcript {\n background: ").concat(a,";\n padding: 12px;\n border-radius: 12px;\n max-width: 300px;\n width: 100%;\n margin-bottom: 12px;\n min-height: 50px;\n max-height: 90px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);\n flex-shrink: 1;\n overflow-y: auto;\n }\n \n .transcript-label {\n font-size: 10px;\n color: ").concat(s,";\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n margin-bottom: 6px;\n }\n \n .transcript-text {\n font-size: 14px;\n color: ").concat(c,";\n line-height: 1.5;\n min-height: 30px;\n }\n \n .transcript-text.empty {\n color: #cbd5e1;\n font-style: italic;\n }\n \n /* Voice Controls */\n .voice-controls {\n display: flex;\n gap: 12px;\n align-items: center;\n flex-shrink: 0;\n }\n \n .voice-control-btn {\n width: 72px;\n height: 72px;\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.primary {\n width: 80px;\n height: 80px;\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);\n }\n \n .voice-control-btn.primary:hover {\n transform: scale(1.05);\n box-shadow: 0 10px 25px rgba(102, 126, 234, 0.5);\n }\n \n .voice-control-btn.primary.active {\n background: ").concat("#ef4444"===d?"white":l,";\n animation: recordingPulse 1.5s ease-in-out infinite;\n box-shadow: 0 8px 20px ").concat("#ef4444"===d?"rgba(239, 68, 68, 0.4)":"rgba(0, 0, 0, 0.2)",";\n }\n \n @keyframes recordingPulse {\n 0%, 100% { \n box-shadow: 0 8px 20px rgba(239, 68, 68, 0.4);\n }\n 50% { \n box-shadow: 0 8px 30px rgba(239, 68, 68, 0.7);\n }\n }\n \n .voice-control-btn.secondary {\n background: ").concat(l,";\n color: ").concat(u,";\n box-shadow: 0 4px 12px 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: -24px;\n font-size: 12px;\n color: #64748b;\n font-weight: 500;\n }\n \n @media (max-width: 768px) {\n .voice-interface {\n padding: 8px 12px 16px 12px;\n }\n \n .voice-avatar,\n .voice-avatar-active {\n width: 100px;\n height: 100px;\n font-size: 48px;\n margin-top: 8px;\n margin-bottom: 12px;\n }\n \n .voice-status-title {\n font-size: 16px;\n }\n \n .voice-status-subtitle {\n font-size: 13px;\n }\n \n .voice-start-call-btn {\n padding: 12px 24px;\n font-size: 15px;\n min-height: 44px;\n }\n \n .voice-transcript-container {\n padding: 12px;\n max-height: 180px;\n }\n \n .voice-transcript-text {\n font-size: 14px;\n line-height: 1.5;\n }\n \n .voice-controls {\n gap: 12px;\n padding: 12px;\n }\n \n .voice-control-btn {\n width: 48px;\n height: 48px;\n min-width: 48px;\n min-height: 48px;\n }\n \n .voice-control-btn.end-call {\n width: 52px;\n height: 52px;\n min-width: 52px;\n min-height: 52px;\n }\n }\n \n @media (max-width: 480px) {\n .voice-interface {\n padding: 6px 10px 12px 10px;\n }\n \n .voice-avatar,\n .voice-avatar-active {\n width: 90px;\n height: 90px;\n font-size: 42px;\n }\n \n .voice-status-title {\n font-size: 15px;\n }\n \n .voice-status-subtitle {\n font-size: 12px;\n }\n \n .voice-start-call-btn {\n padding: 10px 20px;\n font-size: 14px;\n }\n \n .voice-transcript-container {\n padding: 10px;\n max-height: 150px;\n }\n \n .voice-transcript-text {\n font-size: 13px;\n }\n \n .voice-controls {\n gap: 10px;\n padding: 10px;\n }\n \n .voice-control-btn {\n width: 44px;\n height: 44px;\n min-width: 44px;\n min-height: 44px;\n }\n \n .voice-control-btn.end-call {\n width: 48px;\n height: 48px;\n min-width: 48px;\n min-height: 48px;\n }\n }\n ")}},{key:"setupEventHandlers",value:function(t){var n=this,e=document.getElementById("startCallBtn"),o=document.getElementById("endCallBtn"),i=document.getElementById("muteBtn"),r=document.getElementById("speakerBtn");e&&(e.onclick=function(){return n.startVoiceCall()}),o&&(o.onclick=function(){return n.endVoiceCall()}),i&&(i.onclick=function(){return n.toggleMute()}),r&&(r.onclick=function(){return n.toggleSpeaker()})}},{key:"getSignedUrl",value:(o=fn(un().m(function t(){var n,e,o,i,r,a,c;return un().w(function(t){for(;;)switch(t.n){case 0:if(this.config.getSessionUrl){t.n=2;break}if(this.config.agentId){t.n=1;break}throw new Error("agentId is required");case 1:return n=this.config.websocketUrl||"wss://speech.talktopc.com/ws/conv",(e=new URLSearchParams).append("agentId",this.config.agentId),this.config.appId&&e.append("appId",this.config.appId),!1!==this.config.demo&&e.append("demo","true"),t.a(2,"".concat(n,"?").concat(e.toString()));case 2:if("string"!=typeof this.config.getSessionUrl){t.n=6;break}return o={agentId:this.config.agentId,variables:this.config.variables||{}},this.config.appId&&(o.appId=this.config.appId),t.n=3,fetch(this.config.getSessionUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});case 3:if((i=t.v).ok){t.n=4;break}throw new Error("Failed to get session URL: ".concat(i.statusText));case 4:return t.n=5,i.json();case 5:return r=t.v,t.a(2,r.signedUrl||r.wsUrl||r.url);case 6:if("function"!=typeof this.config.getSessionUrl){t.n=8;break}return a={agentId:this.config.agentId,variables:this.config.variables||{}},this.config.appId&&(a.appId=this.config.appId),t.n=7,this.config.getSessionUrl(a);case 7:return c=t.v,t.a(2,"string"==typeof c?c:c.signedUrl||c.wsUrl||c.url);case 8:throw new Error("getSessionUrl must be a string (backend URL), a function, or omitted (for direct connection with agentId/appId)");case 9:return t.a(2)}},t,this)})),function(){return o.apply(this,arguments)})},{key:"startVoiceCall",value:(e=fn(un().m(function t(){var n,e,o,i,r,a,c,s,l,u=this;return un().w(function(t){for(;;)switch(t.p=t.n){case 0:if(!this.isActive){t.n=1;break}return console.log("⚠️ Voice call already active"),t.a(2);case 1:return console.log("🎤 Starting voice call..."),t.p=2,n=document.getElementById("voiceIdleState"),e=document.getElementById("voiceActiveState"),o=document.getElementById("voiceInterface"),n&&(n.style.display="none"),e&&(e.style.display="flex"),o&&(o.scrollTop=0),t.n=3,this.getSignedUrl();case 3:return i=t.v,console.log("🔗 Got signed URL:",i),t.n=4,this.sdk.connect(i);case 4:r=t.v,console.log("✅ Connected to WebSocket, connected:",r),a=0;case 5:if(this.sdk.isConnected||!(a<50)){t.n=7;break}return t.n=6,new Promise(function(t){return setTimeout(t,100)});case 6:a++,t.n=5;break;case 7:if(!this.sdk.isConnected){t.n=9;break}return console.log("✅ WebSocket ready, starting listening..."),t.n=8,this.sdk.startListening();case 8:console.log("🎤 Started listening"),this.isActive=!0,this.callStartTime=Date.now(),this.callTimerInterval=setInterval(function(){var t=Date.now()-u.callStartTime,n=Math.floor(t/6e4),e=Math.floor(t%6e4/1e3),o=document.getElementById("voiceTimer");o&&(o.textContent="".concat(n.toString().padStart(2,"0"),":").concat(e.toString().padStart(2,"0")))},1e3),t.n=11;break;case 9:return console.warn("⚠️ Connection not fully ready, but trying to start listening anyway..."),t.n=10,this.sdk.startListening();case 10:console.log("🎤 Started listening"),this.isActive=!0,this.callStartTime=Date.now(),this.callTimerInterval=setInterval(function(){var t=Date.now()-u.callStartTime,n=Math.floor(t/6e4),e=Math.floor(t%6e4/1e3),o=document.getElementById("voiceTimer");o&&(o.textContent="".concat(n.toString().padStart(2,"0"),":").concat(e.toString().padStart(2,"0")))},1e3);case 11:console.log("✅ Voice call started successfully"),t.n=13;break;case 12:t.p=12,l=t.v,console.error("❌ Error starting voice call:",l),this.showError(l.message||l),c=document.getElementById("voiceIdleState"),s=document.getElementById("voiceActiveState"),c&&(c.style.display="flex"),s&&(s.style.display="none");case 13:return t.a(2)}},t,this,[[2,12]])})),function(){return e.apply(this,arguments)})},{key:"endVoiceCall",value:function(){console.log("🔴 Ending voice call..."),this.sdk&&this.isActive&&(this.sdk.stopListening(),this.sdk.disconnect(),this.isActive=!1),this.audioStream&&(this.audioStream.getTracks().forEach(function(t){return t.stop()}),this.audioStream=null),this.callTimerInterval&&(clearInterval(this.callTimerInterval),this.callTimerInterval=null);var t=document.getElementById("voiceIdleState"),n=document.getElementById("voiceActiveState");t&&(t.style.display="flex"),n&&(n.style.display="none");var e=document.getElementById("transcriptText");e&&(e.textContent=this.t("transcriptWillAppear"),e.classList.add("empty"));var o=document.getElementById("voiceAvatarActive");o&&o.classList.remove("speaking"),console.log("✅ Voice call ended")}},{key:"updateTranscript",value:function(t){var n=document.getElementById("transcriptText");n&&(n.textContent=t,n.classList.remove("empty"))}},{key:"showError",value:function(t){var n=document.getElementById("transcriptText");n&&(n.textContent="".concat(this.t("error"),": ").concat(t),n.classList.remove("empty"))}},{key:"toggleMute",value:function(){if(this.sdk&&this.isActive){var t=null;if(this.sdk.voiceSDK&&this.sdk.voiceSDK.audioRecorder&&this.sdk.voiceSDK.audioRecorder.mediaStream&&(t=this.sdk.voiceSDK.audioRecorder.mediaStream.getAudioTracks()[0]),!t&&this.audioStream&&(t=this.audioStream.getAudioTracks()[0]),t){t.enabled=!t.enabled;var n=document.getElementById("muteBtn"),e=null==n?void 0:n.querySelector(".mute-icon"),o=null==n?void 0:n.querySelector(".mute-cross");n&&e&&o&&(t.enabled?(e.style.stroke="",o.style.display="none",n.classList.remove("muted")):(e.style.stroke="#9ca3af",o.style.display="block",n.classList.add("muted"))),console.log(t.enabled?"🔊 Unmuted":"🔇 Muted")}else console.warn("⚠️ No audio track available for mute toggle")}}},{key:"toggleSpeaker",value:function(){console.log("🔊 Speaker toggle")}},{key:"destroy",value:function(){this.isActive&&this.endVoiceCall(),this.audioStream&&(this.audioStream.getTracks().forEach(function(t){return t.stop()}),this.audioStream=null),this.callTimerInterval&&(clearInterval(this.callTimerInterval),this.callTimerInterval=null),this.sdk&&(this.sdk.disconnect(),this.sdk=null)}}],n&&gn(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,e,o}();function mn(t){return mn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mn(t)}function yn(){var t,n,e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",i=e.toStringTag||"@@toStringTag";function r(e,o,i,r){var s=o&&o.prototype instanceof c?o:c,l=Object.create(s.prototype);return bn(l,"_invoke",function(e,o,i){var r,c,s,l=0,u=i||[],d=!1,p={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(n,e){return r=n,c=0,s=t,p.n=e,a}};function f(e,o){for(c=e,s=o,n=0;!d&&l&&!i&&n<u.length;n++){var i,r=u[n],f=p.p,g=r[2];e>3?(i=g===o)&&(s=r[(c=r[4])?5:(c=3,3)],r[4]=r[5]=t):r[0]<=f&&((i=e<2&&f<r[1])?(c=0,p.v=o,p.n=r[1]):f<g&&(i=e<3||r[0]>o||o>g)&&(r[4]=e,r[5]=o,p.n=g,c=0))}if(i||e>1)return a;throw d=!0,o}return function(i,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&f(u,g),c=u,s=g;(n=c<2?t:s)||!d;){r||(c?c<3?(c>1&&(p.n=-1),f(c,s)):p.n=s:p.v=s);try{if(l=2,r){if(c||(i="next"),n=r[i]){if(!(n=n.call(r,s)))throw TypeError("iterator result is not an object");if(!n.done)return n;s=n.value,c<2&&(c=0)}else 1===c&&(n=r.return)&&n.call(r),c<2&&(s=TypeError("The iterator does not provide a '"+i+"' method"),c=1);r=t}else if((n=(d=p.n<0)?s:e.call(o,p))!==a)break}catch(n){r=t,c=1,s=n}finally{l=1}}return{value:n,done:d}}}(e,i,r),!0),l}var a={};function c(){}function s(){}function l(){}n=Object.getPrototypeOf;var u=[][o]?n(n([][o]())):(bn(n={},o,function(){return this}),n),d=l.prototype=c.prototype=Object.create(u);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,bn(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return s.prototype=l,bn(d,"constructor",l),bn(l,"constructor",s),s.displayName="GeneratorFunction",bn(l,i,"GeneratorFunction"),bn(d),bn(d,i,"Generator"),bn(d,o,function(){return this}),bn(d,"toString",function(){return"[object Generator]"}),(yn=function(){return{w:r,m:p}})()}function bn(t,n,e,o){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}bn=function(t,n,e,o){function r(n,e){bn(t,n,function(t){return this._invoke(n,e,t)})}n?i?i(t,n,{value:e,enumerable:!o,configurable:!o,writable:!o}):t[n]=e:(r("next",0),r("throw",1),r("return",2))},bn(t,n,e,o)}function xn(t,n,e,o,i,r,a){try{var c=t[r](a),s=c.value}catch(t){return void e(t)}c.done?n(s):Promise.resolve(s).then(o,i)}function wn(t){return function(){var n=this,e=arguments;return new Promise(function(o,i){var r=t.apply(n,e);function a(t){xn(r,o,i,a,c,"next",t)}function c(t){xn(r,o,i,a,c,"throw",t)}a(void 0)})}}function kn(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,Sn(o.key),o)}}function Sn(t){var n=function(t){if("object"!=mn(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var e=n.call(t,"string");if("object"!=mn(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mn(n)?n:n+""}var Cn=function(){return t=function t(n,e){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.config=n,this.sdk=e,this.streamingEl=null,this.hasStartedStreaming=!1,this.isActive=!1},n=[{key:"t",value:function(t){var n,e,o=this.config.language||"en";return((null===(n=this.config.translations)||void 0===n?void 0:n[o])||(null===(e=this.config.translations)||void 0===e?void 0:e.en)||{})[t]||t}},{key:"generateHTML",value:function(){var t,n,e,o,i,r,a,c,s,l=this.config.inputPlaceholder||(null===(t=this.config.panel)||void 0===t?void 0:t.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!==(n=this.config.sendButtonHint)&&void 0!==n&&n.text||null!==(e=this.config.panel)&&void 0!==e&&null!==(e=e.sendButtonHint)&&void 0!==e&&e.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===(c=this.config.sendButtonHint)||void 0===c?void 0:c.text)||(null===(s=this.config.panel)||void 0===s||null===(s=s.sendButtonHint)||void 0===s?void 0:s.text),"\n </div>\n "):"","\n </div>\n </div>")}},{key:"generateCSS",value:function(){var t,n,e,o,i,r,a,c,s,l,u,d,p,f=this.config.messages,g=(this.config.panel,this.config.animation,this.config.sendButtonColor||(null===(t=this.config.panel)||void 0===t?void 0:t.sendButtonColor)||"#7C3AED"),h=this.config.sendButtonHoverColor||(null===(n=this.config.panel)||void 0===n?void 0:n.sendButtonHoverColor)||"#6D28D9",v=this.config.sendButtonTextColor||(null===(e=this.config.panel)||void 0===e?void 0:e.sendButtonTextColor)||"#FFFFFF",m=(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",b=this.config.inputBackgroundColor||(null===(a=this.config.panel)||void 0===a?void 0:a.inputBackgroundColor)||"#FFFFFF",x=this.config.inputTextColor||(null===(c=this.config.panel)||void 0===c?void 0:c.inputTextColor)||"#1F2937",w=this.config.inputFontSize||(null===(s=this.config.panel)||void 0===s?void 0:s.inputFontSize)||"14px",k=this.config.inputBorderRadius||(null===(l=this.config.panel)||void 0===l?void 0:l.inputBorderRadius)||20,S=this.config.inputPadding||(null===(u=this.config.panel)||void 0===u?void 0:u.inputPadding)||"6px 14px";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; \n flex: 1; \n flex-direction: column; \n min-height: 0; \n overflow: hidden; \n }\n .text-interface.active { display: flex; }\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(f.borderRadius,"px; \n max-width: 80%; \n font-size: ").concat(f.fontSize,"; \n color: ").concat(f.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(f.userBackgroundColor,"; \n align-self: ").concat("rtl"===this.config.direction?"flex-start":"flex-end","; \n }\n .message.agent { \n background: ").concat(f.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","; \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(f.systemBackgroundColor,";\n align-self: flex-start;\n }\n .message.error {\n background: ").concat(f.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(S,";\n border: 1px solid ").concat(m,";\n border-radius: ").concat(k,"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(b,";\n color: ").concat(x,";\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"===b?"#FFFFFF":b,";\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===(d=this.config.panel)||void 0===d?void 0:d.sendButtonFontSize)||"18px",";\n font-weight: ").concat(this.config.sendButtonFontWeight||(null===(p=this.config.panel)||void 0===p?void 0:p.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(f.errorBackgroundColor,";\n border-radius: ").concat(f.borderRadius,"px;\n color: #991B1B;\n font-size: ").concat(f.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 ")}},{key:"setupEventHandlers",value:function(){var t=this,n=document.getElementById("sendButton"),e=document.getElementById("messageInput"),o=document.getElementById("newChatBtn");if(n&&(n.onclick=function(){return t.sendMessage()}),o&&(o.onclick=function(){return t.startNewChat()}),this.updateInputAttributes(),e){e.style.height="32px",e.style.overflow="hidden";var i=function(){e.style.height="auto";var t=Math.min(e.scrollHeight,120);e.style.height=t+"px",e.style.overflowY=t>=120?"auto":"hidden",t>=120&&setTimeout(function(){e.scrollTop=e.scrollHeight},0)};e.addEventListener("input",i),e.addEventListener("keydown",function(n){"Enter"!==n.key||n.shiftKey?"Enter"===n.key&&n.shiftKey&&setTimeout(i,0):(n.preventDefault(),t.sendMessage())})}}},{key:"startNewChat",value:function(){try{localStorage.removeItem("ttp_text_chat_conversation_id")}catch(t){}this.sdk&&(this.sdk.config.conversationId=null);var t=document.getElementById("messagesContainer");t&&(t.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 n=document.getElementById("messageInput");n&&n.focus()}},{key:"updateInputAttributes",value:function(){var t=document.getElementById("messageInput");if(t){var n,e=this.config.inputPlaceholder||(null===(n=this.config.panel)||void 0===n?void 0:n.inputPlaceholder)||this.t("typeMessage")||"Type your message...";t.placeholder=e,t.dir=this.config.direction||"ltr",t.style.textAlign="rtl"===this.config.direction?"right":"left"}}},{key:"show",value:function(){var t=document.getElementById("textInterface");t&&t.classList.add("active"),setTimeout(function(){var t=document.getElementById("messageInput");t&&t.focus()},50)}},{key:"hide",value:function(){var t=document.getElementById("textInterface");t&&t.classList.remove("active")}},{key:"startChat",value:(o=wn(yn().m(function t(){return yn().w(function(t){for(;;)switch(t.n){case 0:this.isActive=!0,this.updateSendButtonState();case 1:return t.a(2)}},t,this)})),function(){return o.apply(this,arguments)})},{key:"sendMessage",value:(e=wn(yn().m(function t(){var n,e,o;return yn().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=document.getElementById("messageInput"),e=n.value.trim()){t.n=1;break}return t.a(2);case 1:if(this.isActive){t.n=2;break}return t.n=2,this.startChat();case 2:return this.addMessage("user",e),n.value="",n.style.height="32px",n.style.overflow="hidden",t.p=3,this.beginStreaming(),t.n=4,this.sdk.sendMessage(e);case 4:t.n=6;break;case 5:t.p=5,o=t.v,console.error("❌ Failed to send message:",o),this.showError(o.message),this.stopStreamingState();case 6:return t.a(2)}},t,this,[[3,5]])})),function(){return e.apply(this,arguments)})},{key:"updateSendButtonState",value:function(){var t=document.getElementById("sendButton");t&&(t.disabled=!this.isActive)}},{key:"addMessage",value:function(t,n){var e=document.getElementById("messagesContainer");if(e){var o=e.querySelector(".empty-state");o&&o.remove();var i=document.createElement("div"),r="rtl"===this.config.direction?"user"===t?"edge-left":"edge-right":"user"===t?"edge-right":"edge-left";i.className="message ".concat(t," ").concat(r);var a=document.createElement("div");a.className="message-avatar ".concat(t),a.textContent="user"===t?"👤":"🤖";var c=document.createElement("div");c.className="message-bubble",c.textContent=n,i.appendChild(a),i.appendChild(c),e.appendChild(i),e.scrollTop=e.scrollHeight}}},{key:"beginStreaming",value:function(){var t=document.getElementById("messagesContainer");if(t){this.stopStreamingState();var n=document.createElement("div"),e="rtl"===this.config.direction?"edge-right":"edge-left";n.className="message agent ".concat(e),n.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>',n.appendChild(o),n.appendChild(i),t.appendChild(n),this.streamingEl=i,this.hasStartedStreaming=!1,t.scrollTop=t.scrollHeight}}},{key:"appendStreamingChunk",value:function(t){if(this.streamingEl){this.hasStartedStreaming||(this.streamingEl.textContent="",this.hasStartedStreaming=!0),this.streamingEl.textContent+=t;var n=document.getElementById("messagesContainer");n&&(n.scrollTop=n.scrollHeight)}}},{key:"finalizeStreaming",value:function(t){if(this.streamingEl){this.streamingEl.textContent=t||this.streamingEl.textContent;var n=document.getElementById("agent-streaming");n&&(n.id=""),this.streamingEl=null}this.updateSendButtonState()}},{key:"stopStreamingState",value:function(){var t=document.getElementById("agent-streaming");t&&t.remove(),this.streamingEl=null,this.hasStartedStreaming=!1}},{key:"showError",value:function(t){var n=document.getElementById("messagesContainer");if(n){var e=document.createElement("div");e.className="error-message",e.textContent=t,n.appendChild(e),n.scrollTop=n.scrollHeight}}},{key:"setActive",value:function(t){this.isActive=t,this.updateSendButtonState()}}],n&&kn(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,e,o}();const On={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"},he:{landingTitle:"איך תרצה לתקשר?",voiceCall:"שיחה קולית",textChat:"צ'אט טקסט",clickToStartCall:"לחץ להתחלת שיחה",realTimeVoice:"שיחה קולית בזמן אמת",startCall:"התחל שיחה",listening:"מקשיב...",speakFreely:"דבר בחופשיות",liveTranscript:"תמלול בזמן אמת",transcriptWillAppear:"התמלול יופיע כאן במהלך השיחה...",mute:"השתק",speaker:"רמקול",endCall:"סיים שיחה",hello:"שלום! איך אפשר לעזור?",sendMessage:"שלח הודעה או עבור למצב קולי לשיחה בזמן אמת",online:"מקוון",newChat:"צ'אט חדש",back:"חזור",close:"סגור",error:"שגיאה",typeMessage:"הקלד הודעה...",sendMessageAria:"שלח הודעה"},ar:{landingTitle:"كيف تريد التواصل؟",voiceCall:"مكالمة صوتية",textChat:"دردشة نصية",clickToStartCall:"انقر لبدء المكالمة",realTimeVoice:"محادثة صوتية في الوقت الفعلي",startCall:"ابدأ المكالمة",listening:"الاستماع...",speakFreely:"تكلم بحرية",liveTranscript:"نص مباشر",transcriptWillAppear:"سيظهر النص هنا أثناء المكالمة...",mute:"كتم الصوت",speaker:"مكبر الصوت",endCall:"إنهاء المكالمة",hello:"مرحبا! كيف يمكنني المساعدة؟",sendMessage:"أرسل رسالة للبدء",online:"متصل",newChat:"محادثة جديدة",back:"رجوع",close:"إغلاق",error:"خطأ",typeMessage:"اكتب رسالة...",sendMessageAria:"إرسال رسالة"},ru:{landingTitle:"Как вы хотите общаться?",voiceCall:"Голосовой звонок",textChat:"Текстовый чат",clickToStartCall:"Нажмите, чтобы начать звонок",realTimeVoice:"Голосовой разговор в реальном времени",startCall:"Начать звонок",listening:"Слушаю...",speakFreely:"Говорите свободно",liveTranscript:"Живая транскрипция",transcriptWillAppear:"Транскрипция появится здесь во время звонка...",mute:"Отключить звук",speaker:"Динамик",endCall:"Завершить звонок",hello:"Привет! Как я могу помочь?",sendMessage:"Отправьте сообщение для начала",online:"В сети",newChat:"Новый чат",back:"Назад",close:"Закрыть",error:"Ошибка",typeMessage:"Введите сообщение...",sendMessageAria:"Отправить сообщение"},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"},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"},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"}};function In(){var t,n,e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",i=e.toStringTag||"@@toStringTag";function r(e,o,i,r){var s=o&&o.prototype instanceof c?o:c,l=Object.create(s.prototype);return Bn(l,"_invoke",function(e,o,i){var r,c,s,l=0,u=i||[],d=!1,p={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(n,e){return r=n,c=0,s=t,p.n=e,a}};function f(e,o){for(c=e,s=o,n=0;!d&&l&&!i&&n<u.length;n++){var i,r=u[n],f=p.p,g=r[2];e>3?(i=g===o)&&(s=r[(c=r[4])?5:(c=3,3)],r[4]=r[5]=t):r[0]<=f&&((i=e<2&&f<r[1])?(c=0,p.v=o,p.n=r[1]):f<g&&(i=e<3||r[0]>o||o>g)&&(r[4]=e,r[5]=o,p.n=g,c=0))}if(i||e>1)return a;throw d=!0,o}return function(i,u,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&f(u,g),c=u,s=g;(n=c<2?t:s)||!d;){r||(c?c<3?(c>1&&(p.n=-1),f(c,s)):p.n=s:p.v=s);try{if(l=2,r){if(c||(i="next"),n=r[i]){if(!(n=n.call(r,s)))throw TypeError("iterator result is not an object");if(!n.done)return n;s=n.value,c<2&&(c=0)}else 1===c&&(n=r.return)&&n.call(r),c<2&&(s=TypeError("The iterator does not provide a '"+i+"' method"),c=1);r=t}else if((n=(d=p.n<0)?s:e.call(o,p))!==a)break}catch(n){r=t,c=1,s=n}finally{l=1}}return{value:n,done:d}}}(e,i,r),!0),l}var a={};function c(){}function s(){}function l(){}n=Object.getPrototypeOf;var u=[][o]?n(n([][o]())):(Bn(n={},o,function(){return this}),n),d=l.prototype=c.prototype=Object.create(u);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,Bn(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return s.prototype=l,Bn(d,"constructor",l),Bn(l,"constructor",s),s.displayName="GeneratorFunction",Bn(l,i,"GeneratorFunction"),Bn(d),Bn(d,i,"Generator"),Bn(d,o,function(){return this}),Bn(d,"toString",function(){return"[object Generator]"}),(In=function(){return{w:r,m:p}})()}function Bn(t,n,e,o){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}Bn=function(t,n,e,o){function r(n,e){Bn(t,n,function(t){return this._invoke(n,e,t)})}n?i?i(t,n,{value:e,enumerable:!o,configurable:!o,writable:!o}):t[n]=e:(r("next",0),r("throw",1),r("return",2))},Bn(t,n,e,o)}function jn(t,n,e,o,i,r,a){try{var c=t[r](a),s=c.value}catch(t){return void e(t)}c.done?n(s):Promise.resolve(s).then(o,i)}function En(t){return function(){var n=this,e=arguments;return new Promise(function(o,i){var r=t.apply(n,e);function a(t){jn(r,o,i,a,c,"next",t)}function c(t){jn(r,o,i,a,c,"throw",t)}a(void 0)})}}function Pn(t){return Pn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pn(t)}function Tn(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);n&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),e.push.apply(e,o)}return e}function Fn(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{};n%2?Tn(Object(e),!0).forEach(function(n){An(t,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Tn(Object(e)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}return t}function An(t,n,e){return(n=Mn(n))in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function Dn(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,Mn(o.key),o)}}function Mn(t){var n=function(t){if("object"!=Pn(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var e=n.call(t,"string");if("object"!=Pn(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Pn(n)?n:n+""}var zn=function(){return t=function t(){var n,e,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.config=this.mergeWithDefaults(o),this.sdk=new Ot(this.config),this.isOpen=!1,this.isActive=!1,this.translations=On;var i=Fn(Fn(Fn({},this.config),this.config.voice),{},{language:(null===(n=this.config.voice)||void 0===n?void 0:n.language)||this.config.language||"en",websocketUrl:(null===(e=this.config.voice)||void 0===e?void 0:e.websocketUrl)||this.config.websocketUrl||"wss://speech.talktopc.com/ws/conv",translations:this.translations});this.voiceInterface=new vn(i);var r=Fn(Fn(Fn({},this.config),this.config.text),{},{translations:this.translations});if(this.textInterface=new Cn(r,this.sdk),this.setupEventHandlers(),this.createWidget(),this.config.behavior.startOpen||this.config.behavior.autoOpen){var a=document.getElementById("text-chat-panel");a&&(this.isOpen=!0,a.classList.add("open"))}},n=[{key:"mergeWithDefaults",value:function(t){var n,e,o,i,r,a,c,s,l,u,d,p,f,g,h,v,m,y,b,x,w,k,S,C,O,I,B,j,E,P,T,F,A,D,M,z,R,_,H,L,U,K,W,N,G,V,q,Q,Y,J,$,Z,X,tt,nt,et,ot,it,rt,at,ct,st,lt,ut,dt,pt,ft,gt,ht,vt,mt,yt,bt,xt,wt,kt,St,Ct,Ot,It,Bt,jt,Et,Pt,Tt,Ft,At,Dt,Mt,zt,Rt,_t,Ht,Lt,Ut,Kt,Wt,Nt,Gt,Vt,qt,Qt,Yt,Jt,$t,Zt,Xt,tn,nn,en,on,rn,an,cn,sn,ln,un,dn,pn,fn,gn,hn,vn,mn,yn,bn,xn,wn,kn,Sn,Cn,On,In,Bn,jn=t.position||"bottom-right";if("string"==typeof jn){var En=jn.split("-");jn={vertical:En[0]||"bottom",horizontal:En[1]||"right",offset:t.positionOffset||{x:20,y:20}}}var Tn=t.primaryColor||(null===(n=t.button)||void 0===n?void 0:n.primaryColor)||(null===(e=t.button)||void 0===e?void 0:e.backgroundColor)||"#7C3AED",An=(null===(o=t.header)||void 0===o?void 0:o.backgroundColor)||(null===(i=t.button)||void 0===i?void 0:i.backgroundColor)||Tn;return Fn({agentId:t.agentId,appId:t.appId,getSessionUrl:t.getSessionUrl,websocketUrl:t.websocketUrl,demo:!1!==t.demo,direction:t.direction||"ltr",language:t.language||"en",icon:Fn({type:(null===(r=t.icon)||void 0===r?void 0:r.type)||"chat",customImage:(null===(a=t.icon)||void 0===a?void 0:a.customImage)||null,emoji:(null===(c=t.icon)||void 0===c?void 0:c.emoji)||"💬",text:(null===(s=t.icon)||void 0===s?void 0:s.text)||"AI",size:(null===(l=t.icon)||void 0===l?void 0:l.size)||"medium",backgroundColor:(null===(u=t.icon)||void 0===u?void 0:u.backgroundColor)||null},t.icon),position:Fn({vertical:jn.vertical||"bottom",horizontal:jn.horizontal||"right",offset:jn.offset||{x:20,y:20}},"object"===Pn(t.position)?t.position:{}),button:Fn({size:(null===(d=t.button)||void 0===d?void 0:d.size)||"medium",shape:(null===(p=t.button)||void 0===p?void 0:p.shape)||"circle",backgroundColor:(null===(f=t.button)||void 0===f?void 0:f.backgroundColor)||(null===(g=t.icon)||void 0===g?void 0:g.backgroundColor)||Tn,hoverColor:(null===(h=t.button)||void 0===h?void 0:h.hoverColor)||"#7C3AED",shadow:!1!==(null===(v=t.button)||void 0===v?void 0:v.shadow),shadowColor:(null===(m=t.button)||void 0===m?void 0:m.shadowColor)||"rgba(0,0,0,0.15)",primaryColor:(null===(y=t.button)||void 0===y?void 0:y.backgroundColor)||(null===(b=t.icon)||void 0===b?void 0:b.backgroundColor)||Tn},t.button),panel:Fn({width:(null===(x=t.panel)||void 0===x?void 0:x.width)||350,height:(null===(w=t.panel)||void 0===w?void 0:w.height)||500,borderRadius:(null===(k=t.panel)||void 0===k?void 0:k.borderRadius)||12,backgroundColor:(null===(S=t.panel)||void 0===S?void 0:S.backgroundColor)||"#FFFFFF",backdropFilter:(null===(C=t.panel)||void 0===C?void 0:C.backdropFilter)||null,border:(null===(O=t.panel)||void 0===O?void 0:O.border)||"1px solid rgba(0,0,0,0.1)"},t.panel),voice:Fn({micButtonColor:(null===(I=t.voice)||void 0===I?void 0:I.micButtonColor)||(null===(B=t.panel)||void 0===B?void 0:B.micButtonColor)||Tn,micButtonActiveColor:(null===(j=t.voice)||void 0===j?void 0:j.micButtonActiveColor)||(null===(E=t.panel)||void 0===E?void 0:E.micButtonActiveColor)||"#EF4444",micButtonHint:Fn(Fn({text:(null===(P=t.voice)||void 0===P||null===(P=P.micButtonHint)||void 0===P?void 0:P.text)||(null===(T=t.panel)||void 0===T||null===(T=T.micButtonHint)||void 0===T?void 0:T.text)||"Click the button to start voice conversation",color:(null===(F=t.voice)||void 0===F||null===(F=F.micButtonHint)||void 0===F?void 0:F.color)||(null===(A=t.panel)||void 0===A||null===(A=A.micButtonHint)||void 0===A?void 0:A.color)||"#6B7280",fontSize:(null===(D=t.voice)||void 0===D||null===(D=D.micButtonHint)||void 0===D?void 0:D.fontSize)||(null===(M=t.panel)||void 0===M||null===(M=M.micButtonHint)||void 0===M?void 0:M.fontSize)||"12px"},null===(z=t.voice)||void 0===z?void 0:z.micButtonHint),null===(R=t.panel)||void 0===R?void 0:R.micButtonHint),avatarBackgroundColor:(null===(_=t.voice)||void 0===_?void 0:_.avatarBackgroundColor)||"#667eea",avatarActiveBackgroundColor:(null===(H=t.voice)||void 0===H?void 0:H.avatarActiveBackgroundColor)||"#667eea",statusTitleColor:(null===(L=t.voice)||void 0===L?void 0:L.statusTitleColor)||"#1e293b",statusSubtitleColor:(null===(U=t.voice)||void 0===U?void 0:U.statusSubtitleColor)||"#64748b",startCallButtonColor:(null===(K=t.voice)||void 0===K?void 0:K.startCallButtonColor)||"#667eea",startCallButtonTextColor:(null===(W=t.voice)||void 0===W?void 0:W.startCallButtonTextColor)||"#FFFFFF",transcriptBackgroundColor:(null===(N=t.voice)||void 0===N?void 0:N.transcriptBackgroundColor)||"#FFFFFF",transcriptTextColor:(null===(G=t.voice)||void 0===G?void 0:G.transcriptTextColor)||"#1e293b",transcriptLabelColor:(null===(V=t.voice)||void 0===V?void 0:V.transcriptLabelColor)||"#94a3b8",controlButtonColor:(null===(q=t.voice)||void 0===q?void 0:q.controlButtonColor)||"#FFFFFF",controlButtonSecondaryColor:(null===(Q=t.voice)||void 0===Q?void 0:Q.controlButtonSecondaryColor)||"#64748b",endCallButtonColor:(null===(Y=t.voice)||void 0===Y?void 0:Y.endCallButtonColor)||"#ef4444",language:(null===(J=t.voice)||void 0===J?void 0:J.language)||t.language||"en",websocketUrl:(null===($=t.voice)||void 0===$?void 0:$.websocketUrl)||t.websocketUrl},t.voice),text:Fn({sendButtonColor:(null===(Z=t.text)||void 0===Z?void 0:Z.sendButtonColor)||(null===(X=t.panel)||void 0===X?void 0:X.sendButtonColor)||"#7C3AED",sendButtonHoverColor:(null===(tt=t.text)||void 0===tt?void 0:tt.sendButtonHoverColor)||(null===(nt=t.panel)||void 0===nt?void 0:nt.sendButtonHoverColor)||"#6D28D9",sendButtonActiveColor:(null===(et=t.text)||void 0===et?void 0:et.sendButtonActiveColor)||(null===(ot=t.panel)||void 0===ot?void 0:ot.sendButtonActiveColor)||"#6D28D9",sendButtonText:(null===(it=t.text)||void 0===it?void 0:it.sendButtonText)||(null===(rt=t.panel)||void 0===rt?void 0:rt.sendButtonText)||"➤",sendButtonTextColor:(null===(at=t.text)||void 0===at?void 0:at.sendButtonTextColor)||(null===(ct=t.panel)||void 0===ct?void 0:ct.sendButtonTextColor)||"#FFFFFF",sendButtonFontSize:(null===(st=t.text)||void 0===st?void 0:st.sendButtonFontSize)||(null===(lt=t.panel)||void 0===lt?void 0:lt.sendButtonFontSize)||"18px",sendButtonFontWeight:(null===(ut=t.text)||void 0===ut?void 0:ut.sendButtonFontWeight)||(null===(dt=t.panel)||void 0===dt?void 0:dt.sendButtonFontWeight)||"500",sendButtonHint:Fn(Fn({text:(null===(pt=t.text)||void 0===pt||null===(pt=pt.sendButtonHint)||void 0===pt?void 0:pt.text)||(null===(ft=t.panel)||void 0===ft||null===(ft=ft.sendButtonHint)||void 0===ft?void 0:ft.text)||"",color:(null===(gt=t.text)||void 0===gt||null===(gt=gt.sendButtonHint)||void 0===gt?void 0:gt.color)||(null===(ht=t.panel)||void 0===ht||null===(ht=ht.sendButtonHint)||void 0===ht?void 0:ht.color)||"#6B7280",fontSize:(null===(vt=t.text)||void 0===vt||null===(vt=vt.sendButtonHint)||void 0===vt?void 0:vt.fontSize)||(null===(mt=t.panel)||void 0===mt||null===(mt=mt.sendButtonHint)||void 0===mt?void 0:mt.fontSize)||"12px"},null===(yt=t.text)||void 0===yt?void 0:yt.sendButtonHint),null===(bt=t.panel)||void 0===bt?void 0:bt.sendButtonHint),inputPlaceholder:(null===(xt=t.text)||void 0===xt?void 0:xt.inputPlaceholder)||(null===(wt=t.panel)||void 0===wt?void 0:wt.inputPlaceholder)||"Type your message...",inputBorderColor:(null===(kt=t.text)||void 0===kt?void 0:kt.inputBorderColor)||(null===(St=t.panel)||void 0===St?void 0:St.inputBorderColor)||"#E5E7EB",inputFocusColor:(null===(Ct=t.text)||void 0===Ct?void 0:Ct.inputFocusColor)||(null===(Ot=t.panel)||void 0===Ot?void 0:Ot.inputFocusColor)||"#7C3AED",inputBackgroundColor:(null===(It=t.text)||void 0===It?void 0:It.inputBackgroundColor)||(null===(Bt=t.panel)||void 0===Bt?void 0:Bt.inputBackgroundColor)||"#FFFFFF",inputTextColor:(null===(jt=t.text)||void 0===jt?void 0:jt.inputTextColor)||(null===(Et=t.panel)||void 0===Et?void 0:Et.inputTextColor)||"#1F2937",inputFontSize:(null===(Pt=t.text)||void 0===Pt?void 0:Pt.inputFontSize)||(null===(Tt=t.panel)||void 0===Tt?void 0:Tt.inputFontSize)||"14px",inputBorderRadius:(null===(Ft=t.text)||void 0===Ft?void 0:Ft.inputBorderRadius)||(null===(At=t.panel)||void 0===At?void 0:At.inputBorderRadius)||20,inputPadding:(null===(Dt=t.text)||void 0===Dt?void 0:Dt.inputPadding)||(null===(Mt=t.panel)||void 0===Mt?void 0:Mt.inputPadding)||"6px 14px"},t.text),landing:Fn({backgroundColor:(null===(zt=t.landing)||void 0===zt?void 0:zt.backgroundColor)||"linear-gradient(180deg, #f8fafc 0%, #e0e7ff 100%)",logo:(null===(Rt=t.landing)||void 0===Rt?void 0:Rt.logo)||"🤖",title:(null===(_t=t.landing)||void 0===_t?void 0:_t.title)||null,titleColor:(null===(Ht=t.landing)||void 0===Ht?void 0:Ht.titleColor)||"#1e293b",modeCardBackgroundColor:(null===(Lt=t.landing)||void 0===Lt?void 0:Lt.modeCardBackgroundColor)||"#FFFFFF",modeCardBorderColor:(null===(Ut=t.landing)||void 0===Ut?void 0:Ut.modeCardBorderColor)||"#E2E8F0",modeCardHoverBorderColor:(null===(Kt=t.landing)||void 0===Kt?void 0:Kt.modeCardHoverBorderColor)||An,modeCardIconBackgroundColor:(null===(Wt=t.landing)||void 0===Wt?void 0:Wt.modeCardIconBackgroundColor)||An,modeCardTitleColor:(null===(Nt=t.landing)||void 0===Nt?void 0:Nt.modeCardTitleColor)||"#111827",voiceCardIcon:(null===(Gt=t.landing)||void 0===Gt?void 0:Gt.voiceCardIcon)||"🎤",textCardIcon:(null===(Vt=t.landing)||void 0===Vt?void 0:Vt.textCardIcon)||"💬"},t.landing),header:Fn({title:(null===(qt=t.header)||void 0===qt?void 0:qt.title)||"Chat Assistant",showTitle:!1!==(null===(Qt=t.header)||void 0===Qt?void 0:Qt.showTitle),backgroundColor:(null===(Yt=t.header)||void 0===Yt?void 0:Yt.backgroundColor)||(null===(Jt=t.button)||void 0===Jt?void 0:Jt.backgroundColor)||"#7C3AED",textColor:(null===($t=t.header)||void 0===$t?void 0:$t.textColor)||"#FFFFFF",showCloseButton:!1!==(null===(Zt=t.header)||void 0===Zt?void 0:Zt.showCloseButton)},t.header),tooltips:Fn({newChat:(null===(Xt=t.tooltips)||void 0===Xt?void 0:Xt.newChat)||null,back:(null===(tn=t.tooltips)||void 0===tn?void 0:tn.back)||null,close:(null===(nn=t.tooltips)||void 0===nn?void 0:nn.close)||null,mute:(null===(en=t.tooltips)||void 0===en?void 0:en.mute)||null,speaker:(null===(on=t.tooltips)||void 0===on?void 0:on.speaker)||null,endCall:(null===(rn=t.tooltips)||void 0===rn?void 0:rn.endCall)||null},t.tooltips),messages:Fn({userBackgroundColor:(null===(an=t.messages)||void 0===an?void 0:an.userBackgroundColor)||"#E5E7EB",agentBackgroundColor:(null===(cn=t.messages)||void 0===cn?void 0:cn.agentBackgroundColor)||"#F3F4F6",systemBackgroundColor:(null===(sn=t.messages)||void 0===sn?void 0:sn.systemBackgroundColor)||"#DCFCE7",errorBackgroundColor:(null===(ln=t.messages)||void 0===ln?void 0:ln.errorBackgroundColor)||"#FEE2E2",textColor:(null===(un=t.messages)||void 0===un?void 0:un.textColor)||"#1F2937",fontSize:(null===(dn=t.messages)||void 0===dn?void 0:dn.fontSize)||"14px",borderRadius:(null===(pn=t.messages)||void 0===pn?void 0:pn.borderRadius)||8},t.messages),animation:Fn({enableHover:!1!==(null===(fn=t.animation)||void 0===fn?void 0:fn.enableHover),enablePulse:!1!==(null===(gn=t.animation)||void 0===gn?void 0:gn.enablePulse),enableSlide:!1!==(null===(hn=t.animation)||void 0===hn?void 0:hn.enableSlide),duration:(null===(vn=t.animation)||void 0===vn?void 0:vn.duration)||.3},t.animation),behavior:Fn({autoOpen:(null===(mn=t.behavior)||void 0===mn?void 0:mn.autoOpen)||!1,startOpen:(null===(yn=t.behavior)||void 0===yn?void 0:yn.startOpen)||!1,hidden:(null===(bn=t.behavior)||void 0===bn?void 0:bn.hidden)||!1,autoConnect:(null===(xn=t.behavior)||void 0===xn?void 0:xn.autoConnect)||!1,showWelcomeMessage:!1!==(null===(wn=t.behavior)||void 0===wn?void 0:wn.showWelcomeMessage),welcomeMessage:(null===(kn=t.behavior)||void 0===kn?void 0:kn.welcomeMessage)||"Hello! How can I help you today?",enableVoiceMode:void 0===(null===(Sn=t.behavior)||void 0===Sn?void 0:Sn.enableVoiceMode)||t.behavior.enableVoiceMode,mode:(null===(Cn=t.behavior)||void 0===Cn?void 0:Cn.mode)||"unified"},t.behavior),accessibility:Fn({ariaLabel:(null===(On=t.accessibility)||void 0===On?void 0:On.ariaLabel)||"Chat Assistant",ariaDescription:(null===(In=t.accessibility)||void 0===In?void 0:In.ariaDescription)||"Click to open chat assistant",keyboardNavigation:!1!==(null===(Bn=t.accessibility)||void 0===Bn?void 0:Bn.keyboardNavigation)},t.accessibility),customStyles:t.customStyles||"",variables:t.variables||{},forceConversationId:t.forceConversationId,primaryColor:Tn},"string"==typeof t.position?{positionString:t.position}:{})}},{key:"setupEventHandlers",value:function(){var t=this;this.sdk.on("error",function(n){t.textInterface.showError(n.message||n),t.textInterface.stopStreamingState()}),this.sdk.on("chunk",function(n){t.textInterface.appendStreamingChunk(n)}),this.sdk.on("done",function(n){var e=n.text;t.textInterface.finalizeStreaming(e)})}},{key:"createWidget",value:function(){var t=document.createElement("div");if(t.id="text-chat-widget",t.innerHTML=this.generateWidgetHTML(),document.body.appendChild(t),this.setupWidgetEvents(),this.config.behavior.startOpen||this.config.behavior.autoOpen){var n=document.getElementById("text-chat-panel");n&&(this.isOpen=!0,n.classList.add("open"))}}},{key:"generateWidgetHTML",value:function(){var t=this,n=(this.config.position,this.config.button),e=this.config.icon,o=(this.config.panel,this.config.header),i=(this.config.animation,{small:50,medium:60,large:70,xl:80}[n.size]||60),r={small:20,medium:28,large:36,xl:44}[e.size]||28,a=this.generatePositionStyles(),c=this.generateIconHTML(r),s=this.config.behavior.mode||"unified",l="unified"===s,u="unified"===s||"voice-only"===s,d="unified"===s||"text-only"===s,p=function(n){var e=t.config.language||"en";return(t.translations[e]||t.translations.en)[n]||n},f=function(n){var e,o=null===(e=t.config.tooltips)||void 0===e?void 0:e[n];return null!=o?o:{newChat:p("newChat"),back:p("back"),close:p("close"),mute:p("mute"),speaker:p("speaker"),endCall:p("endCall")}[n]||""};return"\n <style>\n ".concat(this.generateCSS(a,i,r),"\n ").concat(this.config.customStyles,"\n </style>\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(c,"\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(o.backgroundColor,"; color: ").concat(o.textColor,';">\n <div>\n ').concat(o.showTitle?'<div class="header-title">'.concat(o.title,"</div>"):"",'\n <div class="header-status">\n <span class="status-dot"></span>\n <span>').concat(p("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(f("newChat"),'" style="').concat(l?"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"===s?'<button class="header-icon back-btn" id="backBtn" title="'.concat(f("back"),'" style="display: none;">\n <span style="font-size: 16px;">‹</span>\n </button>'):"","\n \n \x3c!-- Close Button --\x3e\n ").concat(o.showCloseButton?'<button class="header-icon close-btn" id="closeBtn" title="'+f("close")+'"><span style="font-size: 18px; font-weight: bold;">×</span></button>':"","\n </div>\n </div>\n\n ").concat(l?'\n <div class="landing-screen" id="landingScreen">\n <div class="landing-logo">🤖</div>\n <div class="landing-title">'.concat(p("landingTitle"),'</div>\n <div class="mode-selection">\n ').concat(u?'<div class="mode-card voice" id="mode-card-voice">\n <div class="mode-card-icon">🎤</div>\n <div class="mode-card-title">'.concat(p("voiceCall"),"</div>\n </div>"):"","\n ").concat(d?'<div class="mode-card text" id="mode-card-text">\n <div class="mode-card-icon">💬</div>\n <div class="mode-card-title">'.concat(p("textChat"),"</div>\n </div>"):"","\n </div>\n </div>"):"","\n\n ").concat(u?this.voiceInterface.generateHTML():"","\n ").concat(d?this.textInterface.generateHTML():"","\n </div>\n </div>\n </div>\n ")}},{key:"generatePositionStyles",value:function(){var t=this.config.position,n=t.offset||{x:20,y:20},e="";return"top"===t.vertical?e+="top: ".concat(n.y,"px;"):"bottom"===t.vertical?e+="bottom: ".concat(n.y,"px;"):"center"===t.vertical&&(e+="top: 50%; transform: translateY(-50%);"),"left"===t.horizontal?e+="left: ".concat(n.x,"px;"):"right"===t.horizontal?e+="right: ".concat(n.x,"px;"):"center"===t.horizontal&&(e+="left: 50%; transform: translateX(-50%);"),e}},{key:"generateIconHTML",value:function(t){var n=this.config.icon;switch(n.type){case"custom":return'<img src="'.concat(n.customImage,'" alt="Chat Assistant" style="width: ').concat(t,"px; height: ").concat(t,'px; object-fit: contain;" />');case"emoji":return'<span style="font-size: '.concat(t,'px; line-height: 1;">').concat(n.emoji,"</span>");case"text":return'<span style="font-size: '.concat(Math.floor(.6*t),'px; font-weight: bold; color: white;">').concat(n.text,"</span>");default:return'<svg viewBox="0 0 24 24" style="width: '.concat(t,"px; height: ").concat(t,'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>')}}},{key:"generateCSS",value:function(t,n,e){var o,i,r,a,c,s,l,u=this.config.button,d=this.config.panel,p=this.config.header,f=(this.config.messages,this.config.animation),g=this.config.behavior.mode||"unified",h="unified"===g||"voice-only"===g,v="unified"===g||"text-only"===g,m=p.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(t,"\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 width: ").concat(n,"px;\n height: ").concat(n,"px;\n border-radius: ").concat("circle"===u.shape?"50%":"square"===u.shape?"0":"12px",";\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\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 }\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 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: 76px !important; /* 56px button + 20px gap */\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 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: 70px !important;\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 background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);\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;\n position: fixed;\n bottom: calc(").concat(n,"px + 20px);\n ").concat("right"===this.config.position.horizontal?"right: 20px;":"left: 20px;","\n width: ").concat(d.width,"px;\n max-width: calc(100vw - 40px);\n height: ").concat(d.height,"px;\n max-height: calc(100vh - ").concat(n,"px - 40px);\n background: transparent;\n border-radius: ").concat(d.borderRadius,"px;\n border: none;\n flex-direction: column;\n overflow: hidden;\n ").concat(d.backdropFilter?"backdrop-filter: ".concat(d.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;\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(d.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(d.borderRadius,"px; 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(d.borderRadius,"px;\n }\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(d.borderRadius,"px;\n border-top-right-radius: ").concat(d.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; \n flex: 1; \n padding: 20px; \n background: ").concat((null===(o=this.config.landing)||void 0===o?void 0:o.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; }\n .landing-logo { font-size: 48px; }\n .landing-title { \n font-size: 20px; \n color: ").concat((null===(i=this.config.landing)||void 0===i?void 0:i.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===(r=this.config.landing)||void 0===r?void 0:r.modeCardBackgroundColor)||"#FFFFFF","; \n border: 2px solid ").concat((null===(a=this.config.landing)||void 0===a?void 0:a.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===(c=this.config.landing)||void 0===c?void 0:c.modeCardHoverBorderColor)||m,"; \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===(s=this.config.landing)||void 0===s?void 0:s.modeCardIconBackgroundColor)||m,"; \n color: #fff; \n font-size: 32px; \n }\n .mode-card-title { \n color: ").concat((null===(l=this.config.landing)||void 0===l?void 0:l.modeCardTitleColor)||"#111827","; \n font-weight: 600; \n text-align: center;\n width: 100%;\n }\n\n ").concat(h?this.voiceInterface.generateCSS():"","\n ").concat(v?this.textInterface.generateCSS():"","\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 ")}},{key:"setupWidgetEvents",value:function(){var t=this,n=document.getElementById("text-chat-button");n&&(n.onclick=function(){return t.togglePanel()});var e=document.getElementById("closeBtn");e&&(e.onclick=function(){return t.togglePanel()});var o=this.config.behavior.mode||"unified",i="unified"===o,r="unified"===o||"voice-only"===o,a="unified"===o||"text-only"===o,c=document.getElementById("backBtn"),s=document.getElementById("landingScreen"),l=document.getElementById("mode-card-voice"),u=document.getElementById("mode-card-text"),d=document.getElementById("textInterface"),p=document.getElementById("voiceInterface");c&&(c.onclick=function(){return t.showLanding()}),i?(l&&(l.onclick=function(){return t.showVoice()}),u&&(u.onclick=function(){return t.showText()}),s&&s.classList.add("active"),d&&d.classList.remove("active"),p&&p.classList.remove("active"),c&&"unified"===o&&c.classList.remove("visible")):"voice-only"===o?(p&&p.classList.add("active"),d&&d.classList.remove("active"),s&&s.classList.remove("active")):"text-only"===o&&(d&&d.classList.add("active"),p&&p.classList.remove("active"),s&&s.classList.remove("active")),r&&this.voiceInterface.setupEventHandlers(),a&&this.textInterface.setupEventHandlers();var f=document.getElementById("newChatBtn");f&&(f.onclick=function(){return t.textInterface.startNewChat()},i&&(f.style.display="none")),this.config.accessibility.keyboardNavigation&&this.setupKeyboardNavigation()}},{key:"startNewChat",value:function(){this.textInterface.startNewChat()}},{key:"showLanding",value:function(){if("unified"===(this.config.behavior.mode||"unified")){var t=document.getElementById("landingScreen"),n=document.getElementById("textInterface"),e=document.getElementById("voiceInterface"),o=document.getElementById("backBtn"),i=document.getElementById("newChatBtn");t&&t.classList.add("active"),n&&n.classList.remove("active"),e&&e.classList.remove("active"),o&&o.classList.remove("visible"),i&&(i.style.display="none")}}},{key:"showText",value:function(){var t=document.getElementById("landingScreen"),n=document.getElementById("voiceInterface"),e=document.getElementById("backBtn"),o=document.getElementById("newChatBtn");t&&t.classList.remove("active"),n&&n.classList.remove("active"),this.textInterface.show();var i=this.config.behavior.mode||"unified";e&&"unified"===i&&e.classList.add("visible"),o&&(o.style.display="")}},{key:"showVoice",value:function(){var t=document.getElementById("landingScreen"),n=document.getElementById("textInterface"),e=document.getElementById("voiceInterface"),o=document.getElementById("backBtn"),i=document.getElementById("newChatBtn");t&&t.classList.remove("active"),n&&n.classList.remove("active"),e&&e.classList.add("active");var r=this.config.behavior.mode||"unified";o&&"unified"===r&&o.classList.add("visible"),i&&(i.style.display="")}},{key:"setupKeyboardNavigation",value:function(){var t=this;document.addEventListener("keydown",function(n){"Escape"===n.key&&t.isOpen&&t.togglePanel()})}},{key:"togglePanel",value:function(){this.isOpen=!this.isOpen,document.getElementById("text-chat-panel").classList.toggle("open"),this.isOpen&&setTimeout(function(){var t=document.getElementById("messageInput");t&&t.focus()},100),this.isOpen&&!this.isActive&&this.config.behavior.autoConnect&&this.startChat()}},{key:"startChat",value:(r=En(In().m(function t(){return In().w(function(t){for(;;)switch(t.n){case 0:this.isActive=!0,this.textInterface.setActive(!0);case 1:return t.a(2)}},t,this)})),function(){return r.apply(this,arguments)})},{key:"sendMessage",value:(i=En(In().m(function t(){return In().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this.textInterface.sendMessage();case 1:return t.a(2)}},t,this)})),function(){return i.apply(this,arguments)})},{key:"updateSendButtonState",value:function(){this.textInterface.updateSendButtonState()}},{key:"getSignedUrl",value:(o=En(In().m(function t(){var n,e,o,i,r,a,c;return In().w(function(t){for(;;)switch(t.n){case 0:if(this.config.getSessionUrl){t.n=2;break}if(this.config.agentId){t.n=1;break}throw new Error("agentId is required");case 1:return n=this.config.websocketUrl||"wss://backend.talktopc.com/ws/conv",(e=new URLSearchParams).append("agentId",this.config.agentId),this.config.appId&&e.append("appId",this.config.appId),!1!==this.config.demo&&e.append("demo","true"),t.a(2,"".concat(n,"?").concat(e.toString()));case 2:if("string"!=typeof this.config.getSessionUrl){t.n=6;break}return o={agentId:this.config.agentId,variables:this.config.variables||{}},this.config.appId&&(o.appId=this.config.appId),t.n=3,fetch(this.config.getSessionUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});case 3:if((i=t.v).ok){t.n=4;break}throw new Error("Failed to get session URL: ".concat(i.statusText));case 4:return t.n=5,i.json();case 5:return r=t.v,t.a(2,r.signedUrl||r.wsUrl||r.url);case 6:if("function"!=typeof this.config.getSessionUrl){t.n=8;break}return a={agentId:this.config.agentId,variables:this.config.variables||{}},this.config.appId&&(a.appId=this.config.appId),t.n=7,this.config.getSessionUrl(a);case 7:return c=t.v,t.a(2,"string"==typeof c?c:c.signedUrl||c.wsUrl||c.url);case 8:throw new Error("getSessionUrl must be a string (backend URL), a function, or omitted (for direct connection with agentId/appId)");case 9:return t.a(2)}},t,this)})),function(){return o.apply(this,arguments)})},{key:"addMessage",value:function(t,n){this.textInterface.addMessage(t,n)}},{key:"beginStreaming",value:function(){this.textInterface.beginStreaming()}},{key:"appendStreamingChunk",value:function(t){this.textInterface.appendStreamingChunk(t)}},{key:"finalizeStreaming",value:function(t){this.textInterface.finalizeStreaming(t)}},{key:"stopStreamingState",value:function(){this.textInterface.stopStreamingState()}},{key:"showError",value:function(t){this.textInterface.showError(t)}},{key:"updateStatus",value:function(t){}},{key:"updateConfig",value:function(t){var n,e,o,i,r=Fn({},this.config);t.panel&&(r.panel=Fn(Fn({},this.config.panel),t.panel)),t.voice&&(r.voice=Fn(Fn({},this.config.voice),t.voice),t.voice.micButtonHint&&(r.voice.micButtonHint=Fn(Fn({},null===(o=this.config.voice)||void 0===o?void 0:o.micButtonHint),t.voice.micButtonHint))),t.text&&(r.text=Fn(Fn({},this.config.text),t.text),t.text.sendButtonHint&&(r.text.sendButtonHint=Fn(Fn({},null===(i=this.config.text)||void 0===i?void 0:i.sendButtonHint),t.text.sendButtonHint))),void 0!==t.language&&(r.language=t.language),void 0!==t.language&&(["he","ar"].includes(t.language)?r.direction="rtl":void 0===t.direction&&(r.direction="ltr")),t.translations&&(r.translations=t.translations,this.translations=t.translations),t.button&&(r.button=Fn(Fn({},this.config.button),t.button)),t.header&&(r.header=Fn(Fn({},this.config.header),t.header)),t.icon&&(r.icon=Fn(Fn({},this.config.icon),t.icon)),t.messages&&(r.messages=Fn(Fn({},this.config.messages),t.messages)),t.animation&&(r.animation=Fn(Fn({},this.config.animation),t.animation)),t.behavior&&(r.behavior=Fn(Fn({},this.config.behavior),t.behavior)),t.accessibility&&(r.accessibility=Fn(Fn({},this.config.accessibility),t.accessibility)),t.tooltips&&(r.tooltips=Fn(Fn({},this.config.tooltips),t.tooltips)),t.landing&&(r.landing=Fn(Fn({},this.config.landing),t.landing)),void 0!==t.direction&&void 0===r.direction&&(r.direction=t.direction),void 0!==t.primaryColor&&(r.primaryColor=t.primaryColor),Object.keys(t).forEach(function(n){["panel","button","header","icon","messages","direction","voice","text","animation","behavior","accessibility","language","tooltips","landing","primaryColor"].includes(n)||(r[n]=t[n])}),null===(n=this.config)||void 0===n||n.language,this.config=this.mergeWithDefaults(r);var a=this.config.language||"en",c=Fn(Fn(Fn({},this.config),this.config.voice),{},{language:a,websocketUrl:(null===(e=this.config.voice)||void 0===e?void 0:e.websocketUrl)||this.config.websocketUrl||"wss://speech.talktopc.com/ws/conv",translations:this.translations});this.voiceInterface=new vn(c);var s=Fn(Fn(Fn({},this.config),this.config.text),{},{language:a,translations:this.translations});this.textInterface=new Cn(s,this.sdk);var l=document.getElementById("text-chat-widget");l&&l.remove(),this.createWidget(),this.textInterface&&this.textInterface.updateInputAttributes&&this.textInterface.updateInputAttributes()}},{key:"destroy",value:function(){var t=document.getElementById("text-chat-widget");t&&t.remove(),this.sdk&&this.sdk.destroy(),this.voiceInterface&&this.voiceInterface.destroy()}},{key:"startVoiceCall",value:(e=En(In().m(function t(){return In().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this.voiceInterface.startVoiceCall();case 1:return t.a(2)}},t,this)})),function(){return e.apply(this,arguments)})},{key:"endVoiceCall",value:function(){this.voiceInterface.endVoiceCall()}},{key:"toggleMute",value:function(){this.voiceInterface.toggleMute()}},{key:"toggleSpeaker",value:function(){this.voiceInterface.toggleSpeaker()}}],n&&Dn(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,e,o,i,r}(),Rn="2.0.0";const _n={VoiceSDK:pt,TextChatSDK:Ot,WebSocketManager:T,AudioRecorder:K,AudioPlayer:Z,EventEmitter:c,VoiceButton:Rt,VanillaVoiceButton:qt,AgentSDK:cn,AgentWidget:sn,TextChatWidget:zn,VERSION:Rn};return o})());
3
3
  //# sourceMappingURL=agent-widget.js.map