@freeday-ai/webchat 2025.11.0-4.7.7.9962 → 2025.11.0-5.12.5.10993

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.
@@ -327,4 +327,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
327
327
  `))+1))}const s="#".repeat(o),u=n.enter("headingAtx"),A=n.enter("phrasing");i.move(s+" ");let p=n.containerPhrasing(a,{before:"# ",after:`
328
328
  `,...i.current()});return/^[\t ]/.test(p)&&(p=Ui(p.charCodeAt(0))+p.slice(1)),p=p?s+" "+p:s,n.options.closeAtx&&(p+=" "+s),A(),u(),p}m21.peek=Yu2;function m21(a){return a.value||""}function Yu2(){return"<"}u21.peek=Ku2;function u21(a,t,n,l){const o=Gh0(n),i=o==='"'?"Quote":"Apostrophe",s=n.enter("image");let u=n.enter("label");const A=n.createTracker(l);let p=A.move("![");return p+=A.move(n.safe(a.alt,{before:p,after:"]",...A.current()})),p+=A.move("]("),u(),!a.url&&a.title||/[\0- \u007F]/.test(a.url)?(u=n.enter("destinationLiteral"),p+=A.move("<"),p+=A.move(n.safe(a.url,{before:p,after:">",...A.current()})),p+=A.move(">")):(u=n.enter("destinationRaw"),p+=A.move(n.safe(a.url,{before:p,after:a.title?" ":")",...A.current()}))),u(),a.title&&(u=n.enter(`title${i}`),p+=A.move(" "+o),p+=A.move(n.safe(a.title,{before:p,after:o,...A.current()})),p+=A.move(o),u()),p+=A.move(")"),s(),p}function Ku2(){return"!"}h21.peek=Xu2;function h21(a,t,n,l){const o=a.referenceType,i=n.enter("imageReference");let s=n.enter("label");const u=n.createTracker(l);let A=u.move("![");const p=n.safe(a.alt,{before:A,after:"]",...u.current()});A+=u.move(p+"]["),s();const g=n.stack;n.stack=[],s=n.enter("reference");const V=n.safe(n.associationId(a),{before:A,after:"]",...u.current()});return s(),n.stack=g,i(),o==="full"||!p||p!==V?A+=u.move(V+"]"):o==="shortcut"?A=A.slice(0,-1):A+=u.move("]"),A}function Xu2(){return"!"}d21.peek=Qu2;function d21(a,t,n){let l=a.value||"",o="`",i=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(l);)o+="`";for(/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^`|`$/.test(l))&&(l=" "+l+" ");++i<n.unsafe.length;){const s=n.unsafe[i],u=n.compilePattern(s);let A;if(s.atBreak)for(;A=u.exec(l);){let p=A.index;l.charCodeAt(p)===10&&l.charCodeAt(p-1)===13&&p--,l=l.slice(0,p)+" "+l.slice(A.index+1)}}return o+l+o}function Qu2(){return"`"}function A21(a,t){const n=nh0(a);return!!(!t.options.resourceLink&&a.url&&!a.title&&a.children&&a.children.length===1&&a.children[0].type==="text"&&(n===a.url||"mailto:"+n===a.url)&&/^[a-z][a-z+.-]+:/i.test(a.url)&&!/[\0- <>\u007F]/.test(a.url))}p21.peek=Ju2;function p21(a,t,n,l){const o=Gh0(n),i=o==='"'?"Quote":"Apostrophe",s=n.createTracker(l);let u,A;if(A21(a,n)){const g=n.stack;n.stack=[],u=n.enter("autolink");let V=s.move("<");return V+=s.move(n.containerPhrasing(a,{before:V,after:">",...s.current()})),V+=s.move(">"),u(),n.stack=g,V}u=n.enter("link"),A=n.enter("label");let p=s.move("[");return p+=s.move(n.containerPhrasing(a,{before:p,after:"](",...s.current()})),p+=s.move("]("),A(),!a.url&&a.title||/[\0- \u007F]/.test(a.url)?(A=n.enter("destinationLiteral"),p+=s.move("<"),p+=s.move(n.safe(a.url,{before:p,after:">",...s.current()})),p+=s.move(">")):(A=n.enter("destinationRaw"),p+=s.move(n.safe(a.url,{before:p,after:a.title?" ":")",...s.current()}))),A(),a.title&&(A=n.enter(`title${i}`),p+=s.move(" "+o),p+=s.move(n.safe(a.title,{before:p,after:o,...s.current()})),p+=s.move(o),A()),p+=s.move(")"),u(),p}function Ju2(a,t,n){return A21(a,n)?"<":"["}f21.peek=eh2;function f21(a,t,n,l){const o=a.referenceType,i=n.enter("linkReference");let s=n.enter("label");const u=n.createTracker(l);let A=u.move("[");const p=n.containerPhrasing(a,{before:A,after:"]",...u.current()});A+=u.move(p+"]["),s();const g=n.stack;n.stack=[],s=n.enter("reference");const V=n.safe(n.associationId(a),{before:A,after:"]",...u.current()});return s(),n.stack=g,i(),o==="full"||!p||p!==V?A+=u.move(V+"]"):o==="shortcut"?A=A.slice(0,-1):A+=u.move("]"),A}function eh2(){return"["}function Yh0(a){const t=a.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function ah2(a){const t=Yh0(a),n=a.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function th2(a){const t=a.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Z21(a){const t=a.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function nh2(a,t,n,l){const o=n.enter("list"),i=n.bulletCurrent;let s=a.ordered?th2(n):Yh0(n);const u=a.ordered?s==="."?")":".":ah2(n);let A=t&&n.bulletLastUsed?s===n.bulletLastUsed:!1;if(!a.ordered){const g=a.children?a.children[0]:void 0;if((s==="*"||s==="-")&&g&&(!g.children||!g.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&&(A=!0),Z21(n)===s&&g){let V=-1;for(;++V<a.children.length;){const v=a.children[V];if(v&&v.type==="listItem"&&v.children&&v.children[0]&&v.children[0].type==="thematicBreak"){A=!0;break}}}}A&&(s=u),n.bulletCurrent=s;const p=n.containerFlow(a,l);return n.bulletLastUsed=s,n.bulletCurrent=i,o(),p}function lh2(a){const t=a.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function rh2(a,t,n,l){const o=lh2(n);let i=n.bulletCurrent||Yh0(n);t&&t.type==="list"&&t.ordered&&(i=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(a))+i);let s=i.length+1;(o==="tab"||o==="mixed"&&(t&&t.type==="list"&&t.spread||a.spread))&&(s=Math.ceil(s/4)*4);const u=n.createTracker(l);u.move(i+" ".repeat(s-i.length)),u.shift(s);const A=n.enter("listItem"),p=n.indentLines(n.containerFlow(a,u.current()),g);return A(),p;function g(V,v,L){return v?(L?"":" ".repeat(s))+V:(L?i:i+" ".repeat(s-i.length))+V}}function oh2(a,t,n,l){const o=n.enter("paragraph"),i=n.enter("phrasing"),s=n.containerPhrasing(a,l);return i(),o(),s}const ch2=Bd(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function ih2(a,t,n,l){return(a.children.some(function(s){return ch2(s)})?n.containerPhrasing:n.containerFlow).call(n,a,l)}function sh2(a){const t=a.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}H21.peek=mh2;function H21(a,t,n,l){const o=sh2(n),i=n.enter("strong"),s=n.createTracker(l),u=s.move(o+o);let A=s.move(n.containerPhrasing(a,{after:o,before:u,...s.current()}));const p=A.charCodeAt(0),g=tA(l.before.charCodeAt(l.before.length-1),p,o);g.inside&&(A=Ui(p)+A.slice(1));const V=A.charCodeAt(A.length-1),v=tA(l.after.charCodeAt(0),V,o);v.inside&&(A=A.slice(0,-1)+Ui(V));const L=s.move(o+o);return i(),n.attentionEncodeSurroundingInfo={after:v.outside,before:g.outside},u+A+L}function mh2(a,t,n){return n.options.strong||"*"}function uh2(a,t,n,l){return n.safe(a.value,l)}function hh2(a){const t=a.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function dh2(a,t,n){const l=(Z21(n)+(n.options.ruleSpaces?" ":"")).repeat(hh2(n));return n.options.ruleSpaces?l.slice(0,-1):l}const g21={blockquote:$u2,break:i21,code:Bu2,definition:zu2,emphasis:s21,hardBreak:i21,heading:Gu2,html:m21,image:u21,imageReference:h21,inlineCode:d21,link:p21,linkReference:f21,list:nh2,listItem:rh2,paragraph:oh2,root:ih2,strong:H21,text:uh2,thematicBreak:dh2};function Ah2(){return{enter:{table:ph2,tableData:E21,tableHeader:E21,tableRow:Zh2},exit:{codeText:Hh2,table:fh2,tableData:Kh0,tableHeader:Kh0,tableRow:Kh0}}}function ph2(a){const t=a._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},a),this.data.inTable=!0}function fh2(a){this.exit(a),this.data.inTable=void 0}function Zh2(a){this.enter({type:"tableRow",children:[]},a)}function Kh0(a){this.exit(a)}function E21(a){this.enter({type:"tableCell",children:[]},a)}function Hh2(a){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,gh2));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(a)}function gh2(a,t){return t==="|"?t:a}function Eh2(a){const t=a||{},n=t.tableCellPadding,l=t.tablePipeAlign,o=t.stringLength,i=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
329
329
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:v,table:s,tableCell:A,tableRow:u}};function s(L,b,I,T){return p(g(L,I,T),L.align)}function u(L,b,I,T){const N=V(L,I,T),P=p([N]);return P.slice(0,P.indexOf(`
330
- `))}function A(L,b,I,T){const N=I.enter("tableCell"),P=I.enter("phrasing"),B=I.containerPhrasing(L,{...T,before:i,after:i});return P(),N(),B}function p(L,b){return xu2(L,{align:b,alignDelimiters:l,padding:n,stringLength:o})}function g(L,b,I){const T=L.children;let N=-1;const P=[],B=b.enter("table");for(;++N<T.length;)P[N]=V(T[N],b,I);return B(),P}function V(L,b,I){const T=L.children;let N=-1;const P=[],B=b.enter("tableRow");for(;++N<T.length;)P[N]=A(T[N],L,b,I);return B(),P}function v(L,b,I){let T=g21.inlineCode(L,b,I);return I.stack.includes("tableCell")&&(T=T.replace(/\|/g,"\\$&")),T}}function Vh2(){return{exit:{taskListCheckValueChecked:V21,taskListCheckValueUnchecked:V21,paragraph:vh2}}}function Mh2(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Lh2}}}function V21(a){const t=this.stack[this.stack.length-2];t.type,t.checked=a.type==="taskListCheckValueChecked"}function vh2(a){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const l=n.children[0];if(l&&l.type==="text"){const o=t.children;let i=-1,s;for(;++i<o.length;){const u=o[i];if(u.type==="paragraph"){s=u;break}}s===n&&(l.value=l.value.slice(1),l.value.length===0?n.children.shift():n.position&&l.position&&typeof l.position.start.offset=="number"&&(l.position.start.column++,l.position.start.offset++,n.position.start=Object.assign({},l.position.start)))}}this.exit(a)}function Lh2(a,t,n,l){const o=a.children[0],i=typeof a.checked=="boolean"&&o&&o.type==="paragraph",s="["+(a.checked?"x":" ")+"] ",u=n.createTracker(l);i&&u.move(s);let A=g21.listItem(a,t,n,{...l,...u.current()});return i&&(A=A.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,p)),A;function p(g){return g+s}}function wh2(){return[nu2(),Lu2(),Cu2(),Ah2(),Vh2()]}function yh2(a){return{extensions:[lu2(),wu2(a),bu2(),Eh2(a),Mh2()]}}const Fh2={tokenize:Th2,partial:!0},M21={tokenize:xh2,partial:!0},v21={tokenize:Nh2,partial:!0},L21={tokenize:$h2,partial:!0},Ch2={tokenize:kh2,partial:!0},w21={name:"wwwAutolink",tokenize:Sh2,previous:F21},y21={name:"protocolAutolink",tokenize:Rh2,previous:C21},z3={name:"emailAutolink",tokenize:Ih2,previous:b21},Bt={};function bh2(){return{text:Bt}}let jr=48;for(;jr<123;)Bt[jr]=z3,jr++,jr===58?jr=65:jr===91&&(jr=97);Bt[43]=z3,Bt[45]=z3,Bt[46]=z3,Bt[95]=z3,Bt[72]=[z3,y21],Bt[104]=[z3,y21],Bt[87]=[z3,w21],Bt[119]=[z3,w21];function Ih2(a,t,n){const l=this;let o,i;return s;function s(V){return!Xh0(V)||!b21.call(l,l.previous)||Qh0(l.events)?n(V):(a.enter("literalAutolink"),a.enter("literalAutolinkEmail"),u(V))}function u(V){return Xh0(V)?(a.consume(V),u):V===64?(a.consume(V),A):n(V)}function A(V){return V===46?a.check(Ch2,g,p)(V):V===45||V===95||Ie(V)?(i=!0,a.consume(V),A):g(V)}function p(V){return a.consume(V),o=!0,A}function g(V){return i&&o&&Qe(l.previous)?(a.exit("literalAutolinkEmail"),a.exit("literalAutolink"),t(V)):n(V)}}function Sh2(a,t,n){const l=this;return o;function o(s){return s!==87&&s!==119||!F21.call(l,l.previous)||Qh0(l.events)?n(s):(a.enter("literalAutolink"),a.enter("literalAutolinkWww"),a.check(Fh2,a.attempt(M21,a.attempt(v21,i),n),n)(s))}function i(s){return a.exit("literalAutolinkWww"),a.exit("literalAutolink"),t(s)}}function Rh2(a,t,n){const l=this;let o="",i=!1;return s;function s(V){return(V===72||V===104)&&C21.call(l,l.previous)&&!Qh0(l.events)?(a.enter("literalAutolink"),a.enter("literalAutolinkHttp"),o+=String.fromCodePoint(V),a.consume(V),u):n(V)}function u(V){if(Qe(V)&&o.length<5)return o+=String.fromCodePoint(V),a.consume(V),u;if(V===58){const v=o.toLowerCase();if(v==="http"||v==="https")return a.consume(V),A}return n(V)}function A(V){return V===47?(a.consume(V),i?p:(i=!0,A)):n(V)}function p(V){return V===null||xd(V)||M8(V)||Or(V)||Nd(V)?n(V):a.attempt(M21,a.attempt(v21,g),n)(V)}function g(V){return a.exit("literalAutolinkHttp"),a.exit("literalAutolink"),t(V)}}function Th2(a,t,n){let l=0;return o;function o(s){return(s===87||s===119)&&l<3?(l++,a.consume(s),o):s===46&&l===3?(a.consume(s),i):n(s)}function i(s){return s===null?n(s):t(s)}}function xh2(a,t,n){let l,o,i;return s;function s(p){return p===46||p===95?a.check(L21,A,u)(p):p===null||M8(p)||Or(p)||p!==45&&Nd(p)?A(p):(i=!0,a.consume(p),s)}function u(p){return p===95?l=!0:(o=l,l=void 0),a.consume(p),s}function A(p){return o||l||!i?n(p):t(p)}}function Nh2(a,t){let n=0,l=0;return o;function o(s){return s===40?(n++,a.consume(s),o):s===41&&l<n?i(s):s===33||s===34||s===38||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===60||s===63||s===93||s===95||s===126?a.check(L21,t,i)(s):s===null||M8(s)||Or(s)?t(s):(a.consume(s),o)}function i(s){return s===41&&l++,a.consume(s),o}}function $h2(a,t,n){return l;function l(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(a.consume(u),l):u===38?(a.consume(u),i):u===93?(a.consume(u),o):u===60||u===null||M8(u)||Or(u)?t(u):n(u)}function o(u){return u===null||u===40||u===91||M8(u)||Or(u)?t(u):l(u)}function i(u){return Qe(u)?s(u):n(u)}function s(u){return u===59?(a.consume(u),l):Qe(u)?(a.consume(u),s):n(u)}}function kh2(a,t,n){return l;function l(i){return a.consume(i),o}function o(i){return Ie(i)?n(i):t(i)}}function F21(a){return a===null||a===40||a===42||a===95||a===91||a===93||a===126||M8(a)}function C21(a){return!Qe(a)}function b21(a){return!(a===47||Xh0(a))}function Xh0(a){return a===43||a===45||a===46||a===95||Ie(a)}function Qh0(a){let t=a.length,n=!1;for(;t--;){const l=a[t][1];if((l.type==="labelLink"||l.type==="labelImage")&&!l._balanced){n=!0;break}if(l._gfmAutolinkLiteralWalkedInto){n=!1;break}}return a.length>0&&!n&&(a[a.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Dh2={tokenize:qh2,partial:!0};function Ph2(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Uh2,continuation:{tokenize:zh2},exit:jh2}},text:{91:{name:"gfmFootnoteCall",tokenize:Bh2},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Oh2,resolveTo:_h2}}}}function Oh2(a,t,n){const l=this;let o=l.events.length;const i=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let s;for(;o--;){const A=l.events[o][1];if(A.type==="labelImage"){s=A;break}if(A.type==="gfmFootnoteCall"||A.type==="labelLink"||A.type==="label"||A.type==="image"||A.type==="link")break}return u;function u(A){if(!s||!s._balanced)return n(A);const p=Ya(l.sliceSerialize({start:s.end,end:l.now()}));return p.codePointAt(0)!==94||!i.includes(p.slice(1))?n(A):(a.enter("gfmFootnoteCallLabelMarker"),a.consume(A),a.exit("gfmFootnoteCallLabelMarker"),t(A))}}function _h2(a,t){let n=a.length;for(;n--;)if(a[n][1].type==="labelImage"&&a[n][0]==="enter"){a[n][1];break}a[n+1][1].type="data",a[n+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},a[n+3][1].start),end:Object.assign({},a[a.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},a[n+3][1].end),end:Object.assign({},a[n+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const i={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},a[a.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},u=[a[n+1],a[n+2],["enter",l,t],a[n+3],a[n+4],["enter",o,t],["exit",o,t],["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t],a[a.length-2],a[a.length-1],["exit",l,t]];return a.splice(n,a.length-n+1,...u),a}function Bh2(a,t,n){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let i=0,s;return u;function u(V){return a.enter("gfmFootnoteCall"),a.enter("gfmFootnoteCallLabelMarker"),a.consume(V),a.exit("gfmFootnoteCallLabelMarker"),A}function A(V){return V!==94?n(V):(a.enter("gfmFootnoteCallMarker"),a.consume(V),a.exit("gfmFootnoteCallMarker"),a.enter("gfmFootnoteCallString"),a.enter("chunkString").contentType="string",p)}function p(V){if(i>999||V===93&&!s||V===null||V===91||M8(V))return n(V);if(V===93){a.exit("chunkString");const v=a.exit("gfmFootnoteCallString");return o.includes(Ya(l.sliceSerialize(v)))?(a.enter("gfmFootnoteCallLabelMarker"),a.consume(V),a.exit("gfmFootnoteCallLabelMarker"),a.exit("gfmFootnoteCall"),t):n(V)}return M8(V)||(s=!0),i++,a.consume(V),V===92?g:p}function g(V){return V===91||V===92||V===93?(a.consume(V),i++,p):p(V)}}function Uh2(a,t,n){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let i,s=0,u;return A;function A(b){return a.enter("gfmFootnoteDefinition")._container=!0,a.enter("gfmFootnoteDefinitionLabel"),a.enter("gfmFootnoteDefinitionLabelMarker"),a.consume(b),a.exit("gfmFootnoteDefinitionLabelMarker"),p}function p(b){return b===94?(a.enter("gfmFootnoteDefinitionMarker"),a.consume(b),a.exit("gfmFootnoteDefinitionMarker"),a.enter("gfmFootnoteDefinitionLabelString"),a.enter("chunkString").contentType="string",g):n(b)}function g(b){if(s>999||b===93&&!u||b===null||b===91||M8(b))return n(b);if(b===93){a.exit("chunkString");const I=a.exit("gfmFootnoteDefinitionLabelString");return i=Ya(l.sliceSerialize(I)),a.enter("gfmFootnoteDefinitionLabelMarker"),a.consume(b),a.exit("gfmFootnoteDefinitionLabelMarker"),a.exit("gfmFootnoteDefinitionLabel"),v}return M8(b)||(u=!0),s++,a.consume(b),b===92?V:g}function V(b){return b===91||b===92||b===93?(a.consume(b),s++,g):g(b)}function v(b){return b===58?(a.enter("definitionMarker"),a.consume(b),a.exit("definitionMarker"),o.includes(i)||o.push(i),G2(a,L,"gfmFootnoteDefinitionWhitespace")):n(b)}function L(b){return t(b)}}function zh2(a,t,n){return a.check(wi,t,a.attempt(Dh2,t,n))}function jh2(a){a.exit("gfmFootnoteDefinition")}function qh2(a,t,n){const l=this;return G2(a,o,"gfmFootnoteDefinitionIndent",5);function o(i){const s=l.events[l.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?t(i):n(i)}}function Wh2(a){let n=(a||{}).singleTilde;const l={name:"strikethrough",tokenize:i,resolveAll:o};return n==null&&(n=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function o(s,u){let A=-1;for(;++A<s.length;)if(s[A][0]==="enter"&&s[A][1].type==="strikethroughSequenceTemporary"&&s[A][1]._close){let p=A;for(;p--;)if(s[p][0]==="exit"&&s[p][1].type==="strikethroughSequenceTemporary"&&s[p][1]._open&&s[A][1].end.offset-s[A][1].start.offset===s[p][1].end.offset-s[p][1].start.offset){s[A][1].type="strikethroughSequence",s[p][1].type="strikethroughSequence";const g={type:"strikethrough",start:Object.assign({},s[p][1].start),end:Object.assign({},s[A][1].end)},V={type:"strikethroughText",start:Object.assign({},s[p][1].end),end:Object.assign({},s[A][1].start)},v=[["enter",g,u],["enter",s[p][1],u],["exit",s[p][1],u],["enter",V,u]],L=u.parser.constructs.insideSpan.null;L&&W4(v,v.length,0,$d(L,s.slice(p+1,A),u)),W4(v,v.length,0,[["exit",V,u],["enter",s[A][1],u],["exit",s[A][1],u],["exit",g,u]]),W4(s,p-1,A-p+3,v),A=p+v.length-2;break}}for(A=-1;++A<s.length;)s[A][1].type==="strikethroughSequenceTemporary"&&(s[A][1].type="data");return s}function i(s,u,A){const p=this.previous,g=this.events;let V=0;return v;function v(b){return p===126&&g[g.length-1][1].type!=="characterEscape"?A(b):(s.enter("strikethroughSequenceTemporary"),L(b))}function L(b){const I=n9(p);if(b===126)return V>1?A(b):(s.consume(b),V++,L);if(V<2&&!n)return A(b);const T=s.exit("strikethroughSequenceTemporary"),N=n9(b);return T._open=!N||N===2&&!!I,T._close=!I||I===2&&!!N,u(b)}}}class Gh2{constructor(){this.map=[]}add(t,n,l){Yh2(this,t,n,l)}consume(t){if(this.map.sort(function(i,s){return i[0]-s[0]}),this.map.length===0)return;let n=this.map.length;const l=[];for(;n>0;)n-=1,l.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];l.push(t.slice()),t.length=0;let o=l.pop();for(;o;){for(const i of o)t.push(i);o=l.pop()}this.map.length=0}}function Yh2(a,t,n,l){let o=0;if(!(n===0&&l.length===0)){for(;o<a.map.length;){if(a.map[o][0]===t){a.map[o][1]+=n,a.map[o][2].push(...l);return}o+=1}a.map.push([t,n,l])}}function Kh2(a,t){let n=!1;const l=[];for(;t<a.length;){const o=a[t];if(n){if(o[0]==="enter")o[1].type==="tableContent"&&l.push(a[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(a[t-1][1].type==="tableDelimiterMarker"){const i=l.length-1;l[i]=l[i]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return l}function Xh2(){return{flow:{null:{name:"table",tokenize:Qh2,resolveAll:Jh2}}}}function Qh2(a,t,n){const l=this;let o=0,i=0,s;return u;function u(Q){let H0=l.events.length-1;for(;H0>-1;){const m0=l.events[H0][1].type;if(m0==="lineEnding"||m0==="linePrefix")H0--;else break}const o0=H0>-1?l.events[H0][1].type:null,n0=o0==="tableHead"||o0==="tableRow"?j:A;return n0===j&&l.parser.lazy[l.now().line]?n(Q):n0(Q)}function A(Q){return a.enter("tableHead"),a.enter("tableRow"),p(Q)}function p(Q){return Q===124||(s=!0,i+=1),g(Q)}function g(Q){return Q===null?n(Q):X1(Q)?i>1?(i=0,l.interrupt=!0,a.exit("tableRow"),a.enter("lineEnding"),a.consume(Q),a.exit("lineEnding"),L):n(Q):P2(Q)?G2(a,g,"whitespace")(Q):(i+=1,s&&(s=!1,o+=1),Q===124?(a.enter("tableCellDivider"),a.consume(Q),a.exit("tableCellDivider"),s=!0,g):(a.enter("data"),V(Q)))}function V(Q){return Q===null||Q===124||M8(Q)?(a.exit("data"),g(Q)):(a.consume(Q),Q===92?v:V)}function v(Q){return Q===92||Q===124?(a.consume(Q),V):V(Q)}function L(Q){return l.interrupt=!1,l.parser.lazy[l.now().line]?n(Q):(a.enter("tableDelimiterRow"),s=!1,P2(Q)?G2(a,b,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Q):b(Q))}function b(Q){return Q===45||Q===58?T(Q):Q===124?(s=!0,a.enter("tableCellDivider"),a.consume(Q),a.exit("tableCellDivider"),I):Y(Q)}function I(Q){return P2(Q)?G2(a,T,"whitespace")(Q):T(Q)}function T(Q){return Q===58?(i+=1,s=!0,a.enter("tableDelimiterMarker"),a.consume(Q),a.exit("tableDelimiterMarker"),N):Q===45?(i+=1,N(Q)):Q===null||X1(Q)?q(Q):Y(Q)}function N(Q){return Q===45?(a.enter("tableDelimiterFiller"),P(Q)):Y(Q)}function P(Q){return Q===45?(a.consume(Q),P):Q===58?(s=!0,a.exit("tableDelimiterFiller"),a.enter("tableDelimiterMarker"),a.consume(Q),a.exit("tableDelimiterMarker"),B):(a.exit("tableDelimiterFiller"),B(Q))}function B(Q){return P2(Q)?G2(a,q,"whitespace")(Q):q(Q)}function q(Q){return Q===124?b(Q):Q===null||X1(Q)?!s||o!==i?Y(Q):(a.exit("tableDelimiterRow"),a.exit("tableHead"),t(Q)):Y(Q)}function Y(Q){return n(Q)}function j(Q){return a.enter("tableRow"),G(Q)}function G(Q){return Q===124?(a.enter("tableCellDivider"),a.consume(Q),a.exit("tableCellDivider"),G):Q===null||X1(Q)?(a.exit("tableRow"),t(Q)):P2(Q)?G2(a,G,"whitespace")(Q):(a.enter("data"),J(Q))}function J(Q){return Q===null||Q===124||M8(Q)?(a.exit("data"),G(Q)):(a.consume(Q),Q===92?Z0:J)}function Z0(Q){return Q===92||Q===124?(a.consume(Q),J):J(Q)}}function Jh2(a,t){let n=-1,l=!0,o=0,i=[0,0,0,0],s=[0,0,0,0],u=!1,A=0,p,g,V;const v=new Gh2;for(;++n<a.length;){const L=a[n],b=L[1];L[0]==="enter"?b.type==="tableHead"?(u=!1,A!==0&&(I21(v,t,A,p,g),g=void 0,A=0),p={type:"table",start:Object.assign({},b.start),end:Object.assign({},b.end)},v.add(n,0,[["enter",p,t]])):b.type==="tableRow"||b.type==="tableDelimiterRow"?(l=!0,V=void 0,i=[0,0,0,0],s=[0,n+1,0,0],u&&(u=!1,g={type:"tableBody",start:Object.assign({},b.start),end:Object.assign({},b.end)},v.add(n,0,[["enter",g,t]])),o=b.type==="tableDelimiterRow"?2:g?3:1):o&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")?(l=!1,s[2]===0&&(i[1]!==0&&(s[0]=s[1],V=nA(v,t,i,o,void 0,V),i=[0,0,0,0]),s[2]=n)):b.type==="tableCellDivider"&&(l?l=!1:(i[1]!==0&&(s[0]=s[1],V=nA(v,t,i,o,void 0,V)),i=s,s=[i[1],n,0,0])):b.type==="tableHead"?(u=!0,A=n):b.type==="tableRow"||b.type==="tableDelimiterRow"?(A=n,i[1]!==0?(s[0]=s[1],V=nA(v,t,i,o,n,V)):s[1]!==0&&(V=nA(v,t,s,o,n,V)),o=0):o&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")&&(s[3]=n)}for(A!==0&&I21(v,t,A,p,g),v.consume(t.events),n=-1;++n<t.events.length;){const L=t.events[n];L[0]==="enter"&&L[1].type==="table"&&(L[1]._align=Kh2(t.events,n))}return a}function nA(a,t,n,l,o,i){const s=l===1?"tableHeader":l===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(i.end=Object.assign({},d9(t.events,n[0])),a.add(n[0],0,[["exit",i,t]]));const A=d9(t.events,n[1]);if(i={type:s,start:Object.assign({},A),end:Object.assign({},A)},a.add(n[1],0,[["enter",i,t]]),n[2]!==0){const p=d9(t.events,n[2]),g=d9(t.events,n[3]),V={type:u,start:Object.assign({},p),end:Object.assign({},g)};if(a.add(n[2],0,[["enter",V,t]]),l!==2){const v=t.events[n[2]],L=t.events[n[3]];if(v[1].end=Object.assign({},L[1].end),v[1].type="chunkText",v[1].contentType="text",n[3]>n[2]+1){const b=n[2]+1,I=n[3]-n[2]-1;a.add(b,I,[])}}a.add(n[3]+1,0,[["exit",V,t]])}return o!==void 0&&(i.end=Object.assign({},d9(t.events,o)),a.add(o,0,[["exit",i,t]]),i=void 0),i}function I21(a,t,n,l,o){const i=[],s=d9(t.events,n);o&&(o.end=Object.assign({},s),i.push(["exit",o,t])),l.end=Object.assign({},s),i.push(["exit",l,t]),a.add(n+1,0,i)}function d9(a,t){const n=a[t],l=n[0]==="enter"?"start":"end";return n[1][l]}const ed2={name:"tasklistCheck",tokenize:td2};function ad2(){return{text:{91:ed2}}}function td2(a,t,n){const l=this;return o;function o(A){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?n(A):(a.enter("taskListCheck"),a.enter("taskListCheckMarker"),a.consume(A),a.exit("taskListCheckMarker"),i)}function i(A){return M8(A)?(a.enter("taskListCheckValueUnchecked"),a.consume(A),a.exit("taskListCheckValueUnchecked"),s):A===88||A===120?(a.enter("taskListCheckValueChecked"),a.consume(A),a.exit("taskListCheckValueChecked"),s):n(A)}function s(A){return A===93?(a.enter("taskListCheckMarker"),a.consume(A),a.exit("taskListCheckMarker"),a.exit("taskListCheck"),u):n(A)}function u(A){return X1(A)?t(A):P2(A)?a.check({tokenize:nd2},t,n)(A):n(A)}}function nd2(a,t,n){return G2(a,l,"whitespace");function l(o){return o===null?n(o):t(o)}}function ld2(a){return YJ0([bh2(),Ph2(),Wh2(a),Xh2(),ad2()])}const rd2={};function od2(a){const t=this,n=a||rd2,l=t.data(),o=l.micromarkExtensions||(l.micromarkExtensions=[]),i=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),s=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);o.push(ld2(n)),i.push(wh2()),s.push(yh2(n))}const cd2=Nu0("relative flex w-full flex-col gap-3",{variants:{variant:{received:"items-start",sent:"items-end"},layout:{user:"",ai:"w-full max-w-full items-center"},isLastInGroup:{true:"",false:""}},defaultVariants:{variant:"received",layout:"user"}}),Jh0=e.forwardRef(({settings:a,className:t,variant:n,isLastInGroup:l,isFirstInGroup:o,sentAt:i,layout:s,children:u,testId:A="",userName:p,...g},V)=>_.jsxs("div",{"data-testid":n=="received"?`chat-message-${A} incoming-message-${A}`:`chat-message-${A} outgoing-message-${A}`,children:[n&&o&&sd2({variant:n,settings:a,userName:p}),_.jsx("div",{className:W2(cd2({variant:n,layout:s,isLastInGroup:l,className:t}),a!=null&&a.avatar?"pl-6":""),ref:V,...g,children:u})]}));Jh0.displayName="Message";const id2=Nu0("p-4",{variants:{variant:{received:"message-received",sent:"message-send"},layout:{default:"",ai:"message-ai"},isLoading:{true:"animate-pulse bg-gray-200",false:""}},defaultVariants:{variant:"received",layout:"default"}}),zi=e.forwardRef(({className:a,variant:t,layout:n,isLoading:l=!1,children:o,...i},s)=>_.jsx("div",{className:W2(id2({variant:t,layout:n,isLoading:l,className:a}),"overflow-x-auto break-words"),ref:s,...i,children:o}));zi.displayName="MessageBubble";const sd2=({variant:a,settings:t,userName:n})=>a!=="received"?null:_.jsxs("div",{className:"mb-1 flex items-center justify-start space-x-1",children:[(t==null?void 0:t.avatar)&&_.jsx("img",{width:48,height:48,className:"mt-1 h-5 w-5 rounded-full",src:t.avatar,alt:"Avatar"}),n&&_.jsx("span",{className:"font-brand text-[11.2px] font-bold leading-[16.8px] text-primary",children:n})]}),md2=({block:a,variant:t,layout:n,isLoading:l})=>_.jsx(zi,{variant:t,layout:n,isLoading:l,className:"prose max-w-[95%] break-words prose-a:text-blue-600",children:_.jsx(P01,{rehypePlugins:[e21],remarkPlugins:[od2],components:{a:ud2},className:"",skipHtml:!0,children:a.content})});function ud2(a){return _.jsx("a",{href:a.href,target:"_blank",children:a.children})}const S21=e.forwardRef(({className:a,...t},n)=>_.jsx("div",{ref:n,className:W2("rounded-lg border bg-card text-card-foreground shadow-sm",a),...t}));S21.displayName="Card";const R21=e.forwardRef(({className:a,...t},n)=>_.jsx("div",{ref:n,className:W2("flex flex-col space-y-1.5 p-6",a),...t}));R21.displayName="CardHeader";const T21=e.forwardRef(({className:a,...t},n)=>_.jsx("h3",{ref:n,className:W2("text-2xl font-semibold leading-none tracking-tight",a),...t}));T21.displayName="CardTitle";const x21=e.forwardRef(({className:a,...t},n)=>_.jsx("p",{ref:n,className:W2("text-sm text-muted-foreground",a),...t}));x21.displayName="CardDescription";const N21=e.forwardRef(({className:a,...t},n)=>_.jsx("div",{ref:n,className:W2("p-6 pt-0",a),...t}));N21.displayName="CardContent";const $21=e.forwardRef(({className:a,...t},n)=>_.jsx("div",{ref:n,className:W2("flex items-center p-6 pt-0",a),...t}));$21.displayName="CardFooter";const hd2=({block:a})=>{const{t}=we("common");return a.sources.some(l=>l.document_metadata&&l.document_metadata.card)?_.jsx("div",{className:"flex w-full max-w-full gap-5 overflow-x-auto",children:a.sources.map(l=>_.jsxs(S21,{"data-url":l.source_link,className:"min-w-[200px] max-w-72 overflow-hidden",children:[_.jsx(R21,{className:"h-full max-h-[120px] p-0",children:_.jsx("img",{className:"h-full w-full object-cover transition duration-300 ease-in-out group-hover:scale-105",src:l.document_metadata.card.image,alt:l.document_metadata.card.title})}),_.jsxs(N21,{className:"p-4",children:[_.jsx(T21,{className:"text-md line-clamp-1 font-bold",children:l.document_metadata.card.title}),l.document_metadata.card.description&&_.jsx(x21,{className:"line-clamp-2 text-sm",children:l.document_metadata.card.description})]}),_.jsx($21,{children:_.jsx("a",{href:l.document_metadata.card.url,target:"_blank",children:_.jsx(da,{variant:"outline",children:l.document_metadata.card.call_to_action_text??t("sourceCallToActionLabel")})})})]},l.id))}):_.jsx(_.Fragment,{})},dd2=({block:a,variant:t,layout:n,isLoading:l})=>_.jsx(zi,{variant:t,layout:n,isLoading:l,className:"max-w-[95%]",children:_.jsx("img",{src:a.url,alt:a.filename})}),k21={markdown:md2,text:({block:a,variant:t,layout:n,isLoading:l})=>_.jsx(zi,{variant:t,layout:n,isLoading:l,className:"prose max-w-[60%]",children:_.jsx("p",{children:a.text})}),button:V0.Fragment,button_group:Xm2,source_group:hd2,image_reference:dd2,conversation_rating:V0.Fragment},Ad2=a=>a in k21,D21=(a,t,n)=>{const l=k21[a.type];return typeof l<"u"?V0.createElement(l,{key:`block-${a.id}`,variant:t,layout:n,block:a}):(console.warn(`No component found for block type: ${a.type}`),null)};function pd2({message:a,handleActionEvent:t,close:n}){return _.jsxs(gd,{className:"sm:max-w-[425px]",children:[_.jsxs(Lu0,{children:[_.jsx(wu0,{children:"Thank you for your response!"}),_.jsx(EQ0,{children:"Can you tell us what went wrong?"})]}),_.jsx(Hd2,{message:a,handleActionEvent:t,close:n})]})}function fd2({message:a,handleActionEvent:t,close:n}){const{t:l}=we(["common","feedback"]),[o,i]=e.useState(""),[s,u]=e.useState(!1),[A,p]=e.useState(!1),g=V=>{V.preventDefault(),u(!0),t("user-feedback-message",{id:a.id,value:o},"input"),i(""),p(!0),setTimeout(()=>{u(!1),setTimeout(n,1500)},1500)};return _.jsxs(Md,{className:"min-h-40 overflow-hidden rounded-t-[20px] border-primary bg-primary text-primary-foreground",children:[_.jsx(T7,{children:_.jsx(ll.div,{layoutId:"underline",children:_.jsx(vd,{className:"",children:A?_.jsx(sJ0,{title:l("feedback:modalSubmittedTitle"),description:l("feedback:modalSubmittedDescription")}):_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsx("div",{className:"relative w-12"}),_.jsxs("div",{className:"text-center",children:[_.jsx(Ai,{className:"text-center",children:l("feedback:modalTitle")}),_.jsx(xu0,{className:"text-primary-foreground/80",children:l("feedback:modalDescription")})]}),_.jsx(Tu0,{className:"w-12",asChild:!0,children:_.jsx(da,{variant:"link",onClick:n,className:"text-right text-primary-foreground",children:_.jsx(Qn,{weight:"regular",size:20})})})]})})})}),A?_.jsx(_.Fragment,{}):_.jsxs(ll.form,{onSubmit:g,className:"mt-auto flex flex-col gap-2 p-4 pt-2",children:[_.jsx(Cd,{className:"border border-white text-base text-white shadow-none ring-0 placeholder:text-white focus-visible:ring-0 widget:text-sm",placeholder:l("feedback:modalPlaceholder"),"data-testid":"feedback-form-textarea",value:o,rows:4,disabled:s,onChange:V=>i(V.target.value)}),_.jsx(da,{disabled:s||!o,type:"submit",variant:"secondary","data-testid":"feedback-form-button",className:"bg-primary-foreground text-primary hover:bg-primary-foreground/80",children:l(s?"sending":"send")})]})]})}const Zd2=({message:a,handleActionEvent:t})=>{const{t:n}=we("common"),{openModal:l,closeModal:o}=OQ0(),i=cd("(min-width: 768px)"),{state:s}=ye(),u=A=>{A.preventDefault(),t("feedback-pressed",{id:a.id,value:"negative"}),i&&!s.inShadowDom?l(Y7.Dialog,_.jsx(pd2,{message:a,handleActionEvent:t,close:o})):l(Y7.Drawer,_.jsx(fd2,{message:a,handleActionEvent:t,close:o}))};return _.jsxs("div",{className:"flex justify-start space-x-3",children:[_.jsxs("button",{className:`flex h-auto items-center space-x-1 p-0 text-xs underline-offset-4 hover:underline disabled:pointer-events-none disabled:opacity-50 ${a.user_feedback_value==="positive"?"text-green-500":"text-primary"}`,"data-testid":`thumbs-up thumbs-feedback-sentiment-${a.user_feedback_value==="positive"?a.user_feedback_value:"none"}`,onClick:A=>{A.preventDefault(),t("feedback-pressed",{id:a.id,value:"positive"})},children:[_.jsx(IG0,{"aria-hidden":!0,focusable:"false",weight:a.user_feedback_value==="positive"?"fill":"regular",size:20})," ",_.jsx("span",{children:n("feedback:thumbsUp")})]}),_.jsxs("button",{className:`flex h-auto items-center space-x-1 p-0 text-xs underline-offset-4 hover:underline disabled:pointer-events-none disabled:opacity-50 ${a.user_feedback_value==="negative"?"text-red-500":"text-primary"}`,"data-testid":`thumbs-down thumbs-feedback-sentiment-${a.user_feedback_value==="negative"?a.user_feedback_value:"none"}`,onClick:u,children:[_.jsx(bG0,{"aria-hidden":!0,focusable:"false",weight:a.user_feedback_value==="negative"?"fill":"regular",size:20})," ",_.jsx("span",{children:n("feedback:thumbsDown")})]})]})},Hd2=({message:a,handleActionEvent:t,close:n,className:l})=>{const[o,i]=e.useState(""),[s,u]=e.useState(!1),A=p=>{p.preventDefault(),u(!0),t("user-feedback-message",{id:a.id,value:o},"input"),i(""),setTimeout(()=>{u(!1),n()},500)};return _.jsxs("form",{"data-testid":"feedback-form",onSubmit:A,className:W2("mt-auto flex flex-col gap-2",l),children:[_.jsx(Cd,{className:"border-0 bg-white text-base text-black shadow-none ring-0 focus-visible:ring-0 widget:text-sm",placeholder:"Share your thoughts here..",value:o,disabled:s,"data-testid":"feedback-form-textarea",onChange:p=>i(p.target.value)}),_.jsx(da,{disabled:s||!o,type:"submit",variant:"secondary","data-testid":"feedback-form-button",className:"bg-primary-foreground text-primary hover:bg-primary-foreground/80",children:"Send"})]})},gd2=({message:a,index:t,isLast:n,isLastInGroup:l,isFirstInGroup:o,...i})=>{var b;const{state:s,handleActionEvent:u}=ye(),{messages:A,userId:p}=s,g=t===A.length-1,V=p?dc(a,p):!1,v=V?"sent":"received",L=V?"default":"ai";return _.jsx("div",{...i,children:_.jsxs(Jh0,{settings:s.settings,testId:t.toString(),variant:v,isFirstInGroup:o,isLastInGroup:l,sentAt:g?a.sent_at:null,userName:a.sender_name?a.sender_name:(b=s.settings)==null?void 0:b.digitalEmployeeName,className:"",children:[a.blocks.map(I=>D21(I,v,L)),a.request_user_feedback&&!V&&_.jsx(Zd2,{message:a,handleActionEvent:u})]})})},Ed2=()=>_.jsxs("div",{className:"flex items-center gap-1",children:[_.jsx("div",{className:"bubble1 h-2 w-2 rounded-full"}),_.jsx("div",{className:"bubble2 h-2 w-2 rounded-full"}),_.jsx("div",{className:"bubble3 h-2 w-2 rounded-full"})]}),Vd2=()=>{var t;const{state:a}=ye();return _.jsx(Jh0,{settings:a.settings,userName:(t=a.settings)==null?void 0:t.digitalEmployeeName,testId:"loading",variant:"received",isFirstInGroup:!0,isLastInGroup:!1,sentAt:null,className:"",children:_.jsx(zi,{variant:"received",layout:"ai",className:"prose max-w-[60%]",children:_.jsx(Ed2,{})})},"message-loading")},Md2=150,vd2=a=>{const[t,n]=e.useState(!1),l=e.useCallback(()=>{if(!a)return;const{scrollTop:i,scrollHeight:s,clientHeight:u}=a,A=s-i-u;n(A>Md2)},[a]);return e.useEffect(()=>{if(a)return l(),a.addEventListener("scroll",l),()=>{a.removeEventListener("scroll",l)}},[a,l]),{scrollToBottom:()=>{a==null||a.scrollTo({top:a.scrollHeight,behavior:"smooth"})},isScrolledUp:t}},Ld2=()=>{var o;const{t:a}=we(),{state:t}=ye(),n=e.useMemo(()=>{const i=u=>u.type==="text"||u.type==="markdown",s=t.messages.filter(u=>!dc(u,t.userId)&&u.type==="message"&&u.blocks.some(i)).slice(-1)[0];return(s==null?void 0:s.blocks.filter(i))??[]},[t.messages,t.userId]),l=`${((o=t.settings)==null?void 0:o.title)??a("common:bot")} ${a("header:typing")}`;return _.jsx("div",{className:"sr-only","aria-live":"polite",children:t.isTyping?l:n.map(i=>D21(i,"sent","default"))})};function wd2(a){return a?a.map(t=>({...t,blocks:t.blocks?t.blocks.filter(n=>Ad2(n.type)):[]})):[]}function yd2(a){return a?a.filter(t=>t.blocks&&t.blocks.length>0):[]}const Fd2=({href:a="",children:t,...n})=>_.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",...n,children:t}),Cd2=68;function bd2(){var L,b,I,T,N;const a=e.useRef(null),{state:t,endDivRef:n,scrollableDivRef:l}=ye(),{scrollToBottom:o,isScrolledUp:i}=vd2(l.current),[s,u]=e.useState(!1),A=e.useMemo(()=>{const P=wd2(t.messages);return yd2(P)},[t.messages]),p=e.useMemo(()=>A.length>0&&dc(A[A.length-1],t.userId),[A,t.userId]);e.useEffect(()=>{t.isWaitingOnFirstStream&&setTimeout(()=>{var P;(P=l.current)==null||P.scrollTo({top:l.current.scrollHeight,behavior:"smooth"})},100)},[t.isWaitingOnFirstStream]),e.useEffect(()=>{!s&&t.messages.length>0&&(u(!0),setTimeout(()=>{var P,B;(B=l.current)==null||B.scrollTo({top:(P=l.current)==null?void 0:P.scrollHeight})},0))},[t.messages,s]);const g=((L=l.current)==null?void 0:L.clientHeight)||0,V=Cd2+(((b=a.current)==null?void 0:b.clientHeight)||0),v=`${g-V}px`;return _.jsxs("div",{className:"relative h-full w-full",children:[_.jsx(Ld2,{}),_.jsxs("div",{className:"flex h-full w-full flex-col overflow-y-auto",ref:l,children:[_.jsxs("div",{className:"flex grow flex-col gap-3 px-4 py-2",children:[((I=t.settings)==null?void 0:I.disclaimer)&&_.jsx("div",{children:_.jsx(P01,{rehypePlugins:[e21],className:"!m-0 max-w-none text-center text-[10px] leading-[14px] text-gray-500",skipHtml:!0,components:{a:Fd2},children:(T=t.settings)==null?void 0:T.disclaimer})}),A.map((P,B)=>{const q=B===A.length-1,Y=A[B+1],j=A[B-1],G=Y?P.sender_id!==Y.sender_id:!0,J=j?P.sender_id!==j.sender_id:!0;return _.jsx(gd2,{message:P,index:B,isLast:q,isLastInGroup:G,isFirstInGroup:J,style:{minHeight:q&&t.hasSentMessageThisSession&&!p?v:void 0}},`message-${P.id}-${B}`)}),p&&_.jsx("div",{style:{minHeight:t.hasSentMessageThisSession?v:void 0},children:t.isTyping&&_.jsx(Vd2,{})})]}),((N=t.settings)==null?void 0:N.showFreedayBranding)&&_.jsx($u0,{ref:a,name:"Freeday",site:"https://freeday.ai",className:"shrink-0 pb-4 pt-8"})]}),_.jsx("div",{ref:n}),i&&_.jsx(da,{variant:"outline",size:"icon",onClick:o,className:"absolute bottom-2 left-1/2 -translate-x-1/2 border border-border p-1",children:_.jsx(ph,{size:18})})]})}const Id2=()=>{var u,A,p,g;const{state:a}=ye(),{t}=we(),[n,l]=e.useState(!0),[o,i]=e.useState(!1);e.useEffect(()=>{const V=setTimeout(()=>{i(!0)},300);return()=>clearTimeout(V)},[]),e.useEffect(()=>{if(!n)return;const V=v=>{!o||v.target.closest('[data-testid="chat-button"]')||l(!1)};return window.addEventListener("click",V),window.addEventListener("touchstart",V),()=>{window.removeEventListener("click",V),window.removeEventListener("touchstart",V)}},[o,n]);const s=()=>{l(!1)};return(u=a.settings)!=null&&u.bannerTitle&&n?_.jsx("div",{className:"pb-7.5 absolute left-0 right-0 top-0 max-h-[500px] -translate-y-full gap-4 overflow-hidden rounded-t-[30px] bg-white transition-all duration-300 ease-in-out","data-testid":"banner",children:_.jsxs("div",{className:"flex h-full w-full flex-col justify-center rounded-t-[30px] bg-primary/10 p-6",children:[_.jsx("button",{onClick:s,className:"absolute right-8 top-8 flex -translate-y-1/2 translate-x-1/2 cursor-pointer rounded p-1 hover:bg-primary/10 focus:outline-none focus:ring-2 focus:ring-primary","aria-label":t("common:closeNotification"),"data-testid":"close-button",children:_.jsx(Qn,{weight:"regular",size:20,className:"text-primary"})}),_.jsx("p",{className:"text-sm font-semibold text-primary",children:(A=a.settings)==null?void 0:A.bannerTitle}),((p=a.settings)==null?void 0:p.bannerMessage)&&_.jsx("p",{className:"whitespace-pre-line text-sm",children:(g=a.settings)==null?void 0:g.bannerMessage})]})}):null},Sd2=({placeholder:a,isTyping:t,onSendMessage:n})=>{const{t:l}=we(),[o,i]=e.useState(""),[s,u]=e.useState(!0),A=e.useRef(null),p=L=>{i(L.target.value)};e.useEffect(()=>{u(o.trim().length===0||t)},[o,t]);const g=L=>{L==null||L.preventDefault(),!s&&(n(o),i(""))},V=L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),g(L))},v=()=>W2("absolute right-2 top-1/2 flex h-9 w-9 -translate-y-1/2 transform items-center justify-center rounded p-0 transition-all duration-0 ease-in-out",o.trim().length>0?"text-primary":"text-gray-300");return _.jsx("footer",{className:"relative bottom-0 left-0 right-0 border-t border-gray-200 bg-white",children:_.jsxs("div",{className:"p-4",children:[_.jsx(Id2,{}),_.jsx("form",{onSubmit:g,children:_.jsx("div",{className:"flex w-full max-w-full items-center space-x-2",children:_.jsxs("div",{className:"relative w-full flex-1",ref:A,children:[_.jsxs("div",{className:"invisible max-h-[164px] min-h-[44px] overflow-y-hidden whitespace-pre-wrap break-words px-4 py-2",children:[o||a,"|"]}),_.jsx("label",{htmlFor:"chat-input-textarea",className:"sr-only",children:a}),_.jsx("textarea",{id:"chat-input-textarea",className:"absolute inset-0 resize-none rounded-3xl border border-gray-300 pb-[0px] pl-[16px] pr-[48px] pt-[10px] text-[16px] leading-[20px] placeholder:text-gray-500 focus:outline-none focus:ring-1 focus:ring-primary",placeholder:a,wrap:"hard","data-testid":"text-input-field",value:o,onKeyDown:V,onChange:p,rows:1}),t?_.jsx("div",{"data-testid":"stop-button",className:v(),children:_.jsx(kh,{weight:"bold",className:"h-6 w-6"})}):_.jsx("button",{"data-testid":"send-button",className:v(),"aria-label":l("common:send"),children:_.jsx(jc,{weight:"fill",className:"h-6 w-6"})})]})})})]})})},Rd2=()=>{var l,o;const{t:a}=we(["common","footer"]),{sendNewMessage:t,state:n}=ye();return _.jsxs(_.Fragment,{children:[((l=n.settings)==null?void 0:l.theme)!=="slim"&&_.jsx(Kr2,{}),_.jsx(C52,{position:"top-center",expand:!0,pauseWhenPageIsHidden:!0,richColors:!0}),_.jsx("main",{className:"flex-1 space-y-2 overflow-hidden bg-white",children:_.jsx(T7,{initial:!0,children:_.jsx(ll.div,{className:"h-full w-full",initial:{opacity:0,y:5},animate:{opacity:1,y:0},exit:{opacity:0,y:5},transition:{duration:.3,ease:[.42,0,0,1],delay:.4},children:_.jsx(bd2,{})})})}),_.jsx(Sd2,{placeholder:a(((o=n.settings)==null?void 0:o.newMessagePlaceholder)??a("footer:newMessagePlaceholder")),isTyping:n.isTyping,onSendMessage:t})]})},Td2=a=>{const[t,n]=e.useState(null);return e.useEffect(()=>{if(!a)return;(async()=>{try{const i=await new zg0(a,new yH($Z0())).fetchWidgetSettings();n(i)}catch(o){W6(o)}})()},[a]),{widgetSettings:t}},xd2=(a=!1)=>{const[t,n]=e.useState(a),[l,o]=e.useState(!1);return e.useEffect(()=>{const i=s=>{s.type===T8.CLOSE?(n(!1),o(!0)):s.type===T8.OPEN&&(n(!0),o(!1))};return globalThis.addEventListener(T8.CLOSE,i),globalThis.addEventListener(T8.OPEN,i),()=>{globalThis.removeEventListener(T8.CLOSE,i),globalThis.removeEventListener(T8.OPEN,i)}},[]),{isWidgetOpen:t,setIsWidgetOpen:n,hideChatBarInput:l}},Nd2=a=>{const t=cE0();return{handleOpen:()=>{t.capture("widget:opened",{start_view:a==null?void 0:a.startView}),globalThis.dispatchEvent(new Event(T8.OPEN)),globalThis.postMessage({event:T8.START,payload:a},globalThis.location.origin)},handleOpenAndSendMessage:o=>{setTimeout(()=>{globalThis.postMessage({event:T8.START,payload:{suggestionMessage:o}},globalThis.location.origin),globalThis.dispatchEvent(new Event(T8.OPEN))},400)}}},$d2="https://cdn.jsdelivr.net/npm/@freeday-ai/webchat",kd2=()=>{e.useEffect(()=>{const a=n=>{P21(n.error)},t=n=>{P21(n.reason)};return globalThis.addEventListener("error",a),globalThis.addEventListener("unhandledrejection",t),()=>{globalThis.removeEventListener("error",a),globalThis.removeEventListener("unhandledrejection",t)}},[])},P21=a=>{var t;(t=a==null?void 0:a.stack)!=null&&t.includes($d2)&&W6(a)};class Dd2 extends e.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){W6(t,"Uncaught rendering error",{componentStack:n.componentStack})}render(){return this.props.children}}function Pd2(a){e.useEffect(()=>{if(!a)return;const t=document.body,n=t.style.overflow;return t.style.overflow="hidden",()=>{t.style.overflow=n}},[a])}const Od2=({channelId:a,metadata:t})=>{kd2();const{widgetSettings:n}=Td2(a);return!a||!n?null:_.jsx(Dd2,{children:_.jsx(Xr1,{config:{...n,metadata:t?JSON.parse(t):void 0},inShadowDom:!0,children:_.jsx(_d2,{widgetSettings:{...n,metadata:t?JSON.parse(t):void 0}})})})},_d2=({widgetSettings:a})=>{const t=a.startView===F3.FULL_SCREEN,n=a.startView===F3.UNFOLDED_CHAT_VIEW,l=t||n,{isWidgetOpen:o,setIsWidgetOpen:i}=xd2(l),{handleOpen:s,handleOpenAndSendMessage:u}=Nd2(a),A=cd("(max-width: 640px)");return Pd2(o&&A),e.useEffect(()=>{if(!l)return;i(!0);const p=requestAnimationFrame(s);return()=>cancelAnimationFrame(p)},[]),_.jsxs(_.Fragment,{children:[_.jsx(T7,{children:o&&_.jsx(ll.div,{className:W2("chat-window-renderer",{"full-screen":t}),"data-testid":"chat-window-renderer",initial:{opacity:0,y:30},animate:{opacity:1,y:0,transition:{delay:.2}},exit:{opacity:0,y:30},transition:{duration:.35,ease:[.42,0,0,1]},transformTemplate:t?(p,g)=>`translateX(-50%) ${g}`:void 0,children:_.jsx(nr2,{children:_.jsx("div",{className:"widget-chat-container flex flex-col",children:_.jsx(Rd2,{})})})})}),!t&&_.jsx(T7,{children:!o&&_.jsx(ll.div,{className:"button-container",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1,transition:{delay:.3}},exit:{opacity:0,scale:0},transition:{duration:.3,ease:[.42,0,0,1]},children:_.jsx(z32,{onOpen:s,onSendMessage:u})})})]})};_41("freeday-widget",Od2,["channelId","metadata"]);const O21=a=>{const{channelId:t,metadata:n}=a,l=document.createElement("div"),o=document.createElement("freeday-widget");o.setAttribute("channelId",t),n&&o.setAttribute("metadata",JSON.stringify(n)),l.appendChild(o),document.body?document.body.appendChild(l):window.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(l)})};return window.FreedayWidget={bootstrap:O21},Kf.bootstrap=O21,Object.defineProperty(Kf,Symbol.toStringTag,{value:"Module"}),Kf})({});
330
+ `))}function A(L,b,I,T){const N=I.enter("tableCell"),P=I.enter("phrasing"),B=I.containerPhrasing(L,{...T,before:i,after:i});return P(),N(),B}function p(L,b){return xu2(L,{align:b,alignDelimiters:l,padding:n,stringLength:o})}function g(L,b,I){const T=L.children;let N=-1;const P=[],B=b.enter("table");for(;++N<T.length;)P[N]=V(T[N],b,I);return B(),P}function V(L,b,I){const T=L.children;let N=-1;const P=[],B=b.enter("tableRow");for(;++N<T.length;)P[N]=A(T[N],L,b,I);return B(),P}function v(L,b,I){let T=g21.inlineCode(L,b,I);return I.stack.includes("tableCell")&&(T=T.replace(/\|/g,"\\$&")),T}}function Vh2(){return{exit:{taskListCheckValueChecked:V21,taskListCheckValueUnchecked:V21,paragraph:vh2}}}function Mh2(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Lh2}}}function V21(a){const t=this.stack[this.stack.length-2];t.type,t.checked=a.type==="taskListCheckValueChecked"}function vh2(a){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const l=n.children[0];if(l&&l.type==="text"){const o=t.children;let i=-1,s;for(;++i<o.length;){const u=o[i];if(u.type==="paragraph"){s=u;break}}s===n&&(l.value=l.value.slice(1),l.value.length===0?n.children.shift():n.position&&l.position&&typeof l.position.start.offset=="number"&&(l.position.start.column++,l.position.start.offset++,n.position.start=Object.assign({},l.position.start)))}}this.exit(a)}function Lh2(a,t,n,l){const o=a.children[0],i=typeof a.checked=="boolean"&&o&&o.type==="paragraph",s="["+(a.checked?"x":" ")+"] ",u=n.createTracker(l);i&&u.move(s);let A=g21.listItem(a,t,n,{...l,...u.current()});return i&&(A=A.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,p)),A;function p(g){return g+s}}function wh2(){return[nu2(),Lu2(),Cu2(),Ah2(),Vh2()]}function yh2(a){return{extensions:[lu2(),wu2(a),bu2(),Eh2(a),Mh2()]}}const Fh2={tokenize:Th2,partial:!0},M21={tokenize:xh2,partial:!0},v21={tokenize:Nh2,partial:!0},L21={tokenize:$h2,partial:!0},Ch2={tokenize:kh2,partial:!0},w21={name:"wwwAutolink",tokenize:Sh2,previous:F21},y21={name:"protocolAutolink",tokenize:Rh2,previous:C21},z3={name:"emailAutolink",tokenize:Ih2,previous:b21},Bt={};function bh2(){return{text:Bt}}let jr=48;for(;jr<123;)Bt[jr]=z3,jr++,jr===58?jr=65:jr===91&&(jr=97);Bt[43]=z3,Bt[45]=z3,Bt[46]=z3,Bt[95]=z3,Bt[72]=[z3,y21],Bt[104]=[z3,y21],Bt[87]=[z3,w21],Bt[119]=[z3,w21];function Ih2(a,t,n){const l=this;let o,i;return s;function s(V){return!Xh0(V)||!b21.call(l,l.previous)||Qh0(l.events)?n(V):(a.enter("literalAutolink"),a.enter("literalAutolinkEmail"),u(V))}function u(V){return Xh0(V)?(a.consume(V),u):V===64?(a.consume(V),A):n(V)}function A(V){return V===46?a.check(Ch2,g,p)(V):V===45||V===95||Ie(V)?(i=!0,a.consume(V),A):g(V)}function p(V){return a.consume(V),o=!0,A}function g(V){return i&&o&&Qe(l.previous)?(a.exit("literalAutolinkEmail"),a.exit("literalAutolink"),t(V)):n(V)}}function Sh2(a,t,n){const l=this;return o;function o(s){return s!==87&&s!==119||!F21.call(l,l.previous)||Qh0(l.events)?n(s):(a.enter("literalAutolink"),a.enter("literalAutolinkWww"),a.check(Fh2,a.attempt(M21,a.attempt(v21,i),n),n)(s))}function i(s){return a.exit("literalAutolinkWww"),a.exit("literalAutolink"),t(s)}}function Rh2(a,t,n){const l=this;let o="",i=!1;return s;function s(V){return(V===72||V===104)&&C21.call(l,l.previous)&&!Qh0(l.events)?(a.enter("literalAutolink"),a.enter("literalAutolinkHttp"),o+=String.fromCodePoint(V),a.consume(V),u):n(V)}function u(V){if(Qe(V)&&o.length<5)return o+=String.fromCodePoint(V),a.consume(V),u;if(V===58){const v=o.toLowerCase();if(v==="http"||v==="https")return a.consume(V),A}return n(V)}function A(V){return V===47?(a.consume(V),i?p:(i=!0,A)):n(V)}function p(V){return V===null||xd(V)||M8(V)||Or(V)||Nd(V)?n(V):a.attempt(M21,a.attempt(v21,g),n)(V)}function g(V){return a.exit("literalAutolinkHttp"),a.exit("literalAutolink"),t(V)}}function Th2(a,t,n){let l=0;return o;function o(s){return(s===87||s===119)&&l<3?(l++,a.consume(s),o):s===46&&l===3?(a.consume(s),i):n(s)}function i(s){return s===null?n(s):t(s)}}function xh2(a,t,n){let l,o,i;return s;function s(p){return p===46||p===95?a.check(L21,A,u)(p):p===null||M8(p)||Or(p)||p!==45&&Nd(p)?A(p):(i=!0,a.consume(p),s)}function u(p){return p===95?l=!0:(o=l,l=void 0),a.consume(p),s}function A(p){return o||l||!i?n(p):t(p)}}function Nh2(a,t){let n=0,l=0;return o;function o(s){return s===40?(n++,a.consume(s),o):s===41&&l<n?i(s):s===33||s===34||s===38||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===60||s===63||s===93||s===95||s===126?a.check(L21,t,i)(s):s===null||M8(s)||Or(s)?t(s):(a.consume(s),o)}function i(s){return s===41&&l++,a.consume(s),o}}function $h2(a,t,n){return l;function l(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(a.consume(u),l):u===38?(a.consume(u),i):u===93?(a.consume(u),o):u===60||u===null||M8(u)||Or(u)?t(u):n(u)}function o(u){return u===null||u===40||u===91||M8(u)||Or(u)?t(u):l(u)}function i(u){return Qe(u)?s(u):n(u)}function s(u){return u===59?(a.consume(u),l):Qe(u)?(a.consume(u),s):n(u)}}function kh2(a,t,n){return l;function l(i){return a.consume(i),o}function o(i){return Ie(i)?n(i):t(i)}}function F21(a){return a===null||a===40||a===42||a===95||a===91||a===93||a===126||M8(a)}function C21(a){return!Qe(a)}function b21(a){return!(a===47||Xh0(a))}function Xh0(a){return a===43||a===45||a===46||a===95||Ie(a)}function Qh0(a){let t=a.length,n=!1;for(;t--;){const l=a[t][1];if((l.type==="labelLink"||l.type==="labelImage")&&!l._balanced){n=!0;break}if(l._gfmAutolinkLiteralWalkedInto){n=!1;break}}return a.length>0&&!n&&(a[a.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Dh2={tokenize:qh2,partial:!0};function Ph2(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Uh2,continuation:{tokenize:zh2},exit:jh2}},text:{91:{name:"gfmFootnoteCall",tokenize:Bh2},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Oh2,resolveTo:_h2}}}}function Oh2(a,t,n){const l=this;let o=l.events.length;const i=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let s;for(;o--;){const A=l.events[o][1];if(A.type==="labelImage"){s=A;break}if(A.type==="gfmFootnoteCall"||A.type==="labelLink"||A.type==="label"||A.type==="image"||A.type==="link")break}return u;function u(A){if(!s||!s._balanced)return n(A);const p=Ya(l.sliceSerialize({start:s.end,end:l.now()}));return p.codePointAt(0)!==94||!i.includes(p.slice(1))?n(A):(a.enter("gfmFootnoteCallLabelMarker"),a.consume(A),a.exit("gfmFootnoteCallLabelMarker"),t(A))}}function _h2(a,t){let n=a.length;for(;n--;)if(a[n][1].type==="labelImage"&&a[n][0]==="enter"){a[n][1];break}a[n+1][1].type="data",a[n+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},a[n+3][1].start),end:Object.assign({},a[a.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},a[n+3][1].end),end:Object.assign({},a[n+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const i={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},a[a.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},u=[a[n+1],a[n+2],["enter",l,t],a[n+3],a[n+4],["enter",o,t],["exit",o,t],["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t],a[a.length-2],a[a.length-1],["exit",l,t]];return a.splice(n,a.length-n+1,...u),a}function Bh2(a,t,n){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let i=0,s;return u;function u(V){return a.enter("gfmFootnoteCall"),a.enter("gfmFootnoteCallLabelMarker"),a.consume(V),a.exit("gfmFootnoteCallLabelMarker"),A}function A(V){return V!==94?n(V):(a.enter("gfmFootnoteCallMarker"),a.consume(V),a.exit("gfmFootnoteCallMarker"),a.enter("gfmFootnoteCallString"),a.enter("chunkString").contentType="string",p)}function p(V){if(i>999||V===93&&!s||V===null||V===91||M8(V))return n(V);if(V===93){a.exit("chunkString");const v=a.exit("gfmFootnoteCallString");return o.includes(Ya(l.sliceSerialize(v)))?(a.enter("gfmFootnoteCallLabelMarker"),a.consume(V),a.exit("gfmFootnoteCallLabelMarker"),a.exit("gfmFootnoteCall"),t):n(V)}return M8(V)||(s=!0),i++,a.consume(V),V===92?g:p}function g(V){return V===91||V===92||V===93?(a.consume(V),i++,p):p(V)}}function Uh2(a,t,n){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let i,s=0,u;return A;function A(b){return a.enter("gfmFootnoteDefinition")._container=!0,a.enter("gfmFootnoteDefinitionLabel"),a.enter("gfmFootnoteDefinitionLabelMarker"),a.consume(b),a.exit("gfmFootnoteDefinitionLabelMarker"),p}function p(b){return b===94?(a.enter("gfmFootnoteDefinitionMarker"),a.consume(b),a.exit("gfmFootnoteDefinitionMarker"),a.enter("gfmFootnoteDefinitionLabelString"),a.enter("chunkString").contentType="string",g):n(b)}function g(b){if(s>999||b===93&&!u||b===null||b===91||M8(b))return n(b);if(b===93){a.exit("chunkString");const I=a.exit("gfmFootnoteDefinitionLabelString");return i=Ya(l.sliceSerialize(I)),a.enter("gfmFootnoteDefinitionLabelMarker"),a.consume(b),a.exit("gfmFootnoteDefinitionLabelMarker"),a.exit("gfmFootnoteDefinitionLabel"),v}return M8(b)||(u=!0),s++,a.consume(b),b===92?V:g}function V(b){return b===91||b===92||b===93?(a.consume(b),s++,g):g(b)}function v(b){return b===58?(a.enter("definitionMarker"),a.consume(b),a.exit("definitionMarker"),o.includes(i)||o.push(i),G2(a,L,"gfmFootnoteDefinitionWhitespace")):n(b)}function L(b){return t(b)}}function zh2(a,t,n){return a.check(wi,t,a.attempt(Dh2,t,n))}function jh2(a){a.exit("gfmFootnoteDefinition")}function qh2(a,t,n){const l=this;return G2(a,o,"gfmFootnoteDefinitionIndent",5);function o(i){const s=l.events[l.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?t(i):n(i)}}function Wh2(a){let n=(a||{}).singleTilde;const l={name:"strikethrough",tokenize:i,resolveAll:o};return n==null&&(n=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function o(s,u){let A=-1;for(;++A<s.length;)if(s[A][0]==="enter"&&s[A][1].type==="strikethroughSequenceTemporary"&&s[A][1]._close){let p=A;for(;p--;)if(s[p][0]==="exit"&&s[p][1].type==="strikethroughSequenceTemporary"&&s[p][1]._open&&s[A][1].end.offset-s[A][1].start.offset===s[p][1].end.offset-s[p][1].start.offset){s[A][1].type="strikethroughSequence",s[p][1].type="strikethroughSequence";const g={type:"strikethrough",start:Object.assign({},s[p][1].start),end:Object.assign({},s[A][1].end)},V={type:"strikethroughText",start:Object.assign({},s[p][1].end),end:Object.assign({},s[A][1].start)},v=[["enter",g,u],["enter",s[p][1],u],["exit",s[p][1],u],["enter",V,u]],L=u.parser.constructs.insideSpan.null;L&&W4(v,v.length,0,$d(L,s.slice(p+1,A),u)),W4(v,v.length,0,[["exit",V,u],["enter",s[A][1],u],["exit",s[A][1],u],["exit",g,u]]),W4(s,p-1,A-p+3,v),A=p+v.length-2;break}}for(A=-1;++A<s.length;)s[A][1].type==="strikethroughSequenceTemporary"&&(s[A][1].type="data");return s}function i(s,u,A){const p=this.previous,g=this.events;let V=0;return v;function v(b){return p===126&&g[g.length-1][1].type!=="characterEscape"?A(b):(s.enter("strikethroughSequenceTemporary"),L(b))}function L(b){const I=n9(p);if(b===126)return V>1?A(b):(s.consume(b),V++,L);if(V<2&&!n)return A(b);const T=s.exit("strikethroughSequenceTemporary"),N=n9(b);return T._open=!N||N===2&&!!I,T._close=!I||I===2&&!!N,u(b)}}}class Gh2{constructor(){this.map=[]}add(t,n,l){Yh2(this,t,n,l)}consume(t){if(this.map.sort(function(i,s){return i[0]-s[0]}),this.map.length===0)return;let n=this.map.length;const l=[];for(;n>0;)n-=1,l.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];l.push(t.slice()),t.length=0;let o=l.pop();for(;o;){for(const i of o)t.push(i);o=l.pop()}this.map.length=0}}function Yh2(a,t,n,l){let o=0;if(!(n===0&&l.length===0)){for(;o<a.map.length;){if(a.map[o][0]===t){a.map[o][1]+=n,a.map[o][2].push(...l);return}o+=1}a.map.push([t,n,l])}}function Kh2(a,t){let n=!1;const l=[];for(;t<a.length;){const o=a[t];if(n){if(o[0]==="enter")o[1].type==="tableContent"&&l.push(a[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(a[t-1][1].type==="tableDelimiterMarker"){const i=l.length-1;l[i]=l[i]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return l}function Xh2(){return{flow:{null:{name:"table",tokenize:Qh2,resolveAll:Jh2}}}}function Qh2(a,t,n){const l=this;let o=0,i=0,s;return u;function u(Q){let H0=l.events.length-1;for(;H0>-1;){const m0=l.events[H0][1].type;if(m0==="lineEnding"||m0==="linePrefix")H0--;else break}const o0=H0>-1?l.events[H0][1].type:null,n0=o0==="tableHead"||o0==="tableRow"?j:A;return n0===j&&l.parser.lazy[l.now().line]?n(Q):n0(Q)}function A(Q){return a.enter("tableHead"),a.enter("tableRow"),p(Q)}function p(Q){return Q===124||(s=!0,i+=1),g(Q)}function g(Q){return Q===null?n(Q):X1(Q)?i>1?(i=0,l.interrupt=!0,a.exit("tableRow"),a.enter("lineEnding"),a.consume(Q),a.exit("lineEnding"),L):n(Q):P2(Q)?G2(a,g,"whitespace")(Q):(i+=1,s&&(s=!1,o+=1),Q===124?(a.enter("tableCellDivider"),a.consume(Q),a.exit("tableCellDivider"),s=!0,g):(a.enter("data"),V(Q)))}function V(Q){return Q===null||Q===124||M8(Q)?(a.exit("data"),g(Q)):(a.consume(Q),Q===92?v:V)}function v(Q){return Q===92||Q===124?(a.consume(Q),V):V(Q)}function L(Q){return l.interrupt=!1,l.parser.lazy[l.now().line]?n(Q):(a.enter("tableDelimiterRow"),s=!1,P2(Q)?G2(a,b,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Q):b(Q))}function b(Q){return Q===45||Q===58?T(Q):Q===124?(s=!0,a.enter("tableCellDivider"),a.consume(Q),a.exit("tableCellDivider"),I):Y(Q)}function I(Q){return P2(Q)?G2(a,T,"whitespace")(Q):T(Q)}function T(Q){return Q===58?(i+=1,s=!0,a.enter("tableDelimiterMarker"),a.consume(Q),a.exit("tableDelimiterMarker"),N):Q===45?(i+=1,N(Q)):Q===null||X1(Q)?q(Q):Y(Q)}function N(Q){return Q===45?(a.enter("tableDelimiterFiller"),P(Q)):Y(Q)}function P(Q){return Q===45?(a.consume(Q),P):Q===58?(s=!0,a.exit("tableDelimiterFiller"),a.enter("tableDelimiterMarker"),a.consume(Q),a.exit("tableDelimiterMarker"),B):(a.exit("tableDelimiterFiller"),B(Q))}function B(Q){return P2(Q)?G2(a,q,"whitespace")(Q):q(Q)}function q(Q){return Q===124?b(Q):Q===null||X1(Q)?!s||o!==i?Y(Q):(a.exit("tableDelimiterRow"),a.exit("tableHead"),t(Q)):Y(Q)}function Y(Q){return n(Q)}function j(Q){return a.enter("tableRow"),G(Q)}function G(Q){return Q===124?(a.enter("tableCellDivider"),a.consume(Q),a.exit("tableCellDivider"),G):Q===null||X1(Q)?(a.exit("tableRow"),t(Q)):P2(Q)?G2(a,G,"whitespace")(Q):(a.enter("data"),J(Q))}function J(Q){return Q===null||Q===124||M8(Q)?(a.exit("data"),G(Q)):(a.consume(Q),Q===92?Z0:J)}function Z0(Q){return Q===92||Q===124?(a.consume(Q),J):J(Q)}}function Jh2(a,t){let n=-1,l=!0,o=0,i=[0,0,0,0],s=[0,0,0,0],u=!1,A=0,p,g,V;const v=new Gh2;for(;++n<a.length;){const L=a[n],b=L[1];L[0]==="enter"?b.type==="tableHead"?(u=!1,A!==0&&(I21(v,t,A,p,g),g=void 0,A=0),p={type:"table",start:Object.assign({},b.start),end:Object.assign({},b.end)},v.add(n,0,[["enter",p,t]])):b.type==="tableRow"||b.type==="tableDelimiterRow"?(l=!0,V=void 0,i=[0,0,0,0],s=[0,n+1,0,0],u&&(u=!1,g={type:"tableBody",start:Object.assign({},b.start),end:Object.assign({},b.end)},v.add(n,0,[["enter",g,t]])),o=b.type==="tableDelimiterRow"?2:g?3:1):o&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")?(l=!1,s[2]===0&&(i[1]!==0&&(s[0]=s[1],V=nA(v,t,i,o,void 0,V),i=[0,0,0,0]),s[2]=n)):b.type==="tableCellDivider"&&(l?l=!1:(i[1]!==0&&(s[0]=s[1],V=nA(v,t,i,o,void 0,V)),i=s,s=[i[1],n,0,0])):b.type==="tableHead"?(u=!0,A=n):b.type==="tableRow"||b.type==="tableDelimiterRow"?(A=n,i[1]!==0?(s[0]=s[1],V=nA(v,t,i,o,n,V)):s[1]!==0&&(V=nA(v,t,s,o,n,V)),o=0):o&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")&&(s[3]=n)}for(A!==0&&I21(v,t,A,p,g),v.consume(t.events),n=-1;++n<t.events.length;){const L=t.events[n];L[0]==="enter"&&L[1].type==="table"&&(L[1]._align=Kh2(t.events,n))}return a}function nA(a,t,n,l,o,i){const s=l===1?"tableHeader":l===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(i.end=Object.assign({},d9(t.events,n[0])),a.add(n[0],0,[["exit",i,t]]));const A=d9(t.events,n[1]);if(i={type:s,start:Object.assign({},A),end:Object.assign({},A)},a.add(n[1],0,[["enter",i,t]]),n[2]!==0){const p=d9(t.events,n[2]),g=d9(t.events,n[3]),V={type:u,start:Object.assign({},p),end:Object.assign({},g)};if(a.add(n[2],0,[["enter",V,t]]),l!==2){const v=t.events[n[2]],L=t.events[n[3]];if(v[1].end=Object.assign({},L[1].end),v[1].type="chunkText",v[1].contentType="text",n[3]>n[2]+1){const b=n[2]+1,I=n[3]-n[2]-1;a.add(b,I,[])}}a.add(n[3]+1,0,[["exit",V,t]])}return o!==void 0&&(i.end=Object.assign({},d9(t.events,o)),a.add(o,0,[["exit",i,t]]),i=void 0),i}function I21(a,t,n,l,o){const i=[],s=d9(t.events,n);o&&(o.end=Object.assign({},s),i.push(["exit",o,t])),l.end=Object.assign({},s),i.push(["exit",l,t]),a.add(n+1,0,i)}function d9(a,t){const n=a[t],l=n[0]==="enter"?"start":"end";return n[1][l]}const ed2={name:"tasklistCheck",tokenize:td2};function ad2(){return{text:{91:ed2}}}function td2(a,t,n){const l=this;return o;function o(A){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?n(A):(a.enter("taskListCheck"),a.enter("taskListCheckMarker"),a.consume(A),a.exit("taskListCheckMarker"),i)}function i(A){return M8(A)?(a.enter("taskListCheckValueUnchecked"),a.consume(A),a.exit("taskListCheckValueUnchecked"),s):A===88||A===120?(a.enter("taskListCheckValueChecked"),a.consume(A),a.exit("taskListCheckValueChecked"),s):n(A)}function s(A){return A===93?(a.enter("taskListCheckMarker"),a.consume(A),a.exit("taskListCheckMarker"),a.exit("taskListCheck"),u):n(A)}function u(A){return X1(A)?t(A):P2(A)?a.check({tokenize:nd2},t,n)(A):n(A)}}function nd2(a,t,n){return G2(a,l,"whitespace");function l(o){return o===null?n(o):t(o)}}function ld2(a){return YJ0([bh2(),Ph2(),Wh2(a),Xh2(),ad2()])}const rd2={};function od2(a){const t=this,n=a||rd2,l=t.data(),o=l.micromarkExtensions||(l.micromarkExtensions=[]),i=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),s=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);o.push(ld2(n)),i.push(wh2()),s.push(yh2(n))}const cd2=Nu0("relative flex w-full flex-col gap-3",{variants:{variant:{received:"items-start",sent:"items-end"},layout:{user:"",ai:"w-full max-w-full items-center"},isLastInGroup:{true:"",false:""}},defaultVariants:{variant:"received",layout:"user"}}),Jh0=e.forwardRef(({settings:a,className:t,variant:n,isLastInGroup:l,isFirstInGroup:o,sentAt:i,layout:s,children:u,testId:A="",userName:p,...g},V)=>_.jsxs("div",{"data-testid":n=="received"?`chat-message-${A} incoming-message-${A}`:`chat-message-${A} outgoing-message-${A}`,children:[n&&o&&sd2({variant:n,settings:a,userName:p}),_.jsx("div",{className:W2(cd2({variant:n,layout:s,isLastInGroup:l,className:t}),a!=null&&a.avatar?"pl-6":""),ref:V,...g,children:u})]}));Jh0.displayName="Message";const id2=Nu0("p-4",{variants:{variant:{received:"message-received",sent:"message-send"},layout:{default:"",ai:"message-ai"},isLoading:{true:"animate-pulse bg-gray-200",false:""}},defaultVariants:{variant:"received",layout:"default"}}),zi=e.forwardRef(({className:a,variant:t,layout:n,isLoading:l=!1,children:o,...i},s)=>_.jsx("div",{className:W2(id2({variant:t,layout:n,isLoading:l,className:a}),"overflow-x-auto break-words"),ref:s,...i,children:o}));zi.displayName="MessageBubble";const sd2=({variant:a,settings:t,userName:n})=>a!=="received"?null:_.jsxs("div",{className:"mb-1 flex items-center justify-start space-x-1",children:[(t==null?void 0:t.avatar)&&_.jsx("img",{width:48,height:48,className:"mt-1 h-5 w-5 rounded-full",src:t.avatar,alt:"Avatar"}),n&&_.jsx("span",{className:"font-brand text-[11.2px] font-bold leading-[16.8px] text-primary",children:n})]}),md2=({block:a,variant:t,layout:n,isLoading:l})=>_.jsx(zi,{variant:t,layout:n,isLoading:l,className:"prose max-w-[95%] break-words prose-a:text-blue-600",children:_.jsx(P01,{rehypePlugins:[e21],remarkPlugins:[od2],components:{a:ud2},className:"",skipHtml:!0,children:a.content})});function ud2(a){return _.jsx("a",{href:a.href,target:"_blank",children:a.children})}const S21=e.forwardRef(({className:a,...t},n)=>_.jsx("div",{ref:n,className:W2("rounded-lg border bg-card text-card-foreground shadow-sm",a),...t}));S21.displayName="Card";const R21=e.forwardRef(({className:a,...t},n)=>_.jsx("div",{ref:n,className:W2("flex flex-col space-y-1.5 p-6",a),...t}));R21.displayName="CardHeader";const T21=e.forwardRef(({className:a,...t},n)=>_.jsx("h3",{ref:n,className:W2("text-2xl font-semibold leading-none tracking-tight",a),...t}));T21.displayName="CardTitle";const x21=e.forwardRef(({className:a,...t},n)=>_.jsx("p",{ref:n,className:W2("text-sm text-muted-foreground",a),...t}));x21.displayName="CardDescription";const N21=e.forwardRef(({className:a,...t},n)=>_.jsx("div",{ref:n,className:W2("p-6 pt-0",a),...t}));N21.displayName="CardContent";const $21=e.forwardRef(({className:a,...t},n)=>_.jsx("div",{ref:n,className:W2("flex items-center p-6 pt-0",a),...t}));$21.displayName="CardFooter";const hd2=({block:a})=>{const{t}=we("common");return a.sources.some(l=>l.document_metadata&&l.document_metadata.card)?_.jsx("div",{className:"flex w-full max-w-full gap-5 overflow-x-auto",children:a.sources.map(l=>_.jsxs(S21,{"data-url":l.source_link,className:"min-w-[200px] max-w-72 overflow-hidden",children:[_.jsx(R21,{className:"h-full max-h-[120px] p-0",children:_.jsx("img",{className:"h-full w-full object-cover transition duration-300 ease-in-out group-hover:scale-105",src:l.document_metadata.card.image,alt:l.document_metadata.card.title})}),_.jsxs(N21,{className:"p-4",children:[_.jsx(T21,{className:"text-md line-clamp-1 font-bold",children:l.document_metadata.card.title}),l.document_metadata.card.description&&_.jsx(x21,{className:"line-clamp-2 text-sm",children:l.document_metadata.card.description})]}),_.jsx($21,{children:_.jsx("a",{href:l.document_metadata.card.url,target:"_blank",children:_.jsx(da,{variant:"outline",children:l.document_metadata.card.call_to_action_text??t("sourceCallToActionLabel")})})})]},l.id))}):_.jsx(_.Fragment,{})},dd2=({block:a,variant:t,layout:n,isLoading:l})=>_.jsx(zi,{variant:t,layout:n,isLoading:l,className:"max-w-[95%]",children:_.jsx("img",{src:a.url,alt:a.filename})}),k21={markdown:md2,text:({block:a,variant:t,layout:n,isLoading:l})=>_.jsx(zi,{variant:t,layout:n,isLoading:l,className:"prose max-w-[60%]",children:_.jsx("p",{children:a.text})}),button:V0.Fragment,button_group:Xm2,source_group:hd2,image_reference:dd2,conversation_rating:V0.Fragment},Ad2=a=>a in k21,D21=(a,t,n)=>{const l=k21[a.type];return typeof l<"u"?V0.createElement(l,{key:`block-${a.id}`,variant:t,layout:n,block:a}):(console.warn(`No component found for block type: ${a.type}`),null)};function pd2({message:a,handleActionEvent:t,close:n}){return _.jsxs(gd,{className:"sm:max-w-[425px]",children:[_.jsxs(Lu0,{children:[_.jsx(wu0,{children:"Thank you for your response!"}),_.jsx(EQ0,{children:"Can you tell us what went wrong?"})]}),_.jsx(Hd2,{message:a,handleActionEvent:t,close:n})]})}function fd2({message:a,handleActionEvent:t,close:n}){const{t:l}=we(["common","feedback"]),[o,i]=e.useState(""),[s,u]=e.useState(!1),[A,p]=e.useState(!1),g=V=>{V.preventDefault(),u(!0),t("user-feedback-message",{id:a.id,value:o},"input"),i(""),p(!0),setTimeout(()=>{u(!1),setTimeout(n,1500)},1500)};return _.jsxs(Md,{className:"min-h-40 overflow-hidden rounded-t-[20px] border-primary bg-primary text-primary-foreground",children:[_.jsx(T7,{children:_.jsx(ll.div,{layoutId:"underline",children:_.jsx(vd,{className:"",children:A?_.jsx(sJ0,{title:l("feedback:modalSubmittedTitle"),description:l("feedback:modalSubmittedDescription")}):_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsx("div",{className:"relative w-12"}),_.jsxs("div",{className:"text-center",children:[_.jsx(Ai,{className:"text-center",children:l("feedback:modalTitle")}),_.jsx(xu0,{className:"text-primary-foreground/80",children:l("feedback:modalDescription")})]}),_.jsx(Tu0,{className:"w-12",asChild:!0,children:_.jsx(da,{variant:"link",onClick:n,className:"text-right text-primary-foreground",children:_.jsx(Qn,{weight:"regular",size:20})})})]})})})}),A?_.jsx(_.Fragment,{}):_.jsxs(ll.form,{onSubmit:g,className:"mt-auto flex flex-col gap-2 p-4 pt-2",children:[_.jsx(Cd,{className:"border border-white text-base text-white shadow-none ring-0 placeholder:text-white focus-visible:ring-0 widget:text-sm",placeholder:l("feedback:modalPlaceholder"),"data-testid":"feedback-form-textarea",value:o,rows:4,disabled:s,onChange:V=>i(V.target.value)}),_.jsx(da,{disabled:s||!o,type:"submit",variant:"secondary","data-testid":"feedback-form-button",className:"bg-primary-foreground text-primary hover:bg-primary-foreground/80",children:l(s?"sending":"send")})]})]})}const Zd2=({message:a,handleActionEvent:t})=>{const{t:n}=we("common"),{openModal:l,closeModal:o}=OQ0(),i=cd("(min-width: 768px)"),{state:s}=ye(),u=A=>{A.preventDefault(),t("feedback-pressed",{id:a.id,value:"negative"}),i&&!s.inShadowDom?l(Y7.Dialog,_.jsx(pd2,{message:a,handleActionEvent:t,close:o})):l(Y7.Drawer,_.jsx(fd2,{message:a,handleActionEvent:t,close:o}))};return _.jsxs("div",{className:"flex justify-start space-x-3",children:[_.jsxs("button",{className:`flex h-auto items-center space-x-1 p-0 text-xs underline-offset-4 hover:underline disabled:pointer-events-none disabled:opacity-50 ${a.user_feedback_value==="positive"?"text-green-500":"text-primary"}`,"data-testid":`thumbs-up thumbs-feedback-sentiment-${a.user_feedback_value==="positive"?a.user_feedback_value:"none"}`,onClick:A=>{A.preventDefault(),t("feedback-pressed",{id:a.id,value:"positive"})},children:[_.jsx(IG0,{"aria-hidden":!0,focusable:"false",weight:a.user_feedback_value==="positive"?"fill":"regular",size:20})," ",_.jsx("span",{children:n("feedback:thumbsUp")})]}),_.jsxs("button",{className:`flex h-auto items-center space-x-1 p-0 text-xs underline-offset-4 hover:underline disabled:pointer-events-none disabled:opacity-50 ${a.user_feedback_value==="negative"?"text-red-500":"text-primary"}`,"data-testid":`thumbs-down thumbs-feedback-sentiment-${a.user_feedback_value==="negative"?a.user_feedback_value:"none"}`,onClick:u,children:[_.jsx(bG0,{"aria-hidden":!0,focusable:"false",weight:a.user_feedback_value==="negative"?"fill":"regular",size:20})," ",_.jsx("span",{children:n("feedback:thumbsDown")})]})]})},Hd2=({message:a,handleActionEvent:t,close:n,className:l})=>{const[o,i]=e.useState(""),[s,u]=e.useState(!1),A=p=>{p.preventDefault(),u(!0),t("user-feedback-message",{id:a.id,value:o},"input"),i(""),setTimeout(()=>{u(!1),n()},500)};return _.jsxs("form",{"data-testid":"feedback-form",onSubmit:A,className:W2("mt-auto flex flex-col gap-2",l),children:[_.jsx(Cd,{className:"border-0 bg-white text-base text-black shadow-none ring-0 focus-visible:ring-0 widget:text-sm",placeholder:"Share your thoughts here..",value:o,disabled:s,"data-testid":"feedback-form-textarea",onChange:p=>i(p.target.value)}),_.jsx(da,{disabled:s||!o,type:"submit",variant:"secondary","data-testid":"feedback-form-button",className:"bg-primary-foreground text-primary hover:bg-primary-foreground/80",children:"Send"})]})},gd2=({message:a,index:t,isLast:n,isLastInGroup:l,isFirstInGroup:o,...i})=>{var b;const{state:s,handleActionEvent:u}=ye(),{messages:A,userId:p}=s,g=t===A.length-1,V=p?dc(a,p):!1,v=V?"sent":"received",L=V?"default":"ai";return _.jsx("div",{...i,children:_.jsxs(Jh0,{settings:s.settings,testId:t.toString(),variant:v,isFirstInGroup:o,isLastInGroup:l,sentAt:g?a.sent_at:null,userName:a.sender_name?a.sender_name:(b=s.settings)==null?void 0:b.digitalEmployeeName,className:"",children:[a.blocks.map(I=>D21(I,v,L)),a.request_user_feedback&&!V&&_.jsx(Zd2,{message:a,handleActionEvent:u})]})})},Ed2=()=>_.jsxs("div",{className:"flex items-center gap-1",children:[_.jsx("div",{className:"bubble1 h-2 w-2 rounded-full"}),_.jsx("div",{className:"bubble2 h-2 w-2 rounded-full"}),_.jsx("div",{className:"bubble3 h-2 w-2 rounded-full"})]}),Vd2=()=>{var t;const{state:a}=ye();return _.jsx(Jh0,{settings:a.settings,userName:(t=a.settings)==null?void 0:t.digitalEmployeeName,testId:"loading",variant:"received",isFirstInGroup:!0,isLastInGroup:!1,sentAt:null,className:"",children:_.jsx(zi,{variant:"received",layout:"ai",className:"prose max-w-[60%]",children:_.jsx(Ed2,{})})},"message-loading")},Md2=150,vd2=a=>{const[t,n]=e.useState(!1),l=e.useCallback(()=>{if(!a)return;const{scrollTop:i,scrollHeight:s,clientHeight:u}=a,A=s-i-u;n(A>Md2)},[a]);return e.useEffect(()=>{if(a)return l(),a.addEventListener("scroll",l),()=>{a.removeEventListener("scroll",l)}},[a,l]),{scrollToBottom:()=>{a==null||a.scrollTo({top:a.scrollHeight,behavior:"smooth"})},isScrolledUp:t}},Ld2=()=>{var o;const{t:a}=we(),{state:t}=ye(),n=e.useMemo(()=>{const i=u=>u.type==="text"||u.type==="markdown",s=t.messages.filter(u=>!dc(u,t.userId)&&u.type==="message"&&u.blocks.some(i)).slice(-1)[0];return(s==null?void 0:s.blocks.filter(i))??[]},[t.messages,t.userId]),l=`${((o=t.settings)==null?void 0:o.title)??a("common:bot")} ${a("header:typing")}`;return _.jsx("div",{className:"sr-only","aria-live":"polite",children:t.isTyping?l:n.map(i=>D21(i,"sent","default"))})};function wd2(a){return a?a.map(t=>({...t,blocks:t.blocks?t.blocks.filter(n=>Ad2(n.type)):[]})):[]}function yd2(a){return a?a.filter(t=>t.blocks&&t.blocks.length>0):[]}const Fd2=({href:a="",children:t,...n})=>_.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",...n,children:t}),Cd2=68;function bd2(){var L,b,I,T,N;const a=e.useRef(null),{state:t,endDivRef:n,scrollableDivRef:l}=ye(),{scrollToBottom:o,isScrolledUp:i}=vd2(l.current),[s,u]=e.useState(!1),A=e.useMemo(()=>{const P=wd2(t.messages);return yd2(P)},[t.messages]),p=e.useMemo(()=>A.length>0&&dc(A[A.length-1],t.userId),[A,t.userId]);e.useEffect(()=>{t.isWaitingOnFirstStream&&setTimeout(()=>{var P;(P=l.current)==null||P.scrollTo({top:l.current.scrollHeight,behavior:"smooth"})},100)},[t.isWaitingOnFirstStream]),e.useEffect(()=>{!s&&t.messages.length>0&&(u(!0),setTimeout(()=>{var P,B;(B=l.current)==null||B.scrollTo({top:(P=l.current)==null?void 0:P.scrollHeight})},0))},[t.messages,s]);const g=((L=l.current)==null?void 0:L.clientHeight)||0,V=Cd2+(((b=a.current)==null?void 0:b.clientHeight)||0),v=`${g-V}px`;return _.jsxs("div",{className:"relative h-full w-full",children:[_.jsx(Ld2,{}),_.jsxs("div",{className:"flex h-full w-full flex-col overflow-y-auto",ref:l,children:[_.jsxs("div",{className:"flex grow flex-col gap-3 px-4 py-2",children:[((I=t.settings)==null?void 0:I.disclaimer)&&_.jsx("div",{children:_.jsx(P01,{rehypePlugins:[e21],className:"!m-0 max-w-none text-center text-[10px] leading-[14px] text-gray-500",skipHtml:!0,components:{a:Fd2},children:(T=t.settings)==null?void 0:T.disclaimer})}),A.map((P,B)=>{const q=B===A.length-1,Y=A[B+1],j=A[B-1],G=Y?P.sender_id!==Y.sender_id:!0,J=j?P.sender_id!==j.sender_id:!0;return _.jsx(gd2,{message:P,index:B,isLast:q,isLastInGroup:G,isFirstInGroup:J,style:{minHeight:q&&t.hasSentMessageThisSession&&!p?v:void 0}},`message-${P.id}-${B}`)}),p&&_.jsx("div",{style:{minHeight:t.hasSentMessageThisSession?v:void 0},children:t.isTyping&&_.jsx(Vd2,{})})]}),((N=t.settings)==null?void 0:N.showFreedayBranding)&&_.jsx($u0,{ref:a,name:"Freeday",site:"https://freeday.ai",className:"shrink-0 pb-4 pt-8"})]}),_.jsx("div",{ref:n}),i&&_.jsx(da,{variant:"outline",size:"icon",onClick:o,className:"absolute bottom-2 left-1/2 -translate-x-1/2 border border-border p-1",children:_.jsx(ph,{size:18})})]})}const Id2=()=>{var u,A,p,g;const{state:a}=ye(),{t}=we(),[n,l]=e.useState(!0),[o,i]=e.useState(!1);e.useEffect(()=>{const V=setTimeout(()=>{i(!0)},300);return()=>clearTimeout(V)},[]),e.useEffect(()=>{if(!n)return;const V=v=>{!o||v.target.closest('[data-testid="chat-button"]')||l(!1)};return window.addEventListener("click",V),window.addEventListener("touchstart",V),()=>{window.removeEventListener("click",V),window.removeEventListener("touchstart",V)}},[o,n]);const s=()=>{l(!1)};return(u=a.settings)!=null&&u.bannerTitle&&n?_.jsx("div",{className:"pb-7.5 absolute left-0 right-0 top-0 max-h-[500px] -translate-y-full gap-4 overflow-hidden rounded-t-[30px] bg-white transition-all duration-300 ease-in-out","data-testid":"banner",children:_.jsxs("div",{className:"flex h-full w-full flex-col justify-center rounded-t-[30px] bg-primary/10 p-6",children:[_.jsx("button",{onClick:s,className:"absolute right-8 top-8 flex -translate-y-1/2 translate-x-1/2 cursor-pointer rounded p-1 hover:bg-primary/10 focus:outline-none focus:ring-2 focus:ring-primary","aria-label":t("common:closeNotification"),"data-testid":"close-button",children:_.jsx(Qn,{weight:"regular",size:20,className:"text-primary"})}),_.jsx("p",{className:"text-sm font-semibold text-primary",children:(A=a.settings)==null?void 0:A.bannerTitle}),((p=a.settings)==null?void 0:p.bannerMessage)&&_.jsx("p",{className:"whitespace-pre-line text-sm",children:(g=a.settings)==null?void 0:g.bannerMessage})]})}):null},Sd2=({placeholder:a,isTyping:t,onSendMessage:n})=>{const{t:l}=we(),[o,i]=e.useState(""),[s,u]=e.useState(!0),A=e.useRef(null),p=L=>{i(L.target.value)};e.useEffect(()=>{u(o.trim().length===0||t)},[o,t]);const g=L=>{L==null||L.preventDefault(),!s&&(n(o),i(""))},V=L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),g(L))},v=()=>W2("absolute right-2 top-1/2 flex h-9 w-9 -translate-y-1/2 transform items-center justify-center rounded p-0 transition-all duration-0 ease-in-out",o.trim().length>0?"text-primary":"text-gray-300");return _.jsx("footer",{className:"relative bottom-0 left-0 right-0 border-t border-gray-200 bg-white",children:_.jsxs("div",{className:"p-4",children:[_.jsx(Id2,{}),_.jsx("form",{onSubmit:g,children:_.jsx("div",{className:"flex w-full max-w-full items-center space-x-2",children:_.jsxs("div",{className:"relative w-full flex-1",ref:A,children:[_.jsxs("div",{className:"invisible max-h-[164px] min-h-[44px] overflow-y-hidden whitespace-pre-wrap break-words px-4 py-2",children:[o||a,"|"]}),_.jsx("label",{htmlFor:"chat-input-textarea",className:"sr-only",children:a}),_.jsx("textarea",{id:"chat-input-textarea",className:"absolute inset-0 resize-none rounded-3xl border border-gray-300 pb-[0px] pl-[16px] pr-[48px] pt-[10px] text-[16px] leading-[20px] placeholder:text-gray-500 focus:outline-none focus:ring-1 focus:ring-primary",placeholder:a,wrap:"hard","data-testid":"text-input-field",value:o,onKeyDown:V,onChange:p,rows:1}),t?_.jsx("div",{"data-testid":"stop-button",className:v(),children:_.jsx(kh,{weight:"bold",className:"h-6 w-6"})}):_.jsx("button",{"data-testid":"send-button",className:v(),"aria-label":l("common:send"),children:_.jsx(jc,{weight:"fill",className:"h-6 w-6"})})]})})})]})})},Rd2=()=>{var l,o;const{t:a}=we(["common","footer"]),{sendNewMessage:t,state:n}=ye();return _.jsxs(_.Fragment,{children:[((l=n.settings)==null?void 0:l.theme)!=="slim"&&_.jsx(Kr2,{}),_.jsx(C52,{position:"top-center",expand:!0,pauseWhenPageIsHidden:!0,richColors:!0}),_.jsx("main",{className:"flex-1 space-y-2 overflow-hidden bg-white",children:_.jsx(T7,{initial:!0,children:_.jsx(ll.div,{className:"h-full w-full",initial:{opacity:0,y:5},animate:{opacity:1,y:0},exit:{opacity:0,y:5},transition:{duration:.3,ease:[.42,0,0,1],delay:.4},children:_.jsx(bd2,{})})})}),_.jsx(Sd2,{placeholder:a(((o=n.settings)==null?void 0:o.newMessagePlaceholder)??a("footer:newMessagePlaceholder")),isTyping:n.isTyping,onSendMessage:t})]})},Td2=a=>{const[t,n]=e.useState(null);return e.useEffect(()=>{if(!a)return;(async()=>{try{const i=await new zg0(a,new yH($Z0())).fetchWidgetSettings();n(i)}catch(o){W6(o)}})()},[a]),{widgetSettings:t}},xd2=(a=!1)=>{const[t,n]=e.useState(a),[l,o]=e.useState(!1);return e.useEffect(()=>{const i=s=>{s.type===T8.CLOSE?(n(!1),o(!0)):s.type===T8.OPEN&&(n(!0),o(!1))};return globalThis.addEventListener(T8.CLOSE,i),globalThis.addEventListener(T8.OPEN,i),()=>{globalThis.removeEventListener(T8.CLOSE,i),globalThis.removeEventListener(T8.OPEN,i)}},[]),{isWidgetOpen:t,setIsWidgetOpen:n,hideChatBarInput:l}},Nd2=a=>{const t=cE0();return{handleOpen:()=>{t.capture("widget:opened",{start_view:a==null?void 0:a.startView}),globalThis.dispatchEvent(new Event(T8.OPEN)),globalThis.postMessage({event:T8.START,payload:a},globalThis.location.origin)},handleOpenAndSendMessage:o=>{setTimeout(()=>{globalThis.postMessage({event:T8.START,payload:{suggestionMessage:o}},globalThis.location.origin),globalThis.dispatchEvent(new Event(T8.OPEN))},400)}}},$d2="https://cdn.jsdelivr.net/npm/@freeday-ai/webchat",kd2=()=>{e.useEffect(()=>{const a=n=>{P21(n.error)},t=n=>{P21(n.reason)};return globalThis.addEventListener("error",a),globalThis.addEventListener("unhandledrejection",t),()=>{globalThis.removeEventListener("error",a),globalThis.removeEventListener("unhandledrejection",t)}},[])},P21=a=>{var t;(t=a==null?void 0:a.stack)!=null&&t.includes($d2)&&W6(a)};class Dd2 extends e.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){W6(t,"Uncaught rendering error",{componentStack:n.componentStack})}render(){return this.props.children}}function Pd2(a){e.useEffect(()=>{if(!a)return;const t=document.body,n=window.scrollY,l=t.style.position,o=t.style.top;return t.style.position="fixed",t.style.top=`-${n}px`,t.style.width="100%",()=>{t.style.position=l,t.style.top=o,window.scrollTo(0,n)}},[a])}const Od2=({channelId:a,metadata:t})=>{kd2();const{widgetSettings:n}=Td2(a);return!a||!n?null:_.jsx(Dd2,{children:_.jsx(Xr1,{config:{...n,metadata:t?JSON.parse(t):void 0},inShadowDom:!0,children:_.jsx(_d2,{widgetSettings:{...n,metadata:t?JSON.parse(t):void 0}})})})},_d2=({widgetSettings:a})=>{const t=a.startView===F3.FULL_SCREEN,n=a.startView===F3.UNFOLDED_CHAT_VIEW,l=t||n,{isWidgetOpen:o,setIsWidgetOpen:i}=xd2(l),{handleOpen:s,handleOpenAndSendMessage:u}=Nd2(a),A=cd("(max-width: 640px)");return Pd2(o&&A),e.useEffect(()=>{if(!l)return;i(!0);const p=requestAnimationFrame(s);return()=>cancelAnimationFrame(p)},[]),_.jsxs(_.Fragment,{children:[_.jsx(T7,{children:o&&_.jsx(ll.div,{className:W2("chat-window-renderer",{"full-screen":t}),"data-testid":"chat-window-renderer",initial:{opacity:0,y:30},animate:{opacity:1,y:0,transition:{delay:.2}},exit:{opacity:0,y:30},transition:{duration:.35,ease:[.42,0,0,1]},transformTemplate:t?(p,g)=>`translateX(-50%) ${g}`:void 0,children:_.jsx(nr2,{children:_.jsx("div",{className:"widget-chat-container flex flex-col",children:_.jsx(Rd2,{})})})})}),!t&&_.jsx(T7,{children:!o&&_.jsx(ll.div,{className:"button-container",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1,transition:{delay:.3}},exit:{opacity:0,scale:0},transition:{duration:.3,ease:[.42,0,0,1]},children:_.jsx(z32,{onOpen:s,onSendMessage:u})})})]})};_41("freeday-widget",Od2,["channelId","metadata"]);const O21=a=>{const{channelId:t,metadata:n}=a,l=document.createElement("div"),o=document.createElement("freeday-widget");o.setAttribute("channelId",t),n&&o.setAttribute("metadata",JSON.stringify(n)),l.appendChild(o),document.body?document.body.appendChild(l):window.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(l)})};return window.FreedayWidget={bootstrap:O21},Kf.bootstrap=O21,Object.defineProperty(Kf,Symbol.toStringTag,{value:"Module"}),Kf})({});
package/dist/webchat.mjs CHANGED
@@ -117319,9 +117319,9 @@ class zg2 extends e.Component {
117319
117319
  function jg2(a) {
117320
117320
  e.useEffect(() => {
117321
117321
  if (!a) return;
117322
- const t = document.body, n = t.style.overflow;
117323
- return t.style.overflow = "hidden", () => {
117324
- t.style.overflow = n;
117322
+ const t = document.body, n = window.scrollY, l = t.style.position, o = t.style.top;
117323
+ return t.style.position = "fixed", t.style.top = `-${n}px`, t.style.width = "100%", () => {
117324
+ t.style.position = l, t.style.top = o, window.scrollTo(0, n);
117325
117325
  };
117326
117326
  }, [a]);
117327
117327
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freeday-ai/webchat",
3
- "version": "2025.11.04.07.07.9962",
3
+ "version": "2025.11.05.12.05.10993",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist"
@@ -39,9 +39,9 @@
39
39
  "@testing-library/jest-dom": "^6.5.0",
40
40
  "@testing-library/react": "^16.0.0",
41
41
  "@types/lodash": "^4.17.9",
42
- "@types/node": "^22.0.0",
43
- "@types/react": "^18",
44
- "@types/react-dom": "^18",
42
+ "@types/node": "^24.0.0",
43
+ "@types/react": "^19.0.0",
44
+ "@types/react-dom": "^19.0.0",
45
45
  "@types/react-i18next": "^8.1.0",
46
46
  "@vitejs/plugin-react": "^5.0.0",
47
47
  "@vitest/coverage-v8": "^2.1.2",