@desivocal/agents-cdn 2.0.0-beta.3 → 2.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dv-agent.es.js +4 -2
- package/dist/dv-agent.umd.js +1 -1
- package/package.json +1 -1
package/dist/dv-agent.es.js
CHANGED
|
@@ -60562,7 +60562,9 @@ const q3 = ({ initialComponent: t, onApiCall: e, onComplete: n, onSendResponse:
|
|
|
60562
60562
|
animate: { opacity: 1, y: 0 },
|
|
60563
60563
|
className: Fn("ringg_ai-w-full", c ? "ringg_ai-overflow-visible" : "ringg_ai-border ringg_ai-overflow-hidden"),
|
|
60564
60564
|
style: {
|
|
60565
|
-
|
|
60565
|
+
// Subtle grey card so widgets (calendar, forms, options) read as distinct
|
|
60566
|
+
// from the chat — half surface keeps them lighter than user bubbles.
|
|
60567
|
+
backgroundColor: c ? "transparent" : `color-mix(in srgb, ${p.surfaceColor} 50%, ${p.backgroundColor})`,
|
|
60566
60568
|
borderColor: c ? "transparent" : p.borderColor,
|
|
60567
60569
|
color: p.textColor,
|
|
60568
60570
|
fontFamily: p.fontFamily,
|
|
@@ -61046,7 +61048,7 @@ const Cle = ({ label: t, onSearch: e, onSubmit: n }) => {
|
|
|
61046
61048
|
"data-ringg": "policy-finder",
|
|
61047
61049
|
"data-ringg-step": a,
|
|
61048
61050
|
className: "ringg_ai-rounded-lg ringg_ai-border ringg_ai-overflow-hidden ringg_ai-p-3",
|
|
61049
|
-
style: { borderColor: r.borderColor, backgroundColor: r.backgroundColor },
|
|
61051
|
+
style: { borderColor: r.borderColor, backgroundColor: `color-mix(in srgb, ${r.surfaceColor} 50%, ${r.backgroundColor})` },
|
|
61050
61052
|
children: /* @__PURE__ */ F.jsxs(l0, { mode: "wait", children: [
|
|
61051
61053
|
a === "searching" && /* @__PURE__ */ F.jsxs(
|
|
61052
61054
|
Xi.div,
|
package/dist/dv-agent.umd.js
CHANGED
|
@@ -452,4 +452,4 @@ a=extmap-allow-mixed`)!==-1){const s=a.sdp.split(`
|
|
|
452
452
|
`))+1))}const l="#".repeat(a),c=n.enter("headingAtx"),h=n.enter("phrasing");s.move(l+" ");let p=n.containerPhrasing(t,{before:"# ",after:`
|
|
453
453
|
`,...s.current()});return/^[\t ]/.test(p)&&(p=Lv(p.charCodeAt(0))+p.slice(1)),p=p?l+" "+p:l,n.options.closeAtx&&(p+=" "+l),h(),c(),p}Kj.peek=Lee;function Kj(t){return t.value||""}function Lee(){return"<"}Qj.peek=jee;function Qj(t,e,n,r){const a=Dw(n),s=a==='"'?"Quote":"Apostrophe",l=n.enter("image");let c=n.enter("label");const h=n.createTracker(r);let p=h.move("![");return p+=h.move(n.safe(t.alt,{before:p,after:"]",...h.current()})),p+=h.move("]("),c(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(c=n.enter("destinationLiteral"),p+=h.move("<"),p+=h.move(n.safe(t.url,{before:p,after:">",...h.current()})),p+=h.move(">")):(c=n.enter("destinationRaw"),p+=h.move(n.safe(t.url,{before:p,after:t.title?" ":")",...h.current()}))),c(),t.title&&(c=n.enter(`title${s}`),p+=h.move(" "+a),p+=h.move(n.safe(t.title,{before:p,after:a,...h.current()})),p+=h.move(a),c()),p+=h.move(")"),l(),p}function jee(){return"!"}Zj.peek=Fee;function Zj(t,e,n,r){const a=t.referenceType,s=n.enter("imageReference");let l=n.enter("label");const c=n.createTracker(r);let h=c.move("![");const p=n.safe(t.alt,{before:h,after:"]",...c.current()});h+=c.move(p+"]["),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,s(),a==="full"||!p||p!==b?h+=c.move(b+"]"):a==="shortcut"?h=h.slice(0,-1):h+=c.move("]"),h}function Fee(){return"!"}Jj.peek=Uee;function Jj(t,e,n){let r=t.value||"",a="`",s=-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+" ");++s<n.unsafe.length;){const l=n.unsafe[s],c=n.compilePattern(l);let h;if(l.atBreak)for(;h=c.exec(r);){let p=h.index;r.charCodeAt(p)===10&&r.charCodeAt(p-1)===13&&p--,r=r.slice(0,p)+" "+r.slice(h.index+1)}}return a+r+a}function Uee(){return"`"}function Xj(t,e){const n=iw(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))}e5.peek=Bee;function e5(t,e,n,r){const a=Dw(n),s=a==='"'?"Quote":"Apostrophe",l=n.createTracker(r);let c,h;if(Xj(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 p=l.move("[");return p+=l.move(n.containerPhrasing(t,{before:p,after:"](",...l.current()})),p+=l.move("]("),h(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(h=n.enter("destinationLiteral"),p+=l.move("<"),p+=l.move(n.safe(t.url,{before:p,after:">",...l.current()})),p+=l.move(">")):(h=n.enter("destinationRaw"),p+=l.move(n.safe(t.url,{before:p,after:t.title?" ":")",...l.current()}))),h(),t.title&&(h=n.enter(`title${s}`),p+=l.move(" "+a),p+=l.move(n.safe(t.title,{before:p,after:a,...l.current()})),p+=l.move(a),h()),p+=l.move(")"),c(),p}function Bee(t,e,n){return Xj(t,n)?"<":"["}t5.peek=Vee;function t5(t,e,n,r){const a=t.referenceType,s=n.enter("linkReference");let l=n.enter("label");const c=n.createTracker(r);let h=c.move("[");const p=n.containerPhrasing(t,{before:h,after:"]",...c.current()});h+=c.move(p+"]["),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,s(),a==="full"||!p||p!==b?h+=c.move(b+"]"):a==="shortcut"?h=h.slice(0,-1):h+=c.move("]"),h}function Vee(){return"["}function Ow(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 zee(t){const e=Ow(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 Hee(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 n5(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 Wee(t,e,n,r){const a=n.enter("list"),s=n.bulletCurrent;let l=t.ordered?Hee(n):Ow(n);const c=t.ordered?l==="."?")":".":zee(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),n5(n)===l&&v){let b=-1;for(;++b<t.children.length;){const k=t.children[b];if(k&&k.type==="listItem"&&k.children&&k.children[0]&&k.children[0].type==="thematicBreak"){h=!0;break}}}}h&&(l=c),n.bulletCurrent=l;const p=n.containerFlow(t,r);return n.bulletLastUsed=l,n.bulletCurrent=s,a(),p}function qee(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 Gee(t,e,n,r){const a=qee(n);let s=n.bulletCurrent||Ow(n);e&&e.type==="list"&&e.ordered&&(s=(typeof e.start=="number"&&e.start>-1?e.start:1)+(n.options.incrementListMarker===!1?0:e.children.indexOf(t))+s);let l=s.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(s+" ".repeat(l-s.length)),c.shift(l);const h=n.enter("listItem"),p=n.indentLines(n.containerFlow(t,c.current()),v);return h(),p;function v(b,k,x){return k?(x?"":" ".repeat(l))+b:(x?s:s+" ".repeat(l-s.length))+b}}function Yee(t,e,n,r){const a=n.enter("paragraph"),s=n.enter("phrasing"),l=n.containerPhrasing(t,r);return s(),a(),l}const $ee=AC(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Kee(t,e,n,r){return(t.children.some(function(l){return $ee(l)})?n.containerPhrasing:n.containerFlow).call(n,t,r)}function Qee(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}r5.peek=Zee;function r5(t,e,n,r){const a=Qee(n),s=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 p=h.charCodeAt(0),v=MC(r.before.charCodeAt(r.before.length-1),p,a);v.inside&&(h=Lv(p)+h.slice(1));const b=h.charCodeAt(h.length-1),k=MC(r.after.charCodeAt(0),b,a);k.inside&&(h=h.slice(0,-1)+Lv(b));const x=l.move(a+a);return s(),n.attentionEncodeSurroundingInfo={after:k.outside,before:v.outside},c+h+x}function Zee(t,e,n){return n.options.strong||"*"}function Jee(t,e,n,r){return n.safe(t.value,r)}function Xee(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 ete(t,e,n){const r=(n5(n)+(n.options.ruleSpaces?" ":"")).repeat(Xee(n));return n.options.ruleSpaces?r.slice(0,-1):r}const i5={blockquote:xee,break:Yj,code:Aee,definition:Dee,emphasis:$j,hardBreak:Yj,heading:Nee,html:Kj,image:Qj,imageReference:Zj,inlineCode:Jj,link:e5,linkReference:t5,list:Wee,listItem:Gee,paragraph:Yee,root:Kee,strong:r5,text:Jee,thematicBreak:ete};function tte(){return{enter:{table:nte,tableData:a5,tableHeader:a5,tableRow:ite},exit:{codeText:ate,table:rte,tableData:Mw,tableHeader:Mw,tableRow:Mw}}}function nte(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 rte(t){this.exit(t),this.data.inTable=void 0}function ite(t){this.enter({type:"tableRow",children:[]},t)}function Mw(t){this.exit(t)}function a5(t){this.enter({type:"tableCell",children:[]},t)}function ate(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,ote));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function ote(t,e){return e==="|"?e:t}function ste(t){const e=t||{},n=e.tableCellPadding,r=e.tablePipeAlign,a=e.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
454
454
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:k,table:l,tableCell:h,tableRow:c}};function l(x,w,R,O){return p(v(x,R,O),x.align)}function c(x,w,R,O){const P=b(x,R,O),U=p([P]);return U.slice(0,U.indexOf(`
|
|
455
|
-
`))}function h(x,w,R,O){const P=R.enter("tableCell"),U=R.enter("phrasing"),I=R.containerPhrasing(x,{...O,before:s,after:s});return U(),P(),I}function p(x,w){return See(x,{align:w,alignDelimiters:r,padding:n,stringLength:a})}function v(x,w,R){const O=x.children;let P=-1;const U=[],I=w.enter("table");for(;++P<O.length;)U[P]=b(O[P],w,R);return I(),U}function b(x,w,R){const O=x.children;let P=-1;const U=[],I=w.enter("tableRow");for(;++P<O.length;)U[P]=h(O[P],x,w,R);return I(),U}function k(x,w,R){let O=i5.inlineCode(x,w,R);return R.stack.includes("tableCell")&&(O=O.replace(/\|/g,"\\$&")),O}}function lte(){return{exit:{taskListCheckValueChecked:o5,taskListCheckValueUnchecked:o5,paragraph:cte}}}function ute(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:dte}}}function o5(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function cte(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 s=-1,l;for(;++s<a.length;){const c=a[s];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 dte(t,e,n,r){const a=t.children[0],s=typeof t.checked=="boolean"&&a&&a.type==="paragraph",l="["+(t.checked?"x":" ")+"] ",c=n.createTracker(r);s&&c.move(l);let h=i5.listItem(t,e,n,{...r,...c.current()});return s&&(h=h.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,p)),h;function p(v){return v+l}}function fte(){return[HX(),tee(),mee(),tte(),lte()]}function hte(t){return{extensions:[WX(),nee(),gee(),ste(t),ute()]}}const pte={tokenize:Cte,partial:!0},s5={tokenize:Ste,partial:!0},l5={tokenize:kte,partial:!0},u5={tokenize:xte,partial:!0},mte={tokenize:Tte,partial:!0},c5={name:"wwwAutolink",tokenize:yte,previous:f5},d5={name:"protocolAutolink",tokenize:bte,previous:h5},Nu={name:"emailAutolink",tokenize:vte,previous:p5},Fl={};function gte(){return{text:Fl}}let Rf=48;for(;Rf<123;)Fl[Rf]=Nu,Rf++,Rf===58?Rf=65:Rf===91&&(Rf=97);Fl[43]=Nu,Fl[45]=Nu,Fl[46]=Nu,Fl[95]=Nu,Fl[72]=[Nu,d5],Fl[104]=[Nu,d5],Fl[87]=[Nu,c5],Fl[119]=[Nu,c5];function vte(t,e,n){const r=this;let a,s;return l;function l(b){return!Iw(b)||!p5.call(r,r.previous)||Nw(r.events)?n(b):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),c(b))}function c(b){return Iw(b)?(t.consume(b),c):b===64?(t.consume(b),h):n(b)}function h(b){return b===46?t.check(mte,v,p)(b):b===45||b===95||Ia(b)?(s=!0,t.consume(b),h):v(b)}function p(b){return t.consume(b),a=!0,h}function v(b){return s&&a&&to(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(b)):n(b)}}function yte(t,e,n){const r=this;return a;function a(l){return l!==87&&l!==119||!f5.call(r,r.previous)||Nw(r.events)?n(l):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(pte,t.attempt(s5,t.attempt(l5,s),n),n)(l))}function s(l){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(l)}}function bte(t,e,n){const r=this;let a="",s=!1;return l;function l(b){return(b===72||b===104)&&h5.call(r,r.previous)&&!Nw(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),a+=String.fromCodePoint(b),t.consume(b),c):n(b)}function c(b){if(to(b)&&a.length<5)return a+=String.fromCodePoint(b),t.consume(b),c;if(b===58){const k=a.toLowerCase();if(k==="http"||k==="https")return t.consume(b),h}return n(b)}function h(b){return b===47?(t.consume(b),s?p:(s=!0,h)):n(b)}function p(b){return b===null||bC(b)||Tr(b)||Ef(b)||CC(b)?n(b):t.attempt(s5,t.attempt(l5,v),n)(b)}function v(b){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(b)}}function Cte(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),s):n(l)}function s(l){return l===null?n(l):e(l)}}function Ste(t,e,n){let r,a,s;return l;function l(p){return p===46||p===95?t.check(u5,h,c)(p):p===null||Tr(p)||Ef(p)||p!==45&&CC(p)?h(p):(s=!0,t.consume(p),l)}function c(p){return p===95?r=!0:(a=r,r=void 0),t.consume(p),l}function h(p){return a||r||!s?n(p):e(p)}}function kte(t,e){let n=0,r=0;return a;function a(l){return l===40?(n++,t.consume(l),a):l===41&&r<n?s(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(u5,e,s)(l):l===null||Tr(l)||Ef(l)?e(l):(t.consume(l),a)}function s(l){return l===41&&r++,t.consume(l),a}}function xte(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),s):c===93?(t.consume(c),a):c===60||c===null||Tr(c)||Ef(c)?e(c):n(c)}function a(c){return c===null||c===40||c===91||Tr(c)||Ef(c)?e(c):r(c)}function s(c){return to(c)?l(c):n(c)}function l(c){return c===59?(t.consume(c),r):to(c)?(t.consume(c),l):n(c)}}function Tte(t,e,n){return r;function r(s){return t.consume(s),a}function a(s){return Ia(s)?n(s):e(s)}}function f5(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Tr(t)}function h5(t){return!to(t)}function p5(t){return!(t===47||Iw(t))}function Iw(t){return t===43||t===45||t===46||t===95||Ia(t)}function Nw(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 _te={tokenize:Mte,partial:!0};function wte(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Pte,continuation:{tokenize:Dte},exit:Ote}},text:{91:{name:"gfmFootnoteCall",tokenize:Ate},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Ete,resolveTo:Rte}}}}function Ete(t,e,n){const r=this;let a=r.events.length;const s=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 p=el(r.sliceSerialize({start:l.end,end:r.now()}));return p.codePointAt(0)!==94||!s.includes(p.slice(1))?n(h):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),e(h))}}function Rte(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 s={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},t[t.length-1][1].start)},l={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},c=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",a,e],["exit",a,e],["enter",s,e],["enter",l,e],["exit",l,e],["exit",s,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...c),t}function Ate(t,e,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=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",p)}function p(b){if(s>999||b===93&&!l||b===null||b===91||Tr(b))return n(b);if(b===93){t.exit("chunkString");const k=t.exit("gfmFootnoteCallString");return a.includes(el(r.sliceSerialize(k)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(b),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(b)}return Tr(b)||(l=!0),s++,t.consume(b),b===92?v:p}function v(b){return b===91||b===92||b===93?(t.consume(b),s++,p):p(b)}}function Pte(t,e,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,l=0,c;return h;function h(w){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(w),t.exit("gfmFootnoteDefinitionLabelMarker"),p}function p(w){return w===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(w),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",v):n(w)}function v(w){if(l>999||w===93&&!c||w===null||w===91||Tr(w))return n(w);if(w===93){t.exit("chunkString");const R=t.exit("gfmFootnoteDefinitionLabelString");return s=el(r.sliceSerialize(R)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(w),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),k}return Tr(w)||(c=!0),l++,t.consume(w),w===92?b:v}function b(w){return w===91||w===92||w===93?(t.consume(w),l++,v):v(w)}function k(w){return w===58?(t.enter("definitionMarker"),t.consume(w),t.exit("definitionMarker"),a.includes(s)||a.push(s),Wn(t,x,"gfmFootnoteDefinitionWhitespace")):n(w)}function x(w){return e(w)}}function Dte(t,e,n){return t.check(Dv,e,t.attempt(_te,e,n))}function Ote(t){t.exit("gfmFootnoteDefinition")}function Mte(t,e,n){const r=this;return Wn(t,a,"gfmFootnoteDefinitionIndent",5);function a(s){const l=r.events[r.events.length-1];return l&&l[1].type==="gfmFootnoteDefinitionIndent"&&l[2].sliceSerialize(l[1],!0).length===4?e(s):n(s)}}function Ite(t){let n=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:s,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 p=h;for(;p--;)if(l[p][0]==="exit"&&l[p][1].type==="strikethroughSequenceTemporary"&&l[p][1]._open&&l[h][1].end.offset-l[h][1].start.offset===l[p][1].end.offset-l[p][1].start.offset){l[h][1].type="strikethroughSequence",l[p][1].type="strikethroughSequence";const v={type:"strikethrough",start:Object.assign({},l[p][1].start),end:Object.assign({},l[h][1].end)},b={type:"strikethroughText",start:Object.assign({},l[p][1].end),end:Object.assign({},l[h][1].start)},k=[["enter",v,c],["enter",l[p][1],c],["exit",l[p][1],c],["enter",b,c]],x=c.parser.constructs.insideSpan.null;x&&Xo(k,k.length,0,SC(x,l.slice(p+1,h),c)),Xo(k,k.length,0,[["exit",b,c],["enter",l[h][1],c],["exit",l[h][1],c],["exit",v,c]]),Xo(l,p-1,h-p+3,k),h=p+k.length-2;break}}for(h=-1;++h<l.length;)l[h][1].type==="strikethroughSequenceTemporary"&&(l[h][1].type="data");return l}function s(l,c,h){const p=this.previous,v=this.events;let b=0;return k;function k(w){return p===126&&v[v.length-1][1].type!=="characterEscape"?h(w):(l.enter("strikethroughSequenceTemporary"),x(w))}function x(w){const R=Pp(p);if(w===126)return b>1?h(w):(l.consume(w),b++,x);if(b<2&&!n)return h(w);const O=l.exit("strikethroughSequenceTemporary"),P=Pp(w);return O._open=!P||P===2&&!!R,O._close=!R||R===2&&!!P,c(w)}}}class Nte{constructor(){this.map=[]}add(e,n,r){Lte(this,e,n,r)}consume(e){if(this.map.sort(function(s,l){return s[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 Lte(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 jte(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 s=r.length-1;r[s]=r[s]==="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 Fte(){return{flow:{null:{name:"table",tokenize:Ute,resolveAll:Bte}}}}function Ute(t,e,n){const r=this;let a=0,s=0,l;return c;function c(G){let re=r.events.length-1;for(;re>-1;){const he=r.events[re][1].type;if(he==="lineEnding"||he==="linePrefix")re--;else break}const te=re>-1?r.events[re][1].type:null,le=te==="tableHead"||te==="tableRow"?N:h;return le===N&&r.parser.lazy[r.now().line]?n(G):le(G)}function h(G){return t.enter("tableHead"),t.enter("tableRow"),p(G)}function p(G){return G===124||(l=!0,s+=1),v(G)}function v(G){return G===null?n(G):Gt(G)?s>1?(s=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(G),t.exit("lineEnding"),x):n(G):Ln(G)?Wn(t,v,"whitespace")(G):(s+=1,l&&(l=!1,a+=1),G===124?(t.enter("tableCellDivider"),t.consume(G),t.exit("tableCellDivider"),l=!0,v):(t.enter("data"),b(G)))}function b(G){return G===null||G===124||Tr(G)?(t.exit("data"),v(G)):(t.consume(G),G===92?k:b)}function k(G){return G===92||G===124?(t.consume(G),b):b(G)}function x(G){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(G):(t.enter("tableDelimiterRow"),l=!1,Ln(G)?Wn(t,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(G):w(G))}function w(G){return G===45||G===58?O(G):G===124?(l=!0,t.enter("tableCellDivider"),t.consume(G),t.exit("tableCellDivider"),R):L(G)}function R(G){return Ln(G)?Wn(t,O,"whitespace")(G):O(G)}function O(G){return G===58?(s+=1,l=!0,t.enter("tableDelimiterMarker"),t.consume(G),t.exit("tableDelimiterMarker"),P):G===45?(s+=1,P(G)):G===null||Gt(G)?B(G):L(G)}function P(G){return G===45?(t.enter("tableDelimiterFiller"),U(G)):L(G)}function U(G){return G===45?(t.consume(G),U):G===58?(l=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(G),t.exit("tableDelimiterMarker"),I):(t.exit("tableDelimiterFiller"),I(G))}function I(G){return Ln(G)?Wn(t,B,"whitespace")(G):B(G)}function B(G){return G===124?w(G):G===null||Gt(G)?!l||a!==s?L(G):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(G)):L(G)}function L(G){return n(G)}function N(G){return t.enter("tableRow"),Q(G)}function Q(G){return G===124?(t.enter("tableCellDivider"),t.consume(G),t.exit("tableCellDivider"),Q):G===null||Gt(G)?(t.exit("tableRow"),e(G)):Ln(G)?Wn(t,Q,"whitespace")(G):(t.enter("data"),Z(G))}function Z(G){return G===null||G===124||Tr(G)?(t.exit("data"),Q(G)):(t.consume(G),G===92?Se:Z)}function Se(G){return G===92||G===124?(t.consume(G),Z):Z(G)}}function Bte(t,e){let n=-1,r=!0,a=0,s=[0,0,0,0],l=[0,0,0,0],c=!1,h=0,p,v,b;const k=new Nte;for(;++n<t.length;){const x=t[n],w=x[1];x[0]==="enter"?w.type==="tableHead"?(c=!1,h!==0&&(m5(k,e,h,p,v),v=void 0,h=0),p={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},k.add(n,0,[["enter",p,e]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(r=!0,b=void 0,s=[0,0,0,0],l=[0,n+1,0,0],c&&(c=!1,v={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},k.add(n,0,[["enter",v,e]])),a=w.type==="tableDelimiterRow"?2:v?3:1):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(r=!1,l[2]===0&&(s[1]!==0&&(l[0]=l[1],b=IC(k,e,s,a,void 0,b),s=[0,0,0,0]),l[2]=n)):w.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(l[0]=l[1],b=IC(k,e,s,a,void 0,b)),s=l,l=[s[1],n,0,0])):w.type==="tableHead"?(c=!0,h=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(h=n,s[1]!==0?(l[0]=l[1],b=IC(k,e,s,a,n,b)):l[1]!==0&&(b=IC(k,e,l,a,n,b)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(l[3]=n)}for(h!==0&&m5(k,e,h,p,v),k.consume(e.events),n=-1;++n<e.events.length;){const x=e.events[n];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=jte(e.events,n))}return t}function IC(t,e,n,r,a,s){const l=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(s.end=Object.assign({},Op(e.events,n[0])),t.add(n[0],0,[["exit",s,e]]));const h=Op(e.events,n[1]);if(s={type:l,start:Object.assign({},h),end:Object.assign({},h)},t.add(n[1],0,[["enter",s,e]]),n[2]!==0){const p=Op(e.events,n[2]),v=Op(e.events,n[3]),b={type:c,start:Object.assign({},p),end:Object.assign({},v)};if(t.add(n[2],0,[["enter",b,e]]),r!==2){const k=e.events[n[2]],x=e.events[n[3]];if(k[1].end=Object.assign({},x[1].end),k[1].type="chunkText",k[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,R=n[3]-n[2]-1;t.add(w,R,[])}}t.add(n[3]+1,0,[["exit",b,e]])}return a!==void 0&&(s.end=Object.assign({},Op(e.events,a)),t.add(a,0,[["exit",s,e]]),s=void 0),s}function m5(t,e,n,r,a){const s=[],l=Op(e.events,n);a&&(a.end=Object.assign({},l),s.push(["exit",a,e])),r.end=Object.assign({},l),s.push(["exit",r,e]),t.add(n+1,0,s)}function Op(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const Vte={name:"tasklistCheck",tokenize:Hte};function zte(){return{text:{91:Vte}}}function Hte(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"),s)}function s(h){return Tr(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 Gt(h)?e(h):Ln(h)?t.check({tokenize:Wte},e,n)(h):n(h)}}function Wte(t,e,n){return Wn(t,r,"whitespace");function r(a){return a===null?n(a):e(a)}}function qte(t){return q4([gte(),wte(),Ite(t),Fte(),zte()])}const Gte={};function Yte(t){const e=this,n=t||Gte,r=e.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),l=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(qte(n)),s.push(fte()),l.push(hte(n))}const NC=({itemIndex:t,message:e,children:n,hideMessageContent:r=!1})=>{const a=Ja(),s=!e.isSelf,l=a.textColor,c=!r&&!!e.message.trim();return F.jsx("div",{"data-ringg":"message","data-ringg-role":s?"agent":"user",className:Nn("ringg_ai-flex ringg_ai-flex-col ringg_ai-items-start ringg_ai-gap-1 ringg_ai-justify-start",s?"ringg_ai-flex-row":"ringg_ai-flex-row-reverse"),children:F.jsx("div",{"data-ringg":"message-bubble",className:Nn("ringg_ai-flex ringg_ai-items-center ringg_ai-justify-start ringg_ai-gap-2 ringg_ai-text-left ringg_ai-leading-[1.3] ringg_ai-max-w-[80%]",s?"ringg_ai-mr-auto":"ringg_ai-ml-auto ringg_ai-pl-3 ringg_ai-pr-2 ringg_ai-py-2 ringg_ai-rounded-xl ringg_ai-rounded-br-[2px]"),style:{...s?{}:{backgroundColor:a.surfaceColor},color:l},children:F.jsxs("div",{"data-ringg":"message-content",className:"ringg_ai-flex ringg_ai-flex-col ringg_ai-gap-2.5 ringg_ai-w-full ringg_ai-overflow-x-auto",children:[c&&F.jsx("div",{"data-ringg":"message-body",className:"ringg_ai-prose ringg_ai-prose-sm ringg_ai-max-w-none [&_p]:ringg_ai-text-sm [&_li]:ringg_ai-text-sm [&_table]:ringg_ai-w-max",style:{"--tw-prose-body":l,"--tw-prose-headings":l,"--tw-prose-bold":l,"--tw-prose-counters":l,"--tw-prose-bullets":l,"--tw-prose-quotes":l,"--tw-prose-code":l,"--tw-prose-th-borders":a.borderColor,"--tw-prose-td-borders":a.borderColor,color:l},children:F.jsx(MX,{remarkPlugins:[Yte],children:e.message})}),(e==null?void 0:e.sourceUrl)&&F.jsxs("a",{"data-ringg":"message-source",href:e.sourceUrl,target:"_blank",rel:"noopener noreferrer",className:"ringg_ai-text-sm ringg_ai-break-all ringg_ai-w-fit ringg_ai-hover:underline",style:{color:On(a.primaryColor)},children:["Source: ",e.sourceUrl]}),n&&F.jsx("div",{"data-ringg":"message-attachment",className:"ringg_ai-w-full",children:n})]})},`${e.name}__${t}`)},`${e.timestamp}__${t}`)},g5=({filled:t,filledColor:e,emptyColor:n,sizeClassName:r="ringg_ai-w-7 ringg_ai-h-7",onClick:a,onMouseEnter:s,onMouseLeave:l})=>F.jsx("button",{"data-ringg":"feedback-star","data-ringg-filled":t?"true":"false",type:"button",onClick:a,onMouseEnter:s,onMouseLeave:l,className:"ringg_ai-p-1 ringg_ai-transition-transform hover:ringg_ai-scale-110",children:F.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:t?e:"none",stroke:t?e:n,strokeWidth:"1.5",className:Nn("ringg_ai-cursor-pointer ringg_ai-transition-colors",r),children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z"})})}),$te=({callMode:t,isSubmitting:e,feedbackScreenConfig:n,messages:r,title:a,logoUrl:s,logoStyles:l,onSubmit:c,onSkip:h})=>{var re,te;const p=Ja(),v=__(p.buttonStyle),[b,k]=H.useState(0),[x,w]=H.useState(0),[R,O]=H.useState(""),P=(r??[]).filter(le=>!le.componentType&&le.kind!=="system"&&!!le.message.trim()),U=P.length>0,I=H.useRef(null);H.useEffect(()=>{var le;(le=I.current)==null||le.scrollTo({top:I.current.scrollHeight})},[]);const B=()=>{b>0&&c(b,R)},L=x||b,N=(n==null?void 0:n.starsCount)??5,Q=Array.from({length:N},(le,he)=>he+1),Z=((re=n==null?void 0:n.starsStyles)==null?void 0:re.filledColor)??On(p.primaryColor),Se=((te=n==null?void 0:n.starsStyles)==null?void 0:te.emptyColor)??"#D1D5DB",G=b===0||e;return U?F.jsxs("div",{"data-ringg":"feedback-screen","data-ringg-variant":"transcript",className:"ringg_ai-relative ringg_ai-h-full ringg_ai-flex ringg_ai-flex-col ringg_ai-p-2 ringg_ai-gap-2",children:[F.jsx(p4,{isCalling:!0,isLoading:!1,title:a??"",description:"",logoUrl:s,logoStyles:l}),F.jsx("div",{ref:I,"data-ringg":"transcript","data-scrollable":"true",className:"ringg_ai-h-full ringg_ai-overflow-y-auto ringg_ai-flex ringg_ai-flex-col",children:F.jsxs("div",{"data-ringg":"transcript-list",className:"ringg_ai-mt-auto ringg_ai-flex ringg_ai-flex-col ringg_ai-gap-3 ringg_ai-pt-12",children:[P.map((le,he)=>F.jsx(NC,{itemIndex:he,message:le},`${le.timestamp}__${he}`)),F.jsxs("div",{"data-ringg":"feedback-footer",className:"ringg_ai-flex ringg_ai-flex-col ringg_ai-gap-2.5 ringg_ai-px-2 ringg_ai-pt-2 ringg_ai-pb-2",children:[F.jsxs("div",{"data-ringg":"conversation-ended",className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-3",children:[F.jsx("span",{"aria-hidden":!0,className:"ringg_ai-h-px ringg_ai-flex-1",style:{backgroundColor:p.borderColor}}),F.jsx("span",{className:"ringg_ai-text-xs",style:{color:p.mutedTextColor},children:"Conversation ended"}),F.jsx("span",{"aria-hidden":!0,className:"ringg_ai-h-px ringg_ai-flex-1",style:{backgroundColor:p.borderColor}})]}),F.jsx("p",{"data-ringg":"feedback-prompt",className:"ringg_ai-text-[13px] ringg_ai-text-center",style:{color:p.mutedTextColor},children:(n==null?void 0:n.title)??"Please rate your experience"}),F.jsx("div",{"data-ringg":"feedback-stars",className:"ringg_ai-flex ringg_ai-justify-center ringg_ai-gap-0.5 -ringg_ai-mt-1",children:Q.map(le=>F.jsx(g5,{filled:le<=L,filledColor:Z,emptyColor:Se,sizeClassName:"ringg_ai-w-6 ringg_ai-h-6",onClick:()=>{e||(k(le),c(le,""))},onMouseEnter:()=>w(le),onMouseLeave:()=>w(0)},le))})]})]})})]}):F.jsxs("div",{"data-ringg":"feedback-screen",className:"ringg_ai-flex ringg_ai-flex-col ringg_ai-items-center ringg_ai-justify-center ringg_ai-p-6 ringg_ai-h-full ringg_ai-gap-4",children:[F.jsxs("div",{"data-ringg":"feedback-header",className:"ringg_ai-text-center",children:[F.jsx("h3",{"data-ringg":"feedback-title",className:"ringg_ai-text-lg ringg_ai-font-medium ringg_ai-mb-1",style:{color:p.textColor},children:(n==null?void 0:n.title)??`How was your ${t==="text"?"chat":"call"}?`}),F.jsx("p",{"data-ringg":"feedback-description",className:"ringg_ai-text-sm",style:{color:p.mutedTextColor},children:(n==null?void 0:n.description)??"Your feedback helps us improve!"})]}),F.jsx("div",{"data-ringg":"feedback-stars",className:"ringg_ai-flex ringg_ai-gap-1 ringg_ai-my-2",children:Q.map(le=>F.jsx(g5,{filled:le<=L,filledColor:Z,emptyColor:Se,onClick:()=>k(le),onMouseEnter:()=>w(le),onMouseLeave:()=>w(0)},le))}),F.jsx("textarea",{"data-ringg":"feedback-comment",value:R,onChange:le=>O(le.target.value),placeholder:(n==null?void 0:n.placeholder)??"We'd love to hear more...",className:Nn("ringg_ai-w-full ringg_ai-min-h-[80px] ringg_ai-p-3 ringg_ai-text-sm ringg_ai-border ringg_ai-resize-none focus:ringg_ai-outline-none focus:ringg_ai-ring-2"),style:{backgroundColor:p.backgroundColor,color:p.textColor,borderColor:p.borderColor,borderRadius:p.borderRadius,"--tw-ring-color":On(p.primaryColor)},maxLength:500}),F.jsxs("div",{"data-ringg":"feedback-actions",className:"ringg_ai-flex ringg_ai-w-full ringg_ai-flex-col ringg_ai-gap-1 ringg_ai-mt-2",children:[F.jsx("button",{"data-ringg":"feedback-submit",onClick:B,disabled:G,className:Nn("ringg_ai-w-full ringg_ai-h-11 ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-text-sm ringg_ai-font-medium ringg_ai-transition-all","hover:ringg_ai-opacity-90 disabled:ringg_ai-cursor-not-allowed"),style:{...G?{backgroundColor:p.surfaceColor,color:p.mutedTextColor}:{...gi(p.primaryColor),color:p.primaryTextColor},borderRadius:v,...n==null?void 0:n.submitBtnStyles},children:(n==null?void 0:n.submitBtnCTA)??"Submit Feedback"}),F.jsx("button",{"data-ringg":"feedback-skip",type:"button",onClick:h,disabled:e,className:"ringg_ai-w-full ringg_ai-py-2 ringg_ai-text-sm ringg_ai-transition-colors hover:ringg_ai-opacity-80",style:{color:p.mutedTextColor},children:"Skip"})]})]})};function Kte(t){const e=new Map;return t.forEach(n=>{const a=new Date(n.datetime).toISOString().split("T")[0];e.has(a)||e.set(a,[]),e.get(a).push(n)}),Array.from(e.entries()).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>{const a=new Date(n);return{date:n,dateLabel:a.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}),slots:r.sort((s,l)=>new Date(s.datetime).getTime()-new Date(l.datetime).getTime())}})}function v5(t,e){return new Date(t).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:e})}function Qte(t,e){return new Date(t).toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",timeZone:e})}function Zte(t,e){const n={};for(const[r,a]of Object.entries(t))if(typeof a=="string"&&a.startsWith("{")&&a.endsWith("}")){const s=a.slice(1,-1);n[r]=e[s]??a}else n[r]=a;return n}function Jte(t){return t.component_type==="calendar_booking"}function Xte(t){return t.component_type==="form"}function jv(t){return t.component_type==="buttons"}function ene(t){return t.component_type==="confirmation"}const tne={primaryColor:"#0a0a0b",primaryTextColor:"#ffffff",backgroundColor:"#ffffff",surfaceColor:"#f3f4f6",textColor:"#0a0a0b",mutedTextColor:"#6b7280",borderColor:"#e5e7eb",errorColor:"#ef4444",successColor:"#16a34a",fontFamily:"inherit",fontSize:"14px",borderRadius:"8px",padding:"12px",buttonStyle:"pill",buttonSize:"md"};function Lw(t){return{...tne,...t}}function LC(t){switch(t){case"pill":return"9999px";case"square":return"4px";case"rounded":default:return"8px"}}const y5=H.createContext(null),Af=()=>{const t=H.useContext(y5);let e;try{e=Ja()}catch{e=null}return t||Lw(e?{primaryColor:e.primaryColor,primaryTextColor:e.primaryTextColor,backgroundColor:e.backgroundColor,surfaceColor:e.surfaceColor,textColor:e.textColor,mutedTextColor:e.mutedTextColor,borderColor:e.borderColor,errorColor:e.errorColor,successColor:e.successColor,buttonStyle:e.buttonStyle}:{})},nne=({payload:t,isProcessing:e,onComplete:n})=>{var x;const r=Af(),a=LC(r.buttonStyle),{data:s}=t,l=H.useMemo(()=>Kte(s.available_slots),[s.available_slots]),[c,h]=H.useState(((x=l[0])==null?void 0:x.date)||""),[p,v]=H.useState(null),b=l.find(w=>w.date===c),k=()=>{p&&n(p.id,p.datetime)};return F.jsxs("div",{children:[F.jsxs("div",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2 ringg_ai-mb-3",children:[F.jsx(k_,{className:"ringg_ai-w-4 ringg_ai-h-4",style:{color:On(r.primaryColor)}}),F.jsx("p",{className:"ringg_ai-text-sm ringg_ai-font-medium",style:{color:r.textColor},children:s.title})]}),F.jsxs("p",{className:"ringg_ai-text-xs ringg_ai-mb-3",style:{color:r.mutedTextColor},children:["Timezone: ",s.timezone]}),F.jsxs("div",{className:"ringg_ai-mb-3",children:[F.jsx("p",{className:"ringg_ai-text-xs ringg_ai-font-semibold ringg_ai-uppercase ringg_ai-tracking-wide ringg_ai-mb-2",style:{color:r.mutedTextColor},children:"Select Date"}),F.jsx("div",{className:"ringg_ai-flex ringg_ai-gap-2 ringg_ai-flex-wrap",children:l.map(w=>F.jsx("button",{onClick:()=>{h(w.date),v(null)},className:Nn("ringg_ai-px-3 ringg_ai-py-2 ringg_ai-text-xs ringg_ai-font-semibold ringg_ai-transition-all ringg_ai-duration-200","hover:ringg_ai-opacity-90 focus:ringg_ai-outline-none focus:ringg_ai-ring-2 focus:ringg_ai-ring-offset-1"),style:{borderRadius:a,...c===w.date?gi(r.primaryColor):{backgroundColor:r.backgroundColor},color:c===w.date?r.primaryTextColor:r.textColor,border:c===w.date?"none":`1px solid ${r.borderColor}`,boxShadow:c===w.date?"0 2px 4px rgba(0,0,0,0.1)":"none","--tw-ring-color":On(r.primaryColor)},children:w.dateLabel},w.date))})]}),F.jsx(Bg,{mode:"wait",children:b&&F.jsxs(Fi.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"ringg_ai-mb-3",children:[F.jsxs("p",{className:"ringg_ai-text-xs ringg_ai-font-semibold ringg_ai-uppercase ringg_ai-tracking-wide ringg_ai-mb-2 ringg_ai-flex ringg_ai-items-center ringg_ai-gap-1",style:{color:r.mutedTextColor},children:[F.jsx(QL,{className:"ringg_ai-w-3 ringg_ai-h-3"}),"Select Time"]}),F.jsx("div",{className:"ringg_ai-grid ringg_ai-grid-cols-3 ringg_ai-gap-1.5",children:b.slots.map(w=>F.jsx("button",{onClick:()=>v(w),className:Nn("ringg_ai-px-2 ringg_ai-py-2 ringg_ai-text-xs ringg_ai-font-medium ringg_ai-transition-all ringg_ai-duration-200","hover:ringg_ai-opacity-90 focus:ringg_ai-outline-none focus:ringg_ai-ring-2 focus:ringg_ai-ring-offset-1"),style:{borderRadius:a,...(p==null?void 0:p.id)===w.id?gi(r.primaryColor):{backgroundColor:r.backgroundColor},color:(p==null?void 0:p.id)===w.id?r.primaryTextColor:r.textColor,border:`1px solid ${(p==null?void 0:p.id)===w.id?On(r.primaryColor):r.borderColor}`,boxShadow:(p==null?void 0:p.id)===w.id?"0 2px 4px rgba(0,0,0,0.1)":"none","--tw-ring-color":On(r.primaryColor)},children:v5(w.datetime,s.timezone)},w.id))})]},c)}),F.jsx("button",{onClick:k,disabled:!p||e,className:Nn("ringg_ai-w-full ringg_ai-h-9 ringg_ai-text-sm ringg_ai-font-semibold ringg_ai-transition-all ringg_ai-duration-200","hover:ringg_ai-opacity-90 focus:ringg_ai-outline-none focus:ringg_ai-ring-2 focus:ringg_ai-ring-offset-2","disabled:ringg_ai-opacity-50 disabled:ringg_ai-cursor-not-allowed disabled:hover:ringg_ai-opacity-50"),style:{borderRadius:a,...!p||e?{backgroundColor:r.borderColor}:gi(r.primaryColor),color:!p||e?r.mutedTextColor:r.primaryTextColor,"--tw-ring-color":On(r.primaryColor)},children:e?F.jsxs("span",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-gap-2",children:[F.jsx(bf,{className:"ringg_ai-w-4 ringg_ai-h-4 ringg_ai-animate-spin"}),"Processing..."]}):"Next"})]})},rne={text:T_,email:XL,tel:EG,number:T_,select:KL,multiselect:TG,textarea:JL,boolean:RG,date:k_},ine=({payload:t,isProcessing:e,onComplete:n})=>{const r=Af(),a=LC(r.buttonStyle),{data:s}=t,[l,c]=H.useState({}),[h,p]=H.useState({}),v=(I,B)=>{if(I.required){if(B==null||B==="")return`${I.label} is required`;if(Array.isArray(B)&&B.length===0)return`${I.label} is required`;if(typeof B=="string"&&!B.trim())return`${I.label} is required`}if(typeof B=="string"&&B){if(I.validation){if(I.validation.minLength&&B.length<I.validation.minLength)return I.validation.message||`${I.label} must be at least ${I.validation.minLength} characters`;if(I.validation.maxLength&&B.length>I.validation.maxLength)return I.validation.message||`${I.label} must be at most ${I.validation.maxLength} characters`;if(I.validation.pattern&&!new RegExp(I.validation.pattern).test(B))return I.validation.message||`${I.label} is invalid`}if(I.type==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(B))return"Please enter a valid email address";if(I.type==="tel"&&!/^[\d\s\-+()]{7,}$/.test(B))return"Please enter a valid phone number"}return null},b=()=>{const I={};let B=!0;return s.fields.forEach(L=>{const N=v(L,l[L.name]);N&&(I[L.name]=N,B=!1)}),p(I),B},k=(I,B)=>{c(L=>({...L,[I]:B})),h[I]&&p(L=>{const N={...L};return delete N[I],N})},x=(I,B,L)=>{c(N=>{const Q=N[I]||[];return L?{...N,[I]:[...Q,B]}:{...N,[I]:Q.filter(Z=>Z!==B)}}),h[I]&&p(N=>{const Q={...N};return delete Q[I],Q})},w=()=>{b()&&n(l)},R=I=>typeof I=="string"?I:I.label,O=I=>typeof I=="string"?I:I.value,P=I=>({backgroundColor:r.backgroundColor,color:r.textColor,borderColor:I?r.errorColor:r.borderColor,borderRadius:r.borderRadius}),U="focus:ringg_ai-outline-none focus:ringg_ai-ring-2";return F.jsxs("div",{children:[F.jsxs("div",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2 ringg_ai-mb-2",children:[F.jsx(JL,{className:"ringg_ai-w-4 ringg_ai-h-4",style:{color:On(r.primaryColor)}}),F.jsx("p",{className:"ringg_ai-text-sm ringg_ai-font-medium",style:{color:r.textColor},children:s.title})]}),s.description&&F.jsx("p",{className:"ringg_ai-text-xs ringg_ai-mb-3",style:{color:r.mutedTextColor},children:s.description}),F.jsx("div",{className:"ringg_ai-space-y-2.5 ringg_ai-mb-3",children:s.fields.map(I=>{const B=rne[I.type]||T_,L=!!h[I.name];return F.jsxs("div",{children:[F.jsxs("label",{className:"ringg_ai-text-xs ringg_ai-font-medium ringg_ai-mb-1 ringg_ai-flex ringg_ai-items-center ringg_ai-gap-1",style:{color:r.mutedTextColor},children:[F.jsx(B,{className:"ringg_ai-w-3 ringg_ai-h-3"}),I.label,I.required&&F.jsx("span",{style:{color:r.errorColor},children:"*"})]}),I.type==="select"&&I.options&&F.jsxs("div",{className:"ringg_ai-relative",children:[F.jsxs("select",{value:l[I.name]||"",onChange:N=>k(I.name,N.target.value),className:Nn("ringg_ai-w-full ringg_ai-px-3 ringg_ai-py-2 ringg_ai-text-xs ringg_ai-border ringg_ai-transition-colors ringg_ai-appearance-none",U),style:{...P(L),"--tw-ring-color":On(r.primaryColor)},children:[F.jsx("option",{value:"",children:I.placeholder||`Select ${I.label.toLowerCase()}`}),I.options.map((N,Q)=>F.jsx("option",{value:O(N),children:R(N)},Q))]}),F.jsx(KL,{className:"ringg_ai-absolute ringg_ai-right-3 ringg_ai-top-1/2 -ringg_ai-translate-y-1/2 ringg_ai-w-3.5 ringg_ai-h-3.5 ringg_ai-pointer-events-none",style:{color:r.mutedTextColor}})]}),I.type==="multiselect"&&I.options&&F.jsx("div",{className:"ringg_ai-border ringg_ai-p-2 ringg_ai-space-y-1.5",style:{...P(L)},children:I.options.map((N,Q)=>{const Z=O(N),Se=(l[I.name]||[]).includes(Z);return F.jsxs("label",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2 ringg_ai-cursor-pointer",children:[F.jsx("input",{type:"checkbox",checked:Se,onChange:G=>x(I.name,Z,G.target.checked),className:"ringg_ai-w-3.5 ringg_ai-h-3.5 ringg_ai-rounded ringg_ai-border",style:{accentColor:On(r.primaryColor)}}),F.jsx("span",{className:"ringg_ai-text-xs",style:{color:r.textColor},children:R(N)})]},Q)})}),I.type==="boolean"&&F.jsxs("label",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2 ringg_ai-cursor-pointer ringg_ai-py-1",children:[F.jsx("input",{type:"checkbox",checked:l[I.name]||!1,onChange:N=>k(I.name,N.target.checked),className:"ringg_ai-w-4 ringg_ai-h-4 ringg_ai-rounded ringg_ai-border",style:{accentColor:On(r.primaryColor)}}),F.jsx("span",{className:"ringg_ai-text-xs",style:{color:r.mutedTextColor},children:I.placeholder||"Yes"})]}),I.type==="textarea"&&F.jsx("textarea",{placeholder:I.placeholder||`Enter ${I.label.toLowerCase()}`,value:l[I.name]||"",onChange:N=>k(I.name,N.target.value),rows:2,className:Nn("ringg_ai-w-full ringg_ai-px-3 ringg_ai-py-2 ringg_ai-text-xs ringg_ai-border ringg_ai-transition-colors ringg_ai-resize-none",U),style:{...P(L),"--tw-ring-color":On(r.primaryColor)}}),I.type==="number"&&F.jsx("input",{type:"number",placeholder:I.placeholder||`Enter ${I.label.toLowerCase()}`,value:l[I.name]??"",onChange:N=>k(I.name,N.target.value?Number(N.target.value):""),className:Nn("ringg_ai-w-full ringg_ai-px-3 ringg_ai-py-2 ringg_ai-text-xs ringg_ai-border ringg_ai-transition-colors",U),style:{...P(L),"--tw-ring-color":On(r.primaryColor)}}),I.type!=="select"&&I.type!=="multiselect"&&I.type!=="boolean"&&I.type!=="textarea"&&I.type!=="number"&&F.jsx("input",{type:I.type,placeholder:I.placeholder||`Enter ${I.label.toLowerCase()}`,value:l[I.name]||"",onChange:N=>k(I.name,N.target.value),className:Nn("ringg_ai-w-full ringg_ai-px-3 ringg_ai-py-2 ringg_ai-text-xs ringg_ai-border ringg_ai-transition-colors",U),style:{...P(L),"--tw-ring-color":On(r.primaryColor)}}),L&&F.jsx("p",{className:"ringg_ai-text-xs ringg_ai-mt-0.5",style:{color:r.errorColor},children:h[I.name]})]},I.name)})}),F.jsx("button",{onClick:w,disabled:e,className:Nn("ringg_ai-w-full ringg_ai-h-9 ringg_ai-text-sm ringg_ai-font-semibold ringg_ai-transition-all ringg_ai-duration-200","hover:ringg_ai-opacity-90 focus:ringg_ai-outline-none focus:ringg_ai-ring-2 focus:ringg_ai-ring-offset-2","disabled:ringg_ai-opacity-50 disabled:ringg_ai-cursor-not-allowed disabled:hover:ringg_ai-opacity-50"),style:{borderRadius:a,...e?{backgroundColor:r.borderColor}:gi(r.primaryColor),color:e?r.mutedTextColor:r.primaryTextColor,"--tw-ring-color":On(r.primaryColor)},children:e?F.jsxs("span",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-gap-2",children:[F.jsx(bf,{className:"ringg_ai-w-4 ringg_ai-h-4 ringg_ai-animate-spin"}),"Submitting..."]}):s.submit_label||"Next"})]})},ane=({payload:t,isProcessing:e,align:n="end",onButtonClick:r})=>{const a=Af(),{data:s}=t,l=s.presentation==="free",[c,h]=H.useState(null),p=async k=>{if(k.action.type==="navigate"){r(k.id,k.action);return}h(k.id);try{await r(k.id,k.action)}finally{h(null)}},v=k=>{switch(k){case"secondary":case"outline":return{backgroundColor:a.surfaceColor,color:a.textColor};case"destructive":return{backgroundColor:a.errorColor,color:a.primaryTextColor};case"primary":default:return{...gi(a.primaryColor),color:a.primaryTextColor}}},b=s.title&&F.jsx("p",{"data-ringg":"buttons-step-title",className:"ringg_ai-text-sm ringg_ai-font-medium ringg_ai-mb-2",style:{color:a.textColor},children:s.title});return l?F.jsxs("div",{"data-ringg":"quick-replies","data-ringg-align":n,className:"ringg_ai-w-full",children:[b,F.jsx("div",{className:Nn("ringg_ai-flex ringg_ai-flex-row ringg_ai-flex-wrap ringg_ai-gap-2",n==="center"?"ringg_ai-justify-center":"ringg_ai-justify-end"),children:s.buttons.map(k=>{const x=c===k.id,w=k.action.type==="navigate",R=x||e;return F.jsxs("button",{"data-ringg":"quick-reply-button","data-ringg-style":k.style??"primary",onClick:()=>p(k),disabled:R,className:Nn("ringg_ai-inline-flex ringg_ai-items-center ringg_ai-gap-1.5 ringg_ai-h-7 ringg_ai-px-3 ringg_ai-text-sm ringg_ai-font-medium ringg_ai-rounded-full ringg_ai-transition-opacity","hover:ringg_ai-opacity-90 focus:ringg_ai-outline-none",R&&"ringg_ai-opacity-50 ringg_ai-cursor-not-allowed hover:ringg_ai-opacity-50"),style:v(k.style),children:[x&&F.jsx(bf,{className:"ringg_ai-w-3 ringg_ai-h-3 ringg_ai-animate-spin"}),k.label,w&&F.jsx(ZL,{className:"ringg_ai-w-3 ringg_ai-h-3"})]},k.id)})})]}):F.jsxs("div",{children:[b,F.jsx("div",{"data-ringg":"options-list",className:"ringg_ai-flex ringg_ai-flex-col",children:s.buttons.map(k=>{const x=c===k.id,w=k.action.type==="navigate",R=x||e,O=k.style==="destructive";return F.jsxs("button",{"data-ringg":"option-row","data-ringg-style":k.style??"primary",onClick:()=>p(k),disabled:R,className:Nn("ringg_ai-flex ringg_ai-w-full ringg_ai-items-center ringg_ai-gap-3 ringg_ai-px-2 ringg_ai-py-2.5 ringg_ai-text-left ringg_ai-text-sm ringg_ai-transition-colors","ringg_ai-border-b last:ringg_ai-border-b-0 focus:ringg_ai-outline-none",!R&&"hover:ringg_ai-bg-black/[0.03]",R&&"ringg_ai-opacity-50 ringg_ai-cursor-not-allowed"),style:{borderColor:a.borderColor,color:O?a.errorColor:a.textColor},children:[x?F.jsx(bf,{className:"ringg_ai-w-4 ringg_ai-h-4 ringg_ai-shrink-0 ringg_ai-animate-spin"}):F.jsx("span",{"data-ringg":"option-radio","aria-hidden":!0,className:"ringg_ai-w-4 ringg_ai-h-4 ringg_ai-rounded-full ringg_ai-border ringg_ai-shrink-0",style:{borderColor:a.mutedTextColor}}),F.jsx("span",{className:"ringg_ai-flex-1",children:k.label}),w&&F.jsx(ZL,{className:"ringg_ai-w-3.5 ringg_ai-h-3.5 ringg_ai-shrink-0"})]},k.id)})})]})},b5=({data:t,collectedData:e})=>{const n=Af(),r=t.icon||"success",a=()=>{switch(r){case"success":return{icon:iv,bgColor:n.successColor};case"info":return{icon:xG,bgColor:n.primaryColor};case"warning":return{icon:AG,bgColor:"#f59e0b"};case"error":return{icon:SG,bgColor:n.errorColor};default:return{icon:iv,bgColor:n.successColor}}},{icon:s,bgColor:l}=a(),c=t.details||[],h=["slot_date","slot_time","name","email","phone"],p=x=>Array.isArray(x)?x.join(", "):typeof x=="boolean"?x?"Yes":"No":String(x),v=e?Object.entries(e).filter(([x])=>h.includes(x)).sort((x,w)=>h.indexOf(x[0])-h.indexOf(w[0])).map(([x,w])=>({key:x,label:x.replace(/slot_/g,"").replace(/_/g," ").replace(/\b\w/g,R=>R.toUpperCase()),value:p(w)})):[],b=c.length>0?c:v,k=x=>x?x.includes("date")?k_:x.includes("time")?QL:x.includes("email")?XL:x.includes("name")?PG:null:null;return F.jsxs(Fi.div,{initial:{opacity:0},animate:{opacity:1},className:"ringg_ai-py-2",children:[F.jsxs("div",{className:"ringg_ai-flex ringg_ai-items-start ringg_ai-gap-3 ringg_ai-mb-4",children:[F.jsx(Fi.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",stiffness:400,damping:15},className:"ringg_ai-w-9 ringg_ai-h-9 ringg_ai-rounded-full ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-flex-shrink-0",style:gi(l),children:F.jsx(s,{className:"ringg_ai-w-4.5 ringg_ai-h-4.5 ringg_ai-text-white"})}),F.jsxs(Fi.div,{initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{delay:.1},className:"ringg_ai-flex-1 ringg_ai-min-w-0 ringg_ai-pt-0.5",children:[F.jsx("h3",{className:"ringg_ai-text-sm ringg_ai-font-semibold ringg_ai-leading-tight",style:{color:n.textColor},children:t.title}),t.message&&F.jsx("p",{className:"ringg_ai-text-xs ringg_ai-mt-1 ringg_ai-leading-relaxed",style:{color:n.mutedTextColor},children:t.message})]})]}),b.length>0&&F.jsx(Fi.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:.15},className:"ringg_ai-rounded-lg ringg_ai-divide-y",style:{backgroundColor:n.surfaceColor,borderColor:n.borderColor},children:b.slice(0,4).map((x,w)=>{const R=x.key?k(x.key):null;return F.jsxs("div",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2.5 ringg_ai-px-3 ringg_ai-py-2.5",style:{borderColor:n.borderColor},children:[R&&F.jsx(R,{className:"ringg_ai-w-3.5 ringg_ai-h-3.5 ringg_ai-flex-shrink-0",style:{color:n.mutedTextColor}}),F.jsx("span",{className:"ringg_ai-text-xs ringg_ai-flex-shrink-0",style:{color:n.mutedTextColor},children:x.label}),F.jsx("span",{className:"ringg_ai-text-xs ringg_ai-font-medium ringg_ai-ml-auto ringg_ai-truncate",style:{color:n.textColor},title:x.value,children:x.value})]},w)})})]})};function one(t){return t.component_type==="interactive_flow"}const C5=({initialComponent:t,onApiCall:e,onComplete:n,onSendResponse:r,onSelectionDisplayed:a,quickReplyAlign:s="end"})=>{const l=one(t),c=!l&&jv(t)&&t.data.presentation==="free",h=Ja(),p=H.useMemo(()=>{const le=t.theme||{};return Lw({primaryColor:h.primaryColor,primaryTextColor:h.primaryTextColor,backgroundColor:h.backgroundColor,surfaceColor:h.surfaceColor,textColor:h.textColor,mutedTextColor:h.mutedTextColor,borderColor:h.borderColor,...le})},[t.theme,h]),v=l?t.data.steps:[{id:"single",title:"",component:t}],b=v.length,[k,x]=H.useState(0),[w,R]=H.useState(!1),[O,P]=H.useState({}),[U,I]=H.useState(null),[B,L]=H.useState(null),[N,Q]=H.useState(new Array(b).fill(!1)),Z=v[k],Se=b>1,G=H.useCallback(()=>{k>0&&x(le=>le-1)},[k]),re=H.useCallback(async le=>{R(!0);const he={...O,...le};P(he),Q(Le=>{const Ke=[...Le];return Ke[k]=!0,Ke});try{const Le=k===b-1,Ke=typeof le.selected_button=="string"?le.selected_button:null,ze=jv(Z.component)&&Ke?Z.component.data.buttons.find(De=>De.id===Ke)??{id:Ke,label:Ke,action:{type:"trigger_component"}}:null,me=jv(Z.component)&&Z.component.data.completionDisplay==="selected_item"&&!!ze;if(r){const De=Le&&me&&!!ze&&!!a;De&&(a(t.component_id,ze.label),n==null||n(he)),await r(t.component_id,{step_index:k,step_data:le,all_data:he,is_final_step:Le}),Le?De||(me&&ze?(L(ze.label),n==null||n(he)):(I({title:"Success!",message:"Your selection has been submitted.",icon:"success"}),n==null||n(he))):x(z=>z+1)}else if(Le)if(l){const{on_complete:De}=t.data,z={};for(const[q,ht]of Object.entries(he))z[q]=Array.isArray(ht)?JSON.stringify(ht):String(ht);const ee=Zte(De.payload,{...z,all_data:JSON.stringify(he)}),ke=await e(De.method,De.endpoint,ee);if(ke.success)I(ke.confirmation||{title:"Success!",message:ke.message,icon:"success"}),n==null||n(he);else throw new Error(ke.message||"Failed to complete")}else n==null||n(he);else x(De=>De+1)}catch(Le){console.error("Error processing step:",Le),I({title:"Something went wrong",message:Le.message||"Please try again.",icon:"error"})}finally{R(!1)}},[O,k,b,l,t,Z,e,n,r,a]),te=H.useCallback(async(le,he)=>{if(he.type==="navigate"&&he.url){window.open(he.url,"_blank","noopener,noreferrer");return}if(r){re({selected_button:le});return}if(he.type==="api_call"&&he.endpoint){R(!0);try{(await e(he.method||"POST",he.endpoint,he.payload||{})).success&&re({selected_button:le})}catch(Le){console.error("Error in button action:",Le)}finally{R(!1)}}else re({selected_button:le})},[e,re,r]);return F.jsx(y5.Provider,{value:p,children:F.jsxs(Fi.div,{"data-ringg":"interactive-flow",initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:Nn("ringg_ai-w-full",c?"ringg_ai-overflow-visible":"ringg_ai-border ringg_ai-overflow-hidden"),style:{backgroundColor:c?"transparent":p.backgroundColor,borderColor:c?"transparent":p.borderColor,color:p.textColor,fontFamily:p.fontFamily,fontSize:p.fontSize,borderRadius:c?void 0:p.borderRadius},children:[Se&&!U&&!B&&F.jsxs("div",{"data-ringg":"flow-stepper",className:"ringg_ai-px-4 ringg_ai-pt-4 ringg_ai-pb-3",children:[F.jsx("div",{"data-ringg":"flow-stepper-progress",className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2",children:v.map((le,he)=>F.jsxs("div",{"data-ringg":"flow-step","data-ringg-step-active":he===k,"data-ringg-step-completed":N[he],className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2 ringg_ai-flex-1 ringg_ai-min-w-0",children:[F.jsx("div",{"data-ringg":"flow-step-indicator",className:"ringg_ai-w-7 ringg_ai-h-7 ringg_ai-rounded-full ringg_ai-text-xs ringg_ai-font-semibold ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-flex-shrink-0 ringg_ai-transition-all",style:{...N[he]?{backgroundColor:p.successColor}:he===k?gi(p.primaryColor):{backgroundColor:p.borderColor},color:N[he]||he===k?p.primaryTextColor:p.mutedTextColor},children:N[he]?F.jsx(iv,{className:"ringg_ai-w-3.5 ringg_ai-h-3.5"}):he+1}),he<v.length-1&&F.jsx("div",{"data-ringg":"flow-step-connector",className:"ringg_ai-flex-1 ringg_ai-h-[2px] ringg_ai-rounded-full ringg_ai-transition-all",style:{backgroundColor:N[he]?p.successColor:p.borderColor}})]},le.id))}),F.jsx("p",{"data-ringg":"flow-step-title",className:"ringg_ai-text-xs ringg_ai-font-medium ringg_ai-mt-3 ringg_ai-truncate",style:{color:p.textColor},children:Z.title||`Step ${k+1} of ${b}`})]}),F.jsxs("div",{"data-ringg":"flow-content",className:Nn(c?"ringg_ai-p-0":"ringg_ai-px-4 ringg_ai-pb-4",!Se&&!c&&"ringg_ai-pt-4"),children:[k>0&&!U&&!B&&F.jsxs("button",{"data-ringg":"flow-back-button",onClick:G,className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-1 ringg_ai-text-xs ringg_ai-mb-3 ringg_ai-transition-colors hover:ringg_ai-opacity-80",style:{color:p.mutedTextColor},children:[F.jsx(x_,{className:"ringg_ai-w-3.5 ringg_ai-h-3.5"}),"Back"]}),F.jsx(Bg,{mode:"wait",children:B?F.jsx(Fi.div,{"data-ringg":"flow-submitted-selection",initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},className:"ringg_ai-py-2",children:F.jsxs("div",{"data-ringg":"flow-submitted-pill",className:"ringg_ai-inline-flex ringg_ai-max-w-full ringg_ai-items-center ringg_ai-gap-2 ringg_ai-rounded-[10px] ringg_ai-border ringg_ai-px-3 ringg_ai-py-2 ringg_ai-text-sm ringg_ai-font-semibold",style:{...gi(p.primaryColor),borderColor:p.primaryColor,color:p.primaryTextColor},children:[F.jsx(iv,{className:"ringg_ai-w-4 ringg_ai-h-4 ringg_ai-flex-shrink-0"}),F.jsx("span",{className:"ringg_ai-truncate",title:B,children:B})]})},"submitted_selection"):U?F.jsx(b5,{data:U,collectedData:O},"confirmation"):F.jsxs(Fi.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},children:[Jte(Z.component)&&F.jsx(nne,{payload:Z.component,isProcessing:w,onComplete:(le,he)=>{const Le=Z.component.data.timezone;re({slot_id:le,slot_datetime:he,slot_time:v5(he,Le),slot_date:Qte(he,Le)})}}),Xte(Z.component)&&F.jsx(ine,{payload:Z.component,isProcessing:w,onComplete:le=>re(le)}),jv(Z.component)&&F.jsx(ane,{payload:Z.component,isProcessing:w,align:s,onButtonClick:te}),ene(Z.component)&&F.jsx(b5,{data:Z.component.data})]},k)})]})]})})},sne=({ariaLabel:t="Connecting",className:e})=>{const n=Ja();return F.jsx("div",{"data-ringg":"loading-bar",className:Nn("ringg_ai-flex ringg_ai-h-12 ringg_ai-items-center ringg_ai-justify-center",e),children:F.jsx("div",{"data-ringg":"loading-bar-track",role:"progressbar","aria-label":t,"aria-busy":"true",className:"ringg_ai-relative ringg_ai-h-1.5 ringg_ai-w-[90%] ringg_ai-overflow-hidden ringg_ai-rounded-full",style:{backgroundColor:n.borderColor},children:F.jsx("div",{"data-ringg":"loading-bar-fill",className:"ringg_ai-absolute ringg_ai-inset-y-0 ringg_ai-left-0 ringg_ai-w-1/3 ringg_ai-rounded-full ringg_ai-animate-indeterminate-progress",style:gi(n.primaryColor)})})})},lne=()=>{const t=Ja();return F.jsx("div",{"data-ringg":"typing-indicator",className:"ringg_ai-flex ringg_ai-flex-col ringg_ai-items-start ringg_ai-gap-1 ringg_ai-justify-start ringg_ai-flex-row","aria-label":"Agent is typing",role:"status",children:F.jsx("div",{"data-ringg":"typing-indicator-bubble",className:"ringg_ai-flex ringg_ai-items-center ringg_ai-justify-start ringg_ai-gap-1 ringg_ai-py-2 ringg_ai-mr-auto",children:[0,1,2].map(e=>F.jsx("span",{"data-ringg":"typing-indicator-dot",className:Nn("ringg_ai-h-1.5 ringg_ai-w-1.5 ringg_ai-rounded-full ringg_ai-animate-bounce"),style:{backgroundColor:t.mutedTextColor,animationDelay:`${e*150}ms`,animationDuration:"1s"}},e))})})};function une(t){return t.sub_questions.length>0}function cne(t){return t.filter(une)}const dne=300,fne=({selectedDiseases:t,onSelectionChange:e,onNext:n,onSearch:r})=>{const a=Af(),s=LC(a.buttonStyle),[l,c]=H.useState(""),[h,p]=H.useState([]),[v,b]=H.useState(!1),[k,x]=H.useState(!1),w=H.useRef(),R=H.useMemo(()=>new Set(t.map(U=>U.disease_name)),[t]),O=H.useCallback(U=>{R.has(U.disease_name)?e(t.filter(I=>I.disease_name!==U.disease_name)):e([...t,U])},[t,R,e]),P=H.useCallback(U=>{e(t.filter(I=>I.disease_name!==U))},[t,e]);return H.useEffect(()=>{const U=l.trim();if(!U){p([]),x(!1),b(!1);return}return b(!0),w.current=setTimeout(async()=>{try{const I=await r(U);p(I)}catch{p([])}finally{b(!1),x(!0)}},dne),()=>{clearTimeout(w.current)}},[l,r]),F.jsxs("div",{"data-ringg":"disease-search",children:[t.length>0&&F.jsx("div",{"data-ringg":"disease-search-selected",className:"ringg_ai-flex ringg_ai-flex-wrap ringg_ai-gap-1.5 ringg_ai-mb-3",children:t.map(U=>F.jsxs("span",{"data-ringg":"disease-pill",className:"ringg_ai-inline-flex ringg_ai-items-center ringg_ai-gap-1 ringg_ai-px-2 ringg_ai-py-1 ringg_ai-rounded-full ringg_ai-text-[10px] ringg_ai-font-medium",style:{backgroundColor:On(a.primaryColor)+"18",color:On(a.primaryColor)},children:[U.disease_name,F.jsx("button",{"data-ringg":"disease-pill-remove",type:"button",onClick:()=>P(U.disease_name),className:"ringg_ai-ml-0.5 hover:ringg_ai-opacity-70 ringg_ai-transition-opacity",children:F.jsx(t3,{className:"ringg_ai-w-2.5 ringg_ai-h-2.5"})})]},U.disease_name))}),t.length===0&&F.jsx("p",{"data-ringg":"disease-search-empty",className:"ringg_ai-text-[10px] ringg_ai-mb-2",style:{color:a.mutedTextColor},children:"No conditions selected yet"}),F.jsxs("div",{"data-ringg":"disease-search-input-wrapper",className:"ringg_ai-relative ringg_ai-mb-3",children:[F.jsx(e3,{className:"ringg_ai-absolute ringg_ai-left-2.5 ringg_ai-top-1/2 -ringg_ai-translate-y-1/2 ringg_ai-w-3.5 ringg_ai-h-3.5",style:{color:a.mutedTextColor}}),F.jsx("input",{"data-ringg":"disease-search-input",type:"text",value:l,onChange:U=>c(U.target.value),placeholder:"Type to search diseases...",autoComplete:"off",className:"ringg_ai-w-full ringg_ai-pl-8 ringg_ai-pr-3 ringg_ai-py-2 ringg_ai-text-xs ringg_ai-border ringg_ai-transition-colors focus:ringg_ai-outline-none focus:ringg_ai-ring-1 focus:ringg_ai-ring-inset",style:{backgroundColor:a.backgroundColor,color:a.textColor,borderColor:a.borderColor,borderRadius:s,"--tw-ring-color":On(a.primaryColor)}})]}),F.jsxs("div",{"data-ringg":"disease-search-results",className:"ringg_ai-max-h-[200px] ringg_ai-overflow-y-auto ringg_ai-mb-3",children:[!l.trim()&&F.jsx("p",{className:"ringg_ai-text-xs ringg_ai-text-center ringg_ai-py-4",style:{color:a.mutedTextColor},children:"Type to search diseases..."}),l.trim()&&v&&F.jsxs("div",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-py-4 ringg_ai-gap-2",children:[F.jsx(bf,{className:"ringg_ai-w-4 ringg_ai-h-4 ringg_ai-animate-spin",style:{color:On(a.primaryColor)}}),F.jsx("p",{className:"ringg_ai-text-xs",style:{color:a.mutedTextColor},children:"Searching..."})]}),l.trim()&&!v&&k&&h.length===0&&F.jsxs("p",{className:"ringg_ai-text-xs ringg_ai-text-center ringg_ai-py-4",style:{color:a.mutedTextColor},children:['No diseases found for "',l.trim(),'"']}),!v&&h.length>0&&F.jsx("div",{"data-ringg":"disease-search-list",className:"ringg_ai-space-y-1",children:h.map(U=>{const I=R.has(U.disease_name);return F.jsxs("button",{"data-ringg":"disease-option","data-ringg-selected":I,type:"button",onClick:()=>O(U),className:"ringg_ai-w-full ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2 ringg_ai-px-2.5 ringg_ai-py-2 ringg_ai-rounded-lg ringg_ai-text-left ringg_ai-transition-colors hover:ringg_ai-opacity-80",style:{backgroundColor:I?On(a.primaryColor)+"0D":"transparent"},children:[F.jsx("div",{className:"ringg_ai-flex-shrink-0 ringg_ai-w-4 ringg_ai-h-4 ringg_ai-rounded ringg_ai-border ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-transition-colors",style:{...I?gi(a.primaryColor):{},borderColor:I?On(a.primaryColor):a.borderColor},children:I&&F.jsx(iv,{className:"ringg_ai-w-2.5 ringg_ai-h-2.5",style:{color:a.primaryTextColor}})}),F.jsx("span",{className:"ringg_ai-flex-1 ringg_ai-text-xs",style:{color:a.textColor},children:U.disease_name})]},U.disease_name)})})]}),F.jsx("button",{"data-ringg":"disease-search-next",onClick:n,disabled:t.length===0,className:Nn("ringg_ai-w-full ringg_ai-h-9 ringg_ai-text-sm ringg_ai-font-semibold ringg_ai-transition-all ringg_ai-duration-200","hover:ringg_ai-opacity-90 focus:ringg_ai-outline-none focus:ringg_ai-ring-1 focus:ringg_ai-ring-inset","disabled:ringg_ai-opacity-50 disabled:ringg_ai-cursor-not-allowed disabled:hover:ringg_ai-opacity-50"),style:{borderRadius:s,...t.length===0?{backgroundColor:a.borderColor}:gi(a.primaryColor),color:t.length===0?a.mutedTextColor:a.primaryTextColor,"--tw-ring-color":On(a.primaryColor)},children:F.jsxs("span",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-gap-1",children:["Next",F.jsx("span",{className:"ringg_ai-text-xs ringg_ai-opacity-70",children:"→"})]})})]})},hne=({diseases:t,initialAnswers:e,onComplete:n,isProcessing:r})=>{const a=Af(),s=LC(a.buttonStyle),[l,c]=H.useState(0),[h,p]=H.useState(e),v=t[l],b=l===t.length-1,k=l===0,x=h[v.disease_name]??[],w=U=>{var I;return((I=x.find(B=>B.question_id===U))==null?void 0:I.answer)??""},R=H.useCallback((U,I)=>{p(B=>{const N=(B[v.disease_name]??[]).filter(Q=>Q.question_id!==U);return N.push({question_id:U,answer:I}),{...B,[v.disease_name]:N}})},[v.disease_name]),O=H.useCallback(()=>{k||c(U=>U-1)},[k]),P=H.useCallback(()=>{b?n(h):c(U=>U+1)},[b,h,n]);return F.jsxs("div",{"data-ringg":"sub-questions",children:[F.jsxs("div",{"data-ringg":"sub-questions-header",className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2 ringg_ai-mb-3",children:[F.jsx("div",{"data-ringg":"sub-questions-counter",className:"ringg_ai-w-7 ringg_ai-h-7 ringg_ai-rounded-lg ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center",style:{backgroundColor:On(a.primaryColor)+"18"},children:F.jsxs("span",{className:"ringg_ai-text-xs",style:{color:On(a.primaryColor)},children:[l+1,"/",t.length]})}),F.jsxs("div",{"data-ringg":"sub-questions-meta",children:[F.jsx("p",{"data-ringg":"sub-questions-disease-name",className:"ringg_ai-text-xs ringg_ai-font-medium",style:{color:a.textColor},children:v.disease_name}),F.jsxs("p",{"data-ringg":"sub-questions-progress",className:"ringg_ai-text-[10px]",style:{color:a.mutedTextColor},children:[l+1," of ",t.length]})]})]}),F.jsx("div",{"data-ringg":"sub-questions-list",className:"ringg_ai-space-y-3 ringg_ai-mb-4",children:v.sub_questions.map(U=>{const I=w(U.question_id);return F.jsxs("div",{"data-ringg":"sub-question","data-ringg-question-type":U.question_type,children:[F.jsx("label",{"data-ringg":"sub-question-label",className:"ringg_ai-text-xs ringg_ai-font-medium ringg_ai-mb-1 ringg_ai-block",style:{color:a.mutedTextColor},children:U.label}),U.question_type==="INPUT"&&F.jsx("input",{"data-ringg":"sub-question-input",type:"text",value:I,onChange:B=>R(U.question_id,B.target.value),placeholder:U.placeholder??`Enter ${U.label.toLowerCase()}`,className:"ringg_ai-w-full ringg_ai-px-3 ringg_ai-py-2 ringg_ai-text-xs ringg_ai-border ringg_ai-transition-colors focus:ringg_ai-outline-none focus:ringg_ai-ring-1 focus:ringg_ai-ring-inset",style:{backgroundColor:a.backgroundColor,color:a.textColor,borderColor:a.borderColor,borderRadius:s,"--tw-ring-color":On(a.primaryColor)}}),U.question_type==="SINGLE_SELECT"&&U.options&&F.jsx("div",{"data-ringg":"sub-question-options","data-ringg-mode":"single",className:"ringg_ai-flex ringg_ai-flex-wrap ringg_ai-gap-1.5",children:U.options.map(B=>{const L=I===B;return F.jsx("button",{"data-ringg":"sub-question-option","data-ringg-selected":L,type:"button",onClick:()=>R(U.question_id,B),className:"ringg_ai-px-3 ringg_ai-py-1.5 ringg_ai-text-xs ringg_ai-font-medium ringg_ai-border ringg_ai-transition-all hover:ringg_ai-opacity-80",style:{borderRadius:s,...L?gi(a.primaryColor):{backgroundColor:a.backgroundColor},color:L?a.primaryTextColor:a.textColor,borderColor:L?On(a.primaryColor):a.borderColor},children:B},B)})}),U.question_type==="MULTI_SELECT"&&U.options&&F.jsx("div",{"data-ringg":"sub-question-options","data-ringg-mode":"multi",className:"ringg_ai-flex ringg_ai-flex-wrap ringg_ai-gap-1.5",children:U.options.map(B=>{const L=I?I.split(","):[],N=L.includes(B);return F.jsx("button",{"data-ringg":"sub-question-option","data-ringg-selected":N,type:"button",onClick:()=>{const Q=N?L.filter(Z=>Z!==B):[...L,B];R(U.question_id,Q.join(","))},className:"ringg_ai-px-3 ringg_ai-py-1.5 ringg_ai-text-xs ringg_ai-font-medium ringg_ai-border ringg_ai-transition-all hover:ringg_ai-opacity-80",style:{borderRadius:s,...N?gi(a.primaryColor):{backgroundColor:a.backgroundColor},color:N?a.primaryTextColor:a.textColor,borderColor:N?On(a.primaryColor):a.borderColor},children:B},B)})})]},U.question_id)})}),F.jsxs("div",{"data-ringg":"sub-questions-nav",className:"ringg_ai-flex ringg_ai-gap-2",children:[!k&&F.jsxs("button",{"data-ringg":"sub-questions-prev",onClick:O,className:"ringg_ai-flex-1 ringg_ai-h-9 ringg_ai-text-sm ringg_ai-font-semibold ringg_ai-border ringg_ai-transition-all hover:ringg_ai-opacity-80 ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-gap-1",style:{borderRadius:s,backgroundColor:a.backgroundColor,color:a.textColor,borderColor:a.borderColor},children:[F.jsx(x_,{className:"ringg_ai-w-3.5 ringg_ai-h-3.5"}),"Back"]}),F.jsx("button",{"data-ringg":"sub-questions-next",onClick:P,disabled:r,className:Nn("ringg_ai-flex-1 ringg_ai-h-9 ringg_ai-text-sm ringg_ai-font-semibold ringg_ai-transition-all ringg_ai-duration-200","hover:ringg_ai-opacity-90 focus:ringg_ai-outline-none focus:ringg_ai-ring-1 focus:ringg_ai-ring-inset","disabled:ringg_ai-opacity-50 disabled:ringg_ai-cursor-not-allowed","ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-gap-1"),style:{borderRadius:s,...r?{backgroundColor:a.borderColor}:gi(a.primaryColor),color:r?a.mutedTextColor:a.primaryTextColor,"--tw-ring-color":On(a.primaryColor)},children:r?F.jsx(bf,{className:"ringg_ai-w-4 ringg_ai-h-4 ringg_ai-animate-spin"}):F.jsxs(F.Fragment,{children:["Next",F.jsx(CG,{className:"ringg_ai-w-3.5 ringg_ai-h-3.5"})]})})]})]})},pne=1500;function mne(t){return t.replace(/^\//,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}const gne=({label:t,onSearch:e,onSubmit:n})=>{const r=Af(),[a,s]=H.useState("select"),[l,c]=H.useState([]),[h,p]=H.useState({}),v=H.useMemo(()=>cne(l),[l]),b=a==="select"||a==="details",k=H.useCallback(()=>{a==="details"&&s("select")},[a]),x=H.useCallback(O=>{n({selections:O}),s("searching")},[n]),w=H.useCallback(()=>{if(v.length>0)s("details");else{const O=l.map(P=>({disease_name:P.disease_name,sub_questions:[]}));x(O)}},[v.length,l,x]),R=H.useCallback(O=>{p(O);const P=l.map(U=>({disease_name:U.disease_name,sub_questions:O[U.disease_name]??[]}));x(P)},[l,x]);return H.useEffect(()=>{if(a!=="searching")return;const O=setTimeout(()=>{s("submitted")},pne);return()=>clearTimeout(O)},[a]),F.jsx("div",{"data-ringg":"policy-finder","data-ringg-step":a,className:"ringg_ai-rounded-lg ringg_ai-border ringg_ai-overflow-hidden ringg_ai-p-3",style:{borderColor:r.borderColor,backgroundColor:r.backgroundColor},children:F.jsxs(Bg,{mode:"wait",children:[a==="searching"&&F.jsxs(Fi.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-3 ringg_ai-py-3",children:[F.jsx("div",{className:"ringg_ai-w-8 ringg_ai-h-8 ringg_ai-rounded-full ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-flex-shrink-0",style:{backgroundColor:On(r.primaryColor)+"12"},children:F.jsx(Fi.div,{animate:{rotate:360},transition:{duration:1.5,repeat:1/0,ease:"linear"},children:F.jsx(e3,{className:"ringg_ai-w-4 ringg_ai-h-4",style:{color:On(r.primaryColor)}})})}),F.jsxs("div",{className:"ringg_ai-flex-1 ringg_ai-min-w-0",children:[F.jsx("p",{className:"ringg_ai-text-xs ringg_ai-font-medium",style:{color:r.textColor},children:"Finding best policies..."}),F.jsx("div",{className:"ringg_ai-flex ringg_ai-gap-1 ringg_ai-mt-1",children:[0,1,2].map(O=>F.jsx(Fi.div,{animate:{opacity:[.3,1,.3]},transition:{duration:1,repeat:1/0,delay:O*.15},className:"ringg_ai-w-1 ringg_ai-h-1 ringg_ai-rounded-full",style:{backgroundColor:On(r.primaryColor)}},O))})]})]},"searching"),a==="submitted"&&F.jsxs(Fi.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-3 ringg_ai-py-3",children:[F.jsx("div",{className:"ringg_ai-w-8 ringg_ai-h-8 ringg_ai-flex-shrink-0",children:F.jsxs("svg",{viewBox:"0 0 32 32",fill:"none",className:"ringg_ai-w-full ringg_ai-h-full",children:[F.jsx(Fi.circle,{cx:"16",cy:"16",r:"14",stroke:r.successColor,strokeWidth:"2",fill:"none",initial:{pathLength:0},animate:{pathLength:1},transition:{duration:.4,ease:"easeOut"}}),F.jsx(Fi.path,{d:"M10 16.5L14 20.5L22 12.5",stroke:r.successColor,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",initial:{pathLength:0},animate:{pathLength:1},transition:{duration:.3,delay:.3,ease:"easeOut"}})]})}),F.jsxs("div",{className:"ringg_ai-flex-1 ringg_ai-min-w-0",children:[F.jsx("p",{className:"ringg_ai-text-xs ringg_ai-font-medium",style:{color:r.textColor},children:"Query submitted"}),F.jsx("p",{className:"ringg_ai-text-[10px] ringg_ai-mt-0.5",style:{color:r.mutedTextColor},children:"Policy results will appear in chat shortly"})]})]},"submitted"),b&&F.jsxs(Fi.div,{"data-ringg":"policy-finder-form",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:[F.jsx("p",{"data-ringg":"policy-finder-title",className:"ringg_ai-text-sm ringg_ai-font-medium ringg_ai-mb-3",style:{color:r.textColor},children:t?mne(t):"Disease Acceptance"}),a==="details"&&F.jsxs("button",{"data-ringg":"policy-finder-back",onClick:k,className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-1 ringg_ai-text-xs ringg_ai-mb-3 ringg_ai-transition-colors hover:ringg_ai-opacity-80",style:{color:r.mutedTextColor},children:[F.jsx(x_,{className:"ringg_ai-w-3.5 ringg_ai-h-3.5"}),"Back"]}),F.jsx(Bg,{mode:"wait",children:F.jsxs(Fi.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},children:[a==="select"&&F.jsx(fne,{selectedDiseases:l,onSelectionChange:c,onNext:w,onSearch:e}),a==="details"&&F.jsx(hne,{diseases:v,initialAnswers:h,onComplete:R})]},a)})]},"form")]})})},vne=o4("ringg_ai-inline-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-gap-2 ringg_ai-whitespace-nowrap ringg_ai-rounded-md ringg_ai-text-sm ringg_ai-font-medium ringg_ai-ring-offset-background ringg_ai-transition-colors focus-visible:ringg_ai-outline-none focus-visible:ringg_ai-ring-2 focus-visible:ringg_ai-ring-ring focus-visible:ringg_ai-ring-offset-2 disabled:ringg_ai-pointer-events-none disabled:ringg_ai-opacity-50 [&_svg]:ringg_ai-pointer-events-none [&_svg]:ringg_ai-size-4 [&_svg]:ringg_ai-shrink-0",{variants:{variant:{default:"ringg_ai-bg-primary ringg_ai-text-primary-foreground ringg_ai-shadow hover:ringg_ai-bg-primary/90",destructive:"ringg_ai-bg-destructive ringg_ai-text-destructive-foreground ringg_ai-shadow-sm hover:ringg_ai-bg-destructive/90",outline:"ringg_ai-border ringg_ai-border-input ringg_ai-bg-background ringg_ai-shadow-sm hover:ringg_ai-bg-accent hover:ringg_ai-text-accent-foreground",secondary:"ringg_ai-bg-secondary ringg_ai-text-secondary-foreground ringg_ai-shadow-sm hover:ringg_ai-bg-secondary/80",ghost:"hover:ringg_ai-bg-accent hover:ringg_ai-text-accent-foreground",link:"ringg_ai-text-primary ringg_ai-underline-offset-4 hover:ringg_ai-underline"},size:{default:"ringg_ai-h-9 ringg_ai-px-4 ringg_ai-py-2",sm:"ringg_ai-h-8 ringg_ai-rounded-md ringg_ai-px-3 ringg_ai-text-xs",lg:"ringg_ai-h-10 ringg_ai-rounded-md ringg_ai-px-8",icon:"ringg_ai-h-9 ringg_ai-w-9"}},defaultVariants:{variant:"default",size:"default"}}),Fv=H.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,...a},s)=>{const l=r?gC:"button";return F.jsx(l,{className:Nn(vne({variant:e,size:n,className:t})),ref:s,...a})});Fv.displayName="Button";function td(t,e){typeof window<"u"&&window.dispatchEvent(new CustomEvent(t,{detail:e}))}function yne({callMode:t}){const[e,n]=H.useState(!1),[r,a]=H.useState(!1),[s,l]=H.useState(null),c=H.useRef(!1),h=H.useRef(t);h.current=t;const p=H.useCallback(()=>{c.current||(c.current=!0,n(!0),td("ringg:widget_status",{status:"maximised",mode:h.current}))},[]),v=H.useCallback(()=>{c.current=!1,n(!1),td("ringg:widget_status",{status:"minimised",mode:h.current})},[]),b=H.useCallback(()=>{a(!1),l(null),v()},[v]),k=H.useCallback(()=>{c.current?v():p()},[p,v]);return H.useMemo(()=>({isOpen:e,showFeedback:r,currentCallId:s,setShowFeedback:a,setCurrentCallId:l,open:p,minimize:v,close:b,toggle:k}),[e,r,s,p,v,b,k])}function bne({room:t,onError:e}){const[n,r]=H.useState("unknown"),a=H.useRef(e);a.current=e;const s=H.useCallback(async()=>{var h;try{if((h=navigator.permissions)!=null&&h.query){const p=await navigator.permissions.query({name:"microphone"});r(p.state),p.onchange=()=>{r(p.state)}}else try{await navigator.mediaDevices.getUserMedia({audio:!0}),r("granted")}catch{r("denied")}}catch(p){console.error("Error checking microphone permission:",p),r("unknown")}},[]),l=H.useCallback(async()=>{var h;try{const p=await navigator.mediaDevices.getUserMedia({audio:!0});return r("granted"),p.getTracks().forEach(v=>v.stop()),!0}catch(p){return console.error("Error requesting microphone permission:",p),r("denied"),(h=a.current)==null||h.call(a,"Microphone access was denied. Please enable it in your browser settings."),!1}},[]);H.useEffect(()=>{s();const h=()=>{var p;(p=a.current)==null||p.call(a,"Error acquiring microphone permission. Please make sure you grant the necessary permissions in your browser and reload the tab"),r("denied")};return t.on(Pe.MediaDevicesError,h),()=>{t.off(Pe.MediaDevicesError,h)}},[t,s]);const c=n==="granted";return H.useMemo(()=>({state:n,isGranted:c,check:s,request:l}),[n,c,s,l])}function Cne({containerRef:t,enabled:e}){H.useEffect(()=>{const n=t.current;if(!n||!e)return;const r=c=>{const h=n.querySelector('[data-scrollable="true"]');if(!h){c.preventDefault();return}const{scrollTop:p,scrollHeight:v,clientHeight:b}=h,k=p===0&&c.deltaY<0,x=p+b>=v-1&&c.deltaY>0;(k||x)&&c.preventDefault()};let a=0;const s=c=>{a=c.touches[0].clientY},l=c=>{const h=n.querySelector('[data-scrollable="true"]'),p=c.touches[0].clientY,v=a-p;if(!h){c.preventDefault();return}const{scrollTop:b,scrollHeight:k,clientHeight:x}=h,w=b===0&&v<0,R=b+x>=k-1&&v>0;(w||R)&&c.preventDefault()};return n.addEventListener("wheel",r,{passive:!1}),n.addEventListener("touchstart",s,{passive:!0}),n.addEventListener("touchmove",l,{passive:!1}),()=>{n.removeEventListener("wheel",r),n.removeEventListener("touchstart",s),n.removeEventListener("touchmove",l)}},[e])}const Ul={mode:"prod",title:"Ringg AI Support",description:"Ringg AI offers 24/7 support to handle all your customer queries",defaultTab:"audio",hideTabSelector:!1,bypassStartScreen:!1,bypassFeedbackScreen:!1,notificationTuneUrl:"https://assets.ringg.ai/audios/misc/widget_notification.mp3",voiceCallShowTranscript:!0,voiceCallShowAnimation:!1};function jw(t){switch(t){case"dev":return"https://calling-dev.ringg.ai/ca/api/v0";case"stage":return"https://stage-api2.desivocal.com/ca/api/v0";default:return"https://prod-api.ringg.ai/ca/api/v0"}}function Sne(t){switch(t){case"dev":return;case"stage":return"wss://mercury.webrtc-stage.ringg.ai";default:return"wss://mercury.webrtc.ringg.ai"}}function kne(t){return((t==null?void 0:t.trim())||void 0||"").trim()}function xne(t){return((t==null?void 0:t.trim())||void 0||"").trim()}function Fw(t,e){const n=xne(t);if(n)return{Authorization:n};const r=kne(e);return r?{"X-API-KEY":r}:{}}const S5={center:{top:0,left:0,right:0,bottom:0,margin:"auto"},"top-left":{top:"2%",left:"2%"},"top-right":{top:"2%",right:"2%"},"bottom-left":{bottom:"2%",left:"2%"},"bottom-right":{bottom:"2%",right:"2%"},"bottom-center":{bottom:"2%",left:"50%"}};function Tne(t){return S5[t]??S5["bottom-right"]}function _ne(t){return t==="bottom-center"?{left:"50%"}:t==="bottom-left"?{left:"2%"}:{right:"2%"}}function jC(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function wne(t){return t?{width:jC(t.width),height:jC(t.height),borderRadius:jC(t.borderRadius)}:{}}function Ene(t,e){if(!e)return t;let n=[t];return Object.entries(e).forEach(([r,a])=>{n=n.flatMap((s,l)=>{if(typeof s!="string")return s;const c=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h=new RegExp(`\\b(${c})\\b`,"g");return s.split(h).map((p,v)=>p===r?F.jsx("a",{target:"_blank",rel:"noopener noreferrer",className:"ringg_ai-text-blue-500 hover:ringg_ai-underline",href:a,children:r},`${l}-${v}`):p)})}),n}const Uv=(...t)=>console.warn("[DOM_ACTION]",...t);function Rne(t,e){const n=s=>{try{e==null||e(s)}catch(l){Uv("logger threw",l)}};if(!t||typeof t!="object"){Uv("Missing or invalid action config"),n({label:"Invalid action",level:"error"});return}const{id:r,kind:a}=t;if(a!=="trigger_event"){Uv(`[${r}] unknown kind`,a),n({id:r,label:"Unknown kind",meta:String(a),level:"error"});return}try{if(!t.event_name)return Uv(`[${r}] trigger_event missing event_name`),n({id:r,label:"Event missing name",level:"error"});const s={...t.default_payload??{},action_id:r};window.dispatchEvent(new CustomEvent(t.event_name,{detail:s})),n({id:r,label:"Triggered",meta:t.event_name,level:"info"})}catch(s){Uv(`[${r}] execution failed`,s),n({id:r,label:"Action failed",level:"error"})}}const Ane=({label:t,meta:e,level:n="info"})=>{const r=Ja(),a=n==="error"?"#ef4444":"#22c55e";return F.jsx("div",{"data-ringg":"system-log","data-ringg-level":n,className:"ringg_ai-flex ringg_ai-justify-center ringg_ai-my-1",children:F.jsxs("div",{"data-ringg":"system-log-pill",className:"ringg_ai-inline-flex ringg_ai-items-center ringg_ai-gap-2 ringg_ai-px-3 ringg_ai-py-1 ringg_ai-rounded-full ringg_ai-border ringg_ai-text-[11px] ringg_ai-max-w-full",style:{borderColor:r.borderColor,backgroundColor:r.backgroundColor,color:r.textColor},role:"status",children:[F.jsx("span",{"data-ringg":"system-log-dot",className:"ringg_ai-inline-block ringg_ai-w-1.5 ringg_ai-h-1.5 ringg_ai-rounded-full ringg_ai-flex-shrink-0",style:{backgroundColor:a}}),F.jsx("span",{"data-ringg":"system-log-label",className:"ringg_ai-font-medium ringg_ai-truncate",children:t}),e&&F.jsx("span",{"data-ringg":"system-log-meta",className:"ringg_ai-font-mono ringg_ai-truncate",style:{color:r.mutedTextColor},title:e,children:e})]})})},Pne=800,Dne=120,One=500;function k5(t){return!!(t!=null&&t.componentData)&&jv(t.componentData)&&t.componentData.data.presentation==="free"}function x5(t){return!!t&&!t.componentType&&!t.isSelf&&!!t.message.trim()}const Mne=({room:t,config:e})=>{var ns,Bi,Bl,Ai,Vl,Lu,ju,Oo,rs,Vi,io;const[n,r]=H.useState({}),a=e,{mode:s=Ul.mode,title:l=Ul.title,description:c=Ul.description,agentId:h,variables:p,buttons:v,xApiKey:b,authorization:k,defaultTab:x=Ul.defaultTab,hideTabSelector:w=Ul.hideTabSelector,bypassStartScreen:R=Ul.bypassStartScreen,bypassFeedbackScreen:O=Ul.bypassFeedbackScreen,innerWindowProps:P,logoUrl:U,logoStyles:I,legalDisclaimer:B,feedbackScreen:L,notificationTuneUrl:N=Ul.notificationTuneUrl,widgetPosition:Q,theme:Z,enabledSlashCommands:Se,voiceCall:G}=a,re=i3(Z),te=__(re.buttonStyle),le=(Q==null?void 0:Q.triggerPlacement)??"fixed",he=(Q==null?void 0:Q.triggerAlignment)??"bottom-right",Le=(Q==null?void 0:Q.hideTriggerOnExpand)??!0,Ke=(Q==null?void 0:Q.widgetAlignment)??"bottom-right",ze=Tne(he),me=wne(P),[De,z]=H.useState(x),[ee,ke]=H.useState(!1),[q,ht]=H.useState(!1),[At,yt]=H.useState({hasError:!1,message:""}),[ut,ot]=H.useState([]),[jt,en]=H.useState(!1),[Kn,_r]=H.useState(new Set),[Ar,sr]=H.useState(new Map),[jr,kr]=H.useState([]),Qn=H.useRef(null),J=H.useRef(null),ue=H.useRef(null),ve=H.useRef(null),Be=H.useRef(""),We=H.useRef(),je=H.useRef(null),ct=H.useRef(!1),Lt=H.useRef([]),se=H.useRef(null),we=H.useRef(null),pt=H.useRef(0),Yt=H.useRef(De);Yt.current=De;const tn=H.useRef(!1);H.useEffect(()=>{tn.current||z(x)},[x]);const qe=H.useCallback(()=>{pt.current=performance.now(),we.current===null&&(we.current=performance.now()),en(!0)},[]),kt=H.useRef(new Map),Mt=c1(t),wt=Mt==="connected";tn.current=wt;const mt=yne({callMode:De}),fn=bne({room:t,onError:Te=>yt({hasError:!0,message:Te})});Cne({containerRef:ue,enabled:mt.isOpen});const{chatMessages:Mn}=XM(),Rn=M7(),gn=x7(),Zn=JM(),An=d1(Rn.audioTrack||void 0),ra=d1({publication:gn.microphoneTrack,source:Oe.Source.Microphone,participant:gn.localParticipant}),lr=H.useMemo(()=>Zn.find(Te=>{var Ee;return(Ee=Te.identity)==null?void 0:Ee.includes("agent")}),[Zn]),Ri=De==="audio",ma=Ri&&wt&&((G==null?void 0:G.showAnimation)??Ul.voiceCallShowAnimation),es=!Ri||((G==null?void 0:G.showTranscript)??Ul.voiceCallShowTranscript),tl=ma?(ns=gn.localParticipant.getTrackPublication(Oe.Source.Microphone))==null?void 0:ns.track:void 0,ts=ma?(Bi=lr==null?void 0:lr.getTrackPublication(Oe.Source.Microphone))==null?void 0:Bi.track:void 0,ks=H.useMemo(()=>{const Te=Se??[],Ee=new Set(Te.map(Et=>Et.command)),Xe=[...Te];for(const Et of jr)Ee.has(Et.command)||Xe.push(Et);return Xe},[Se,jr]),no=H.useCallback((Te,Ee)=>{ct.current=!1,td("ringg:conversation_status",{status:"started",mode:Te,callId:Ee})},[]),ia=H.useCallback((Te,Ee)=>{ct.current||(ct.current=!0,td("ringg:conversation_status",{status:"ended",mode:Te,callId:Ee}))},[]),Fr=H.useCallback(async Te=>{if(!(Te==="audio"&&!fn.isGranted&&!await fn.request())){ke(!0),z(Te);try{const Ee=await fetch(`${jw(s)}/calling/webcall`,{method:"POST",body:JSON.stringify({agent_id:h,custom_args_values:p,media_type:Te}),headers:{"Content-Type":"application/json",...Fw(k,b)}}),Xe=await Ee.json();if(!Ee.ok)throw new Error((Xe==null?void 0:Xe.message)||"Failed to make call");Xe!=null&&Xe.call_id&&mt.setCurrentCallId(Xe.call_id),Array.isArray(Xe==null?void 0:Xe.enabled_slash_commands)&&kr(Xe.enabled_slash_commands),await t.connect(Sne(s),Xe==null?void 0:Xe.user_token),Te==="audio"&&await t.localParticipant.setMicrophoneEnabled(!0),no(Te,Xe.call_id),yt({hasError:!1,message:""})}catch(Ee){yt({hasError:!0,message:Ee.message})}finally{ke(!1)}}},[t,s,h,p,b,k,fn,mt,no]),ga=H.useCallback(()=>{R&&!wt&&!ee&&Mt==="disconnected"?(mt.open(),Fr(De)):mt.toggle()},[R,wt,ee,Mt,De,mt,Fr]),zr=H.useCallback(()=>{ot([]),_r(new Set),sr(new Map)},[]),bi=H.useCallback(async()=>{ke(!0);try{mt.currentCallId&&ia(De,mt.currentCallId),kr([]),Qn.current=null,Be.current="",We.current=void 0,pt.current=0,we.current=null,en(!1),Lt.current=[],se.current&&(clearTimeout(se.current),se.current=null),t.disconnect(),ht(!1),O?(mt.setShowFeedback(!1),zr(),mt.close()):(mt.setShowFeedback(!0),mt.open())}catch(Te){yt({hasError:!0,message:"Error ending call: "+Te.message})}finally{ke(!1)}},[t,De,mt,ia,O,zr]),Ro=H.useCallback(async(Te,Ee)=>{if(!mt.currentCallId){zr(),mt.close();return}ke(!0);try{await fetch(`${jw(s)}/calling/${mt.currentCallId}/feedback`,{method:"POST",body:JSON.stringify({rating:Te,comment:Ee}),headers:{"Content-Type":"application/json",...Fw(k,b)}}),td("ringg:feedback_status",{status:"submitted",callId:mt.currentCallId,rating:Te})}catch(Xe){console.error("Error submitting feedback:",Xe)}finally{ke(!1),zr(),mt.close()}},[s,b,k,mt,zr]),Ao=H.useCallback(()=>{mt.currentCallId&&td("ringg:feedback_status",{status:"skipped",callId:mt.currentCallId}),zr(),mt.close()},[mt,zr]);H.useEffect(()=>()=>{se.current&&clearTimeout(se.current)},[]);const K=H.useCallback((Te,Ee)=>{var Et;const Xe={name:"Agent",message:"",isSelf:!1,timestamp:Date.now()+Math.random(),componentType:Te.component_type,componentData:Te};ot(rt=>[...rt,Xe]),td("ringg:calendar_booking",{status:"shown",componentId:Te.component_id}),pt.current<=Ee&&(we.current=null,en(!1)),mt.isOpen||(Et=ve.current)==null||Et.play().catch(()=>{}),mt.open()},[mt]),Ne=H.useCallback(()=>{se.current&&(clearTimeout(se.current),se.current=null);const Te=Lt.current;Lt.current=[],Te.forEach(({component:Ee,arrivedAt:Xe})=>K(Ee,Xe))},[K]),tt=H.useCallback(Te=>{const Ee=performance.now();if(Yt.current!=="text"){K(Te,Ee);return}Lt.current.push({component:Te,arrivedAt:Ee}),se.current||(se.current=setTimeout(Ne,Pne))},[K,Ne]),st=H.useCallback(Te=>{_r(Ee=>{const Xe=new Set(Ee);return Xe.add(Te),Xe}),td("ringg:calendar_booking",{status:"confirmed",componentId:Te,message:"Flow completed"})},[]),vn=H.useCallback((Te,Ee)=>{ot(Xe=>{const Et=Xe.find(Qt=>{var qt;return((qt=Qt.componentData)==null?void 0:qt.component_id)===Te}),rt=(Et==null?void 0:Et.timestamp)??Date.now(),Wt={name:"You",isSelf:!0,message:Ee,timestamp:rt+Math.random()*.5},ln=new Set;return[...Xe,Wt].filter(Qt=>!ln.has(Qt.timestamp)&&ln.add(Qt.timestamp)).sort((Qt,qt)=>Qt.timestamp-qt.timestamp)})},[]),Kt=H.useCallback(async(Te,Ee)=>{var aa,oa,cn,La;const Xe=kt.current.get(Te);if(!Xe||!lr)return;const{name:Et,originalConfig:rt}=Xe,Wt="receive_dynamic_data";let ln;if(Et==="calendar"){const Zr=Ee.step_data&&Ee.step_data.slot_id,Vt=rt,xs=(Vt==null?void 0:Vt.slots)||[],Hr=(Vt==null?void 0:Vt.timezone)||"UTC",Jr=xs.find(zi=>zi.id===Zr);ln={id:(Jr==null?void 0:Jr.id)||Zr,datetime:(Jr==null?void 0:Jr.datetime)||((aa=Ee.step_data)==null?void 0:aa.slot_datetime),timezone:Hr,slot_time:(oa=Ee.step_data)==null?void 0:oa.slot_time,slot_date:(cn=Ee.step_data)==null?void 0:cn.slot_date}}else if(Et==="form")ln=Ee.step_data||Ee.all_data;else if(Et==="buttons"){const Zr=Ee.step_data&&Ee.step_data.selected_button;ln=(Array.isArray(rt)?rt:[]).find(Hr=>Hr.id===Zr)||{id:Zr}}else Et==="quick_replay"?ln={text:(La=Ee.step_data)==null?void 0:La.selected_button}:ln=Ee;const Qt=rt==null?void 0:rt.tool_id,qt=JSON.stringify({component_type:`receive_component_${Et}`,component_id:Te,component_data:ln,...Qt&&{tool_id:Qt}});try{await gn.localParticipant.performRpc({destinationIdentity:lr.identity,method:Wt,payload:qt}),kt.current.delete(Te)}catch(Zr){console.error("[RinggWidget] Failed to send receive_dynamic_data:",Zr)}},[lr,gn.localParticipant]),Sn=H.useCallback(async(Te,Ee)=>{if(!lr){console.warn("[DiseaseWidget] Submit blocked — no agent participant connected");return}const Xe=JSON.stringify({component_type:"receive_component_disease_plans",component_id:Te,selections:Ee.selections});try{await gn.localParticipant.performRpc({destinationIdentity:lr.identity,method:"receive_dynamic_data",payload:Xe})}catch(Et){console.error("[DiseaseWidget] Submit RPC failed:",Et)}},[lr,gn.localParticipant]),hn=H.useCallback(Te=>new Promise(Ee=>{if(!lr){console.warn("[DiseaseSearch] Search blocked — no agent participant connected"),Ee([]);return}Qn.current=Ee;const Xe=JSON.stringify({component_type:"receive_component_disease_search",query:Te});gn.localParticipant.performRpc({destinationIdentity:lr.identity,method:"receive_dynamic_data",payload:Xe}).catch(Et=>{console.error("[DiseaseSearch] Search RPC failed:",Et),Qn.current=null,Ee([])})}),[lr,gn.localParticipant]),Pr=H.useCallback(async Te=>{if(Te.tool_type==="WIDGET_TOOL"||Te.tool_type==="DISEASE_ACCEPTANCE_TOOL"){const Xe=`disease_data_${Date.now()}`,Et={name:"Agent",message:"",isSelf:!1,timestamp:Date.now()+Math.random(),componentType:"disease_data",componentData:{component_type:"disease_data",component_id:Xe,label:Te.command}};ot(rt=>[...rt,Et]);return}if(!lr){console.warn("[RinggWidget] No agent participant found, cannot send slash command");return}const Ee=JSON.stringify({component_type:"receive_component_slash_command",command:Te.command.replace(/^\//,"")});try{await gn.localParticipant.performRpc({destinationIdentity:lr.identity,method:"receive_dynamic_data",payload:Ee})}catch(Xe){console.error("[RinggWidget] Failed to send slash command via RPC:",Xe)}},[lr,gn.localParticipant]),ur=H.useMemo(()=>null,[]),cr=H.useCallback(async(Te,Ee,Xe)=>(await fetch(Ee.startsWith("http")?Ee:`${jw(s)}${Ee}`,{method:Te,body:JSON.stringify(Xe),headers:{"Content-Type":"application/json",...Fw(k,b)}})).json(),[s,b,k,wt,ur]),Ci=H.useCallback(async Te=>{try{const Ee=JSON.parse(Te.payload);return Array.isArray(Ee.source_urls)?Be.current=Ee.source_urls.join(", "):Ee.source_url&&(Be.current=Ee.source_url),JSON.stringify({status:"received"})}catch(Ee){throw console.error("Failed to parse send_source_urls payload:",Ee),new Error("Invalid payload for send_source_urls")}},[]),Na=H.useCallback(async Te=>{try{const Ee=JSON.parse(Te.payload);return Ee.component_type&&Ee.component_id&&tt(Ee),JSON.stringify({status:"received"})}catch(Ee){throw console.error("Failed to parse render_component payload:",Ee),new Error("Invalid component payload")}},[tt]),Un=H.useCallback((Te,Ee)=>{const Xe=`${Te}_${Date.now()}`,Et=Ee.component_config??Ee.component_data;if(Te==="calendar"){const rt=Et,Wt=(rt==null?void 0:rt.slots)||[],ln=(rt==null?void 0:rt.timezone)||"UTC";return{component_type:"calendar_booking",component_id:Xe,data:{available_slots:Wt.map(Qt=>({id:Qt.id,datetime:Qt.datetime})),timezone:ln,title:Ee.title||"Select a time slot"}}}if(Te==="form"){const rt=Et,Wt=Qt=>({text:"text",string:"text",number:"number",email:"email",phone_number:"tel",single_select:"select",multiselect:"multiselect",checkbox:"boolean",date:"date",textarea:"textarea"})[Qt]||"text",ln=((rt==null?void 0:rt.fields)||[]).map(Qt=>({name:Qt.key||Qt.name||"",type:Wt(Qt.type),label:Qt.description||Qt.label||Qt.key||Qt.name||"",required:Qt.required,placeholder:Qt.placeholder,options:Qt.options}));return{component_type:"form",component_id:Xe,data:{title:(rt==null?void 0:rt.title)||"Form",description:rt==null?void 0:rt.description,fields:ln,submit_label:(rt==null?void 0:rt.cta)||(rt==null?void 0:rt.submit_label)||"Submit"}}}if(Te==="buttons")return{component_type:"buttons",component_id:Xe,data:{title:Ee.title,buttons:Array.isArray(Et)?Et:[]}};if(Te==="quick_replay"){const rt=Et,Wt=Array.isArray(rt==null?void 0:rt.options)?rt.options.filter(ln=>typeof ln=="string"&&ln.trim().length>0):[];return{component_type:"buttons",component_id:Xe,data:{presentation:"free",completionDisplay:"selected_item",buttons:Wt.map(ln=>({id:ln,label:ln,action:{type:"trigger_component"}}))}}}return Te==="confirmation"?{component_type:"confirmation",component_id:Xe,data:{title:Ee.title||"Confirmed",message:Ee.message||"",icon:Ee.icon||"success",details:Ee.details}}:Ee.component_type&&Ee.component_id?Ee:null},[]),vr=((Bl=a.eventLogs)==null?void 0:Bl.enabled)===!0,rn=((Ai=a.eventLogs)==null?void 0:Ai.showIds)===!0,ro=H.useCallback(Te=>{if(!vr)return;const Ee=rn&&Te.id?Te.meta?`${Te.id} · ${Te.meta}`:Te.id:Te.meta,Xe={name:"system",message:Te.label,isSelf:!1,timestamp:Date.now()+Math.random(),kind:"system",systemMeta:Ee,systemLevel:Te.level};ot(Et=>[...Et,Xe])},[vr,rn]),Po=H.useCallback(async Te=>{try{const Ee=JSON.parse(Te.payload),Xe=Ee.component_type;if(!Xe)return console.warn("[RinggWidget] No component_type in send_dynamic_data payload"),JSON.stringify({status:"error",message:"No component_type provided"});if(Xe==="execute_dom_action"){const Wt=Ee.component_config??Ee.component_data??{},ln={id:Wt.id??Wt.action_id??"",kind:Wt.kind??"trigger_event",event_name:Wt.event_name,default_payload:Wt.default_payload??Wt.detail};return Rne(ln,ro),JSON.stringify({status:"received"})}const Et=Xe.replace("render_component_","");if(Et==="disease_search_results"){const Wt=Ee.results??[];return Qn.current?(Qn.current(Wt),Qn.current=null):console.warn("[DiseaseSearch] No pending resolver — results dropped (search may have timed out or was cancelled)"),JSON.stringify({status:"received"})}const rt=Un(Et,Ee);return rt?(kt.current.set(rt.component_id,{name:Et,originalConfig:Ee.component_config??Ee.component_data}),tt(rt),JSON.stringify({status:"received",component_id:rt.component_id})):(console.warn("[RinggWidget] Unknown component type:",Et),JSON.stringify({status:"error",message:`Unknown component type: ${Et}`}))}catch(Ee){throw console.error("[RinggWidget] Failed to parse send_dynamic_data payload:",Ee),new Error("Invalid send_dynamic_data payload")}},[tt,Un,ro]);H.useEffect(()=>{je.current=tt},[tt]);const nd=H.useRef(mt.open);nd.current=mt.open,H.useEffect(()=>{},[]),H.useEffect(()=>{var Et,rt;if(!t||De!=="audio"||!wt)return;const Te=new Map(Ar);Rn.audioTrack&&An.segments.forEach(Wt=>{const ln=Te.get(Wt.id),Qt=A_(Wt,ln,Rn.audioTrack.participant);Te.set(Wt.id,Qt)}),ra.segments.forEach(Wt=>{const ln=Te.get(Wt.id),Qt=A_(Wt,ln,gn.localParticipant);Te.set(Wt.id,Qt)});const Ee=Array.from(Te.values()).sort((Wt,ln)=>Wt.timestamp-ln.timestamp),Xe=Be.current&&((Et=Ee[Ee.length-1])==null?void 0:Et.name.includes("Agent"))&&!((rt=Ee[Ee.length-1])!=null&&rt.sourceUrl)&&We.current!==Ee.length-1;if(Xe){We.current=Ee.length,Ee[Ee.length-1]={...Ee[Ee.length-1],sourceUrl:Be.current};const Wt=Ee.filter(Qt=>!Qt.isSelf).length-1,ln=Te.get(An.segments[Wt].id);Te.set(An.segments[Wt].id,A_(An.segments[Wt],{...ln,sourceUrl:Be.current},Rn.audioTrack.participant))}ot(Ee),sr(Te),Xe||(Be.current="")},[De,Mn,An.segments,ra.segments,Rn.audioTrack,gn.localParticipant,wt]),H.useEffect(()=>{if(!t||De!=="text"||!wt)return;const Te=async(Xe,Et)=>{var ln,Qt;const rt=(ln=Et.identity)==null?void 0:ln.includes("agent"),Wt=performance.now();rt&&(we.current===null&&(we.current=performance.now()),en(!0));try{const qt=await Xe.readAll();if(rt&&we.current!==null){const oa=performance.now()-we.current,cn=One-oa;cn>0&&await new Promise(La=>setTimeout(La,cn))}rt&&(mt.isOpen||(Qt=ve.current)==null||Qt.play().catch(()=>{}),mt.open());const aa={message:qt,isSelf:!rt,name:rt?"Agent":"You",timestamp:Date.now()+performance.now()%1,...rt&&Be.current&&{sourceUrl:Be.current}};Be.current&&(Be.current=""),ot(oa=>{const cn=new Set;return[...oa,aa].filter(La=>!cn.has(La.timestamp)&&cn.add(La.timestamp)).sort((La,Zr)=>La.timestamp-Zr.timestamp)}),rt&&(pt.current<=Wt?(we.current=null,en(!1)):we.current=performance.now(),Lt.current.length>0&&setTimeout(Ne,Dne))}catch(qt){rt&&pt.current<=Wt&&(we.current=null,en(!1)),console.error("Error reading text stream",qt)}},Ee=Mn.map(Xe=>{var Wt,ln,Qt,qt;const Et=((Wt=Xe.from)==null?void 0:Wt.identity)===gn.localParticipant.identity,rt=Rn.audioTrack?((ln=Xe.from)==null?void 0:ln.identity)===((Qt=Rn.audioTrack.participant)==null?void 0:Qt.identity):!Et;return{name:((qt=Xe.from)==null?void 0:qt.name)||(rt?"Agent":Et?"You":"Unknown"),isSelf:Et,message:Xe.message,timestamp:Xe.timestamp}});return ot(Xe=>{const Et=new Set;return[...Xe,...Ee].filter(rt=>!Et.has(rt.timestamp)&&Et.add(rt.timestamp)).sort((rt,Wt)=>rt.timestamp-Wt.timestamp)}),t.registerTextStreamHandler("lk.transcription",Te),()=>{t.unregisterTextStreamHandler("lk.transcription")}},[t,De,Mn,mt,gn.localParticipant,Rn.audioTrack,wt,Ne]),H.useEffect(()=>{if(t)return t.registerRpcMethod("send_source_urls",Ci),t.registerRpcMethod("render_component",Na),t.registerRpcMethod("send_dynamic_data",Po),()=>{t.unregisterRpcMethod("send_source_urls"),t.unregisterRpcMethod("render_component"),t.unregisterRpcMethod("send_dynamic_data")}},[t,Ci,Na,Po]),H.useEffect(()=>{if(t)return t.on(Pe.ParticipantDisconnected,bi),t.on(Pe.Disconnected,bi),()=>{t.off(Pe.ParticipantDisconnected,bi),t.off(Pe.Disconnected,bi)}},[bi,t]);const Do=H.useRef(0);return H.useEffect(()=>{const Te=J.current;if(!Te)return;const Ee=ut.length>Do.current;if(Do.current=ut.length,!Ee){Te.scrollTop=Te.scrollHeight;return}const Xe=Te.querySelector('[data-ringg="transcript-list"]'),Et=Array.from((Xe==null?void 0:Xe.children)??[]);let rt=null;for(let aa=Et.length-1;aa>=0;aa--){const oa=Et[aa].getAttribute("data-ringg");if(oa!=="typing-indicator"&&(rt??(rt=Et[aa]),oa==="message")){rt=Et[aa];break}}if(!rt){Te.scrollTop=Te.scrollHeight;return}const Wt=Te.getBoundingClientRect(),Qt=rt.getBoundingClientRect().top-Wt.top+Te.scrollTop,qt=56;Te.scrollTop=Math.max(0,Qt-qt)},[ut,jt]),H.useEffect(()=>(ve.current=new Audio(N),ve.current.preload="auto",()=>{ve.current&&(ve.current.pause(),ve.current.src="",ve.current=null)}),[N]),F.jsxs(BG,{theme:Z,children:[F.jsxs(Bg,{children:[(!Le||!mt.isOpen)&&F.jsx(Fi.button,{"data-ringg":"trigger-button",initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.8,opacity:0},transition:{type:"spring",stiffness:400,damping:25},"aria-label":"Open call widget",onClick:ga,style:{position:le,...ze,...gi(re.primaryColor),color:re.primaryTextColor,...(Vl=v==null?void 0:v.modalTrigger)==null?void 0:Vl.styles},className:"ringg_ai-h-[52px] ringg_ai-w-[52px] !ringg_ai-rounded-2xl ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-shadow ringg_ai-trigger-btn !ringg_ai-z-[9999] hover:ringg_ai-opacity-90 ringg_ai-transition-opacity",children:F.jsx("img",{"data-ringg":"trigger-icon",src:((ju=(Lu=v==null?void 0:v.modalTrigger)==null?void 0:Lu.icon)==null?void 0:ju.url)??"https://assets.ringg.ai/images/icons/widget-phone.svg",alt:"Widget trigger",style:{width:((rs=(Oo=v==null?void 0:v.modalTrigger)==null?void 0:Oo.icon)==null?void 0:rs.size)??24,height:((io=(Vi=v==null?void 0:v.modalTrigger)==null?void 0:Vi.icon)==null?void 0:io.size)??24}})},"trigger-button"),mt.isOpen&&F.jsxs(Fi.div,{"data-ringg":"widget-root",ref:ue,initial:{y:24,scale:.96,opacity:0,x:Ke==="bottom-center"?"-50%":0},animate:{y:0,scale:1,opacity:1,x:Ke==="bottom-center"?"-50%":0},exit:{y:24,scale:.96,opacity:0,x:Ke==="bottom-center"?"-50%":0},transition:{type:"spring",stiffness:380,damping:30},className:Nn("ringg_ai-relative ringg_ai-border ringg_ai-overflow-hidden !ringg_ai-z-[9999] ringg_ai-w-[95vw] md:ringg_ai-w-[380px] ringg_ai-h-[25.75rem]"),style:{position:"fixed",bottom:"2%",transformOrigin:Ke==="bottom-center"?"bottom center":Ke==="bottom-left"?"bottom left":"bottom right",boxShadow:"0px 54px 33px 0px rgba(0,0,0,0.01), 0px 24px 24px 0px rgba(0,0,0,0.02), 0px 6px 13px 0px rgba(0,0,0,0.02)",..._ne(Ke),...wt?me:{},maxWidth:"96dvw",maxHeight:"96dvh",backgroundColor:re.backgroundColor,borderColor:re.borderColor,borderRadius:jC(P==null?void 0:P.borderRadius)??re.borderRadius,fontFamily:re.fontFamily,"--widget-primary":On(re.primaryColor),"--widget-primary-text":re.primaryTextColor,"--widget-bg":re.backgroundColor,"--widget-surface":re.surfaceColor,"--widget-text":re.textColor,"--widget-muted":re.mutedTextColor,"--widget-border":re.borderColor,"--widget-button-radius":te},children:[(wt||mt.showFeedback)&&F.jsx(Fv,{"data-ringg":"minimize-button",size:"icon",variant:"ghost","aria-label":"Minimize widget",onClick:mt.minimize,className:"ringg_ai-absolute !ringg_ai-z-[9999] ringg_ai-top-2.5 ringg_ai-right-[42px] !ringg_ai-h-7 !ringg_ai-w-7 !ringg_ai-rounded-full ringg_ai-text-gray-500 hover:ringg_ai-text-gray-700",children:F.jsx(wG,{size:16})}),F.jsx(Fv,{"data-ringg":"close-button",size:"icon",variant:"ghost","aria-label":wt?"End call":"Close widget",onClick:()=>wt?ht(!0):mt.showFeedback?Ao():mt.minimize(),className:"ringg_ai-absolute !ringg_ai-z-[9999] ringg_ai-top-2.5 ringg_ai-right-2.5 !ringg_ai-h-7 !ringg_ai-w-7 !ringg_ai-rounded-full ringg_ai-text-gray-500 hover:ringg_ai-text-gray-700",children:F.jsx(t3,{size:16})}),F.jsx(lK,{open:q,onOpenChange:ht,containerRef:ue,children:F.jsxs(uK,{"data-ringg":"end-call-dialog",children:[F.jsxs(cK,{"data-ringg":"end-call-dialog-header",children:[F.jsxs(dK,{"data-ringg":"end-call-dialog-title",children:["Are you sure you want to end ",De==="text"?"chat":"call","?"]}),F.jsx(fK,{"data-ringg":"end-call-dialog-description",children:"Your current conversation will be closed and cannot be accessed later."})]}),F.jsxs(hK,{"data-ringg":"end-call-dialog-footer",children:[F.jsx(Fv,{"data-ringg":"end-call-cancel",variant:"outline",size:"sm",onClick:()=>ht(!1),style:{borderRadius:te,borderColor:re.borderColor,backgroundColor:re.surfaceColor,color:re.textColor},children:"Cancel"}),F.jsxs(Fv,{"data-ringg":"end-call-confirm",size:"sm",onClick:bi,style:{borderRadius:te,...gi(re.primaryColor),color:re.primaryTextColor},children:["End ",De==="text"?"Chat":"Call"]})]})]})}),mt.showFeedback?F.jsx($te,{callMode:De,isSubmitting:ee,feedbackScreenConfig:L,messages:ut,title:l,logoUrl:U,logoStyles:I,onSubmit:Ro,onSkip:Ao}):F.jsx("div",{"data-ringg":"widget-body",className:"ringg_ai-flex ringg_ai-h-full ringg_ai-flex-col",children:F.jsxs("div",{"data-ringg":"widget-panel",className:Nn("ringg_ai-relative ringg_ai-h-full ringg_ai-mb-2 ringg_ai-flex ringg_ai-flex-col",wt?"ringg_ai-p-2 ringg_ai-gap-2.5":"ringg_ai-p-5 ringg_ai-gap-3"),children:[F.jsx(p4,{isCalling:wt,isLoading:ee,title:l,description:c,logoUrl:U,logoStyles:I}),ma&&F.jsx("div",{"data-ringg":"voice-animation-wrapper",className:Nn("ringg_ai-flex ringg_ai-w-full ringg_ai-items-stretch ringg_ai-justify-center",es&&ut.length>0?"ringg_ai-mt-14 ringg_ai-h-14 ringg_ai-flex-shrink-0":"ringg_ai-mt-14 ringg_ai-flex-1 ringg_ai-min-h-0"),children:F.jsx(gK,{className:"ringg_ai-flex-1",localTrack:tl,remoteTrack:ts})}),wt&&!ma&&(ut.length===0&&!jt||!es)&&F.jsx("div",{"data-ringg":"body-spacer",className:"ringg_ai-mt-14 ringg_ai-h-full"}),(ut.length>0||jt)&&wt&&es&&F.jsx("div",{"data-ringg":"transcript","data-scrollable":"true",ref:J,className:"ringg_ai-h-full ringg_ai-overflow-y-auto ringg_ai-flex ringg_ai-flex-col",children:F.jsxs("div",{"data-ringg":"transcript-list",className:Nn("ringg_ai-mt-auto md:ringg_ai-mt-0 ringg_ai-flex ringg_ai-flex-col ringg_ai-gap-3",!ma&&"ringg_ai-pt-12",!Ri&&"ringg_ai-pb-14"),children:[ut.sort((Te,Ee)=>Te.timestamp-Ee.timestamp).map((Te,Ee)=>{var ln;if(Te.kind==="system")return F.jsx(Ane,{label:Te.message,meta:Te.systemMeta,level:Te.systemLevel},`sys_${Te.timestamp}_${Ee}`);const Xe=ut[Ee-1],Et=ut[Ee+1],rt=k5(Te)&&x5(Xe);return x5(Te)&&k5(Et)?null:rt?((ln=Te.componentData)==null?void 0:ln.component_type)==="buttons"&&Te.componentData.data.completionDisplay==="selected_item"&&Kn.has(Te.componentData.component_id)?F.jsx(NC,{itemIndex:Ee,message:Xe},`message_with_buttons_${Te.componentData.component_id}_${Ee}`):F.jsxs(H.Fragment,{children:[F.jsx(NC,{itemIndex:Ee,message:Xe}),F.jsx("div",{"data-ringg":"attached-buttons",className:"ringg_ai-w-full",children:F.jsx(C5,{initialComponent:Te.componentData,onApiCall:cr,onComplete:()=>st(Te.componentData.component_id),onSendResponse:Kt,onSelectionDisplayed:vn,quickReplyAlign:Ri?"center":"end"})})]},`message_with_buttons_${Te.componentData.component_id}_${Ee}`):Te.componentType==="disease_data"&&Te.componentData?F.jsx(gne,{label:Te.componentData.label,onSearch:hn,onSubmit:Qt=>Sn(Te.componentData.component_id,Qt)},`widget_${Te.componentData.component_id}_${Ee}`):Te.componentType&&Te.componentData?Te.componentData.component_type==="buttons"&&Te.componentData.data.completionDisplay==="selected_item"&&Kn.has(Te.componentData.component_id)?null:F.jsx(C5,{initialComponent:Te.componentData,onApiCall:cr,onComplete:()=>st(Te.componentData.component_id),onSendResponse:Kt,onSelectionDisplayed:vn,quickReplyAlign:Ri?"center":"end"},`flow_${Te.componentData.component_id}_${Ee}`):F.jsx(NC,{itemIndex:Ee,message:Te},`${Te.timestamp}__${Ee}`)}),jt&&F.jsx(lne,{})]})}),wt&&De==="text"?F.jsxs("div",{"data-ringg":"controls-bar",className:"ringg_ai-absolute ringg_ai-z-10 ringg_ai-bottom-0 ringg_ai-left-0 ringg_ai-w-full ringg_ai-p-2",children:[At.hasError&&F.jsx("div",{"data-ringg":"error-message",className:"ringg_ai-text-center ringg_ai-text-sm ringg_ai-text-red-500 ringg_ai-mb-2",children:At.message}),F.jsx(f4,{buttonConfig:v,callMode:De,isCalling:wt,enabledSlashCommands:ks,onSlashCommand:Pr,onUserMessage:qe,onCallEnd:bi})]}):F.jsxs(F.Fragment,{children:[F.jsx(f4,{buttonConfig:v,callMode:De,isCalling:wt,enabledSlashCommands:ks,onSlashCommand:Pr,onUserMessage:qe,onCallEnd:bi}),At.hasError&&F.jsx("div",{"data-ringg":"error-message",className:"ringg_ai-text-center ringg_ai-text-sm ringg_ai-text-red-500 -ringg_ai-mt-3 -ringg_ai-mb-2",children:At.message})]}),!wt&&ee&&F.jsxs("div",{"data-ringg":"connecting-status",className:"ringg_ai-flex ringg_ai-flex-col",children:[F.jsx("p",{"data-ringg":"connecting-label",className:"ringg_ai-text-[13px] ringg_ai-text-center",style:{color:re.mutedTextColor},children:"Connecting..."}),F.jsx(sne,{ariaLabel:De==="text"?"Starting chat":"Connecting"})]}),!ee&&Mt==="disconnected"&&(!R||At.hasError)&&(w?F.jsx(P_,{callMode:De,buttonConfig:v,isCalling:wt,isLoading:ee,onCallTrigger:Fr}):F.jsxs("div",{"data-ringg":"start-actions",className:"ringg_ai-flex ringg_ai-w-full ringg_ai-items-center ringg_ai-gap-2 ringg_ai-px-6",children:[F.jsx(P_,{dual:!0,callMode:"text",buttonConfig:v,isCalling:wt,isLoading:ee,onCallTrigger:Fr}),F.jsx(P_,{dual:!0,callMode:"audio",buttonConfig:v,isCalling:wt,isLoading:ee,onCallTrigger:Fr})]})),!wt&&F.jsx("p",{"data-ringg":"legal-disclaimer",className:"ringg_ai-text-[11px] ringg_ai-leading-[1.7] ringg_ai-text-center",style:{color:re.mutedTextColor},children:B?Ene(B.text,B.links):F.jsxs(F.Fragment,{children:["By continuing, you agree to our",F.jsx("br",{}),F.jsx("a",{"data-ringg":"legal-link-privacy",target:"_blank",rel:"noopener noreferrer",className:"ringg_ai-underline ringg_ai-underline-offset-2",style:{color:On(re.primaryColor)},href:"https://www.ringg.ai/privacy",children:"Privacy Policy"})," and ",F.jsx("a",{"data-ringg":"legal-link-terms",target:"_blank",rel:"noopener noreferrer",className:"ringg_ai-underline ringg_ai-underline-offset-2",style:{color:On(re.primaryColor)},href:"https://www.ringg.ai/terms",children:"T&C"}),"."]})})]})})]},"chat-widget")]}),F.jsx(j7,{}),!1]})},Ine=({config:t})=>{const[e]=H.useState(()=>new np({dynacast:!0,adaptiveStream:!0}));return F.jsx(l1.Provider,{value:e,children:F.jsx(Mne,{config:t,room:e})})};function Nne(){if(typeof document>"u")return;const t=document.currentScript;if(t!=null&&t.src)return t.src;const e=document.getElementsByTagName("script");for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(r.src&&/dv-agent\.(es|umd)\.js/.test(r.src))return r.src}}const T5="ringg_ai_brand_font";if(typeof document<"u"&&!document.getElementById(T5)){const t=Nne();if(t){const e=new URL("./Automat-Grotesk-Variable-Roman.woff2",t).href,n=document.createElement("style");n.id=T5,n.textContent=`@font-face{font-family:"Automat Grotesk";src:url("${e}") format("woff2");font-weight:100 900;font-style:normal;font-display:swap;}`,document.head.appendChild(n)}}{const t="ringg_ai_container";(function(e,n){function r(a){let s=n.getElementById(t);s||(s=n.createElement("div"),s.id=t,n.body.appendChild(s)),kg.createRoot(s).render(F.jsx(ir.StrictMode,{children:F.jsx(Ine,{config:a})}))}e.loadAgent=r})(window,document)}});
|
|
455
|
+
`))}function h(x,w,R,O){const P=R.enter("tableCell"),U=R.enter("phrasing"),I=R.containerPhrasing(x,{...O,before:s,after:s});return U(),P(),I}function p(x,w){return See(x,{align:w,alignDelimiters:r,padding:n,stringLength:a})}function v(x,w,R){const O=x.children;let P=-1;const U=[],I=w.enter("table");for(;++P<O.length;)U[P]=b(O[P],w,R);return I(),U}function b(x,w,R){const O=x.children;let P=-1;const U=[],I=w.enter("tableRow");for(;++P<O.length;)U[P]=h(O[P],x,w,R);return I(),U}function k(x,w,R){let O=i5.inlineCode(x,w,R);return R.stack.includes("tableCell")&&(O=O.replace(/\|/g,"\\$&")),O}}function lte(){return{exit:{taskListCheckValueChecked:o5,taskListCheckValueUnchecked:o5,paragraph:cte}}}function ute(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:dte}}}function o5(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function cte(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 s=-1,l;for(;++s<a.length;){const c=a[s];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 dte(t,e,n,r){const a=t.children[0],s=typeof t.checked=="boolean"&&a&&a.type==="paragraph",l="["+(t.checked?"x":" ")+"] ",c=n.createTracker(r);s&&c.move(l);let h=i5.listItem(t,e,n,{...r,...c.current()});return s&&(h=h.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,p)),h;function p(v){return v+l}}function fte(){return[HX(),tee(),mee(),tte(),lte()]}function hte(t){return{extensions:[WX(),nee(),gee(),ste(t),ute()]}}const pte={tokenize:Cte,partial:!0},s5={tokenize:Ste,partial:!0},l5={tokenize:kte,partial:!0},u5={tokenize:xte,partial:!0},mte={tokenize:Tte,partial:!0},c5={name:"wwwAutolink",tokenize:yte,previous:f5},d5={name:"protocolAutolink",tokenize:bte,previous:h5},Nu={name:"emailAutolink",tokenize:vte,previous:p5},Fl={};function gte(){return{text:Fl}}let Rf=48;for(;Rf<123;)Fl[Rf]=Nu,Rf++,Rf===58?Rf=65:Rf===91&&(Rf=97);Fl[43]=Nu,Fl[45]=Nu,Fl[46]=Nu,Fl[95]=Nu,Fl[72]=[Nu,d5],Fl[104]=[Nu,d5],Fl[87]=[Nu,c5],Fl[119]=[Nu,c5];function vte(t,e,n){const r=this;let a,s;return l;function l(b){return!Iw(b)||!p5.call(r,r.previous)||Nw(r.events)?n(b):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),c(b))}function c(b){return Iw(b)?(t.consume(b),c):b===64?(t.consume(b),h):n(b)}function h(b){return b===46?t.check(mte,v,p)(b):b===45||b===95||Ia(b)?(s=!0,t.consume(b),h):v(b)}function p(b){return t.consume(b),a=!0,h}function v(b){return s&&a&&to(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(b)):n(b)}}function yte(t,e,n){const r=this;return a;function a(l){return l!==87&&l!==119||!f5.call(r,r.previous)||Nw(r.events)?n(l):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(pte,t.attempt(s5,t.attempt(l5,s),n),n)(l))}function s(l){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(l)}}function bte(t,e,n){const r=this;let a="",s=!1;return l;function l(b){return(b===72||b===104)&&h5.call(r,r.previous)&&!Nw(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),a+=String.fromCodePoint(b),t.consume(b),c):n(b)}function c(b){if(to(b)&&a.length<5)return a+=String.fromCodePoint(b),t.consume(b),c;if(b===58){const k=a.toLowerCase();if(k==="http"||k==="https")return t.consume(b),h}return n(b)}function h(b){return b===47?(t.consume(b),s?p:(s=!0,h)):n(b)}function p(b){return b===null||bC(b)||Tr(b)||Ef(b)||CC(b)?n(b):t.attempt(s5,t.attempt(l5,v),n)(b)}function v(b){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(b)}}function Cte(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),s):n(l)}function s(l){return l===null?n(l):e(l)}}function Ste(t,e,n){let r,a,s;return l;function l(p){return p===46||p===95?t.check(u5,h,c)(p):p===null||Tr(p)||Ef(p)||p!==45&&CC(p)?h(p):(s=!0,t.consume(p),l)}function c(p){return p===95?r=!0:(a=r,r=void 0),t.consume(p),l}function h(p){return a||r||!s?n(p):e(p)}}function kte(t,e){let n=0,r=0;return a;function a(l){return l===40?(n++,t.consume(l),a):l===41&&r<n?s(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(u5,e,s)(l):l===null||Tr(l)||Ef(l)?e(l):(t.consume(l),a)}function s(l){return l===41&&r++,t.consume(l),a}}function xte(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),s):c===93?(t.consume(c),a):c===60||c===null||Tr(c)||Ef(c)?e(c):n(c)}function a(c){return c===null||c===40||c===91||Tr(c)||Ef(c)?e(c):r(c)}function s(c){return to(c)?l(c):n(c)}function l(c){return c===59?(t.consume(c),r):to(c)?(t.consume(c),l):n(c)}}function Tte(t,e,n){return r;function r(s){return t.consume(s),a}function a(s){return Ia(s)?n(s):e(s)}}function f5(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Tr(t)}function h5(t){return!to(t)}function p5(t){return!(t===47||Iw(t))}function Iw(t){return t===43||t===45||t===46||t===95||Ia(t)}function Nw(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 _te={tokenize:Mte,partial:!0};function wte(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Pte,continuation:{tokenize:Dte},exit:Ote}},text:{91:{name:"gfmFootnoteCall",tokenize:Ate},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Ete,resolveTo:Rte}}}}function Ete(t,e,n){const r=this;let a=r.events.length;const s=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 p=el(r.sliceSerialize({start:l.end,end:r.now()}));return p.codePointAt(0)!==94||!s.includes(p.slice(1))?n(h):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),e(h))}}function Rte(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 s={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},t[t.length-1][1].start)},l={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},c=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",a,e],["exit",a,e],["enter",s,e],["enter",l,e],["exit",l,e],["exit",s,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...c),t}function Ate(t,e,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=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",p)}function p(b){if(s>999||b===93&&!l||b===null||b===91||Tr(b))return n(b);if(b===93){t.exit("chunkString");const k=t.exit("gfmFootnoteCallString");return a.includes(el(r.sliceSerialize(k)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(b),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(b)}return Tr(b)||(l=!0),s++,t.consume(b),b===92?v:p}function v(b){return b===91||b===92||b===93?(t.consume(b),s++,p):p(b)}}function Pte(t,e,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,l=0,c;return h;function h(w){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(w),t.exit("gfmFootnoteDefinitionLabelMarker"),p}function p(w){return w===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(w),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",v):n(w)}function v(w){if(l>999||w===93&&!c||w===null||w===91||Tr(w))return n(w);if(w===93){t.exit("chunkString");const R=t.exit("gfmFootnoteDefinitionLabelString");return s=el(r.sliceSerialize(R)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(w),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),k}return Tr(w)||(c=!0),l++,t.consume(w),w===92?b:v}function b(w){return w===91||w===92||w===93?(t.consume(w),l++,v):v(w)}function k(w){return w===58?(t.enter("definitionMarker"),t.consume(w),t.exit("definitionMarker"),a.includes(s)||a.push(s),Wn(t,x,"gfmFootnoteDefinitionWhitespace")):n(w)}function x(w){return e(w)}}function Dte(t,e,n){return t.check(Dv,e,t.attempt(_te,e,n))}function Ote(t){t.exit("gfmFootnoteDefinition")}function Mte(t,e,n){const r=this;return Wn(t,a,"gfmFootnoteDefinitionIndent",5);function a(s){const l=r.events[r.events.length-1];return l&&l[1].type==="gfmFootnoteDefinitionIndent"&&l[2].sliceSerialize(l[1],!0).length===4?e(s):n(s)}}function Ite(t){let n=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:s,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 p=h;for(;p--;)if(l[p][0]==="exit"&&l[p][1].type==="strikethroughSequenceTemporary"&&l[p][1]._open&&l[h][1].end.offset-l[h][1].start.offset===l[p][1].end.offset-l[p][1].start.offset){l[h][1].type="strikethroughSequence",l[p][1].type="strikethroughSequence";const v={type:"strikethrough",start:Object.assign({},l[p][1].start),end:Object.assign({},l[h][1].end)},b={type:"strikethroughText",start:Object.assign({},l[p][1].end),end:Object.assign({},l[h][1].start)},k=[["enter",v,c],["enter",l[p][1],c],["exit",l[p][1],c],["enter",b,c]],x=c.parser.constructs.insideSpan.null;x&&Xo(k,k.length,0,SC(x,l.slice(p+1,h),c)),Xo(k,k.length,0,[["exit",b,c],["enter",l[h][1],c],["exit",l[h][1],c],["exit",v,c]]),Xo(l,p-1,h-p+3,k),h=p+k.length-2;break}}for(h=-1;++h<l.length;)l[h][1].type==="strikethroughSequenceTemporary"&&(l[h][1].type="data");return l}function s(l,c,h){const p=this.previous,v=this.events;let b=0;return k;function k(w){return p===126&&v[v.length-1][1].type!=="characterEscape"?h(w):(l.enter("strikethroughSequenceTemporary"),x(w))}function x(w){const R=Pp(p);if(w===126)return b>1?h(w):(l.consume(w),b++,x);if(b<2&&!n)return h(w);const O=l.exit("strikethroughSequenceTemporary"),P=Pp(w);return O._open=!P||P===2&&!!R,O._close=!R||R===2&&!!P,c(w)}}}class Nte{constructor(){this.map=[]}add(e,n,r){Lte(this,e,n,r)}consume(e){if(this.map.sort(function(s,l){return s[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 Lte(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 jte(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 s=r.length-1;r[s]=r[s]==="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 Fte(){return{flow:{null:{name:"table",tokenize:Ute,resolveAll:Bte}}}}function Ute(t,e,n){const r=this;let a=0,s=0,l;return c;function c(G){let re=r.events.length-1;for(;re>-1;){const he=r.events[re][1].type;if(he==="lineEnding"||he==="linePrefix")re--;else break}const te=re>-1?r.events[re][1].type:null,le=te==="tableHead"||te==="tableRow"?N:h;return le===N&&r.parser.lazy[r.now().line]?n(G):le(G)}function h(G){return t.enter("tableHead"),t.enter("tableRow"),p(G)}function p(G){return G===124||(l=!0,s+=1),v(G)}function v(G){return G===null?n(G):Gt(G)?s>1?(s=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(G),t.exit("lineEnding"),x):n(G):Ln(G)?Wn(t,v,"whitespace")(G):(s+=1,l&&(l=!1,a+=1),G===124?(t.enter("tableCellDivider"),t.consume(G),t.exit("tableCellDivider"),l=!0,v):(t.enter("data"),b(G)))}function b(G){return G===null||G===124||Tr(G)?(t.exit("data"),v(G)):(t.consume(G),G===92?k:b)}function k(G){return G===92||G===124?(t.consume(G),b):b(G)}function x(G){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(G):(t.enter("tableDelimiterRow"),l=!1,Ln(G)?Wn(t,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(G):w(G))}function w(G){return G===45||G===58?O(G):G===124?(l=!0,t.enter("tableCellDivider"),t.consume(G),t.exit("tableCellDivider"),R):L(G)}function R(G){return Ln(G)?Wn(t,O,"whitespace")(G):O(G)}function O(G){return G===58?(s+=1,l=!0,t.enter("tableDelimiterMarker"),t.consume(G),t.exit("tableDelimiterMarker"),P):G===45?(s+=1,P(G)):G===null||Gt(G)?B(G):L(G)}function P(G){return G===45?(t.enter("tableDelimiterFiller"),U(G)):L(G)}function U(G){return G===45?(t.consume(G),U):G===58?(l=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(G),t.exit("tableDelimiterMarker"),I):(t.exit("tableDelimiterFiller"),I(G))}function I(G){return Ln(G)?Wn(t,B,"whitespace")(G):B(G)}function B(G){return G===124?w(G):G===null||Gt(G)?!l||a!==s?L(G):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(G)):L(G)}function L(G){return n(G)}function N(G){return t.enter("tableRow"),Q(G)}function Q(G){return G===124?(t.enter("tableCellDivider"),t.consume(G),t.exit("tableCellDivider"),Q):G===null||Gt(G)?(t.exit("tableRow"),e(G)):Ln(G)?Wn(t,Q,"whitespace")(G):(t.enter("data"),Z(G))}function Z(G){return G===null||G===124||Tr(G)?(t.exit("data"),Q(G)):(t.consume(G),G===92?Se:Z)}function Se(G){return G===92||G===124?(t.consume(G),Z):Z(G)}}function Bte(t,e){let n=-1,r=!0,a=0,s=[0,0,0,0],l=[0,0,0,0],c=!1,h=0,p,v,b;const k=new Nte;for(;++n<t.length;){const x=t[n],w=x[1];x[0]==="enter"?w.type==="tableHead"?(c=!1,h!==0&&(m5(k,e,h,p,v),v=void 0,h=0),p={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},k.add(n,0,[["enter",p,e]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(r=!0,b=void 0,s=[0,0,0,0],l=[0,n+1,0,0],c&&(c=!1,v={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},k.add(n,0,[["enter",v,e]])),a=w.type==="tableDelimiterRow"?2:v?3:1):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(r=!1,l[2]===0&&(s[1]!==0&&(l[0]=l[1],b=IC(k,e,s,a,void 0,b),s=[0,0,0,0]),l[2]=n)):w.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(l[0]=l[1],b=IC(k,e,s,a,void 0,b)),s=l,l=[s[1],n,0,0])):w.type==="tableHead"?(c=!0,h=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(h=n,s[1]!==0?(l[0]=l[1],b=IC(k,e,s,a,n,b)):l[1]!==0&&(b=IC(k,e,l,a,n,b)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(l[3]=n)}for(h!==0&&m5(k,e,h,p,v),k.consume(e.events),n=-1;++n<e.events.length;){const x=e.events[n];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=jte(e.events,n))}return t}function IC(t,e,n,r,a,s){const l=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(s.end=Object.assign({},Op(e.events,n[0])),t.add(n[0],0,[["exit",s,e]]));const h=Op(e.events,n[1]);if(s={type:l,start:Object.assign({},h),end:Object.assign({},h)},t.add(n[1],0,[["enter",s,e]]),n[2]!==0){const p=Op(e.events,n[2]),v=Op(e.events,n[3]),b={type:c,start:Object.assign({},p),end:Object.assign({},v)};if(t.add(n[2],0,[["enter",b,e]]),r!==2){const k=e.events[n[2]],x=e.events[n[3]];if(k[1].end=Object.assign({},x[1].end),k[1].type="chunkText",k[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,R=n[3]-n[2]-1;t.add(w,R,[])}}t.add(n[3]+1,0,[["exit",b,e]])}return a!==void 0&&(s.end=Object.assign({},Op(e.events,a)),t.add(a,0,[["exit",s,e]]),s=void 0),s}function m5(t,e,n,r,a){const s=[],l=Op(e.events,n);a&&(a.end=Object.assign({},l),s.push(["exit",a,e])),r.end=Object.assign({},l),s.push(["exit",r,e]),t.add(n+1,0,s)}function Op(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const Vte={name:"tasklistCheck",tokenize:Hte};function zte(){return{text:{91:Vte}}}function Hte(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"),s)}function s(h){return Tr(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 Gt(h)?e(h):Ln(h)?t.check({tokenize:Wte},e,n)(h):n(h)}}function Wte(t,e,n){return Wn(t,r,"whitespace");function r(a){return a===null?n(a):e(a)}}function qte(t){return q4([gte(),wte(),Ite(t),Fte(),zte()])}const Gte={};function Yte(t){const e=this,n=t||Gte,r=e.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),l=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(qte(n)),s.push(fte()),l.push(hte(n))}const NC=({itemIndex:t,message:e,children:n,hideMessageContent:r=!1})=>{const a=Ja(),s=!e.isSelf,l=a.textColor,c=!r&&!!e.message.trim();return F.jsx("div",{"data-ringg":"message","data-ringg-role":s?"agent":"user",className:Nn("ringg_ai-flex ringg_ai-flex-col ringg_ai-items-start ringg_ai-gap-1 ringg_ai-justify-start",s?"ringg_ai-flex-row":"ringg_ai-flex-row-reverse"),children:F.jsx("div",{"data-ringg":"message-bubble",className:Nn("ringg_ai-flex ringg_ai-items-center ringg_ai-justify-start ringg_ai-gap-2 ringg_ai-text-left ringg_ai-leading-[1.3] ringg_ai-max-w-[80%]",s?"ringg_ai-mr-auto":"ringg_ai-ml-auto ringg_ai-pl-3 ringg_ai-pr-2 ringg_ai-py-2 ringg_ai-rounded-xl ringg_ai-rounded-br-[2px]"),style:{...s?{}:{backgroundColor:a.surfaceColor},color:l},children:F.jsxs("div",{"data-ringg":"message-content",className:"ringg_ai-flex ringg_ai-flex-col ringg_ai-gap-2.5 ringg_ai-w-full ringg_ai-overflow-x-auto",children:[c&&F.jsx("div",{"data-ringg":"message-body",className:"ringg_ai-prose ringg_ai-prose-sm ringg_ai-max-w-none [&_p]:ringg_ai-text-sm [&_li]:ringg_ai-text-sm [&_table]:ringg_ai-w-max",style:{"--tw-prose-body":l,"--tw-prose-headings":l,"--tw-prose-bold":l,"--tw-prose-counters":l,"--tw-prose-bullets":l,"--tw-prose-quotes":l,"--tw-prose-code":l,"--tw-prose-th-borders":a.borderColor,"--tw-prose-td-borders":a.borderColor,color:l},children:F.jsx(MX,{remarkPlugins:[Yte],children:e.message})}),(e==null?void 0:e.sourceUrl)&&F.jsxs("a",{"data-ringg":"message-source",href:e.sourceUrl,target:"_blank",rel:"noopener noreferrer",className:"ringg_ai-text-sm ringg_ai-break-all ringg_ai-w-fit ringg_ai-hover:underline",style:{color:On(a.primaryColor)},children:["Source: ",e.sourceUrl]}),n&&F.jsx("div",{"data-ringg":"message-attachment",className:"ringg_ai-w-full",children:n})]})},`${e.name}__${t}`)},`${e.timestamp}__${t}`)},g5=({filled:t,filledColor:e,emptyColor:n,sizeClassName:r="ringg_ai-w-7 ringg_ai-h-7",onClick:a,onMouseEnter:s,onMouseLeave:l})=>F.jsx("button",{"data-ringg":"feedback-star","data-ringg-filled":t?"true":"false",type:"button",onClick:a,onMouseEnter:s,onMouseLeave:l,className:"ringg_ai-p-1 ringg_ai-transition-transform hover:ringg_ai-scale-110",children:F.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:t?e:"none",stroke:t?e:n,strokeWidth:"1.5",className:Nn("ringg_ai-cursor-pointer ringg_ai-transition-colors",r),children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z"})})}),$te=({callMode:t,isSubmitting:e,feedbackScreenConfig:n,messages:r,title:a,logoUrl:s,logoStyles:l,onSubmit:c,onSkip:h})=>{var re,te;const p=Ja(),v=__(p.buttonStyle),[b,k]=H.useState(0),[x,w]=H.useState(0),[R,O]=H.useState(""),P=(r??[]).filter(le=>!le.componentType&&le.kind!=="system"&&!!le.message.trim()),U=P.length>0,I=H.useRef(null);H.useEffect(()=>{var le;(le=I.current)==null||le.scrollTo({top:I.current.scrollHeight})},[]);const B=()=>{b>0&&c(b,R)},L=x||b,N=(n==null?void 0:n.starsCount)??5,Q=Array.from({length:N},(le,he)=>he+1),Z=((re=n==null?void 0:n.starsStyles)==null?void 0:re.filledColor)??On(p.primaryColor),Se=((te=n==null?void 0:n.starsStyles)==null?void 0:te.emptyColor)??"#D1D5DB",G=b===0||e;return U?F.jsxs("div",{"data-ringg":"feedback-screen","data-ringg-variant":"transcript",className:"ringg_ai-relative ringg_ai-h-full ringg_ai-flex ringg_ai-flex-col ringg_ai-p-2 ringg_ai-gap-2",children:[F.jsx(p4,{isCalling:!0,isLoading:!1,title:a??"",description:"",logoUrl:s,logoStyles:l}),F.jsx("div",{ref:I,"data-ringg":"transcript","data-scrollable":"true",className:"ringg_ai-h-full ringg_ai-overflow-y-auto ringg_ai-flex ringg_ai-flex-col",children:F.jsxs("div",{"data-ringg":"transcript-list",className:"ringg_ai-mt-auto ringg_ai-flex ringg_ai-flex-col ringg_ai-gap-3 ringg_ai-pt-12",children:[P.map((le,he)=>F.jsx(NC,{itemIndex:he,message:le},`${le.timestamp}__${he}`)),F.jsxs("div",{"data-ringg":"feedback-footer",className:"ringg_ai-flex ringg_ai-flex-col ringg_ai-gap-2.5 ringg_ai-px-2 ringg_ai-pt-2 ringg_ai-pb-2",children:[F.jsxs("div",{"data-ringg":"conversation-ended",className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-3",children:[F.jsx("span",{"aria-hidden":!0,className:"ringg_ai-h-px ringg_ai-flex-1",style:{backgroundColor:p.borderColor}}),F.jsx("span",{className:"ringg_ai-text-xs",style:{color:p.mutedTextColor},children:"Conversation ended"}),F.jsx("span",{"aria-hidden":!0,className:"ringg_ai-h-px ringg_ai-flex-1",style:{backgroundColor:p.borderColor}})]}),F.jsx("p",{"data-ringg":"feedback-prompt",className:"ringg_ai-text-[13px] ringg_ai-text-center",style:{color:p.mutedTextColor},children:(n==null?void 0:n.title)??"Please rate your experience"}),F.jsx("div",{"data-ringg":"feedback-stars",className:"ringg_ai-flex ringg_ai-justify-center ringg_ai-gap-0.5 -ringg_ai-mt-1",children:Q.map(le=>F.jsx(g5,{filled:le<=L,filledColor:Z,emptyColor:Se,sizeClassName:"ringg_ai-w-6 ringg_ai-h-6",onClick:()=>{e||(k(le),c(le,""))},onMouseEnter:()=>w(le),onMouseLeave:()=>w(0)},le))})]})]})})]}):F.jsxs("div",{"data-ringg":"feedback-screen",className:"ringg_ai-flex ringg_ai-flex-col ringg_ai-items-center ringg_ai-justify-center ringg_ai-p-6 ringg_ai-h-full ringg_ai-gap-4",children:[F.jsxs("div",{"data-ringg":"feedback-header",className:"ringg_ai-text-center",children:[F.jsx("h3",{"data-ringg":"feedback-title",className:"ringg_ai-text-lg ringg_ai-font-medium ringg_ai-mb-1",style:{color:p.textColor},children:(n==null?void 0:n.title)??`How was your ${t==="text"?"chat":"call"}?`}),F.jsx("p",{"data-ringg":"feedback-description",className:"ringg_ai-text-sm",style:{color:p.mutedTextColor},children:(n==null?void 0:n.description)??"Your feedback helps us improve!"})]}),F.jsx("div",{"data-ringg":"feedback-stars",className:"ringg_ai-flex ringg_ai-gap-1 ringg_ai-my-2",children:Q.map(le=>F.jsx(g5,{filled:le<=L,filledColor:Z,emptyColor:Se,onClick:()=>k(le),onMouseEnter:()=>w(le),onMouseLeave:()=>w(0)},le))}),F.jsx("textarea",{"data-ringg":"feedback-comment",value:R,onChange:le=>O(le.target.value),placeholder:(n==null?void 0:n.placeholder)??"We'd love to hear more...",className:Nn("ringg_ai-w-full ringg_ai-min-h-[80px] ringg_ai-p-3 ringg_ai-text-sm ringg_ai-border ringg_ai-resize-none focus:ringg_ai-outline-none focus:ringg_ai-ring-2"),style:{backgroundColor:p.backgroundColor,color:p.textColor,borderColor:p.borderColor,borderRadius:p.borderRadius,"--tw-ring-color":On(p.primaryColor)},maxLength:500}),F.jsxs("div",{"data-ringg":"feedback-actions",className:"ringg_ai-flex ringg_ai-w-full ringg_ai-flex-col ringg_ai-gap-1 ringg_ai-mt-2",children:[F.jsx("button",{"data-ringg":"feedback-submit",onClick:B,disabled:G,className:Nn("ringg_ai-w-full ringg_ai-h-11 ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-text-sm ringg_ai-font-medium ringg_ai-transition-all","hover:ringg_ai-opacity-90 disabled:ringg_ai-cursor-not-allowed"),style:{...G?{backgroundColor:p.surfaceColor,color:p.mutedTextColor}:{...gi(p.primaryColor),color:p.primaryTextColor},borderRadius:v,...n==null?void 0:n.submitBtnStyles},children:(n==null?void 0:n.submitBtnCTA)??"Submit Feedback"}),F.jsx("button",{"data-ringg":"feedback-skip",type:"button",onClick:h,disabled:e,className:"ringg_ai-w-full ringg_ai-py-2 ringg_ai-text-sm ringg_ai-transition-colors hover:ringg_ai-opacity-80",style:{color:p.mutedTextColor},children:"Skip"})]})]})};function Kte(t){const e=new Map;return t.forEach(n=>{const a=new Date(n.datetime).toISOString().split("T")[0];e.has(a)||e.set(a,[]),e.get(a).push(n)}),Array.from(e.entries()).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>{const a=new Date(n);return{date:n,dateLabel:a.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}),slots:r.sort((s,l)=>new Date(s.datetime).getTime()-new Date(l.datetime).getTime())}})}function v5(t,e){return new Date(t).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:e})}function Qte(t,e){return new Date(t).toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",timeZone:e})}function Zte(t,e){const n={};for(const[r,a]of Object.entries(t))if(typeof a=="string"&&a.startsWith("{")&&a.endsWith("}")){const s=a.slice(1,-1);n[r]=e[s]??a}else n[r]=a;return n}function Jte(t){return t.component_type==="calendar_booking"}function Xte(t){return t.component_type==="form"}function jv(t){return t.component_type==="buttons"}function ene(t){return t.component_type==="confirmation"}const tne={primaryColor:"#0a0a0b",primaryTextColor:"#ffffff",backgroundColor:"#ffffff",surfaceColor:"#f3f4f6",textColor:"#0a0a0b",mutedTextColor:"#6b7280",borderColor:"#e5e7eb",errorColor:"#ef4444",successColor:"#16a34a",fontFamily:"inherit",fontSize:"14px",borderRadius:"8px",padding:"12px",buttonStyle:"pill",buttonSize:"md"};function Lw(t){return{...tne,...t}}function LC(t){switch(t){case"pill":return"9999px";case"square":return"4px";case"rounded":default:return"8px"}}const y5=H.createContext(null),Af=()=>{const t=H.useContext(y5);let e;try{e=Ja()}catch{e=null}return t||Lw(e?{primaryColor:e.primaryColor,primaryTextColor:e.primaryTextColor,backgroundColor:e.backgroundColor,surfaceColor:e.surfaceColor,textColor:e.textColor,mutedTextColor:e.mutedTextColor,borderColor:e.borderColor,errorColor:e.errorColor,successColor:e.successColor,buttonStyle:e.buttonStyle}:{})},nne=({payload:t,isProcessing:e,onComplete:n})=>{var x;const r=Af(),a=LC(r.buttonStyle),{data:s}=t,l=H.useMemo(()=>Kte(s.available_slots),[s.available_slots]),[c,h]=H.useState(((x=l[0])==null?void 0:x.date)||""),[p,v]=H.useState(null),b=l.find(w=>w.date===c),k=()=>{p&&n(p.id,p.datetime)};return F.jsxs("div",{children:[F.jsxs("div",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2 ringg_ai-mb-3",children:[F.jsx(k_,{className:"ringg_ai-w-4 ringg_ai-h-4",style:{color:On(r.primaryColor)}}),F.jsx("p",{className:"ringg_ai-text-sm ringg_ai-font-medium",style:{color:r.textColor},children:s.title})]}),F.jsxs("p",{className:"ringg_ai-text-xs ringg_ai-mb-3",style:{color:r.mutedTextColor},children:["Timezone: ",s.timezone]}),F.jsxs("div",{className:"ringg_ai-mb-3",children:[F.jsx("p",{className:"ringg_ai-text-xs ringg_ai-font-semibold ringg_ai-uppercase ringg_ai-tracking-wide ringg_ai-mb-2",style:{color:r.mutedTextColor},children:"Select Date"}),F.jsx("div",{className:"ringg_ai-flex ringg_ai-gap-2 ringg_ai-flex-wrap",children:l.map(w=>F.jsx("button",{onClick:()=>{h(w.date),v(null)},className:Nn("ringg_ai-px-3 ringg_ai-py-2 ringg_ai-text-xs ringg_ai-font-semibold ringg_ai-transition-all ringg_ai-duration-200","hover:ringg_ai-opacity-90 focus:ringg_ai-outline-none focus:ringg_ai-ring-2 focus:ringg_ai-ring-offset-1"),style:{borderRadius:a,...c===w.date?gi(r.primaryColor):{backgroundColor:r.backgroundColor},color:c===w.date?r.primaryTextColor:r.textColor,border:c===w.date?"none":`1px solid ${r.borderColor}`,boxShadow:c===w.date?"0 2px 4px rgba(0,0,0,0.1)":"none","--tw-ring-color":On(r.primaryColor)},children:w.dateLabel},w.date))})]}),F.jsx(Bg,{mode:"wait",children:b&&F.jsxs(Fi.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"ringg_ai-mb-3",children:[F.jsxs("p",{className:"ringg_ai-text-xs ringg_ai-font-semibold ringg_ai-uppercase ringg_ai-tracking-wide ringg_ai-mb-2 ringg_ai-flex ringg_ai-items-center ringg_ai-gap-1",style:{color:r.mutedTextColor},children:[F.jsx(QL,{className:"ringg_ai-w-3 ringg_ai-h-3"}),"Select Time"]}),F.jsx("div",{className:"ringg_ai-grid ringg_ai-grid-cols-3 ringg_ai-gap-1.5",children:b.slots.map(w=>F.jsx("button",{onClick:()=>v(w),className:Nn("ringg_ai-px-2 ringg_ai-py-2 ringg_ai-text-xs ringg_ai-font-medium ringg_ai-transition-all ringg_ai-duration-200","hover:ringg_ai-opacity-90 focus:ringg_ai-outline-none focus:ringg_ai-ring-2 focus:ringg_ai-ring-offset-1"),style:{borderRadius:a,...(p==null?void 0:p.id)===w.id?gi(r.primaryColor):{backgroundColor:r.backgroundColor},color:(p==null?void 0:p.id)===w.id?r.primaryTextColor:r.textColor,border:`1px solid ${(p==null?void 0:p.id)===w.id?On(r.primaryColor):r.borderColor}`,boxShadow:(p==null?void 0:p.id)===w.id?"0 2px 4px rgba(0,0,0,0.1)":"none","--tw-ring-color":On(r.primaryColor)},children:v5(w.datetime,s.timezone)},w.id))})]},c)}),F.jsx("button",{onClick:k,disabled:!p||e,className:Nn("ringg_ai-w-full ringg_ai-h-9 ringg_ai-text-sm ringg_ai-font-semibold ringg_ai-transition-all ringg_ai-duration-200","hover:ringg_ai-opacity-90 focus:ringg_ai-outline-none focus:ringg_ai-ring-2 focus:ringg_ai-ring-offset-2","disabled:ringg_ai-opacity-50 disabled:ringg_ai-cursor-not-allowed disabled:hover:ringg_ai-opacity-50"),style:{borderRadius:a,...!p||e?{backgroundColor:r.borderColor}:gi(r.primaryColor),color:!p||e?r.mutedTextColor:r.primaryTextColor,"--tw-ring-color":On(r.primaryColor)},children:e?F.jsxs("span",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-gap-2",children:[F.jsx(bf,{className:"ringg_ai-w-4 ringg_ai-h-4 ringg_ai-animate-spin"}),"Processing..."]}):"Next"})]})},rne={text:T_,email:XL,tel:EG,number:T_,select:KL,multiselect:TG,textarea:JL,boolean:RG,date:k_},ine=({payload:t,isProcessing:e,onComplete:n})=>{const r=Af(),a=LC(r.buttonStyle),{data:s}=t,[l,c]=H.useState({}),[h,p]=H.useState({}),v=(I,B)=>{if(I.required){if(B==null||B==="")return`${I.label} is required`;if(Array.isArray(B)&&B.length===0)return`${I.label} is required`;if(typeof B=="string"&&!B.trim())return`${I.label} is required`}if(typeof B=="string"&&B){if(I.validation){if(I.validation.minLength&&B.length<I.validation.minLength)return I.validation.message||`${I.label} must be at least ${I.validation.minLength} characters`;if(I.validation.maxLength&&B.length>I.validation.maxLength)return I.validation.message||`${I.label} must be at most ${I.validation.maxLength} characters`;if(I.validation.pattern&&!new RegExp(I.validation.pattern).test(B))return I.validation.message||`${I.label} is invalid`}if(I.type==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(B))return"Please enter a valid email address";if(I.type==="tel"&&!/^[\d\s\-+()]{7,}$/.test(B))return"Please enter a valid phone number"}return null},b=()=>{const I={};let B=!0;return s.fields.forEach(L=>{const N=v(L,l[L.name]);N&&(I[L.name]=N,B=!1)}),p(I),B},k=(I,B)=>{c(L=>({...L,[I]:B})),h[I]&&p(L=>{const N={...L};return delete N[I],N})},x=(I,B,L)=>{c(N=>{const Q=N[I]||[];return L?{...N,[I]:[...Q,B]}:{...N,[I]:Q.filter(Z=>Z!==B)}}),h[I]&&p(N=>{const Q={...N};return delete Q[I],Q})},w=()=>{b()&&n(l)},R=I=>typeof I=="string"?I:I.label,O=I=>typeof I=="string"?I:I.value,P=I=>({backgroundColor:r.backgroundColor,color:r.textColor,borderColor:I?r.errorColor:r.borderColor,borderRadius:r.borderRadius}),U="focus:ringg_ai-outline-none focus:ringg_ai-ring-2";return F.jsxs("div",{children:[F.jsxs("div",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2 ringg_ai-mb-2",children:[F.jsx(JL,{className:"ringg_ai-w-4 ringg_ai-h-4",style:{color:On(r.primaryColor)}}),F.jsx("p",{className:"ringg_ai-text-sm ringg_ai-font-medium",style:{color:r.textColor},children:s.title})]}),s.description&&F.jsx("p",{className:"ringg_ai-text-xs ringg_ai-mb-3",style:{color:r.mutedTextColor},children:s.description}),F.jsx("div",{className:"ringg_ai-space-y-2.5 ringg_ai-mb-3",children:s.fields.map(I=>{const B=rne[I.type]||T_,L=!!h[I.name];return F.jsxs("div",{children:[F.jsxs("label",{className:"ringg_ai-text-xs ringg_ai-font-medium ringg_ai-mb-1 ringg_ai-flex ringg_ai-items-center ringg_ai-gap-1",style:{color:r.mutedTextColor},children:[F.jsx(B,{className:"ringg_ai-w-3 ringg_ai-h-3"}),I.label,I.required&&F.jsx("span",{style:{color:r.errorColor},children:"*"})]}),I.type==="select"&&I.options&&F.jsxs("div",{className:"ringg_ai-relative",children:[F.jsxs("select",{value:l[I.name]||"",onChange:N=>k(I.name,N.target.value),className:Nn("ringg_ai-w-full ringg_ai-px-3 ringg_ai-py-2 ringg_ai-text-xs ringg_ai-border ringg_ai-transition-colors ringg_ai-appearance-none",U),style:{...P(L),"--tw-ring-color":On(r.primaryColor)},children:[F.jsx("option",{value:"",children:I.placeholder||`Select ${I.label.toLowerCase()}`}),I.options.map((N,Q)=>F.jsx("option",{value:O(N),children:R(N)},Q))]}),F.jsx(KL,{className:"ringg_ai-absolute ringg_ai-right-3 ringg_ai-top-1/2 -ringg_ai-translate-y-1/2 ringg_ai-w-3.5 ringg_ai-h-3.5 ringg_ai-pointer-events-none",style:{color:r.mutedTextColor}})]}),I.type==="multiselect"&&I.options&&F.jsx("div",{className:"ringg_ai-border ringg_ai-p-2 ringg_ai-space-y-1.5",style:{...P(L)},children:I.options.map((N,Q)=>{const Z=O(N),Se=(l[I.name]||[]).includes(Z);return F.jsxs("label",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2 ringg_ai-cursor-pointer",children:[F.jsx("input",{type:"checkbox",checked:Se,onChange:G=>x(I.name,Z,G.target.checked),className:"ringg_ai-w-3.5 ringg_ai-h-3.5 ringg_ai-rounded ringg_ai-border",style:{accentColor:On(r.primaryColor)}}),F.jsx("span",{className:"ringg_ai-text-xs",style:{color:r.textColor},children:R(N)})]},Q)})}),I.type==="boolean"&&F.jsxs("label",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2 ringg_ai-cursor-pointer ringg_ai-py-1",children:[F.jsx("input",{type:"checkbox",checked:l[I.name]||!1,onChange:N=>k(I.name,N.target.checked),className:"ringg_ai-w-4 ringg_ai-h-4 ringg_ai-rounded ringg_ai-border",style:{accentColor:On(r.primaryColor)}}),F.jsx("span",{className:"ringg_ai-text-xs",style:{color:r.mutedTextColor},children:I.placeholder||"Yes"})]}),I.type==="textarea"&&F.jsx("textarea",{placeholder:I.placeholder||`Enter ${I.label.toLowerCase()}`,value:l[I.name]||"",onChange:N=>k(I.name,N.target.value),rows:2,className:Nn("ringg_ai-w-full ringg_ai-px-3 ringg_ai-py-2 ringg_ai-text-xs ringg_ai-border ringg_ai-transition-colors ringg_ai-resize-none",U),style:{...P(L),"--tw-ring-color":On(r.primaryColor)}}),I.type==="number"&&F.jsx("input",{type:"number",placeholder:I.placeholder||`Enter ${I.label.toLowerCase()}`,value:l[I.name]??"",onChange:N=>k(I.name,N.target.value?Number(N.target.value):""),className:Nn("ringg_ai-w-full ringg_ai-px-3 ringg_ai-py-2 ringg_ai-text-xs ringg_ai-border ringg_ai-transition-colors",U),style:{...P(L),"--tw-ring-color":On(r.primaryColor)}}),I.type!=="select"&&I.type!=="multiselect"&&I.type!=="boolean"&&I.type!=="textarea"&&I.type!=="number"&&F.jsx("input",{type:I.type,placeholder:I.placeholder||`Enter ${I.label.toLowerCase()}`,value:l[I.name]||"",onChange:N=>k(I.name,N.target.value),className:Nn("ringg_ai-w-full ringg_ai-px-3 ringg_ai-py-2 ringg_ai-text-xs ringg_ai-border ringg_ai-transition-colors",U),style:{...P(L),"--tw-ring-color":On(r.primaryColor)}}),L&&F.jsx("p",{className:"ringg_ai-text-xs ringg_ai-mt-0.5",style:{color:r.errorColor},children:h[I.name]})]},I.name)})}),F.jsx("button",{onClick:w,disabled:e,className:Nn("ringg_ai-w-full ringg_ai-h-9 ringg_ai-text-sm ringg_ai-font-semibold ringg_ai-transition-all ringg_ai-duration-200","hover:ringg_ai-opacity-90 focus:ringg_ai-outline-none focus:ringg_ai-ring-2 focus:ringg_ai-ring-offset-2","disabled:ringg_ai-opacity-50 disabled:ringg_ai-cursor-not-allowed disabled:hover:ringg_ai-opacity-50"),style:{borderRadius:a,...e?{backgroundColor:r.borderColor}:gi(r.primaryColor),color:e?r.mutedTextColor:r.primaryTextColor,"--tw-ring-color":On(r.primaryColor)},children:e?F.jsxs("span",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-gap-2",children:[F.jsx(bf,{className:"ringg_ai-w-4 ringg_ai-h-4 ringg_ai-animate-spin"}),"Submitting..."]}):s.submit_label||"Next"})]})},ane=({payload:t,isProcessing:e,align:n="end",onButtonClick:r})=>{const a=Af(),{data:s}=t,l=s.presentation==="free",[c,h]=H.useState(null),p=async k=>{if(k.action.type==="navigate"){r(k.id,k.action);return}h(k.id);try{await r(k.id,k.action)}finally{h(null)}},v=k=>{switch(k){case"secondary":case"outline":return{backgroundColor:a.surfaceColor,color:a.textColor};case"destructive":return{backgroundColor:a.errorColor,color:a.primaryTextColor};case"primary":default:return{...gi(a.primaryColor),color:a.primaryTextColor}}},b=s.title&&F.jsx("p",{"data-ringg":"buttons-step-title",className:"ringg_ai-text-sm ringg_ai-font-medium ringg_ai-mb-2",style:{color:a.textColor},children:s.title});return l?F.jsxs("div",{"data-ringg":"quick-replies","data-ringg-align":n,className:"ringg_ai-w-full",children:[b,F.jsx("div",{className:Nn("ringg_ai-flex ringg_ai-flex-row ringg_ai-flex-wrap ringg_ai-gap-2",n==="center"?"ringg_ai-justify-center":"ringg_ai-justify-end"),children:s.buttons.map(k=>{const x=c===k.id,w=k.action.type==="navigate",R=x||e;return F.jsxs("button",{"data-ringg":"quick-reply-button","data-ringg-style":k.style??"primary",onClick:()=>p(k),disabled:R,className:Nn("ringg_ai-inline-flex ringg_ai-items-center ringg_ai-gap-1.5 ringg_ai-h-7 ringg_ai-px-3 ringg_ai-text-sm ringg_ai-font-medium ringg_ai-rounded-full ringg_ai-transition-opacity","hover:ringg_ai-opacity-90 focus:ringg_ai-outline-none",R&&"ringg_ai-opacity-50 ringg_ai-cursor-not-allowed hover:ringg_ai-opacity-50"),style:v(k.style),children:[x&&F.jsx(bf,{className:"ringg_ai-w-3 ringg_ai-h-3 ringg_ai-animate-spin"}),k.label,w&&F.jsx(ZL,{className:"ringg_ai-w-3 ringg_ai-h-3"})]},k.id)})})]}):F.jsxs("div",{children:[b,F.jsx("div",{"data-ringg":"options-list",className:"ringg_ai-flex ringg_ai-flex-col",children:s.buttons.map(k=>{const x=c===k.id,w=k.action.type==="navigate",R=x||e,O=k.style==="destructive";return F.jsxs("button",{"data-ringg":"option-row","data-ringg-style":k.style??"primary",onClick:()=>p(k),disabled:R,className:Nn("ringg_ai-flex ringg_ai-w-full ringg_ai-items-center ringg_ai-gap-3 ringg_ai-px-2 ringg_ai-py-2.5 ringg_ai-text-left ringg_ai-text-sm ringg_ai-transition-colors","ringg_ai-border-b last:ringg_ai-border-b-0 focus:ringg_ai-outline-none",!R&&"hover:ringg_ai-bg-black/[0.03]",R&&"ringg_ai-opacity-50 ringg_ai-cursor-not-allowed"),style:{borderColor:a.borderColor,color:O?a.errorColor:a.textColor},children:[x?F.jsx(bf,{className:"ringg_ai-w-4 ringg_ai-h-4 ringg_ai-shrink-0 ringg_ai-animate-spin"}):F.jsx("span",{"data-ringg":"option-radio","aria-hidden":!0,className:"ringg_ai-w-4 ringg_ai-h-4 ringg_ai-rounded-full ringg_ai-border ringg_ai-shrink-0",style:{borderColor:a.mutedTextColor}}),F.jsx("span",{className:"ringg_ai-flex-1",children:k.label}),w&&F.jsx(ZL,{className:"ringg_ai-w-3.5 ringg_ai-h-3.5 ringg_ai-shrink-0"})]},k.id)})})]})},b5=({data:t,collectedData:e})=>{const n=Af(),r=t.icon||"success",a=()=>{switch(r){case"success":return{icon:iv,bgColor:n.successColor};case"info":return{icon:xG,bgColor:n.primaryColor};case"warning":return{icon:AG,bgColor:"#f59e0b"};case"error":return{icon:SG,bgColor:n.errorColor};default:return{icon:iv,bgColor:n.successColor}}},{icon:s,bgColor:l}=a(),c=t.details||[],h=["slot_date","slot_time","name","email","phone"],p=x=>Array.isArray(x)?x.join(", "):typeof x=="boolean"?x?"Yes":"No":String(x),v=e?Object.entries(e).filter(([x])=>h.includes(x)).sort((x,w)=>h.indexOf(x[0])-h.indexOf(w[0])).map(([x,w])=>({key:x,label:x.replace(/slot_/g,"").replace(/_/g," ").replace(/\b\w/g,R=>R.toUpperCase()),value:p(w)})):[],b=c.length>0?c:v,k=x=>x?x.includes("date")?k_:x.includes("time")?QL:x.includes("email")?XL:x.includes("name")?PG:null:null;return F.jsxs(Fi.div,{initial:{opacity:0},animate:{opacity:1},className:"ringg_ai-py-2",children:[F.jsxs("div",{className:"ringg_ai-flex ringg_ai-items-start ringg_ai-gap-3 ringg_ai-mb-4",children:[F.jsx(Fi.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",stiffness:400,damping:15},className:"ringg_ai-w-9 ringg_ai-h-9 ringg_ai-rounded-full ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-flex-shrink-0",style:gi(l),children:F.jsx(s,{className:"ringg_ai-w-4.5 ringg_ai-h-4.5 ringg_ai-text-white"})}),F.jsxs(Fi.div,{initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{delay:.1},className:"ringg_ai-flex-1 ringg_ai-min-w-0 ringg_ai-pt-0.5",children:[F.jsx("h3",{className:"ringg_ai-text-sm ringg_ai-font-semibold ringg_ai-leading-tight",style:{color:n.textColor},children:t.title}),t.message&&F.jsx("p",{className:"ringg_ai-text-xs ringg_ai-mt-1 ringg_ai-leading-relaxed",style:{color:n.mutedTextColor},children:t.message})]})]}),b.length>0&&F.jsx(Fi.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:.15},className:"ringg_ai-rounded-lg ringg_ai-divide-y",style:{backgroundColor:n.surfaceColor,borderColor:n.borderColor},children:b.slice(0,4).map((x,w)=>{const R=x.key?k(x.key):null;return F.jsxs("div",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2.5 ringg_ai-px-3 ringg_ai-py-2.5",style:{borderColor:n.borderColor},children:[R&&F.jsx(R,{className:"ringg_ai-w-3.5 ringg_ai-h-3.5 ringg_ai-flex-shrink-0",style:{color:n.mutedTextColor}}),F.jsx("span",{className:"ringg_ai-text-xs ringg_ai-flex-shrink-0",style:{color:n.mutedTextColor},children:x.label}),F.jsx("span",{className:"ringg_ai-text-xs ringg_ai-font-medium ringg_ai-ml-auto ringg_ai-truncate",style:{color:n.textColor},title:x.value,children:x.value})]},w)})})]})};function one(t){return t.component_type==="interactive_flow"}const C5=({initialComponent:t,onApiCall:e,onComplete:n,onSendResponse:r,onSelectionDisplayed:a,quickReplyAlign:s="end"})=>{const l=one(t),c=!l&&jv(t)&&t.data.presentation==="free",h=Ja(),p=H.useMemo(()=>{const le=t.theme||{};return Lw({primaryColor:h.primaryColor,primaryTextColor:h.primaryTextColor,backgroundColor:h.backgroundColor,surfaceColor:h.surfaceColor,textColor:h.textColor,mutedTextColor:h.mutedTextColor,borderColor:h.borderColor,...le})},[t.theme,h]),v=l?t.data.steps:[{id:"single",title:"",component:t}],b=v.length,[k,x]=H.useState(0),[w,R]=H.useState(!1),[O,P]=H.useState({}),[U,I]=H.useState(null),[B,L]=H.useState(null),[N,Q]=H.useState(new Array(b).fill(!1)),Z=v[k],Se=b>1,G=H.useCallback(()=>{k>0&&x(le=>le-1)},[k]),re=H.useCallback(async le=>{R(!0);const he={...O,...le};P(he),Q(Le=>{const Ke=[...Le];return Ke[k]=!0,Ke});try{const Le=k===b-1,Ke=typeof le.selected_button=="string"?le.selected_button:null,ze=jv(Z.component)&&Ke?Z.component.data.buttons.find(De=>De.id===Ke)??{id:Ke,label:Ke,action:{type:"trigger_component"}}:null,me=jv(Z.component)&&Z.component.data.completionDisplay==="selected_item"&&!!ze;if(r){const De=Le&&me&&!!ze&&!!a;De&&(a(t.component_id,ze.label),n==null||n(he)),await r(t.component_id,{step_index:k,step_data:le,all_data:he,is_final_step:Le}),Le?De||(me&&ze?(L(ze.label),n==null||n(he)):(I({title:"Success!",message:"Your selection has been submitted.",icon:"success"}),n==null||n(he))):x(z=>z+1)}else if(Le)if(l){const{on_complete:De}=t.data,z={};for(const[q,ht]of Object.entries(he))z[q]=Array.isArray(ht)?JSON.stringify(ht):String(ht);const ee=Zte(De.payload,{...z,all_data:JSON.stringify(he)}),ke=await e(De.method,De.endpoint,ee);if(ke.success)I(ke.confirmation||{title:"Success!",message:ke.message,icon:"success"}),n==null||n(he);else throw new Error(ke.message||"Failed to complete")}else n==null||n(he);else x(De=>De+1)}catch(Le){console.error("Error processing step:",Le),I({title:"Something went wrong",message:Le.message||"Please try again.",icon:"error"})}finally{R(!1)}},[O,k,b,l,t,Z,e,n,r,a]),te=H.useCallback(async(le,he)=>{if(he.type==="navigate"&&he.url){window.open(he.url,"_blank","noopener,noreferrer");return}if(r){re({selected_button:le});return}if(he.type==="api_call"&&he.endpoint){R(!0);try{(await e(he.method||"POST",he.endpoint,he.payload||{})).success&&re({selected_button:le})}catch(Le){console.error("Error in button action:",Le)}finally{R(!1)}}else re({selected_button:le})},[e,re,r]);return F.jsx(y5.Provider,{value:p,children:F.jsxs(Fi.div,{"data-ringg":"interactive-flow",initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:Nn("ringg_ai-w-full",c?"ringg_ai-overflow-visible":"ringg_ai-border ringg_ai-overflow-hidden"),style:{backgroundColor:c?"transparent":`color-mix(in srgb, ${p.surfaceColor} 50%, ${p.backgroundColor})`,borderColor:c?"transparent":p.borderColor,color:p.textColor,fontFamily:p.fontFamily,fontSize:p.fontSize,borderRadius:c?void 0:p.borderRadius},children:[Se&&!U&&!B&&F.jsxs("div",{"data-ringg":"flow-stepper",className:"ringg_ai-px-4 ringg_ai-pt-4 ringg_ai-pb-3",children:[F.jsx("div",{"data-ringg":"flow-stepper-progress",className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2",children:v.map((le,he)=>F.jsxs("div",{"data-ringg":"flow-step","data-ringg-step-active":he===k,"data-ringg-step-completed":N[he],className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2 ringg_ai-flex-1 ringg_ai-min-w-0",children:[F.jsx("div",{"data-ringg":"flow-step-indicator",className:"ringg_ai-w-7 ringg_ai-h-7 ringg_ai-rounded-full ringg_ai-text-xs ringg_ai-font-semibold ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-flex-shrink-0 ringg_ai-transition-all",style:{...N[he]?{backgroundColor:p.successColor}:he===k?gi(p.primaryColor):{backgroundColor:p.borderColor},color:N[he]||he===k?p.primaryTextColor:p.mutedTextColor},children:N[he]?F.jsx(iv,{className:"ringg_ai-w-3.5 ringg_ai-h-3.5"}):he+1}),he<v.length-1&&F.jsx("div",{"data-ringg":"flow-step-connector",className:"ringg_ai-flex-1 ringg_ai-h-[2px] ringg_ai-rounded-full ringg_ai-transition-all",style:{backgroundColor:N[he]?p.successColor:p.borderColor}})]},le.id))}),F.jsx("p",{"data-ringg":"flow-step-title",className:"ringg_ai-text-xs ringg_ai-font-medium ringg_ai-mt-3 ringg_ai-truncate",style:{color:p.textColor},children:Z.title||`Step ${k+1} of ${b}`})]}),F.jsxs("div",{"data-ringg":"flow-content",className:Nn(c?"ringg_ai-p-0":"ringg_ai-px-4 ringg_ai-pb-4",!Se&&!c&&"ringg_ai-pt-4"),children:[k>0&&!U&&!B&&F.jsxs("button",{"data-ringg":"flow-back-button",onClick:G,className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-1 ringg_ai-text-xs ringg_ai-mb-3 ringg_ai-transition-colors hover:ringg_ai-opacity-80",style:{color:p.mutedTextColor},children:[F.jsx(x_,{className:"ringg_ai-w-3.5 ringg_ai-h-3.5"}),"Back"]}),F.jsx(Bg,{mode:"wait",children:B?F.jsx(Fi.div,{"data-ringg":"flow-submitted-selection",initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},className:"ringg_ai-py-2",children:F.jsxs("div",{"data-ringg":"flow-submitted-pill",className:"ringg_ai-inline-flex ringg_ai-max-w-full ringg_ai-items-center ringg_ai-gap-2 ringg_ai-rounded-[10px] ringg_ai-border ringg_ai-px-3 ringg_ai-py-2 ringg_ai-text-sm ringg_ai-font-semibold",style:{...gi(p.primaryColor),borderColor:p.primaryColor,color:p.primaryTextColor},children:[F.jsx(iv,{className:"ringg_ai-w-4 ringg_ai-h-4 ringg_ai-flex-shrink-0"}),F.jsx("span",{className:"ringg_ai-truncate",title:B,children:B})]})},"submitted_selection"):U?F.jsx(b5,{data:U,collectedData:O},"confirmation"):F.jsxs(Fi.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},children:[Jte(Z.component)&&F.jsx(nne,{payload:Z.component,isProcessing:w,onComplete:(le,he)=>{const Le=Z.component.data.timezone;re({slot_id:le,slot_datetime:he,slot_time:v5(he,Le),slot_date:Qte(he,Le)})}}),Xte(Z.component)&&F.jsx(ine,{payload:Z.component,isProcessing:w,onComplete:le=>re(le)}),jv(Z.component)&&F.jsx(ane,{payload:Z.component,isProcessing:w,align:s,onButtonClick:te}),ene(Z.component)&&F.jsx(b5,{data:Z.component.data})]},k)})]})]})})},sne=({ariaLabel:t="Connecting",className:e})=>{const n=Ja();return F.jsx("div",{"data-ringg":"loading-bar",className:Nn("ringg_ai-flex ringg_ai-h-12 ringg_ai-items-center ringg_ai-justify-center",e),children:F.jsx("div",{"data-ringg":"loading-bar-track",role:"progressbar","aria-label":t,"aria-busy":"true",className:"ringg_ai-relative ringg_ai-h-1.5 ringg_ai-w-[90%] ringg_ai-overflow-hidden ringg_ai-rounded-full",style:{backgroundColor:n.borderColor},children:F.jsx("div",{"data-ringg":"loading-bar-fill",className:"ringg_ai-absolute ringg_ai-inset-y-0 ringg_ai-left-0 ringg_ai-w-1/3 ringg_ai-rounded-full ringg_ai-animate-indeterminate-progress",style:gi(n.primaryColor)})})})},lne=()=>{const t=Ja();return F.jsx("div",{"data-ringg":"typing-indicator",className:"ringg_ai-flex ringg_ai-flex-col ringg_ai-items-start ringg_ai-gap-1 ringg_ai-justify-start ringg_ai-flex-row","aria-label":"Agent is typing",role:"status",children:F.jsx("div",{"data-ringg":"typing-indicator-bubble",className:"ringg_ai-flex ringg_ai-items-center ringg_ai-justify-start ringg_ai-gap-1 ringg_ai-py-2 ringg_ai-mr-auto",children:[0,1,2].map(e=>F.jsx("span",{"data-ringg":"typing-indicator-dot",className:Nn("ringg_ai-h-1.5 ringg_ai-w-1.5 ringg_ai-rounded-full ringg_ai-animate-bounce"),style:{backgroundColor:t.mutedTextColor,animationDelay:`${e*150}ms`,animationDuration:"1s"}},e))})})};function une(t){return t.sub_questions.length>0}function cne(t){return t.filter(une)}const dne=300,fne=({selectedDiseases:t,onSelectionChange:e,onNext:n,onSearch:r})=>{const a=Af(),s=LC(a.buttonStyle),[l,c]=H.useState(""),[h,p]=H.useState([]),[v,b]=H.useState(!1),[k,x]=H.useState(!1),w=H.useRef(),R=H.useMemo(()=>new Set(t.map(U=>U.disease_name)),[t]),O=H.useCallback(U=>{R.has(U.disease_name)?e(t.filter(I=>I.disease_name!==U.disease_name)):e([...t,U])},[t,R,e]),P=H.useCallback(U=>{e(t.filter(I=>I.disease_name!==U))},[t,e]);return H.useEffect(()=>{const U=l.trim();if(!U){p([]),x(!1),b(!1);return}return b(!0),w.current=setTimeout(async()=>{try{const I=await r(U);p(I)}catch{p([])}finally{b(!1),x(!0)}},dne),()=>{clearTimeout(w.current)}},[l,r]),F.jsxs("div",{"data-ringg":"disease-search",children:[t.length>0&&F.jsx("div",{"data-ringg":"disease-search-selected",className:"ringg_ai-flex ringg_ai-flex-wrap ringg_ai-gap-1.5 ringg_ai-mb-3",children:t.map(U=>F.jsxs("span",{"data-ringg":"disease-pill",className:"ringg_ai-inline-flex ringg_ai-items-center ringg_ai-gap-1 ringg_ai-px-2 ringg_ai-py-1 ringg_ai-rounded-full ringg_ai-text-[10px] ringg_ai-font-medium",style:{backgroundColor:On(a.primaryColor)+"18",color:On(a.primaryColor)},children:[U.disease_name,F.jsx("button",{"data-ringg":"disease-pill-remove",type:"button",onClick:()=>P(U.disease_name),className:"ringg_ai-ml-0.5 hover:ringg_ai-opacity-70 ringg_ai-transition-opacity",children:F.jsx(t3,{className:"ringg_ai-w-2.5 ringg_ai-h-2.5"})})]},U.disease_name))}),t.length===0&&F.jsx("p",{"data-ringg":"disease-search-empty",className:"ringg_ai-text-[10px] ringg_ai-mb-2",style:{color:a.mutedTextColor},children:"No conditions selected yet"}),F.jsxs("div",{"data-ringg":"disease-search-input-wrapper",className:"ringg_ai-relative ringg_ai-mb-3",children:[F.jsx(e3,{className:"ringg_ai-absolute ringg_ai-left-2.5 ringg_ai-top-1/2 -ringg_ai-translate-y-1/2 ringg_ai-w-3.5 ringg_ai-h-3.5",style:{color:a.mutedTextColor}}),F.jsx("input",{"data-ringg":"disease-search-input",type:"text",value:l,onChange:U=>c(U.target.value),placeholder:"Type to search diseases...",autoComplete:"off",className:"ringg_ai-w-full ringg_ai-pl-8 ringg_ai-pr-3 ringg_ai-py-2 ringg_ai-text-xs ringg_ai-border ringg_ai-transition-colors focus:ringg_ai-outline-none focus:ringg_ai-ring-1 focus:ringg_ai-ring-inset",style:{backgroundColor:a.backgroundColor,color:a.textColor,borderColor:a.borderColor,borderRadius:s,"--tw-ring-color":On(a.primaryColor)}})]}),F.jsxs("div",{"data-ringg":"disease-search-results",className:"ringg_ai-max-h-[200px] ringg_ai-overflow-y-auto ringg_ai-mb-3",children:[!l.trim()&&F.jsx("p",{className:"ringg_ai-text-xs ringg_ai-text-center ringg_ai-py-4",style:{color:a.mutedTextColor},children:"Type to search diseases..."}),l.trim()&&v&&F.jsxs("div",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-py-4 ringg_ai-gap-2",children:[F.jsx(bf,{className:"ringg_ai-w-4 ringg_ai-h-4 ringg_ai-animate-spin",style:{color:On(a.primaryColor)}}),F.jsx("p",{className:"ringg_ai-text-xs",style:{color:a.mutedTextColor},children:"Searching..."})]}),l.trim()&&!v&&k&&h.length===0&&F.jsxs("p",{className:"ringg_ai-text-xs ringg_ai-text-center ringg_ai-py-4",style:{color:a.mutedTextColor},children:['No diseases found for "',l.trim(),'"']}),!v&&h.length>0&&F.jsx("div",{"data-ringg":"disease-search-list",className:"ringg_ai-space-y-1",children:h.map(U=>{const I=R.has(U.disease_name);return F.jsxs("button",{"data-ringg":"disease-option","data-ringg-selected":I,type:"button",onClick:()=>O(U),className:"ringg_ai-w-full ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2 ringg_ai-px-2.5 ringg_ai-py-2 ringg_ai-rounded-lg ringg_ai-text-left ringg_ai-transition-colors hover:ringg_ai-opacity-80",style:{backgroundColor:I?On(a.primaryColor)+"0D":"transparent"},children:[F.jsx("div",{className:"ringg_ai-flex-shrink-0 ringg_ai-w-4 ringg_ai-h-4 ringg_ai-rounded ringg_ai-border ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-transition-colors",style:{...I?gi(a.primaryColor):{},borderColor:I?On(a.primaryColor):a.borderColor},children:I&&F.jsx(iv,{className:"ringg_ai-w-2.5 ringg_ai-h-2.5",style:{color:a.primaryTextColor}})}),F.jsx("span",{className:"ringg_ai-flex-1 ringg_ai-text-xs",style:{color:a.textColor},children:U.disease_name})]},U.disease_name)})})]}),F.jsx("button",{"data-ringg":"disease-search-next",onClick:n,disabled:t.length===0,className:Nn("ringg_ai-w-full ringg_ai-h-9 ringg_ai-text-sm ringg_ai-font-semibold ringg_ai-transition-all ringg_ai-duration-200","hover:ringg_ai-opacity-90 focus:ringg_ai-outline-none focus:ringg_ai-ring-1 focus:ringg_ai-ring-inset","disabled:ringg_ai-opacity-50 disabled:ringg_ai-cursor-not-allowed disabled:hover:ringg_ai-opacity-50"),style:{borderRadius:s,...t.length===0?{backgroundColor:a.borderColor}:gi(a.primaryColor),color:t.length===0?a.mutedTextColor:a.primaryTextColor,"--tw-ring-color":On(a.primaryColor)},children:F.jsxs("span",{className:"ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-gap-1",children:["Next",F.jsx("span",{className:"ringg_ai-text-xs ringg_ai-opacity-70",children:"→"})]})})]})},hne=({diseases:t,initialAnswers:e,onComplete:n,isProcessing:r})=>{const a=Af(),s=LC(a.buttonStyle),[l,c]=H.useState(0),[h,p]=H.useState(e),v=t[l],b=l===t.length-1,k=l===0,x=h[v.disease_name]??[],w=U=>{var I;return((I=x.find(B=>B.question_id===U))==null?void 0:I.answer)??""},R=H.useCallback((U,I)=>{p(B=>{const N=(B[v.disease_name]??[]).filter(Q=>Q.question_id!==U);return N.push({question_id:U,answer:I}),{...B,[v.disease_name]:N}})},[v.disease_name]),O=H.useCallback(()=>{k||c(U=>U-1)},[k]),P=H.useCallback(()=>{b?n(h):c(U=>U+1)},[b,h,n]);return F.jsxs("div",{"data-ringg":"sub-questions",children:[F.jsxs("div",{"data-ringg":"sub-questions-header",className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-2 ringg_ai-mb-3",children:[F.jsx("div",{"data-ringg":"sub-questions-counter",className:"ringg_ai-w-7 ringg_ai-h-7 ringg_ai-rounded-lg ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center",style:{backgroundColor:On(a.primaryColor)+"18"},children:F.jsxs("span",{className:"ringg_ai-text-xs",style:{color:On(a.primaryColor)},children:[l+1,"/",t.length]})}),F.jsxs("div",{"data-ringg":"sub-questions-meta",children:[F.jsx("p",{"data-ringg":"sub-questions-disease-name",className:"ringg_ai-text-xs ringg_ai-font-medium",style:{color:a.textColor},children:v.disease_name}),F.jsxs("p",{"data-ringg":"sub-questions-progress",className:"ringg_ai-text-[10px]",style:{color:a.mutedTextColor},children:[l+1," of ",t.length]})]})]}),F.jsx("div",{"data-ringg":"sub-questions-list",className:"ringg_ai-space-y-3 ringg_ai-mb-4",children:v.sub_questions.map(U=>{const I=w(U.question_id);return F.jsxs("div",{"data-ringg":"sub-question","data-ringg-question-type":U.question_type,children:[F.jsx("label",{"data-ringg":"sub-question-label",className:"ringg_ai-text-xs ringg_ai-font-medium ringg_ai-mb-1 ringg_ai-block",style:{color:a.mutedTextColor},children:U.label}),U.question_type==="INPUT"&&F.jsx("input",{"data-ringg":"sub-question-input",type:"text",value:I,onChange:B=>R(U.question_id,B.target.value),placeholder:U.placeholder??`Enter ${U.label.toLowerCase()}`,className:"ringg_ai-w-full ringg_ai-px-3 ringg_ai-py-2 ringg_ai-text-xs ringg_ai-border ringg_ai-transition-colors focus:ringg_ai-outline-none focus:ringg_ai-ring-1 focus:ringg_ai-ring-inset",style:{backgroundColor:a.backgroundColor,color:a.textColor,borderColor:a.borderColor,borderRadius:s,"--tw-ring-color":On(a.primaryColor)}}),U.question_type==="SINGLE_SELECT"&&U.options&&F.jsx("div",{"data-ringg":"sub-question-options","data-ringg-mode":"single",className:"ringg_ai-flex ringg_ai-flex-wrap ringg_ai-gap-1.5",children:U.options.map(B=>{const L=I===B;return F.jsx("button",{"data-ringg":"sub-question-option","data-ringg-selected":L,type:"button",onClick:()=>R(U.question_id,B),className:"ringg_ai-px-3 ringg_ai-py-1.5 ringg_ai-text-xs ringg_ai-font-medium ringg_ai-border ringg_ai-transition-all hover:ringg_ai-opacity-80",style:{borderRadius:s,...L?gi(a.primaryColor):{backgroundColor:a.backgroundColor},color:L?a.primaryTextColor:a.textColor,borderColor:L?On(a.primaryColor):a.borderColor},children:B},B)})}),U.question_type==="MULTI_SELECT"&&U.options&&F.jsx("div",{"data-ringg":"sub-question-options","data-ringg-mode":"multi",className:"ringg_ai-flex ringg_ai-flex-wrap ringg_ai-gap-1.5",children:U.options.map(B=>{const L=I?I.split(","):[],N=L.includes(B);return F.jsx("button",{"data-ringg":"sub-question-option","data-ringg-selected":N,type:"button",onClick:()=>{const Q=N?L.filter(Z=>Z!==B):[...L,B];R(U.question_id,Q.join(","))},className:"ringg_ai-px-3 ringg_ai-py-1.5 ringg_ai-text-xs ringg_ai-font-medium ringg_ai-border ringg_ai-transition-all hover:ringg_ai-opacity-80",style:{borderRadius:s,...N?gi(a.primaryColor):{backgroundColor:a.backgroundColor},color:N?a.primaryTextColor:a.textColor,borderColor:N?On(a.primaryColor):a.borderColor},children:B},B)})})]},U.question_id)})}),F.jsxs("div",{"data-ringg":"sub-questions-nav",className:"ringg_ai-flex ringg_ai-gap-2",children:[!k&&F.jsxs("button",{"data-ringg":"sub-questions-prev",onClick:O,className:"ringg_ai-flex-1 ringg_ai-h-9 ringg_ai-text-sm ringg_ai-font-semibold ringg_ai-border ringg_ai-transition-all hover:ringg_ai-opacity-80 ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-gap-1",style:{borderRadius:s,backgroundColor:a.backgroundColor,color:a.textColor,borderColor:a.borderColor},children:[F.jsx(x_,{className:"ringg_ai-w-3.5 ringg_ai-h-3.5"}),"Back"]}),F.jsx("button",{"data-ringg":"sub-questions-next",onClick:P,disabled:r,className:Nn("ringg_ai-flex-1 ringg_ai-h-9 ringg_ai-text-sm ringg_ai-font-semibold ringg_ai-transition-all ringg_ai-duration-200","hover:ringg_ai-opacity-90 focus:ringg_ai-outline-none focus:ringg_ai-ring-1 focus:ringg_ai-ring-inset","disabled:ringg_ai-opacity-50 disabled:ringg_ai-cursor-not-allowed","ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-gap-1"),style:{borderRadius:s,...r?{backgroundColor:a.borderColor}:gi(a.primaryColor),color:r?a.mutedTextColor:a.primaryTextColor,"--tw-ring-color":On(a.primaryColor)},children:r?F.jsx(bf,{className:"ringg_ai-w-4 ringg_ai-h-4 ringg_ai-animate-spin"}):F.jsxs(F.Fragment,{children:["Next",F.jsx(CG,{className:"ringg_ai-w-3.5 ringg_ai-h-3.5"})]})})]})]})},pne=1500;function mne(t){return t.replace(/^\//,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}const gne=({label:t,onSearch:e,onSubmit:n})=>{const r=Af(),[a,s]=H.useState("select"),[l,c]=H.useState([]),[h,p]=H.useState({}),v=H.useMemo(()=>cne(l),[l]),b=a==="select"||a==="details",k=H.useCallback(()=>{a==="details"&&s("select")},[a]),x=H.useCallback(O=>{n({selections:O}),s("searching")},[n]),w=H.useCallback(()=>{if(v.length>0)s("details");else{const O=l.map(P=>({disease_name:P.disease_name,sub_questions:[]}));x(O)}},[v.length,l,x]),R=H.useCallback(O=>{p(O);const P=l.map(U=>({disease_name:U.disease_name,sub_questions:O[U.disease_name]??[]}));x(P)},[l,x]);return H.useEffect(()=>{if(a!=="searching")return;const O=setTimeout(()=>{s("submitted")},pne);return()=>clearTimeout(O)},[a]),F.jsx("div",{"data-ringg":"policy-finder","data-ringg-step":a,className:"ringg_ai-rounded-lg ringg_ai-border ringg_ai-overflow-hidden ringg_ai-p-3",style:{borderColor:r.borderColor,backgroundColor:`color-mix(in srgb, ${r.surfaceColor} 50%, ${r.backgroundColor})`},children:F.jsxs(Bg,{mode:"wait",children:[a==="searching"&&F.jsxs(Fi.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-3 ringg_ai-py-3",children:[F.jsx("div",{className:"ringg_ai-w-8 ringg_ai-h-8 ringg_ai-rounded-full ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-flex-shrink-0",style:{backgroundColor:On(r.primaryColor)+"12"},children:F.jsx(Fi.div,{animate:{rotate:360},transition:{duration:1.5,repeat:1/0,ease:"linear"},children:F.jsx(e3,{className:"ringg_ai-w-4 ringg_ai-h-4",style:{color:On(r.primaryColor)}})})}),F.jsxs("div",{className:"ringg_ai-flex-1 ringg_ai-min-w-0",children:[F.jsx("p",{className:"ringg_ai-text-xs ringg_ai-font-medium",style:{color:r.textColor},children:"Finding best policies..."}),F.jsx("div",{className:"ringg_ai-flex ringg_ai-gap-1 ringg_ai-mt-1",children:[0,1,2].map(O=>F.jsx(Fi.div,{animate:{opacity:[.3,1,.3]},transition:{duration:1,repeat:1/0,delay:O*.15},className:"ringg_ai-w-1 ringg_ai-h-1 ringg_ai-rounded-full",style:{backgroundColor:On(r.primaryColor)}},O))})]})]},"searching"),a==="submitted"&&F.jsxs(Fi.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-3 ringg_ai-py-3",children:[F.jsx("div",{className:"ringg_ai-w-8 ringg_ai-h-8 ringg_ai-flex-shrink-0",children:F.jsxs("svg",{viewBox:"0 0 32 32",fill:"none",className:"ringg_ai-w-full ringg_ai-h-full",children:[F.jsx(Fi.circle,{cx:"16",cy:"16",r:"14",stroke:r.successColor,strokeWidth:"2",fill:"none",initial:{pathLength:0},animate:{pathLength:1},transition:{duration:.4,ease:"easeOut"}}),F.jsx(Fi.path,{d:"M10 16.5L14 20.5L22 12.5",stroke:r.successColor,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",initial:{pathLength:0},animate:{pathLength:1},transition:{duration:.3,delay:.3,ease:"easeOut"}})]})}),F.jsxs("div",{className:"ringg_ai-flex-1 ringg_ai-min-w-0",children:[F.jsx("p",{className:"ringg_ai-text-xs ringg_ai-font-medium",style:{color:r.textColor},children:"Query submitted"}),F.jsx("p",{className:"ringg_ai-text-[10px] ringg_ai-mt-0.5",style:{color:r.mutedTextColor},children:"Policy results will appear in chat shortly"})]})]},"submitted"),b&&F.jsxs(Fi.div,{"data-ringg":"policy-finder-form",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:[F.jsx("p",{"data-ringg":"policy-finder-title",className:"ringg_ai-text-sm ringg_ai-font-medium ringg_ai-mb-3",style:{color:r.textColor},children:t?mne(t):"Disease Acceptance"}),a==="details"&&F.jsxs("button",{"data-ringg":"policy-finder-back",onClick:k,className:"ringg_ai-flex ringg_ai-items-center ringg_ai-gap-1 ringg_ai-text-xs ringg_ai-mb-3 ringg_ai-transition-colors hover:ringg_ai-opacity-80",style:{color:r.mutedTextColor},children:[F.jsx(x_,{className:"ringg_ai-w-3.5 ringg_ai-h-3.5"}),"Back"]}),F.jsx(Bg,{mode:"wait",children:F.jsxs(Fi.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},children:[a==="select"&&F.jsx(fne,{selectedDiseases:l,onSelectionChange:c,onNext:w,onSearch:e}),a==="details"&&F.jsx(hne,{diseases:v,initialAnswers:h,onComplete:R})]},a)})]},"form")]})})},vne=o4("ringg_ai-inline-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-gap-2 ringg_ai-whitespace-nowrap ringg_ai-rounded-md ringg_ai-text-sm ringg_ai-font-medium ringg_ai-ring-offset-background ringg_ai-transition-colors focus-visible:ringg_ai-outline-none focus-visible:ringg_ai-ring-2 focus-visible:ringg_ai-ring-ring focus-visible:ringg_ai-ring-offset-2 disabled:ringg_ai-pointer-events-none disabled:ringg_ai-opacity-50 [&_svg]:ringg_ai-pointer-events-none [&_svg]:ringg_ai-size-4 [&_svg]:ringg_ai-shrink-0",{variants:{variant:{default:"ringg_ai-bg-primary ringg_ai-text-primary-foreground ringg_ai-shadow hover:ringg_ai-bg-primary/90",destructive:"ringg_ai-bg-destructive ringg_ai-text-destructive-foreground ringg_ai-shadow-sm hover:ringg_ai-bg-destructive/90",outline:"ringg_ai-border ringg_ai-border-input ringg_ai-bg-background ringg_ai-shadow-sm hover:ringg_ai-bg-accent hover:ringg_ai-text-accent-foreground",secondary:"ringg_ai-bg-secondary ringg_ai-text-secondary-foreground ringg_ai-shadow-sm hover:ringg_ai-bg-secondary/80",ghost:"hover:ringg_ai-bg-accent hover:ringg_ai-text-accent-foreground",link:"ringg_ai-text-primary ringg_ai-underline-offset-4 hover:ringg_ai-underline"},size:{default:"ringg_ai-h-9 ringg_ai-px-4 ringg_ai-py-2",sm:"ringg_ai-h-8 ringg_ai-rounded-md ringg_ai-px-3 ringg_ai-text-xs",lg:"ringg_ai-h-10 ringg_ai-rounded-md ringg_ai-px-8",icon:"ringg_ai-h-9 ringg_ai-w-9"}},defaultVariants:{variant:"default",size:"default"}}),Fv=H.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,...a},s)=>{const l=r?gC:"button";return F.jsx(l,{className:Nn(vne({variant:e,size:n,className:t})),ref:s,...a})});Fv.displayName="Button";function td(t,e){typeof window<"u"&&window.dispatchEvent(new CustomEvent(t,{detail:e}))}function yne({callMode:t}){const[e,n]=H.useState(!1),[r,a]=H.useState(!1),[s,l]=H.useState(null),c=H.useRef(!1),h=H.useRef(t);h.current=t;const p=H.useCallback(()=>{c.current||(c.current=!0,n(!0),td("ringg:widget_status",{status:"maximised",mode:h.current}))},[]),v=H.useCallback(()=>{c.current=!1,n(!1),td("ringg:widget_status",{status:"minimised",mode:h.current})},[]),b=H.useCallback(()=>{a(!1),l(null),v()},[v]),k=H.useCallback(()=>{c.current?v():p()},[p,v]);return H.useMemo(()=>({isOpen:e,showFeedback:r,currentCallId:s,setShowFeedback:a,setCurrentCallId:l,open:p,minimize:v,close:b,toggle:k}),[e,r,s,p,v,b,k])}function bne({room:t,onError:e}){const[n,r]=H.useState("unknown"),a=H.useRef(e);a.current=e;const s=H.useCallback(async()=>{var h;try{if((h=navigator.permissions)!=null&&h.query){const p=await navigator.permissions.query({name:"microphone"});r(p.state),p.onchange=()=>{r(p.state)}}else try{await navigator.mediaDevices.getUserMedia({audio:!0}),r("granted")}catch{r("denied")}}catch(p){console.error("Error checking microphone permission:",p),r("unknown")}},[]),l=H.useCallback(async()=>{var h;try{const p=await navigator.mediaDevices.getUserMedia({audio:!0});return r("granted"),p.getTracks().forEach(v=>v.stop()),!0}catch(p){return console.error("Error requesting microphone permission:",p),r("denied"),(h=a.current)==null||h.call(a,"Microphone access was denied. Please enable it in your browser settings."),!1}},[]);H.useEffect(()=>{s();const h=()=>{var p;(p=a.current)==null||p.call(a,"Error acquiring microphone permission. Please make sure you grant the necessary permissions in your browser and reload the tab"),r("denied")};return t.on(Pe.MediaDevicesError,h),()=>{t.off(Pe.MediaDevicesError,h)}},[t,s]);const c=n==="granted";return H.useMemo(()=>({state:n,isGranted:c,check:s,request:l}),[n,c,s,l])}function Cne({containerRef:t,enabled:e}){H.useEffect(()=>{const n=t.current;if(!n||!e)return;const r=c=>{const h=n.querySelector('[data-scrollable="true"]');if(!h){c.preventDefault();return}const{scrollTop:p,scrollHeight:v,clientHeight:b}=h,k=p===0&&c.deltaY<0,x=p+b>=v-1&&c.deltaY>0;(k||x)&&c.preventDefault()};let a=0;const s=c=>{a=c.touches[0].clientY},l=c=>{const h=n.querySelector('[data-scrollable="true"]'),p=c.touches[0].clientY,v=a-p;if(!h){c.preventDefault();return}const{scrollTop:b,scrollHeight:k,clientHeight:x}=h,w=b===0&&v<0,R=b+x>=k-1&&v>0;(w||R)&&c.preventDefault()};return n.addEventListener("wheel",r,{passive:!1}),n.addEventListener("touchstart",s,{passive:!0}),n.addEventListener("touchmove",l,{passive:!1}),()=>{n.removeEventListener("wheel",r),n.removeEventListener("touchstart",s),n.removeEventListener("touchmove",l)}},[e])}const Ul={mode:"prod",title:"Ringg AI Support",description:"Ringg AI offers 24/7 support to handle all your customer queries",defaultTab:"audio",hideTabSelector:!1,bypassStartScreen:!1,bypassFeedbackScreen:!1,notificationTuneUrl:"https://assets.ringg.ai/audios/misc/widget_notification.mp3",voiceCallShowTranscript:!0,voiceCallShowAnimation:!1};function jw(t){switch(t){case"dev":return"https://calling-dev.ringg.ai/ca/api/v0";case"stage":return"https://stage-api2.desivocal.com/ca/api/v0";default:return"https://prod-api.ringg.ai/ca/api/v0"}}function Sne(t){switch(t){case"dev":return;case"stage":return"wss://mercury.webrtc-stage.ringg.ai";default:return"wss://mercury.webrtc.ringg.ai"}}function kne(t){return((t==null?void 0:t.trim())||void 0||"").trim()}function xne(t){return((t==null?void 0:t.trim())||void 0||"").trim()}function Fw(t,e){const n=xne(t);if(n)return{Authorization:n};const r=kne(e);return r?{"X-API-KEY":r}:{}}const S5={center:{top:0,left:0,right:0,bottom:0,margin:"auto"},"top-left":{top:"2%",left:"2%"},"top-right":{top:"2%",right:"2%"},"bottom-left":{bottom:"2%",left:"2%"},"bottom-right":{bottom:"2%",right:"2%"},"bottom-center":{bottom:"2%",left:"50%"}};function Tne(t){return S5[t]??S5["bottom-right"]}function _ne(t){return t==="bottom-center"?{left:"50%"}:t==="bottom-left"?{left:"2%"}:{right:"2%"}}function jC(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function wne(t){return t?{width:jC(t.width),height:jC(t.height),borderRadius:jC(t.borderRadius)}:{}}function Ene(t,e){if(!e)return t;let n=[t];return Object.entries(e).forEach(([r,a])=>{n=n.flatMap((s,l)=>{if(typeof s!="string")return s;const c=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h=new RegExp(`\\b(${c})\\b`,"g");return s.split(h).map((p,v)=>p===r?F.jsx("a",{target:"_blank",rel:"noopener noreferrer",className:"ringg_ai-text-blue-500 hover:ringg_ai-underline",href:a,children:r},`${l}-${v}`):p)})}),n}const Uv=(...t)=>console.warn("[DOM_ACTION]",...t);function Rne(t,e){const n=s=>{try{e==null||e(s)}catch(l){Uv("logger threw",l)}};if(!t||typeof t!="object"){Uv("Missing or invalid action config"),n({label:"Invalid action",level:"error"});return}const{id:r,kind:a}=t;if(a!=="trigger_event"){Uv(`[${r}] unknown kind`,a),n({id:r,label:"Unknown kind",meta:String(a),level:"error"});return}try{if(!t.event_name)return Uv(`[${r}] trigger_event missing event_name`),n({id:r,label:"Event missing name",level:"error"});const s={...t.default_payload??{},action_id:r};window.dispatchEvent(new CustomEvent(t.event_name,{detail:s})),n({id:r,label:"Triggered",meta:t.event_name,level:"info"})}catch(s){Uv(`[${r}] execution failed`,s),n({id:r,label:"Action failed",level:"error"})}}const Ane=({label:t,meta:e,level:n="info"})=>{const r=Ja(),a=n==="error"?"#ef4444":"#22c55e";return F.jsx("div",{"data-ringg":"system-log","data-ringg-level":n,className:"ringg_ai-flex ringg_ai-justify-center ringg_ai-my-1",children:F.jsxs("div",{"data-ringg":"system-log-pill",className:"ringg_ai-inline-flex ringg_ai-items-center ringg_ai-gap-2 ringg_ai-px-3 ringg_ai-py-1 ringg_ai-rounded-full ringg_ai-border ringg_ai-text-[11px] ringg_ai-max-w-full",style:{borderColor:r.borderColor,backgroundColor:r.backgroundColor,color:r.textColor},role:"status",children:[F.jsx("span",{"data-ringg":"system-log-dot",className:"ringg_ai-inline-block ringg_ai-w-1.5 ringg_ai-h-1.5 ringg_ai-rounded-full ringg_ai-flex-shrink-0",style:{backgroundColor:a}}),F.jsx("span",{"data-ringg":"system-log-label",className:"ringg_ai-font-medium ringg_ai-truncate",children:t}),e&&F.jsx("span",{"data-ringg":"system-log-meta",className:"ringg_ai-font-mono ringg_ai-truncate",style:{color:r.mutedTextColor},title:e,children:e})]})})},Pne=800,Dne=120,One=500;function k5(t){return!!(t!=null&&t.componentData)&&jv(t.componentData)&&t.componentData.data.presentation==="free"}function x5(t){return!!t&&!t.componentType&&!t.isSelf&&!!t.message.trim()}const Mne=({room:t,config:e})=>{var ns,Bi,Bl,Ai,Vl,Lu,ju,Oo,rs,Vi,io;const[n,r]=H.useState({}),a=e,{mode:s=Ul.mode,title:l=Ul.title,description:c=Ul.description,agentId:h,variables:p,buttons:v,xApiKey:b,authorization:k,defaultTab:x=Ul.defaultTab,hideTabSelector:w=Ul.hideTabSelector,bypassStartScreen:R=Ul.bypassStartScreen,bypassFeedbackScreen:O=Ul.bypassFeedbackScreen,innerWindowProps:P,logoUrl:U,logoStyles:I,legalDisclaimer:B,feedbackScreen:L,notificationTuneUrl:N=Ul.notificationTuneUrl,widgetPosition:Q,theme:Z,enabledSlashCommands:Se,voiceCall:G}=a,re=i3(Z),te=__(re.buttonStyle),le=(Q==null?void 0:Q.triggerPlacement)??"fixed",he=(Q==null?void 0:Q.triggerAlignment)??"bottom-right",Le=(Q==null?void 0:Q.hideTriggerOnExpand)??!0,Ke=(Q==null?void 0:Q.widgetAlignment)??"bottom-right",ze=Tne(he),me=wne(P),[De,z]=H.useState(x),[ee,ke]=H.useState(!1),[q,ht]=H.useState(!1),[At,yt]=H.useState({hasError:!1,message:""}),[ut,ot]=H.useState([]),[jt,en]=H.useState(!1),[Kn,_r]=H.useState(new Set),[Ar,sr]=H.useState(new Map),[jr,kr]=H.useState([]),Qn=H.useRef(null),J=H.useRef(null),ue=H.useRef(null),ve=H.useRef(null),Be=H.useRef(""),We=H.useRef(),je=H.useRef(null),ct=H.useRef(!1),Lt=H.useRef([]),se=H.useRef(null),we=H.useRef(null),pt=H.useRef(0),Yt=H.useRef(De);Yt.current=De;const tn=H.useRef(!1);H.useEffect(()=>{tn.current||z(x)},[x]);const qe=H.useCallback(()=>{pt.current=performance.now(),we.current===null&&(we.current=performance.now()),en(!0)},[]),kt=H.useRef(new Map),Mt=c1(t),wt=Mt==="connected";tn.current=wt;const mt=yne({callMode:De}),fn=bne({room:t,onError:Te=>yt({hasError:!0,message:Te})});Cne({containerRef:ue,enabled:mt.isOpen});const{chatMessages:Mn}=XM(),Rn=M7(),gn=x7(),Zn=JM(),An=d1(Rn.audioTrack||void 0),ra=d1({publication:gn.microphoneTrack,source:Oe.Source.Microphone,participant:gn.localParticipant}),lr=H.useMemo(()=>Zn.find(Te=>{var Ee;return(Ee=Te.identity)==null?void 0:Ee.includes("agent")}),[Zn]),Ri=De==="audio",ma=Ri&&wt&&((G==null?void 0:G.showAnimation)??Ul.voiceCallShowAnimation),es=!Ri||((G==null?void 0:G.showTranscript)??Ul.voiceCallShowTranscript),tl=ma?(ns=gn.localParticipant.getTrackPublication(Oe.Source.Microphone))==null?void 0:ns.track:void 0,ts=ma?(Bi=lr==null?void 0:lr.getTrackPublication(Oe.Source.Microphone))==null?void 0:Bi.track:void 0,ks=H.useMemo(()=>{const Te=Se??[],Ee=new Set(Te.map(Et=>Et.command)),Xe=[...Te];for(const Et of jr)Ee.has(Et.command)||Xe.push(Et);return Xe},[Se,jr]),no=H.useCallback((Te,Ee)=>{ct.current=!1,td("ringg:conversation_status",{status:"started",mode:Te,callId:Ee})},[]),ia=H.useCallback((Te,Ee)=>{ct.current||(ct.current=!0,td("ringg:conversation_status",{status:"ended",mode:Te,callId:Ee}))},[]),Fr=H.useCallback(async Te=>{if(!(Te==="audio"&&!fn.isGranted&&!await fn.request())){ke(!0),z(Te);try{const Ee=await fetch(`${jw(s)}/calling/webcall`,{method:"POST",body:JSON.stringify({agent_id:h,custom_args_values:p,media_type:Te}),headers:{"Content-Type":"application/json",...Fw(k,b)}}),Xe=await Ee.json();if(!Ee.ok)throw new Error((Xe==null?void 0:Xe.message)||"Failed to make call");Xe!=null&&Xe.call_id&&mt.setCurrentCallId(Xe.call_id),Array.isArray(Xe==null?void 0:Xe.enabled_slash_commands)&&kr(Xe.enabled_slash_commands),await t.connect(Sne(s),Xe==null?void 0:Xe.user_token),Te==="audio"&&await t.localParticipant.setMicrophoneEnabled(!0),no(Te,Xe.call_id),yt({hasError:!1,message:""})}catch(Ee){yt({hasError:!0,message:Ee.message})}finally{ke(!1)}}},[t,s,h,p,b,k,fn,mt,no]),ga=H.useCallback(()=>{R&&!wt&&!ee&&Mt==="disconnected"?(mt.open(),Fr(De)):mt.toggle()},[R,wt,ee,Mt,De,mt,Fr]),zr=H.useCallback(()=>{ot([]),_r(new Set),sr(new Map)},[]),bi=H.useCallback(async()=>{ke(!0);try{mt.currentCallId&&ia(De,mt.currentCallId),kr([]),Qn.current=null,Be.current="",We.current=void 0,pt.current=0,we.current=null,en(!1),Lt.current=[],se.current&&(clearTimeout(se.current),se.current=null),t.disconnect(),ht(!1),O?(mt.setShowFeedback(!1),zr(),mt.close()):(mt.setShowFeedback(!0),mt.open())}catch(Te){yt({hasError:!0,message:"Error ending call: "+Te.message})}finally{ke(!1)}},[t,De,mt,ia,O,zr]),Ro=H.useCallback(async(Te,Ee)=>{if(!mt.currentCallId){zr(),mt.close();return}ke(!0);try{await fetch(`${jw(s)}/calling/${mt.currentCallId}/feedback`,{method:"POST",body:JSON.stringify({rating:Te,comment:Ee}),headers:{"Content-Type":"application/json",...Fw(k,b)}}),td("ringg:feedback_status",{status:"submitted",callId:mt.currentCallId,rating:Te})}catch(Xe){console.error("Error submitting feedback:",Xe)}finally{ke(!1),zr(),mt.close()}},[s,b,k,mt,zr]),Ao=H.useCallback(()=>{mt.currentCallId&&td("ringg:feedback_status",{status:"skipped",callId:mt.currentCallId}),zr(),mt.close()},[mt,zr]);H.useEffect(()=>()=>{se.current&&clearTimeout(se.current)},[]);const K=H.useCallback((Te,Ee)=>{var Et;const Xe={name:"Agent",message:"",isSelf:!1,timestamp:Date.now()+Math.random(),componentType:Te.component_type,componentData:Te};ot(rt=>[...rt,Xe]),td("ringg:calendar_booking",{status:"shown",componentId:Te.component_id}),pt.current<=Ee&&(we.current=null,en(!1)),mt.isOpen||(Et=ve.current)==null||Et.play().catch(()=>{}),mt.open()},[mt]),Ne=H.useCallback(()=>{se.current&&(clearTimeout(se.current),se.current=null);const Te=Lt.current;Lt.current=[],Te.forEach(({component:Ee,arrivedAt:Xe})=>K(Ee,Xe))},[K]),tt=H.useCallback(Te=>{const Ee=performance.now();if(Yt.current!=="text"){K(Te,Ee);return}Lt.current.push({component:Te,arrivedAt:Ee}),se.current||(se.current=setTimeout(Ne,Pne))},[K,Ne]),st=H.useCallback(Te=>{_r(Ee=>{const Xe=new Set(Ee);return Xe.add(Te),Xe}),td("ringg:calendar_booking",{status:"confirmed",componentId:Te,message:"Flow completed"})},[]),vn=H.useCallback((Te,Ee)=>{ot(Xe=>{const Et=Xe.find(Qt=>{var qt;return((qt=Qt.componentData)==null?void 0:qt.component_id)===Te}),rt=(Et==null?void 0:Et.timestamp)??Date.now(),Wt={name:"You",isSelf:!0,message:Ee,timestamp:rt+Math.random()*.5},ln=new Set;return[...Xe,Wt].filter(Qt=>!ln.has(Qt.timestamp)&&ln.add(Qt.timestamp)).sort((Qt,qt)=>Qt.timestamp-qt.timestamp)})},[]),Kt=H.useCallback(async(Te,Ee)=>{var aa,oa,cn,La;const Xe=kt.current.get(Te);if(!Xe||!lr)return;const{name:Et,originalConfig:rt}=Xe,Wt="receive_dynamic_data";let ln;if(Et==="calendar"){const Zr=Ee.step_data&&Ee.step_data.slot_id,Vt=rt,xs=(Vt==null?void 0:Vt.slots)||[],Hr=(Vt==null?void 0:Vt.timezone)||"UTC",Jr=xs.find(zi=>zi.id===Zr);ln={id:(Jr==null?void 0:Jr.id)||Zr,datetime:(Jr==null?void 0:Jr.datetime)||((aa=Ee.step_data)==null?void 0:aa.slot_datetime),timezone:Hr,slot_time:(oa=Ee.step_data)==null?void 0:oa.slot_time,slot_date:(cn=Ee.step_data)==null?void 0:cn.slot_date}}else if(Et==="form")ln=Ee.step_data||Ee.all_data;else if(Et==="buttons"){const Zr=Ee.step_data&&Ee.step_data.selected_button;ln=(Array.isArray(rt)?rt:[]).find(Hr=>Hr.id===Zr)||{id:Zr}}else Et==="quick_replay"?ln={text:(La=Ee.step_data)==null?void 0:La.selected_button}:ln=Ee;const Qt=rt==null?void 0:rt.tool_id,qt=JSON.stringify({component_type:`receive_component_${Et}`,component_id:Te,component_data:ln,...Qt&&{tool_id:Qt}});try{await gn.localParticipant.performRpc({destinationIdentity:lr.identity,method:Wt,payload:qt}),kt.current.delete(Te)}catch(Zr){console.error("[RinggWidget] Failed to send receive_dynamic_data:",Zr)}},[lr,gn.localParticipant]),Sn=H.useCallback(async(Te,Ee)=>{if(!lr){console.warn("[DiseaseWidget] Submit blocked — no agent participant connected");return}const Xe=JSON.stringify({component_type:"receive_component_disease_plans",component_id:Te,selections:Ee.selections});try{await gn.localParticipant.performRpc({destinationIdentity:lr.identity,method:"receive_dynamic_data",payload:Xe})}catch(Et){console.error("[DiseaseWidget] Submit RPC failed:",Et)}},[lr,gn.localParticipant]),hn=H.useCallback(Te=>new Promise(Ee=>{if(!lr){console.warn("[DiseaseSearch] Search blocked — no agent participant connected"),Ee([]);return}Qn.current=Ee;const Xe=JSON.stringify({component_type:"receive_component_disease_search",query:Te});gn.localParticipant.performRpc({destinationIdentity:lr.identity,method:"receive_dynamic_data",payload:Xe}).catch(Et=>{console.error("[DiseaseSearch] Search RPC failed:",Et),Qn.current=null,Ee([])})}),[lr,gn.localParticipant]),Pr=H.useCallback(async Te=>{if(Te.tool_type==="WIDGET_TOOL"||Te.tool_type==="DISEASE_ACCEPTANCE_TOOL"){const Xe=`disease_data_${Date.now()}`,Et={name:"Agent",message:"",isSelf:!1,timestamp:Date.now()+Math.random(),componentType:"disease_data",componentData:{component_type:"disease_data",component_id:Xe,label:Te.command}};ot(rt=>[...rt,Et]);return}if(!lr){console.warn("[RinggWidget] No agent participant found, cannot send slash command");return}const Ee=JSON.stringify({component_type:"receive_component_slash_command",command:Te.command.replace(/^\//,"")});try{await gn.localParticipant.performRpc({destinationIdentity:lr.identity,method:"receive_dynamic_data",payload:Ee})}catch(Xe){console.error("[RinggWidget] Failed to send slash command via RPC:",Xe)}},[lr,gn.localParticipant]),ur=H.useMemo(()=>null,[]),cr=H.useCallback(async(Te,Ee,Xe)=>(await fetch(Ee.startsWith("http")?Ee:`${jw(s)}${Ee}`,{method:Te,body:JSON.stringify(Xe),headers:{"Content-Type":"application/json",...Fw(k,b)}})).json(),[s,b,k,wt,ur]),Ci=H.useCallback(async Te=>{try{const Ee=JSON.parse(Te.payload);return Array.isArray(Ee.source_urls)?Be.current=Ee.source_urls.join(", "):Ee.source_url&&(Be.current=Ee.source_url),JSON.stringify({status:"received"})}catch(Ee){throw console.error("Failed to parse send_source_urls payload:",Ee),new Error("Invalid payload for send_source_urls")}},[]),Na=H.useCallback(async Te=>{try{const Ee=JSON.parse(Te.payload);return Ee.component_type&&Ee.component_id&&tt(Ee),JSON.stringify({status:"received"})}catch(Ee){throw console.error("Failed to parse render_component payload:",Ee),new Error("Invalid component payload")}},[tt]),Un=H.useCallback((Te,Ee)=>{const Xe=`${Te}_${Date.now()}`,Et=Ee.component_config??Ee.component_data;if(Te==="calendar"){const rt=Et,Wt=(rt==null?void 0:rt.slots)||[],ln=(rt==null?void 0:rt.timezone)||"UTC";return{component_type:"calendar_booking",component_id:Xe,data:{available_slots:Wt.map(Qt=>({id:Qt.id,datetime:Qt.datetime})),timezone:ln,title:Ee.title||"Select a time slot"}}}if(Te==="form"){const rt=Et,Wt=Qt=>({text:"text",string:"text",number:"number",email:"email",phone_number:"tel",single_select:"select",multiselect:"multiselect",checkbox:"boolean",date:"date",textarea:"textarea"})[Qt]||"text",ln=((rt==null?void 0:rt.fields)||[]).map(Qt=>({name:Qt.key||Qt.name||"",type:Wt(Qt.type),label:Qt.description||Qt.label||Qt.key||Qt.name||"",required:Qt.required,placeholder:Qt.placeholder,options:Qt.options}));return{component_type:"form",component_id:Xe,data:{title:(rt==null?void 0:rt.title)||"Form",description:rt==null?void 0:rt.description,fields:ln,submit_label:(rt==null?void 0:rt.cta)||(rt==null?void 0:rt.submit_label)||"Submit"}}}if(Te==="buttons")return{component_type:"buttons",component_id:Xe,data:{title:Ee.title,buttons:Array.isArray(Et)?Et:[]}};if(Te==="quick_replay"){const rt=Et,Wt=Array.isArray(rt==null?void 0:rt.options)?rt.options.filter(ln=>typeof ln=="string"&&ln.trim().length>0):[];return{component_type:"buttons",component_id:Xe,data:{presentation:"free",completionDisplay:"selected_item",buttons:Wt.map(ln=>({id:ln,label:ln,action:{type:"trigger_component"}}))}}}return Te==="confirmation"?{component_type:"confirmation",component_id:Xe,data:{title:Ee.title||"Confirmed",message:Ee.message||"",icon:Ee.icon||"success",details:Ee.details}}:Ee.component_type&&Ee.component_id?Ee:null},[]),vr=((Bl=a.eventLogs)==null?void 0:Bl.enabled)===!0,rn=((Ai=a.eventLogs)==null?void 0:Ai.showIds)===!0,ro=H.useCallback(Te=>{if(!vr)return;const Ee=rn&&Te.id?Te.meta?`${Te.id} · ${Te.meta}`:Te.id:Te.meta,Xe={name:"system",message:Te.label,isSelf:!1,timestamp:Date.now()+Math.random(),kind:"system",systemMeta:Ee,systemLevel:Te.level};ot(Et=>[...Et,Xe])},[vr,rn]),Po=H.useCallback(async Te=>{try{const Ee=JSON.parse(Te.payload),Xe=Ee.component_type;if(!Xe)return console.warn("[RinggWidget] No component_type in send_dynamic_data payload"),JSON.stringify({status:"error",message:"No component_type provided"});if(Xe==="execute_dom_action"){const Wt=Ee.component_config??Ee.component_data??{},ln={id:Wt.id??Wt.action_id??"",kind:Wt.kind??"trigger_event",event_name:Wt.event_name,default_payload:Wt.default_payload??Wt.detail};return Rne(ln,ro),JSON.stringify({status:"received"})}const Et=Xe.replace("render_component_","");if(Et==="disease_search_results"){const Wt=Ee.results??[];return Qn.current?(Qn.current(Wt),Qn.current=null):console.warn("[DiseaseSearch] No pending resolver — results dropped (search may have timed out or was cancelled)"),JSON.stringify({status:"received"})}const rt=Un(Et,Ee);return rt?(kt.current.set(rt.component_id,{name:Et,originalConfig:Ee.component_config??Ee.component_data}),tt(rt),JSON.stringify({status:"received",component_id:rt.component_id})):(console.warn("[RinggWidget] Unknown component type:",Et),JSON.stringify({status:"error",message:`Unknown component type: ${Et}`}))}catch(Ee){throw console.error("[RinggWidget] Failed to parse send_dynamic_data payload:",Ee),new Error("Invalid send_dynamic_data payload")}},[tt,Un,ro]);H.useEffect(()=>{je.current=tt},[tt]);const nd=H.useRef(mt.open);nd.current=mt.open,H.useEffect(()=>{},[]),H.useEffect(()=>{var Et,rt;if(!t||De!=="audio"||!wt)return;const Te=new Map(Ar);Rn.audioTrack&&An.segments.forEach(Wt=>{const ln=Te.get(Wt.id),Qt=A_(Wt,ln,Rn.audioTrack.participant);Te.set(Wt.id,Qt)}),ra.segments.forEach(Wt=>{const ln=Te.get(Wt.id),Qt=A_(Wt,ln,gn.localParticipant);Te.set(Wt.id,Qt)});const Ee=Array.from(Te.values()).sort((Wt,ln)=>Wt.timestamp-ln.timestamp),Xe=Be.current&&((Et=Ee[Ee.length-1])==null?void 0:Et.name.includes("Agent"))&&!((rt=Ee[Ee.length-1])!=null&&rt.sourceUrl)&&We.current!==Ee.length-1;if(Xe){We.current=Ee.length,Ee[Ee.length-1]={...Ee[Ee.length-1],sourceUrl:Be.current};const Wt=Ee.filter(Qt=>!Qt.isSelf).length-1,ln=Te.get(An.segments[Wt].id);Te.set(An.segments[Wt].id,A_(An.segments[Wt],{...ln,sourceUrl:Be.current},Rn.audioTrack.participant))}ot(Ee),sr(Te),Xe||(Be.current="")},[De,Mn,An.segments,ra.segments,Rn.audioTrack,gn.localParticipant,wt]),H.useEffect(()=>{if(!t||De!=="text"||!wt)return;const Te=async(Xe,Et)=>{var ln,Qt;const rt=(ln=Et.identity)==null?void 0:ln.includes("agent"),Wt=performance.now();rt&&(we.current===null&&(we.current=performance.now()),en(!0));try{const qt=await Xe.readAll();if(rt&&we.current!==null){const oa=performance.now()-we.current,cn=One-oa;cn>0&&await new Promise(La=>setTimeout(La,cn))}rt&&(mt.isOpen||(Qt=ve.current)==null||Qt.play().catch(()=>{}),mt.open());const aa={message:qt,isSelf:!rt,name:rt?"Agent":"You",timestamp:Date.now()+performance.now()%1,...rt&&Be.current&&{sourceUrl:Be.current}};Be.current&&(Be.current=""),ot(oa=>{const cn=new Set;return[...oa,aa].filter(La=>!cn.has(La.timestamp)&&cn.add(La.timestamp)).sort((La,Zr)=>La.timestamp-Zr.timestamp)}),rt&&(pt.current<=Wt?(we.current=null,en(!1)):we.current=performance.now(),Lt.current.length>0&&setTimeout(Ne,Dne))}catch(qt){rt&&pt.current<=Wt&&(we.current=null,en(!1)),console.error("Error reading text stream",qt)}},Ee=Mn.map(Xe=>{var Wt,ln,Qt,qt;const Et=((Wt=Xe.from)==null?void 0:Wt.identity)===gn.localParticipant.identity,rt=Rn.audioTrack?((ln=Xe.from)==null?void 0:ln.identity)===((Qt=Rn.audioTrack.participant)==null?void 0:Qt.identity):!Et;return{name:((qt=Xe.from)==null?void 0:qt.name)||(rt?"Agent":Et?"You":"Unknown"),isSelf:Et,message:Xe.message,timestamp:Xe.timestamp}});return ot(Xe=>{const Et=new Set;return[...Xe,...Ee].filter(rt=>!Et.has(rt.timestamp)&&Et.add(rt.timestamp)).sort((rt,Wt)=>rt.timestamp-Wt.timestamp)}),t.registerTextStreamHandler("lk.transcription",Te),()=>{t.unregisterTextStreamHandler("lk.transcription")}},[t,De,Mn,mt,gn.localParticipant,Rn.audioTrack,wt,Ne]),H.useEffect(()=>{if(t)return t.registerRpcMethod("send_source_urls",Ci),t.registerRpcMethod("render_component",Na),t.registerRpcMethod("send_dynamic_data",Po),()=>{t.unregisterRpcMethod("send_source_urls"),t.unregisterRpcMethod("render_component"),t.unregisterRpcMethod("send_dynamic_data")}},[t,Ci,Na,Po]),H.useEffect(()=>{if(t)return t.on(Pe.ParticipantDisconnected,bi),t.on(Pe.Disconnected,bi),()=>{t.off(Pe.ParticipantDisconnected,bi),t.off(Pe.Disconnected,bi)}},[bi,t]);const Do=H.useRef(0);return H.useEffect(()=>{const Te=J.current;if(!Te)return;const Ee=ut.length>Do.current;if(Do.current=ut.length,!Ee){Te.scrollTop=Te.scrollHeight;return}const Xe=Te.querySelector('[data-ringg="transcript-list"]'),Et=Array.from((Xe==null?void 0:Xe.children)??[]);let rt=null;for(let aa=Et.length-1;aa>=0;aa--){const oa=Et[aa].getAttribute("data-ringg");if(oa!=="typing-indicator"&&(rt??(rt=Et[aa]),oa==="message")){rt=Et[aa];break}}if(!rt){Te.scrollTop=Te.scrollHeight;return}const Wt=Te.getBoundingClientRect(),Qt=rt.getBoundingClientRect().top-Wt.top+Te.scrollTop,qt=56;Te.scrollTop=Math.max(0,Qt-qt)},[ut,jt]),H.useEffect(()=>(ve.current=new Audio(N),ve.current.preload="auto",()=>{ve.current&&(ve.current.pause(),ve.current.src="",ve.current=null)}),[N]),F.jsxs(BG,{theme:Z,children:[F.jsxs(Bg,{children:[(!Le||!mt.isOpen)&&F.jsx(Fi.button,{"data-ringg":"trigger-button",initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.8,opacity:0},transition:{type:"spring",stiffness:400,damping:25},"aria-label":"Open call widget",onClick:ga,style:{position:le,...ze,...gi(re.primaryColor),color:re.primaryTextColor,...(Vl=v==null?void 0:v.modalTrigger)==null?void 0:Vl.styles},className:"ringg_ai-h-[52px] ringg_ai-w-[52px] !ringg_ai-rounded-2xl ringg_ai-flex ringg_ai-items-center ringg_ai-justify-center ringg_ai-shadow ringg_ai-trigger-btn !ringg_ai-z-[9999] hover:ringg_ai-opacity-90 ringg_ai-transition-opacity",children:F.jsx("img",{"data-ringg":"trigger-icon",src:((ju=(Lu=v==null?void 0:v.modalTrigger)==null?void 0:Lu.icon)==null?void 0:ju.url)??"https://assets.ringg.ai/images/icons/widget-phone.svg",alt:"Widget trigger",style:{width:((rs=(Oo=v==null?void 0:v.modalTrigger)==null?void 0:Oo.icon)==null?void 0:rs.size)??24,height:((io=(Vi=v==null?void 0:v.modalTrigger)==null?void 0:Vi.icon)==null?void 0:io.size)??24}})},"trigger-button"),mt.isOpen&&F.jsxs(Fi.div,{"data-ringg":"widget-root",ref:ue,initial:{y:24,scale:.96,opacity:0,x:Ke==="bottom-center"?"-50%":0},animate:{y:0,scale:1,opacity:1,x:Ke==="bottom-center"?"-50%":0},exit:{y:24,scale:.96,opacity:0,x:Ke==="bottom-center"?"-50%":0},transition:{type:"spring",stiffness:380,damping:30},className:Nn("ringg_ai-relative ringg_ai-border ringg_ai-overflow-hidden !ringg_ai-z-[9999] ringg_ai-w-[95vw] md:ringg_ai-w-[380px] ringg_ai-h-[25.75rem]"),style:{position:"fixed",bottom:"2%",transformOrigin:Ke==="bottom-center"?"bottom center":Ke==="bottom-left"?"bottom left":"bottom right",boxShadow:"0px 54px 33px 0px rgba(0,0,0,0.01), 0px 24px 24px 0px rgba(0,0,0,0.02), 0px 6px 13px 0px rgba(0,0,0,0.02)",..._ne(Ke),...wt?me:{},maxWidth:"96dvw",maxHeight:"96dvh",backgroundColor:re.backgroundColor,borderColor:re.borderColor,borderRadius:jC(P==null?void 0:P.borderRadius)??re.borderRadius,fontFamily:re.fontFamily,"--widget-primary":On(re.primaryColor),"--widget-primary-text":re.primaryTextColor,"--widget-bg":re.backgroundColor,"--widget-surface":re.surfaceColor,"--widget-text":re.textColor,"--widget-muted":re.mutedTextColor,"--widget-border":re.borderColor,"--widget-button-radius":te},children:[(wt||mt.showFeedback)&&F.jsx(Fv,{"data-ringg":"minimize-button",size:"icon",variant:"ghost","aria-label":"Minimize widget",onClick:mt.minimize,className:"ringg_ai-absolute !ringg_ai-z-[9999] ringg_ai-top-2.5 ringg_ai-right-[42px] !ringg_ai-h-7 !ringg_ai-w-7 !ringg_ai-rounded-full ringg_ai-text-gray-500 hover:ringg_ai-text-gray-700",children:F.jsx(wG,{size:16})}),F.jsx(Fv,{"data-ringg":"close-button",size:"icon",variant:"ghost","aria-label":wt?"End call":"Close widget",onClick:()=>wt?ht(!0):mt.showFeedback?Ao():mt.minimize(),className:"ringg_ai-absolute !ringg_ai-z-[9999] ringg_ai-top-2.5 ringg_ai-right-2.5 !ringg_ai-h-7 !ringg_ai-w-7 !ringg_ai-rounded-full ringg_ai-text-gray-500 hover:ringg_ai-text-gray-700",children:F.jsx(t3,{size:16})}),F.jsx(lK,{open:q,onOpenChange:ht,containerRef:ue,children:F.jsxs(uK,{"data-ringg":"end-call-dialog",children:[F.jsxs(cK,{"data-ringg":"end-call-dialog-header",children:[F.jsxs(dK,{"data-ringg":"end-call-dialog-title",children:["Are you sure you want to end ",De==="text"?"chat":"call","?"]}),F.jsx(fK,{"data-ringg":"end-call-dialog-description",children:"Your current conversation will be closed and cannot be accessed later."})]}),F.jsxs(hK,{"data-ringg":"end-call-dialog-footer",children:[F.jsx(Fv,{"data-ringg":"end-call-cancel",variant:"outline",size:"sm",onClick:()=>ht(!1),style:{borderRadius:te,borderColor:re.borderColor,backgroundColor:re.surfaceColor,color:re.textColor},children:"Cancel"}),F.jsxs(Fv,{"data-ringg":"end-call-confirm",size:"sm",onClick:bi,style:{borderRadius:te,...gi(re.primaryColor),color:re.primaryTextColor},children:["End ",De==="text"?"Chat":"Call"]})]})]})}),mt.showFeedback?F.jsx($te,{callMode:De,isSubmitting:ee,feedbackScreenConfig:L,messages:ut,title:l,logoUrl:U,logoStyles:I,onSubmit:Ro,onSkip:Ao}):F.jsx("div",{"data-ringg":"widget-body",className:"ringg_ai-flex ringg_ai-h-full ringg_ai-flex-col",children:F.jsxs("div",{"data-ringg":"widget-panel",className:Nn("ringg_ai-relative ringg_ai-h-full ringg_ai-mb-2 ringg_ai-flex ringg_ai-flex-col",wt?"ringg_ai-p-2 ringg_ai-gap-2.5":"ringg_ai-p-5 ringg_ai-gap-3"),children:[F.jsx(p4,{isCalling:wt,isLoading:ee,title:l,description:c,logoUrl:U,logoStyles:I}),ma&&F.jsx("div",{"data-ringg":"voice-animation-wrapper",className:Nn("ringg_ai-flex ringg_ai-w-full ringg_ai-items-stretch ringg_ai-justify-center",es&&ut.length>0?"ringg_ai-mt-14 ringg_ai-h-14 ringg_ai-flex-shrink-0":"ringg_ai-mt-14 ringg_ai-flex-1 ringg_ai-min-h-0"),children:F.jsx(gK,{className:"ringg_ai-flex-1",localTrack:tl,remoteTrack:ts})}),wt&&!ma&&(ut.length===0&&!jt||!es)&&F.jsx("div",{"data-ringg":"body-spacer",className:"ringg_ai-mt-14 ringg_ai-h-full"}),(ut.length>0||jt)&&wt&&es&&F.jsx("div",{"data-ringg":"transcript","data-scrollable":"true",ref:J,className:"ringg_ai-h-full ringg_ai-overflow-y-auto ringg_ai-flex ringg_ai-flex-col",children:F.jsxs("div",{"data-ringg":"transcript-list",className:Nn("ringg_ai-mt-auto md:ringg_ai-mt-0 ringg_ai-flex ringg_ai-flex-col ringg_ai-gap-3",!ma&&"ringg_ai-pt-12",!Ri&&"ringg_ai-pb-14"),children:[ut.sort((Te,Ee)=>Te.timestamp-Ee.timestamp).map((Te,Ee)=>{var ln;if(Te.kind==="system")return F.jsx(Ane,{label:Te.message,meta:Te.systemMeta,level:Te.systemLevel},`sys_${Te.timestamp}_${Ee}`);const Xe=ut[Ee-1],Et=ut[Ee+1],rt=k5(Te)&&x5(Xe);return x5(Te)&&k5(Et)?null:rt?((ln=Te.componentData)==null?void 0:ln.component_type)==="buttons"&&Te.componentData.data.completionDisplay==="selected_item"&&Kn.has(Te.componentData.component_id)?F.jsx(NC,{itemIndex:Ee,message:Xe},`message_with_buttons_${Te.componentData.component_id}_${Ee}`):F.jsxs(H.Fragment,{children:[F.jsx(NC,{itemIndex:Ee,message:Xe}),F.jsx("div",{"data-ringg":"attached-buttons",className:"ringg_ai-w-full",children:F.jsx(C5,{initialComponent:Te.componentData,onApiCall:cr,onComplete:()=>st(Te.componentData.component_id),onSendResponse:Kt,onSelectionDisplayed:vn,quickReplyAlign:Ri?"center":"end"})})]},`message_with_buttons_${Te.componentData.component_id}_${Ee}`):Te.componentType==="disease_data"&&Te.componentData?F.jsx(gne,{label:Te.componentData.label,onSearch:hn,onSubmit:Qt=>Sn(Te.componentData.component_id,Qt)},`widget_${Te.componentData.component_id}_${Ee}`):Te.componentType&&Te.componentData?Te.componentData.component_type==="buttons"&&Te.componentData.data.completionDisplay==="selected_item"&&Kn.has(Te.componentData.component_id)?null:F.jsx(C5,{initialComponent:Te.componentData,onApiCall:cr,onComplete:()=>st(Te.componentData.component_id),onSendResponse:Kt,onSelectionDisplayed:vn,quickReplyAlign:Ri?"center":"end"},`flow_${Te.componentData.component_id}_${Ee}`):F.jsx(NC,{itemIndex:Ee,message:Te},`${Te.timestamp}__${Ee}`)}),jt&&F.jsx(lne,{})]})}),wt&&De==="text"?F.jsxs("div",{"data-ringg":"controls-bar",className:"ringg_ai-absolute ringg_ai-z-10 ringg_ai-bottom-0 ringg_ai-left-0 ringg_ai-w-full ringg_ai-p-2",children:[At.hasError&&F.jsx("div",{"data-ringg":"error-message",className:"ringg_ai-text-center ringg_ai-text-sm ringg_ai-text-red-500 ringg_ai-mb-2",children:At.message}),F.jsx(f4,{buttonConfig:v,callMode:De,isCalling:wt,enabledSlashCommands:ks,onSlashCommand:Pr,onUserMessage:qe,onCallEnd:bi})]}):F.jsxs(F.Fragment,{children:[F.jsx(f4,{buttonConfig:v,callMode:De,isCalling:wt,enabledSlashCommands:ks,onSlashCommand:Pr,onUserMessage:qe,onCallEnd:bi}),At.hasError&&F.jsx("div",{"data-ringg":"error-message",className:"ringg_ai-text-center ringg_ai-text-sm ringg_ai-text-red-500 -ringg_ai-mt-3 -ringg_ai-mb-2",children:At.message})]}),!wt&&ee&&F.jsxs("div",{"data-ringg":"connecting-status",className:"ringg_ai-flex ringg_ai-flex-col",children:[F.jsx("p",{"data-ringg":"connecting-label",className:"ringg_ai-text-[13px] ringg_ai-text-center",style:{color:re.mutedTextColor},children:"Connecting..."}),F.jsx(sne,{ariaLabel:De==="text"?"Starting chat":"Connecting"})]}),!ee&&Mt==="disconnected"&&(!R||At.hasError)&&(w?F.jsx(P_,{callMode:De,buttonConfig:v,isCalling:wt,isLoading:ee,onCallTrigger:Fr}):F.jsxs("div",{"data-ringg":"start-actions",className:"ringg_ai-flex ringg_ai-w-full ringg_ai-items-center ringg_ai-gap-2 ringg_ai-px-6",children:[F.jsx(P_,{dual:!0,callMode:"text",buttonConfig:v,isCalling:wt,isLoading:ee,onCallTrigger:Fr}),F.jsx(P_,{dual:!0,callMode:"audio",buttonConfig:v,isCalling:wt,isLoading:ee,onCallTrigger:Fr})]})),!wt&&F.jsx("p",{"data-ringg":"legal-disclaimer",className:"ringg_ai-text-[11px] ringg_ai-leading-[1.7] ringg_ai-text-center",style:{color:re.mutedTextColor},children:B?Ene(B.text,B.links):F.jsxs(F.Fragment,{children:["By continuing, you agree to our",F.jsx("br",{}),F.jsx("a",{"data-ringg":"legal-link-privacy",target:"_blank",rel:"noopener noreferrer",className:"ringg_ai-underline ringg_ai-underline-offset-2",style:{color:On(re.primaryColor)},href:"https://www.ringg.ai/privacy",children:"Privacy Policy"})," and ",F.jsx("a",{"data-ringg":"legal-link-terms",target:"_blank",rel:"noopener noreferrer",className:"ringg_ai-underline ringg_ai-underline-offset-2",style:{color:On(re.primaryColor)},href:"https://www.ringg.ai/terms",children:"T&C"}),"."]})})]})})]},"chat-widget")]}),F.jsx(j7,{}),!1]})},Ine=({config:t})=>{const[e]=H.useState(()=>new np({dynacast:!0,adaptiveStream:!0}));return F.jsx(l1.Provider,{value:e,children:F.jsx(Mne,{config:t,room:e})})};function Nne(){if(typeof document>"u")return;const t=document.currentScript;if(t!=null&&t.src)return t.src;const e=document.getElementsByTagName("script");for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(r.src&&/dv-agent\.(es|umd)\.js/.test(r.src))return r.src}}const T5="ringg_ai_brand_font";if(typeof document<"u"&&!document.getElementById(T5)){const t=Nne();if(t){const e=new URL("./Automat-Grotesk-Variable-Roman.woff2",t).href,n=document.createElement("style");n.id=T5,n.textContent=`@font-face{font-family:"Automat Grotesk";src:url("${e}") format("woff2");font-weight:100 900;font-style:normal;font-display:swap;}`,document.head.appendChild(n)}}{const t="ringg_ai_container";(function(e,n){function r(a){let s=n.getElementById(t);s||(s=n.createElement("div"),s.id=t,n.body.appendChild(s)),kg.createRoot(s).render(F.jsx(ir.StrictMode,{children:F.jsx(Ine,{config:a})}))}e.loadAgent=r})(window,document)}});
|