@desivocal/agents-cdn 1.0.7-appha.0 → 1.0.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.
@@ -59188,7 +59188,7 @@ const Lse = ({
59188
59188
  return ye({ hasError: !0, message: "Microphone access was denied. Please enable it in your browser settings." });
59189
59189
  x(!0), B(Rt);
59190
59190
  try {
59191
- const Pt = e === "dev" ? "https://calling-dev.ringg.ai/ca/api/v0" : e === "stage" ? "https://stage-api2.desivocal.com/ca/api/v0" : "https://prod-api.ringg.ai/ca/api/v0", ln = e === "dev" ? "wss://ringg-ai-dev-92tubwpz.livekit.cloud" : e === "stage" ? "wss://ringg-ai-ujrjmhgy.livekit.cloud" : "wss://ringg-ai-prod-r0vhjzhs.livekit.cloud", W = await fetch(`${Pt}/calling/webcall`, {
59191
+ const Pt = e === "dev" ? "https://stage-api2.desivocal.com/ca/api/v0" : e === "stage" ? void 0 : "https://prod-api.ringg.ai/ca/api/v0", ln = e === "dev" ? "wss://ringg-ai-ujrjmhgy.livekit.cloud" : void 0, W = await fetch(`${Pt}/calling/webcall`, {
59192
59192
  method: "POST",
59193
59193
  body: JSON.stringify({ agent_id: a, custom_args_values: o, media_type: Rt }),
59194
59194
  headers: { "Content-Type": "application/json", "X-API-KEY": c }
@@ -339,4 +339,4 @@ a=extmap-allow-mixed`)!==-1){const o=a.sdp.split(`
339
339
  `))+1))}const l="#".repeat(a),c=n.enter("headingAtx"),h=n.enter("phrasing");o.move(l+" ");let m=n.containerPhrasing(t,{before:"# ",after:`
340
340
  `,...o.current()});return/^[\t ]/.test(m)&&(m=Ev(m.charCodeAt(0))+m.slice(1)),m=m?l+" "+m:l,n.options.closeAtx&&(m+=" "+l),h(),c(),m}l5.peek=mJ;function l5(t){return t.value||""}function mJ(){return"<"}u5.peek=gJ;function u5(t,e,n,r){const a=nE(n),o=a==='"'?"Quote":"Apostrophe",l=n.enter("image");let c=n.enter("label");const h=n.createTracker(r);let m=h.move("![");return m+=h.move(n.safe(t.alt,{before:m,after:"]",...h.current()})),m+=h.move("]("),c(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(c=n.enter("destinationLiteral"),m+=h.move("<"),m+=h.move(n.safe(t.url,{before:m,after:">",...h.current()})),m+=h.move(">")):(c=n.enter("destinationRaw"),m+=h.move(n.safe(t.url,{before:m,after:t.title?" ":")",...h.current()}))),c(),t.title&&(c=n.enter(`title${o}`),m+=h.move(" "+a),m+=h.move(n.safe(t.title,{before:m,after:a,...h.current()})),m+=h.move(a),c()),m+=h.move(")"),l(),m}function gJ(){return"!"}c5.peek=vJ;function c5(t,e,n,r){const a=t.referenceType,o=n.enter("imageReference");let l=n.enter("label");const c=n.createTracker(r);let h=c.move("![");const m=n.safe(t.alt,{before:h,after:"]",...c.current()});h+=c.move(m+"]["),l();const v=n.stack;n.stack=[],l=n.enter("reference");const b=n.safe(n.associationId(t),{before:h,after:"]",...c.current()});return l(),n.stack=v,o(),a==="full"||!m||m!==b?h+=c.move(b+"]"):a==="shortcut"?h=h.slice(0,-1):h+=c.move("]"),h}function vJ(){return"!"}d5.peek=yJ;function d5(t,e,n){let r=t.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(r);)a+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const l=n.unsafe[o],c=n.compilePattern(l);let h;if(l.atBreak)for(;h=c.exec(r);){let m=h.index;r.charCodeAt(m)===10&&r.charCodeAt(m-1)===13&&m--,r=r.slice(0,m)+" "+r.slice(h.index+1)}}return a+r+a}function yJ(){return"`"}function f5(t,e){const n=Pw(t);return!!(!e.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(n===t.url||"mailto:"+n===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}h5.peek=bJ;function h5(t,e,n,r){const a=nE(n),o=a==='"'?"Quote":"Apostrophe",l=n.createTracker(r);let c,h;if(f5(t,n)){const v=n.stack;n.stack=[],c=n.enter("autolink");let b=l.move("<");return b+=l.move(n.containerPhrasing(t,{before:b,after:">",...l.current()})),b+=l.move(">"),c(),n.stack=v,b}c=n.enter("link"),h=n.enter("label");let m=l.move("[");return m+=l.move(n.containerPhrasing(t,{before:m,after:"](",...l.current()})),m+=l.move("]("),h(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(h=n.enter("destinationLiteral"),m+=l.move("<"),m+=l.move(n.safe(t.url,{before:m,after:">",...l.current()})),m+=l.move(">")):(h=n.enter("destinationRaw"),m+=l.move(n.safe(t.url,{before:m,after:t.title?" ":")",...l.current()}))),h(),t.title&&(h=n.enter(`title${o}`),m+=l.move(" "+a),m+=l.move(n.safe(t.title,{before:m,after:a,...l.current()})),m+=l.move(a),h()),m+=l.move(")"),c(),m}function bJ(t,e,n){return f5(t,n)?"<":"["}p5.peek=SJ;function p5(t,e,n,r){const a=t.referenceType,o=n.enter("linkReference");let l=n.enter("label");const c=n.createTracker(r);let h=c.move("[");const m=n.containerPhrasing(t,{before:h,after:"]",...c.current()});h+=c.move(m+"]["),l();const v=n.stack;n.stack=[],l=n.enter("reference");const b=n.safe(n.associationId(t),{before:h,after:"]",...c.current()});return l(),n.stack=v,o(),a==="full"||!m||m!==b?h+=c.move(b+"]"):a==="shortcut"?h=h.slice(0,-1):h+=c.move("]"),h}function SJ(){return"["}function rE(t){const e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function kJ(t){const e=rE(t),n=t.options.bulletOther;if(!n)return e==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+n+"`) to be different");return n}function CJ(t){const e=t.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function m5(t){const e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function TJ(t,e,n,r){const a=n.enter("list"),o=n.bulletCurrent;let l=t.ordered?CJ(n):rE(n);const c=t.ordered?l==="."?")":".":kJ(n);let h=e&&n.bulletLastUsed?l===n.bulletLastUsed:!1;if(!t.ordered){const v=t.children?t.children[0]:void 0;if((l==="*"||l==="-")&&v&&(!v.children||!v.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(h=!0),m5(n)===l&&v){let b=-1;for(;++b<t.children.length;){const C=t.children[b];if(C&&C.type==="listItem"&&C.children&&C.children[0]&&C.children[0].type==="thematicBreak"){h=!0;break}}}}h&&(l=c),n.bulletCurrent=l;const m=n.containerFlow(t,r);return n.bulletLastUsed=l,n.bulletCurrent=o,a(),m}function xJ(t){const e=t.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function wJ(t,e,n,r){const a=xJ(n);let o=n.bulletCurrent||rE(n);e&&e.type==="list"&&e.ordered&&(o=(typeof e.start=="number"&&e.start>-1?e.start:1)+(n.options.incrementListMarker===!1?0:e.children.indexOf(t))+o);let l=o.length+1;(a==="tab"||a==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(l=Math.ceil(l/4)*4);const c=n.createTracker(r);c.move(o+" ".repeat(l-o.length)),c.shift(l);const h=n.enter("listItem"),m=n.indentLines(n.containerFlow(t,c.current()),v);return h(),m;function v(b,C,x){return C?(x?"":" ".repeat(l))+b:(x?o:o+" ".repeat(l-o.length))+b}}function EJ(t,e,n,r){const a=n.enter("paragraph"),o=n.enter("phrasing"),l=n.containerPhrasing(t,r);return o(),a(),l}const _J=hk(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function RJ(t,e,n,r){return(t.children.some(function(l){return _J(l)})?n.containerPhrasing:n.containerFlow).call(n,t,r)}function PJ(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}g5.peek=DJ;function g5(t,e,n,r){const a=PJ(n),o=n.enter("strong"),l=n.createTracker(r),c=l.move(a+a);let h=l.move(n.containerPhrasing(t,{after:a,before:c,...l.current()}));const m=h.charCodeAt(0),v=vk(r.before.charCodeAt(r.before.length-1),m,a);v.inside&&(h=Ev(m)+h.slice(1));const b=h.charCodeAt(h.length-1),C=vk(r.after.charCodeAt(0),b,a);C.inside&&(h=h.slice(0,-1)+Ev(b));const x=l.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:C.outside,before:v.outside},c+h+x}function DJ(t,e,n){return n.options.strong||"*"}function AJ(t,e,n,r){return n.safe(t.value,r)}function OJ(t){const e=t.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function MJ(t,e,n){const r=(m5(n)+(n.options.ruleSpaces?" ":"")).repeat(OJ(n));return n.options.ruleSpaces?r.slice(0,-1):r}const v5={blockquote:nJ,break:s5,code:lJ,definition:cJ,emphasis:o5,hardBreak:s5,heading:pJ,html:l5,image:u5,imageReference:c5,inlineCode:d5,link:h5,linkReference:p5,list:TJ,listItem:wJ,paragraph:EJ,root:RJ,strong:g5,text:AJ,thematicBreak:MJ};function LJ(){return{enter:{table:IJ,tableData:y5,tableHeader:y5,tableRow:UJ},exit:{codeText:FJ,table:NJ,tableData:iE,tableHeader:iE,tableRow:iE}}}function IJ(t){const e=t._align;this.enter({type:"table",align:e.map(function(n){return n==="none"?null:n}),children:[]},t),this.data.inTable=!0}function NJ(t){this.exit(t),this.data.inTable=void 0}function UJ(t){this.enter({type:"tableRow",children:[]},t)}function iE(t){this.exit(t)}function y5(t){this.enter({type:"tableCell",children:[]},t)}function FJ(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,jJ));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function jJ(t,e){return e==="|"?e:t}function VJ(t){const e=t,n=e.tableCellPadding,r=e.tablePipeAlign,a=e.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
341
341
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:C,table:l,tableCell:h,tableRow:c}};function l(x,_,R,L){return m(v(x,R,L),x.align)}function c(x,_,R,L){const A=b(x,R,L),F=m([A]);return F.slice(0,F.indexOf(`
342
- `))}function h(x,_,R,L){const A=R.enter("tableCell"),F=R.enter("phrasing"),j=R.containerPhrasing(x,{...L,before:o,after:o});return F(),A(),j}function m(x,_){return eJ(x,{align:_,alignDelimiters:r,padding:n,stringLength:a})}function v(x,_,R){const L=x.children;let A=-1;const F=[],j=_.enter("table");for(;++A<L.length;)F[A]=b(L[A],_,R);return j(),F}function b(x,_,R){const L=x.children;let A=-1;const F=[],j=_.enter("tableRow");for(;++A<L.length;)F[A]=h(L[A],x,_,R);return j(),F}function C(x,_,R){let L=v5.inlineCode(x,_,R);return R.stack.includes("tableCell")&&(L=L.replace(/\|/g,"\\$&")),L}}function zJ(){return{exit:{taskListCheckValueChecked:b5,taskListCheckValueUnchecked:b5,paragraph:HJ}}}function BJ(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:$J}}}function b5(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function HJ(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const a=e.children;let o=-1,l;for(;++o<a.length;){const c=a[o];if(c.type==="paragraph"){l=c;break}}l===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function $J(t,e,n,r){const a=t.children[0],o=typeof t.checked=="boolean"&&a&&a.type==="paragraph",l="["+(t.checked?"x":" ")+"] ",c=n.createTracker(r);o&&c.move(l);let h=v5.listItem(t,e,n,{...r,...c.current()});return o&&(h=h.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,m)),h;function m(v){return v+l}}function qJ(){return[CX(),LX(),KX(),LJ(),zJ()]}function WJ(t){return{extensions:[TX(),IX(),YX(),VJ(t),BJ()]}}const GJ={tokenize:JJ,partial:!0},S5={tokenize:eee,partial:!0},k5={tokenize:tee,partial:!0},C5={tokenize:nee,partial:!0},KJ={tokenize:ree,partial:!0},T5={name:"wwwAutolink",tokenize:QJ,previous:w5},x5={name:"protocolAutolink",tokenize:XJ,previous:E5},mu={name:"emailAutolink",tokenize:ZJ,previous:_5},yl={};function YJ(){return{text:yl}}let hf=48;for(;hf<123;)yl[hf]=mu,hf++,hf===58?hf=65:hf===91&&(hf=97);yl[43]=mu,yl[45]=mu,yl[46]=mu,yl[95]=mu,yl[72]=[mu,x5],yl[104]=[mu,x5],yl[87]=[mu,T5],yl[119]=[mu,T5];function ZJ(t,e,n){const r=this;let a,o;return l;function l(b){return!aE(b)||!_5.call(r,r.previous)||sE(r.events)?n(b):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),c(b))}function c(b){return aE(b)?(t.consume(b),c):b===64?(t.consume(b),h):n(b)}function h(b){return b===46?t.check(KJ,v,m)(b):b===45||b===95||oa(b)?(o=!0,t.consume(b),h):v(b)}function m(b){return t.consume(b),a=!0,h}function v(b){return o&&a&&Ra(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(b)):n(b)}}function QJ(t,e,n){const r=this;return a;function a(l){return l!==87&&l!==119||!w5.call(r,r.previous)||sE(r.events)?n(l):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(GJ,t.attempt(S5,t.attempt(k5,o),n),n)(l))}function o(l){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(l)}}function XJ(t,e,n){const r=this;let a="",o=!1;return l;function l(b){return(b===72||b===104)&&E5.call(r,r.previous)&&!sE(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),a+=String.fromCodePoint(b),t.consume(b),c):n(b)}function c(b){if(Ra(b)&&a.length<5)return a+=String.fromCodePoint(b),t.consume(b),c;if(b===58){const C=a.toLowerCase();if(C==="http"||C==="https")return t.consume(b),h}return n(b)}function h(b){return b===47?(t.consume(b),o?m:(o=!0,h)):n(b)}function m(b){return b===null||rk(b)||fr(b)||ff(b)||ik(b)?n(b):t.attempt(S5,t.attempt(k5,v),n)(b)}function v(b){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(b)}}function JJ(t,e,n){let r=0;return a;function a(l){return(l===87||l===119)&&r<3?(r++,t.consume(l),a):l===46&&r===3?(t.consume(l),o):n(l)}function o(l){return l===null?n(l):e(l)}}function eee(t,e,n){let r,a,o;return l;function l(m){return m===46||m===95?t.check(C5,h,c)(m):m===null||fr(m)||ff(m)||m!==45&&ik(m)?h(m):(o=!0,t.consume(m),l)}function c(m){return m===95?r=!0:(a=r,r=void 0),t.consume(m),l}function h(m){return a||r||!o?n(m):e(m)}}function tee(t,e){let n=0,r=0;return a;function a(l){return l===40?(n++,t.consume(l),a):l===41&&r<n?o(l):l===33||l===34||l===38||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===60||l===63||l===93||l===95||l===126?t.check(C5,e,o)(l):l===null||fr(l)||ff(l)?e(l):(t.consume(l),a)}function o(l){return l===41&&r++,t.consume(l),a}}function nee(t,e,n){return r;function r(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(t.consume(c),r):c===38?(t.consume(c),o):c===93?(t.consume(c),a):c===60||c===null||fr(c)||ff(c)?e(c):n(c)}function a(c){return c===null||c===40||c===91||fr(c)||ff(c)?e(c):r(c)}function o(c){return Ra(c)?l(c):n(c)}function l(c){return c===59?(t.consume(c),r):Ra(c)?(t.consume(c),l):n(c)}}function ree(t,e,n){return r;function r(o){return t.consume(o),a}function a(o){return oa(o)?n(o):e(o)}}function w5(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||fr(t)}function E5(t){return!Ra(t)}function _5(t){return!(t===47||aE(t))}function aE(t){return t===43||t===45||t===46||t===95||oa(t)}function sE(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const iee={tokenize:fee,partial:!0};function aee(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:uee,continuation:{tokenize:cee},exit:dee}},text:{91:{name:"gfmFootnoteCall",tokenize:lee},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:see,resolveTo:oee}}}}function see(t,e,n){const r=this;let a=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l;for(;a--;){const h=r.events[a][1];if(h.type==="labelImage"){l=h;break}if(h.type==="gfmFootnoteCall"||h.type==="labelLink"||h.type==="label"||h.type==="image"||h.type==="link")break}return c;function c(h){if(!l||!l._balanced)return n(h);const m=_o(r.sliceSerialize({start:l.end,end:r.now()}));return m.codePointAt(0)!==94||!o.includes(m.slice(1))?n(h):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),e(h))}}function oee(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},t[t.length-1][1].start)},l={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},c=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",a,e],["exit",a,e],["enter",o,e],["enter",l,e],["exit",l,e],["exit",o,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...c),t}function lee(t,e,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,l;return c;function c(b){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(b),t.exit("gfmFootnoteCallLabelMarker"),h}function h(b){return b!==94?n(b):(t.enter("gfmFootnoteCallMarker"),t.consume(b),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",m)}function m(b){if(o>999||b===93&&!l||b===null||b===91||fr(b))return n(b);if(b===93){t.exit("chunkString");const C=t.exit("gfmFootnoteCallString");return a.includes(_o(r.sliceSerialize(C)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(b),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(b)}return fr(b)||(l=!0),o++,t.consume(b),b===92?v:m}function v(b){return b===91||b===92||b===93?(t.consume(b),o++,m):m(b)}}function uee(t,e,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,l=0,c;return h;function h(_){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(_),t.exit("gfmFootnoteDefinitionLabelMarker"),m}function m(_){return _===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(_),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",v):n(_)}function v(_){if(l>999||_===93&&!c||_===null||_===91||fr(_))return n(_);if(_===93){t.exit("chunkString");const R=t.exit("gfmFootnoteDefinitionLabelString");return o=_o(r.sliceSerialize(R)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(_),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),C}return fr(_)||(c=!0),l++,t.consume(_),_===92?b:v}function b(_){return _===91||_===92||_===93?(t.consume(_),l++,v):v(_)}function C(_){return _===58?(t.enter("definitionMarker"),t.consume(_),t.exit("definitionMarker"),a.includes(o)||a.push(o),Mn(t,x,"gfmFootnoteDefinitionWhitespace")):n(_)}function x(_){return e(_)}}function cee(t,e,n){return t.check(kv,e,t.attempt(iee,e,n))}function dee(t){t.exit("gfmFootnoteDefinition")}function fee(t,e,n){const r=this;return Mn(t,a,"gfmFootnoteDefinitionIndent",5);function a(o){const l=r.events[r.events.length-1];return l&&l[1].type==="gfmFootnoteDefinitionIndent"&&l[2].sliceSerialize(l[1],!0).length===4?e(o):n(o)}}function hee(t){let n=t.singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function a(l,c){let h=-1;for(;++h<l.length;)if(l[h][0]==="enter"&&l[h][1].type==="strikethroughSequenceTemporary"&&l[h][1]._close){let m=h;for(;m--;)if(l[m][0]==="exit"&&l[m][1].type==="strikethroughSequenceTemporary"&&l[m][1]._open&&l[h][1].end.offset-l[h][1].start.offset===l[m][1].end.offset-l[m][1].start.offset){l[h][1].type="strikethroughSequence",l[m][1].type="strikethroughSequence";const v={type:"strikethrough",start:Object.assign({},l[m][1].start),end:Object.assign({},l[h][1].end)},b={type:"strikethroughText",start:Object.assign({},l[m][1].end),end:Object.assign({},l[h][1].start)},C=[["enter",v,c],["enter",l[m][1],c],["exit",l[m][1],c],["enter",b,c]],x=c.parser.constructs.insideSpan.null;x&&xs(C,C.length,0,ak(x,l.slice(m+1,h),c)),xs(C,C.length,0,[["exit",b,c],["enter",l[h][1],c],["exit",l[h][1],c],["exit",v,c]]),xs(l,m-1,h-m+3,C),h=m+C.length-2;break}}for(h=-1;++h<l.length;)l[h][1].type==="strikethroughSequenceTemporary"&&(l[h][1].type="data");return l}function o(l,c,h){const m=this.previous,v=this.events;let b=0;return C;function C(_){return m===126&&v[v.length-1][1].type!=="characterEscape"?h(_):(l.enter("strikethroughSequenceTemporary"),x(_))}function x(_){const R=vp(m);if(_===126)return b>1?h(_):(l.consume(_),b++,x);if(b<2&&!n)return h(_);const L=l.exit("strikethroughSequenceTemporary"),A=vp(_);return L._open=!A||A===2&&!!R,L._close=!R||R===2&&!!A,c(_)}}}class pee{constructor(){this.map=[]}add(e,n,r){mee(this,e,n,r)}consume(e){if(this.map.sort(function(o,l){return o[0]-l[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push([...e]),e.length=0;let a=r.pop();for(;a;)e.push(...a),a=r.pop();this.map.length=0}}function mee(t,e,n,r){let a=0;if(!(n===0&&r.length===0)){for(;a<t.map.length;){if(t.map[a][0]===e){t.map[a][1]+=n,t.map[a][2].push(...r);return}a+=1}t.map.push([e,n,r])}}function gee(t,e){let n=!1;const r=[];for(;e<t.length;){const a=t[e];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function vee(){return{flow:{null:{name:"table",tokenize:yee,resolveAll:bee}}}}function yee(t,e,n){const r=this;let a=0,o=0,l;return c;function c(q){let ae=r.events.length-1;for(;ae>-1;){const Ee=r.events[ae][1].type;if(Ee==="lineEnding"||Ee==="linePrefix")ae--;else break}const X=ae>-1?r.events[ae][1].type:null,_e=X==="tableHead"||X==="tableRow"?N:h;return _e===N&&r.parser.lazy[r.now().line]?n(q):_e(q)}function h(q){return t.enter("tableHead"),t.enter("tableRow"),m(q)}function m(q){return q===124||(l=!0,o+=1),v(q)}function v(q){return q===null?n(q):Ft(q)?o>1?(o=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(q),t.exit("lineEnding"),x):n(q):Cn(q)?Mn(t,v,"whitespace")(q):(o+=1,l&&(l=!1,a+=1),q===124?(t.enter("tableCellDivider"),t.consume(q),t.exit("tableCellDivider"),l=!0,v):(t.enter("data"),b(q)))}function b(q){return q===null||q===124||fr(q)?(t.exit("data"),v(q)):(t.consume(q),q===92?C:b)}function C(q){return q===92||q===124?(t.consume(q),b):b(q)}function x(q){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(q):(t.enter("tableDelimiterRow"),l=!1,Cn(q)?Mn(t,_,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(q):_(q))}function _(q){return q===45||q===58?L(q):q===124?(l=!0,t.enter("tableCellDivider"),t.consume(q),t.exit("tableCellDivider"),R):I(q)}function R(q){return Cn(q)?Mn(t,L,"whitespace")(q):L(q)}function L(q){return q===58?(o+=1,l=!0,t.enter("tableDelimiterMarker"),t.consume(q),t.exit("tableDelimiterMarker"),A):q===45?(o+=1,A(q)):q===null||Ft(q)?B(q):I(q)}function A(q){return q===45?(t.enter("tableDelimiterFiller"),F(q)):I(q)}function F(q){return q===45?(t.consume(q),F):q===58?(l=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(q),t.exit("tableDelimiterMarker"),j):(t.exit("tableDelimiterFiller"),j(q))}function j(q){return Cn(q)?Mn(t,B,"whitespace")(q):B(q)}function B(q){return q===124?_(q):q===null||Ft(q)?!l||a!==o?I(q):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(q)):I(q)}function I(q){return n(q)}function N(q){return t.enter("tableRow"),J(q)}function J(q){return q===124?(t.enter("tableCellDivider"),t.consume(q),t.exit("tableCellDivider"),J):q===null||Ft(q)?(t.exit("tableRow"),e(q)):Cn(q)?Mn(t,J,"whitespace")(q):(t.enter("data"),ee(q))}function ee(q){return q===null||q===124||fr(q)?(t.exit("data"),J(q)):(t.consume(q),q===92?ye:ee)}function ye(q){return q===92||q===124?(t.consume(q),ee):ee(q)}}function bee(t,e){let n=-1,r=!0,a=0,o=[0,0,0,0],l=[0,0,0,0],c=!1,h=0,m,v,b;const C=new pee;for(;++n<t.length;){const x=t[n],_=x[1];x[0]==="enter"?_.type==="tableHead"?(c=!1,h!==0&&(R5(C,e,h,m,v),v=void 0,h=0),m={type:"table",start:Object.assign({},_.start),end:Object.assign({},_.end)},C.add(n,0,[["enter",m,e]])):_.type==="tableRow"||_.type==="tableDelimiterRow"?(r=!0,b=void 0,o=[0,0,0,0],l=[0,n+1,0,0],c&&(c=!1,v={type:"tableBody",start:Object.assign({},_.start),end:Object.assign({},_.end)},C.add(n,0,[["enter",v,e]])),a=_.type==="tableDelimiterRow"?2:v?3:1):a&&(_.type==="data"||_.type==="tableDelimiterMarker"||_.type==="tableDelimiterFiller")?(r=!1,l[2]===0&&(o[1]!==0&&(l[0]=l[1],b=yk(C,e,o,a,void 0,b),o=[0,0,0,0]),l[2]=n)):_.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(l[0]=l[1],b=yk(C,e,o,a,void 0,b)),o=l,l=[o[1],n,0,0])):_.type==="tableHead"?(c=!0,h=n):_.type==="tableRow"||_.type==="tableDelimiterRow"?(h=n,o[1]!==0?(l[0]=l[1],b=yk(C,e,o,a,n,b)):l[1]!==0&&(b=yk(C,e,l,a,n,b)),a=0):a&&(_.type==="data"||_.type==="tableDelimiterMarker"||_.type==="tableDelimiterFiller")&&(l[3]=n)}for(h!==0&&R5(C,e,h,m,v),C.consume(e.events),n=-1;++n<e.events.length;){const x=e.events[n];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=gee(e.events,n))}return t}function yk(t,e,n,r,a,o){const l=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(o.end=Object.assign({},bp(e.events,n[0])),t.add(n[0],0,[["exit",o,e]]));const h=bp(e.events,n[1]);if(o={type:l,start:Object.assign({},h),end:Object.assign({},h)},t.add(n[1],0,[["enter",o,e]]),n[2]!==0){const m=bp(e.events,n[2]),v=bp(e.events,n[3]),b={type:c,start:Object.assign({},m),end:Object.assign({},v)};if(t.add(n[2],0,[["enter",b,e]]),r!==2){const C=e.events[n[2]],x=e.events[n[3]];if(C[1].end=Object.assign({},x[1].end),C[1].type="chunkText",C[1].contentType="text",n[3]>n[2]+1){const _=n[2]+1,R=n[3]-n[2]-1;t.add(_,R,[])}}t.add(n[3]+1,0,[["exit",b,e]])}return a!==void 0&&(o.end=Object.assign({},bp(e.events,a)),t.add(a,0,[["exit",o,e]]),o=void 0),o}function R5(t,e,n,r,a){const o=[],l=bp(e.events,n);a&&(a.end=Object.assign({},l),o.push(["exit",a,e])),r.end=Object.assign({},l),o.push(["exit",r,e]),t.add(n+1,0,o)}function bp(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const See={name:"tasklistCheck",tokenize:Cee};function kee(){return{text:{91:See}}}function Cee(t,e,n){const r=this;return a;function a(h){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(h):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(h),t.exit("taskListCheckMarker"),o)}function o(h){return fr(h)?(t.enter("taskListCheckValueUnchecked"),t.consume(h),t.exit("taskListCheckValueUnchecked"),l):h===88||h===120?(t.enter("taskListCheckValueChecked"),t.consume(h),t.exit("taskListCheckValueChecked"),l):n(h)}function l(h){return h===93?(t.enter("taskListCheckMarker"),t.consume(h),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),c):n(h)}function c(h){return Ft(h)?e(h):Cn(h)?t.check({tokenize:Tee},e,n)(h):n(h)}}function Tee(t,e,n){return Mn(t,r,"whitespace");function r(a){return a===null?n(a):e(a)}}function xee(t){return i4([YJ(),aee(),hee(t),vee(),kee()])}const wee={};function Eee(t){const e=this,n=t||wee,r=e.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),l=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(xee(n)),o.push(qJ()),l.push(WJ(n))}const _ee=({itemIndex:t,message:e})=>{const n=uW(e.name);return Se.jsx("div",{className:vi("ringg_ai-flex ringg_ai-flex-col ringg_ai-items-start ringg_ai-gap-1 ringg_ai-justify-start",n?"ringg_ai-flex-row":"ringg_ai-flex-row-reverse"),children:Se.jsx("div",{className:vi("ringg_ai-flex ringg_ai-items-center ringg_ai-justify-start ringg_ai-gap-2 ringg_ai-px-4 ringg_ai-py-2 ringg_ai-rounded-xl ringg_ai-max-w-[75%]",n?"ringg_ai-bg-[#F3F3F5] ringg_ai-mr-auto ringg_ai-text-left ringg_ai-rounded-bl-none":"ringg_ai-bg-[#2C2E30] ringg_ai-text-white ringg_ai-ml-auto ringg_ai-text-right ringg_ai-rounded-br-none"),children:Se.jsxs("div",{className:"ringg_ai-flex ringg_ai-flex-col ringg_ai-gap-2.5 ringg_ai-w-fit",children:[Se.jsx(mX,{remarkPlugins:[Eee],className:"ringg_ai-prose ringg_ai-prose-sm ringg_ai-break-before-auto ringg_ai-w-fit [&_p]:ringg_ai-text-sm [&_li]:ringg_ai-text-sm",children:e.message}),(e==null?void 0:e.sourceUrl)&&Se.jsxs("a",{href:e.sourceUrl,target:"_blank",rel:"noopener noreferrer",className:"ringg_ai-text-sm ringg_ai-break-all ringg_ai-w-fit ringg_ai-text-blue-600 ringg_ai-hover:underline",children:["Source: ",e.sourceUrl]})]})},`${e.name}__${t}`)},`${e.timestamp}__${t}`)};function Ree({tabs:t=[],activeTab:e="voice-call",onTabChange:n}){const[r,a]=he.useState(e),o=l=>{a(l),n==null||n(l)};return Se.jsx("div",{className:"ringg_ai-w-full ringg_ai-bg-white ringg_ai-border-t ringg_ai-border-gray-200",children:Se.jsx("div",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-px-0",children:t.map(l=>{const c=l.icon,h=r===l.id;return Se.jsxs("button",{onClick:()=>o(l.id),className:vi("ringg_ai-flex ringg_ai-flex-col ringg_ai-items-center ringg_ai-gap-1 ringg_ai-border-t ringg_ai-py-3 ringg_ai-transition-all ringg_ai-duration-200 ringg_ai-flex-1",h?"ringg_ai-border-t-black":"ringg_ai-border-t-transparent"),children:[Se.jsx(c,{className:vi("ringg_ai-w-5 ringg_ai-h-5 ringg_ai-transition-colors",h?"ringg_ai-text-black [&_path]:ringg_ai-fill-black":"ringg_ai-text-gray-400 [&_path]:ringg_ai-fill-gray-400")}),Se.jsx("span",{className:vi("ringg_ai-text-xs ringg_ai-font-medium ringg_ai-transition-colors",h?"ringg_ai-text-black":"ringg_ai-text-gray-400"),children:l.label})]},l.id)})})})}const Pee=({room:t,config:{mode:e="prod",title:n="Ringg AI Support",description:r="Ringg AI offers 24/7 voice support to handle your business calls efficiently and professionally",agentId:a,variables:o,buttons:l,xApiKey:c,defaultTab:h="audio",hideTabSelector:m=!1,innerWindowProps:v}})=>{var Lt,Xt,Fn,hr,pr,Yn;const b=B0(t),[C,x]=he.useState(!1),_=he.createRef(),R=he.useRef(""),L=he.useRef(),[A,F]=he.useState(!1),[j,B]=he.useState(h),I=he.useRef(null),[N,J]=he.useState(!1),[ee,ye]=he.useState({hasError:!1,message:""}),[q,ae]=he.useState("unknown"),X={bottom:((Xt=(Lt=l==null?void 0:l.modalTrigger)==null?void 0:Lt.styles)==null?void 0:Xt.top)||"2%",right:((hr=(Fn=l==null?void 0:l.modalTrigger)==null?void 0:Fn.styles)==null?void 0:hr.bottom)||"2%"},_e={width:v!=null&&v.width?typeof v.width=="number"?`${v.width}px`:v.width:void 0,height:v!=null&&v.height?typeof v.height=="number"?`${v.height}px`:v.height:void 0,borderRadius:v!=null&&v.borderRadius?typeof v.borderRadius=="number"?`${v.borderRadius}px`:v.borderRadius:void 0},{chatMessages:Ee}=CM(),ze=Iz(),Qe=Ez(),Ie=b==="connected",[de,Be]=he.useState([]),V=H0(ze.audioTrack||void 0),[Z,ke]=he.useState(new Map),H=H0({publication:Qe.microphoneTrack,source:De.Source.Microphone,participant:Qe.localParticipant}),vt=async()=>{try{if(navigator.permissions&&navigator.permissions.query){const Pt=await navigator.permissions.query({name:"microphone"});ae(Pt.state),Pt.onchange=()=>{ae(Pt.state),Pt.state==="granted"&&ye({hasError:!1,message:""})}}else try{await navigator.mediaDevices.getUserMedia({audio:!0}),ae("granted")}catch{ae("denied")}}catch(Pt){console.error("Error checking microphone permission:",Pt),ae("unknown")}},wt=async()=>{try{const Pt=await navigator.mediaDevices.getUserMedia({audio:!0});return ae("granted"),ye({hasError:!1,message:""}),Pt.getTracks().forEach(Dt=>Dt.stop()),!0}catch(Pt){return console.error("Error requesting microphone permission:",Pt),ae("denied"),ye({hasError:!0,message:"Microphone access was denied. Please enable it in your browser settings."}),!1}},pt=async Pt=>{if(Pt==="audio"&&q!=="granted"&&!await wt())return ye({hasError:!0,message:"Microphone access was denied. Please enable it in your browser settings."});x(!0),B(Pt);try{const Dt=e==="dev"?"https://calling-dev.ringg.ai/ca/api/v0":e==="stage"?"https://stage-api2.desivocal.com/ca/api/v0":"https://prod-api.ringg.ai/ca/api/v0",un=e==="dev"?"wss://ringg-ai-dev-92tubwpz.livekit.cloud":e==="stage"?"wss://ringg-ai-ujrjmhgy.livekit.cloud":"wss://ringg-ai-prod-r0vhjzhs.livekit.cloud",W=await fetch(`${Dt}/calling/webcall`,{method:"POST",body:JSON.stringify({agent_id:a,custom_args_values:o,media_type:Pt}),headers:{"Content-Type":"application/json","X-API-KEY":c}}),ie=await W.json();if(!W.ok)throw new Error((ie==null?void 0:ie.message)||"Failed to make call");await t.connect(un,ie==null?void 0:ie.user_token),Pt==="audio"&&await t.localParticipant.setMicrophoneEnabled(!0),ye({hasError:!1,message:""})}catch(Dt){ye({hasError:!0,message:Dt.message})}finally{x(!1)}},ot=he.useCallback(async()=>{x(!0);try{Be([]),ke(new Map),R.current="",L.current=void 0,t.disconnect(),F(!1),J(!1)}catch(Pt){ye({hasError:!0,message:"Error ending call: "+Pt.message})}finally{x(!1)}},[t]),ut=async Pt=>{try{const Dt=JSON.parse(Pt.payload);return Array.isArray(Dt.source_urls)?R.current=Dt.source_urls.join(", "):Dt.source_url&&(R.current=Dt.source_url),JSON.stringify({status:"received"})}catch(Dt){throw console.error("Failed to parse RPC payload:",Dt),new Error("Invalid payload for send_source_urls")}};return he.useEffect(()=>(vt(),t.on(we.MediaDevicesError,()=>{ye({hasError:!0,message:"Error acquiring microphone permission. Please make sure you grant the necessary permissions in your browser and reload the tab"}),ae("denied")}),()=>{t.off(we.MediaDevicesError,()=>{})}),[t]),he.useEffect(()=>{if(!t||j!=="audio")return;const Pt=new Map(Z);ze.audioTrack&&V.segments.forEach(W=>{const ie=Pt.get(W.id),ce=nw(W,ie,ze.audioTrack.participant);Pt.set(W.id,ce)}),H.segments.forEach(W=>{const ie=Pt.get(W.id),ce=nw(W,ie,Qe.localParticipant);Pt.set(W.id,ce)});const Dt=Array.from(Pt.values());Dt.sort((W,ie)=>W.timestamp-ie.timestamp);const un=R.current&&Dt[Dt.length-1].name.includes("Agent")&&!Dt[Dt.length-1].sourceUrl&&L.current!==Dt.length-1;if(un){L.current=Dt.length,Dt[Dt.length-1]={...Dt[Dt.length-1],sourceUrl:R.current};const W=Dt.filter(Ue=>!Ue.isSelf).length-1,ie=Pt.get(V.segments[W].id),ce=nw(V.segments[W],{...ie,sourceUrl:R.current},ze.audioTrack.participant);Pt.set(V.segments[W].id,ce)}return Be(Dt),ke(Pt),un||(R.current=""),t.registerRpcMethod("send_source_urls",ut),()=>t.unregisterRpcMethod("send_source_urls")},[j,Ee,V.segments,H.segments,ze.audioTrack,(pr=ze.audioTrack)==null?void 0:pr.participant,Qe.localParticipant]),he.useEffect(()=>{if(!t||j!=="text")return;const Pt=async(un,W)=>{var ie;try{const ce=await un.readAll(),Ue=(ie=W.identity)==null?void 0:ie.includes("agent"),je={message:ce,isSelf:!Ue,name:Ue?"Agent":"You",timestamp:Date.now()+performance.now()%1,...Ue&&{sourceUrl:R.current?R.current:""}};R.current&&(R.current=""),Be(Oe=>{const tt=new Set,It=[...Oe,je].filter(oe=>tt.has(oe.timestamp)?!1:(tt.add(oe.timestamp),!0));return It.sort((oe,Pe)=>oe.timestamp-Pe.timestamp),It})}catch(ce){console.error("Error reading text stream",ce)}},Dt=Ee.map(un=>{var Ue,je,Oe,tt;const W=((Ue=un.from)==null?void 0:Ue.identity)===Qe.localParticipant.identity,ie=ze.audioTrack?((je=un.from)==null?void 0:je.identity)===((Oe=ze.audioTrack.participant)==null?void 0:Oe.identity):!W;return{name:((tt=un.from)==null?void 0:tt.name)||(ie?"Agent":W?"You":"Unknown"),isSelf:W,message:un.message,timestamp:un.timestamp}});return Be(un=>{const W=new Set,ie=[...un,...Dt].filter(ce=>W.has(ce.timestamp)?!1:(W.add(ce.timestamp),!0));return ie.sort((ce,Ue)=>ce.timestamp-Ue.timestamp),ie}),t.registerTextStreamHandler("lk.transcription",Pt),t.registerRpcMethod("send_source_urls",ut),()=>{t.unregisterTextStreamHandler("lk.transcription"),t.unregisterRpcMethod("send_source_urls")}},[t,j,Ee]),he.useEffect(()=>{if(t)return t.on(we.ParticipantDisconnected,ot),t.on(we.Disconnected,ot),()=>{t.off(we.ParticipantDisconnected,ot),t.off(we.Disconnected,ot)}},[ot,t]),he.useEffect(()=>{_.current&&(_.current.scrollTop+=_.current.scrollHeight)},[_,de]),Se.jsxs(Se.Fragment,{children:[!N&&Se.jsx(cu,{size:"icon","aria-label":"Open call widget",onClick:()=>J(!0),style:{position:"fixed",...X,...(Yn=l==null?void 0:l.modalTrigger)==null?void 0:Yn.styles},className:vi("!ringg_ai-z-[9999] !ringg_ai-h-14 !ringg_ai-w-14 !ringg_ai-rounded-full","ringg_ai-trigger-btn"),children:Se.jsx(vI,{className:"!ringg_ai-size-5"})}),N&&Se.jsxs(gq.div,{ref:I,animate:{y:0,opacity:1},exit:{y:200,opacity:.5},initial:{y:200,opacity:.5},style:{position:"fixed",...X,...Ie?_e:{}},transition:{duration:.15,ease:"anticipate"},className:vi("ringg_ai-relative ringg_ai-border ringg_ai-overflow-hidden !ringg_ai-z-[9999] ringg_ai-bg-[#fafafa] ringg_ai-rounded-[20px] ringg_ai-shadow-xl ringg_ai-animate-fade-in ringg_ai-transition-all ringg_ai-w-[95vw] md:ringg_ai-w-[360px]",Ie&&"ringg_ai-h-[24.5rem]"),children:[Se.jsx(cu,{size:"icon",variant:"ghost","aria-label":"Close widget",onClick:()=>Ie?F(!0):J(!1),className:"ringg_ai-absolute !ringg_ai-z-[9999] ringg_ai-top-2.5 ringg_ai-right-2.5 !ringg_ai-rounded-full ringg_ai-text-gray-500 hover:ringg_ai-text-gray-700",children:Se.jsx(Cq,{size:20})}),Se.jsx(ZG,{open:A,onOpenChange:F,containerRef:I,children:Se.jsxs(QG,{children:[Se.jsxs(XG,{children:[Se.jsxs(JG,{children:["Are you sure you want to end ",j==="text"?"chat":j==="audio"?"call":j,"?"]}),Se.jsx(eK,{children:"Your current conversation will be closed and cannot be accessed later."})]}),Se.jsxs(tK,{children:[Se.jsx(cu,{variant:"outline",onClick:()=>F(!1),className:"!ringg_ai-rounded-lg",children:"Cancel"}),Se.jsxs(cu,{onClick:ot,className:"!ringg_ai-rounded-lg",children:["End ",j==="text"?"Chat":j==="audio"?"Call":j]})]})]})}),Se.jsxs("div",{className:"ringg_ai-flex ringg_ai-h-full ringg_ai-flex-col",children:[Se.jsxs("div",{className:vi("ringg_ai-relative ringg_ai-p-5 ringg_ai-h-full ringg_ai-mb-2 ringg_ai-flex ringg_ai-gap-5 ringg_ai-flex-col",!Ie&&"ringg_ai-mt-2"),children:[Se.jsx(nK,{isCalling:Ie,isLoading:C,title:n,description:r}),(de==null?void 0:de.length)===0&&Ie&&Se.jsx("div",{className:"ringg_ai-mt-20 ringg_ai-h-full"}),(de==null?void 0:de.length)>0&&Ie&&Se.jsx("div",{ref:_,className:"ringg_ai-mt-20 ringg_ai-h-full ringg_ai-overflow-y-scroll ringg_ai-flex ringg_ai-flex-col ringg_ai-gap-2.5",children:de.sort((Pt,Dt)=>new Date(Pt.timestamp).getTime()-new Date(Dt.timestamp).getTime()).map((Pt,Dt)=>Se.jsx(_ee,{itemIndex:Dt,message:Pt},`${Pt.timestamp}__${Dt}`))}),Se.jsx(YG,{buttonConfig:l,callMode:j,isCalling:Ie,onCallEnd:ot}),ee.hasError&&Se.jsx("div",{className:"ringg_ai-text-center ringg_ai-text-sm ringg_ai-text-red-500 -ringg_ai-mt-3 -ringg_ai-mb-2",children:ee.message}),b==="disconnected"&&Se.jsx(dW,{callMode:j,buttonConfig:l,isCalling:Ie,isLoading:C,onCallTrigger:pt}),!Ie&&Se.jsxs("p",{className:"ringg_ai-text-xs ringg_ai-text-center ringg_ai-text-[#11111180]",children:["By starting call you agree to ",Se.jsx("a",{target:"_blank",className:"ringg_ai-text-blue-500 hover:ringg_ai-underline",href:"https://www.ringg.ai/privacy",children:"Privacy policy"})," & ",Se.jsx("a",{target:"_blank",className:"ringg_ai-text-blue-500 hover:ringg_ai-underline",href:"https://www.ringg.ai/terms",children:"T&C"})]})]}),!Ie&&!m&&Se.jsx(Ree,{tabs:gG,activeTab:j,onTabChange:Pt=>B(Pt)})]})]}),Se.jsx(jz,{})]})},Dee=({config:t})=>{const[e]=he.useState(()=>new Hh({dynacast:!0,adaptiveStream:!0}));return Se.jsx(V0.Provider,{value:e,children:Se.jsx(Pee,{config:t,room:e})})};(function(t,e){function n(r){var l;const a=e.createElement("div");a.id="ringg_ai_container",r.refId?(l=e.getElementById(r.refId))==null||l.appendChild(a):e.body.appendChild(a),pg.createRoot(a).render(Se.jsx(Wn.StrictMode,{children:Se.jsx(Dee,{config:r})}))}t.loadAgent=n})(window,document)});
342
+ `))}function h(x,_,R,L){const A=R.enter("tableCell"),F=R.enter("phrasing"),j=R.containerPhrasing(x,{...L,before:o,after:o});return F(),A(),j}function m(x,_){return eJ(x,{align:_,alignDelimiters:r,padding:n,stringLength:a})}function v(x,_,R){const L=x.children;let A=-1;const F=[],j=_.enter("table");for(;++A<L.length;)F[A]=b(L[A],_,R);return j(),F}function b(x,_,R){const L=x.children;let A=-1;const F=[],j=_.enter("tableRow");for(;++A<L.length;)F[A]=h(L[A],x,_,R);return j(),F}function C(x,_,R){let L=v5.inlineCode(x,_,R);return R.stack.includes("tableCell")&&(L=L.replace(/\|/g,"\\$&")),L}}function zJ(){return{exit:{taskListCheckValueChecked:b5,taskListCheckValueUnchecked:b5,paragraph:HJ}}}function BJ(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:$J}}}function b5(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function HJ(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const a=e.children;let o=-1,l;for(;++o<a.length;){const c=a[o];if(c.type==="paragraph"){l=c;break}}l===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function $J(t,e,n,r){const a=t.children[0],o=typeof t.checked=="boolean"&&a&&a.type==="paragraph",l="["+(t.checked?"x":" ")+"] ",c=n.createTracker(r);o&&c.move(l);let h=v5.listItem(t,e,n,{...r,...c.current()});return o&&(h=h.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,m)),h;function m(v){return v+l}}function qJ(){return[CX(),LX(),KX(),LJ(),zJ()]}function WJ(t){return{extensions:[TX(),IX(),YX(),VJ(t),BJ()]}}const GJ={tokenize:JJ,partial:!0},S5={tokenize:eee,partial:!0},k5={tokenize:tee,partial:!0},C5={tokenize:nee,partial:!0},KJ={tokenize:ree,partial:!0},T5={name:"wwwAutolink",tokenize:QJ,previous:w5},x5={name:"protocolAutolink",tokenize:XJ,previous:E5},mu={name:"emailAutolink",tokenize:ZJ,previous:_5},yl={};function YJ(){return{text:yl}}let hf=48;for(;hf<123;)yl[hf]=mu,hf++,hf===58?hf=65:hf===91&&(hf=97);yl[43]=mu,yl[45]=mu,yl[46]=mu,yl[95]=mu,yl[72]=[mu,x5],yl[104]=[mu,x5],yl[87]=[mu,T5],yl[119]=[mu,T5];function ZJ(t,e,n){const r=this;let a,o;return l;function l(b){return!aE(b)||!_5.call(r,r.previous)||sE(r.events)?n(b):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),c(b))}function c(b){return aE(b)?(t.consume(b),c):b===64?(t.consume(b),h):n(b)}function h(b){return b===46?t.check(KJ,v,m)(b):b===45||b===95||oa(b)?(o=!0,t.consume(b),h):v(b)}function m(b){return t.consume(b),a=!0,h}function v(b){return o&&a&&Ra(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(b)):n(b)}}function QJ(t,e,n){const r=this;return a;function a(l){return l!==87&&l!==119||!w5.call(r,r.previous)||sE(r.events)?n(l):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(GJ,t.attempt(S5,t.attempt(k5,o),n),n)(l))}function o(l){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(l)}}function XJ(t,e,n){const r=this;let a="",o=!1;return l;function l(b){return(b===72||b===104)&&E5.call(r,r.previous)&&!sE(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),a+=String.fromCodePoint(b),t.consume(b),c):n(b)}function c(b){if(Ra(b)&&a.length<5)return a+=String.fromCodePoint(b),t.consume(b),c;if(b===58){const C=a.toLowerCase();if(C==="http"||C==="https")return t.consume(b),h}return n(b)}function h(b){return b===47?(t.consume(b),o?m:(o=!0,h)):n(b)}function m(b){return b===null||rk(b)||fr(b)||ff(b)||ik(b)?n(b):t.attempt(S5,t.attempt(k5,v),n)(b)}function v(b){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(b)}}function JJ(t,e,n){let r=0;return a;function a(l){return(l===87||l===119)&&r<3?(r++,t.consume(l),a):l===46&&r===3?(t.consume(l),o):n(l)}function o(l){return l===null?n(l):e(l)}}function eee(t,e,n){let r,a,o;return l;function l(m){return m===46||m===95?t.check(C5,h,c)(m):m===null||fr(m)||ff(m)||m!==45&&ik(m)?h(m):(o=!0,t.consume(m),l)}function c(m){return m===95?r=!0:(a=r,r=void 0),t.consume(m),l}function h(m){return a||r||!o?n(m):e(m)}}function tee(t,e){let n=0,r=0;return a;function a(l){return l===40?(n++,t.consume(l),a):l===41&&r<n?o(l):l===33||l===34||l===38||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===60||l===63||l===93||l===95||l===126?t.check(C5,e,o)(l):l===null||fr(l)||ff(l)?e(l):(t.consume(l),a)}function o(l){return l===41&&r++,t.consume(l),a}}function nee(t,e,n){return r;function r(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(t.consume(c),r):c===38?(t.consume(c),o):c===93?(t.consume(c),a):c===60||c===null||fr(c)||ff(c)?e(c):n(c)}function a(c){return c===null||c===40||c===91||fr(c)||ff(c)?e(c):r(c)}function o(c){return Ra(c)?l(c):n(c)}function l(c){return c===59?(t.consume(c),r):Ra(c)?(t.consume(c),l):n(c)}}function ree(t,e,n){return r;function r(o){return t.consume(o),a}function a(o){return oa(o)?n(o):e(o)}}function w5(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||fr(t)}function E5(t){return!Ra(t)}function _5(t){return!(t===47||aE(t))}function aE(t){return t===43||t===45||t===46||t===95||oa(t)}function sE(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const iee={tokenize:fee,partial:!0};function aee(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:uee,continuation:{tokenize:cee},exit:dee}},text:{91:{name:"gfmFootnoteCall",tokenize:lee},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:see,resolveTo:oee}}}}function see(t,e,n){const r=this;let a=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l;for(;a--;){const h=r.events[a][1];if(h.type==="labelImage"){l=h;break}if(h.type==="gfmFootnoteCall"||h.type==="labelLink"||h.type==="label"||h.type==="image"||h.type==="link")break}return c;function c(h){if(!l||!l._balanced)return n(h);const m=_o(r.sliceSerialize({start:l.end,end:r.now()}));return m.codePointAt(0)!==94||!o.includes(m.slice(1))?n(h):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),e(h))}}function oee(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},t[t.length-1][1].start)},l={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},c=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",a,e],["exit",a,e],["enter",o,e],["enter",l,e],["exit",l,e],["exit",o,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...c),t}function lee(t,e,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,l;return c;function c(b){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(b),t.exit("gfmFootnoteCallLabelMarker"),h}function h(b){return b!==94?n(b):(t.enter("gfmFootnoteCallMarker"),t.consume(b),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",m)}function m(b){if(o>999||b===93&&!l||b===null||b===91||fr(b))return n(b);if(b===93){t.exit("chunkString");const C=t.exit("gfmFootnoteCallString");return a.includes(_o(r.sliceSerialize(C)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(b),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(b)}return fr(b)||(l=!0),o++,t.consume(b),b===92?v:m}function v(b){return b===91||b===92||b===93?(t.consume(b),o++,m):m(b)}}function uee(t,e,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,l=0,c;return h;function h(_){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(_),t.exit("gfmFootnoteDefinitionLabelMarker"),m}function m(_){return _===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(_),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",v):n(_)}function v(_){if(l>999||_===93&&!c||_===null||_===91||fr(_))return n(_);if(_===93){t.exit("chunkString");const R=t.exit("gfmFootnoteDefinitionLabelString");return o=_o(r.sliceSerialize(R)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(_),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),C}return fr(_)||(c=!0),l++,t.consume(_),_===92?b:v}function b(_){return _===91||_===92||_===93?(t.consume(_),l++,v):v(_)}function C(_){return _===58?(t.enter("definitionMarker"),t.consume(_),t.exit("definitionMarker"),a.includes(o)||a.push(o),Mn(t,x,"gfmFootnoteDefinitionWhitespace")):n(_)}function x(_){return e(_)}}function cee(t,e,n){return t.check(kv,e,t.attempt(iee,e,n))}function dee(t){t.exit("gfmFootnoteDefinition")}function fee(t,e,n){const r=this;return Mn(t,a,"gfmFootnoteDefinitionIndent",5);function a(o){const l=r.events[r.events.length-1];return l&&l[1].type==="gfmFootnoteDefinitionIndent"&&l[2].sliceSerialize(l[1],!0).length===4?e(o):n(o)}}function hee(t){let n=t.singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function a(l,c){let h=-1;for(;++h<l.length;)if(l[h][0]==="enter"&&l[h][1].type==="strikethroughSequenceTemporary"&&l[h][1]._close){let m=h;for(;m--;)if(l[m][0]==="exit"&&l[m][1].type==="strikethroughSequenceTemporary"&&l[m][1]._open&&l[h][1].end.offset-l[h][1].start.offset===l[m][1].end.offset-l[m][1].start.offset){l[h][1].type="strikethroughSequence",l[m][1].type="strikethroughSequence";const v={type:"strikethrough",start:Object.assign({},l[m][1].start),end:Object.assign({},l[h][1].end)},b={type:"strikethroughText",start:Object.assign({},l[m][1].end),end:Object.assign({},l[h][1].start)},C=[["enter",v,c],["enter",l[m][1],c],["exit",l[m][1],c],["enter",b,c]],x=c.parser.constructs.insideSpan.null;x&&xs(C,C.length,0,ak(x,l.slice(m+1,h),c)),xs(C,C.length,0,[["exit",b,c],["enter",l[h][1],c],["exit",l[h][1],c],["exit",v,c]]),xs(l,m-1,h-m+3,C),h=m+C.length-2;break}}for(h=-1;++h<l.length;)l[h][1].type==="strikethroughSequenceTemporary"&&(l[h][1].type="data");return l}function o(l,c,h){const m=this.previous,v=this.events;let b=0;return C;function C(_){return m===126&&v[v.length-1][1].type!=="characterEscape"?h(_):(l.enter("strikethroughSequenceTemporary"),x(_))}function x(_){const R=vp(m);if(_===126)return b>1?h(_):(l.consume(_),b++,x);if(b<2&&!n)return h(_);const L=l.exit("strikethroughSequenceTemporary"),A=vp(_);return L._open=!A||A===2&&!!R,L._close=!R||R===2&&!!A,c(_)}}}class pee{constructor(){this.map=[]}add(e,n,r){mee(this,e,n,r)}consume(e){if(this.map.sort(function(o,l){return o[0]-l[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push([...e]),e.length=0;let a=r.pop();for(;a;)e.push(...a),a=r.pop();this.map.length=0}}function mee(t,e,n,r){let a=0;if(!(n===0&&r.length===0)){for(;a<t.map.length;){if(t.map[a][0]===e){t.map[a][1]+=n,t.map[a][2].push(...r);return}a+=1}t.map.push([e,n,r])}}function gee(t,e){let n=!1;const r=[];for(;e<t.length;){const a=t[e];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function vee(){return{flow:{null:{name:"table",tokenize:yee,resolveAll:bee}}}}function yee(t,e,n){const r=this;let a=0,o=0,l;return c;function c(q){let ae=r.events.length-1;for(;ae>-1;){const Ee=r.events[ae][1].type;if(Ee==="lineEnding"||Ee==="linePrefix")ae--;else break}const X=ae>-1?r.events[ae][1].type:null,_e=X==="tableHead"||X==="tableRow"?N:h;return _e===N&&r.parser.lazy[r.now().line]?n(q):_e(q)}function h(q){return t.enter("tableHead"),t.enter("tableRow"),m(q)}function m(q){return q===124||(l=!0,o+=1),v(q)}function v(q){return q===null?n(q):Ft(q)?o>1?(o=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(q),t.exit("lineEnding"),x):n(q):Cn(q)?Mn(t,v,"whitespace")(q):(o+=1,l&&(l=!1,a+=1),q===124?(t.enter("tableCellDivider"),t.consume(q),t.exit("tableCellDivider"),l=!0,v):(t.enter("data"),b(q)))}function b(q){return q===null||q===124||fr(q)?(t.exit("data"),v(q)):(t.consume(q),q===92?C:b)}function C(q){return q===92||q===124?(t.consume(q),b):b(q)}function x(q){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(q):(t.enter("tableDelimiterRow"),l=!1,Cn(q)?Mn(t,_,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(q):_(q))}function _(q){return q===45||q===58?L(q):q===124?(l=!0,t.enter("tableCellDivider"),t.consume(q),t.exit("tableCellDivider"),R):I(q)}function R(q){return Cn(q)?Mn(t,L,"whitespace")(q):L(q)}function L(q){return q===58?(o+=1,l=!0,t.enter("tableDelimiterMarker"),t.consume(q),t.exit("tableDelimiterMarker"),A):q===45?(o+=1,A(q)):q===null||Ft(q)?B(q):I(q)}function A(q){return q===45?(t.enter("tableDelimiterFiller"),F(q)):I(q)}function F(q){return q===45?(t.consume(q),F):q===58?(l=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(q),t.exit("tableDelimiterMarker"),j):(t.exit("tableDelimiterFiller"),j(q))}function j(q){return Cn(q)?Mn(t,B,"whitespace")(q):B(q)}function B(q){return q===124?_(q):q===null||Ft(q)?!l||a!==o?I(q):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(q)):I(q)}function I(q){return n(q)}function N(q){return t.enter("tableRow"),J(q)}function J(q){return q===124?(t.enter("tableCellDivider"),t.consume(q),t.exit("tableCellDivider"),J):q===null||Ft(q)?(t.exit("tableRow"),e(q)):Cn(q)?Mn(t,J,"whitespace")(q):(t.enter("data"),ee(q))}function ee(q){return q===null||q===124||fr(q)?(t.exit("data"),J(q)):(t.consume(q),q===92?ye:ee)}function ye(q){return q===92||q===124?(t.consume(q),ee):ee(q)}}function bee(t,e){let n=-1,r=!0,a=0,o=[0,0,0,0],l=[0,0,0,0],c=!1,h=0,m,v,b;const C=new pee;for(;++n<t.length;){const x=t[n],_=x[1];x[0]==="enter"?_.type==="tableHead"?(c=!1,h!==0&&(R5(C,e,h,m,v),v=void 0,h=0),m={type:"table",start:Object.assign({},_.start),end:Object.assign({},_.end)},C.add(n,0,[["enter",m,e]])):_.type==="tableRow"||_.type==="tableDelimiterRow"?(r=!0,b=void 0,o=[0,0,0,0],l=[0,n+1,0,0],c&&(c=!1,v={type:"tableBody",start:Object.assign({},_.start),end:Object.assign({},_.end)},C.add(n,0,[["enter",v,e]])),a=_.type==="tableDelimiterRow"?2:v?3:1):a&&(_.type==="data"||_.type==="tableDelimiterMarker"||_.type==="tableDelimiterFiller")?(r=!1,l[2]===0&&(o[1]!==0&&(l[0]=l[1],b=yk(C,e,o,a,void 0,b),o=[0,0,0,0]),l[2]=n)):_.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(l[0]=l[1],b=yk(C,e,o,a,void 0,b)),o=l,l=[o[1],n,0,0])):_.type==="tableHead"?(c=!0,h=n):_.type==="tableRow"||_.type==="tableDelimiterRow"?(h=n,o[1]!==0?(l[0]=l[1],b=yk(C,e,o,a,n,b)):l[1]!==0&&(b=yk(C,e,l,a,n,b)),a=0):a&&(_.type==="data"||_.type==="tableDelimiterMarker"||_.type==="tableDelimiterFiller")&&(l[3]=n)}for(h!==0&&R5(C,e,h,m,v),C.consume(e.events),n=-1;++n<e.events.length;){const x=e.events[n];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=gee(e.events,n))}return t}function yk(t,e,n,r,a,o){const l=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(o.end=Object.assign({},bp(e.events,n[0])),t.add(n[0],0,[["exit",o,e]]));const h=bp(e.events,n[1]);if(o={type:l,start:Object.assign({},h),end:Object.assign({},h)},t.add(n[1],0,[["enter",o,e]]),n[2]!==0){const m=bp(e.events,n[2]),v=bp(e.events,n[3]),b={type:c,start:Object.assign({},m),end:Object.assign({},v)};if(t.add(n[2],0,[["enter",b,e]]),r!==2){const C=e.events[n[2]],x=e.events[n[3]];if(C[1].end=Object.assign({},x[1].end),C[1].type="chunkText",C[1].contentType="text",n[3]>n[2]+1){const _=n[2]+1,R=n[3]-n[2]-1;t.add(_,R,[])}}t.add(n[3]+1,0,[["exit",b,e]])}return a!==void 0&&(o.end=Object.assign({},bp(e.events,a)),t.add(a,0,[["exit",o,e]]),o=void 0),o}function R5(t,e,n,r,a){const o=[],l=bp(e.events,n);a&&(a.end=Object.assign({},l),o.push(["exit",a,e])),r.end=Object.assign({},l),o.push(["exit",r,e]),t.add(n+1,0,o)}function bp(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const See={name:"tasklistCheck",tokenize:Cee};function kee(){return{text:{91:See}}}function Cee(t,e,n){const r=this;return a;function a(h){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(h):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(h),t.exit("taskListCheckMarker"),o)}function o(h){return fr(h)?(t.enter("taskListCheckValueUnchecked"),t.consume(h),t.exit("taskListCheckValueUnchecked"),l):h===88||h===120?(t.enter("taskListCheckValueChecked"),t.consume(h),t.exit("taskListCheckValueChecked"),l):n(h)}function l(h){return h===93?(t.enter("taskListCheckMarker"),t.consume(h),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),c):n(h)}function c(h){return Ft(h)?e(h):Cn(h)?t.check({tokenize:Tee},e,n)(h):n(h)}}function Tee(t,e,n){return Mn(t,r,"whitespace");function r(a){return a===null?n(a):e(a)}}function xee(t){return i4([YJ(),aee(),hee(t),vee(),kee()])}const wee={};function Eee(t){const e=this,n=t||wee,r=e.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),l=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(xee(n)),o.push(qJ()),l.push(WJ(n))}const _ee=({itemIndex:t,message:e})=>{const n=uW(e.name);return Se.jsx("div",{className:vi("ringg_ai-flex ringg_ai-flex-col ringg_ai-items-start ringg_ai-gap-1 ringg_ai-justify-start",n?"ringg_ai-flex-row":"ringg_ai-flex-row-reverse"),children:Se.jsx("div",{className:vi("ringg_ai-flex ringg_ai-items-center ringg_ai-justify-start ringg_ai-gap-2 ringg_ai-px-4 ringg_ai-py-2 ringg_ai-rounded-xl ringg_ai-max-w-[75%]",n?"ringg_ai-bg-[#F3F3F5] ringg_ai-mr-auto ringg_ai-text-left ringg_ai-rounded-bl-none":"ringg_ai-bg-[#2C2E30] ringg_ai-text-white ringg_ai-ml-auto ringg_ai-text-right ringg_ai-rounded-br-none"),children:Se.jsxs("div",{className:"ringg_ai-flex ringg_ai-flex-col ringg_ai-gap-2.5 ringg_ai-w-fit",children:[Se.jsx(mX,{remarkPlugins:[Eee],className:"ringg_ai-prose ringg_ai-prose-sm ringg_ai-break-before-auto ringg_ai-w-fit [&_p]:ringg_ai-text-sm [&_li]:ringg_ai-text-sm",children:e.message}),(e==null?void 0:e.sourceUrl)&&Se.jsxs("a",{href:e.sourceUrl,target:"_blank",rel:"noopener noreferrer",className:"ringg_ai-text-sm ringg_ai-break-all ringg_ai-w-fit ringg_ai-text-blue-600 ringg_ai-hover:underline",children:["Source: ",e.sourceUrl]})]})},`${e.name}__${t}`)},`${e.timestamp}__${t}`)};function Ree({tabs:t=[],activeTab:e="voice-call",onTabChange:n}){const[r,a]=he.useState(e),o=l=>{a(l),n==null||n(l)};return Se.jsx("div",{className:"ringg_ai-w-full ringg_ai-bg-white ringg_ai-border-t ringg_ai-border-gray-200",children:Se.jsx("div",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-px-0",children:t.map(l=>{const c=l.icon,h=r===l.id;return Se.jsxs("button",{onClick:()=>o(l.id),className:vi("ringg_ai-flex ringg_ai-flex-col ringg_ai-items-center ringg_ai-gap-1 ringg_ai-border-t ringg_ai-py-3 ringg_ai-transition-all ringg_ai-duration-200 ringg_ai-flex-1",h?"ringg_ai-border-t-black":"ringg_ai-border-t-transparent"),children:[Se.jsx(c,{className:vi("ringg_ai-w-5 ringg_ai-h-5 ringg_ai-transition-colors",h?"ringg_ai-text-black [&_path]:ringg_ai-fill-black":"ringg_ai-text-gray-400 [&_path]:ringg_ai-fill-gray-400")}),Se.jsx("span",{className:vi("ringg_ai-text-xs ringg_ai-font-medium ringg_ai-transition-colors",h?"ringg_ai-text-black":"ringg_ai-text-gray-400"),children:l.label})]},l.id)})})})}const Pee=({room:t,config:{mode:e="prod",title:n="Ringg AI Support",description:r="Ringg AI offers 24/7 voice support to handle your business calls efficiently and professionally",agentId:a,variables:o,buttons:l,xApiKey:c,defaultTab:h="audio",hideTabSelector:m=!1,innerWindowProps:v}})=>{var Lt,Xt,Fn,hr,pr,Yn;const b=B0(t),[C,x]=he.useState(!1),_=he.createRef(),R=he.useRef(""),L=he.useRef(),[A,F]=he.useState(!1),[j,B]=he.useState(h),I=he.useRef(null),[N,J]=he.useState(!1),[ee,ye]=he.useState({hasError:!1,message:""}),[q,ae]=he.useState("unknown"),X={bottom:((Xt=(Lt=l==null?void 0:l.modalTrigger)==null?void 0:Lt.styles)==null?void 0:Xt.top)||"2%",right:((hr=(Fn=l==null?void 0:l.modalTrigger)==null?void 0:Fn.styles)==null?void 0:hr.bottom)||"2%"},_e={width:v!=null&&v.width?typeof v.width=="number"?`${v.width}px`:v.width:void 0,height:v!=null&&v.height?typeof v.height=="number"?`${v.height}px`:v.height:void 0,borderRadius:v!=null&&v.borderRadius?typeof v.borderRadius=="number"?`${v.borderRadius}px`:v.borderRadius:void 0},{chatMessages:Ee}=CM(),ze=Iz(),Qe=Ez(),Ie=b==="connected",[de,Be]=he.useState([]),V=H0(ze.audioTrack||void 0),[Z,ke]=he.useState(new Map),H=H0({publication:Qe.microphoneTrack,source:De.Source.Microphone,participant:Qe.localParticipant}),vt=async()=>{try{if(navigator.permissions&&navigator.permissions.query){const Pt=await navigator.permissions.query({name:"microphone"});ae(Pt.state),Pt.onchange=()=>{ae(Pt.state),Pt.state==="granted"&&ye({hasError:!1,message:""})}}else try{await navigator.mediaDevices.getUserMedia({audio:!0}),ae("granted")}catch{ae("denied")}}catch(Pt){console.error("Error checking microphone permission:",Pt),ae("unknown")}},wt=async()=>{try{const Pt=await navigator.mediaDevices.getUserMedia({audio:!0});return ae("granted"),ye({hasError:!1,message:""}),Pt.getTracks().forEach(Dt=>Dt.stop()),!0}catch(Pt){return console.error("Error requesting microphone permission:",Pt),ae("denied"),ye({hasError:!0,message:"Microphone access was denied. Please enable it in your browser settings."}),!1}},pt=async Pt=>{if(Pt==="audio"&&q!=="granted"&&!await wt())return ye({hasError:!0,message:"Microphone access was denied. Please enable it in your browser settings."});x(!0),B(Pt);try{const Dt=e==="dev"?"https://stage-api2.desivocal.com/ca/api/v0":e==="stage"?void 0:"https://prod-api.ringg.ai/ca/api/v0",un=e==="dev"?"wss://ringg-ai-ujrjmhgy.livekit.cloud":void 0,W=await fetch(`${Dt}/calling/webcall`,{method:"POST",body:JSON.stringify({agent_id:a,custom_args_values:o,media_type:Pt}),headers:{"Content-Type":"application/json","X-API-KEY":c}}),ie=await W.json();if(!W.ok)throw new Error((ie==null?void 0:ie.message)||"Failed to make call");await t.connect(un,ie==null?void 0:ie.user_token),Pt==="audio"&&await t.localParticipant.setMicrophoneEnabled(!0),ye({hasError:!1,message:""})}catch(Dt){ye({hasError:!0,message:Dt.message})}finally{x(!1)}},ot=he.useCallback(async()=>{x(!0);try{Be([]),ke(new Map),R.current="",L.current=void 0,t.disconnect(),F(!1),J(!1)}catch(Pt){ye({hasError:!0,message:"Error ending call: "+Pt.message})}finally{x(!1)}},[t]),ut=async Pt=>{try{const Dt=JSON.parse(Pt.payload);return Array.isArray(Dt.source_urls)?R.current=Dt.source_urls.join(", "):Dt.source_url&&(R.current=Dt.source_url),JSON.stringify({status:"received"})}catch(Dt){throw console.error("Failed to parse RPC payload:",Dt),new Error("Invalid payload for send_source_urls")}};return he.useEffect(()=>(vt(),t.on(we.MediaDevicesError,()=>{ye({hasError:!0,message:"Error acquiring microphone permission. Please make sure you grant the necessary permissions in your browser and reload the tab"}),ae("denied")}),()=>{t.off(we.MediaDevicesError,()=>{})}),[t]),he.useEffect(()=>{if(!t||j!=="audio")return;const Pt=new Map(Z);ze.audioTrack&&V.segments.forEach(W=>{const ie=Pt.get(W.id),ce=nw(W,ie,ze.audioTrack.participant);Pt.set(W.id,ce)}),H.segments.forEach(W=>{const ie=Pt.get(W.id),ce=nw(W,ie,Qe.localParticipant);Pt.set(W.id,ce)});const Dt=Array.from(Pt.values());Dt.sort((W,ie)=>W.timestamp-ie.timestamp);const un=R.current&&Dt[Dt.length-1].name.includes("Agent")&&!Dt[Dt.length-1].sourceUrl&&L.current!==Dt.length-1;if(un){L.current=Dt.length,Dt[Dt.length-1]={...Dt[Dt.length-1],sourceUrl:R.current};const W=Dt.filter(Ue=>!Ue.isSelf).length-1,ie=Pt.get(V.segments[W].id),ce=nw(V.segments[W],{...ie,sourceUrl:R.current},ze.audioTrack.participant);Pt.set(V.segments[W].id,ce)}return Be(Dt),ke(Pt),un||(R.current=""),t.registerRpcMethod("send_source_urls",ut),()=>t.unregisterRpcMethod("send_source_urls")},[j,Ee,V.segments,H.segments,ze.audioTrack,(pr=ze.audioTrack)==null?void 0:pr.participant,Qe.localParticipant]),he.useEffect(()=>{if(!t||j!=="text")return;const Pt=async(un,W)=>{var ie;try{const ce=await un.readAll(),Ue=(ie=W.identity)==null?void 0:ie.includes("agent"),je={message:ce,isSelf:!Ue,name:Ue?"Agent":"You",timestamp:Date.now()+performance.now()%1,...Ue&&{sourceUrl:R.current?R.current:""}};R.current&&(R.current=""),Be(Oe=>{const tt=new Set,It=[...Oe,je].filter(oe=>tt.has(oe.timestamp)?!1:(tt.add(oe.timestamp),!0));return It.sort((oe,Pe)=>oe.timestamp-Pe.timestamp),It})}catch(ce){console.error("Error reading text stream",ce)}},Dt=Ee.map(un=>{var Ue,je,Oe,tt;const W=((Ue=un.from)==null?void 0:Ue.identity)===Qe.localParticipant.identity,ie=ze.audioTrack?((je=un.from)==null?void 0:je.identity)===((Oe=ze.audioTrack.participant)==null?void 0:Oe.identity):!W;return{name:((tt=un.from)==null?void 0:tt.name)||(ie?"Agent":W?"You":"Unknown"),isSelf:W,message:un.message,timestamp:un.timestamp}});return Be(un=>{const W=new Set,ie=[...un,...Dt].filter(ce=>W.has(ce.timestamp)?!1:(W.add(ce.timestamp),!0));return ie.sort((ce,Ue)=>ce.timestamp-Ue.timestamp),ie}),t.registerTextStreamHandler("lk.transcription",Pt),t.registerRpcMethod("send_source_urls",ut),()=>{t.unregisterTextStreamHandler("lk.transcription"),t.unregisterRpcMethod("send_source_urls")}},[t,j,Ee]),he.useEffect(()=>{if(t)return t.on(we.ParticipantDisconnected,ot),t.on(we.Disconnected,ot),()=>{t.off(we.ParticipantDisconnected,ot),t.off(we.Disconnected,ot)}},[ot,t]),he.useEffect(()=>{_.current&&(_.current.scrollTop+=_.current.scrollHeight)},[_,de]),Se.jsxs(Se.Fragment,{children:[!N&&Se.jsx(cu,{size:"icon","aria-label":"Open call widget",onClick:()=>J(!0),style:{position:"fixed",...X,...(Yn=l==null?void 0:l.modalTrigger)==null?void 0:Yn.styles},className:vi("!ringg_ai-z-[9999] !ringg_ai-h-14 !ringg_ai-w-14 !ringg_ai-rounded-full","ringg_ai-trigger-btn"),children:Se.jsx(vI,{className:"!ringg_ai-size-5"})}),N&&Se.jsxs(gq.div,{ref:I,animate:{y:0,opacity:1},exit:{y:200,opacity:.5},initial:{y:200,opacity:.5},style:{position:"fixed",...X,...Ie?_e:{}},transition:{duration:.15,ease:"anticipate"},className:vi("ringg_ai-relative ringg_ai-border ringg_ai-overflow-hidden !ringg_ai-z-[9999] ringg_ai-bg-[#fafafa] ringg_ai-rounded-[20px] ringg_ai-shadow-xl ringg_ai-animate-fade-in ringg_ai-transition-all ringg_ai-w-[95vw] md:ringg_ai-w-[360px]",Ie&&"ringg_ai-h-[24.5rem]"),children:[Se.jsx(cu,{size:"icon",variant:"ghost","aria-label":"Close widget",onClick:()=>Ie?F(!0):J(!1),className:"ringg_ai-absolute !ringg_ai-z-[9999] ringg_ai-top-2.5 ringg_ai-right-2.5 !ringg_ai-rounded-full ringg_ai-text-gray-500 hover:ringg_ai-text-gray-700",children:Se.jsx(Cq,{size:20})}),Se.jsx(ZG,{open:A,onOpenChange:F,containerRef:I,children:Se.jsxs(QG,{children:[Se.jsxs(XG,{children:[Se.jsxs(JG,{children:["Are you sure you want to end ",j==="text"?"chat":j==="audio"?"call":j,"?"]}),Se.jsx(eK,{children:"Your current conversation will be closed and cannot be accessed later."})]}),Se.jsxs(tK,{children:[Se.jsx(cu,{variant:"outline",onClick:()=>F(!1),className:"!ringg_ai-rounded-lg",children:"Cancel"}),Se.jsxs(cu,{onClick:ot,className:"!ringg_ai-rounded-lg",children:["End ",j==="text"?"Chat":j==="audio"?"Call":j]})]})]})}),Se.jsxs("div",{className:"ringg_ai-flex ringg_ai-h-full ringg_ai-flex-col",children:[Se.jsxs("div",{className:vi("ringg_ai-relative ringg_ai-p-5 ringg_ai-h-full ringg_ai-mb-2 ringg_ai-flex ringg_ai-gap-5 ringg_ai-flex-col",!Ie&&"ringg_ai-mt-2"),children:[Se.jsx(nK,{isCalling:Ie,isLoading:C,title:n,description:r}),(de==null?void 0:de.length)===0&&Ie&&Se.jsx("div",{className:"ringg_ai-mt-20 ringg_ai-h-full"}),(de==null?void 0:de.length)>0&&Ie&&Se.jsx("div",{ref:_,className:"ringg_ai-mt-20 ringg_ai-h-full ringg_ai-overflow-y-scroll ringg_ai-flex ringg_ai-flex-col ringg_ai-gap-2.5",children:de.sort((Pt,Dt)=>new Date(Pt.timestamp).getTime()-new Date(Dt.timestamp).getTime()).map((Pt,Dt)=>Se.jsx(_ee,{itemIndex:Dt,message:Pt},`${Pt.timestamp}__${Dt}`))}),Se.jsx(YG,{buttonConfig:l,callMode:j,isCalling:Ie,onCallEnd:ot}),ee.hasError&&Se.jsx("div",{className:"ringg_ai-text-center ringg_ai-text-sm ringg_ai-text-red-500 -ringg_ai-mt-3 -ringg_ai-mb-2",children:ee.message}),b==="disconnected"&&Se.jsx(dW,{callMode:j,buttonConfig:l,isCalling:Ie,isLoading:C,onCallTrigger:pt}),!Ie&&Se.jsxs("p",{className:"ringg_ai-text-xs ringg_ai-text-center ringg_ai-text-[#11111180]",children:["By starting call you agree to ",Se.jsx("a",{target:"_blank",className:"ringg_ai-text-blue-500 hover:ringg_ai-underline",href:"https://www.ringg.ai/privacy",children:"Privacy policy"})," & ",Se.jsx("a",{target:"_blank",className:"ringg_ai-text-blue-500 hover:ringg_ai-underline",href:"https://www.ringg.ai/terms",children:"T&C"})]})]}),!Ie&&!m&&Se.jsx(Ree,{tabs:gG,activeTab:j,onTabChange:Pt=>B(Pt)})]})]}),Se.jsx(jz,{})]})},Dee=({config:t})=>{const[e]=he.useState(()=>new Hh({dynacast:!0,adaptiveStream:!0}));return Se.jsx(V0.Provider,{value:e,children:Se.jsx(Pee,{config:t,room:e})})};(function(t,e){function n(r){var l;const a=e.createElement("div");a.id="ringg_ai_container",r.refId?(l=e.getElementById(r.refId))==null||l.appendChild(a):e.body.appendChild(a),pg.createRoot(a).render(Se.jsx(Wn.StrictMode,{children:Se.jsx(Dee,{config:r})}))}t.loadAgent=n})(window,document)});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@desivocal/agents-cdn",
3
3
  "private": false,
4
- "version": "1.0.7-appha.0",
4
+ "version": "1.0.8",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "lint": "eslint .",