@runtypelabs/persona 3.31.1 → 3.34.0
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/README.md +17 -10
- package/dist/animations/glyph-cycle.d.cts +1 -1
- package/dist/animations/glyph-cycle.d.ts +1 -1
- package/dist/animations/{types-quh7NmYD.d.cts → types-CthJFfNx.d.cts} +7 -0
- package/dist/animations/{types-quh7NmYD.d.ts → types-CthJFfNx.d.ts} +7 -0
- package/dist/animations/wipe.d.cts +1 -1
- package/dist/animations/wipe.d.ts +1 -1
- package/dist/codegen.cjs +1 -1
- package/dist/codegen.js +1 -1
- package/dist/index.cjs +43 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +320 -8
- package/dist/index.d.ts +320 -8
- package/dist/index.global.js +193 -192
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +43 -43
- package/dist/index.js.map +1 -1
- package/dist/launcher.global.js +117 -117
- package/dist/launcher.global.js.map +1 -1
- package/dist/smart-dom-reader.d.cts +110 -2
- package/dist/smart-dom-reader.d.ts +110 -2
- package/dist/theme-editor.cjs +30 -30
- package/dist/theme-editor.d.cts +124 -5
- package/dist/theme-editor.d.ts +124 -5
- package/dist/theme-editor.js +30 -30
- package/package.json +3 -3
- package/src/ask-user-question-tool.test.ts +148 -0
- package/src/ask-user-question-tool.ts +138 -0
- package/src/client.ts +43 -9
- package/src/codegen.test.ts +0 -14
- package/src/components/messages.ts +10 -0
- package/src/components/suggestions.ts +49 -6
- package/src/index-core.ts +15 -0
- package/src/runtime/host-layout.test.ts +206 -9
- package/src/runtime/host-layout.ts +121 -8
- package/src/runtime/init.test.ts +2 -2
- package/src/session.ts +188 -32
- package/src/session.webmcp.test.ts +48 -0
- package/src/suggest-replies-tool.test.ts +445 -0
- package/src/suggest-replies-tool.ts +152 -0
- package/src/theme-editor/index.ts +2 -0
- package/src/theme-editor/webmcp/index.ts +2 -0
- package/src/theme-editor/webmcp/types.ts +16 -3
- package/src/types.ts +108 -2
- package/src/ui.docked.test.ts +2 -2
- package/src/ui.suggest-replies.test.ts +237 -0
- package/src/ui.ts +57 -13
- package/src/utils/dock.test.ts +23 -1
- package/src/utils/dock.ts +2 -0
- package/src/voice/voice.test.ts +0 -51
- package/src/install-config.test.ts +0 -38
package/dist/index.global.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
"use strict";var AgentWidget=(()=>{var
|
|
2
|
-
\r `.includes(r[
|
|
3
|
-
`).map(
|
|
4
|
-
`)}var
|
|
5
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let
|
|
6
|
-
$1`);
|
|
7
|
-
`);let
|
|
8
|
-
`,1)[0].replace(/^\t+/,M=>" ".repeat(3*M.length)),
|
|
9
|
-
`,1)[0],m=0;this.options.pedantic?(m=2,d=f.trimStart()):(m=t[2].search(/[^ ]/),m=m>4?1:m,d=f.slice(m),m+=t[1].length);let
|
|
10
|
-
`,e=e.substring(
|
|
11
|
-
`,1)[0];if(
|
|
12
|
-
`+
|
|
13
|
-
`+
|
|
14
|
-
`,e=e.substring(w.length+1),f=
|
|
15
|
-
`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(
|
|
16
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:
|
|
17
|
-
]`).replace("lheading"
|
|
18
|
-
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let
|
|
19
|
-
`:t.push(
|
|
20
|
-
`+
|
|
21
|
-
`+
|
|
22
|
-
`+
|
|
23
|
-
`+
|
|
24
|
-
`+
|
|
25
|
-
`+
|
|
26
|
-
`+
|
|
27
|
-
`+
|
|
28
|
-
`,
|
|
29
|
-
`:"<pre><code>"+(
|
|
1
|
+
"use strict";var AgentWidget=(()=>{var ib=Object.create;var Rs=Object.defineProperty;var lb=Object.getOwnPropertyDescriptor;var db=Object.getOwnPropertyNames;var cb=Object.getPrototypeOf,pb=Object.prototype.hasOwnProperty;var zg=r=>{throw TypeError(r)};var ub=(r,e,t)=>e in r?Rs(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var fb=(r=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(r,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):r)(function(r){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var $g=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),mb=(r,e)=>{for(var t in e)Rs(r,t,{get:e[t],enumerable:!0})},Vg=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of db(e))!pb.call(r,n)&&n!==t&&Rs(r,n,{get:()=>e[n],enumerable:!(o=lb(e,n))||o.enumerable});return r};var Bi=(r,e,t)=>(t=r!=null?ib(cb(r)):{},Vg(e||!r||!r.__esModule?Rs(t,"default",{value:r,enumerable:!0}):t,r)),gb=r=>Vg(Rs({},"__esModule",{value:!0}),r);var lr=(r,e,t)=>ub(r,typeof e!="symbol"?e+"":e,t),hb=(r,e,t)=>e.has(r)||zg("Cannot "+t);var jg=(r,e,t)=>e.has(r)?zg("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t);var Di=(r,e,t)=>(hb(r,e,"access private method"),t);var Wd=$g($e=>{"use strict";Object.defineProperty($e,"__esModule",{value:!0});$e.Allow=$e.ALL=$e.COLLECTION=$e.ATOM=$e.SPECIAL=$e.INF=$e._INFINITY=$e.INFINITY=$e.NAN=$e.BOOL=$e.NULL=$e.OBJ=$e.ARR=$e.NUM=$e.STR=void 0;$e.STR=1;$e.NUM=2;$e.ARR=4;$e.OBJ=8;$e.NULL=16;$e.BOOL=32;$e.NAN=64;$e.INFINITY=128;$e._INFINITY=256;$e.INF=$e.INFINITY|$e._INFINITY;$e.SPECIAL=$e.NULL|$e.BOOL|$e.INF|$e.NAN;$e.ATOM=$e.STR|$e.NUM|$e.SPECIAL;$e.COLLECTION=$e.ARR|$e.OBJ;$e.ALL=$e.ATOM|$e.COLLECTION;$e.Allow={STR:$e.STR,NUM:$e.NUM,ARR:$e.ARR,OBJ:$e.OBJ,NULL:$e.NULL,BOOL:$e.BOOL,NAN:$e.NAN,INFINITY:$e.INFINITY,_INFINITY:$e._INFINITY,INF:$e.INF,SPECIAL:$e.SPECIAL,ATOM:$e.ATOM,COLLECTION:$e.COLLECTION,ALL:$e.ALL};$e.default=$e.Allow});var ji=$g(Qr=>{"use strict";var q0=Qr&&Qr.__createBinding||(Object.create?(function(r,e,t,o){o===void 0&&(o=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,o,n)}):(function(r,e,t,o){o===void 0&&(o=t),r[o]=e[t]})),z0=Qr&&Qr.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&q0(e,r,t)};Object.defineProperty(Qr,"__esModule",{value:!0});Qr.Allow=Qr.MalformedJSON=Qr.PartialJSON=Qr.parseJSON=Qr.parse=void 0;var wo=Wd();Object.defineProperty(Qr,"Allow",{enumerable:!0,get:function(){return wo.Allow}});z0(Wd(),Qr);var $i=class extends Error{};Qr.PartialJSON=$i;var Vi=class extends Error{};Qr.MalformedJSON=Vi;function Dh(r,e=wo.Allow.ALL){if(typeof r!="string")throw new TypeError(`expecting str, got ${typeof r}`);if(!r.trim())throw new Error(`${r} is empty`);return $0(r.trim(),e)}Qr.parseJSON=Dh;var $0=(r,e)=>{let t=r.length,o=0,n=p=>{throw new $i(`${p} at position ${o}`)},a=p=>{throw new Vi(`${p} at position ${o}`)},s=()=>(f(),o>=t&&n("Unexpected end of input"),r[o]==='"'?i():r[o]==="{"?d():r[o]==="["?l():r.substring(o,o+4)==="null"||wo.Allow.NULL&e&&t-o<4&&"null".startsWith(r.substring(o))?(o+=4,null):r.substring(o,o+4)==="true"||wo.Allow.BOOL&e&&t-o<4&&"true".startsWith(r.substring(o))?(o+=4,!0):r.substring(o,o+5)==="false"||wo.Allow.BOOL&e&&t-o<5&&"false".startsWith(r.substring(o))?(o+=5,!1):r.substring(o,o+8)==="Infinity"||wo.Allow.INFINITY&e&&t-o<8&&"Infinity".startsWith(r.substring(o))?(o+=8,1/0):r.substring(o,o+9)==="-Infinity"||wo.Allow._INFINITY&e&&1<t-o&&t-o<9&&"-Infinity".startsWith(r.substring(o))?(o+=9,-1/0):r.substring(o,o+3)==="NaN"||wo.Allow.NAN&e&&t-o<3&&"NaN".startsWith(r.substring(o))?(o+=3,NaN):u()),i=()=>{let p=o,m=!1;for(o++;o<t&&(r[o]!=='"'||m&&r[o-1]==="\\");)m=r[o]==="\\"?!m:!1,o++;if(r.charAt(o)=='"')try{return JSON.parse(r.substring(p,++o-Number(m)))}catch(y){a(String(y))}else if(wo.Allow.STR&e)try{return JSON.parse(r.substring(p,o-Number(m))+'"')}catch{return JSON.parse(r.substring(p,r.lastIndexOf("\\"))+'"')}n("Unterminated string literal")},d=()=>{o++,f();let p={};try{for(;r[o]!=="}";){if(f(),o>=t&&wo.Allow.OBJ&e)return p;let m=i();f(),o++;try{let y=s();p[m]=y}catch(y){if(wo.Allow.OBJ&e)return p;throw y}f(),r[o]===","&&o++}}catch{if(wo.Allow.OBJ&e)return p;n("Expected '}' at end of object")}return o++,p},l=()=>{o++;let p=[];try{for(;r[o]!=="]";)p.push(s()),f(),r[o]===","&&o++}catch{if(wo.Allow.ARR&e)return p;n("Expected ']' at end of array")}return o++,p},u=()=>{if(o===0){r==="-"&&a("Not sure what '-' is");try{return JSON.parse(r)}catch(m){if(wo.Allow.NUM&e)try{return JSON.parse(r.substring(0,r.lastIndexOf("e")))}catch{}a(String(m))}}let p=o;for(r[o]==="-"&&o++;r[o]&&",]}".indexOf(r[o])===-1;)o++;o==t&&!(wo.Allow.NUM&e)&&n("Unterminated number literal");try{return JSON.parse(r.substring(p,o))}catch{r.substring(p,o)==="-"&&n("Not sure what '-' is");try{return JSON.parse(r.substring(p,r.lastIndexOf("e")))}catch(y){a(String(y))}}},f=()=>{for(;o<t&&`
|
|
2
|
+
\r `.includes(r[o]);)o++};return s()},V0=Dh;Qr.parse=V0});var Kw={};mb(Kw,{ASK_USER_QUESTION_CLIENT_TOOL:()=>$d,ASK_USER_QUESTION_PARAMETERS_SCHEMA:()=>zd,ASK_USER_QUESTION_TOOL_NAME:()=>$s,AgentWidgetClient:()=>ya,AgentWidgetSession:()=>Za,AttachmentManager:()=>wa,DEFAULT_COMPONENTS:()=>$p,DEFAULT_FLOATING_LAUNCHER_MAX_WIDTH:()=>Sl,DEFAULT_FLOATING_LAUNCHER_WIDTH:()=>Wo,DEFAULT_PALETTE:()=>qp,DEFAULT_SEMANTIC:()=>zp,DEFAULT_WIDGET_CONFIG:()=>Xt,PRESETS:()=>Lu,PRESET_FULLSCREEN:()=>Eu,PRESET_MINIMAL:()=>ku,PRESET_SHOP:()=>Mu,SUGGEST_REPLIES_CLIENT_TOOL:()=>Qi,SUGGEST_REPLIES_PARAMETERS_SCHEMA:()=>Fd,SUGGEST_REPLIES_TOOL_NAME:()=>en,THEME_ZONES:()=>bx,VERSION:()=>By,WEBMCP_TOOL_PREFIX:()=>Cn,WebMcpBridge:()=>Ga,accessibilityPlugin:()=>Dy,animationsPlugin:()=>Oy,applyThemeVariables:()=>Vn,attachHeaderToContainer:()=>Ta,brandPlugin:()=>_y,buildComposer:()=>ns,buildDefaultHeader:()=>eu,buildHeader:()=>kn,buildHeaderWithLayout:()=>os,buildMinimalHeader:()=>tu,builtInClientToolsForDispatch:()=>Gs,collectEnrichedPageContext:()=>Iy,componentRegistry:()=>En,createActionManager:()=>hi,createAgentExperience:()=>sd,createAskUserQuestionBubble:()=>Xh,createBestAvailableVoiceProvider:()=>ul,createBubbleWithLayout:()=>Ux,createCSATFeedback:()=>od,createComboButton:()=>Nl,createComponentMiddleware:()=>py,createComponentStreamParser:()=>Zl,createDefaultSanitizer:()=>Pd,createDirectivePostprocessor:()=>uh,createDropdownMenu:()=>Xn,createFlexibleJsonStreamParser:()=>Zh,createIconButton:()=>Br,createImagePart:()=>sx,createJsonStreamParser:()=>nl,createLabelButton:()=>ci,createLocalStorageAdapter:()=>Jl,createMarkdownProcessor:()=>_s,createMarkdownProcessorFromConfig:()=>ua,createMessageActions:()=>su,createNPSFeedback:()=>nd,createPlainTextParser:()=>rl,createPlugin:()=>Uy,createRegexJsonParser:()=>ol,createStandardBubble:()=>as,createTextPart:()=>Qs,createTheme:()=>ts,createThemeObserver:()=>El,createToggleGroup:()=>Wx,createTypingIndicator:()=>Ma,createVoiceProvider:()=>Ca,createWidgetHostLayout:()=>xi,createXmlParser:()=>al,defaultActionHandlers:()=>Ea,defaultJsonActionParser:()=>gi,defaultParseRules:()=>Su,detectColorScheme:()=>ti,directivePostprocessor:()=>fh,ensureAskUserQuestionSheet:()=>Qa,escapeHtml:()=>fa,extractComponentDirectiveFromMessage:()=>rd,fileToImagePart:()=>ix,formatEnrichedContext:()=>Hy,generateAssistantMessageId:()=>ba,generateMessageId:()=>tx,generateStableSelector:()=>Tu,generateUserMessageId:()=>Ja,getActiveTheme:()=>rs,getColorScheme:()=>jp,getDisplayText:()=>ox,getHeaderLayout:()=>ru,getImageParts:()=>ax,getPreset:()=>zy,hasComponentDirective:()=>td,hasImages:()=>nx,headerLayouts:()=>Fl,highContrastPlugin:()=>Fy,initAgentWidget:()=>Cy,isAskUserQuestionMessage:()=>wn,isComponentDirectiveType:()=>cy,isDockedMountMode:()=>Lr,isSuggestRepliesMessage:()=>js,isVoiceSupported:()=>Js,isWebMcpToolName:()=>ga,latestAgentSuggestions:()=>Yi,listRegisteredStreamAnimations:()=>Qp,markdownPostprocessor:()=>wd,mergeWithDefaults:()=>Tl,normalizeContent:()=>rx,parseAskUserQuestionPayload:()=>An,parseSuggestRepliesPayload:()=>qd,pluginRegistry:()=>mi,reducedMotionPlugin:()=>Ny,registerStreamAnimationPlugin:()=>Sa,removeAskUserQuestionSheet:()=>zn,renderComponentDirective:()=>ed,renderLoadingIndicatorWithFallback:()=>au,renderLucideIcon:()=>Ee,resolveDockConfig:()=>Bo,resolveSanitizer:()=>ja,resolveTokens:()=>Ml,stripWebMcpPrefix:()=>zi,themeToCssVariables:()=>kl,unregisterStreamAnimationPlugin:()=>Xp,validateImageFile:()=>lx,validateTheme:()=>Vp});function hd(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var pa=hd();function Jg(r){pa=r}var Zg=/[&<>"']/,xb=new RegExp(Zg.source,"g"),eh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,yb=new RegExp(eh.source,"g"),bb={"&":"&","<":"<",">":">",'"':""","'":"'"},Gg=r=>bb[r];function Ho(r,e){if(e){if(Zg.test(r))return r.replace(xb,Gg)}else if(eh.test(r))return r.replace(yb,Gg);return r}var vb=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Cb(r){return r.replace(vb,(e,t)=>(t=t.toLowerCase(),t==="colon"?":":t.charAt(0)==="#"?t.charAt(1)==="x"?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}var wb=/(^|[^\[])\^/g;function rr(r,e){let t=typeof r=="string"?r:r.source;e=e||"";let o={replace:(n,a)=>{let s=typeof a=="string"?a:a.source;return s=s.replace(wb,"$1"),t=t.replace(n,s),o},getRegex:()=>new RegExp(t,e)};return o}function Kg(r){try{r=encodeURI(r).replace(/%25/g,"%")}catch{return null}return r}var Hs={exec:()=>null};function Xg(r,e){let t=r.replace(/\|/g,(a,s,i)=>{let d=!1,l=s;for(;--l>=0&&i[l]==="\\";)d=!d;return d?"|":" |"}),o=t.split(/ \|/),n=0;if(o[0].trim()||o.shift(),o.length>0&&!o[o.length-1].trim()&&o.pop(),e)if(o.length>e)o.splice(e);else for(;o.length<e;)o.push("");for(;n<o.length;n++)o[n]=o[n].trim().replace(/\\\|/g,"|");return o}function Oi(r,e,t){let o=r.length;if(o===0)return"";let n=0;for(;n<o;){let a=r.charAt(o-n-1);if(a===e&&!t)n++;else if(a!==e&&t)n++;else break}return r.slice(0,o-n)}function Ab(r,e){if(r.indexOf(e[1])===-1)return-1;let t=0;for(let o=0;o<r.length;o++)if(r[o]==="\\")o++;else if(r[o]===e[0])t++;else if(r[o]===e[1]&&(t--,t<0))return o;return-1}function Qg(r,e,t,o){let n=e.href,a=e.title?Ho(e.title):null,s=r[1].replace(/\\([\[\]])/g,"$1");if(r[0].charAt(0)!=="!"){o.state.inLink=!0;let i={type:"link",raw:t,href:n,title:a,text:s,tokens:o.inlineTokens(s)};return o.state.inLink=!1,i}return{type:"image",raw:t,href:n,title:a,text:Ho(s)}}function Sb(r,e){let t=r.match(/^(\s+)(?:```)/);if(t===null)return e;let o=t[1];return e.split(`
|
|
3
|
+
`).map(n=>{let a=n.match(/^\s+/);if(a===null)return n;let[s]=a;return s.length>=o.length?n.slice(o.length):n}).join(`
|
|
4
|
+
`)}var qa=class{constructor(e){lr(this,"options");lr(this,"rules");lr(this,"lexer");this.options=e||pa}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let o=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?o:Oi(o,`
|
|
5
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let o=t[0],n=Sb(o,t[3]||"");return{type:"code",raw:o,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let o=t[2].trim();if(/#$/.test(o)){let n=Oi(o,"#");(this.options.pedantic||!n||/ $/.test(n))&&(o=n.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:o,tokens:this.lexer.inline(o)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let o=t[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
|
|
6
|
+
$1`);o=Oi(o.replace(/^ *>[ \t]?/gm,""),`
|
|
7
|
+
`);let n=this.lexer.state.top;this.lexer.state.top=!0;let a=this.lexer.blockTokens(o);return this.lexer.state.top=n,{type:"blockquote",raw:t[0],tokens:a,text:o}}}list(e){let t=this.rules.block.list.exec(e);if(t){let o=t[1].trim(),n=o.length>1,a={type:"list",raw:"",ordered:n,start:n?+o.slice(0,-1):"",loose:!1,items:[]};o=n?`\\d{1,9}\\${o.slice(-1)}`:`\\${o}`,this.options.pedantic&&(o=n?o:"[*+-]");let s=new RegExp(`^( {0,3}${o})((?:[ ][^\\n]*)?(?:\\n|$))`),i="",d="",l=!1;for(;e;){let u=!1;if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;i=t[0],e=e.substring(i.length);let f=t[2].split(`
|
|
8
|
+
`,1)[0].replace(/^\t+/,M=>" ".repeat(3*M.length)),p=e.split(`
|
|
9
|
+
`,1)[0],m=0;this.options.pedantic?(m=2,d=f.trimStart()):(m=t[2].search(/[^ ]/),m=m>4?1:m,d=f.slice(m),m+=t[1].length);let y=!1;if(!f&&/^ *$/.test(p)&&(i+=p+`
|
|
10
|
+
`,e=e.substring(p.length+1),u=!0),!u){let M=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),k=new RegExp(`^ {0,${Math.min(3,m-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),L=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:\`\`\`|~~~)`),x=new RegExp(`^ {0,${Math.min(3,m-1)}}#`);for(;e;){let w=e.split(`
|
|
11
|
+
`,1)[0];if(p=w,this.options.pedantic&&(p=p.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),L.test(p)||x.test(p)||M.test(p)||k.test(e))break;if(p.search(/[^ ]/)>=m||!p.trim())d+=`
|
|
12
|
+
`+p.slice(m);else{if(y||f.search(/[^ ]/)>=4||L.test(f)||x.test(f)||k.test(f))break;d+=`
|
|
13
|
+
`+p}!y&&!p.trim()&&(y=!0),i+=w+`
|
|
14
|
+
`,e=e.substring(w.length+1),f=p.slice(m)}}a.loose||(l?a.loose=!0:/\n *\n *$/.test(i)&&(l=!0));let h=null,T;this.options.gfm&&(h=/^\[[ xX]\] /.exec(d),h&&(T=h[0]!=="[ ] ",d=d.replace(/^\[[ xX]\] +/,""))),a.items.push({type:"list_item",raw:i,task:!!h,checked:T,loose:!1,text:d,tokens:[]}),a.raw+=i}a.items[a.items.length-1].raw=i.trimEnd(),a.items[a.items.length-1].text=d.trimEnd(),a.raw=a.raw.trimEnd();for(let u=0;u<a.items.length;u++)if(this.lexer.state.top=!1,a.items[u].tokens=this.lexer.blockTokens(a.items[u].text,[]),!a.loose){let f=a.items[u].tokens.filter(m=>m.type==="space"),p=f.length>0&&f.some(m=>/\n.*\n/.test(m.raw));a.loose=p}if(a.loose)for(let u=0;u<a.items.length;u++)a.items[u].loose=!0;return a}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let o=t[1].toLowerCase().replace(/\s+/g," "),n=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:o,raw:t[0],href:n,title:a}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!/[:|]/.test(t[2]))return;let o=Xg(t[1]),n=t[2].replace(/^\||\| *$/g,"").split("|"),a=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split(`
|
|
15
|
+
`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(o.length===n.length){for(let i of n)/^ *-+: *$/.test(i)?s.align.push("right"):/^ *:-+: *$/.test(i)?s.align.push("center"):/^ *:-+ *$/.test(i)?s.align.push("left"):s.align.push(null);for(let i of o)s.header.push({text:i,tokens:this.lexer.inline(i)});for(let i of a)s.rows.push(Xg(i,s.header.length).map(d=>({text:d,tokens:this.lexer.inline(d)})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let o=t[1].charAt(t[1].length-1)===`
|
|
16
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:o,tokens:this.lexer.inline(o)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:Ho(t[1])}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let o=t[2].trim();if(!this.options.pedantic&&/^</.test(o)){if(!/>$/.test(o))return;let s=Oi(o.slice(0,-1),"\\");if((o.length-s.length)%2===0)return}else{let s=Ab(t[2],"()");if(s>-1){let d=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,d).trim(),t[3]=""}}let n=t[2],a="";if(this.options.pedantic){let s=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);s&&(n=s[1],a=s[3])}else a=t[3]?t[3].slice(1,-1):"";return n=n.trim(),/^</.test(n)&&(this.options.pedantic&&!/>$/.test(o)?n=n.slice(1):n=n.slice(1,-1)),Qg(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer)}}reflink(e,t){let o;if((o=this.rules.inline.reflink.exec(e))||(o=this.rules.inline.nolink.exec(e))){let n=(o[2]||o[1]).replace(/\s+/g," "),a=t[n.toLowerCase()];if(!a){let s=o[0].charAt(0);return{type:"text",raw:s,text:s}}return Qg(o,a,o[0],this.lexer)}}emStrong(e,t,o=""){let n=this.rules.inline.emStrongLDelim.exec(e);if(!n||n[3]&&o.match(/[\p{L}\p{N}]/u))return;if(!(n[1]||n[2]||"")||!o||this.rules.inline.punctuation.exec(o)){let s=[...n[0]].length-1,i,d,l=s,u=0,f=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(f.lastIndex=0,t=t.slice(-1*e.length+s);(n=f.exec(t))!=null;){if(i=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!i)continue;if(d=[...i].length,n[3]||n[4]){l+=d;continue}else if((n[5]||n[6])&&s%3&&!((s+d)%3)){u+=d;continue}if(l-=d,l>0)continue;d=Math.min(d,d+l+u);let p=[...n[0]][0].length,m=e.slice(0,s+n.index+p+d);if(Math.min(s,d)%2){let h=m.slice(1,-1);return{type:"em",raw:m,text:h,tokens:this.lexer.inlineTokens(h)}}let y=m.slice(2,-2);return{type:"strong",raw:m,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let o=t[2].replace(/\n/g," "),n=/[^ ]/.test(o),a=/^ /.test(o)&&/ $/.test(o);return n&&a&&(o=o.substring(1,o.length-1)),o=Ho(o,!0),{type:"codespan",raw:t[0],text:o}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let o,n;return t[2]==="@"?(o=Ho(t[1]),n="mailto:"+o):(o=Ho(t[1]),n=o),{type:"link",raw:t[0],text:o,href:n,tokens:[{type:"text",raw:o,text:o}]}}}url(e){var o,n;let t;if(t=this.rules.inline.url.exec(e)){let a,s;if(t[2]==="@")a=Ho(t[0]),s="mailto:"+a;else{let i;do i=t[0],t[0]=(n=(o=this.rules.inline._backpedal.exec(t[0]))==null?void 0:o[0])!=null?n:"";while(i!==t[0]);a=Ho(t[0]),t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:a,href:s,tokens:[{type:"text",raw:a,text:a}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let o;return this.lexer.state.inRawBlock?o=t[0]:o=Ho(t[0]),{type:"text",raw:t[0],text:o}}}},Tb=/^(?: *(?:\n|$))+/,Mb=/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,kb=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ds=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Eb=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,th=/(?:[*+-]|\d{1,9}[.)])/,rh=rr(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,th).replace(/blockCode/g,/ {4}/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),xd=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Lb=/^[^\n]+/,yd=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Pb=rr(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",yd).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Rb=rr(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,th).getRegex(),Fi="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",bd=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ib=rr("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))","i").replace("comment",bd).replace("tag",Fi).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),oh=rr(xd).replace("hr",Ds).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fi).getRegex(),Hb=rr(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",oh).getRegex(),vd={blockquote:Hb,code:Mb,def:Pb,fences:kb,heading:Eb,hr:Ds,html:Ib,lheading:rh,list:Rb,newline:Tb,paragraph:oh,table:Hs,text:Lb},Yg=rr("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ds).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fi).getRegex(),Wb={...vd,table:Yg,paragraph:rr(xd).replace("hr",Ds).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Yg).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fi).getRegex()},Bb={...vd,html:rr(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",bd).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Hs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:rr(xd).replace("hr",Ds).replace("heading",` *#{1,6} *[^
|
|
17
|
+
]`).replace("lheading",rh).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},nh=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Db=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ah=/^( {2,}|\\)\n(?!\s*$)/,Ob=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Os="\\p{P}\\p{S}",_b=rr(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,Os).getRegex(),Nb=/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,Fb=rr(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,Os).getRegex(),Ub=rr("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,Os).getRegex(),qb=rr("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,Os).getRegex(),zb=rr(/\\([punct])/,"gu").replace(/punct/g,Os).getRegex(),$b=rr(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Vb=rr(bd).replace("(?:-->|$)","-->").getRegex(),jb=rr("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Vb).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ni=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Gb=rr(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Ni).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),sh=rr(/^!?\[(label)\]\[(ref)\]/).replace("label",Ni).replace("ref",yd).getRegex(),ih=rr(/^!?\[(ref)\](?:\[\])?/).replace("ref",yd).getRegex(),Kb=rr("reflink|nolink(?!\\()","g").replace("reflink",sh).replace("nolink",ih).getRegex(),Cd={_backpedal:Hs,anyPunctuation:zb,autolink:$b,blockSkip:Nb,br:ah,code:Db,del:Hs,emStrongLDelim:Fb,emStrongRDelimAst:Ub,emStrongRDelimUnd:qb,escape:nh,link:Gb,nolink:ih,punctuation:_b,reflink:sh,reflinkSearch:Kb,tag:jb,text:Ob,url:Hs},Xb={...Cd,link:rr(/^!?\[(label)\]\((.*?)\)/).replace("label",Ni).getRegex(),reflink:rr(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ni).getRegex()},md={...Cd,escape:rr(nh).replace("])","~|])").getRegex(),url:rr(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Qb={...md,br:rr(ah).replace("{2,}","*").getRegex(),text:rr(md.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},_i={normal:vd,gfm:Wb,pedantic:Bb},Is={normal:Cd,gfm:md,breaks:Qb,pedantic:Xb},bn=class r{constructor(e){lr(this,"tokens");lr(this,"options");lr(this,"state");lr(this,"tokenizer");lr(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||pa,this.options.tokenizer=this.options.tokenizer||new qa,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={block:_i.normal,inline:Is.normal};this.options.pedantic?(t.block=_i.pedantic,t.inline=Is.pedantic):this.options.gfm&&(t.block=_i.gfm,this.options.breaks?t.inline=Is.breaks:t.inline=Is.gfm),this.tokenizer.rules=t}static get rules(){return{block:_i,inline:Is}}static lex(e,t){return new r(t).lex(e)}static lexInline(e,t){return new r(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,`
|
|
18
|
+
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let o=this.inlineQueue[t];this.inlineTokens(o.src,o.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[]){this.options.pedantic?e=e.replace(/\t/g," ").replace(/^ +$/gm,""):e=e.replace(/^( *)(\t+)/gm,(i,d,l)=>d+" ".repeat(l.length));let o,n,a,s;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(i=>(o=i.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))){if(o=this.tokenizer.space(e)){e=e.substring(o.raw.length),o.raw.length===1&&t.length>0?t[t.length-1].raw+=`
|
|
19
|
+
`:t.push(o);continue}if(o=this.tokenizer.code(e)){e=e.substring(o.raw.length),n=t[t.length-1],n&&(n.type==="paragraph"||n.type==="text")?(n.raw+=`
|
|
20
|
+
`+o.raw,n.text+=`
|
|
21
|
+
`+o.text,this.inlineQueue[this.inlineQueue.length-1].src=n.text):t.push(o);continue}if(o=this.tokenizer.fences(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.heading(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.hr(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.blockquote(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.list(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.html(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.def(e)){e=e.substring(o.raw.length),n=t[t.length-1],n&&(n.type==="paragraph"||n.type==="text")?(n.raw+=`
|
|
22
|
+
`+o.raw,n.text+=`
|
|
23
|
+
`+o.raw,this.inlineQueue[this.inlineQueue.length-1].src=n.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title});continue}if(o=this.tokenizer.table(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.lheading(e)){e=e.substring(o.raw.length),t.push(o);continue}if(a=e,this.options.extensions&&this.options.extensions.startBlock){let i=1/0,d=e.slice(1),l;this.options.extensions.startBlock.forEach(u=>{l=u.call({lexer:this},d),typeof l=="number"&&l>=0&&(i=Math.min(i,l))}),i<1/0&&i>=0&&(a=e.substring(0,i+1))}if(this.state.top&&(o=this.tokenizer.paragraph(a))){n=t[t.length-1],s&&n.type==="paragraph"?(n.raw+=`
|
|
24
|
+
`+o.raw,n.text+=`
|
|
25
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=n.text):t.push(o),s=a.length!==e.length,e=e.substring(o.raw.length);continue}if(o=this.tokenizer.text(e)){e=e.substring(o.raw.length),n=t[t.length-1],n&&n.type==="text"?(n.raw+=`
|
|
26
|
+
`+o.raw,n.text+=`
|
|
27
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=n.text):t.push(o);continue}if(e){let i="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw new Error(i)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let o,n,a,s=e,i,d,l;if(this.tokens.links){let u=Object.keys(this.tokens.links);if(u.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)u.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,i.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(d||(l=""),d=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(u=>(o=u.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))){if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),n=t[t.length-1],n&&o.type==="text"&&n.type==="text"?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length),n=t[t.length-1],n&&o.type==="text"&&n.type==="text"?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,s,l)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}if(a=e,this.options.extensions&&this.options.extensions.startInline){let u=1/0,f=e.slice(1),p;this.options.extensions.startInline.forEach(m=>{p=m.call({lexer:this},f),typeof p=="number"&&p>=0&&(u=Math.min(u,p))}),u<1/0&&u>=0&&(a=e.substring(0,u+1))}if(o=this.tokenizer.inlineText(a)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(l=o.raw.slice(-1)),d=!0,n=t[t.length-1],n&&n.type==="text"?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return t}},za=class{constructor(e){lr(this,"options");this.options=e||pa}code(e,t,o){var a;let n=(a=(t||"").match(/^\S*/))==null?void 0:a[0];return e=e.replace(/\n$/,"")+`
|
|
28
|
+
`,n?'<pre><code class="language-'+Ho(n)+'">'+(o?e:Ho(e,!0))+`</code></pre>
|
|
29
|
+
`:"<pre><code>"+(o?e:Ho(e,!0))+`</code></pre>
|
|
30
30
|
`}blockquote(e){return`<blockquote>
|
|
31
31
|
${e}</blockquote>
|
|
32
|
-
`}html(e,t){return e}heading(e,t,
|
|
32
|
+
`}html(e,t){return e}heading(e,t,o){return`<h${t}>${e}</h${t}>
|
|
33
33
|
`}hr(){return`<hr>
|
|
34
|
-
`}list(e,t,
|
|
35
|
-
`+e+"</"+
|
|
36
|
-
`}listitem(e,t,
|
|
34
|
+
`}list(e,t,o){let n=t?"ol":"ul",a=t&&o!==1?' start="'+o+'"':"";return"<"+n+a+`>
|
|
35
|
+
`+e+"</"+n+`>
|
|
36
|
+
`}listitem(e,t,o){return`<li>${e}</li>
|
|
37
37
|
`}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph(e){return`<p>${e}</p>
|
|
38
38
|
`}table(e,t){return t&&(t=`<tbody>${t}</tbody>`),`<table>
|
|
39
39
|
<thead>
|
|
@@ -41,25 +41,26 @@ ${e}</blockquote>
|
|
|
41
41
|
`+t+`</table>
|
|
42
42
|
`}tablerow(e){return`<tr>
|
|
43
43
|
${e}</tr>
|
|
44
|
-
`}tablecell(e,t){let
|
|
45
|
-
`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,t,
|
|
46
|
-
`+(s.tokens?this.parseInline(s.tokens):s.text);
|
|
47
|
-
Please report this to https://github.com/markedjs/marked.`,e){let o="<p>An error occurred:</p><pre>"+yn(n.message+"",!0)+"</pre>";return t?Promise.resolve(o):o}if(t)return Promise.reject(n);throw n}};var na=new Ms;function nr(r,e){return na.parse(r,e)}nr.options=nr.setOptions=function(r){return na.setOptions(r),nr.defaults=na.defaults,_g(nr.defaults),nr};nr.getDefaults=sd;nr.defaults=aa;nr.use=function(...r){return na.use(...r),nr.defaults=na.defaults,_g(nr.defaults),nr};nr.walkTokens=function(r,e){return na.walkTokens(r,e)};nr.parseInline=na.parseInline;nr.Parser=fo;nr.parser=fo.parse;nr.Renderer=Ba;nr.TextRenderer=Ts;nr.Lexer=uo;nr.lexer=uo.lex;nr.Tokenizer=Ha;nr.Hooks=ra;nr.parse=nr;var gw=nr.options,hw=nr.setOptions,xw=nr.use,bw=nr.walkTokens,yw=nr.parseInline;var vw=fo.parse,Cw=uo.lex;var Ry=r=>{if(r)return r},Ls=r=>{var o,a;let e=r==null?void 0:r.markedOptions,t=new Ms({gfm:(o=e==null?void 0:e.gfm)!=null?o:!0,breaks:(a=e==null?void 0:e.breaks)!=null?a:!0,pedantic:e==null?void 0:e.pedantic,silent:e==null?void 0:e.silent}),n=Ry(r==null?void 0:r.renderer);return n&&t.use({renderer:n}),s=>t.parse(s)},sa=r=>r?Ls({markedOptions:r.options,renderer:r.renderer}):Ls(),Iy=Ls(),ud=r=>Iy(r),ia=r=>r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Yg=r=>r.replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),Jg=r=>`%%FORM_PLACEHOLDER_${r}%%`,Zg=(r,e)=>{let t=r;return t=t.replace(/<Directive>([\s\S]*?)<\/Directive>/gi,(n,o)=>{try{let a=JSON.parse(o.trim());if(a&&typeof a=="object"&&a.component==="form"&&a.type){let s=Jg(e.length);return e.push({token:s,type:String(a.type)}),s}}catch{return n}return n}),t=t.replace(/<Form\s+type="([^"]+)"\s*\/>/gi,(n,o)=>{let a=Jg(e.length);return e.push({token:a,type:o}),a}),t},eh=r=>{let e=sa(r);return t=>{let n=[],o=Zg(t,n),a=e(o);return n.forEach(({token:s,type:i})=>{let d=new RegExp(s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),p=`<div class="persona-form-directive" data-tv-form="${Yg(i)}"></div>`;a=a.replace(d,p)}),a}},th=r=>{let e=[],t=Zg(r,e),n=ud(t);return e.forEach(({token:o,type:a})=>{let s=new RegExp(o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),d=`<div class="persona-form-directive" data-tv-form="${Yg(a)}"></div>`;n=n.replace(s,d)}),n};var{entries:ch,setPrototypeOf:rh,isFrozen:Wy,getPrototypeOf:Hy,getOwnPropertyDescriptor:By}=Object,{freeze:Zr,seal:Wn,create:Ri}=Object,{apply:yd,construct:vd}=typeof Reflect!="undefined"&&Reflect;Zr||(Zr=function(e){return e});Wn||(Wn=function(e){return e});yd||(yd=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),a=2;a<n;a++)o[a-2]=arguments[a];return e.apply(t,o)});vd||(vd=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return new e(...n)});var Li=en(Array.prototype.forEach),Dy=en(Array.prototype.lastIndexOf),nh=en(Array.prototype.pop),Ps=en(Array.prototype.push),Fy=en(Array.prototype.splice),Ii=en(String.prototype.toLowerCase),fd=en(String.prototype.toString),md=en(String.prototype.match),Rs=en(String.prototype.replace),Ny=en(String.prototype.indexOf),Oy=en(String.prototype.trim),vn=en(Object.prototype.hasOwnProperty),Yr=en(RegExp.prototype.test),Is=_y(TypeError);function en(r){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return yd(r,e,n)}}function _y(r){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return vd(r,t)}}function Ht(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ii;rh&&rh(r,null);let n=e.length;for(;n--;){let o=e[n];if(typeof o=="string"){let a=t(o);a!==o&&(Wy(e)||(e[n]=a),o=a)}r[o]=!0}return r}function Uy(r){for(let e=0;e<r.length;e++)vn(r,e)||(r[e]=null);return r}function eo(r){let e=Ri(null);for(let[t,n]of ch(r))vn(r,t)&&(Array.isArray(n)?e[t]=Uy(n):n&&typeof n=="object"&&n.constructor===Object?e[t]=eo(n):e[t]=n);return e}function Ws(r,e){for(;r!==null;){let n=By(r,e);if(n){if(n.get)return en(n.get);if(typeof n.value=="function")return en(n.value)}r=Hy(r)}function t(){return null}return t}var oh=Zr(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),gd=Zr(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),hd=Zr(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),qy=Zr(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),xd=Zr(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),zy=Zr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ah=Zr(["#text"]),sh=Zr(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),bd=Zr(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),ih=Zr(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Pi=Zr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),$y=Wn(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Vy=Wn(/<%[\w\W]*|[\w\W]*%>/gm),jy=Wn(/\$\{[\w\W]*/gm),Gy=Wn(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ky=Wn(/^aria-[\-\w]+$/),ph=Wn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Xy=Wn(/^(?:\w+script|data):/i),Qy=Wn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),uh=Wn(/^html$/i),Jy=Wn(/^[a-z][.\w]*(-[.\w]+)+$/i),lh=Object.freeze({__proto__:null,ARIA_ATTR:Ky,ATTR_WHITESPACE:Qy,CUSTOM_ELEMENT:Jy,DATA_ATTR:Gy,DOCTYPE_NAME:uh,ERB_EXPR:Vy,IS_ALLOWED_URI:ph,IS_SCRIPT_OR_DATA:Xy,MUSTACHE_EXPR:$y,TMPLIT_EXPR:jy}),Hs={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Yy=function(){return typeof window=="undefined"?null:window},Zy=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null,o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));let a="dompurify"+(n?"#"+n:"");try{return e.createPolicy(a,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},dh=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function fh(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Yy(),e=_e=>fh(_e);if(e.version="3.3.3",e.removed=[],!r||!r.document||r.document.nodeType!==Hs.document||!r.Element)return e.isSupported=!1,e;let{document:t}=r,n=t,o=n.currentScript,{DocumentFragment:a,HTMLTemplateElement:s,Node:i,Element:d,NodeFilter:l,NamedNodeMap:p=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:f,DOMParser:u,trustedTypes:m}=r,v=d.prototype,x=Ws(v,"cloneNode"),S=Ws(v,"remove"),M=Ws(v,"nextSibling"),E=Ws(v,"childNodes"),k=Ws(v,"parentNode");if(typeof s=="function"){let _e=t.createElement("template");_e.content&&_e.content.ownerDocument&&(t=_e.content.ownerDocument)}let h,w="",{implementation:C,createNodeIterator:T,createDocumentFragment:W,getElementsByTagName:R}=t,{importNode:I}=n,N=dh();e.isSupported=typeof ch=="function"&&typeof k=="function"&&C&&C.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:V,ERB_EXPR:ie,TMPLIT_EXPR:xe,DATA_ATTR:Je,ARIA_ATTR:we,IS_SCRIPT_OR_DATA:De,ATTR_WHITESPACE:Ae,CUSTOM_ELEMENT:qe}=lh,{IS_ALLOWED_URI:Ie}=lh,J=null,re=Ht({},[...oh,...gd,...hd,...xd,...ah]),Q=null,ge=Ht({},[...sh,...bd,...ih,...Pi]),Z=Object.seal(Ri(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),G=null,pe=null,ke=Object.seal(Ri(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),le=!0,ne=!0,de=!1,Lt=!0,St=!1,We=!0,he=!1,at=!1,Pe=!1,j=!1,ue=!1,nt=!1,It=!0,ee=!1,je="user-content-",Fr=!0,Dt=!1,ar={},gr=null,nn=Ht({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),F=null,fe=Ht({},["audio","video","img","source","image","track"]),Re=null,Xe=Ht({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Fe="http://www.w3.org/1998/Math/MathML",Oe="http://www.w3.org/2000/svg",Ye="http://www.w3.org/1999/xhtml",Tt=Ye,Qt=!1,sr=null,K=Ht({},[Fe,Oe,Ye],fd),ft=Ht({},["mi","mo","mn","ms","mtext"]),it=Ht({},["annotation-xml"]),ye=Ht({},["title","style","font","a","script"]),se=null,st=["application/xhtml+xml","text/html"],ur="text/html",ct=null,xr=null,Ir=t.createElement("form"),pt=function(P){return P instanceof RegExp||P instanceof Function},Pt=function(){let P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(xr&&xr===P)){if((!P||typeof P!="object")&&(P={}),P=eo(P),se=st.indexOf(P.PARSER_MEDIA_TYPE)===-1?ur:P.PARSER_MEDIA_TYPE,ct=se==="application/xhtml+xml"?fd:Ii,J=vn(P,"ALLOWED_TAGS")?Ht({},P.ALLOWED_TAGS,ct):re,Q=vn(P,"ALLOWED_ATTR")?Ht({},P.ALLOWED_ATTR,ct):ge,sr=vn(P,"ALLOWED_NAMESPACES")?Ht({},P.ALLOWED_NAMESPACES,fd):K,Re=vn(P,"ADD_URI_SAFE_ATTR")?Ht(eo(Xe),P.ADD_URI_SAFE_ATTR,ct):Xe,F=vn(P,"ADD_DATA_URI_TAGS")?Ht(eo(fe),P.ADD_DATA_URI_TAGS,ct):fe,gr=vn(P,"FORBID_CONTENTS")?Ht({},P.FORBID_CONTENTS,ct):nn,G=vn(P,"FORBID_TAGS")?Ht({},P.FORBID_TAGS,ct):eo({}),pe=vn(P,"FORBID_ATTR")?Ht({},P.FORBID_ATTR,ct):eo({}),ar=vn(P,"USE_PROFILES")?P.USE_PROFILES:!1,le=P.ALLOW_ARIA_ATTR!==!1,ne=P.ALLOW_DATA_ATTR!==!1,de=P.ALLOW_UNKNOWN_PROTOCOLS||!1,Lt=P.ALLOW_SELF_CLOSE_IN_ATTR!==!1,St=P.SAFE_FOR_TEMPLATES||!1,We=P.SAFE_FOR_XML!==!1,he=P.WHOLE_DOCUMENT||!1,j=P.RETURN_DOM||!1,ue=P.RETURN_DOM_FRAGMENT||!1,nt=P.RETURN_TRUSTED_TYPE||!1,Pe=P.FORCE_BODY||!1,It=P.SANITIZE_DOM!==!1,ee=P.SANITIZE_NAMED_PROPS||!1,Fr=P.KEEP_CONTENT!==!1,Dt=P.IN_PLACE||!1,Ie=P.ALLOWED_URI_REGEXP||ph,Tt=P.NAMESPACE||Ye,ft=P.MATHML_TEXT_INTEGRATION_POINTS||ft,it=P.HTML_INTEGRATION_POINTS||it,Z=P.CUSTOM_ELEMENT_HANDLING||{},P.CUSTOM_ELEMENT_HANDLING&&pt(P.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Z.tagNameCheck=P.CUSTOM_ELEMENT_HANDLING.tagNameCheck),P.CUSTOM_ELEMENT_HANDLING&&pt(P.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Z.attributeNameCheck=P.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),P.CUSTOM_ELEMENT_HANDLING&&typeof P.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Z.allowCustomizedBuiltInElements=P.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),St&&(ne=!1),ue&&(j=!0),ar&&(J=Ht({},ah),Q=Ri(null),ar.html===!0&&(Ht(J,oh),Ht(Q,sh)),ar.svg===!0&&(Ht(J,gd),Ht(Q,bd),Ht(Q,Pi)),ar.svgFilters===!0&&(Ht(J,hd),Ht(Q,bd),Ht(Q,Pi)),ar.mathMl===!0&&(Ht(J,xd),Ht(Q,ih),Ht(Q,Pi))),vn(P,"ADD_TAGS")||(ke.tagCheck=null),vn(P,"ADD_ATTR")||(ke.attributeCheck=null),P.ADD_TAGS&&(typeof P.ADD_TAGS=="function"?ke.tagCheck=P.ADD_TAGS:(J===re&&(J=eo(J)),Ht(J,P.ADD_TAGS,ct))),P.ADD_ATTR&&(typeof P.ADD_ATTR=="function"?ke.attributeCheck=P.ADD_ATTR:(Q===ge&&(Q=eo(Q)),Ht(Q,P.ADD_ATTR,ct))),P.ADD_URI_SAFE_ATTR&&Ht(Re,P.ADD_URI_SAFE_ATTR,ct),P.FORBID_CONTENTS&&(gr===nn&&(gr=eo(gr)),Ht(gr,P.FORBID_CONTENTS,ct)),P.ADD_FORBID_CONTENTS&&(gr===nn&&(gr=eo(gr)),Ht(gr,P.ADD_FORBID_CONTENTS,ct)),Fr&&(J["#text"]=!0),he&&Ht(J,["html","head","body"]),J.table&&(Ht(J,["tbody"]),delete G.tbody),P.TRUSTED_TYPES_POLICY){if(typeof P.TRUSTED_TYPES_POLICY.createHTML!="function")throw Is('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof P.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Is('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');h=P.TRUSTED_TYPES_POLICY,w=h.createHTML("")}else h===void 0&&(h=Zy(m,o)),h!==null&&typeof w=="string"&&(w=h.createHTML(""));Zr&&Zr(P),xr=P}},et=Ht({},[...gd,...hd,...qy]),$t=Ht({},[...xd,...zy]),br=function(P){let ae=k(P);(!ae||!ae.tagName)&&(ae={namespaceURI:Tt,tagName:"template"});let Ee=Ii(P.tagName),Ot=Ii(ae.tagName);return sr[P.namespaceURI]?P.namespaceURI===Oe?ae.namespaceURI===Ye?Ee==="svg":ae.namespaceURI===Fe?Ee==="svg"&&(Ot==="annotation-xml"||ft[Ot]):!!et[Ee]:P.namespaceURI===Fe?ae.namespaceURI===Ye?Ee==="math":ae.namespaceURI===Oe?Ee==="math"&&it[Ot]:!!$t[Ee]:P.namespaceURI===Ye?ae.namespaceURI===Oe&&!it[Ot]||ae.namespaceURI===Fe&&!ft[Ot]?!1:!$t[Ee]&&(ye[Ee]||!et[Ee]):!!(se==="application/xhtml+xml"&&sr[P.namespaceURI]):!1},ir=function(P){Ps(e.removed,{element:P});try{k(P).removeChild(P)}catch{S(P)}},fr=function(P,ae){try{Ps(e.removed,{attribute:ae.getAttributeNode(P),from:ae})}catch{Ps(e.removed,{attribute:null,from:ae})}if(ae.removeAttribute(P),P==="is")if(j||ue)try{ir(ae)}catch{}else try{ae.setAttribute(P,"")}catch{}},Sr=function(P){let ae=null,Ee=null;if(Pe)P="<remove></remove>"+P;else{let _t=md(P,/^[\r\n\t ]+/);Ee=_t&&_t[0]}se==="application/xhtml+xml"&&Tt===Ye&&(P='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+P+"</body></html>");let Ot=h?h.createHTML(P):P;if(Tt===Ye)try{ae=new u().parseFromString(Ot,se)}catch{}if(!ae||!ae.documentElement){ae=C.createDocument(Tt,"template",null);try{ae.documentElement.innerHTML=Qt?w:Ot}catch{}}let Ze=ae.body||ae.documentElement;return P&&Ee&&Ze.insertBefore(t.createTextNode(Ee),Ze.childNodes[0]||null),Tt===Ye?R.call(ae,he?"html":"body")[0]:he?ae.documentElement:Ze},cn=function(P){return T.call(P.ownerDocument||P,P,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Mt=function(P){return P instanceof f&&(typeof P.nodeName!="string"||typeof P.textContent!="string"||typeof P.removeChild!="function"||!(P.attributes instanceof p)||typeof P.removeAttribute!="function"||typeof P.setAttribute!="function"||typeof P.namespaceURI!="string"||typeof P.insertBefore!="function"||typeof P.hasChildNodes!="function")},_r=function(P){return typeof i=="function"&&P instanceof i};function hr(_e,P,ae){Li(_e,Ee=>{Ee.call(e,P,ae,xr)})}let An=function(P){let ae=null;if(hr(N.beforeSanitizeElements,P,null),Mt(P))return ir(P),!0;let Ee=ct(P.nodeName);if(hr(N.uponSanitizeElement,P,{tagName:Ee,allowedTags:J}),We&&P.hasChildNodes()&&!_r(P.firstElementChild)&&Yr(/<[/\w!]/g,P.innerHTML)&&Yr(/<[/\w!]/g,P.textContent)||P.nodeType===Hs.progressingInstruction||We&&P.nodeType===Hs.comment&&Yr(/<[/\w]/g,P.data))return ir(P),!0;if(!(ke.tagCheck instanceof Function&&ke.tagCheck(Ee))&&(!J[Ee]||G[Ee])){if(!G[Ee]&&Ct(Ee)&&(Z.tagNameCheck instanceof RegExp&&Yr(Z.tagNameCheck,Ee)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(Ee)))return!1;if(Fr&&!gr[Ee]){let Ot=k(P)||P.parentNode,Ze=E(P)||P.childNodes;if(Ze&&Ot){let _t=Ze.length;for(let Zt=_t-1;Zt>=0;--Zt){let dr=x(Ze[Zt],!0);dr.__removalCount=(P.__removalCount||0)+1,Ot.insertBefore(dr,M(P))}}}return ir(P),!0}return P instanceof d&&!br(P)||(Ee==="noscript"||Ee==="noembed"||Ee==="noframes")&&Yr(/<\/no(script|embed|frames)/i,P.innerHTML)?(ir(P),!0):(St&&P.nodeType===Hs.text&&(ae=P.textContent,Li([V,ie,xe],Ot=>{ae=Rs(ae,Ot," ")}),P.textContent!==ae&&(Ps(e.removed,{element:P.cloneNode()}),P.textContent=ae)),hr(N.afterSanitizeElements,P,null),!1)},on=function(P,ae,Ee){if(pe[ae]||It&&(ae==="id"||ae==="name")&&(Ee in t||Ee in Ir))return!1;if(!(ne&&!pe[ae]&&Yr(Je,ae))){if(!(le&&Yr(we,ae))){if(!(ke.attributeCheck instanceof Function&&ke.attributeCheck(ae,P))){if(!Q[ae]||pe[ae]){if(!(Ct(P)&&(Z.tagNameCheck instanceof RegExp&&Yr(Z.tagNameCheck,P)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(P))&&(Z.attributeNameCheck instanceof RegExp&&Yr(Z.attributeNameCheck,ae)||Z.attributeNameCheck instanceof Function&&Z.attributeNameCheck(ae,P))||ae==="is"&&Z.allowCustomizedBuiltInElements&&(Z.tagNameCheck instanceof RegExp&&Yr(Z.tagNameCheck,Ee)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(Ee))))return!1}else if(!Re[ae]){if(!Yr(Ie,Rs(Ee,Ae,""))){if(!((ae==="src"||ae==="xlink:href"||ae==="href")&&P!=="script"&&Ny(Ee,"data:")===0&&F[P])){if(!(de&&!Yr(De,Rs(Ee,Ae,"")))){if(Ee)return!1}}}}}}}return!0},Ct=function(P){return P!=="annotation-xml"&&md(P,qe)},jn=function(P){hr(N.beforeSanitizeAttributes,P,null);let{attributes:ae}=P;if(!ae||Mt(P))return;let Ee={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Q,forceKeepAttr:void 0},Ot=ae.length;for(;Ot--;){let Ze=ae[Ot],{name:_t,namespaceURI:Zt,value:dr}=Ze,wt=ct(_t),Ur=dr,Vt=_t==="value"?Ur:Oy(Ur);if(Ee.attrName=wt,Ee.attrValue=Vt,Ee.keepAttr=!0,Ee.forceKeepAttr=void 0,hr(N.uponSanitizeAttribute,P,Ee),Vt=Ee.attrValue,ee&&(wt==="id"||wt==="name")&&(fr(_t,P),Vt=je+Vt),We&&Yr(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Vt)){fr(_t,P);continue}if(wt==="attributename"&&md(Vt,"href")){fr(_t,P);continue}if(Ee.forceKeepAttr)continue;if(!Ee.keepAttr){fr(_t,P);continue}if(!Lt&&Yr(/\/>/i,Vt)){fr(_t,P);continue}St&&Li([V,ie,xe],Fn=>{Vt=Rs(Vt,Fn," ")});let qr=ct(P.nodeName);if(!on(qr,wt,Vt)){fr(_t,P);continue}if(h&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Zt)switch(m.getAttributeType(qr,wt)){case"TrustedHTML":{Vt=h.createHTML(Vt);break}case"TrustedScriptURL":{Vt=h.createScriptURL(Vt);break}}if(Vt!==Ur)try{Zt?P.setAttributeNS(Zt,_t,Vt):P.setAttribute(_t,Vt),Mt(P)?ir(P):nh(e.removed)}catch{fr(_t,P)}}hr(N.afterSanitizeAttributes,P,null)},Sn=function _e(P){let ae=null,Ee=cn(P);for(hr(N.beforeSanitizeShadowDOM,P,null);ae=Ee.nextNode();)hr(N.uponSanitizeShadowNode,ae,null),An(ae),jn(ae),ae.content instanceof a&&_e(ae.content);hr(N.afterSanitizeShadowDOM,P,null)};return e.sanitize=function(_e){let P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ae=null,Ee=null,Ot=null,Ze=null;if(Qt=!_e,Qt&&(_e="<!-->"),typeof _e!="string"&&!_r(_e))if(typeof _e.toString=="function"){if(_e=_e.toString(),typeof _e!="string")throw Is("dirty is not a string, aborting")}else throw Is("toString is not a function");if(!e.isSupported)return _e;if(at||Pt(P),e.removed=[],typeof _e=="string"&&(Dt=!1),Dt){if(_e.nodeName){let dr=ct(_e.nodeName);if(!J[dr]||G[dr])throw Is("root node is forbidden and cannot be sanitized in-place")}}else if(_e instanceof i)ae=Sr("<!---->"),Ee=ae.ownerDocument.importNode(_e,!0),Ee.nodeType===Hs.element&&Ee.nodeName==="BODY"||Ee.nodeName==="HTML"?ae=Ee:ae.appendChild(Ee);else{if(!j&&!St&&!he&&_e.indexOf("<")===-1)return h&&nt?h.createHTML(_e):_e;if(ae=Sr(_e),!ae)return j?null:nt?w:""}ae&&Pe&&ir(ae.firstChild);let _t=cn(Dt?_e:ae);for(;Ot=_t.nextNode();)An(Ot),jn(Ot),Ot.content instanceof a&&Sn(Ot.content);if(Dt)return _e;if(j){if(ue)for(Ze=W.call(ae.ownerDocument);ae.firstChild;)Ze.appendChild(ae.firstChild);else Ze=ae;return(Q.shadowroot||Q.shadowrootmode)&&(Ze=I.call(n,Ze,!0)),Ze}let Zt=he?ae.outerHTML:ae.innerHTML;return he&&J["!doctype"]&&ae.ownerDocument&&ae.ownerDocument.doctype&&ae.ownerDocument.doctype.name&&Yr(uh,ae.ownerDocument.doctype.name)&&(Zt="<!DOCTYPE "+ae.ownerDocument.doctype.name+`>
|
|
48
|
-
`+Zt),St&&Li([V,ie,xe],dr=>{Zt=Rs(Zt,dr," ")}),h&&nt?h.createHTML(Zt):Zt},e.setConfig=function(){let _e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Pt(_e),at=!0},e.clearConfig=function(){xr=null,at=!1},e.isValidAttribute=function(_e,P,ae){xr||Pt({});let Ee=ct(_e),Ot=ct(P);return on(Ee,Ot,ae)},e.addHook=function(_e,P){typeof P=="function"&&Ps(N[_e],P)},e.removeHook=function(_e,P){if(P!==void 0){let ae=Dy(N[_e],P);return ae===-1?void 0:Fy(N[_e],ae,1)[0]}return nh(N[_e])},e.removeHooks=function(_e){N[_e]=[]},e.removeAllHooks=function(){N=dh()},e}var mh=fh();var e0={ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","p","br","hr","div","span","ul","ol","li","dl","dt","dd","strong","em","b","i","u","s","del","ins","mark","small","sub","sup","abbr","kbd","var","samp","code","a","img","blockquote","pre","details","summary","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col","input","label","select","option","textarea","button"],ALLOWED_ATTR:["href","src","alt","title","target","rel","loading","width","height","colspan","rowspan","scope","class","id","type","name","value","placeholder","disabled","checked","for","aria-label","aria-hidden","aria-expanded","role","tabindex","data-tv-form","data-message-id","data-persona-component-directive","data-preserve-animation","data-persona-instance"]},t0=/^data:image\/(?:png|jpe?g|gif|webp|bmp|x-icon|avif)/i,Cd=()=>{let r=mh(typeof window!="undefined"?window:void 0);return r.addHook("uponSanitizeAttribute",(e,t)=>{if(t.attrName==="src"||t.attrName==="href"){let n=t.attrValue;n.toLowerCase().startsWith("data:")&&!t0.test(n)&&(t.attrValue="",t.keepAttr=!1)}}),e=>r.sanitize(e,e0)},Da=r=>r===!1?null:typeof r=="function"?r:Cd();var mo="webmcp:",wd=new Map,gh=r=>{var e;wd.clear();for(let t of r){let n=(e=t.title)==null?void 0:e.trim();n&&wd.set(t.name,n)}},Sd=r=>wd.get(Hi(r)),Wi={warn(r,...e){typeof console!="undefined"&&typeof console.warn=="function"&&console.warn(`[Persona/WebMCP] ${r}`,...e)}},Ad=null,xh=r=>{Ad=r};function bh(r){if(r.length===0)return"0:empty";let e=r.map(t=>{var n,o;return[t.name,(n=t.description)!=null?n:"",t.parametersSchema?JSON.stringify(t.parametersSchema):"",(o=t.origin)!=null?o:"",t.annotations?JSON.stringify(t.annotations):""].join("")}).sort();return`${r.length}:${r0(e.join(""))}`}function hh(r,e){let t=3735928559^e,n=1103547991^e;for(let o=0;o<r.length;o++){let a=r.charCodeAt(o);t=Math.imul(t^a,2654435761),n=Math.imul(n^a,1597334677)}return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}function r0(r){let e=hh(r,0).toString(36),t=hh(r,2654435761).toString(36);return`${e}.${t}`}var Fa=class{constructor(e){this.config=e;this.installed=!1;this.readyPromise=null;this.incompatibleContextWarned=!1;var t;this.confirmHandler=(t=e.onConfirm)!=null?t:null,this.timeoutMs=3e4}setConfirmHandler(e){this.confirmHandler=e}isOperational(){return this.config.enabled!==!0||!this.installed?!1:this.getModelContext()!==null}async snapshotForDispatch(){if(await this.ensureReady(),this.config.enabled!==!0)return[];let e=this.getModelContext();if(!e)return[];let t;try{t=await e.getTools()}catch(o){return Wi.warn("getTools() threw \u2014 shipping an empty WebMCP snapshot.",o),[]}gh(t);let n=typeof location!="undefined"?location.origin:"";return t.filter(o=>this.passesClientAllowlist(o.name)).map(o=>{let a={name:o.name,description:o.description,origin:"webmcp",...n?{pageOrigin:n}:{}},s=o0(o.inputSchema);return s&&(a.parametersSchema=s),a})}async executeToolCall(e,t,n){if(await this.ensureReady(),this.config.enabled!==!0)return $n("WebMCP is not enabled on this widget.");let o=this.getModelContext();if(!o){let v=typeof document!="undefined"&&!!document.modelContext;return $n(v?"WebMCP is not operational: document.modelContext is present but does not expose the strict getTools()/executeTool() surface (likely a different or older WebMCP polyfill).":"WebMCP bridge is not operational on this page (document.modelContext not available).")}let a=Hi(e),s;try{s=await o.getTools()}catch(v){let x=v instanceof Error?v.message:String(v);return $n(`Failed to read WebMCP registry: ${x}`)}gh(s);let i=s.find(v=>v.name===a);if(!i)return $n(`WebMCP tool not registered on this page: ${a}`);if(!this.passesClientAllowlist(a))return $n(`WebMCP tool not allowed by client allowlist: ${a}`);if(n!=null&&n.aborted)return $n("Aborted by cancel()");let d=Sd(a),l={toolName:a,args:t,description:i.description,...d?{title:d}:{},reason:"gate"};if(!await this.requestConfirm(l))return $n("User declined the tool call.");if(n!=null&&n.aborted)return $n("Aborted by cancel()");let p=new AbortController,f=!1,u=setTimeout(()=>{f=!0,p.abort()},this.timeoutMs),m=()=>p.abort();n&&(n.aborted?p.abort():n.addEventListener("abort",m,{once:!0}));try{let v=await o.executeTool(i,l0(t),{signal:p.signal});return a0(v)}catch(v){if(f)return $n(`WebMCP tool '${a}' timed out after ${this.timeoutMs}ms`);if(n!=null&&n.aborted)return $n("Aborted by cancel()");let x=v instanceof Error?v.message:String(v);return $n(x)}finally{clearTimeout(u),n&&n.removeEventListener("abort",m)}}ensureReady(){return this.config.enabled!==!0?Promise.resolve():(this.readyPromise||(this.readyPromise=this.install()),this.readyPromise)}async install(){try{if(this.getModelContext()){this.installed=!0;return}(Ad?await Ad():await import("@mcp-b/webmcp-polyfill")).initializeWebMCPPolyfill(),this.installed=!0}catch(e){Wi.warn("Failed to load @mcp-b/webmcp-polyfill \u2014 WebMCP consumption disabled.",e),this.installed=!1}}getModelContext(){if(typeof document=="undefined")return null;let e=document.modelContext;if(!e||typeof e!="object")return null;let t=e;return typeof t.getTools!="function"||typeof t.executeTool!="function"?(this.incompatibleContextWarned||(this.incompatibleContextWarned=!0,Wi.warn("document.modelContext is present but does not expose getTools()/executeTool() \u2014 WebMCP consumption is disabled. Another (incompatible or older) WebMCP polyfill likely installed document.modelContext before Persona. Remove it, or use a polyfill implementing the strict standard surface (e.g. @mcp-b/webmcp-polyfill).")),null):e}async requestConfirm(e){var n;let t=(n=this.confirmHandler)!=null?n:s0;try{return await t(e)}catch(o){return Wi.warn(`Confirm handler threw for WebMCP tool '${e.toolName}'; declining.`,o),!1}}passesClientAllowlist(e){let t=this.config.allowlist;return!t||t.length===0?!0:t.some(n=>n0(e,n))}},Hi=r=>r.startsWith(mo)?r.slice(mo.length):r,Bo=r=>r.startsWith(mo),n0=(r,e)=>{if(e==="*")return!0;let t=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&");return new RegExp("^"+t.replace(/\*/g,".*")+"$").test(r)},o0=r=>{if(!(r===void 0||r===""))try{let e=JSON.parse(r);return e!==null&&typeof e=="object"?e:void 0}catch{return}},a0=r=>{if(r==null)return{content:[{type:"text",text:""}]};let e;try{e=JSON.parse(r)}catch{return{content:[{type:"text",text:r}]}}return e!==null&&typeof e=="object"&&Array.isArray(e.content)?e:{content:[{type:"text",text:typeof e=="string"?e:d0(e)}]}},$n=r=>({isError:!0,content:[{type:"text",text:r}]}),s0=async r=>{if(typeof window=="undefined"||typeof window.confirm!="function")return!1;let e=i0(r.args),t=`Allow the AI to call ${r.toolName}`+(e?`
|
|
44
|
+
`}tablecell(e,t){let o=t.header?"th":"td";return(t.align?`<${o} align="${t.align}">`:`<${o}>`)+e+`</${o}>
|
|
45
|
+
`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,t,o){let n=Kg(e);if(n===null)return o;e=n;let a='<a href="'+e+'"';return t&&(a+=' title="'+t+'"'),a+=">"+o+"</a>",a}image(e,t,o){let n=Kg(e);if(n===null)return o;e=n;let a=`<img src="${e}" alt="${o}"`;return t&&(a+=` title="${t}"`),a+=">",a}text(e){return e}},Ws=class{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,o){return""+o}image(e,t,o){return""+o}br(){return""}},vn=class r{constructor(e){lr(this,"options");lr(this,"renderer");lr(this,"textRenderer");this.options=e||pa,this.options.renderer=this.options.renderer||new za,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Ws}static parse(e,t){return new r(t).parse(e)}static parseInline(e,t){return new r(t).parseInline(e)}parse(e,t=!0){let o="";for(let n=0;n<e.length;n++){let a=e[n];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){let s=a,i=this.options.extensions.renderers[s.type].call({parser:this},s);if(i!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(s.type)){o+=i||"";continue}}switch(a.type){case"space":continue;case"hr":{o+=this.renderer.hr();continue}case"heading":{let s=a;o+=this.renderer.heading(this.parseInline(s.tokens),s.depth,Cb(this.parseInline(s.tokens,this.textRenderer)));continue}case"code":{let s=a;o+=this.renderer.code(s.text,s.lang,!!s.escaped);continue}case"table":{let s=a,i="",d="";for(let u=0;u<s.header.length;u++)d+=this.renderer.tablecell(this.parseInline(s.header[u].tokens),{header:!0,align:s.align[u]});i+=this.renderer.tablerow(d);let l="";for(let u=0;u<s.rows.length;u++){let f=s.rows[u];d="";for(let p=0;p<f.length;p++)d+=this.renderer.tablecell(this.parseInline(f[p].tokens),{header:!1,align:s.align[p]});l+=this.renderer.tablerow(d)}o+=this.renderer.table(i,l);continue}case"blockquote":{let s=a,i=this.parse(s.tokens);o+=this.renderer.blockquote(i);continue}case"list":{let s=a,i=s.ordered,d=s.start,l=s.loose,u="";for(let f=0;f<s.items.length;f++){let p=s.items[f],m=p.checked,y=p.task,h="";if(p.task){let T=this.renderer.checkbox(!!m);l?p.tokens.length>0&&p.tokens[0].type==="paragraph"?(p.tokens[0].text=T+" "+p.tokens[0].text,p.tokens[0].tokens&&p.tokens[0].tokens.length>0&&p.tokens[0].tokens[0].type==="text"&&(p.tokens[0].tokens[0].text=T+" "+p.tokens[0].tokens[0].text)):p.tokens.unshift({type:"text",text:T+" "}):h+=T+" "}h+=this.parse(p.tokens,l),u+=this.renderer.listitem(h,y,!!m)}o+=this.renderer.list(u,i,d);continue}case"html":{let s=a;o+=this.renderer.html(s.text,s.block);continue}case"paragraph":{let s=a;o+=this.renderer.paragraph(this.parseInline(s.tokens));continue}case"text":{let s=a,i=s.tokens?this.parseInline(s.tokens):s.text;for(;n+1<e.length&&e[n+1].type==="text";)s=e[++n],i+=`
|
|
46
|
+
`+(s.tokens?this.parseInline(s.tokens):s.text);o+=t?this.renderer.paragraph(i):i;continue}default:{let s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return o}parseInline(e,t){t=t||this.renderer;let o="";for(let n=0;n<e.length;n++){let a=e[n];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){let s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){o+=s||"";continue}}switch(a.type){case"escape":{let s=a;o+=t.text(s.text);break}case"html":{let s=a;o+=t.html(s.text);break}case"link":{let s=a;o+=t.link(s.href,s.title,this.parseInline(s.tokens,t));break}case"image":{let s=a;o+=t.image(s.href,s.title,s.text);break}case"strong":{let s=a;o+=t.strong(this.parseInline(s.tokens,t));break}case"em":{let s=a;o+=t.em(this.parseInline(s.tokens,t));break}case"codespan":{let s=a;o+=t.codespan(s.text);break}case"br":{o+=t.br();break}case"del":{let s=a;o+=t.del(this.parseInline(s.tokens,t));break}case"text":{let s=a;o+=t.text(s.text);break}default:{let s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return o}},la=class{constructor(e){lr(this,"options");this.options=e||pa}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}};lr(la,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));var ca,gd,lh,Bs=class{constructor(...e){jg(this,ca);lr(this,"defaults",hd());lr(this,"options",this.setOptions);lr(this,"parse",Di(this,ca,gd).call(this,bn.lex,vn.parse));lr(this,"parseInline",Di(this,ca,gd).call(this,bn.lexInline,vn.parseInline));lr(this,"Parser",vn);lr(this,"Renderer",za);lr(this,"TextRenderer",Ws);lr(this,"Lexer",bn);lr(this,"Tokenizer",qa);lr(this,"Hooks",la);this.use(...e)}walkTokens(e,t){var n,a;let o=[];for(let s of e)switch(o=o.concat(t.call(this,s)),s.type){case"table":{let i=s;for(let d of i.header)o=o.concat(this.walkTokens(d.tokens,t));for(let d of i.rows)for(let l of d)o=o.concat(this.walkTokens(l.tokens,t));break}case"list":{let i=s;o=o.concat(this.walkTokens(i.items,t));break}default:{let i=s;(a=(n=this.defaults.extensions)==null?void 0:n.childTokens)!=null&&a[i.type]?this.defaults.extensions.childTokens[i.type].forEach(d=>{let l=i[d].flat(1/0);o=o.concat(this.walkTokens(l,t))}):i.tokens&&(o=o.concat(this.walkTokens(i.tokens,t)))}}return o}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(o=>{let n={...o};if(n.async=this.defaults.async||n.async||!1,o.extensions&&(o.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){let s=t.renderers[a.name];s?t.renderers[a.name]=function(...i){let d=a.renderer.apply(this,i);return d===!1&&(d=s.apply(this,i)),d}:t.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[a.level];s?s.unshift(a.tokenizer):t[a.level]=[a.tokenizer],a.start&&(a.level==="block"?t.startBlock?t.startBlock.push(a.start):t.startBlock=[a.start]:a.level==="inline"&&(t.startInline?t.startInline.push(a.start):t.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(t.childTokens[a.name]=a.childTokens)}),n.extensions=t),o.renderer){let a=this.defaults.renderer||new za(this.defaults);for(let s in o.renderer){if(!(s in a))throw new Error(`renderer '${s}' does not exist`);if(s==="options")continue;let i=s,d=o.renderer[i],l=a[i];a[i]=(...u)=>{let f=d.apply(a,u);return f===!1&&(f=l.apply(a,u)),f||""}}n.renderer=a}if(o.tokenizer){let a=this.defaults.tokenizer||new qa(this.defaults);for(let s in o.tokenizer){if(!(s in a))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let i=s,d=o.tokenizer[i],l=a[i];a[i]=(...u)=>{let f=d.apply(a,u);return f===!1&&(f=l.apply(a,u)),f}}n.tokenizer=a}if(o.hooks){let a=this.defaults.hooks||new la;for(let s in o.hooks){if(!(s in a))throw new Error(`hook '${s}' does not exist`);if(s==="options")continue;let i=s,d=o.hooks[i],l=a[i];la.passThroughHooks.has(s)?a[i]=u=>{if(this.defaults.async)return Promise.resolve(d.call(a,u)).then(p=>l.call(a,p));let f=d.call(a,u);return l.call(a,f)}:a[i]=(...u)=>{let f=d.apply(a,u);return f===!1&&(f=l.apply(a,u)),f}}n.hooks=a}if(o.walkTokens){let a=this.defaults.walkTokens,s=o.walkTokens;n.walkTokens=function(i){let d=[];return d.push(s.call(this,i)),a&&(d=d.concat(a.call(this,i))),d}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return bn.lex(e,t!=null?t:this.defaults)}parser(e,t){return vn.parse(e,t!=null?t:this.defaults)}};ca=new WeakSet,gd=function(e,t){return(o,n)=>{let a={...n},s={...this.defaults,...a};this.defaults.async===!0&&a.async===!1&&(s.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),s.async=!0);let i=Di(this,ca,lh).call(this,!!s.silent,!!s.async);if(typeof o=="undefined"||o===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof o!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(o)+", string expected"));if(s.hooks&&(s.hooks.options=s),s.async)return Promise.resolve(s.hooks?s.hooks.preprocess(o):o).then(d=>e(d,s)).then(d=>s.hooks?s.hooks.processAllTokens(d):d).then(d=>s.walkTokens?Promise.all(this.walkTokens(d,s.walkTokens)).then(()=>d):d).then(d=>t(d,s)).then(d=>s.hooks?s.hooks.postprocess(d):d).catch(i);try{s.hooks&&(o=s.hooks.preprocess(o));let d=e(o,s);s.hooks&&(d=s.hooks.processAllTokens(d)),s.walkTokens&&this.walkTokens(d,s.walkTokens);let l=t(d,s);return s.hooks&&(l=s.hooks.postprocess(l)),l}catch(d){return i(d)}}},lh=function(e,t){return o=>{if(o.message+=`
|
|
47
|
+
Please report this to https://github.com/markedjs/marked.`,e){let n="<p>An error occurred:</p><pre>"+Ho(o.message+"",!0)+"</pre>";return t?Promise.resolve(n):n}if(t)return Promise.reject(o);throw o}};var da=new Bs;function tr(r,e){return da.parse(r,e)}tr.options=tr.setOptions=function(r){return da.setOptions(r),tr.defaults=da.defaults,Jg(tr.defaults),tr};tr.getDefaults=hd;tr.defaults=pa;tr.use=function(...r){return da.use(...r),tr.defaults=da.defaults,Jg(tr.defaults),tr};tr.walkTokens=function(r,e){return da.walkTokens(r,e)};tr.parseInline=da.parseInline;tr.Parser=vn;tr.parser=vn.parse;tr.Renderer=za;tr.TextRenderer=Ws;tr.Lexer=bn;tr.lexer=bn.lex;tr.Tokenizer=qa;tr.Hooks=la;tr.parse=tr;var Jw=tr.options,Zw=tr.setOptions,eA=tr.use,tA=tr.walkTokens,rA=tr.parseInline;var oA=vn.parse,nA=bn.lex;var Yb=r=>{if(r)return r},_s=r=>{var n,a;let e=r==null?void 0:r.markedOptions,t=new Bs({gfm:(n=e==null?void 0:e.gfm)!=null?n:!0,breaks:(a=e==null?void 0:e.breaks)!=null?a:!0,pedantic:e==null?void 0:e.pedantic,silent:e==null?void 0:e.silent}),o=Yb(r==null?void 0:r.renderer);return o&&t.use({renderer:o}),s=>t.parse(s)},ua=r=>r?_s({markedOptions:r.options,renderer:r.renderer}):_s(),Jb=_s(),wd=r=>Jb(r),fa=r=>r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),ch=r=>r.replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),dh=r=>`%%FORM_PLACEHOLDER_${r}%%`,ph=(r,e)=>{let t=r;return t=t.replace(/<Directive>([\s\S]*?)<\/Directive>/gi,(o,n)=>{try{let a=JSON.parse(n.trim());if(a&&typeof a=="object"&&a.component==="form"&&a.type){let s=dh(e.length);return e.push({token:s,type:String(a.type)}),s}}catch{return o}return o}),t=t.replace(/<Form\s+type="([^"]+)"\s*\/>/gi,(o,n)=>{let a=dh(e.length);return e.push({token:a,type:n}),a}),t},uh=r=>{let e=ua(r);return t=>{let o=[],n=ph(t,o),a=e(n);return o.forEach(({token:s,type:i})=>{let d=new RegExp(s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),u=`<div class="persona-form-directive" data-tv-form="${ch(i)}"></div>`;a=a.replace(d,u)}),a}},fh=r=>{let e=[],t=ph(r,e),o=wd(t);return e.forEach(({token:n,type:a})=>{let s=new RegExp(n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),d=`<div class="persona-form-directive" data-tv-form="${ch(a)}"></div>`;o=o.replace(s,d)}),o};function mh(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,o=Array(e);t<e;t++)o[t]=r[t];return o}function Zb(r){if(Array.isArray(r))return r}function e0(r,e){var t=r==null?null:typeof Symbol!="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var o,n,a,s,i=[],d=!0,l=!1;try{if(a=(t=t.call(r)).next,e!==0)for(;!(d=(o=a.call(t)).done)&&(i.push(o.value),i.length!==e);d=!0);}catch(u){l=!0,n=u}finally{try{if(!d&&t.return!=null&&(s=t.return(),Object(s)!==s))return}finally{if(l)throw n}}return i}}function t0(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
48
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function r0(r,e){return Zb(r)||e0(r,e)||o0(r,e)||t0()}function o0(r,e){if(r){if(typeof r=="string")return mh(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?mh(r,e):void 0}}var Eh=Object.entries,gh=Object.setPrototypeOf,n0=Object.isFrozen,a0=Object.getPrototypeOf,s0=Object.getOwnPropertyDescriptor,Kr=Object.freeze,Xr=Object.seal,Va=Object.create,Lh=typeof Reflect!="undefined"&&Reflect,Ed=Lh.apply,Ld=Lh.construct;Kr||(Kr=function(e){return e});Xr||(Xr=function(e){return e});Ed||(Ed=function(e,t){for(var o=arguments.length,n=new Array(o>2?o-2:0),a=2;a<o;a++)n[a-2]=arguments[a];return e.apply(t,n)});Ld||(Ld=function(e){for(var t=arguments.length,o=new Array(t>1?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];return new e(...o)});var Ns=Er(Array.prototype.forEach),i0=Er(Array.prototype.lastIndexOf),hh=Er(Array.prototype.pop),$a=Er(Array.prototype.push),l0=Er(Array.prototype.splice),Fn=Array.isArray,qs=Er(String.prototype.toLowerCase),Ad=Er(String.prototype.toString),xh=Er(String.prototype.match),Fs=Er(String.prototype.replace),yh=Er(String.prototype.indexOf),d0=Er(String.prototype.trim),c0=Er(Number.prototype.toString),p0=Er(Boolean.prototype.toString),bh=typeof BigInt=="undefined"?null:Er(BigInt.prototype.toString),vh=typeof Symbol=="undefined"?null:Er(Symbol.prototype.toString),Co=Er(Object.prototype.hasOwnProperty),Us=Er(Object.prototype.toString),Gr=Er(RegExp.prototype.test),ma=u0(TypeError);function Er(r){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,o=new Array(t>1?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];return Ed(r,e,o)}}function u0(r){return function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];return Ld(r,t)}}function Nt(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qs;if(gh&&gh(r,null),!Fn(e))return r;let o=e.length;for(;o--;){let n=e[o];if(typeof n=="string"){let a=t(n);a!==n&&(n0(e)||(e[o]=a),n=a)}r[n]=!0}return r}function f0(r){for(let e=0;e<r.length;e++)Co(r,e)||(r[e]=null);return r}function vo(r){let e=Va(null);for(let o of Eh(r)){var t=r0(o,2);let n=t[0],a=t[1];Co(r,n)&&(Fn(a)?e[n]=f0(a):a&&typeof a=="object"&&a.constructor===Object?e[n]=vo(a):e[n]=a)}return e}function m0(r){switch(typeof r){case"string":return r;case"number":return c0(r);case"boolean":return p0(r);case"bigint":return bh?bh(r):"0";case"symbol":return vh?vh(r):"Symbol()";case"undefined":return Us(r);case"function":case"object":{if(r===null)return Us(r);let e=r,t=pn(e,"toString");if(typeof t=="function"){let o=t(e);return typeof o=="string"?o:Us(o)}return Us(r)}default:return Us(r)}}function pn(r,e){for(;r!==null;){let o=s0(r,e);if(o){if(o.get)return Er(o.get);if(typeof o.value=="function")return Er(o.value)}r=a0(r)}function t(){return null}return t}function g0(r){try{return Gr(r,""),!0}catch{return!1}}var Ch=Kr(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Sd=Kr(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Td=Kr(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),h0=Kr(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Md=Kr(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),x0=Kr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),wh=Kr(["#text"]),Ah=Kr(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),kd=Kr(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Sh=Kr(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ui=Kr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),y0=Xr(/{{[\w\W]*|^[\w\W]*}}/g),b0=Xr(/<%[\w\W]*|^[\w\W]*%>/g),v0=Xr(/\${[\w\W]*/g),C0=Xr(/^data-[\-\w.\u00B7-\uFFFF]+$/),w0=Xr(/^aria-[\-\w]+$/),Th=Xr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),A0=Xr(/^(?:\w+script|data):/i),S0=Xr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),T0=Xr(/^html$/i),M0=Xr(/^[a-z][.\w]*(-[.\w]+)+$/i),Mh=Xr(/<[/\w!]/g),k0=Xr(/<[/\w]/g),E0=Xr(/<\/no(script|embed|frames)/i),L0=Xr(/\/>/i),cn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},P0=function(){return typeof window=="undefined"?null:window},R0=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let o=null,n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(o=t.getAttribute(n));let a="dompurify"+(o?"#"+o:"");try{return e.createPolicy(a,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},kh=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Nn=function(e,t,o,n){return Co(e,t)&&Fn(e[t])?Nt(n.base?vo(n.base):{},e[t],n.transform):o};function Ph(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:P0(),e=re=>Ph(re);if(e.version="3.4.10",e.removed=[],!r||!r.document||r.document.nodeType!==cn.document||!r.Element)return e.isSupported=!1,e;let t=r.document,o=t,n=o.currentScript;r.DocumentFragment;let a=r.HTMLTemplateElement,s=r.Node,i=r.Element,d=r.NodeFilter,l=r.NamedNodeMap;l===void 0&&(r.NamedNodeMap||r.MozNamedAttrMap),r.HTMLFormElement;let u=r.DOMParser,f=r.trustedTypes,p=i.prototype,m=pn(p,"cloneNode"),y=pn(p,"remove"),h=pn(p,"nextSibling"),T=pn(p,"childNodes"),M=pn(p,"parentNode"),k=pn(p,"shadowRoot"),L=pn(p,"attributes"),x=s&&s.prototype?pn(s.prototype,"nodeType"):null,w=s&&s.prototype?pn(s.prototype,"nodeName"):null;if(typeof a=="function"){let re=t.createElement("template");re.content&&re.content.ownerDocument&&(t=re.content.ownerDocument)}let v,E="",H,I=!1,P=0,z=function(){if(P>0)throw ma('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},j=function(A){z(),P++;try{return v.createHTML(A)}finally{P--}},ie=function(A){z(),P++;try{return v.createScriptURL(A)}finally{P--}},ve=function(){return I||(H=R0(f,n),I=!0),H},Xe=t,Ae=Xe.implementation,We=Xe.createNodeIterator,Me=Xe.createDocumentFragment,Ue=Xe.getElementsByTagName,Be=o.importNode,Z=kh();e.isSupported=typeof Eh=="function"&&typeof M=="function"&&Ae&&Ae.createHTMLDocument!==void 0;let ne=y0,me=b0,be=v0,ye=C0,Y=w0,ge=A0,Oe=S0,ce=M0,ae=Th,Q=null,Tt=Nt({},[...Ch,...Sd,...Td,...Md,...wh]),Ye=null,De=Nt({},[...Ah,...kd,...Sh,...Ui]),le=Object.seal(Va(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),nt=null,Re=null,K=Object.seal(Va(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),he=!0,it=!0,Pt=!1,te=!0,_e=!1,Ar=!0,Rt=!1,dr=!1,Yr=!1,zr=!1,O=!1,fe=!1,Ie=!0,Je=!1,qe="user-content-",ze=!0,lt=!1,Mt={},Dt=null,or=Nt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),X=null,wt=Nt({},["audio","video","img","source","image","track"]),ct=null,Ce=Nt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),de="http://www.w3.org/1998/Math/MathML",rt="http://www.w3.org/2000/svg",Ft="http://www.w3.org/1999/xhtml",zt=Ft,Pr=!1,vr=null,xt=Nt({},[de,rt,Ft],Ad),It=Kr(["mi","mo","mn","ms","mtext"]),tt=Nt({},It),jt=Kr(["annotation-xml"]),cr=Nt({},jt),Dr=Nt({},["title","style","font","a","script"]),hr=null,Sr=["application/xhtml+xml","text/html"],Oo="text/html",je=null,Tr=null,io=t.createElement("form"),_o=function(A){return A instanceof RegExp||A instanceof Function},lo=function(){let A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Tr&&Tr===A)return;(!A||typeof A!="object")&&(A={}),A=vo(A),hr=Sr.indexOf(A.PARSER_MEDIA_TYPE)===-1?Oo:A.PARSER_MEDIA_TYPE,je=hr==="application/xhtml+xml"?Ad:qs,Q=Nn(A,"ALLOWED_TAGS",Tt,{transform:je}),Ye=Nn(A,"ALLOWED_ATTR",De,{transform:je}),vr=Nn(A,"ALLOWED_NAMESPACES",xt,{transform:Ad}),ct=Nn(A,"ADD_URI_SAFE_ATTR",Ce,{transform:je,base:Ce}),X=Nn(A,"ADD_DATA_URI_TAGS",wt,{transform:je,base:wt}),Dt=Nn(A,"FORBID_CONTENTS",or,{transform:je}),nt=Nn(A,"FORBID_TAGS",vo({}),{transform:je}),Re=Nn(A,"FORBID_ATTR",vo({}),{transform:je}),Mt=Co(A,"USE_PROFILES")?A.USE_PROFILES&&typeof A.USE_PROFILES=="object"?vo(A.USE_PROFILES):A.USE_PROFILES:!1,he=A.ALLOW_ARIA_ATTR!==!1,it=A.ALLOW_DATA_ATTR!==!1,Pt=A.ALLOW_UNKNOWN_PROTOCOLS||!1,te=A.ALLOW_SELF_CLOSE_IN_ATTR!==!1,_e=A.SAFE_FOR_TEMPLATES||!1,Ar=A.SAFE_FOR_XML!==!1,Rt=A.WHOLE_DOCUMENT||!1,zr=A.RETURN_DOM||!1,O=A.RETURN_DOM_FRAGMENT||!1,fe=A.RETURN_TRUSTED_TYPE||!1,Yr=A.FORCE_BODY||!1,Ie=A.SANITIZE_DOM!==!1,Je=A.SANITIZE_NAMED_PROPS||!1,ze=A.KEEP_CONTENT!==!1,lt=A.IN_PLACE||!1,ae=g0(A.ALLOWED_URI_REGEXP)?A.ALLOWED_URI_REGEXP:Th,zt=typeof A.NAMESPACE=="string"?A.NAMESPACE:Ft,tt=Co(A,"MATHML_TEXT_INTEGRATION_POINTS")&&A.MATHML_TEXT_INTEGRATION_POINTS&&typeof A.MATHML_TEXT_INTEGRATION_POINTS=="object"?vo(A.MATHML_TEXT_INTEGRATION_POINTS):Nt({},It),cr=Co(A,"HTML_INTEGRATION_POINTS")&&A.HTML_INTEGRATION_POINTS&&typeof A.HTML_INTEGRATION_POINTS=="object"?vo(A.HTML_INTEGRATION_POINTS):Nt({},jt);let _=Co(A,"CUSTOM_ELEMENT_HANDLING")&&A.CUSTOM_ELEMENT_HANDLING&&typeof A.CUSTOM_ELEMENT_HANDLING=="object"?vo(A.CUSTOM_ELEMENT_HANDLING):Va(null);if(le=Va(null),Co(_,"tagNameCheck")&&_o(_.tagNameCheck)&&(le.tagNameCheck=_.tagNameCheck),Co(_,"attributeNameCheck")&&_o(_.attributeNameCheck)&&(le.attributeNameCheck=_.attributeNameCheck),Co(_,"allowCustomizedBuiltInElements")&&typeof _.allowCustomizedBuiltInElements=="boolean"&&(le.allowCustomizedBuiltInElements=_.allowCustomizedBuiltInElements),Xr(le),_e&&(it=!1),O&&(zr=!0),Mt&&(Q=Nt({},wh),Ye=Va(null),Mt.html===!0&&(Nt(Q,Ch),Nt(Ye,Ah)),Mt.svg===!0&&(Nt(Q,Sd),Nt(Ye,kd),Nt(Ye,Ui)),Mt.svgFilters===!0&&(Nt(Q,Td),Nt(Ye,kd),Nt(Ye,Ui)),Mt.mathMl===!0&&(Nt(Q,Md),Nt(Ye,Sh),Nt(Ye,Ui))),K.tagCheck=null,K.attributeCheck=null,Co(A,"ADD_TAGS")&&(typeof A.ADD_TAGS=="function"?K.tagCheck=A.ADD_TAGS:Fn(A.ADD_TAGS)&&(Q===Tt&&(Q=vo(Q)),Nt(Q,A.ADD_TAGS,je))),Co(A,"ADD_ATTR")&&(typeof A.ADD_ATTR=="function"?K.attributeCheck=A.ADD_ATTR:Fn(A.ADD_ATTR)&&(Ye===De&&(Ye=vo(Ye)),Nt(Ye,A.ADD_ATTR,je))),Co(A,"ADD_URI_SAFE_ATTR")&&Fn(A.ADD_URI_SAFE_ATTR)&&Nt(ct,A.ADD_URI_SAFE_ATTR,je),Co(A,"FORBID_CONTENTS")&&Fn(A.FORBID_CONTENTS)&&(Dt===or&&(Dt=vo(Dt)),Nt(Dt,A.FORBID_CONTENTS,je)),Co(A,"ADD_FORBID_CONTENTS")&&Fn(A.ADD_FORBID_CONTENTS)&&(Dt===or&&(Dt=vo(Dt)),Nt(Dt,A.ADD_FORBID_CONTENTS,je)),ze&&(Q["#text"]=!0),Rt&&Nt(Q,["html","head","body"]),Q.table&&(Nt(Q,["tbody"]),delete nt.tbody),A.TRUSTED_TYPES_POLICY){if(typeof A.TRUSTED_TYPES_POLICY.createHTML!="function")throw ma('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof A.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ma('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let ue=v;v=A.TRUSTED_TYPES_POLICY;try{E=j("")}catch($){throw v=ue,$}}else A.TRUSTED_TYPES_POLICY===null?(v=void 0,E=""):(v===void 0&&(v=ve()),v&&typeof E=="string"&&(E=j("")));(Z.uponSanitizeElement.length>0||Z.uponSanitizeAttribute.length>0)&&Q===Tt&&(Q=vo(Q)),Z.uponSanitizeAttribute.length>0&&Ye===De&&(Ye=vo(Ye)),Kr&&Kr(A),Tr=A},At=Nt({},[...Sd,...Td,...h0]),rn=Nt({},[...Md,...x0]),No=function(A,_,ue){return _.namespaceURI===Ft?A==="svg":_.namespaceURI===de?A==="svg"&&(ue==="annotation-xml"||tt[ue]):!!At[A]},mn=function(A,_,ue){return _.namespaceURI===Ft?A==="math":_.namespaceURI===rt?A==="math"&&cr[ue]:!!rn[A]},Jr=function(A,_,ue){return _.namespaceURI===rt&&!cr[ue]||_.namespaceURI===de&&!tt[ue]?!1:!rn[A]&&(Dr[A]||!At[A])},Ln=function(A){let _=M(A);(!_||!_.tagName)&&(_={namespaceURI:zt,tagName:"template"});let ue=qs(A.tagName),$=qs(_.tagName);return vr[A.namespaceURI]?A.namespaceURI===rt?No(ue,_,$):A.namespaceURI===de?mn(ue,_,$):A.namespaceURI===Ft?Jr(ue,_,$):!!(hr==="application/xhtml+xml"&&vr[A.namespaceURI]):!1},$r=function(A){$a(e.removed,{element:A});try{M(A).removeChild(A)}catch{if(y(A),!M(A))throw ma("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Fo=function(A){let _=T(A);if(_){let $=[];Ns(_,at=>{$a($,at)}),Ns($,at=>{try{y(at)}catch{}})}let ue=L(A);if(ue)for(let $=ue.length-1;$>=0;--$){let at=ue[$],ut=at&&at.name;if(typeof ut=="string")try{A.removeAttribute(ut)}catch{}}},mt=function(A,_){try{$a(e.removed,{attribute:_.getAttributeNode(A),from:_})}catch{$a(e.removed,{attribute:null,from:_})}if(_.removeAttribute(A),A==="is")if(zr||O)try{$r(_)}catch{}else try{_.setAttribute(A,"")}catch{}},co=function(A){let _=L(A);if(_)for(let ue=_.length-1;ue>=0;--ue){let $=_[ue],at=$&&$.name;if(!(typeof at!="string"||Ye[je(at)]))try{A.removeAttribute(at)}catch{}}},po=function(A){let _=[A];for(;_.length>0;){let ue=_.pop();(x?x(ue):ue.nodeType)===cn.element&&co(ue);let at=T(ue);if(at)for(let ut=at.length-1;ut>=0;--ut)_.push(at[ut])}},Or=function(A){let _=null,ue=null;if(Yr)A="<remove></remove>"+A;else{let ut=xh(A,/^[\r\n\t ]+/);ue=ut&&ut[0]}hr==="application/xhtml+xml"&&zt===Ft&&(A='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+A+"</body></html>");let $=v?j(A):A;if(zt===Ft)try{_=new u().parseFromString($,hr)}catch{}if(!_||!_.documentElement){_=Ae.createDocument(zt,"template",null);try{_.documentElement.innerHTML=Pr?E:$}catch{}}let at=_.body||_.documentElement;return A&&ue&&at.insertBefore(t.createTextNode(ue),at.childNodes[0]||null),zt===Ft?Ue.call(_,Rt?"html":"body")[0]:Rt?_.documentElement:at},Wt=function(A){return We.call(A.ownerDocument||A,A,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Vr=function(A){return A=Fs(A,ne," "),A=Fs(A,me," "),A=Fs(A,be," "),A},Zr=function(A){var _;A.normalize();let ue=We.call(A.ownerDocument||A,A,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null),$=ue.nextNode();for(;$;)$.data=Vr($.data),$=ue.nextNode();let at=(_=A.querySelectorAll)===null||_===void 0?void 0:_.call(A,"template");at&&Ns(at,ut=>{uo(ut.content)&&Zr(ut.content)})},_r=function(A){let _=w?w(A):null;return typeof _!="string"||je(_)!=="form"?!1:typeof A.nodeName!="string"||typeof A.textContent!="string"||typeof A.removeChild!="function"||A.attributes!==L(A)||typeof A.removeAttribute!="function"||typeof A.setAttribute!="function"||typeof A.namespaceURI!="string"||typeof A.insertBefore!="function"||typeof A.hasChildNodes!="function"||A.nodeType!==x(A)||A.childNodes!==T(A)},uo=function(A){if(!x||typeof A!="object"||A===null)return!1;try{return x(A)===cn.documentFragment}catch{return!1}},fo=function(A){if(!x||typeof A!="object"||A===null)return!1;try{return typeof x(A)=="number"}catch{return!1}};function Nr(re,A,_){re.length!==0&&Ns(re,ue=>{ue.call(e,A,_,Tr)})}let mo=function(A,_){return!!(Ar&&A.hasChildNodes()&&!fo(A.firstElementChild)&&Gr(Mh,A.textContent)&&Gr(Mh,A.innerHTML)||Ar&&A.namespaceURI===Ft&&_==="style"&&fo(A.firstElementChild)||A.nodeType===cn.processingInstruction||Ar&&A.nodeType===cn.comment&&Gr(k0,A.data))},$t=function(A,_){if(!nt[_]&&Uo(_)&&(le.tagNameCheck instanceof RegExp&&Gr(le.tagNameCheck,_)||le.tagNameCheck instanceof Function&&le.tagNameCheck(_)))return!1;if(ze&&!Dt[_]){let ue=M(A),$=T(A);if($&&ue){let at=$.length;for(let ut=at-1;ut>=0;--ut){let U=lt?$[ut]:m($[ut],!0);ue.insertBefore(U,h(A))}}}return $r(A),!0},Fr=function(A){if(Nr(Z.beforeSanitizeElements,A,null),_r(A))return $r(A),!0;let _=je(w?w(A):A.nodeName);if(Nr(Z.uponSanitizeElement,A,{tagName:_,allowedTags:Q}),mo(A,_))return $r(A),!0;if(nt[_]||!(K.tagCheck instanceof Function&&K.tagCheck(_))&&!Q[_])return $t(A,_);if((x?x(A):A.nodeType)===cn.element&&!Ln(A)||(_==="noscript"||_==="noembed"||_==="noframes")&&Gr(E0,A.innerHTML))return $r(A),!0;if(_e&&A.nodeType===cn.text){let $=Vr(A.textContent);A.textContent!==$&&($a(e.removed,{element:A.cloneNode()}),A.textContent=$)}return Nr(Z.afterSanitizeElements,A,null),!1},go=function(A,_,ue){if(Re[_]||Ie&&(_==="id"||_==="name")&&(ue in t||ue in io))return!1;let $=Ye[_]||K.attributeCheck instanceof Function&&K.attributeCheck(_,A);if(!(it&&Gr(ye,_))){if(!(he&&Gr(Y,_))){if($){if(!ct[_]){if(!Gr(ae,Fs(ue,Oe,""))){if(!((_==="src"||_==="xlink:href"||_==="href")&&A!=="script"&&yh(ue,"data:")===0&&X[A])){if(!(Pt&&!Gr(ge,Fs(ue,Oe,"")))){if(ue)return!1}}}}}else if(!(Uo(A)&&(le.tagNameCheck instanceof RegExp&&Gr(le.tagNameCheck,A)||le.tagNameCheck instanceof Function&&le.tagNameCheck(A))&&(le.attributeNameCheck instanceof RegExp&&Gr(le.attributeNameCheck,_)||le.attributeNameCheck instanceof Function&&le.attributeNameCheck(_,A))||_==="is"&&le.allowCustomizedBuiltInElements&&(le.tagNameCheck instanceof RegExp&&Gr(le.tagNameCheck,ue)||le.tagNameCheck instanceof Function&&le.tagNameCheck(ue))))return!1}}return!0},on=Nt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Uo=function(A){return!on[qs(A)]&&Gr(ce,A)},nn=function(A,_,ue,$){if(v&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!ue)switch(f.getAttributeType(A,_)){case"TrustedHTML":return j($);case"TrustedScriptURL":return ie($)}return $},qo=function(A,_,ue,$){try{ue?A.setAttributeNS(ue,_,$):A.setAttribute(_,$),_r(A)?$r(A):hh(e.removed)}catch{mt(_,A)}},eo=function(A){Nr(Z.beforeSanitizeAttributes,A,null);let _=A.attributes;if(!_||_r(A))return;let ue={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ye,forceKeepAttr:void 0},$=_.length,at=je(A.nodeName);for(;$--;){let ut=_[$],U=ut.name,nr=ut.namespaceURI,mr=ut.value,Cr=je(U),ko=mr,sr=U==="value"?ko:d0(ko);if(ue.attrName=Cr,ue.attrValue=sr,ue.keepAttr=!0,ue.forceKeepAttr=void 0,Nr(Z.uponSanitizeAttribute,A,ue),sr=ue.attrValue,Je&&(Cr==="id"||Cr==="name")&&yh(sr,qe)!==0&&(mt(U,A),sr=qe+sr),Ar&&Gr(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,sr)){mt(U,A);continue}if(Cr==="attributename"&&xh(sr,"href")){mt(U,A);continue}if(!ue.forceKeepAttr){if(!ue.keepAttr){mt(U,A);continue}if(!te&&Gr(L0,sr)){mt(U,A);continue}if(_e&&(sr=Vr(sr)),!go(at,Cr,sr)){mt(U,A);continue}sr=nn(at,Cr,nr,sr),sr!==ko&&qo(A,U,nr,sr)}}Nr(Z.afterSanitizeAttributes,A,null)},to=function(A){let _=null,ue=Wt(A);for(Nr(Z.beforeSanitizeShadowDOM,A,null);_=ue.nextNode();)if(Nr(Z.uponSanitizeShadowNode,_,null),Fr(_),eo(_),uo(_.content)&&to(_.content),(x?x(_):_.nodeType)===cn.element){let at=k(_);uo(at)&&(gt(at),to(at))}Nr(Z.afterSanitizeShadowDOM,A,null)},gt=function(A){let _=[{node:A,shadow:null}];for(;_.length>0;){let ue=_.pop();if(ue.shadow){to(ue.shadow);continue}let $=ue.node,ut=(x?x($):$.nodeType)===cn.element,U=T($);if(U)for(let nr=U.length-1;nr>=0;--nr)_.push({node:U[nr],shadow:null});if(ut){let nr=w?w($):null;if(typeof nr=="string"&&je(nr)==="template"){let mr=$.content;uo(mr)&&_.push({node:mr,shadow:null})}}if(ut){let nr=k($);uo(nr)&&_.push({node:null,shadow:nr},{node:nr,shadow:null})}}};return e.sanitize=function(re){let A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_=null,ue=null,$=null,at=null;if(Pr=!re,Pr&&(re="<!-->"),typeof re!="string"&&!fo(re)&&(re=m0(re),typeof re!="string"))throw ma("dirty is not a string, aborting");if(!e.isSupported)return re;dr||lo(A),e.removed=[];let ut=lt&&typeof re!="string"&&fo(re);if(ut){let mr=w?w(re):re.nodeName;if(typeof mr=="string"){let Cr=je(mr);if(!Q[Cr]||nt[Cr])throw ma("root node is forbidden and cannot be sanitized in-place")}if(_r(re))throw ma("root node is clobbered and cannot be sanitized in-place");try{gt(re)}catch(Cr){throw Fo(re),Cr}}else if(fo(re))_=Or("<!---->"),ue=_.ownerDocument.importNode(re,!0),ue.nodeType===cn.element&&ue.nodeName==="BODY"||ue.nodeName==="HTML"?_=ue:_.appendChild(ue),gt(ue);else{if(!zr&&!_e&&!Rt&&re.indexOf("<")===-1)return v&&fe?j(re):re;if(_=Or(re),!_)return zr?null:fe?E:""}_&&Yr&&$r(_.firstChild);let U=Wt(ut?re:_);try{for(;$=U.nextNode();)Fr($),eo($),uo($.content)&&to($.content)}catch(mr){throw ut&&Fo(re),mr}if(ut)return Ns(e.removed,mr=>{mr.element&&po(mr.element)}),_e&&Zr(re),re;if(zr){if(_e&&Zr(_),O)for(at=Me.call(_.ownerDocument);_.firstChild;)at.appendChild(_.firstChild);else at=_;return(Ye.shadowroot||Ye.shadowrootmode)&&(at=Be.call(o,at,!0)),at}let nr=Rt?_.outerHTML:_.innerHTML;return Rt&&Q["!doctype"]&&_.ownerDocument&&_.ownerDocument.doctype&&_.ownerDocument.doctype.name&&Gr(T0,_.ownerDocument.doctype.name)&&(nr="<!DOCTYPE "+_.ownerDocument.doctype.name+`>
|
|
49
|
+
`+nr),_e&&(nr=Vr(nr)),v&&fe?j(nr):nr},e.setConfig=function(){let re=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};lo(re),dr=!0},e.clearConfig=function(){Tr=null,dr=!1,v=H,E=""},e.isValidAttribute=function(re,A,_){Tr||lo({});let ue=je(re),$=je(A);return go(ue,$,_)},e.addHook=function(re,A){typeof A=="function"&&$a(Z[re],A)},e.removeHook=function(re,A){if(A!==void 0){let _=i0(Z[re],A);return _===-1?void 0:l0(Z[re],_,1)[0]}return hh(Z[re])},e.removeHooks=function(re){Z[re]=[]},e.removeAllHooks=function(){Z=kh()},e}var Rh=Ph();var I0={ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","p","br","hr","div","span","ul","ol","li","dl","dt","dd","strong","em","b","i","u","s","del","ins","mark","small","sub","sup","abbr","kbd","var","samp","code","a","img","blockquote","pre","details","summary","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col","input","label","select","option","textarea","button"],ALLOWED_ATTR:["href","src","alt","title","target","rel","loading","width","height","colspan","rowspan","scope","class","id","type","name","value","placeholder","disabled","checked","for","aria-label","aria-hidden","aria-expanded","role","tabindex","data-tv-form","data-message-id","data-persona-component-directive","data-preserve-animation","data-persona-instance"]},H0=/^data:image\/(?:png|jpe?g|gif|webp|bmp|x-icon|avif)/i,Pd=()=>{let r=Rh(typeof window!="undefined"?window:void 0);return r.addHook("uponSanitizeAttribute",(e,t)=>{if(t.attrName==="src"||t.attrName==="href"){let o=t.attrValue;o.toLowerCase().startsWith("data:")&&!H0.test(o)&&(t.attrValue="",t.keepAttr=!1)}}),e=>r.sanitize(e,I0)},ja=r=>r===!1?null:typeof r=="function"?r:Pd();var Cn="webmcp:",Rd=new Map,Ih=r=>{var e;Rd.clear();for(let t of r){let o=(e=t.title)==null?void 0:e.trim();o&&Rd.set(t.name,o)}},Hd=r=>Rd.get(zi(r)),qi={warn(r,...e){typeof console!="undefined"&&typeof console.warn=="function"&&console.warn(`[Persona/WebMCP] ${r}`,...e)}},Id=null,Wh=r=>{Id=r};function Bh(r){if(r.length===0)return"0:empty";let e=r.map(t=>{var o,n;return[t.name,(o=t.description)!=null?o:"",t.parametersSchema?JSON.stringify(t.parametersSchema):"",(n=t.origin)!=null?n:"",t.annotations?JSON.stringify(t.annotations):""].join("")}).sort();return`${r.length}:${W0(e.join(""))}`}function Hh(r,e){let t=3735928559^e,o=1103547991^e;for(let n=0;n<r.length;n++){let a=r.charCodeAt(n);t=Math.imul(t^a,2654435761),o=Math.imul(o^a,1597334677)}return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(o^o>>>13,3266489909),o=Math.imul(o^o>>>16,2246822507),o^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&o)+(t>>>0)}function W0(r){let e=Hh(r,0).toString(36),t=Hh(r,2654435761).toString(36);return`${e}.${t}`}var Ga=class{constructor(e){this.config=e;this.installed=!1;this.readyPromise=null;this.incompatibleContextWarned=!1;var t;this.confirmHandler=(t=e.onConfirm)!=null?t:null,this.timeoutMs=3e4}setConfirmHandler(e){this.confirmHandler=e}isOperational(){return this.config.enabled!==!0||!this.installed?!1:this.getModelContext()!==null}async snapshotForDispatch(){if(await this.ensureReady(),this.config.enabled!==!0)return[];let e=this.getModelContext();if(!e)return[];let t;try{t=await e.getTools()}catch(n){return qi.warn("getTools() threw \u2014 shipping an empty WebMCP snapshot.",n),[]}Ih(t);let o=typeof location!="undefined"?location.origin:"";return t.filter(n=>this.passesClientAllowlist(n.name)).map(n=>{let a={name:n.name,description:n.description,origin:"webmcp",...o?{pageOrigin:o}:{}},s=D0(n.inputSchema);return s&&(a.parametersSchema=s),a})}async executeToolCall(e,t,o){if(await this.ensureReady(),this.config.enabled!==!0)return Zo("WebMCP is not enabled on this widget.");let n=this.getModelContext();if(!n){let y=typeof document!="undefined"&&!!document.modelContext;return Zo(y?"WebMCP is not operational: document.modelContext is present but does not expose the strict getTools()/executeTool() surface (likely a different or older WebMCP polyfill).":"WebMCP bridge is not operational on this page (document.modelContext not available).")}let a=zi(e),s;try{s=await n.getTools()}catch(y){let h=y instanceof Error?y.message:String(y);return Zo(`Failed to read WebMCP registry: ${h}`)}Ih(s);let i=s.find(y=>y.name===a);if(!i)return Zo(`WebMCP tool not registered on this page: ${a}`);if(!this.passesClientAllowlist(a))return Zo(`WebMCP tool not allowed by client allowlist: ${a}`);if(o!=null&&o.aborted)return Zo("Aborted by cancel()");let d=Hd(a),l={toolName:a,args:t,description:i.description,...d?{title:d}:{},reason:"gate"};if(!await this.requestConfirm(l))return Zo("User declined the tool call.");if(o!=null&&o.aborted)return Zo("Aborted by cancel()");let u=new AbortController,f=!1,p=setTimeout(()=>{f=!0,u.abort()},this.timeoutMs),m=()=>u.abort();o&&(o.aborted?u.abort():o.addEventListener("abort",m,{once:!0}));try{let y=await n.executeTool(i,F0(t),{signal:u.signal});return O0(y)}catch(y){if(f)return Zo(`WebMCP tool '${a}' timed out after ${this.timeoutMs}ms`);if(o!=null&&o.aborted)return Zo("Aborted by cancel()");let h=y instanceof Error?y.message:String(y);return Zo(h)}finally{clearTimeout(p),o&&o.removeEventListener("abort",m)}}ensureReady(){return this.config.enabled!==!0?Promise.resolve():(this.readyPromise||(this.readyPromise=this.install()),this.readyPromise)}async install(){try{if(this.getModelContext()){this.installed=!0;return}(Id?await Id():await import("@mcp-b/webmcp-polyfill")).initializeWebMCPPolyfill(),this.installed=!0}catch(e){qi.warn("Failed to load @mcp-b/webmcp-polyfill \u2014 WebMCP consumption disabled.",e),this.installed=!1}}getModelContext(){if(typeof document=="undefined")return null;let e=document.modelContext;if(!e||typeof e!="object")return null;let t=e;return typeof t.getTools!="function"||typeof t.executeTool!="function"?(this.incompatibleContextWarned||(this.incompatibleContextWarned=!0,qi.warn("document.modelContext is present but does not expose getTools()/executeTool() \u2014 WebMCP consumption is disabled. Another (incompatible or older) WebMCP polyfill likely installed document.modelContext before Persona. Remove it, or use a polyfill implementing the strict standard surface (e.g. @mcp-b/webmcp-polyfill).")),null):e}async requestConfirm(e){var o;let t=(o=this.confirmHandler)!=null?o:_0;try{return await t(e)}catch(n){return qi.warn(`Confirm handler threw for WebMCP tool '${e.toolName}'; declining.`,n),!1}}passesClientAllowlist(e){let t=this.config.allowlist;return!t||t.length===0?!0:t.some(o=>B0(e,o))}},zi=r=>r.startsWith(Cn)?r.slice(Cn.length):r,ga=r=>r.startsWith(Cn),B0=(r,e)=>{if(e==="*")return!0;let t=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&");return new RegExp("^"+t.replace(/\*/g,".*")+"$").test(r)},D0=r=>{if(!(r===void 0||r===""))try{let e=JSON.parse(r);return e!==null&&typeof e=="object"?e:void 0}catch{return}},O0=r=>{if(r==null)return{content:[{type:"text",text:""}]};let e;try{e=JSON.parse(r)}catch{return{content:[{type:"text",text:r}]}}return e!==null&&typeof e=="object"&&Array.isArray(e.content)?e:{content:[{type:"text",text:typeof e=="string"?e:U0(e)}]}},Zo=r=>({isError:!0,content:[{type:"text",text:r}]}),_0=async r=>{if(typeof window=="undefined"||typeof window.confirm!="function")return!1;let e=N0(r.args),t=`Allow the AI to call ${r.toolName}`+(e?`
|
|
49
50
|
|
|
50
51
|
Arguments:
|
|
51
52
|
${e}`:"")+(r.description?`
|
|
52
53
|
|
|
53
|
-
${r.description}`:"");return window.confirm(t)},i0=r=>{if(r==null)return"";try{let e=JSON.stringify(r,null,2);return e.length>500?e.slice(0,500)+"\u2026":e}catch{return String(r)}},l0=r=>{if(r===void 0)return"{}";try{let e=JSON.stringify(r);return e===void 0?"{}":e}catch{return"{}"}},d0=r=>{if(r===void 0)return"";try{return JSON.stringify(r)}catch{return String(r)}};var go=Ai(Fi(),1),Ni=r=>r.replace(/\\n/g,`
|
|
54
|
-
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\"),
|
|
55
|
-
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}catch{return a[1]}let s=/"text"\s*:\s*"((?:[^"\\]|\\.)*)/,i=
|
|
56
|
-
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}catch{return i[1]}return null};return{getExtractedText:()=>r,processChunk:async n=>{if(n.length<=e)return r!==null?{text:r,raw:n}:null;let o=n.trim();if(!o.startsWith("{")&&!o.startsWith("["))return null;let a=t(n);return a!==null&&(r=a),e=n.length,r!==null?{text:r,raw:n}:null},close:async()=>{}}},la=r=>{try{let e=JSON.parse(r);if(e&&typeof e=="object"&&typeof e.text=="string")return e.text}catch{return null}return null},qi=()=>{let r={processChunk:e=>null,getExtractedText:()=>null};return r.__isPlainTextParser=!0,r},zi=()=>{var e;let r=h0();return{processChunk:async t=>{let n=t.trim();return!n.startsWith("{")&&!n.startsWith("[")?null:r.processChunk(t)},getExtractedText:r.getExtractedText.bind(r),close:(e=r.close)==null?void 0:e.bind(r)}},$i=()=>{let r=null,e=0;return{getExtractedText:()=>r,processChunk:t=>{let n=t.trim();if(!n.startsWith("{")&&!n.startsWith("["))return null;if(t.length<=e)return r!==null||r===""?{text:r||"",raw:t}:null;try{let o=(0,go.parse)(t,go.STR|go.OBJ);o&&typeof o=="object"&&(o.component&&typeof o.component=="string"?r=typeof o.text=="string"?Ni(o.text):"":o.type==="init"&&o.form?r="":typeof o.text=="string"&&(r=Ni(o.text)))}catch{}return e=t.length,r!==null?{text:r,raw:t}:null},close:()=>{}}},wh=r=>{let e=null,t=0,o=r||(a=>{if(!a||typeof a!="object")return null;let s=i=>typeof i=="string"?Ni(i):null;if(a.component&&typeof a.component=="string")return typeof a.text=="string"?Ni(a.text):"";if(a.type==="init"&&a.form)return"";if(a.action)switch(a.action){case"nav_then_click":return s(a.on_load_text)||s(a.text)||null;case"message":case"message_and_click":case"checkout":return s(a.text)||null;default:return s(a.text)||s(a.display_text)||s(a.message)||null}return s(a.text)||s(a.display_text)||s(a.message)||s(a.content)||null});return{getExtractedText:()=>e,processChunk:a=>{let s=a.trim();if(!s.startsWith("{")&&!s.startsWith("["))return null;if(a.length<=t)return e!==null?{text:e,raw:a}:null;try{let i=(0,go.parse)(a,go.STR|go.OBJ),d=o(i);d!==null&&(e=d)}catch{}return t=a.length,{text:e||"",raw:a}},close:()=>{}}},Vi=()=>{let r=null;return{processChunk:e=>{if(!e.trim().startsWith("<"))return null;let n=e.match(/<text[^>]*>([\s\S]*?)<\/text>/);return n&&n[1]?(r=n[1],{text:r,raw:e}):null},getExtractedText:()=>r}};var ji=class{constructor(e,t=50){this.nextExpectedSeq=null;this.buffer=new Map;this.flushTimer=null;this.emitter=e,this.gapTimeoutMs=t}push(e,t){var a,s,i;let n=(i=(a=t==null?void 0:t.seq)!=null?a:t==null?void 0:t.sequenceIndex)!=null?i:(s=t==null?void 0:t.agentContext)==null?void 0:s.seq;if(n==null){this.buffer.size>0&&this.flushAll(),this.emitter(e,t);return}if(this.nextExpectedSeq===null&&(this.nextExpectedSeq=1),n===this.nextExpectedSeq){this.emitter(e,t),this.nextExpectedSeq=n+1,this.drainConsecutive();return}if(n<this.nextExpectedSeq){this.emitter(e,t);return}let o=this.buffer.get(n);o!==void 0&&(typeof console!="undefined"&&typeof console.warn=="function"&&console.warn(`[persona] SequenceReorderBuffer: duplicate seq=${n} (${o.payloadType} vs ${e}); emitting earlier event out-of-order to avoid loss`),this.emitter(o.payloadType,o.payload)),this.buffer.set(n,{payloadType:e,payload:t,seq:n}),this.startGapTimer()}drainConsecutive(){for(;this.buffer.has(this.nextExpectedSeq);){let e=this.buffer.get(this.nextExpectedSeq);this.buffer.delete(this.nextExpectedSeq),this.emitter(e.payloadType,e.payload),this.nextExpectedSeq++}this.buffer.size===0&&this.clearGapTimer()}startGapTimer(){this.flushTimer===null&&(this.flushTimer=setTimeout(()=>{this.flushAll()},this.gapTimeoutMs))}clearGapTimer(){this.flushTimer!==null&&(clearTimeout(this.flushTimer),this.flushTimer=null)}flushAll(){if(this.clearGapTimer(),this.buffer.size===0)return;let e=[...this.buffer.entries()].sort((t,n)=>t[0]-n[0]);for(let[t,n]of e)this.buffer.delete(t),this.emitter(n.payloadType,n.payload);e.length>0&&(this.nextExpectedSeq=e[e.length-1][0]+1)}destroy(){this.clearGapTimer(),this.buffer.clear()}flushPending(){this.flushAll()}};var x0="https://api.runtype.com/v1/dispatch",Gi="https://api.runtype.com";function b0(r){var a,s;let e=r.toLowerCase(),n={"application/pdf":"pdf","application/json":"json","application/zip":"zip","text/plain":"txt","text/csv":"csv","text/markdown":"md"}[e];if(n)return`attachment.${n}`;let o=e.indexOf("/");if(o>0){let i=(s=(a=e.slice(o+1).split(";")[0])==null?void 0:a.trim())!=null?s:"";if(i&&i!=="octet-stream"&&/^[a-z0-9.+-]+$/i.test(i))return`attachment.${i}`}return"attachment"}var kd=r=>!!(r.contentParts&&r.contentParts.length>0||r.llmContent&&r.llmContent.trim().length>0||r.rawContent&&r.rawContent.trim().length>0||r.content&&r.content.trim().length>0);function y0(r){switch(r){case"json":return $i;case"regex-json":return zi;case"xml":return Vi;default:return qi}}var Ah=r=>r.startsWith("{")||r.startsWith("[")||r.startsWith("<");function v0(r,e){if(!r)return e;let t=r.trim(),n=e.trim();if(t.length===0)return e;if(n.length===0)return r;let o=Ah(t);if(!Ah(n))return r;if(!o||n===t||n.startsWith(t))return e;let s=la(r);return la(e)!==null&&s===null?e:r}var da=class{constructor(e={}){this.config=e;this.clientSession=null;this.sessionInitPromise=null;this.lastSentClientToolsFingerprint=null;this.clientToolsFingerprintSessionId=null;var t,n,o,a;this.apiUrl=(t=e.apiUrl)!=null?t:x0,this.headers={"Content-Type":"application/json",...e.headers},this.debug=!!e.debug,this.createStreamParser=(n=e.streamParser)!=null?n:y0(e.parserType),this.contextProviders=(o=e.contextProviders)!=null?o:[],this.requestMiddleware=e.requestMiddleware,this.customFetch=e.customFetch,this.parseSSEEvent=e.parseSSEEvent,this.getHeaders=e.getHeaders,this.webMcpBridge=((a=e.webmcp)==null?void 0:a.enabled)===!0?new Fa(e.webmcp):null}setSSEEventCallback(e){this.onSSEEvent=e}setWebMcpConfirmHandler(e){var t;(t=this.webMcpBridge)==null||t.setConfirmHandler(e)}isWebMcpOperational(){var e;return((e=this.webMcpBridge)==null?void 0:e.isOperational())===!0}executeWebMcpToolCall(e,t,n){return this.webMcpBridge?this.webMcpBridge.executeToolCall(e,t,n):null}getSSEEventCallback(){return this.onSSEEvent}isClientTokenMode(){return!!this.config.clientToken}isAgentMode(){return!!this.config.agent}getClientApiUrl(e){var n;return`${((n=this.config.apiUrl)==null?void 0:n.replace(/\/+$/,"").replace(/\/v1\/dispatch$/,""))||Gi}/v1/client/${e}`}getClientSession(){return this.clientSession}async initSession(){var e,t;if(!this.isClientTokenMode())throw new Error("initSession() only available in client token mode");if(this.clientSession&&new Date<this.clientSession.expiresAt)return this.clientSession;if(this.sessionInitPromise)return this.sessionInitPromise;this.sessionInitPromise=this._doInitSession();try{let n=await this.sessionInitPromise;return this.clientSession=n,this.resetClientToolsFingerprint(),(t=(e=this.config).onSessionInit)==null||t.call(e,n),n}finally{this.sessionInitPromise=null}}async _doInitSession(){var a,s;let e=((s=(a=this.config).getStoredSessionId)==null?void 0:s.call(a))||null,t={token:this.config.clientToken,...this.config.flowId&&{flowId:this.config.flowId},...e&&{sessionId:e}},n=await fetch(this.getClientApiUrl("init"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){let i=await n.json().catch(()=>({error:"Session initialization failed"}));throw n.status===401?new Error(`Invalid client token: ${i.hint||i.error}`):n.status===403?new Error(`Origin not allowed: ${i.hint||i.error}`):new Error(i.error||"Failed to initialize session")}let o=await n.json();return this.config.setStoredSessionId&&this.config.setStoredSessionId(o.sessionId),{sessionId:o.sessionId,expiresAt:new Date(o.expiresAt),flow:o.flow,config:{welcomeMessage:o.config.welcomeMessage,placeholder:o.config.placeholder,theme:o.config.theme}}}clearClientSession(){this.clientSession=null,this.sessionInitPromise=null,this.resetClientToolsFingerprint()}resetClientToolsFingerprint(){this.lastSentClientToolsFingerprint=null,this.clientToolsFingerprintSessionId=null}getFeedbackApiUrl(){var t;return`${((t=this.config.apiUrl)==null?void 0:t.replace(/\/+$/,"").replace(/\/v1\/dispatch$/,""))||Gi}/v1/client/feedback`}async sendFeedback(e){var a,s;if(!this.isClientTokenMode())throw new Error("sendFeedback() only available in client token mode");if(!this.getClientSession())throw new Error("No active session. Please initialize session first.");if(["upvote","downvote","copy"].includes(e.type)&&!e.messageId)throw new Error(`messageId is required for ${e.type} feedback type`);if(e.type==="csat"&&(e.rating===void 0||e.rating<1||e.rating>5))throw new Error("CSAT rating must be between 1 and 5");if(e.type==="nps"&&(e.rating===void 0||e.rating<0||e.rating>10))throw new Error("NPS rating must be between 0 and 10");this.debug&&console.debug("[AgentWidgetClient] sending feedback",e);let o=await fetch(this.getFeedbackApiUrl(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok){let i=await o.json().catch(()=>({error:"Feedback submission failed"}));throw o.status===401?(this.clientSession=null,(s=(a=this.config).onSessionExpired)==null||s.call(a),new Error("Session expired. Please refresh to continue.")):new Error(i.error||"Failed to submit feedback")}}async submitMessageFeedback(e,t){let n=this.getClientSession();if(!n)throw new Error("No active session. Please initialize session first.");return this.sendFeedback({sessionId:n.sessionId,messageId:e,type:t})}async submitCSATFeedback(e,t){let n=this.getClientSession();if(!n)throw new Error("No active session. Please initialize session first.");return this.sendFeedback({sessionId:n.sessionId,type:"csat",rating:e,comment:t})}async submitNPSFeedback(e,t){let n=this.getClientSession();if(!n)throw new Error("No active session. Please initialize session first.");return this.sendFeedback({sessionId:n.sessionId,type:"nps",rating:e,comment:t})}async dispatch(e,t){return this.isAgentMode()?this.dispatchAgent(e,t):this.isClientTokenMode()?this.dispatchClientToken(e,t):this.dispatchProxy(e,t)}async dispatchClientToken(e,t){var o,a,s,i;let n=new AbortController;e.signal&&e.signal.addEventListener("abort",()=>n.abort()),t({type:"status",status:"connecting"});try{let d=await this.initSession();if(new Date>=new Date(d.expiresAt.getTime()-6e4)){this.clearClientSession(),(a=(o=this.config).onSessionExpired)==null||a.call(o);let h=new Error("Session expired. Please refresh to continue.");throw t({type:"error",error:h}),h}let l=await this.buildPayload(e.messages),p=l.metadata?Object.fromEntries(Object.entries(l.metadata).filter(([h])=>h!=="sessionId"&&h!=="session_id")):void 0,f={sessionId:d.sessionId,messages:e.messages.filter(kd).map(h=>{var w,C,T;return{id:h.id,role:h.role,content:(T=(C=(w=h.contentParts)!=null?w:h.llmContent)!=null?C:h.rawContent)!=null?T:h.content}}),...e.assistantMessageId&&{assistantMessageId:e.assistantMessageId},...p&&Object.keys(p).length>0&&{metadata:p},...l.inputs&&Object.keys(l.inputs).length>0&&{inputs:l.inputs},...l.context&&{context:l.context}},u=l.clientTools,m=!!(u&&u.length>0),v=m?bh(u):void 0,x=this.clientToolsFingerprintSessionId===d.sessionId,S=m&&x&&this.lastSentClientToolsFingerprint===v,M=!1,E=null,k;for(let h=0;;h++){let C={...f,...m&&(M||!S)&&u?{clientTools:u}:{},...v?{clientToolsFingerprint:v}:{}};if(this.debug&&console.debug("[AgentWidgetClient] client token dispatch",C),k=await fetch(this.getClientApiUrl("chat"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C),signal:n.signal}),k.status===409&&h===0&&m){let T=await k.json().catch(()=>null);if((T==null?void 0:T.error)==="client_tools_resend_required"){M=!0,this.lastSentClientToolsFingerprint=null;continue}E=T!=null?T:{error:"Chat request failed"}}break}if(!k.ok){let h=E!=null?E:await k.json().catch(()=>({error:"Chat request failed"}));if(k.status===401){this.clearClientSession(),(i=(s=this.config).onSessionExpired)==null||i.call(s);let C=new Error("Session expired. Please refresh to continue.");throw t({type:"error",error:C}),C}if(k.status===429){let C=new Error(h.hint||"Message limit reached for this session.");throw t({type:"error",error:C}),C}let w=new Error(h.error||"Failed to send message");throw t({type:"error",error:w}),w}if(!k.body){let h=new Error("No response body received");throw t({type:"error",error:h}),h}this.lastSentClientToolsFingerprint=v!=null?v:null,this.clientToolsFingerprintSessionId=d.sessionId,t({type:"status",status:"connected"});try{await this.streamResponse(k.body,t,e.assistantMessageId)}finally{t({type:"status",status:"idle"})}}catch(d){let l=d instanceof Error?d:new Error(String(d));throw!l.message.includes("Session expired")&&!l.message.includes("Message limit")&&t({type:"error",error:l}),l}}async dispatchProxy(e,t){let n=new AbortController;e.signal&&e.signal.addEventListener("abort",()=>n.abort()),t({type:"status",status:"connecting"});let o=await this.buildPayload(e.messages);this.debug&&console.debug("[AgentWidgetClient] dispatch payload",o);let a={...this.headers};if(this.getHeaders)try{let i=await this.getHeaders();a={...a,...i}}catch(i){typeof console!="undefined"&&console.error("[AgentWidget] getHeaders error:",i)}let s;if(this.customFetch)try{s=await this.customFetch(this.apiUrl,{method:"POST",headers:a,body:JSON.stringify(o),signal:n.signal},o)}catch(i){let d=i instanceof Error?i:new Error(String(i));throw t({type:"error",error:d}),d}else s=await fetch(this.apiUrl,{method:"POST",headers:a,body:JSON.stringify(o),signal:n.signal});if(!s.ok||!s.body){let i=new Error(`Chat backend request failed: ${s.status} ${s.statusText}`);throw t({type:"error",error:i}),i}t({type:"status",status:"connected"});try{await this.streamResponse(s.body,t)}finally{t({type:"status",status:"idle"})}}async dispatchAgent(e,t){let n=new AbortController;e.signal&&e.signal.addEventListener("abort",()=>n.abort()),t({type:"status",status:"connecting"});let o=await this.buildAgentPayload(e.messages);this.debug&&console.debug("[AgentWidgetClient] agent dispatch payload",o);let a={...this.headers};if(this.getHeaders)try{let i=await this.getHeaders();a={...a,...i}}catch(i){typeof console!="undefined"&&console.error("[AgentWidget] getHeaders error:",i)}let s;if(this.customFetch)try{s=await this.customFetch(this.apiUrl,{method:"POST",headers:a,body:JSON.stringify(o),signal:n.signal},o)}catch(i){let d=i instanceof Error?i:new Error(String(i));throw t({type:"error",error:d}),d}else s=await fetch(this.apiUrl,{method:"POST",headers:a,body:JSON.stringify(o),signal:n.signal});if(!s.ok||!s.body){let i=new Error(`Agent execution request failed: ${s.status} ${s.statusText}`);throw t({type:"error",error:i}),i}t({type:"status",status:"connected"});try{await this.streamResponse(s.body,t,e.assistantMessageId)}finally{t({type:"status",status:"idle"})}}async processStream(e,t,n){t({type:"status",status:"connected"});try{await this.streamResponse(e,t,n)}finally{t({type:"status",status:"idle"})}}async resolveApproval(e,t){var s;let o=`${((s=this.config.apiUrl)==null?void 0:s.replace(/\/+$/,"").replace(/\/v1\/dispatch$/,""))||Gi}/v1/agents/${e.agentId}/approve`,a={"Content-Type":"application/json",...this.headers};return this.getHeaders&&Object.assign(a,await this.getHeaders()),fetch(o,{method:"POST",headers:a,body:JSON.stringify({executionId:e.executionId,approvalId:e.approvalId,decision:t,streamResponse:!0})})}async resumeFlow(e,t,n){var l,p;let o=this.isClientTokenMode(),a=o?this.getClientApiUrl("resume"):`${((l=this.config.apiUrl)==null?void 0:l.replace(/\/+$/,""))||Gi}/resume`,s;o&&(s=(await this.initSession()).sessionId);let i={"Content-Type":"application/json",...this.headers};this.getHeaders&&Object.assign(i,await this.getHeaders());let d={executionId:e,toolOutputs:t,streamResponse:(p=n==null?void 0:n.streamResponse)!=null?p:!0};return s&&(d.sessionId=s),fetch(a,{method:"POST",headers:i,body:JSON.stringify(d),signal:n==null?void 0:n.signal})}async buildAgentPayload(e){var a;if(!this.config.agent)throw new Error("Agent configuration required for agent mode");let t=e.slice().filter(kd).filter(s=>s.role==="user"||s.role==="assistant"||s.role==="system").filter(s=>!s.variant||s.variant==="assistant").sort((s,i)=>{let d=new Date(s.createdAt).getTime(),l=new Date(i.createdAt).getTime();return d-l}).map(s=>{var i,d,l;return{role:s.role,content:(l=(d=(i=s.contentParts)!=null?i:s.llmContent)!=null?d:s.rawContent)!=null?l:s.content,createdAt:s.createdAt}}),n={agent:this.config.agent,messages:t,options:{streamResponse:!0,recordMode:"virtual",...this.config.agentOptions}},o=await((a=this.webMcpBridge)==null?void 0:a.snapshotForDispatch());if(o&&o.length>0&&(n.clientTools=o),this.contextProviders.length){let s={};await Promise.all(this.contextProviders.map(async i=>{try{let d=await i({messages:e,config:this.config});d&&typeof d=="object"&&Object.assign(s,d)}catch(d){typeof console!="undefined"&&console.warn("[AgentWidget] Context provider failed:",d)}})),Object.keys(s).length&&(n.context=s)}return n}async buildPayload(e){var a;let n={messages:e.slice().filter(kd).sort((s,i)=>{let d=new Date(s.createdAt).getTime(),l=new Date(i.createdAt).getTime();return d-l}).map(s=>{var i,d,l;return{role:s.role,content:(l=(d=(i=s.contentParts)!=null?i:s.llmContent)!=null?d:s.rawContent)!=null?l:s.content,createdAt:s.createdAt}}),...this.config.flowId&&{flowId:this.config.flowId}},o=await((a=this.webMcpBridge)==null?void 0:a.snapshotForDispatch());if(o&&o.length>0&&(n.clientTools=o),this.contextProviders.length){let s={};await Promise.all(this.contextProviders.map(async i=>{try{let d=await i({messages:e,config:this.config});d&&typeof d=="object"&&Object.assign(s,d)}catch(d){typeof console!="undefined"&&console.warn("[AgentWidget] Context provider failed:",d)}})),Object.keys(s).length&&(n.context=s)}if(this.requestMiddleware)try{let s=await this.requestMiddleware({payload:{...n},config:this.config});if(s&&typeof s=="object"){let i=s;return n.clientTools!==void 0&&!("clientTools"in i)&&(i.clientTools=n.clientTools),i}}catch(s){typeof console!="undefined"&&console.error("[AgentWidget] Request middleware error:",s)}return n}async handleCustomSSEEvent(e,t,n,o,a,s){if(!this.parseSSEEvent)return!1;try{let i=await this.parseSSEEvent(e);if(i===null)return!1;let d=p=>{let f={id:`assistant-${Date.now()}-${Math.random().toString(16).slice(2)}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,variant:"assistant",sequence:a(),...p!==void 0&&{partId:p}};return n.current=f,o(f),f},l=p=>n.current?n.current:d(p);if(i.text!==void 0){i.partId!==void 0&&s.current!==null&&i.partId!==s.current&&(n.current&&(n.current.streaming=!1,o(n.current)),d(i.partId)),i.partId!==void 0&&(s.current=i.partId);let p=l(i.partId);i.partId!==void 0&&!p.partId&&(p.partId=i.partId),p.content+=i.text,o(p)}return i.done&&(n.current&&(n.current.streaming=!1,o(n.current)),s.current=null,t({type:"status",status:"idle"})),i.error&&(s.current=null,t({type:"error",error:new Error(i.error)})),!0}catch(i){return typeof console!="undefined"&&console.error("[AgentWidget] parseSSEEvent error:",i),!1}}async streamResponse(e,t,n){var Dt,ar,gr,nn;let o=e.getReader(),a=new TextDecoder,s="",i=Date.now(),d=0,l=()=>i+d++,p=F=>{let fe=F.reasoning?{...F.reasoning,chunks:[...F.reasoning.chunks]}:void 0,Re=F.toolCall?{...F.toolCall,chunks:F.toolCall.chunks?[...F.toolCall.chunks]:void 0}:void 0,Xe=F.tools?F.tools.map(Fe=>({...Fe,chunks:Fe.chunks?[...Fe.chunks]:void 0})):void 0;return{...F,reasoning:fe,toolCall:Re,tools:Xe}},f=F=>{if(F.role!=="assistant"||F.variant)return!0;let fe=Array.isArray(F.contentParts)&&F.contentParts.length>0,Re=typeof F.rawContent=="string"&&F.rawContent.trim()!=="";return typeof F.content=="string"&&F.content.trim()!==""||fe||Re||!!F.stopReason},u=F=>{f(F)&&t({type:"message",message:p(F)})},m=null,v=null,x={current:null},S={current:null},M=!1,E=new Map,k=new Map,h=new Map,w=new Map,C={lastId:null,byStep:new Map},T={lastId:null,byCall:new Map},W=(F,fe,Re="")=>`${F}::${fe}::${Re}`,R=(F,fe)=>`${F}::${fe}::`,I=(F,fe,Re,Xe)=>{let Fe=W(F,fe,Re),Oe=h.get(Fe);if(Oe)return Oe;let Ye=Re?`-${Re}`:"",Tt={id:`nested-${F}-${fe}${Ye}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,sequence:l(),...Re?{partId:Re}:{},agentMetadata:{executionId:Xe,parentToolId:F,parentStepId:fe}};return h.set(Fe,Tt),u(Tt),Tt},N=F=>{if(F==null)return null;try{return String(F)}catch{return null}},V=F=>{var fe,Re,Xe,Fe,Oe;return N((Oe=(Fe=(Xe=(Re=(fe=F.stepId)!=null?fe:F.step_id)!=null?Re:F.step)!=null?Xe:F.parentId)!=null?Fe:F.flowStepId)!=null?Oe:F.flow_step_id)},ie=F=>{var fe,Re,Xe,Fe,Oe,Ye,Tt;return N((Tt=(Ye=(Oe=(Fe=(Xe=(Re=(fe=F.callId)!=null?fe:F.call_id)!=null?Re:F.requestId)!=null?Xe:F.request_id)!=null?Fe:F.toolCallId)!=null?Oe:F.tool_call_id)!=null?Ye:F.stepId)!=null?Tt:F.step_id)},xe=n,Je=!1,we=()=>{if(m)return m;let F;return!Je&&xe?(F=xe,Je=!0):xe&&S.current?F=`${xe}_${S.current}`:F=`assistant-${Date.now()}-${Math.random().toString(16).slice(2)}`,m={id:F,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,sequence:l()},u(m),m},De=(F,fe)=>{C.lastId=fe,F&&C.byStep.set(F,fe)},Ae=(F,fe)=>{var Oe;let Re=(Oe=F.reasoningId)!=null?Oe:F.id,Xe=V(F);if(Re){let Ye=String(Re);return De(Xe,Ye),Ye}if(Xe){let Ye=C.byStep.get(Xe);if(Ye)return C.lastId=Ye,Ye}if(C.lastId&&!fe)return C.lastId;if(!fe)return null;let Fe=`reason-${l()}`;return De(Xe,Fe),Fe},qe=F=>{let fe=E.get(F);if(fe)return fe;let Re={id:`reason-${F}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,variant:"reasoning",sequence:l(),reasoning:{id:F,status:"streaming",chunks:[]}};return E.set(F,Re),u(Re),Re},Ie=(F,fe)=>{T.lastId=fe,F&&T.byCall.set(F,fe)},J=new Set,re=new Map,Q=new Set,ge=new Map,Z=F=>{if(!F)return!1;let fe=F.replace(/_+/g,"_").replace(/^_|_$/g,"");return fe==="emit_artifact_markdown"||fe==="emit_artifact_component"},G=(F,fe)=>{var Oe;let Re=(Oe=F.toolId)!=null?Oe:F.id,Xe=ie(F);if(Re){let Ye=String(Re);return Ie(Xe,Ye),Ye}if(Xe){let Ye=T.byCall.get(Xe);if(Ye)return T.lastId=Ye,Ye}if(T.lastId&&!fe)return T.lastId;if(!fe)return null;let Fe=`tool-${l()}`;return Ie(Xe,Fe),Fe},pe=F=>{let fe=k.get(F);if(fe)return fe;let Re={id:`tool-${F}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,variant:"tool",sequence:l(),toolCall:{id:F,status:"pending"}};return k.set(F,Re),u(Re),Re},ke=F=>{if(typeof F=="number"&&Number.isFinite(F))return F;if(typeof F=="string"){let fe=Number(F);if(!Number.isNaN(fe)&&Number.isFinite(fe))return fe;let Re=Date.parse(F);if(!Number.isNaN(Re))return Re}return Date.now()},le=F=>{if(typeof F=="string")return F;if(F==null)return"";try{return JSON.stringify(F)}catch{return String(F)}},ne=new Map,de=new Map,Lt=new Map,St=new Map,We=null,he=(F,fe,Re)=>{var Tt;let Xe=Lt.get(F);Xe||(Xe=[],Lt.set(F,Xe));let Fe=0,Oe=Xe.length;for(;Fe<Oe;){let Qt=Fe+Oe>>>1;Xe[Qt].seq<fe?Fe=Qt+1:Oe=Qt}((Tt=Xe[Fe])==null?void 0:Tt.seq)===fe?Xe[Fe]={seq:fe,text:Re}:Xe.splice(Fe,0,{seq:fe,text:Re});let Ye="";for(let Qt=0;Qt<Xe.length;Qt++)Ye+=Xe[Qt].text;return Ye},at=(F,fe)=>{let Re=le(fe),Xe=de.get(F.id),Fe=v0(Xe,Re);F.rawContent=Fe;let Oe=ne.get(F.id),Ye=ft=>{var ye;let it=(ye=F.content)!=null?ye:"";ft.trim()!==""&&(it.trim().length===0||ft.startsWith(it)||ft.trimStart().startsWith(it.trim()))&&(F.content=ft)},Tt=()=>{var ft;if(Oe){let it=(ft=Oe.close)==null?void 0:ft.call(Oe);it instanceof Promise&&it.catch(()=>{})}ne.delete(F.id),de.delete(F.id),F.streaming=!1,u(F)};if(!Oe){Ye(Re),Tt();return}let Qt=la(Fe);if(Qt!==null&&Qt.trim()!==""){Ye(Qt),Tt();return}let sr=ft=>{var se;let it=typeof ft=="string"?ft:(se=ft==null?void 0:ft.text)!=null?se:null;if(it!==null&&it.trim()!=="")return it;let ye=Oe.getExtractedText();return ye!==null&&ye.trim()!==""?ye:Re},K;try{K=Oe.processChunk(Fe)}catch{Ye(Re),Tt();return}if(K instanceof Promise){K.then(ft=>{Ye(sr(ft)),Tt()}).catch(()=>{Ye(Re),Tt()});return}Ye(sr(K)),Tt()},Pe=[],j=!1,ue,nt=()=>{j||(j=!0,queueMicrotask(()=>{j=!1,ue()}))},It=new ji((F,fe)=>{Pe.push({payloadType:F,payload:fe}),nt()}),ee=null,je=new Map,Fr=(Dt=this.config.iterationDisplay)!=null?Dt:"separate";for(ue=()=>{var F,fe,Re,Xe,Fe,Oe,Ye,Tt,Qt,sr,K,ft,it,ye,se,st,ur,ct,xr,Ir,pt,Pt,et,$t,br,ir,fr,Sr,cn,Mt,_r,hr,An,on,Ct,jn,Sn,_e,P,ae,Ee,Ot,Ze,_t,Zt,dr,wt,Ur,Vt,qr,Fn,no,wo,pn,jt,Kr,Tn,Ao,oo,So,Gn,un,Nn,kt,yr,vr,fn,To,ve,Mn,kn,q,Kn,ao,so,Xn,On,rs,mn,gn,_n,Un,Vo,io,zr,Qn,wa,jo,Aa,si,Sa,ii,Ta,Rt,ns,En,an,li,di,Ma,lo,os,Mo,as,ss,is,ls,sn,ka,Jn,Yn,ds,ci,cs,ps,Go,pi,ui,fi,mi,Zl,Ko,ko,gi,us,Eo,hi,fs,Lo,ms,xi,co,bi,Po,Gt,Ea,La,gs;for(let Ln=0;Ln<Pe.length;Ln++){let tt=Pe[Ln].payloadType,L=Pe[Ln].payload;if(tt==="reason_start"){let z=(F=Ae(L,!0))!=null?F:`reason-${l()}`,B=qe(z);B.reasoning=(fe=B.reasoning)!=null?fe:{id:z,status:"streaming",chunks:[]},B.reasoning.startedAt=(Xe=B.reasoning.startedAt)!=null?Xe:ke((Re=L.startedAt)!=null?Re:L.timestamp),B.reasoning.completedAt=void 0,B.reasoning.durationMs=void 0,B.streaming=!0,B.reasoning.status="streaming",u(B)}else if(tt==="reason_delta"||tt==="reason_chunk"){let z=(Oe=(Fe=Ae(L,!1))!=null?Fe:Ae(L,!0))!=null?Oe:`reason-${l()}`,B=qe(z);B.reasoning=(Ye=B.reasoning)!=null?Ye:{id:z,status:"streaming",chunks:[]},B.reasoning.startedAt=(Qt=B.reasoning.startedAt)!=null?Qt:ke((Tt=L.startedAt)!=null?Tt:L.timestamp);let te=(ft=(K=(sr=L.reasoningText)!=null?sr:L.text)!=null?K:L.delta)!=null?ft:"";if(te&&L.hidden!==!0){let ce=typeof L.sequenceIndex=="number"?L.sequenceIndex:void 0;if(ce!==void 0){let X=he(z,ce,String(te));B.reasoning.chunks=[X]}else B.reasoning.chunks.push(String(te))}if(B.reasoning.status=L.done?"complete":"streaming",L.done){B.reasoning.completedAt=ke((it=L.completedAt)!=null?it:L.timestamp);let ce=(ye=B.reasoning.startedAt)!=null?ye:Date.now();B.reasoning.durationMs=Math.max(0,((se=B.reasoning.completedAt)!=null?se:Date.now())-ce)}B.streaming=B.reasoning.status!=="complete",u(B)}else if(tt==="reason_complete"){let z=(ur=(st=Ae(L,!1))!=null?st:Ae(L,!0))!=null?ur:`reason-${l()}`,B=E.get(z);if(B!=null&&B.reasoning){B.reasoning.status="complete",B.reasoning.completedAt=ke((ct=L.completedAt)!=null?ct:L.timestamp);let ce=(xr=B.reasoning.startedAt)!=null?xr:Date.now();B.reasoning.durationMs=Math.max(0,((Ir=B.reasoning.completedAt)!=null?Ir:Date.now())-ce),B.streaming=!1,u(B)}let te=V(L);te&&C.byStep.delete(te)}else if(tt==="tool_start"){let z=(pt=G(L,!0))!=null?pt:`tool-${l()}`,B=(Pt=L.toolName)!=null?Pt:L.name;if(Z(B)){J.add(z);continue}let te=pe(z),ce=(et=te.toolCall)!=null?et:{id:z,status:"pending"};ce.name=B!=null?B:ce.name,ce.status="running",L.args!==void 0?ce.args=L.args:L.parameters!==void 0&&(ce.args=L.parameters),ce.startedAt=(br=ce.startedAt)!=null?br:ke(($t=L.startedAt)!=null?$t:L.timestamp),ce.completedAt=void 0,ce.durationMs=void 0,te.toolCall=ce,te.streaming=!0;let X=L.agentContext;(X||L.executionId)&&(te.agentMetadata={executionId:(ir=X==null?void 0:X.executionId)!=null?ir:L.executionId,iteration:(fr=X==null?void 0:X.iteration)!=null?fr:L.iteration}),u(te)}else if(tt==="tool_chunk"||tt==="tool_delta"){let z=(cn=(Sr=G(L,!1))!=null?Sr:G(L,!0))!=null?cn:`tool-${l()}`;if(J.has(z))continue;let B=pe(z),te=(Mt=B.toolCall)!=null?Mt:{id:z,status:"running"};te.startedAt=(hr=te.startedAt)!=null?hr:ke((_r=L.startedAt)!=null?_r:L.timestamp);let ce=(Ct=(on=(An=L.text)!=null?An:L.delta)!=null?on:L.message)!=null?Ct:"";ce&&(te.chunks=(jn=te.chunks)!=null?jn:[],te.chunks.push(String(ce))),te.status="running",B.toolCall=te,B.streaming=!0;let X=L.agentContext;(X||L.executionId)&&(B.agentMetadata=(P=B.agentMetadata)!=null?P:{executionId:(Sn=X==null?void 0:X.executionId)!=null?Sn:L.executionId,iteration:(_e=X==null?void 0:X.iteration)!=null?_e:L.iteration}),u(B)}else if(tt==="tool_complete"){let z=(Ee=(ae=G(L,!1))!=null?ae:G(L,!0))!=null?Ee:`tool-${l()}`;if(J.has(z)){J.delete(z);continue}let B=pe(z),te=(Ot=B.toolCall)!=null?Ot:{id:z,status:"running"};te.status="complete",L.result!==void 0&&(te.result=L.result),typeof L.duration=="number"&&(te.duration=L.duration),te.completedAt=ke((Ze=L.completedAt)!=null?Ze:L.timestamp);let ce=(_t=L.duration)!=null?_t:L.executionTime;if(typeof ce=="number")te.durationMs=ce;else{let $e=(Zt=te.startedAt)!=null?Zt:Date.now();te.durationMs=Math.max(0,((dr=te.completedAt)!=null?dr:Date.now())-$e)}B.toolCall=te,B.streaming=!1;let X=L.agentContext;(X||L.executionId)&&(B.agentMetadata=(Vt=B.agentMetadata)!=null?Vt:{executionId:(wt=X==null?void 0:X.executionId)!=null?wt:L.executionId,iteration:(Ur=X==null?void 0:X.iteration)!=null?Ur:L.iteration}),u(B);let He=ie(L);He&&T.byCall.delete(He)}else if(tt==="step_await"&&L.awaitReason==="local_tool_required"&&L.toolName){let z=typeof L.toolCallId=="string"&&L.toolCallId.length>0?L.toolCallId:void 0,B=(qr=z!=null?z:L.toolId)!=null?qr:`local-${l()}`,te=pe(B),ce=L.toolName,X=Bo(ce),He=(Fn=te.toolCall)!=null?Fn:{id:B,status:"pending"};He.name=ce,He.args=L.parameters,He.status=X?"running":"complete",He.chunks=(no=He.chunks)!=null?no:[],He.startedAt=(pn=He.startedAt)!=null?pn:ke((wo=L.startedAt)!=null?wo:L.timestamp),X?(He.completedAt=void 0,He.duration=void 0,He.durationMs=void 0):He.completedAt=(jt=He.completedAt)!=null?jt:He.startedAt,te.toolCall=He,te.streaming=!1,te.agentMetadata={...te.agentMetadata,executionId:(Tn=L.executionId)!=null?Tn:(Kr=te.agentMetadata)==null?void 0:Kr.executionId,awaitingLocalTool:!0,...z?{webMcpToolCallId:z}:{}},u(te)}else if(tt==="text_start"){if((Ao=L.toolContext)!=null&&Ao.toolId)continue;let z=L.partId;if(z!==void 0&&S.current!==null&&z!==S.current){let B=m;B&&(B.streaming=!1,u(B),We=B,m=null,M=!0)}z!==void 0&&(S.current=z)}else if(tt==="text_end"){if((oo=L.toolContext)!=null&&oo.toolId)continue;let z=m;z&&(z.streaming=!1,u(z),We=z,m=null,M=!0)}else if(tt==="step_chunk"||tt==="step_delta"){let z=L.stepType,B=L.executionType;if(z==="tool"||B==="context")continue;let te=L.toolContext;if(te!=null&&te.toolId){let $e=String((Gn=(So=L.id)!=null?So:te.stepId)!=null?Gn:`step-${l()}`),mt=L.partId!==void 0&&L.partId!==null?String(L.partId):"",lt=`${te.toolId}::${$e}`,zt=w.get(lt);if(mt!==""&&zt!==void 0&&zt!==""&&zt!==mt){let gt=h.get(W(te.toolId,$e,zt));gt&>.streaming!==!1&&(gt.streaming=!1,u(gt))}mt!==""&&w.set(lt,mt);let er=I(te.toolId,$e,mt,te.executionId),Jt=(yr=(kt=(Nn=(un=L.text)!=null?un:L.delta)!=null?Nn:L.content)!=null?kt:L.chunk)!=null?yr:"";Jt&&(er.content+=String(Jt),er.streaming=!0,u(er)),L.isComplete&&(er.streaming=!1,u(er));continue}let ce=L.partId;if(ce!==void 0&&S.current!==null&&ce!==S.current){let $e=m;$e&&($e.streaming=!1,u($e),We=$e,m=null,M=!0)}ce!==void 0&&(S.current=ce);let X=ce!==void 0&&(vr=St.get(ce))!=null?vr:we();ce!==void 0&&(X.partId||(X.partId=ce),St.set(ce,X));let He=(Mn=(ve=(To=(fn=L.text)!=null?fn:L.delta)!=null?To:L.content)!=null?ve:L.chunk)!=null?Mn:"";if(He){let $e=typeof L.seq=="number"?L.seq:void 0,mt=ce!=null?ce:X.id,lt=$e!==void 0?he(mt,$e,String(He)):((kn=de.get(X.id))!=null?kn:"")+He;X.rawContent=lt,ne.has(X.id)||ne.set(X.id,this.createStreamParser());let zt=ne.get(X.id),er=lt.trim().startsWith("{")||lt.trim().startsWith("[");if(er&&de.set(X.id,lt),zt.__isPlainTextParser===!0){X.content=$e!==void 0?lt:X.content+He,de.delete(X.id),ne.delete(X.id),X.rawContent=void 0,u(X);continue}let gt=zt.processChunk(lt);if(gt instanceof Promise)gt.then(Ft=>{var $r;let Ge=typeof Ft=="string"?Ft:($r=Ft==null?void 0:Ft.text)!=null?$r:null;if(Ge!==null&&Ge.trim()!=="")X.content=Ge,u(X);else if(!er&&!lt.trim().startsWith("<")){let Wr=m,tr=Wr&&Wr.id===X.id?Wr:X;tr.id===X.id&&(tr.content=$e!==void 0?lt:tr.content+He,de.delete(tr.id),ne.delete(tr.id),tr.rawContent=void 0,u(tr))}}).catch(()=>{X.content=$e!==void 0?lt:X.content+He,de.delete(X.id),ne.delete(X.id),X.rawContent=void 0,u(X)});else{let Ft=typeof gt=="string"?gt:(q=gt==null?void 0:gt.text)!=null?q:null;Ft!==null&&Ft.trim()!==""?(X.content=Ft,u(X)):!er&&!lt.trim().startsWith("<")&&(X.content=$e!==void 0?lt:X.content+He,de.delete(X.id),ne.delete(X.id),X.rawContent=void 0,u(X))}}if(L.isComplete){let $e=(ao=(Kn=L.result)==null?void 0:Kn.response)!=null?ao:X.content;if($e){let mt=de.get(X.id),lt=mt!=null?mt:le($e);X.rawContent=lt;let zt=ne.get(X.id),er=null,Jt=!1;if(zt&&(er=zt.getExtractedText(),er===null&&(er=la(lt)),er===null)){let gt=zt.processChunk(lt);gt instanceof Promise?(Jt=!0,gt.then(Ft=>{var $r;let Ge=typeof Ft=="string"?Ft:($r=Ft==null?void 0:Ft.text)!=null?$r:null;if(Ge!==null){let Wr=m;Wr&&Wr.id===X.id&&(Wr.content=Ge,Wr.streaming=!1,ne.delete(Wr.id),de.delete(Wr.id),u(Wr))}})):er=typeof gt=="string"?gt:(so=gt==null?void 0:gt.text)!=null?so:null}if(!Jt){er!==null&&er.trim()!==""?X.content=er:de.has(X.id)||(X.content=le($e));let gt=ne.get(X.id);if(gt){let Ft=(Xn=gt.close)==null?void 0:Xn.call(gt);Ft instanceof Promise&&Ft.catch(()=>{}),ne.delete(X.id)}de.delete(X.id),X.streaming=!1,u(X)}}}}else if(tt==="step_complete"){let z=L.stepType,B=L.executionType;if(z==="tool"||B==="context")continue;let te=L.toolContext;if(te!=null&&te.toolId){let $e=String((rs=(On=L.id)!=null?On:te.stepId)!=null?rs:"");if($e){let mt=R(te.toolId,$e);for(let[lt,zt]of h)lt.startsWith(mt)&&zt.streaming!==!1&&(zt.streaming=!1,u(zt));w.delete(`${te.toolId}::${$e}`)}continue}let ce=L.stopReason;if(M){if(m!==null){let lt=m;ce&&(lt.stopReason=ce),ne.delete(lt.id),de.delete(lt.id),lt.streaming!==!1&&(lt.streaming=!1,u(lt))}let $e=(mn=L.result)==null?void 0:mn.response,mt=We;mt&&(ce&&(mt.stopReason=ce),$e!=null?at(mt,$e):(ne.delete(mt.id),de.delete(mt.id))),We=null;continue}let X=(gn=L.result)==null?void 0:gn.response,He=we();if(ce&&(He.stopReason=ce),X!=null){let $e=ne.get(He.id),mt=!1,lt=!1;if($e){let zt=$e.getExtractedText(),er=de.get(He.id),Jt=er!=null?er:le(X);if(He.rawContent=Jt,zt!==null&&zt.trim()!=="")He.content=zt,mt=!0;else{let gt=la(Jt);if(gt!==null)He.content=gt,mt=!0;else{let Ft=$e.processChunk(Jt);if(Ft instanceof Promise)lt=!0,Ft.then(Ge=>{var Wr;let $r=typeof Ge=="string"?Ge:(Wr=Ge==null?void 0:Ge.text)!=null?Wr:null;if($r!==null&&$r.trim()!==""){let tr=m;tr&&tr.id===He.id&&(tr.content=$r,tr.streaming=!1,ne.delete(tr.id),de.delete(tr.id),u(tr))}else{let tr=$e.getExtractedText(),qn=m;qn&&qn.id===He.id&&(tr!==null&&tr.trim()!==""?qn.content=tr:de.has(qn.id)||(qn.content=le(X)),qn.streaming=!1,ne.delete(qn.id),de.delete(qn.id),u(qn))}});else{let Ge=typeof Ft=="string"?Ft:(_n=Ft==null?void 0:Ft.text)!=null?_n:null;if(Ge!==null&&Ge.trim()!=="")He.content=Ge,mt=!0;else{let $r=$e.getExtractedText();$r!==null&&$r.trim()!==""&&(He.content=$r,mt=!0)}}}}}if(!lt){if(!He.rawContent){let zt=de.get(He.id);He.rawContent=zt!=null?zt:le(X)}if(!mt&&!de.has(He.id)&&(He.content=le(X)),$e){let zt=(Un=$e.close)==null?void 0:Un.call($e);zt instanceof Promise&&zt.catch(()=>{})}ne.delete(He.id),de.delete(He.id),He.streaming=!1,u(He)}}else ne.delete(He.id),de.delete(He.id),He.streaming=!1,u(He)}else if(tt==="flow_complete"){let z=(Vo=L.result)==null?void 0:Vo.response;if(M){if(m!==null){let B=m;ne.delete(B.id),de.delete(B.id),B.streaming!==!1&&(B.streaming=!1,u(B))}}else if(z!=null){let B=we(),te=de.get(B.id),ce=te!=null?te:le(z);B.rawContent=ce;let X=le(z),He=ne.get(B.id);if(He){let lt=la(ce);if(lt!==null)X=lt;else{let zt=He.processChunk(ce);zt instanceof Promise&&zt.then(Jt=>{var Ft;let gt=typeof Jt=="string"?Jt:(Ft=Jt==null?void 0:Jt.text)!=null?Ft:null;gt!==null&&(B.content=gt,B.streaming=!1,u(B))});let er=He.getExtractedText();er!==null&&(X=er)}}ne.delete(B.id),de.delete(B.id);let $e=X!==B.content,mt=B.streaming!==!1;$e&&(B.content=X),B.streaming=!1,($e||mt)&&u(B)}else if(m!==null){let B=m;ne.delete(B.id),de.delete(B.id),B.streaming!==!1&&(B.streaming=!1,u(B))}t({type:"status",status:"idle"})}else if(tt==="agent_start")ee={executionId:L.executionId,agentId:(io=L.agentId)!=null?io:"virtual",agentName:(zr=L.agentName)!=null?zr:"",status:"running",currentIteration:0,maxTurns:(Qn=L.maxTurns)!=null?Qn:1,startedAt:ke(L.startedAt)};else if(tt==="agent_iteration_start"){if(ee&&(ee.currentIteration=L.iteration),Fr==="separate"&&L.iteration>1){let z=m;z&&(z.streaming=!1,u(z),je.set(L.iteration-1,z),m=null)}}else if(tt==="agent_turn_start")v=null;else if(tt==="agent_turn_delta"){if(L.contentType==="text"){let z=we();z.content+=(wa=L.delta)!=null?wa:"",z.agentMetadata={executionId:L.executionId,iteration:L.iteration,turnId:L.turnId,agentName:ee==null?void 0:ee.agentName},v=z,u(z)}else if(L.contentType==="thinking"){let z=(jo=L.turnId)!=null?jo:`agent-think-${L.iteration}`,B=qe(z);B.reasoning=(Aa=B.reasoning)!=null?Aa:{id:z,status:"streaming",chunks:[]},B.reasoning.chunks.push((si=L.delta)!=null?si:""),B.agentMetadata={executionId:L.executionId,iteration:L.iteration,turnId:L.turnId},u(B)}else if(L.contentType==="tool_input"){let z=(Sa=L.toolCallId)!=null?Sa:T.lastId;if(z){let B=k.get(z);B!=null&&B.toolCall&&(B.toolCall.chunks=(ii=B.toolCall.chunks)!=null?ii:[],B.toolCall.chunks.push((Ta=L.delta)!=null?Ta:""),u(B))}}}else if(tt==="agent_turn_complete"){let z=L.turnId;if(z){let ce=E.get(z);if(ce!=null&&ce.reasoning){ce.reasoning.status="complete",ce.reasoning.completedAt=ke(L.completedAt);let X=(Rt=ce.reasoning.startedAt)!=null?Rt:Date.now();ce.reasoning.durationMs=Math.max(0,((ns=ce.reasoning.completedAt)!=null?ns:Date.now())-X),ce.streaming=!1,u(ce)}}let B=L.stopReason,te=m!=null?m:v;if(B&&te!==null){let ce=L.turnId;(!ce||((En=te.agentMetadata)==null?void 0:En.turnId)===ce)&&(te.stopReason=B,u(te))}}else if(tt==="agent_tool_start"){m&&(m.streaming=!1,u(m),m=null);let z=(an=L.toolCallId)!=null?an:`agent-tool-${l()}`;Ie(ie(L),z);let B=pe(z),te=(li=B.toolCall)!=null?li:{id:z,status:"pending",name:void 0,args:void 0,chunks:void 0,result:void 0,duration:void 0,startedAt:void 0,completedAt:void 0,durationMs:void 0};te.name=(Ma=(di=L.toolName)!=null?di:L.name)!=null?Ma:te.name,te.status="running",L.parameters!==void 0&&(te.args=L.parameters),te.startedAt=ke((lo=L.startedAt)!=null?lo:L.timestamp),B.toolCall=te,B.streaming=!0,B.agentMetadata={executionId:L.executionId,iteration:L.iteration},u(B)}else if(tt==="agent_tool_delta"){let z=(os=L.toolCallId)!=null?os:T.lastId;if(z){let B=(Mo=k.get(z))!=null?Mo:pe(z);B.toolCall&&(B.toolCall.chunks=(as=B.toolCall.chunks)!=null?as:[],B.toolCall.chunks.push((ss=L.delta)!=null?ss:""),B.toolCall.status="running",B.streaming=!0,u(B))}}else if(tt==="agent_tool_complete"){let z=(is=L.toolCallId)!=null?is:T.lastId;if(z){let B=(ls=k.get(z))!=null?ls:pe(z);if(B.toolCall){B.toolCall.status="complete",L.result!==void 0&&(B.toolCall.result=L.result),typeof L.executionTime=="number"&&(B.toolCall.durationMs=L.executionTime),B.toolCall.completedAt=ke((sn=L.completedAt)!=null?sn:L.timestamp),B.streaming=!1,u(B);let te=ie(L);te&&T.byCall.delete(te)}}}else if(tt==="agent_media"){let z=Array.isArray(L.media)?L.media:[],B=[];for(let te of z){if(!te||typeof te!="object")continue;let ce=te,X=typeof ce.type=="string"?ce.type:void 0,He=typeof ce.mediaType=="string"?ce.mediaType.toLowerCase():"",$e=null,mt="";if(X==="media"){let lt=typeof ce.data=="string"?ce.data:void 0;if(!lt)continue;mt=He.length>0?He:"application/octet-stream",$e=`data:${mt};base64,${lt}`}else if(X==="image-url"){let lt=typeof ce.url=="string"?ce.url:void 0;if(!lt)continue;mt=He,$e=lt}else if(X==="file-url"){let lt=typeof ce.url=="string"?ce.url:void 0;if(!lt)continue;mt=He,$e=lt}else continue;if($e)if(X==="image-url"||mt.startsWith("image/"))B.push({type:"image",image:$e,...mt?{mimeType:mt}:{}});else if(mt.startsWith("audio/"))B.push({type:"audio",audio:$e,mimeType:mt});else if(mt.startsWith("video/"))B.push({type:"video",video:$e,mimeType:mt});else{let lt=mt||"application/octet-stream";B.push({type:"file",data:$e,mimeType:lt,filename:b0(lt)})}}if(B.length>0){let te=l(),ce=L.toolCallId,He={id:`agent-media-${typeof ce=="string"&&ce.length>0?`${ce}-${te}`:String(te)}`,role:"assistant",content:"",contentParts:B,createdAt:new Date().toISOString(),streaming:!1,sequence:te,agentMetadata:{executionId:L.executionId,iteration:L.iteration}};u(He);let $e=m;$e&&($e.streaming=!1,u($e)),m=null,x.current=null}}else if(tt!=="agent_iteration_complete"){if(tt==="agent_reflection"||tt==="agent_reflect"){let z=`agent-reflection-${L.executionId}-${L.iteration}`,B={id:z,role:"assistant",content:(ka=L.reflection)!=null?ka:"",createdAt:new Date().toISOString(),streaming:!1,variant:"reasoning",sequence:l(),reasoning:{id:z,status:"complete",chunks:[(Jn=L.reflection)!=null?Jn:""]},agentMetadata:{executionId:L.executionId,iteration:L.iteration}};u(B)}else if(tt==="agent_complete"){ee&&(ee.status=L.success?"complete":"error",ee.completedAt=ke(L.completedAt),ee.stopReason=L.stopReason);let z=m;z&&(z.streaming=!1,u(z)),t({type:"status",status:"idle"})}else if(tt==="agent_error"){let z=typeof L.error=="string"?L.error:(ds=(Yn=L.error)==null?void 0:Yn.message)!=null?ds:"Agent execution error";L.recoverable?typeof console!="undefined"&&console.warn("[AgentWidget] Recoverable agent error:",z):t({type:"error",error:new Error(z)})}else if(tt!=="agent_ping"){if(tt==="agent_approval_start"){let z=(ci=L.approvalId)!=null?ci:`approval-${l()}`,B={id:`approval-${z}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!1,variant:"approval",sequence:l(),approval:{id:z,status:"pending",agentId:(cs=ee==null?void 0:ee.agentId)!=null?cs:"virtual",executionId:(Go=(ps=L.executionId)!=null?ps:ee==null?void 0:ee.executionId)!=null?Go:"",toolName:(pi=L.toolName)!=null?pi:"",toolType:L.toolType,description:(fi=L.description)!=null?fi:`Execute ${(ui=L.toolName)!=null?ui:"tool"}`,...typeof L.reason=="string"&&L.reason?{reason:L.reason}:{},parameters:L.parameters}};u(B)}else if(tt==="step_await"&&L.awaitReason==="approval_required"){let z=(mi=L.approvalId)!=null?mi:`approval-${l()}`,B={id:`approval-${z}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!1,variant:"approval",sequence:l(),approval:{id:z,status:"pending",agentId:(Zl=ee==null?void 0:ee.agentId)!=null?Zl:"virtual",executionId:(ko=(Ko=L.executionId)!=null?Ko:ee==null?void 0:ee.executionId)!=null?ko:"",toolName:(gi=L.toolName)!=null?gi:"",toolType:L.toolType,description:(Eo=L.description)!=null?Eo:`Execute ${(us=L.toolName)!=null?us:"tool"}`,...typeof L.reason=="string"&&L.reason?{reason:L.reason}:{},parameters:L.parameters}};u(B)}else if(tt==="agent_approval_complete"){let z=L.approvalId;if(z){let te={id:`approval-${z}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!1,variant:"approval",sequence:l(),approval:{id:z,status:(hi=L.decision)!=null?hi:"approved",agentId:(fs=ee==null?void 0:ee.agentId)!=null?fs:"virtual",executionId:(ms=(Lo=L.executionId)!=null?Lo:ee==null?void 0:ee.executionId)!=null?ms:"",toolName:(xi=L.toolName)!=null?xi:"",description:(co=L.description)!=null?co:"",resolvedAt:Date.now()}};u(te)}}else if(tt==="artifact_start"||tt==="artifact_delta"||tt==="artifact_update"||tt==="artifact_complete"){if(tt==="artifact_start"){let z=L.artifactType,B=String(L.id),te=typeof L.title=="string"?L.title:void 0;if(t({type:"artifact_start",id:B,artifactType:z,title:te,component:typeof L.component=="string"?L.component:void 0}),ge.set(B,{markdown:"",title:te}),!Q.has(B)){Q.add(B);let ce={id:`artifact-ref-${B}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,sequence:l(),rawContent:JSON.stringify({component:"PersonaArtifactCard",props:{artifactId:B,title:te,artifactType:z,status:"streaming"}})};re.set(B,ce),u(ce)}}else if(tt==="artifact_delta"){let z=String(L.id),B=typeof L.delta=="string"?L.delta:String((bi=L.delta)!=null?bi:"");t({type:"artifact_delta",id:z,artDelta:B});let te=ge.get(z);te&&(te.markdown+=B)}else if(tt==="artifact_update"){let z=L.props&&typeof L.props=="object"&&!Array.isArray(L.props)?L.props:{};t({type:"artifact_update",id:String(L.id),props:z,component:typeof L.component=="string"?L.component:void 0})}else if(tt==="artifact_complete"){let z=String(L.id);t({type:"artifact_complete",id:z});let B=re.get(z);if(B){B.streaming=!1;try{let te=JSON.parse((Po=B.rawContent)!=null?Po:"{}");if(te.props){te.props.status="complete";let ce=ge.get(z);ce!=null&&ce.markdown&&(te.props.markdown=ce.markdown)}B.rawContent=JSON.stringify(te)}catch{}ge.delete(z),u(B),re.delete(z)}}}else if(tt==="transcript_insert"){let z=L.message;if(!z||typeof z!="object")continue;let B=String((Gt=z.id)!=null?Gt:`msg-${l()}`),te=z.role,X={id:B,role:te==="user"?"user":te==="system"?"system":"assistant",content:typeof z.content=="string"?z.content:"",rawContent:typeof z.rawContent=="string"?z.rawContent:void 0,createdAt:typeof z.createdAt=="string"?z.createdAt:new Date().toISOString(),streaming:z.streaming===!0,...typeof z.variant=="string"?{variant:z.variant}:{},sequence:l()};if(u(X),X.rawContent)try{let He=JSON.parse(X.rawContent),$e=(Ea=He==null?void 0:He.props)==null?void 0:Ea.artifactId;typeof $e=="string"&&Q.add($e)}catch{}m=null,x.current=null,ne.delete(B),de.delete(B)}else if(tt==="error"||tt==="step_error"||tt==="dispatch_error"||tt==="flow_error"){let z=null;if(L.error instanceof Error)z=L.error;else if(tt==="dispatch_error"){let B=(La=L.message)!=null?La:L.error;B!=null&&B!==""&&(z=new Error(String(B)))}else if(tt==="step_error"||tt==="flow_error"){let B=L.error;typeof B=="string"&&B!==""?z=new Error(B):B!=null&&typeof B=="object"&&"message"in B&&(z=new Error(String((gs=B.message)!=null?gs:B)))}else tt==="error"&&L.error!=null&&L.error!==""&&(z=new Error(String(L.error)));if(z){t({type:"error",error:z});let B=m;B&&B.streaming&&(B.streaming=!1,u(B)),t({type:"status",status:"idle"})}}}}}Pe.length=0};;){let{done:F,value:fe}=await o.read();if(F)break;s+=a.decode(fe,{stream:!0});let Re=s.split(`
|
|
54
|
+
${r.description}`:"");return window.confirm(t)},N0=r=>{if(r==null)return"";try{let e=JSON.stringify(r,null,2);return e.length>500?e.slice(0,500)+"\u2026":e}catch{return String(r)}},F0=r=>{if(r===void 0)return"{}";try{let e=JSON.stringify(r);return e===void 0?"{}":e}catch{return"{}"}},U0=r=>{if(r===void 0)return"";try{return JSON.stringify(r)}catch{return String(r)}};var Un=Bi(ji(),1);var C=(r,e)=>{let t=document.createElement(r);return e&&(t.className=e),t},un=(r,e,t)=>{let o=r.createElement(e);return t&&(o.className=t),o};var $s="ask_user_question",zs=8,Ka="data-persona-ask-sheet-for",j0="Other",G0="Other\u2026",_h="Type your own answer here",Nh="Send",K0="Next",X0="Back",Q0="Submit all",Y0="Skip",J0=3,Bd="data-ask-current-index",Dd="data-ask-question-count",Fh="data-ask-answers",Od="data-ask-grouped",Uh="data-ask-layout",Z0=r=>r.layout==="pills"?"pills":"rows",ev=r=>r.getAttribute(Uh)==="pills"?"pills":"rows",Oh=!1,qh=r=>r.replace(/["\\]/g,"\\$&"),wn=r=>r.variant==="tool"&&!!r.toolCall&&r.toolCall.name===$s,Gi=r=>{var e,t;return(t=(e=r==null?void 0:r.features)==null?void 0:e.askUserQuestion)!=null?t:{}},An=r=>{let e=r.toolCall;if(!e)return{payload:null,complete:!1};let t=e.status==="complete";if(e.args&&typeof e.args=="object")return{payload:e.args,complete:t};let o=e.chunks;if(!o||o.length===0)return{payload:null,complete:t};try{let n=o.join(""),a=(0,Un.parse)(n,Un.STR|Un.OBJ|Un.ARR);if(a&&typeof a=="object")return{payload:a,complete:t}}catch{}return{payload:null,complete:t}},Vs=r=>{let e=Array.isArray(r==null?void 0:r.questions)?r.questions:[];return e.length>zs&&!Oh&&(Oh=!0,typeof console!="undefined"&&console.warn(`[AgentWidget] ask_user_question received ${e.length} questions; truncating to ${zs}.`)),e.slice(0,zs)},tv=r=>{var e;return(e=Vs(r)[0])!=null?e:null},rv=(r,e)=>{var t;return(t=Vs(r)[e])!=null?t:null},zh=(r,e)=>{let t=e.styles;t&&(t.sheetBackground&&r.style.setProperty("--persona-ask-sheet-bg",t.sheetBackground),t.sheetBorder&&r.style.setProperty("--persona-ask-sheet-border",t.sheetBorder),t.sheetShadow&&r.style.setProperty("--persona-ask-sheet-shadow",t.sheetShadow),t.pillBackground&&r.style.setProperty("--persona-ask-pill-bg",t.pillBackground),t.pillBackgroundSelected&&r.style.setProperty("--persona-ask-pill-bg-selected",t.pillBackgroundSelected),t.pillTextColor&&r.style.setProperty("--persona-ask-pill-fg",t.pillTextColor),t.pillTextColorSelected&&r.style.setProperty("--persona-ask-pill-fg-selected",t.pillTextColorSelected),t.pillBorderRadius&&r.style.setProperty("--persona-ask-pill-radius",t.pillBorderRadius),t.customInputBackground&&r.style.setProperty("--persona-ask-input-bg",t.customInputBackground))},$h=(r,e,t)=>{if(r!=="rows")return null;let o=C("span","persona-ask-row-affordance");if(o.setAttribute("aria-hidden","true"),e){let n=C("span","persona-ask-row-check");o.appendChild(n)}else{let n=C("span","persona-ask-row-badge");n.textContent=String(t+1),o.appendChild(n)}return o},ov=(r,e,t,o)=>{let a=C("button",t==="rows"?"persona-ask-pill persona-ask-row persona-pointer-events-auto":"persona-ask-pill persona-pointer-events-auto");if(a.type="button",a.setAttribute("role",o?"checkbox":"button"),a.setAttribute("aria-pressed","false"),a.setAttribute("data-ask-user-action","pick"),a.setAttribute("data-option-index",String(e)),a.setAttribute("data-option-label",r.label),t==="rows"){let s=C("span","persona-ask-row-content"),i=C("span","persona-ask-row-label");if(i.textContent=r.label,s.appendChild(i),r.description){let l=C("span","persona-ask-row-description");l.textContent=r.description,s.appendChild(l)}a.appendChild(s);let d=$h(t,o,e);d&&a.appendChild(d)}else a.textContent=r.label,r.description&&(a.title=r.description);return a},nv=r=>{let t=C("span",r==="rows"?"persona-ask-pill persona-ask-row persona-ask-pill-skeleton persona-pointer-events-none":"persona-ask-pill persona-ask-pill-skeleton persona-pointer-events-none");return t.setAttribute("aria-hidden","true"),t},av=(r,e,t,o)=>{var u,f,p;let a=C("div",o==="rows"?"persona-ask-pills persona-ask-pills--rows persona-flex persona-flex-col persona-gap-2":"persona-ask-pills persona-flex persona-flex-wrap persona-gap-2");a.setAttribute("role","group"),a.setAttribute("data-ask-pill-list","true");let s=!!(r!=null&&r.multiSelect),d=(Array.isArray(r==null?void 0:r.options)?r.options:[]).filter(m=>m&&typeof m.label=="string"&&m.label.length>0);if(d.length===0&&!t){for(let m=0;m<J0;m++)a.appendChild(nv(o));return a}if(d.forEach((m,y)=>{a.appendChild(ov(m,y,o,s))}),(r==null?void 0:r.allowFreeText)!==!1){let m=o==="rows"?j0:G0;if(o==="rows"){let y=C("div","persona-ask-pill persona-ask-row persona-ask-row--other persona-ask-pill-custom persona-pointer-events-auto");y.setAttribute("data-ask-user-action","focus-free-text"),y.setAttribute("data-option-index",String(d.length)),y.setAttribute("data-ask-other-row","true");let h=C("span","persona-ask-row-content"),T=document.createElement("input");T.type="text",T.className="persona-ask-row-input persona-flex-1 persona-pointer-events-auto",T.placeholder=(u=e.freeTextPlaceholder)!=null?u:_h,T.setAttribute("data-ask-free-text-input","true"),T.setAttribute("aria-label",(f=e.freeTextLabel)!=null?f:m),h.appendChild(T),y.appendChild(h);let M=$h(o,s,d.length);M&&y.appendChild(M),a.appendChild(y)}else{let y=C("button","persona-ask-pill persona-ask-pill-custom persona-pointer-events-auto");y.type="button",y.setAttribute("data-ask-user-action","open-free-text"),y.textContent=(p=e.freeTextLabel)!=null?p:m,a.appendChild(y)}}return a},Vh=(r,e)=>{var a,s;let o=C("div",e==="rows"?"persona-ask-free-text persona-ask-free-text--rows persona-flex persona-gap-2 persona-mt-2":"persona-ask-free-text persona-hidden persona-flex persona-gap-2 persona-mt-2");o.setAttribute("data-ask-free-text-row","true");let n=document.createElement("input");if(n.type="text",n.className="persona-ask-free-text-input persona-flex-1 persona-pointer-events-auto",n.placeholder=(a=r.freeTextPlaceholder)!=null?a:_h,n.setAttribute("data-ask-free-text-input","true"),o.appendChild(n),e!=="rows"){let i=C("button","persona-ask-free-text-submit persona-pointer-events-auto");i.type="button",i.textContent=(s=r.submitLabel)!=null?s:Nh,i.setAttribute("data-ask-user-action","submit-free-text"),o.appendChild(i)}return o},sv=r=>{var o;let e=C("div","persona-ask-multi-actions persona-flex persona-justify-end persona-mt-2");e.setAttribute("data-ask-multi-actions","true");let t=C("button","persona-ask-multi-submit persona-pointer-events-auto");return t.type="button",t.textContent=(o=r.submitLabel)!=null?o:Nh,t.setAttribute("data-ask-user-action","submit-multi"),t.disabled=!0,e.appendChild(t),e},iv=(r,e,t)=>{var l,u,f,p;let o=C("div","persona-ask-nav persona-flex persona-justify-between persona-items-center persona-gap-2 persona-mt-2");o.setAttribute("data-ask-nav-row","true");let n=C("button","persona-ask-nav-back persona-pointer-events-auto");n.type="button",n.textContent=(l=t.backLabel)!=null?l:X0,n.setAttribute("data-ask-user-action","back"),n.disabled=r===0,o.appendChild(n);let a=C("div","persona-ask-nav-right persona-flex persona-items-center persona-gap-2"),s=C("button","persona-ask-nav-skip persona-pointer-events-auto");s.type="button",s.textContent=(u=t.skipLabel)!=null?u:Y0,s.setAttribute("data-ask-user-action","skip"),a.appendChild(s);let i=C("button","persona-ask-nav-next persona-pointer-events-auto");i.type="button";let d=r===e-1;return i.textContent=d?(f=t.submitAllLabel)!=null?f:Q0:(p=t.nextLabel)!=null?p:K0,i.setAttribute("data-ask-user-action",d?"submit-all":"next"),i.disabled=!0,a.appendChild(i),o.appendChild(a),o},ha=r=>{let e=r.getAttribute(Fh);if(!e)return{};try{let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}},jh=(r,e)=>{r.setAttribute(Fh,JSON.stringify(e))},jo=r=>{var t;let e=Number((t=r.getAttribute(Bd))!=null?t:"0");return Number.isFinite(e)?Math.max(0,Math.floor(e)):0},lv=(r,e)=>{r.setAttribute(Bd,String(Math.max(0,Math.floor(e))))},Xa=r=>{var t;let e=Number((t=r.getAttribute(Dd))!=null?t:"1");return Number.isFinite(e)?Math.max(1,Math.floor(e)):1},qn=r=>r.getAttribute(Od)==="true",dv=(r,e)=>{var n;let t=(n=r.agentMetadata)==null?void 0:n.askUserQuestionAnswers;if(!t||typeof t!="object")return{};let o={};return e.forEach((a,s)=>{let i=typeof(a==null?void 0:a.question)=="string"?a.question:"";if(i&&Object.prototype.hasOwnProperty.call(t,i)){let d=t[i];(typeof d=="string"||Array.isArray(d))&&(o[s]=d)}}),o},cv=(r,e)=>{var o;let t=(o=r.agentMetadata)==null?void 0:o.askUserQuestionIndex;return typeof t!="number"||!Number.isFinite(t)?0:Math.max(0,Math.min(e-1,Math.floor(t)))},Ki=(r,e)=>{let{payload:t}=An(e),o=Vs(t),n=ha(r),a={},s=new Set;return o.forEach((i,d)=>{let l=typeof(i==null?void 0:i.question)=="string"?i.question:"";l&&(s.has(l)&&typeof console!="undefined"&&console.warn(`[AgentWidget] ask_user_question has duplicate question text "${l}"; later answer wins.`),s.add(l),Object.prototype.hasOwnProperty.call(n,d)&&(a[l]=n[d]))}),a},Gh=r=>{let e=ha(r),t=jo(r),o=e[t],n=new Set;typeof o=="string"?n.add(o):Array.isArray(o)&&o.forEach(d=>n.add(d));let a=r.querySelectorAll('[data-ask-user-action="pick"][data-option-label]');a.forEach(d=>{var f;let l=(f=d.getAttribute("data-option-label"))!=null?f:"",u=n.has(l);d.setAttribute("aria-pressed",u?"true":"false"),d.classList.toggle("persona-ask-pill-selected",u)});let s=new Set(Array.from(a).map(d=>{var l;return(l=d.getAttribute("data-option-label"))!=null?l:""})),i=r.querySelector('[data-ask-free-text-input="true"]');if(i)if(typeof o=="string"&&o.length>0&&!s.has(o)){i.value=o;let d=i.closest('[data-ask-free-text-row="true"]');d==null||d.classList.remove("persona-hidden")}else i.value=""},Kh=r=>{if(!qn(r))return;let e=ha(r),t=jo(r),o=e[t],n=typeof o=="string"&&o.length>0||Array.isArray(o)&&o.length>0,a=r.querySelector('[data-ask-user-action="next"], [data-ask-user-action="submit-all"]');a&&(a.disabled=!n);let s=r.querySelector('[data-ask-user-action="submit-multi"]');if(s){let i=Array.from(r.querySelectorAll('[aria-pressed="true"][data-option-label]'));s.disabled=i.length===0}},_d=(r,e,t)=>{let o=Gi(t),n=ev(r),{payload:a,complete:s}=An(e),i=qn(r),d=jo(r),l=Xa(r),u=i?rv(a,d):tv(a),f=!!(u!=null&&u.multiSelect),p=r.querySelector('[data-ask-step-inline="true"]');p&&(p.textContent=i?`${d+1}/${l}`:"");let m=r.querySelector('[data-ask-stepper="true"]');m&&m.remove();let y=r.querySelector('[data-ask-question="true"]');if(y){let k=typeof(u==null?void 0:u.question)=="string"?u.question:"";y.textContent=k,y.classList.toggle("persona-ask-question-skeleton",!k&&!s)}let h=r.querySelector('[data-ask-pill-list="true"]');if(h){let k=av(u,o,s,n);h.replaceWith(k)}if(n!=="rows"){let k=r.querySelector('[data-ask-free-text-row="true"]');k&&k.replaceWith(Vh(o,n))}let T=r.querySelector('[data-ask-multi-actions="true"]');!i&&f&&!T?r.appendChild(sv(o)):(!f||i)&&T&&T.remove(),r.setAttribute("data-multi-select",f?"true":"false");let M=r.querySelector('[data-ask-nav-row="true"]');if(i){let k=iv(d,l,o);M?M.replaceWith(k):r.appendChild(k)}else M&&M.remove();Gh(r),Kh(r)},pv=(r,e,t)=>{let o=Gi(e),n=Z0(o),a=r.toolCall.id,s=Vs(t),i=Math.max(1,s.length),d=i>1,l=dv(r,s),u=d?cv(r,i):0,f=C("div",["persona-ask-sheet",`persona-ask-sheet--${n}`,"persona-pointer-events-auto","persona-ask-sheet-enter"].join(" "));f.setAttribute(Ka,a),f.setAttribute("data-tool-call-id",a),f.setAttribute("data-message-id",r.id),f.setAttribute(Dd,String(i)),f.setAttribute(Bd,String(u)),f.setAttribute(Od,d?"true":"false"),f.setAttribute(Uh,n),jh(f,l),f.setAttribute("role","group"),f.setAttribute("aria-label","Suggested answers"),o.slideInMs!==void 0&&f.style.setProperty("--persona-ask-sheet-duration",`${o.slideInMs}ms`),zh(f,o);let p=C("div","persona-ask-sheet-header persona-flex persona-items-center persona-gap-3"),m=C("div","persona-ask-sheet-question persona-flex-1");m.setAttribute("data-ask-question","true"),m.textContent="",p.appendChild(m);let y=C("span","persona-ask-sheet-step-inline");y.setAttribute("data-ask-step-inline","true"),y.textContent="",p.appendChild(y),f.appendChild(p);let T=C("div",n==="rows"?"persona-ask-pills persona-ask-pills--rows persona-flex persona-flex-col persona-gap-2":"persona-ask-pills persona-flex persona-flex-wrap persona-gap-2");return T.setAttribute("data-ask-pill-list","true"),T.setAttribute("role","group"),f.appendChild(T),n!=="rows"&&f.appendChild(Vh(o,n)),_d(f,r,e),requestAnimationFrame(()=>{requestAnimationFrame(()=>f.classList.remove("persona-ask-sheet-enter"))}),f},uv=(r,e,t)=>{let{payload:o}=An(e),n=Math.max(1,Vs(o).length);n>Xa(r)&&(r.setAttribute(Dd,String(n)),n>1&&!qn(r)&&r.setAttribute(Od,"true")),_d(r,e,t)},Xh=(r,e)=>{let t=C("div","persona-ask-stub persona-inline-flex persona-items-center persona-gap-2");t.id=`bubble-${r.id}`,t.setAttribute("data-message-id",r.id),t.setAttribute("data-bubble-type","ask-user-question");let o=Gi(e);zh(t,o);let n=C("span","persona-ask-stub-label"),{complete:a}=An(r);return n.textContent=a?"Awaiting your response\u2026":"Preparing options\u2026",t.appendChild(n),t},Qa=(r,e,t)=>{if(!t||!wn(r)||Gi(e).enabled===!1)return;let n=r.toolCall.id;t.querySelectorAll(`[${Ka}]`).forEach(l=>{l.getAttribute(Ka)!==n&&l.remove()});let s=t.querySelector(`[${Ka}="${qh(n)}"]`);if(s){uv(s,r,e);return}let{payload:i}=An(r),d=pv(r,e,i);t.appendChild(d)},zn=(r,e)=>{if(!r)return;let t=e?`[${Ka}="${qh(e)}"]`:`[${Ka}]`;r.querySelectorAll(t).forEach(n=>{n.classList.add("persona-ask-sheet-leave");let a=Number.parseInt(getComputedStyle(n).getPropertyValue("--persona-ask-sheet-duration")||"180",10);setTimeout(()=>n.remove(),Number.isFinite(a)?a:180)})},Nd=r=>Array.from(r.querySelectorAll('[aria-pressed="true"][data-option-label]')).map(e=>e.getAttribute("data-option-label")).filter(e=>typeof e=="string"&&e.length>0),$n=(r,e)=>{let t=ha(r),o=jo(r);typeof e=="string"&&e.length===0||Array.isArray(e)&&e.length===0?delete t[o]:t[o]=e,jh(r,t),Gh(r),Kh(r)},Xi=(r,e,t,o)=>{let n=Xa(r),a=Math.max(0,Math.min(n-1,o));lv(r,a),_d(r,e,t)};var en="suggest_replies";var Fd={type:"object",properties:{suggestions:{type:"array",minItems:1,maxItems:4,description:"1-4 short, distinct follow-up replies, phrased in the user's voice.",items:{type:"string",minLength:1,maxLength:60}}},required:["suggestions"],additionalProperties:!1},Qi={name:en,description:`Offer the user tappable quick-reply suggestions for their next message. Call at most once per turn, as the LAST action after your reply text is complete. Each suggestion is sent verbatim as the user's next message, so phrase suggestions in the user's voice (e.g. "Tell me more about pricing"). Keep them short and distinct. The result only confirms the suggestions were shown \u2014 do not add further commentary after calling this tool; end your turn.`,parametersSchema:Fd,origin:"sdk",annotations:{readOnlyHint:!0}},Ud=()=>({content:[{type:"text",text:"Suggestions shown to the user."}]}),js=r=>{var e;return r.variant==="tool"&&((e=r.toolCall)==null?void 0:e.name)===en},qd=r=>{let e=r;if(typeof e=="string")try{e=JSON.parse(e)}catch{return[]}let t=e==null?void 0:e.suggestions;if(!Array.isArray(t))return[];let o=t.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0);return o.length>4?(console.warn(`[persona] suggest_replies: ${o.length} suggestions exceeds the cap of 4; extra suggestions dropped.`),o.slice(0,4)):o},Yi=r=>{var e;for(let t=r.length-1;t>=0;t--){let o=r[t];if(o.role==="user")return null;if(!js(o))continue;let n=qd((e=o.toolCall)==null?void 0:e.args);return n.length>0?n:null}return null},Qh=r=>{var t;let e=(t=r==null?void 0:r.features)==null?void 0:t.suggestReplies;return(e==null?void 0:e.expose)===!0&&e.enabled!==!1};var zd={type:"object",properties:{questions:{type:"array",minItems:1,maxItems:zs,description:"Questions to ask the user. Prefer a single question.",items:{type:"object",properties:{question:{type:"string",description:"The complete question, ending with a question mark."},header:{type:"string",maxLength:12,description:'Short topic label, e.g. "Auth method".'},options:{type:"array",minItems:2,maxItems:4,description:'2-4 distinct choices. Do NOT add an "Other" option \u2014 free text is automatic.',items:{type:"object",properties:{label:{type:"string",description:"Concise choice text (1-5 words)."},description:{type:"string",description:"What the option means or implies."}},required:["label"],additionalProperties:!1}},multiSelect:{type:"boolean",description:"Allow selecting multiple options. Default false."},allowFreeText:{type:"boolean",description:"Show a free-text input. Default true."}},required:["question","options"],additionalProperties:!1}}},required:["questions"],additionalProperties:!1},$d={name:$s,description:"Ask the user multiple-choice questions and wait for their answers. Use only when blocked on a decision that is the user's to make \u2014 a preference, a choice between valid approaches, or information you cannot infer. Each question offers 2-4 options plus an automatic free-text input. The result maps each question to its answer (an array when multiSelect); a question absent from the result was skipped.",parametersSchema:zd,origin:"sdk",annotations:{readOnlyHint:!0}},Gs=r=>{var o;let e=[],t=(o=r==null?void 0:r.features)==null?void 0:o.askUserQuestion;return(t==null?void 0:t.expose)===!0&&t.enabled!==!1&&e.push($d),Qh(r)&&e.push(Qi),e};var Sn=Bi(ji(),1),Ji=r=>r.replace(/\\n/g,`
|
|
55
|
+
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\"),Ya=r=>{if(r===null)return"null";if(r===void 0)return"";if(typeof r=="string")return r;if(typeof r=="number"||typeof r=="boolean")return String(r);try{return JSON.stringify(r,null,2)}catch{return String(r)}},fv=r=>{var s,i;let e=(s=r.completedAt)!=null?s:Date.now(),t=(i=r.startedAt)!=null?i:e,n=(r.durationMs!==void 0?r.durationMs:Math.max(0,e-t))/1e3;return n<.1?"Thought for <0.1 seconds":`Thought for ${n>=10?Math.round(n).toString():n.toFixed(1).replace(/\.0$/,"")} seconds`},Yh=r=>r.status==="complete"?fv(r):r.status==="pending"?"Waiting":"",mv=r=>{var n,a,s;let t=(typeof r.duration=="number"?r.duration:typeof r.durationMs=="number"?r.durationMs:Math.max(0,((n=r.completedAt)!=null?n:Date.now())-((s=(a=r.startedAt)!=null?a:r.completedAt)!=null?s:Date.now())))/1e3;return t<.1?"Used tool for <0.1 seconds":`Used tool for ${t>=10?Math.round(t).toString():t.toFixed(1).replace(/\.0$/,"")} seconds`};var Jh=r=>r.status==="complete"?mv(r):"Using tool...",Zi=r=>{let e=r/1e3;return e<.1?"<0.1s":e>=10?`${Math.round(e)}s`:`${e.toFixed(1).replace(/\.0$/,"")}s`},Xs=r=>{var t,o,n;let e=typeof r.duration=="number"?r.duration:typeof r.durationMs=="number"?r.durationMs:Math.max(0,((t=r.completedAt)!=null?t:Date.now())-((n=(o=r.startedAt)!=null?o:r.completedAt)!=null?n:Date.now()));return Zi(e)},el=r=>{var t,o,n;let e=r.durationMs!==void 0?r.durationMs:Math.max(0,((t=r.completedAt)!=null?t:Date.now())-((n=(o=r.startedAt)!=null?o:r.completedAt)!=null?n:Date.now()));return Zi(e)},Vd=(r,e,t)=>{var a;if(!e)return t;let o=((a=r.name)==null?void 0:a.trim())||"tool",n=Xs(r);return e.replace(/\{toolName\}/g,o).replace(/\{duration\}/g,n)},tl=(r,e)=>{let t=r.replace(/\{toolName\}/g,e),o=[],n=/\*\*(.+?)\*\*|\*(.+?)\*|~(.+?)~/g,a=0,s;for(;(s=n.exec(t))!==null;)s.index>a&&Ks(o,t.slice(a,s.index),[]),s[1]!==void 0?Ks(o,s[1],["bold"]):s[2]!==void 0?Ks(o,s[2],["italic"]):s[3]!==void 0&&Ks(o,s[3],["dim"]),a=s.index+s[0].length;return a<t.length&&Ks(o,t.slice(a),[]),o},Ks=(r,e,t)=>{let o=e.split("{duration}");for(let n=0;n<o.length;n++)o[n]&&r.push({text:o[n],styles:t}),n<o.length-1&&r.push({text:"{duration}",styles:t,isDuration:!0})},gv=()=>{let r=null,e=0,t=o=>{let n=/"text"\s*:\s*"((?:[^"\\]|\\.|")*?)"/,a=o.match(n);if(a&&a[1])try{return a[1].replace(/\\n/g,`
|
|
56
|
+
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}catch{return a[1]}let s=/"text"\s*:\s*"((?:[^"\\]|\\.)*)/,i=o.match(s);if(i&&i[1])try{return i[1].replace(/\\n/g,`
|
|
57
|
+
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}catch{return i[1]}return null};return{getExtractedText:()=>r,processChunk:async o=>{if(o.length<=e)return r!==null?{text:r,raw:o}:null;let n=o.trim();if(!n.startsWith("{")&&!n.startsWith("["))return null;let a=t(o);return a!==null&&(r=a),e=o.length,r!==null?{text:r,raw:o}:null},close:async()=>{}}},xa=r=>{try{let e=JSON.parse(r);if(e&&typeof e=="object"&&typeof e.text=="string")return e.text}catch{return null}return null},rl=()=>{let r={processChunk:e=>null,getExtractedText:()=>null};return r.__isPlainTextParser=!0,r},ol=()=>{var e;let r=gv();return{processChunk:async t=>{let o=t.trim();return!o.startsWith("{")&&!o.startsWith("[")?null:r.processChunk(t)},getExtractedText:r.getExtractedText.bind(r),close:(e=r.close)==null?void 0:e.bind(r)}},nl=()=>{let r=null,e=0;return{getExtractedText:()=>r,processChunk:t=>{let o=t.trim();if(!o.startsWith("{")&&!o.startsWith("["))return null;if(t.length<=e)return r!==null||r===""?{text:r||"",raw:t}:null;try{let n=(0,Sn.parse)(t,Sn.STR|Sn.OBJ);n&&typeof n=="object"&&(n.component&&typeof n.component=="string"?r=typeof n.text=="string"?Ji(n.text):"":n.type==="init"&&n.form?r="":typeof n.text=="string"&&(r=Ji(n.text)))}catch{}return e=t.length,r!==null?{text:r,raw:t}:null},close:()=>{}}},Zh=r=>{let e=null,t=0,n=r||(a=>{if(!a||typeof a!="object")return null;let s=i=>typeof i=="string"?Ji(i):null;if(a.component&&typeof a.component=="string")return typeof a.text=="string"?Ji(a.text):"";if(a.type==="init"&&a.form)return"";if(a.action)switch(a.action){case"nav_then_click":return s(a.on_load_text)||s(a.text)||null;case"message":case"message_and_click":case"checkout":return s(a.text)||null;default:return s(a.text)||s(a.display_text)||s(a.message)||null}return s(a.text)||s(a.display_text)||s(a.message)||s(a.content)||null});return{getExtractedText:()=>e,processChunk:a=>{let s=a.trim();if(!s.startsWith("{")&&!s.startsWith("["))return null;if(a.length<=t)return e!==null?{text:e,raw:a}:null;try{let i=(0,Sn.parse)(a,Sn.STR|Sn.OBJ),d=n(i);d!==null&&(e=d)}catch{}return t=a.length,{text:e||"",raw:a}},close:()=>{}}},al=()=>{let r=null;return{processChunk:e=>{if(!e.trim().startsWith("<"))return null;let o=e.match(/<text[^>]*>([\s\S]*?)<\/text>/);return o&&o[1]?(r=o[1],{text:r,raw:e}):null},getExtractedText:()=>r}};var sl=class{constructor(e,t=50){this.nextExpectedSeq=null;this.buffer=new Map;this.flushTimer=null;this.emitter=e,this.gapTimeoutMs=t}push(e,t){var a,s,i;let o=(i=(a=t==null?void 0:t.seq)!=null?a:t==null?void 0:t.sequenceIndex)!=null?i:(s=t==null?void 0:t.agentContext)==null?void 0:s.seq;if(o==null){this.buffer.size>0&&this.flushAll(),this.emitter(e,t);return}if(this.nextExpectedSeq===null&&(this.nextExpectedSeq=1),o===this.nextExpectedSeq){this.emitter(e,t),this.nextExpectedSeq=o+1,this.drainConsecutive();return}if(o<this.nextExpectedSeq){this.emitter(e,t);return}let n=this.buffer.get(o);n!==void 0&&(typeof console!="undefined"&&typeof console.warn=="function"&&console.warn(`[persona] SequenceReorderBuffer: duplicate seq=${o} (${n.payloadType} vs ${e}); emitting earlier event out-of-order to avoid loss`),this.emitter(n.payloadType,n.payload)),this.buffer.set(o,{payloadType:e,payload:t,seq:o}),this.startGapTimer()}drainConsecutive(){for(;this.buffer.has(this.nextExpectedSeq);){let e=this.buffer.get(this.nextExpectedSeq);this.buffer.delete(this.nextExpectedSeq),this.emitter(e.payloadType,e.payload),this.nextExpectedSeq++}this.buffer.size===0&&this.clearGapTimer()}startGapTimer(){this.flushTimer===null&&(this.flushTimer=setTimeout(()=>{this.flushAll()},this.gapTimeoutMs))}clearGapTimer(){this.flushTimer!==null&&(clearTimeout(this.flushTimer),this.flushTimer=null)}flushAll(){if(this.clearGapTimer(),this.buffer.size===0)return;let e=[...this.buffer.entries()].sort((t,o)=>t[0]-o[0]);for(let[t,o]of e)this.buffer.delete(t),this.emitter(o.payloadType,o.payload);e.length>0&&(this.nextExpectedSeq=e[e.length-1][0]+1)}destroy(){this.clearGapTimer(),this.buffer.clear()}flushPending(){this.flushAll()}};var hv="https://api.runtype.com/v1/dispatch",il="https://api.runtype.com";function xv(r){var a,s;let e=r.toLowerCase(),o={"application/pdf":"pdf","application/json":"json","application/zip":"zip","text/plain":"txt","text/csv":"csv","text/markdown":"md"}[e];if(o)return`attachment.${o}`;let n=e.indexOf("/");if(n>0){let i=(s=(a=e.slice(n+1).split(";")[0])==null?void 0:a.trim())!=null?s:"";if(i&&i!=="octet-stream"&&/^[a-z0-9.+-]+$/i.test(i))return`attachment.${i}`}return"attachment"}var jd=r=>!!(r.contentParts&&r.contentParts.length>0||r.llmContent&&r.llmContent.trim().length>0||r.rawContent&&r.rawContent.trim().length>0||r.content&&r.content.trim().length>0);function yv(r){switch(r){case"json":return nl;case"regex-json":return ol;case"xml":return al;default:return rl}}var ex=r=>r.startsWith("{")||r.startsWith("[")||r.startsWith("<");function bv(r,e){if(!r)return e;let t=r.trim(),o=e.trim();if(t.length===0)return e;if(o.length===0)return r;let n=ex(t);if(!ex(o))return r;if(!n||o===t||o.startsWith(t))return e;let s=xa(r);return xa(e)!==null&&s===null?e:r}var ya=class{constructor(e={}){this.config=e;this.clientSession=null;this.sessionInitPromise=null;this.lastSentClientToolsFingerprint=null;this.clientToolsFingerprintSessionId=null;var t,o,n,a;this.apiUrl=(t=e.apiUrl)!=null?t:hv,this.headers={"Content-Type":"application/json",...e.headers},this.debug=!!e.debug,this.createStreamParser=(o=e.streamParser)!=null?o:yv(e.parserType),this.contextProviders=(n=e.contextProviders)!=null?n:[],this.requestMiddleware=e.requestMiddleware,this.customFetch=e.customFetch,this.parseSSEEvent=e.parseSSEEvent,this.getHeaders=e.getHeaders,this.webMcpBridge=((a=e.webmcp)==null?void 0:a.enabled)===!0?new Ga(e.webmcp):null}updateConfig(e){this.config=e}setSSEEventCallback(e){this.onSSEEvent=e}setWebMcpConfirmHandler(e){var t;(t=this.webMcpBridge)==null||t.setConfirmHandler(e)}isWebMcpOperational(){var e;return((e=this.webMcpBridge)==null?void 0:e.isOperational())===!0}executeWebMcpToolCall(e,t,o){return this.webMcpBridge?this.webMcpBridge.executeToolCall(e,t,o):null}getSSEEventCallback(){return this.onSSEEvent}isClientTokenMode(){return!!this.config.clientToken}isAgentMode(){return!!this.config.agent}getClientApiUrl(e){var o;return`${((o=this.config.apiUrl)==null?void 0:o.replace(/\/+$/,"").replace(/\/v1\/dispatch$/,""))||il}/v1/client/${e}`}getClientSession(){return this.clientSession}async initSession(){var e,t;if(!this.isClientTokenMode())throw new Error("initSession() only available in client token mode");if(this.clientSession&&new Date<this.clientSession.expiresAt)return this.clientSession;if(this.sessionInitPromise)return this.sessionInitPromise;this.sessionInitPromise=this._doInitSession();try{let o=await this.sessionInitPromise;return this.clientSession=o,this.resetClientToolsFingerprint(),(t=(e=this.config).onSessionInit)==null||t.call(e,o),o}finally{this.sessionInitPromise=null}}async _doInitSession(){var a,s;let e=((s=(a=this.config).getStoredSessionId)==null?void 0:s.call(a))||null,t={token:this.config.clientToken,...this.config.flowId&&{flowId:this.config.flowId},...e&&{sessionId:e}},o=await fetch(this.getClientApiUrl("init"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!o.ok){let i=await o.json().catch(()=>({error:"Session initialization failed"}));throw o.status===401?new Error(`Invalid client token: ${i.hint||i.error}`):o.status===403?new Error(`Origin not allowed: ${i.hint||i.error}`):new Error(i.error||"Failed to initialize session")}let n=await o.json();return this.config.setStoredSessionId&&this.config.setStoredSessionId(n.sessionId),{sessionId:n.sessionId,expiresAt:new Date(n.expiresAt),flow:n.flow,config:{welcomeMessage:n.config.welcomeMessage,placeholder:n.config.placeholder,theme:n.config.theme}}}clearClientSession(){this.clientSession=null,this.sessionInitPromise=null,this.resetClientToolsFingerprint()}resetClientToolsFingerprint(){this.lastSentClientToolsFingerprint=null,this.clientToolsFingerprintSessionId=null}getFeedbackApiUrl(){var t;return`${((t=this.config.apiUrl)==null?void 0:t.replace(/\/+$/,"").replace(/\/v1\/dispatch$/,""))||il}/v1/client/feedback`}async sendFeedback(e){var a,s;if(!this.isClientTokenMode())throw new Error("sendFeedback() only available in client token mode");if(!this.getClientSession())throw new Error("No active session. Please initialize session first.");if(["upvote","downvote","copy"].includes(e.type)&&!e.messageId)throw new Error(`messageId is required for ${e.type} feedback type`);if(e.type==="csat"&&(e.rating===void 0||e.rating<1||e.rating>5))throw new Error("CSAT rating must be between 1 and 5");if(e.type==="nps"&&(e.rating===void 0||e.rating<0||e.rating>10))throw new Error("NPS rating must be between 0 and 10");this.debug&&console.debug("[AgentWidgetClient] sending feedback",e);let n=await fetch(this.getFeedbackApiUrl(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){let i=await n.json().catch(()=>({error:"Feedback submission failed"}));throw n.status===401?(this.clientSession=null,(s=(a=this.config).onSessionExpired)==null||s.call(a),new Error("Session expired. Please refresh to continue.")):new Error(i.error||"Failed to submit feedback")}}async submitMessageFeedback(e,t){let o=this.getClientSession();if(!o)throw new Error("No active session. Please initialize session first.");return this.sendFeedback({sessionId:o.sessionId,messageId:e,type:t})}async submitCSATFeedback(e,t){let o=this.getClientSession();if(!o)throw new Error("No active session. Please initialize session first.");return this.sendFeedback({sessionId:o.sessionId,type:"csat",rating:e,comment:t})}async submitNPSFeedback(e,t){let o=this.getClientSession();if(!o)throw new Error("No active session. Please initialize session first.");return this.sendFeedback({sessionId:o.sessionId,type:"nps",rating:e,comment:t})}async dispatch(e,t){return this.isAgentMode()?this.dispatchAgent(e,t):this.isClientTokenMode()?this.dispatchClientToken(e,t):this.dispatchProxy(e,t)}async dispatchClientToken(e,t){var n,a,s,i;let o=new AbortController;e.signal&&e.signal.addEventListener("abort",()=>o.abort()),t({type:"status",status:"connecting"});try{let d=await this.initSession();if(new Date>=new Date(d.expiresAt.getTime()-6e4)){this.clearClientSession(),(a=(n=this.config).onSessionExpired)==null||a.call(n);let x=new Error("Session expired. Please refresh to continue.");throw t({type:"error",error:x}),x}let l=await this.buildPayload(e.messages),u=l.metadata?Object.fromEntries(Object.entries(l.metadata).filter(([x])=>x!=="sessionId"&&x!=="session_id")):void 0,f={sessionId:d.sessionId,messages:e.messages.filter(jd).map(x=>{var w,v,E;return{id:x.id,role:x.role,content:(E=(v=(w=x.contentParts)!=null?w:x.llmContent)!=null?v:x.rawContent)!=null?E:x.content}}),...e.assistantMessageId&&{assistantMessageId:e.assistantMessageId},...u&&Object.keys(u).length>0&&{metadata:u},...l.inputs&&Object.keys(l.inputs).length>0&&{inputs:l.inputs},...l.context&&{context:l.context}},p=l.clientTools,m=!!(p&&p.length>0),y=m?Bh(p):void 0,h=this.clientToolsFingerprintSessionId===d.sessionId,T=m&&h&&this.lastSentClientToolsFingerprint===y,M=!1,k=null,L;for(let x=0;;x++){let v={...f,...m&&(M||!T)&&p?{clientTools:p}:{},...y?{clientToolsFingerprint:y}:{}};if(this.debug&&console.debug("[AgentWidgetClient] client token dispatch",v),L=await fetch(this.getClientApiUrl("chat"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v),signal:o.signal}),L.status===409&&x===0&&m){let E=await L.json().catch(()=>null);if((E==null?void 0:E.error)==="client_tools_resend_required"){M=!0,this.lastSentClientToolsFingerprint=null;continue}k=E!=null?E:{error:"Chat request failed"}}break}if(!L.ok){let x=k!=null?k:await L.json().catch(()=>({error:"Chat request failed"}));if(L.status===401){this.clearClientSession(),(i=(s=this.config).onSessionExpired)==null||i.call(s);let v=new Error("Session expired. Please refresh to continue.");throw t({type:"error",error:v}),v}if(L.status===429){let v=new Error(x.hint||"Message limit reached for this session.");throw t({type:"error",error:v}),v}let w=new Error(x.error||"Failed to send message");throw t({type:"error",error:w}),w}if(!L.body){let x=new Error("No response body received");throw t({type:"error",error:x}),x}this.lastSentClientToolsFingerprint=y!=null?y:null,this.clientToolsFingerprintSessionId=d.sessionId,t({type:"status",status:"connected"});try{await this.streamResponse(L.body,t,e.assistantMessageId)}finally{t({type:"status",status:"idle"})}}catch(d){let l=d instanceof Error?d:new Error(String(d));throw!l.message.includes("Session expired")&&!l.message.includes("Message limit")&&t({type:"error",error:l}),l}}async dispatchProxy(e,t){let o=new AbortController;e.signal&&e.signal.addEventListener("abort",()=>o.abort()),t({type:"status",status:"connecting"});let n=await this.buildPayload(e.messages);this.debug&&console.debug("[AgentWidgetClient] dispatch payload",n);let a={...this.headers};if(this.getHeaders)try{let i=await this.getHeaders();a={...a,...i}}catch(i){typeof console!="undefined"&&console.error("[AgentWidget] getHeaders error:",i)}let s;if(this.customFetch)try{s=await this.customFetch(this.apiUrl,{method:"POST",headers:a,body:JSON.stringify(n),signal:o.signal},n)}catch(i){let d=i instanceof Error?i:new Error(String(i));throw t({type:"error",error:d}),d}else s=await fetch(this.apiUrl,{method:"POST",headers:a,body:JSON.stringify(n),signal:o.signal});if(!s.ok||!s.body){let i=new Error(`Chat backend request failed: ${s.status} ${s.statusText}`);throw t({type:"error",error:i}),i}t({type:"status",status:"connected"});try{await this.streamResponse(s.body,t)}finally{t({type:"status",status:"idle"})}}async dispatchAgent(e,t){let o=new AbortController;e.signal&&e.signal.addEventListener("abort",()=>o.abort()),t({type:"status",status:"connecting"});let n=await this.buildAgentPayload(e.messages);this.debug&&console.debug("[AgentWidgetClient] agent dispatch payload",n);let a={...this.headers};if(this.getHeaders)try{let i=await this.getHeaders();a={...a,...i}}catch(i){typeof console!="undefined"&&console.error("[AgentWidget] getHeaders error:",i)}let s;if(this.customFetch)try{s=await this.customFetch(this.apiUrl,{method:"POST",headers:a,body:JSON.stringify(n),signal:o.signal},n)}catch(i){let d=i instanceof Error?i:new Error(String(i));throw t({type:"error",error:d}),d}else s=await fetch(this.apiUrl,{method:"POST",headers:a,body:JSON.stringify(n),signal:o.signal});if(!s.ok||!s.body){let i=new Error(`Agent execution request failed: ${s.status} ${s.statusText}`);throw t({type:"error",error:i}),i}t({type:"status",status:"connected"});try{await this.streamResponse(s.body,t,e.assistantMessageId)}finally{t({type:"status",status:"idle"})}}async processStream(e,t,o){t({type:"status",status:"connected"});try{await this.streamResponse(e,t,o)}finally{t({type:"status",status:"idle"})}}async resolveApproval(e,t){var s;let n=`${((s=this.config.apiUrl)==null?void 0:s.replace(/\/+$/,"").replace(/\/v1\/dispatch$/,""))||il}/v1/agents/${e.agentId}/approve`,a={"Content-Type":"application/json",...this.headers};return this.getHeaders&&Object.assign(a,await this.getHeaders()),fetch(n,{method:"POST",headers:a,body:JSON.stringify({executionId:e.executionId,approvalId:e.approvalId,decision:t,streamResponse:!0})})}async resumeFlow(e,t,o){var l,u;let n=this.isClientTokenMode(),a=n?this.getClientApiUrl("resume"):`${((l=this.config.apiUrl)==null?void 0:l.replace(/\/+$/,""))||il}/resume`,s;n&&(s=(await this.initSession()).sessionId);let i={"Content-Type":"application/json",...this.headers};this.getHeaders&&Object.assign(i,await this.getHeaders());let d={executionId:e,toolOutputs:t,streamResponse:(u=o==null?void 0:o.streamResponse)!=null?u:!0};return s&&(d.sessionId=s),fetch(a,{method:"POST",headers:i,body:JSON.stringify(d),signal:o==null?void 0:o.signal})}async buildAgentPayload(e){var a,s;if(!this.config.agent)throw new Error("Agent configuration required for agent mode");let t=e.slice().filter(jd).filter(i=>i.role==="user"||i.role==="assistant"||i.role==="system").filter(i=>!i.variant||i.variant==="assistant").sort((i,d)=>{let l=new Date(i.createdAt).getTime(),u=new Date(d.createdAt).getTime();return l-u}).map(i=>{var d,l,u;return{role:i.role,content:(u=(l=(d=i.contentParts)!=null?d:i.llmContent)!=null?l:i.rawContent)!=null?u:i.content,createdAt:i.createdAt}}),o={agent:this.config.agent,messages:t,options:{streamResponse:!0,recordMode:"virtual",...this.config.agentOptions}},n=[...Gs(this.config),...(s=await((a=this.webMcpBridge)==null?void 0:a.snapshotForDispatch()))!=null?s:[]];if(n.length>0&&(o.clientTools=n),this.contextProviders.length){let i={};await Promise.all(this.contextProviders.map(async d=>{try{let l=await d({messages:e,config:this.config});l&&typeof l=="object"&&Object.assign(i,l)}catch(l){typeof console!="undefined"&&console.warn("[AgentWidget] Context provider failed:",l)}})),Object.keys(i).length&&(o.context=i)}return o}async buildPayload(e){var a,s;let o={messages:e.slice().filter(jd).sort((i,d)=>{let l=new Date(i.createdAt).getTime(),u=new Date(d.createdAt).getTime();return l-u}).map(i=>{var d,l,u;return{role:i.role,content:(u=(l=(d=i.contentParts)!=null?d:i.llmContent)!=null?l:i.rawContent)!=null?u:i.content,createdAt:i.createdAt}}),...this.config.flowId&&{flowId:this.config.flowId}},n=[...Gs(this.config),...(s=await((a=this.webMcpBridge)==null?void 0:a.snapshotForDispatch()))!=null?s:[]];if(n.length>0&&(o.clientTools=n),this.contextProviders.length){let i={};await Promise.all(this.contextProviders.map(async d=>{try{let l=await d({messages:e,config:this.config});l&&typeof l=="object"&&Object.assign(i,l)}catch(l){typeof console!="undefined"&&console.warn("[AgentWidget] Context provider failed:",l)}})),Object.keys(i).length&&(o.context=i)}if(this.requestMiddleware)try{let i=await this.requestMiddleware({payload:{...o},config:this.config});if(i&&typeof i=="object"){let d=i;return o.clientTools!==void 0&&!("clientTools"in d)&&(d.clientTools=o.clientTools),d}}catch(i){typeof console!="undefined"&&console.error("[AgentWidget] Request middleware error:",i)}return o}async handleCustomSSEEvent(e,t,o,n,a,s){if(!this.parseSSEEvent)return!1;try{let i=await this.parseSSEEvent(e);if(i===null)return!1;let d=u=>{let f={id:`assistant-${Date.now()}-${Math.random().toString(16).slice(2)}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,variant:"assistant",sequence:a(),...u!==void 0&&{partId:u}};return o.current=f,n(f),f},l=u=>o.current?o.current:d(u);if(i.text!==void 0){i.partId!==void 0&&s.current!==null&&i.partId!==s.current&&(o.current&&(o.current.streaming=!1,n(o.current)),d(i.partId)),i.partId!==void 0&&(s.current=i.partId);let u=l(i.partId);i.partId!==void 0&&!u.partId&&(u.partId=i.partId),u.content+=i.text,n(u)}return i.done&&(o.current&&(o.current.streaming=!1,n(o.current)),s.current=null,t({type:"status",status:"idle"})),i.error&&(s.current=null,t({type:"error",error:new Error(i.error)})),!0}catch(i){return typeof console!="undefined"&&console.error("[AgentWidget] parseSSEEvent error:",i),!1}}async streamResponse(e,t,o){var Rt,dr,Yr,zr;let n=e.getReader(),a=new TextDecoder,s="",i=Date.now(),d=0,l=()=>i+d++,u=O=>{let fe=O.reasoning?{...O.reasoning,chunks:[...O.reasoning.chunks]}:void 0,Ie=O.toolCall?{...O.toolCall,chunks:O.toolCall.chunks?[...O.toolCall.chunks]:void 0}:void 0,Je=O.tools?O.tools.map(qe=>({...qe,chunks:qe.chunks?[...qe.chunks]:void 0})):void 0;return{...O,reasoning:fe,toolCall:Ie,tools:Je}},f=O=>{if(O.role!=="assistant"||O.variant)return!0;let fe=Array.isArray(O.contentParts)&&O.contentParts.length>0,Ie=typeof O.rawContent=="string"&&O.rawContent.trim()!=="";return typeof O.content=="string"&&O.content.trim()!==""||fe||Ie||!!O.stopReason},p=O=>{f(O)&&t({type:"message",message:u(O)})},m=null,y=null,h={current:null},T={current:null},M=!1,k=new Map,L=new Map,x=new Map,w=new Map,v={lastId:null,byStep:new Map},E={lastId:null,byCall:new Map},H=(O,fe,Ie="")=>`${O}::${fe}::${Ie}`,I=(O,fe)=>`${O}::${fe}::`,P=(O,fe,Ie,Je)=>{let qe=H(O,fe,Ie),ze=x.get(qe);if(ze)return ze;let lt=Ie?`-${Ie}`:"",Mt={id:`nested-${O}-${fe}${lt}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,sequence:l(),...Ie?{partId:Ie}:{},agentMetadata:{executionId:Je,parentToolId:O,parentStepId:fe}};return x.set(qe,Mt),p(Mt),Mt},z=O=>{if(O==null)return null;try{return String(O)}catch{return null}},j=O=>{var fe,Ie,Je,qe,ze;return z((ze=(qe=(Je=(Ie=(fe=O.stepId)!=null?fe:O.step_id)!=null?Ie:O.step)!=null?Je:O.parentId)!=null?qe:O.flowStepId)!=null?ze:O.flow_step_id)},ie=O=>{var fe,Ie,Je,qe,ze,lt,Mt;return z((Mt=(lt=(ze=(qe=(Je=(Ie=(fe=O.callId)!=null?fe:O.call_id)!=null?Ie:O.requestId)!=null?Je:O.request_id)!=null?qe:O.toolCallId)!=null?ze:O.tool_call_id)!=null?lt:O.stepId)!=null?Mt:O.step_id)},ve=o,Xe=!1,Ae=()=>{if(m)return m;let O;return!Xe&&ve?(O=ve,Xe=!0):ve&&T.current?O=`${ve}_${T.current}`:O=`assistant-${Date.now()}-${Math.random().toString(16).slice(2)}`,m={id:O,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,sequence:l()},p(m),m},We=(O,fe)=>{v.lastId=fe,O&&v.byStep.set(O,fe)},Me=(O,fe)=>{var ze;let Ie=(ze=O.reasoningId)!=null?ze:O.id,Je=j(O);if(Ie){let lt=String(Ie);return We(Je,lt),lt}if(Je){let lt=v.byStep.get(Je);if(lt)return v.lastId=lt,lt}if(v.lastId&&!fe)return v.lastId;if(!fe)return null;let qe=`reason-${l()}`;return We(Je,qe),qe},Ue=O=>{let fe=k.get(O);if(fe)return fe;let Ie={id:`reason-${O}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,variant:"reasoning",sequence:l(),reasoning:{id:O,status:"streaming",chunks:[]}};return k.set(O,Ie),p(Ie),Ie},Be=(O,fe)=>{E.lastId=fe,O&&E.byCall.set(O,fe)},Z=new Set,ne=new Map,me=new Set,be=new Map,ye=O=>{if(!O)return!1;let fe=O.replace(/_+/g,"_").replace(/^_|_$/g,"");return fe==="emit_artifact_markdown"||fe==="emit_artifact_component"},Y=(O,fe)=>{var ze;let Ie=(ze=O.toolId)!=null?ze:O.id,Je=ie(O);if(Ie){let lt=String(Ie);return Be(Je,lt),lt}if(Je){let lt=E.byCall.get(Je);if(lt)return E.lastId=lt,lt}if(E.lastId&&!fe)return E.lastId;if(!fe)return null;let qe=`tool-${l()}`;return Be(Je,qe),qe},ge=O=>{let fe=L.get(O);if(fe)return fe;let Ie={id:`tool-${O}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,variant:"tool",sequence:l(),toolCall:{id:O,status:"pending"}};return L.set(O,Ie),p(Ie),Ie},Oe=O=>{if(typeof O=="number"&&Number.isFinite(O))return O;if(typeof O=="string"){let fe=Number(O);if(!Number.isNaN(fe)&&Number.isFinite(fe))return fe;let Ie=Date.parse(O);if(!Number.isNaN(Ie))return Ie}return Date.now()},ce=O=>{if(typeof O=="string")return O;if(O==null)return"";try{return JSON.stringify(O)}catch{return String(O)}},ae=new Map,Q=new Map,Tt=new Map,Ye=new Map,De=null,le=(O,fe,Ie)=>{var Mt;let Je=Tt.get(O);Je||(Je=[],Tt.set(O,Je));let qe=0,ze=Je.length;for(;qe<ze;){let Dt=qe+ze>>>1;Je[Dt].seq<fe?qe=Dt+1:ze=Dt}((Mt=Je[qe])==null?void 0:Mt.seq)===fe?Je[qe]={seq:fe,text:Ie}:Je.splice(qe,0,{seq:fe,text:Ie});let lt="";for(let Dt=0;Dt<Je.length;Dt++)lt+=Je[Dt].text;return lt},nt=(O,fe)=>{let Ie=ce(fe),Je=Q.get(O.id),qe=bv(Je,Ie);O.rawContent=qe;let ze=ae.get(O.id),lt=wt=>{var Ce;let ct=(Ce=O.content)!=null?Ce:"";wt.trim()!==""&&(ct.trim().length===0||wt.startsWith(ct)||wt.trimStart().startsWith(ct.trim()))&&(O.content=wt)},Mt=()=>{var wt;if(ze){let ct=(wt=ze.close)==null?void 0:wt.call(ze);ct instanceof Promise&&ct.catch(()=>{})}ae.delete(O.id),Q.delete(O.id),O.streaming=!1,p(O)};if(!ze){lt(Ie),Mt();return}let Dt=xa(qe);if(Dt!==null&&Dt.trim()!==""){lt(Dt),Mt();return}let or=wt=>{var de;let ct=typeof wt=="string"?wt:(de=wt==null?void 0:wt.text)!=null?de:null;if(ct!==null&&ct.trim()!=="")return ct;let Ce=ze.getExtractedText();return Ce!==null&&Ce.trim()!==""?Ce:Ie},X;try{X=ze.processChunk(qe)}catch{lt(Ie),Mt();return}if(X instanceof Promise){X.then(wt=>{lt(or(wt)),Mt()}).catch(()=>{lt(Ie),Mt()});return}lt(or(X)),Mt()},Re=[],K=!1,he,it=()=>{K||(K=!0,queueMicrotask(()=>{K=!1,he()}))},Pt=new sl((O,fe)=>{Re.push({payloadType:O,payload:fe}),it()}),te=null,_e=new Map,Ar=(Rt=this.config.iterationDisplay)!=null?Rt:"separate";for(he=()=>{var O,fe,Ie,Je,qe,ze,lt,Mt,Dt,or,X,wt,ct,Ce,de,rt,Ft,zt,Pr,vr,xt,It,tt,jt,cr,Dr,hr,Sr,Oo,je,Tr,io,_o,lo,At,rn,No,mn,Jr,Ln,$r,Fo,mt,co,po,Or,Wt,Vr,Zr,_r,uo,fo,Nr,mo,$t,Fr,go,on,Uo,nn,qo,eo,to,gt,re,A,_,ue,$,at,ut,U,nr,mr,Cr,ko,sr,Ko,us,Eo,Lo,Xo,Qo,Qn,gn,ro,an,Pa,Yn,Ra,bi,Ia,vi,Ha,Lt,fs,zo,So,Ci,wi,Wa,hn,ms,Pn,gs,hs,xs,ys,To,Ba,sn,ln,bs,Ai,vs,Cs,Jn,Si,Ti,Mi,ki,dd,Zn,Rn,Ei,ws,In,Li,As,Hn,Ss,Pi,xn,Ri,Wn,Gt,Da,Oa;for(let ea=0;ea<Re.length;ea++){let Ke=Re[ea].payloadType,R=Re[ea].payload;if(Ke==="reason_start"){let V=(O=Me(R,!0))!=null?O:`reason-${l()}`,B=Ue(V);B.reasoning=(fe=B.reasoning)!=null?fe:{id:V,status:"streaming",chunks:[]},B.reasoning.startedAt=(Je=B.reasoning.startedAt)!=null?Je:Oe((Ie=R.startedAt)!=null?Ie:R.timestamp),B.reasoning.completedAt=void 0,B.reasoning.durationMs=void 0,B.streaming=!0,B.reasoning.status="streaming",p(B)}else if(Ke==="reason_delta"||Ke==="reason_chunk"){let V=(ze=(qe=Me(R,!1))!=null?qe:Me(R,!0))!=null?ze:`reason-${l()}`,B=Ue(V);B.reasoning=(lt=B.reasoning)!=null?lt:{id:V,status:"streaming",chunks:[]},B.reasoning.startedAt=(Dt=B.reasoning.startedAt)!=null?Dt:Oe((Mt=R.startedAt)!=null?Mt:R.timestamp);let oe=(wt=(X=(or=R.reasoningText)!=null?or:R.text)!=null?X:R.delta)!=null?wt:"";if(oe&&R.hidden!==!0){let pe=typeof R.sequenceIndex=="number"?R.sequenceIndex:void 0;if(pe!==void 0){let J=le(V,pe,String(oe));B.reasoning.chunks=[J]}else B.reasoning.chunks.push(String(oe))}if(B.reasoning.status=R.done?"complete":"streaming",R.done){B.reasoning.completedAt=Oe((ct=R.completedAt)!=null?ct:R.timestamp);let pe=(Ce=B.reasoning.startedAt)!=null?Ce:Date.now();B.reasoning.durationMs=Math.max(0,((de=B.reasoning.completedAt)!=null?de:Date.now())-pe)}B.streaming=B.reasoning.status!=="complete",p(B)}else if(Ke==="reason_complete"){let V=(Ft=(rt=Me(R,!1))!=null?rt:Me(R,!0))!=null?Ft:`reason-${l()}`,B=k.get(V);if(B!=null&&B.reasoning){B.reasoning.status="complete",B.reasoning.completedAt=Oe((zt=R.completedAt)!=null?zt:R.timestamp);let pe=(Pr=B.reasoning.startedAt)!=null?Pr:Date.now();B.reasoning.durationMs=Math.max(0,((vr=B.reasoning.completedAt)!=null?vr:Date.now())-pe),B.streaming=!1,p(B)}let oe=j(R);oe&&v.byStep.delete(oe)}else if(Ke==="tool_start"){let V=(xt=Y(R,!0))!=null?xt:`tool-${l()}`,B=(It=R.toolName)!=null?It:R.name;if(ye(B)){Z.add(V);continue}let oe=ge(V),pe=(tt=oe.toolCall)!=null?tt:{id:V,status:"pending"};pe.name=B!=null?B:pe.name,pe.status="running",R.args!==void 0?pe.args=R.args:R.parameters!==void 0&&(pe.args=R.parameters),pe.startedAt=(cr=pe.startedAt)!=null?cr:Oe((jt=R.startedAt)!=null?jt:R.timestamp),pe.completedAt=void 0,pe.durationMs=void 0,oe.toolCall=pe,oe.streaming=!0;let J=R.agentContext;(J||R.executionId)&&(oe.agentMetadata={executionId:(Dr=J==null?void 0:J.executionId)!=null?Dr:R.executionId,iteration:(hr=J==null?void 0:J.iteration)!=null?hr:R.iteration}),p(oe)}else if(Ke==="tool_chunk"||Ke==="tool_delta"){let V=(Oo=(Sr=Y(R,!1))!=null?Sr:Y(R,!0))!=null?Oo:`tool-${l()}`;if(Z.has(V))continue;let B=ge(V),oe=(je=B.toolCall)!=null?je:{id:V,status:"running"};oe.startedAt=(io=oe.startedAt)!=null?io:Oe((Tr=R.startedAt)!=null?Tr:R.timestamp);let pe=(At=(lo=(_o=R.text)!=null?_o:R.delta)!=null?lo:R.message)!=null?At:"";pe&&(oe.chunks=(rn=oe.chunks)!=null?rn:[],oe.chunks.push(String(pe))),oe.status="running",B.toolCall=oe,B.streaming=!0;let J=R.agentContext;(J||R.executionId)&&(B.agentMetadata=(Jr=B.agentMetadata)!=null?Jr:{executionId:(No=J==null?void 0:J.executionId)!=null?No:R.executionId,iteration:(mn=J==null?void 0:J.iteration)!=null?mn:R.iteration}),p(B)}else if(Ke==="tool_complete"){let V=($r=(Ln=Y(R,!1))!=null?Ln:Y(R,!0))!=null?$r:`tool-${l()}`;if(Z.has(V)){Z.delete(V);continue}let B=ge(V),oe=(Fo=B.toolCall)!=null?Fo:{id:V,status:"running"};oe.status="complete",R.result!==void 0&&(oe.result=R.result),typeof R.duration=="number"&&(oe.duration=R.duration),oe.completedAt=Oe((mt=R.completedAt)!=null?mt:R.timestamp);let pe=(co=R.duration)!=null?co:R.executionTime;if(typeof pe=="number")oe.durationMs=pe;else{let Ve=(po=oe.startedAt)!=null?po:Date.now();oe.durationMs=Math.max(0,((Or=oe.completedAt)!=null?Or:Date.now())-Ve)}B.toolCall=oe,B.streaming=!1;let J=R.agentContext;(J||R.executionId)&&(B.agentMetadata=(Zr=B.agentMetadata)!=null?Zr:{executionId:(Wt=J==null?void 0:J.executionId)!=null?Wt:R.executionId,iteration:(Vr=J==null?void 0:J.iteration)!=null?Vr:R.iteration}),p(B);let Le=ie(R);Le&&E.byCall.delete(Le)}else if(Ke==="step_await"&&R.awaitReason==="local_tool_required"&&R.toolName){let V=typeof R.toolCallId=="string"&&R.toolCallId.length>0?R.toolCallId:void 0,B=(_r=V!=null?V:R.toolId)!=null?_r:`local-${l()}`,oe=ge(B),pe=R.toolName,J=ga(pe),Le=(uo=oe.toolCall)!=null?uo:{id:B,status:"pending"};Le.name=pe,Le.args=R.parameters,Le.status=J?"running":"complete",Le.chunks=(fo=Le.chunks)!=null?fo:[],Le.startedAt=(mo=Le.startedAt)!=null?mo:Oe((Nr=R.startedAt)!=null?Nr:R.timestamp),J?(Le.completedAt=void 0,Le.duration=void 0,Le.durationMs=void 0):Le.completedAt=($t=Le.completedAt)!=null?$t:Le.startedAt,oe.toolCall=Le,oe.streaming=!1,oe.agentMetadata={...oe.agentMetadata,executionId:(go=R.executionId)!=null?go:(Fr=oe.agentMetadata)==null?void 0:Fr.executionId,awaitingLocalTool:!0,...V?{webMcpToolCallId:V}:{}},p(oe)}else if(Ke==="text_start"){if((on=R.toolContext)!=null&&on.toolId)continue;let V=R.partId;if(V!==void 0&&T.current!==null&&V!==T.current){let B=m;B&&(B.streaming=!1,p(B),De=B,m=null,M=!0)}V!==void 0&&(T.current=V)}else if(Ke==="text_end"){if((Uo=R.toolContext)!=null&&Uo.toolId)continue;let V=m;V&&(V.streaming=!1,p(V),De=V,m=null,M=!0)}else if(Ke==="step_chunk"||Ke==="step_delta"){let V=R.stepType,B=R.executionType;if(V==="tool"||B==="context")continue;let oe=R.toolContext;if(oe!=null&&oe.toolId){let Ve=String((qo=(nn=R.id)!=null?nn:oe.stepId)!=null?qo:`step-${l()}`),yt=R.partId!==void 0&&R.partId!==null?String(R.partId):"",dt=`${oe.toolId}::${Ve}`,Vt=w.get(dt);if(yt!==""&&Vt!==void 0&&Vt!==""&&Vt!==yt){let ht=x.get(H(oe.toolId,Ve,Vt));ht&&ht.streaming!==!1&&(ht.streaming=!1,p(ht))}yt!==""&&w.set(dt,yt);let Jt=P(oe.toolId,Ve,yt,oe.executionId),Rr=(re=(gt=(to=(eo=R.text)!=null?eo:R.delta)!=null?to:R.content)!=null?gt:R.chunk)!=null?re:"";Rr&&(Jt.content+=String(Rr),Jt.streaming=!0,p(Jt)),R.isComplete&&(Jt.streaming=!1,p(Jt));continue}let pe=R.partId;if(pe!==void 0&&T.current!==null&&pe!==T.current){let Ve=m;Ve&&(Ve.streaming=!1,p(Ve),De=Ve,m=null,M=!0)}pe!==void 0&&(T.current=pe);let J=pe!==void 0&&(A=Ye.get(pe))!=null?A:Ae();pe!==void 0&&(J.partId||(J.partId=pe),Ye.set(pe,J));let Le=(at=($=(ue=(_=R.text)!=null?_:R.delta)!=null?ue:R.content)!=null?$:R.chunk)!=null?at:"";if(Le){let Ve=typeof R.seq=="number"?R.seq:void 0,yt=pe!=null?pe:J.id,dt=Ve!==void 0?le(yt,Ve,String(Le)):((ut=Q.get(J.id))!=null?ut:"")+Le;J.rawContent=dt,ae.has(J.id)||ae.set(J.id,this.createStreamParser());let Vt=ae.get(J.id),Jt=dt.trim().startsWith("{")||dt.trim().startsWith("[");if(Jt&&Q.set(J.id,dt),Vt.__isPlainTextParser===!0){J.content=Ve!==void 0?dt:J.content+Le,Q.delete(J.id),ae.delete(J.id),J.rawContent=void 0,p(J);continue}let ht=Vt.processChunk(dt);if(ht instanceof Promise)ht.then(kt=>{var et;let gr=typeof kt=="string"?kt:(et=kt==null?void 0:kt.text)!=null?et:null;if(gr!==null&&gr.trim()!=="")J.content=gr,p(J);else if(!Jt&&!dt.trim().startsWith("<")){let jr=m,pr=jr&&jr.id===J.id?jr:J;pr.id===J.id&&(pr.content=Ve!==void 0?dt:pr.content+Le,Q.delete(pr.id),ae.delete(pr.id),pr.rawContent=void 0,p(pr))}}).catch(()=>{J.content=Ve!==void 0?dt:J.content+Le,Q.delete(J.id),ae.delete(J.id),J.rawContent=void 0,p(J)});else{let kt=typeof ht=="string"?ht:(U=ht==null?void 0:ht.text)!=null?U:null;kt!==null&&kt.trim()!==""?(J.content=kt,p(J)):!Jt&&!dt.trim().startsWith("<")&&(J.content=Ve!==void 0?dt:J.content+Le,Q.delete(J.id),ae.delete(J.id),J.rawContent=void 0,p(J))}}if(R.isComplete){let Ve=(mr=(nr=R.result)==null?void 0:nr.response)!=null?mr:J.content;if(Ve){let yt=Q.get(J.id),dt=yt!=null?yt:ce(Ve);J.rawContent=dt;let Vt=ae.get(J.id),Jt=null,Rr=!1;if(Vt&&(Jt=Vt.getExtractedText(),Jt===null&&(Jt=xa(dt)),Jt===null)){let ht=Vt.processChunk(dt);ht instanceof Promise?(Rr=!0,ht.then(kt=>{var et;let gr=typeof kt=="string"?kt:(et=kt==null?void 0:kt.text)!=null?et:null;if(gr!==null){let jr=m;jr&&jr.id===J.id&&(jr.content=gr,jr.streaming=!1,ae.delete(jr.id),Q.delete(jr.id),p(jr))}})):Jt=typeof ht=="string"?ht:(Cr=ht==null?void 0:ht.text)!=null?Cr:null}if(!Rr){Jt!==null&&Jt.trim()!==""?J.content=Jt:Q.has(J.id)||(J.content=ce(Ve));let ht=ae.get(J.id);if(ht){let kt=(ko=ht.close)==null?void 0:ko.call(ht);kt instanceof Promise&&kt.catch(()=>{}),ae.delete(J.id)}Q.delete(J.id),J.streaming=!1,p(J)}}}}else if(Ke==="step_complete"){let V=R.stepType,B=R.executionType;if(V==="tool"||B==="context")continue;let oe=R.toolContext;if(oe!=null&&oe.toolId){let Ve=String((Ko=(sr=R.id)!=null?sr:oe.stepId)!=null?Ko:"");if(Ve){let yt=I(oe.toolId,Ve);for(let[dt,Vt]of x)dt.startsWith(yt)&&Vt.streaming!==!1&&(Vt.streaming=!1,p(Vt));w.delete(`${oe.toolId}::${Ve}`)}continue}let pe=R.stopReason;if(M){if(m!==null){let dt=m;pe&&(dt.stopReason=pe),ae.delete(dt.id),Q.delete(dt.id),dt.streaming!==!1&&(dt.streaming=!1,p(dt))}let Ve=(us=R.result)==null?void 0:us.response,yt=De;yt&&(pe&&(yt.stopReason=pe),Ve!=null?nt(yt,Ve):(ae.delete(yt.id),Q.delete(yt.id))),De=null;continue}let J=(Eo=R.result)==null?void 0:Eo.response,Le=Ae();if(pe&&(Le.stopReason=pe),J!=null){let Ve=ae.get(Le.id),yt=!1,dt=!1;if(Ve){let Vt=Ve.getExtractedText(),Jt=Q.get(Le.id),Rr=Jt!=null?Jt:ce(J);if(Le.rawContent=Rr,Vt!==null&&Vt.trim()!=="")Le.content=Vt,yt=!0;else{let ht=xa(Rr);if(ht!==null)Le.content=ht,yt=!0;else{let kt=Ve.processChunk(Rr);if(kt instanceof Promise)dt=!0,kt.then(gr=>{var jr;let et=typeof gr=="string"?gr:(jr=gr==null?void 0:gr.text)!=null?jr:null;if(et!==null&&et.trim()!==""){let pr=m;pr&&pr.id===Le.id&&(pr.content=et,pr.streaming=!1,ae.delete(pr.id),Q.delete(pr.id),p(pr))}else{let pr=Ve.getExtractedText(),Ur=m;Ur&&Ur.id===Le.id&&(pr!==null&&pr.trim()!==""?Ur.content=pr:Q.has(Ur.id)||(Ur.content=ce(J)),Ur.streaming=!1,ae.delete(Ur.id),Q.delete(Ur.id),p(Ur))}});else{let gr=typeof kt=="string"?kt:(Lo=kt==null?void 0:kt.text)!=null?Lo:null;if(gr!==null&&gr.trim()!=="")Le.content=gr,yt=!0;else{let et=Ve.getExtractedText();et!==null&&et.trim()!==""&&(Le.content=et,yt=!0)}}}}}if(!dt){if(!Le.rawContent){let Vt=Q.get(Le.id);Le.rawContent=Vt!=null?Vt:ce(J)}if(!yt&&!Q.has(Le.id)&&(Le.content=ce(J)),Ve){let Vt=(Xo=Ve.close)==null?void 0:Xo.call(Ve);Vt instanceof Promise&&Vt.catch(()=>{})}ae.delete(Le.id),Q.delete(Le.id),Le.streaming=!1,p(Le)}}else ae.delete(Le.id),Q.delete(Le.id),Le.streaming=!1,p(Le)}else if(Ke==="flow_complete"){let V=(Qo=R.result)==null?void 0:Qo.response;if(M){if(m!==null){let B=m;ae.delete(B.id),Q.delete(B.id),B.streaming!==!1&&(B.streaming=!1,p(B))}}else if(V!=null){let B=Ae(),oe=Q.get(B.id),pe=oe!=null?oe:ce(V);B.rawContent=pe;let J=ce(V),Le=ae.get(B.id);if(Le){let dt=xa(pe);if(dt!==null)J=dt;else{let Vt=Le.processChunk(pe);Vt instanceof Promise&&Vt.then(Rr=>{var kt;let ht=typeof Rr=="string"?Rr:(kt=Rr==null?void 0:Rr.text)!=null?kt:null;ht!==null&&(B.content=ht,B.streaming=!1,p(B))});let Jt=Le.getExtractedText();Jt!==null&&(J=Jt)}}ae.delete(B.id),Q.delete(B.id);let Ve=J!==B.content,yt=B.streaming!==!1;Ve&&(B.content=J),B.streaming=!1,(Ve||yt)&&p(B)}else if(m!==null){let B=m;ae.delete(B.id),Q.delete(B.id),B.streaming!==!1&&(B.streaming=!1,p(B))}t({type:"status",status:"idle"})}else if(Ke==="agent_start")te={executionId:R.executionId,agentId:(Qn=R.agentId)!=null?Qn:"virtual",agentName:(gn=R.agentName)!=null?gn:"",status:"running",currentIteration:0,maxTurns:(ro=R.maxTurns)!=null?ro:1,startedAt:Oe(R.startedAt)};else if(Ke==="agent_iteration_start"){if(te&&(te.currentIteration=R.iteration),Ar==="separate"&&R.iteration>1){let V=m;V&&(V.streaming=!1,p(V),_e.set(R.iteration-1,V),m=null)}}else if(Ke==="agent_turn_start")y=null;else if(Ke==="agent_turn_delta"){if(R.contentType==="text"){let V=Ae();V.content+=(an=R.delta)!=null?an:"",V.agentMetadata={executionId:R.executionId,iteration:R.iteration,turnId:R.turnId,agentName:te==null?void 0:te.agentName},y=V,p(V)}else if(R.contentType==="thinking"){let V=(Pa=R.turnId)!=null?Pa:`agent-think-${R.iteration}`,B=Ue(V);B.reasoning=(Yn=B.reasoning)!=null?Yn:{id:V,status:"streaming",chunks:[]},B.reasoning.chunks.push((Ra=R.delta)!=null?Ra:""),B.agentMetadata={executionId:R.executionId,iteration:R.iteration,turnId:R.turnId},p(B)}else if(R.contentType==="tool_input"){let V=(bi=R.toolCallId)!=null?bi:E.lastId;if(V){let B=L.get(V);B!=null&&B.toolCall&&(B.toolCall.chunks=(Ia=B.toolCall.chunks)!=null?Ia:[],B.toolCall.chunks.push((vi=R.delta)!=null?vi:""),p(B))}}}else if(Ke==="agent_turn_complete"){let V=R.turnId;if(V){let pe=k.get(V);if(pe!=null&&pe.reasoning){pe.reasoning.status="complete",pe.reasoning.completedAt=Oe(R.completedAt);let J=(Ha=pe.reasoning.startedAt)!=null?Ha:Date.now();pe.reasoning.durationMs=Math.max(0,((Lt=pe.reasoning.completedAt)!=null?Lt:Date.now())-J),pe.streaming=!1,p(pe)}}let B=R.stopReason,oe=m!=null?m:y;if(B&&oe!==null){let pe=R.turnId;(!pe||((fs=oe.agentMetadata)==null?void 0:fs.turnId)===pe)&&(oe.stopReason=B,p(oe))}}else if(Ke==="agent_tool_start"){m&&(m.streaming=!1,p(m),m=null);let V=(zo=R.toolCallId)!=null?zo:`agent-tool-${l()}`;Be(ie(R),V);let B=ge(V),oe=(So=B.toolCall)!=null?So:{id:V,status:"pending",name:void 0,args:void 0,chunks:void 0,result:void 0,duration:void 0,startedAt:void 0,completedAt:void 0,durationMs:void 0};oe.name=(wi=(Ci=R.toolName)!=null?Ci:R.name)!=null?wi:oe.name,oe.status="running",R.parameters!==void 0&&(oe.args=R.parameters),oe.startedAt=Oe((Wa=R.startedAt)!=null?Wa:R.timestamp),B.toolCall=oe,B.streaming=!0,B.agentMetadata={executionId:R.executionId,iteration:R.iteration},p(B)}else if(Ke==="agent_tool_delta"){let V=(hn=R.toolCallId)!=null?hn:E.lastId;if(V){let B=(ms=L.get(V))!=null?ms:ge(V);B.toolCall&&(B.toolCall.chunks=(Pn=B.toolCall.chunks)!=null?Pn:[],B.toolCall.chunks.push((gs=R.delta)!=null?gs:""),B.toolCall.status="running",B.streaming=!0,p(B))}}else if(Ke==="agent_tool_complete"){let V=(hs=R.toolCallId)!=null?hs:E.lastId;if(V){let B=(xs=L.get(V))!=null?xs:ge(V);if(B.toolCall){B.toolCall.status="complete",R.result!==void 0&&(B.toolCall.result=R.result),typeof R.executionTime=="number"&&(B.toolCall.durationMs=R.executionTime),B.toolCall.completedAt=Oe((ys=R.completedAt)!=null?ys:R.timestamp),B.streaming=!1,p(B);let oe=ie(R);oe&&E.byCall.delete(oe)}}}else if(Ke==="agent_media"){let V=Array.isArray(R.media)?R.media:[],B=[];for(let oe of V){if(!oe||typeof oe!="object")continue;let pe=oe,J=typeof pe.type=="string"?pe.type:void 0,Le=typeof pe.mediaType=="string"?pe.mediaType.toLowerCase():"",Ve=null,yt="";if(J==="media"){let dt=typeof pe.data=="string"?pe.data:void 0;if(!dt)continue;yt=Le.length>0?Le:"application/octet-stream",Ve=`data:${yt};base64,${dt}`}else if(J==="image-url"){let dt=typeof pe.url=="string"?pe.url:void 0;if(!dt)continue;yt=Le,Ve=dt}else if(J==="file-url"){let dt=typeof pe.url=="string"?pe.url:void 0;if(!dt)continue;yt=Le,Ve=dt}else continue;if(Ve)if(J==="image-url"||yt.startsWith("image/"))B.push({type:"image",image:Ve,...yt?{mimeType:yt}:{}});else if(yt.startsWith("audio/"))B.push({type:"audio",audio:Ve,mimeType:yt});else if(yt.startsWith("video/"))B.push({type:"video",video:Ve,mimeType:yt});else{let dt=yt||"application/octet-stream";B.push({type:"file",data:Ve,mimeType:dt,filename:xv(dt)})}}if(B.length>0){let oe=l(),pe=R.toolCallId,Le={id:`agent-media-${typeof pe=="string"&&pe.length>0?`${pe}-${oe}`:String(oe)}`,role:"assistant",content:"",contentParts:B,createdAt:new Date().toISOString(),streaming:!1,sequence:oe,agentMetadata:{executionId:R.executionId,iteration:R.iteration}};p(Le);let Ve=m;Ve&&(Ve.streaming=!1,p(Ve)),m=null,h.current=null}}else if(Ke!=="agent_iteration_complete"){if(Ke==="agent_reflection"||Ke==="agent_reflect"){let V=`agent-reflection-${R.executionId}-${R.iteration}`,B={id:V,role:"assistant",content:(To=R.reflection)!=null?To:"",createdAt:new Date().toISOString(),streaming:!1,variant:"reasoning",sequence:l(),reasoning:{id:V,status:"complete",chunks:[(Ba=R.reflection)!=null?Ba:""]},agentMetadata:{executionId:R.executionId,iteration:R.iteration}};p(B)}else if(Ke==="agent_complete"){te&&(te.status=R.success?"complete":"error",te.completedAt=Oe(R.completedAt),te.stopReason=R.stopReason);let V=m;V&&(V.streaming=!1,p(V)),t({type:"status",status:"idle"})}else if(Ke==="agent_error"){let V=typeof R.error=="string"?R.error:(ln=(sn=R.error)==null?void 0:sn.message)!=null?ln:"Agent execution error";R.recoverable?typeof console!="undefined"&&console.warn("[AgentWidget] Recoverable agent error:",V):t({type:"error",error:new Error(V)})}else if(Ke!=="agent_ping"){if(Ke==="agent_approval_start"){let V=(bs=R.approvalId)!=null?bs:`approval-${l()}`,B={id:`approval-${V}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!1,variant:"approval",sequence:l(),approval:{id:V,status:"pending",agentId:(Ai=te==null?void 0:te.agentId)!=null?Ai:"virtual",executionId:(Cs=(vs=R.executionId)!=null?vs:te==null?void 0:te.executionId)!=null?Cs:"",toolName:(Jn=R.toolName)!=null?Jn:"",toolType:R.toolType,description:(Ti=R.description)!=null?Ti:`Execute ${(Si=R.toolName)!=null?Si:"tool"}`,...typeof R.reason=="string"&&R.reason?{reason:R.reason}:{},parameters:R.parameters}};p(B)}else if(Ke==="step_await"&&R.awaitReason==="approval_required"){let V=(Mi=R.approvalId)!=null?Mi:`approval-${l()}`,B={id:`approval-${V}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!1,variant:"approval",sequence:l(),approval:{id:V,status:"pending",agentId:(ki=te==null?void 0:te.agentId)!=null?ki:"virtual",executionId:(Zn=(dd=R.executionId)!=null?dd:te==null?void 0:te.executionId)!=null?Zn:"",toolName:(Rn=R.toolName)!=null?Rn:"",toolType:R.toolType,description:(ws=R.description)!=null?ws:`Execute ${(Ei=R.toolName)!=null?Ei:"tool"}`,...typeof R.reason=="string"&&R.reason?{reason:R.reason}:{},parameters:R.parameters}};p(B)}else if(Ke==="agent_approval_complete"){let V=R.approvalId;if(V){let oe={id:`approval-${V}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!1,variant:"approval",sequence:l(),approval:{id:V,status:(In=R.decision)!=null?In:"approved",agentId:(Li=te==null?void 0:te.agentId)!=null?Li:"virtual",executionId:(Hn=(As=R.executionId)!=null?As:te==null?void 0:te.executionId)!=null?Hn:"",toolName:(Ss=R.toolName)!=null?Ss:"",description:(Pi=R.description)!=null?Pi:"",resolvedAt:Date.now()}};p(oe)}}else if(Ke==="artifact_start"||Ke==="artifact_delta"||Ke==="artifact_update"||Ke==="artifact_complete"){if(Ke==="artifact_start"){let V=R.artifactType,B=String(R.id),oe=typeof R.title=="string"?R.title:void 0;if(t({type:"artifact_start",id:B,artifactType:V,title:oe,component:typeof R.component=="string"?R.component:void 0}),be.set(B,{markdown:"",title:oe}),!me.has(B)){me.add(B);let pe={id:`artifact-ref-${B}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,sequence:l(),rawContent:JSON.stringify({component:"PersonaArtifactCard",props:{artifactId:B,title:oe,artifactType:V,status:"streaming"}})};ne.set(B,pe),p(pe)}}else if(Ke==="artifact_delta"){let V=String(R.id),B=typeof R.delta=="string"?R.delta:String((xn=R.delta)!=null?xn:"");t({type:"artifact_delta",id:V,artDelta:B});let oe=be.get(V);oe&&(oe.markdown+=B)}else if(Ke==="artifact_update"){let V=R.props&&typeof R.props=="object"&&!Array.isArray(R.props)?R.props:{};t({type:"artifact_update",id:String(R.id),props:V,component:typeof R.component=="string"?R.component:void 0})}else if(Ke==="artifact_complete"){let V=String(R.id);t({type:"artifact_complete",id:V});let B=ne.get(V);if(B){B.streaming=!1;try{let oe=JSON.parse((Ri=B.rawContent)!=null?Ri:"{}");if(oe.props){oe.props.status="complete";let pe=be.get(V);pe!=null&&pe.markdown&&(oe.props.markdown=pe.markdown)}B.rawContent=JSON.stringify(oe)}catch{}be.delete(V),p(B),ne.delete(V)}}}else if(Ke==="transcript_insert"){let V=R.message;if(!V||typeof V!="object")continue;let B=String((Wn=V.id)!=null?Wn:`msg-${l()}`),oe=V.role,J={id:B,role:oe==="user"?"user":oe==="system"?"system":"assistant",content:typeof V.content=="string"?V.content:"",rawContent:typeof V.rawContent=="string"?V.rawContent:void 0,createdAt:typeof V.createdAt=="string"?V.createdAt:new Date().toISOString(),streaming:V.streaming===!0,...typeof V.variant=="string"?{variant:V.variant}:{},sequence:l()};if(p(J),J.rawContent)try{let Le=JSON.parse(J.rawContent),Ve=(Gt=Le==null?void 0:Le.props)==null?void 0:Gt.artifactId;typeof Ve=="string"&&me.add(Ve)}catch{}m=null,h.current=null,ae.delete(B),Q.delete(B)}else if(Ke==="error"||Ke==="step_error"||Ke==="dispatch_error"||Ke==="flow_error"){let V=null;if(R.error instanceof Error)V=R.error;else if(Ke==="dispatch_error"){let B=(Da=R.message)!=null?Da:R.error;B!=null&&B!==""&&(V=new Error(String(B)))}else if(Ke==="step_error"||Ke==="flow_error"){let B=R.error;typeof B=="string"&&B!==""?V=new Error(B):B!=null&&typeof B=="object"&&"message"in B&&(V=new Error(String((Oa=B.message)!=null?Oa:B)))}else Ke==="error"&&R.error!=null&&R.error!==""&&(V=new Error(String(R.error)));if(V){t({type:"error",error:V});let B=m;B&&B.streaming&&(B.streaming=!1,p(B)),t({type:"status",status:"idle"})}}}}}Re.length=0};;){let{done:O,value:fe}=await n.read();if(O)break;s+=a.decode(fe,{stream:!0});let Ie=s.split(`
|
|
57
58
|
|
|
58
|
-
`);s=(
|
|
59
|
-
`),Oe="message",Ye="";for(let sr of Fe)sr.startsWith("event:")?Oe=sr.replace("event:","").trim():sr.startsWith("data:")&&(Ye+=sr.replace("data:","").trim());if(!Ye)continue;let Tt;try{Tt=JSON.parse(Ye)}catch(sr){t({type:"error",error:sr instanceof Error?sr:new Error("Failed to parse chat stream payload")});continue}let Qt=Oe!=="message"?Oe:(gr=Tt.type)!=null?gr:"message";if((nn=this.onSSEEvent)==null||nn.call(this,Qt,Tt),this.parseSSEEvent){x.current=m;let sr=await this.handleCustomSSEEvent(Tt,t,x,u,l,S);if(x.current&&x.current!==m&&(m=x.current),sr)continue}It.push(Qt,Tt),ue()}}It.flushPending(),ue(),It.destroy()}};function Sh(){let r=Date.now().toString(36),e=Math.random().toString(36).substring(2,10);return`msg_${r}_${e}`}function Oa(){let r=Date.now().toString(36),e=Math.random().toString(36).substring(2,10);return`usr_${r}_${e}`}function ca(){let r=Date.now().toString(36),e=Math.random().toString(36).substring(2,10);return`ast_${r}_${e}`}var Ki="[Image]";function Th(r){return typeof r=="string"?[{type:"text",text:r}]:r}function Mh(r){return typeof r=="string"?r:r.filter(e=>e.type==="text").map(e=>e.text).join("")}function kh(r){return typeof r=="string"?!1:r.some(e=>e.type==="image")}function Eh(r){return typeof r=="string"?[]:r.filter(e=>e.type==="image")}function Fs(r){return{type:"text",text:r}}function Lh(r,e){return{type:"image",image:r,...(e==null?void 0:e.mimeType)&&{mimeType:e.mimeType},...(e==null?void 0:e.alt)&&{alt:e.alt}}}async function Ph(r){return new Promise((e,t)=>{let n=new FileReader;n.onload=()=>{let o=n.result;e({type:"image",image:o,mimeType:r.type,alt:r.name})},n.onerror=()=>t(new Error("Failed to read file")),n.readAsDataURL(r)})}function Rh(r,e=["image/png","image/jpeg","image/gif","image/webp"],t=10*1024*1024){return e.includes(r.type)?r.size>t?{valid:!1,error:`File too large. Maximum size: ${Math.round(t/1048576)}MB`}:{valid:!0}:{valid:!1,error:`Invalid file type. Accepted types: ${e.join(", ")}`}}var Ih=["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","image/bmp"],C0=["application/pdf","text/plain","text/markdown","text/csv","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/json"],ho=[...Ih,...C0];function w0(r){return Ih.includes(r)||r.startsWith("image/")}function Xi(r){return w0(r.type)}async function Wh(r){return new Promise((e,t)=>{let n=new FileReader;n.onload=()=>{let o=n.result;Xi(r)?e({type:"image",image:o,mimeType:r.type,alt:r.name}):e({type:"file",data:o,mimeType:r.type,filename:r.name})},n.onerror=()=>t(new Error("Failed to read file")),n.readAsDataURL(r)})}function Hh(r,e=ho,t=10*1024*1024){return e.includes(r.type)?r.size>t?{valid:!1,error:`File too large. Maximum size: ${Math.round(t/1048576)}MB`}:{valid:!0}:{valid:!1,error:`Invalid file type "${r.type}". Accepted types: ${e.join(", ")}`}}function A0(r){let e=r.split(".");return e.length>1?e.pop().toLowerCase():""}function Bh(r,e){let t=A0(e).toUpperCase();return{"application/pdf":"PDF","text/plain":"TXT","text/markdown":"MD","text/csv":"CSV","application/msword":"DOC","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"DOCX","application/vnd.ms-excel":"XLS","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"XLSX","application/json":"JSON"}[r]||t||"FILE"}var Qi=class{constructor(e=24e3){this.ctx=null;this.nextStartTime=0;this.activeSources=[];this.finishedCallbacks=[];this.playing=!1;this.streamEnded=!1;this.pendingCount=0;this.remainder=null;this.sampleRate=e}ensureContext(){if(!this.ctx){let t=typeof window!="undefined"?window:void 0;if(!t)throw new Error("AudioPlaybackManager requires a browser environment");let n=t.AudioContext||t.webkitAudioContext;this.ctx=new n({sampleRate:this.sampleRate})}let e=this.ctx;return e.state==="suspended"&&e.resume(),e}enqueue(e){if(e.length===0)return;let t=e;if(this.remainder){let d=new Uint8Array(this.remainder.length+e.length);d.set(this.remainder),d.set(e,this.remainder.length),t=d,this.remainder=null}if(t.length%2!==0&&(this.remainder=new Uint8Array([t[t.length-1]]),t=t.subarray(0,t.length-1)),t.length===0)return;let n=this.ensureContext(),o=this.pcmToFloat32(t),a=n.createBuffer(1,o.length,this.sampleRate);a.getChannelData(0).set(o);let s=n.createBufferSource();s.buffer=a,s.connect(n.destination);let i=n.currentTime;this.nextStartTime<i&&(this.nextStartTime=i),s.start(this.nextStartTime),this.nextStartTime+=a.duration,this.activeSources.push(s),this.pendingCount++,this.playing=!0,s.onended=()=>{let d=this.activeSources.indexOf(s);d!==-1&&this.activeSources.splice(d,1),this.pendingCount--,this.checkFinished()}}markStreamEnd(){this.streamEnded=!0,this.checkFinished()}flush(){for(let e of this.activeSources)try{e.stop(),e.disconnect()}catch{}this.activeSources=[],this.pendingCount=0,this.nextStartTime=0,this.playing=!1,this.streamEnded=!1,this.finishedCallbacks=[],this.remainder=null}isPlaying(){return this.playing}onFinished(e){this.finishedCallbacks.push(e)}async destroy(){this.flush(),this.ctx&&(await this.ctx.close(),this.ctx=null)}checkFinished(){if(this.streamEnded&&this.pendingCount<=0&&this.playing){this.playing=!1,this.streamEnded=!1;let e=this.finishedCallbacks.slice();this.finishedCallbacks=[];for(let t of e)t()}}pcmToFloat32(e){let t=Math.floor(e.length/2),n=new Float32Array(t),o=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let a=0;a<t;a++){let s=o.getInt16(a*2,!0);n[a]=s/32768}return n}};var Ji=class{constructor(){this.sourceNode=null;this.analyserNode=null;this.interval=null;this.conditionStart=null;this.fired=!1}start(e,t,n,o,a){this.stop(),this.fired=!1,this.conditionStart=null,this.sourceNode=e.createMediaStreamSource(t),this.analyserNode=e.createAnalyser(),this.analyserNode.fftSize=2048,this.sourceNode.connect(this.analyserNode);let s=new Float32Array(this.analyserNode.fftSize);this.interval=setInterval(()=>{if(!this.analyserNode||this.fired)return;this.analyserNode.getFloatTimeDomainData(s);let i=0;for(let p=0;p<s.length;p++)i+=s[p]*s[p];let d=Math.sqrt(i/s.length);(n==="silence"?d<o.threshold:d>=o.threshold)?this.conditionStart===null?this.conditionStart=Date.now():Date.now()-this.conditionStart>=o.duration&&(this.fired=!0,a()):this.conditionStart=null},100)}stop(){this.interval&&(clearInterval(this.interval),this.interval=null),this.sourceNode&&(this.sourceNode.disconnect(),this.sourceNode=null),this.analyserNode=null,this.conditionStart=null,this.fired=!1}};var Ns=class{constructor(e){this.config=e;this.type="runtype";this.ws=null;this.audioContext=null;this.w=typeof window!="undefined"?window:void 0;this.mediaRecorder=null;this.resultCallbacks=[];this.errorCallbacks=[];this.statusCallbacks=[];this.processingStartCallbacks=[];this.audioChunks=[];this.isProcessing=!1;this.isSpeaking=!1;this.vad=new Ji;this.mediaStream=null;this.currentAudio=null;this.currentAudioUrl=null;this.currentRequestId=null;this.interruptionMode="none";this.playbackManager=null}getInterruptionMode(){return this.interruptionMode}isBargeInActive(){return this.interruptionMode==="barge-in"&&this.mediaStream!==null}async deactivateBargeIn(){this.vad.stop(),this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>e.stop()),this.mediaStream=null),this.audioContext&&(await this.audioContext.close(),this.audioContext=null)}async connect(){var e,t,n;if(!(this.ws&&this.ws.readyState===WebSocket.OPEN))try{if(!this.w)throw new Error("Window object not available");let o=this.w;if(!o||!o.location)throw new Error("Window object or location not available");let a=o.location.protocol==="https:"?"wss:":"ws:",s=(e=this.config)==null?void 0:e.host,i=(t=this.config)==null?void 0:t.agentId,d=(n=this.config)==null?void 0:n.clientToken;if(!i||!d)throw new Error("agentId and clientToken are required");if(!s)throw new Error("host must be provided in Runtype voice provider configuration");let l=`${a}//${s}/ws/agents/${i}/voice?token=${d}`;this.ws=new WebSocket(l),this.setupWebSocketHandlers();let p=`${a}//${s}/ws/agents/${i}/voice?token=...`,f=" Check: API running on port 8787? Valid client token? Agent voice enabled? Token allowedOrigins includes this page?";await new Promise((u,m)=>{if(!this.ws)return m(new Error("WebSocket not created"));let v=!1,x=M=>{v||(v=!0,clearTimeout(S),m(new Error(M)))},S=setTimeout(()=>x("WebSocket connection timed out."+f),1e4);this.ws.addEventListener("open",()=>{v||(v=!0,clearTimeout(S),u())},{once:!0}),this.ws.addEventListener("error",()=>{x("WebSocket connection failed to "+p+"."+f)},{once:!0}),this.ws.addEventListener("close",M=>{if(!M.wasClean&&!v){let E=M.code!==1006?` (code ${M.code})`:"";x("WebSocket connection failed"+E+"."+f)}},{once:!0})}),this.sendHeartbeat()}catch(o){throw this.ws=null,this.errorCallbacks.forEach(a=>a(o)),this.statusCallbacks.forEach(a=>a("error")),o}}setupWebSocketHandlers(){this.ws&&(this.ws.onopen=()=>{this.statusCallbacks.forEach(e=>e("connected"))},this.ws.onclose=()=>{this.statusCallbacks.forEach(e=>e("disconnected"))},this.ws.onerror=e=>{this.errorCallbacks.forEach(t=>t(new Error("WebSocket error"))),this.statusCallbacks.forEach(t=>t("error"))},this.ws.binaryType="arraybuffer",this.ws.onmessage=e=>{if(e.data instanceof ArrayBuffer){this.handleAudioChunk(new Uint8Array(e.data));return}try{let t=JSON.parse(e.data);this.handleWebSocketMessage(t)}catch{this.errorCallbacks.forEach(n=>n(new Error("Message parsing failed")))}})}handleWebSocketMessage(e){var t,n;switch(e.type){case"session_config":e.interruptionMode&&(this.interruptionMode=e.interruptionMode);break;case"voice_response":this.isProcessing=!1,this.resultCallbacks.forEach(o=>o({text:e.response.agentResponseText||e.response.transcript,transcript:e.response.transcript,audio:e.response.audio,confidence:.95,provider:"runtype"})),(t=e.response.audio)!=null&&t.base64?(this.isSpeaking=!0,this.statusCallbacks.forEach(o=>o("speaking")),this.playAudio(e.response.audio).catch(o=>this.errorCallbacks.forEach(a=>a(o instanceof Error?o:new Error(String(o)))))):(n=e.response.audio)!=null&&n.base64;break;case"audio_end":if(e.requestId&&e.requestId!==this.currentRequestId)break;this.playbackManager?this.playbackManager.markStreamEnd():(this.isSpeaking=!1,this.isProcessing=!1,this.statusCallbacks.forEach(o=>o("idle")));break;case"cancelled":this.isProcessing=!1;break;case"error":this.errorCallbacks.forEach(o=>o(new Error(e.error))),this.statusCallbacks.forEach(o=>o("error")),this.isProcessing=!1;break;case"pong":break}}handleAudioChunk(e){e.length!==0&&this.currentRequestId&&(this.playbackManager||(this.playbackManager=new Qi(24e3),this.playbackManager.onFinished(()=>{this.isSpeaking=!1,this.playbackManager=null,this.vad.stop(),this.statusCallbacks.forEach(t=>t("idle"))})),this.isSpeaking||(this.isSpeaking=!0,this.statusCallbacks.forEach(t=>t("speaking")),this.startBargeInMonitoring().catch(()=>{})),this.playbackManager.enqueue(e))}stopPlayback(){!this.isProcessing&&!this.isSpeaking||(this.cancelCurrentPlayback(),this.statusCallbacks.forEach(e=>e("idle")))}cancelCurrentPlayback(){this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.src="",this.currentAudio=null),this.currentAudioUrl&&(URL.revokeObjectURL(this.currentAudioUrl),this.currentAudioUrl=null),this.playbackManager&&(this.playbackManager.flush(),this.playbackManager=null),this.currentRequestId&&this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"cancel",requestId:this.currentRequestId})),this.currentRequestId=null,this.isProcessing=!1,this.isSpeaking=!1}async startListening(){var e,t,n,o;try{if(this.isProcessing||this.isSpeaking)if(this.interruptionMode!=="none")this.cancelCurrentPlayback();else return;if(!this.mediaStream){let l=this.interruptionMode==="barge-in"?{audio:{echoCancellation:!0,noiseSuppression:!0}}:{audio:!0};this.mediaStream=await navigator.mediaDevices.getUserMedia(l)}let a=this.w;this.audioContext||(this.audioContext=new(a.AudioContext||a.webkitAudioContext));let s=this.audioContext,i=(t=(e=this.config)==null?void 0:e.pauseDuration)!=null?t:2e3,d=(o=(n=this.config)==null?void 0:n.silenceThreshold)!=null?o:.01;this.vad.start(s,this.mediaStream,"silence",{threshold:d,duration:i},()=>this.stopListening()),this.mediaRecorder=new MediaRecorder(this.mediaStream),this.audioChunks=[],this.mediaRecorder.ondataavailable=l=>{l.data.size>0&&this.audioChunks.push(l.data)},this.mediaRecorder.onstop=async()=>{var l;if(this.audioChunks.length>0){this.isProcessing=!0,this.statusCallbacks.forEach(u=>u("processing")),this.processingStartCallbacks.forEach(u=>u());let p=((l=this.mediaRecorder)==null?void 0:l.mimeType)||"audio/webm",f=new Blob(this.audioChunks,{type:p});await this.sendAudio(f),this.audioChunks=[]}},this.mediaRecorder.start(1e3),this.statusCallbacks.forEach(l=>l("listening"))}catch(a){throw this.errorCallbacks.forEach(s=>s(a)),this.statusCallbacks.forEach(s=>s("error")),a}}async stopListening(){this.vad.stop(),this.mediaRecorder&&(this.interruptionMode!=="barge-in"&&this.mediaRecorder.stream.getTracks().forEach(e=>e.stop()),this.mediaRecorder.stop(),this.mediaRecorder=null),this.interruptionMode!=="barge-in"&&(this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>e.stop()),this.mediaStream=null),this.audioContext&&(await this.audioContext.close(),this.audioContext=null)),this.statusCallbacks.forEach(e=>e("idle"))}async startBargeInMonitoring(){var a,s;if(this.interruptionMode!=="barge-in")return;let e=this.w;if(!this.mediaStream&&e&&(this.mediaStream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0}})),!this.audioContext&&e&&(this.audioContext=new(e.AudioContext||e.webkitAudioContext)),!this.audioContext||!this.mediaStream)return;let t=this.audioContext,n=(s=(a=this.config)==null?void 0:a.silenceThreshold)!=null?s:.01;this.vad.start(t,this.mediaStream,"speech",{threshold:n,duration:200},()=>this.handleBargeIn())}handleBargeIn(){this.cancelCurrentPlayback(),this.startListening().catch(e=>{this.errorCallbacks.forEach(t=>t(e instanceof Error?e:new Error(String(e))))})}generateRequestId(){return"vreq_"+Math.random().toString(36).substring(2,10)+Date.now().toString(36)}async sendAudio(e){var t;if(!this.ws||this.ws.readyState!==WebSocket.OPEN){this.errorCallbacks.forEach(n=>n(new Error("WebSocket not connected"))),this.statusCallbacks.forEach(n=>n("error"));return}try{let n=await this.blobToBase64(e),o=this.getFormatFromMimeType(e.type),a=this.generateRequestId();this.currentRequestId=a,this.ws.send(JSON.stringify({type:"audio_input",audio:n,format:o,sampleRate:16e3,voiceId:(t=this.config)==null?void 0:t.voiceId,requestId:a}))}catch(n){this.errorCallbacks.forEach(o=>o(n)),this.statusCallbacks.forEach(o=>o("error"))}}getFormatFromMimeType(e){return e.includes("wav")?"wav":e.includes("mpeg")||e.includes("mp3")?"mp3":"webm"}blobToBase64(e){return new Promise((t,n)=>{let o=new FileReader;o.onload=()=>{let s=o.result.split(",")[1];t(s)},o.onerror=n,o.readAsDataURL(e)})}async playAudio(e){if(!e.base64)return;let t=atob(e.base64),n=new Uint8Array(t.length);for(let l=0;l<t.length;l++)n[l]=t.charCodeAt(l);let o=e.format||"mp3",a=o==="mp3"?"audio/mpeg":`audio/${o}`,s=new Blob([n],{type:a}),i=URL.createObjectURL(s),d=new Audio(i);this.currentAudio=d,this.currentAudioUrl=i,d.onended=()=>{URL.revokeObjectURL(i),this.currentAudio===d&&(this.currentAudio=null,this.currentAudioUrl=null,this.isSpeaking=!1,this.statusCallbacks.forEach(l=>l("idle")))},await d.play()}onResult(e){this.resultCallbacks.push(e)}onError(e){this.errorCallbacks.push(e)}onStatusChange(e){this.statusCallbacks.push(e)}onProcessingStart(e){this.processingStartCallbacks.push(e)}async disconnect(){if(this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.src="",this.currentAudio=null),this.currentAudioUrl&&(URL.revokeObjectURL(this.currentAudioUrl),this.currentAudioUrl=null),this.playbackManager&&(await this.playbackManager.destroy(),this.playbackManager=null),this.currentRequestId=null,this.isSpeaking=!1,this.vad.stop(),await this.stopListening(),this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>e.stop()),this.mediaStream=null),this.audioContext&&(await this.audioContext.close(),this.audioContext=null),this.ws){try{this.ws.close()}catch{}this.ws=null}this.statusCallbacks.forEach(e=>e("disconnected"))}sendHeartbeat(){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"ping"}))}};var pa=class{constructor(e={}){this.config=e;this.type="browser";this.recognition=null;this.resultCallbacks=[];this.errorCallbacks=[];this.statusCallbacks=[];this.isListening=!1;this.w=typeof window!="undefined"?window:void 0}async connect(){this.statusCallbacks.forEach(e=>e("connected"))}async startListening(){var e,t;try{if(this.isListening)throw new Error("Already listening");if(!this.w)throw new Error("Window object not available");let n=this.w.SpeechRecognition||this.w.webkitSpeechRecognition;if(!n)throw new Error("Browser speech recognition not supported");this.recognition=new n,this.recognition.lang=((e=this.config)==null?void 0:e.language)||"en-US",this.recognition.continuous=((t=this.config)==null?void 0:t.continuous)||!1,this.recognition.interimResults=!0,this.recognition.onresult=o=>{var i;let a=Array.from(o.results).map(d=>d[0]).map(d=>d.transcript).join(""),s=o.results[o.results.length-1].isFinal;this.resultCallbacks.forEach(d=>d({text:a,confidence:s?.8:.5,provider:"browser"})),s&&!((i=this.config)!=null&&i.continuous)&&this.stopListening()},this.recognition.onerror=o=>{this.errorCallbacks.forEach(a=>a(new Error(o.error))),this.statusCallbacks.forEach(a=>a("error"))},this.recognition.onstart=()=>{this.isListening=!0,this.statusCallbacks.forEach(o=>o("listening"))},this.recognition.onend=()=>{this.isListening=!1,this.statusCallbacks.forEach(o=>o("idle"))},this.recognition.start()}catch(n){throw this.errorCallbacks.forEach(o=>o(n)),this.statusCallbacks.forEach(o=>o("error")),n}}async stopListening(){this.recognition&&(this.recognition.stop(),this.recognition=null),this.isListening=!1,this.statusCallbacks.forEach(e=>e("idle"))}onResult(e){this.resultCallbacks.push(e)}onError(e){this.errorCallbacks.push(e)}onStatusChange(e){this.statusCallbacks.push(e)}async disconnect(){await this.stopListening(),this.statusCallbacks.forEach(e=>e("disconnected"))}static isSupported(){return"SpeechRecognition"in window||"webkitSpeechRecognition"in window}};function ua(r){switch(r.type){case"runtype":if(!r.runtype)throw new Error("Runtype voice provider requires configuration");return new Ns(r.runtype);case"browser":if(!pa.isSupported())throw new Error("Browser speech recognition not supported");return new pa(r.browser||{});case"custom":throw new Error("Custom voice providers not yet implemented");default:throw new Error(`Unknown voice provider type: ${r.type}`)}}function Yi(r){if((r==null?void 0:r.type)==="runtype"&&r.runtype)return ua({type:"runtype",runtype:r.runtype});if(pa.isSupported())return ua({type:"browser",browser:(r==null?void 0:r.browser)||{language:"en-US"}});throw new Error("No supported voice providers available")}function Os(r){try{return Yi(r),!0}catch{return!1}}function Dh(r,e){let t=r instanceof Error?r:new Error(String(r));if(typeof e=="string")return e;if(typeof e=="function")return e(t);let n="Sorry \u2014 I couldn't reach the assistant. The chat service didn't respond. Please check that your proxy or backend is running and reachable, then try again.";return t.message?`${n}
|
|
59
|
+
`);s=(dr=Ie.pop())!=null?dr:"";for(let Je of Ie){let qe=Je.split(`
|
|
60
|
+
`),ze="message",lt="";for(let or of qe)or.startsWith("event:")?ze=or.replace("event:","").trim():or.startsWith("data:")&&(lt+=or.replace("data:","").trim());if(!lt)continue;let Mt;try{Mt=JSON.parse(lt)}catch(or){t({type:"error",error:or instanceof Error?or:new Error("Failed to parse chat stream payload")});continue}let Dt=ze!=="message"?ze:(Yr=Mt.type)!=null?Yr:"message";if((zr=this.onSSEEvent)==null||zr.call(this,Dt,Mt),this.parseSSEEvent){h.current=m;let or=await this.handleCustomSSEEvent(Mt,t,h,p,l,T);if(h.current&&h.current!==m&&(m=h.current),or)continue}Pt.push(Dt,Mt),he()}}Pt.flushPending(),he(),Pt.destroy()}};function tx(){let r=Date.now().toString(36),e=Math.random().toString(36).substring(2,10);return`msg_${r}_${e}`}function Ja(){let r=Date.now().toString(36),e=Math.random().toString(36).substring(2,10);return`usr_${r}_${e}`}function ba(){let r=Date.now().toString(36),e=Math.random().toString(36).substring(2,10);return`ast_${r}_${e}`}var ll="[Image]";function rx(r){return typeof r=="string"?[{type:"text",text:r}]:r}function ox(r){return typeof r=="string"?r:r.filter(e=>e.type==="text").map(e=>e.text).join("")}function nx(r){return typeof r=="string"?!1:r.some(e=>e.type==="image")}function ax(r){return typeof r=="string"?[]:r.filter(e=>e.type==="image")}function Qs(r){return{type:"text",text:r}}function sx(r,e){return{type:"image",image:r,...(e==null?void 0:e.mimeType)&&{mimeType:e.mimeType},...(e==null?void 0:e.alt)&&{alt:e.alt}}}async function ix(r){return new Promise((e,t)=>{let o=new FileReader;o.onload=()=>{let n=o.result;e({type:"image",image:n,mimeType:r.type,alt:r.name})},o.onerror=()=>t(new Error("Failed to read file")),o.readAsDataURL(r)})}function lx(r,e=["image/png","image/jpeg","image/gif","image/webp"],t=10*1024*1024){return e.includes(r.type)?r.size>t?{valid:!1,error:`File too large. Maximum size: ${Math.round(t/1048576)}MB`}:{valid:!0}:{valid:!1,error:`Invalid file type. Accepted types: ${e.join(", ")}`}}var dx=["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","image/bmp"],vv=["application/pdf","text/plain","text/markdown","text/csv","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/json"],Tn=[...dx,...vv];function Cv(r){return dx.includes(r)||r.startsWith("image/")}function dl(r){return Cv(r.type)}async function cx(r){return new Promise((e,t)=>{let o=new FileReader;o.onload=()=>{let n=o.result;dl(r)?e({type:"image",image:n,mimeType:r.type,alt:r.name}):e({type:"file",data:n,mimeType:r.type,filename:r.name})},o.onerror=()=>t(new Error("Failed to read file")),o.readAsDataURL(r)})}function px(r,e=Tn,t=10*1024*1024){return e.includes(r.type)?r.size>t?{valid:!1,error:`File too large. Maximum size: ${Math.round(t/1048576)}MB`}:{valid:!0}:{valid:!1,error:`Invalid file type "${r.type}". Accepted types: ${e.join(", ")}`}}function wv(r){let e=r.split(".");return e.length>1?e.pop().toLowerCase():""}function ux(r,e){let t=wv(e).toUpperCase();return{"application/pdf":"PDF","text/plain":"TXT","text/markdown":"MD","text/csv":"CSV","application/msword":"DOC","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"DOCX","application/vnd.ms-excel":"XLS","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"XLSX","application/json":"JSON"}[r]||t||"FILE"}var cl=class{constructor(e=24e3){this.ctx=null;this.nextStartTime=0;this.activeSources=[];this.finishedCallbacks=[];this.playing=!1;this.streamEnded=!1;this.pendingCount=0;this.remainder=null;this.sampleRate=e}ensureContext(){if(!this.ctx){let t=typeof window!="undefined"?window:void 0;if(!t)throw new Error("AudioPlaybackManager requires a browser environment");let o=t.AudioContext||t.webkitAudioContext;this.ctx=new o({sampleRate:this.sampleRate})}let e=this.ctx;return e.state==="suspended"&&e.resume(),e}enqueue(e){if(e.length===0)return;let t=e;if(this.remainder){let d=new Uint8Array(this.remainder.length+e.length);d.set(this.remainder),d.set(e,this.remainder.length),t=d,this.remainder=null}if(t.length%2!==0&&(this.remainder=new Uint8Array([t[t.length-1]]),t=t.subarray(0,t.length-1)),t.length===0)return;let o=this.ensureContext(),n=this.pcmToFloat32(t),a=o.createBuffer(1,n.length,this.sampleRate);a.getChannelData(0).set(n);let s=o.createBufferSource();s.buffer=a,s.connect(o.destination);let i=o.currentTime;this.nextStartTime<i&&(this.nextStartTime=i),s.start(this.nextStartTime),this.nextStartTime+=a.duration,this.activeSources.push(s),this.pendingCount++,this.playing=!0,s.onended=()=>{let d=this.activeSources.indexOf(s);d!==-1&&this.activeSources.splice(d,1),this.pendingCount--,this.checkFinished()}}markStreamEnd(){this.streamEnded=!0,this.checkFinished()}flush(){for(let e of this.activeSources)try{e.stop(),e.disconnect()}catch{}this.activeSources=[],this.pendingCount=0,this.nextStartTime=0,this.playing=!1,this.streamEnded=!1,this.finishedCallbacks=[],this.remainder=null}isPlaying(){return this.playing}onFinished(e){this.finishedCallbacks.push(e)}async destroy(){this.flush(),this.ctx&&(await this.ctx.close(),this.ctx=null)}checkFinished(){if(this.streamEnded&&this.pendingCount<=0&&this.playing){this.playing=!1,this.streamEnded=!1;let e=this.finishedCallbacks.slice();this.finishedCallbacks=[];for(let t of e)t()}}pcmToFloat32(e){let t=Math.floor(e.length/2),o=new Float32Array(t),n=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let a=0;a<t;a++){let s=n.getInt16(a*2,!0);o[a]=s/32768}return o}};var pl=class{constructor(){this.sourceNode=null;this.analyserNode=null;this.interval=null;this.conditionStart=null;this.fired=!1}start(e,t,o,n,a){this.stop(),this.fired=!1,this.conditionStart=null,this.sourceNode=e.createMediaStreamSource(t),this.analyserNode=e.createAnalyser(),this.analyserNode.fftSize=2048,this.sourceNode.connect(this.analyserNode);let s=new Float32Array(this.analyserNode.fftSize);this.interval=setInterval(()=>{if(!this.analyserNode||this.fired)return;this.analyserNode.getFloatTimeDomainData(s);let i=0;for(let u=0;u<s.length;u++)i+=s[u]*s[u];let d=Math.sqrt(i/s.length);(o==="silence"?d<n.threshold:d>=n.threshold)?this.conditionStart===null?this.conditionStart=Date.now():Date.now()-this.conditionStart>=n.duration&&(this.fired=!0,a()):this.conditionStart=null},100)}stop(){this.interval&&(clearInterval(this.interval),this.interval=null),this.sourceNode&&(this.sourceNode.disconnect(),this.sourceNode=null),this.analyserNode=null,this.conditionStart=null,this.fired=!1}};var Ys=class{constructor(e){this.config=e;this.type="runtype";this.ws=null;this.audioContext=null;this.w=typeof window!="undefined"?window:void 0;this.mediaRecorder=null;this.resultCallbacks=[];this.errorCallbacks=[];this.statusCallbacks=[];this.processingStartCallbacks=[];this.audioChunks=[];this.isProcessing=!1;this.isSpeaking=!1;this.vad=new pl;this.mediaStream=null;this.currentAudio=null;this.currentAudioUrl=null;this.currentRequestId=null;this.interruptionMode="none";this.playbackManager=null}getInterruptionMode(){return this.interruptionMode}isBargeInActive(){return this.interruptionMode==="barge-in"&&this.mediaStream!==null}async deactivateBargeIn(){this.vad.stop(),this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>e.stop()),this.mediaStream=null),this.audioContext&&(await this.audioContext.close(),this.audioContext=null)}async connect(){var e,t,o;if(!(this.ws&&this.ws.readyState===WebSocket.OPEN))try{if(!this.w)throw new Error("Window object not available");let n=this.w;if(!n||!n.location)throw new Error("Window object or location not available");let a=n.location.protocol==="https:"?"wss:":"ws:",s=(e=this.config)==null?void 0:e.host,i=(t=this.config)==null?void 0:t.agentId,d=(o=this.config)==null?void 0:o.clientToken;if(!i||!d)throw new Error("agentId and clientToken are required");if(!s)throw new Error("host must be provided in Runtype voice provider configuration");let l=`${a}//${s}/ws/agents/${i}/voice?token=${d}`;this.ws=new WebSocket(l),this.setupWebSocketHandlers();let u=`${a}//${s}/ws/agents/${i}/voice?token=...`,f=" Check: API running on port 8787? Valid client token? Agent voice enabled? Token allowedOrigins includes this page?";await new Promise((p,m)=>{if(!this.ws)return m(new Error("WebSocket not created"));let y=!1,h=M=>{y||(y=!0,clearTimeout(T),m(new Error(M)))},T=setTimeout(()=>h("WebSocket connection timed out."+f),1e4);this.ws.addEventListener("open",()=>{y||(y=!0,clearTimeout(T),p())},{once:!0}),this.ws.addEventListener("error",()=>{h("WebSocket connection failed to "+u+"."+f)},{once:!0}),this.ws.addEventListener("close",M=>{if(!M.wasClean&&!y){let k=M.code!==1006?` (code ${M.code})`:"";h("WebSocket connection failed"+k+"."+f)}},{once:!0})}),this.sendHeartbeat()}catch(n){throw this.ws=null,this.errorCallbacks.forEach(a=>a(n)),this.statusCallbacks.forEach(a=>a("error")),n}}setupWebSocketHandlers(){this.ws&&(this.ws.onopen=()=>{this.statusCallbacks.forEach(e=>e("connected"))},this.ws.onclose=()=>{this.statusCallbacks.forEach(e=>e("disconnected"))},this.ws.onerror=e=>{this.errorCallbacks.forEach(t=>t(new Error("WebSocket error"))),this.statusCallbacks.forEach(t=>t("error"))},this.ws.binaryType="arraybuffer",this.ws.onmessage=e=>{if(e.data instanceof ArrayBuffer){this.handleAudioChunk(new Uint8Array(e.data));return}try{let t=JSON.parse(e.data);this.handleWebSocketMessage(t)}catch{this.errorCallbacks.forEach(o=>o(new Error("Message parsing failed")))}})}handleWebSocketMessage(e){var t,o;switch(e.type){case"session_config":e.interruptionMode&&(this.interruptionMode=e.interruptionMode);break;case"voice_response":this.isProcessing=!1,this.resultCallbacks.forEach(n=>n({text:e.response.agentResponseText||e.response.transcript,transcript:e.response.transcript,audio:e.response.audio,confidence:.95,provider:"runtype"})),(t=e.response.audio)!=null&&t.base64?(this.isSpeaking=!0,this.statusCallbacks.forEach(n=>n("speaking")),this.playAudio(e.response.audio).catch(n=>this.errorCallbacks.forEach(a=>a(n instanceof Error?n:new Error(String(n)))))):(o=e.response.audio)!=null&&o.base64;break;case"audio_end":if(e.requestId&&e.requestId!==this.currentRequestId)break;this.playbackManager?this.playbackManager.markStreamEnd():(this.isSpeaking=!1,this.isProcessing=!1,this.statusCallbacks.forEach(n=>n("idle")));break;case"cancelled":this.isProcessing=!1;break;case"error":this.errorCallbacks.forEach(n=>n(new Error(e.error))),this.statusCallbacks.forEach(n=>n("error")),this.isProcessing=!1;break;case"pong":break}}handleAudioChunk(e){e.length!==0&&this.currentRequestId&&(this.playbackManager||(this.playbackManager=new cl(24e3),this.playbackManager.onFinished(()=>{this.isSpeaking=!1,this.playbackManager=null,this.vad.stop(),this.statusCallbacks.forEach(t=>t("idle"))})),this.isSpeaking||(this.isSpeaking=!0,this.statusCallbacks.forEach(t=>t("speaking")),this.startBargeInMonitoring().catch(()=>{})),this.playbackManager.enqueue(e))}stopPlayback(){!this.isProcessing&&!this.isSpeaking||(this.cancelCurrentPlayback(),this.statusCallbacks.forEach(e=>e("idle")))}cancelCurrentPlayback(){this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.src="",this.currentAudio=null),this.currentAudioUrl&&(URL.revokeObjectURL(this.currentAudioUrl),this.currentAudioUrl=null),this.playbackManager&&(this.playbackManager.flush(),this.playbackManager=null),this.currentRequestId&&this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"cancel",requestId:this.currentRequestId})),this.currentRequestId=null,this.isProcessing=!1,this.isSpeaking=!1}async startListening(){var e,t,o,n;try{if(this.isProcessing||this.isSpeaking)if(this.interruptionMode!=="none")this.cancelCurrentPlayback();else return;if(!this.mediaStream){let l=this.interruptionMode==="barge-in"?{audio:{echoCancellation:!0,noiseSuppression:!0}}:{audio:!0};this.mediaStream=await navigator.mediaDevices.getUserMedia(l)}let a=this.w;this.audioContext||(this.audioContext=new(a.AudioContext||a.webkitAudioContext));let s=this.audioContext,i=(t=(e=this.config)==null?void 0:e.pauseDuration)!=null?t:2e3,d=(n=(o=this.config)==null?void 0:o.silenceThreshold)!=null?n:.01;this.vad.start(s,this.mediaStream,"silence",{threshold:d,duration:i},()=>this.stopListening()),this.mediaRecorder=new MediaRecorder(this.mediaStream),this.audioChunks=[],this.mediaRecorder.ondataavailable=l=>{l.data.size>0&&this.audioChunks.push(l.data)},this.mediaRecorder.onstop=async()=>{var l;if(this.audioChunks.length>0){this.isProcessing=!0,this.statusCallbacks.forEach(p=>p("processing")),this.processingStartCallbacks.forEach(p=>p());let u=((l=this.mediaRecorder)==null?void 0:l.mimeType)||"audio/webm",f=new Blob(this.audioChunks,{type:u});await this.sendAudio(f),this.audioChunks=[]}},this.mediaRecorder.start(1e3),this.statusCallbacks.forEach(l=>l("listening"))}catch(a){throw this.errorCallbacks.forEach(s=>s(a)),this.statusCallbacks.forEach(s=>s("error")),a}}async stopListening(){this.vad.stop(),this.mediaRecorder&&(this.interruptionMode!=="barge-in"&&this.mediaRecorder.stream.getTracks().forEach(e=>e.stop()),this.mediaRecorder.stop(),this.mediaRecorder=null),this.interruptionMode!=="barge-in"&&(this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>e.stop()),this.mediaStream=null),this.audioContext&&(await this.audioContext.close(),this.audioContext=null)),this.statusCallbacks.forEach(e=>e("idle"))}async startBargeInMonitoring(){var a,s;if(this.interruptionMode!=="barge-in")return;let e=this.w;if(!this.mediaStream&&e&&(this.mediaStream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0}})),!this.audioContext&&e&&(this.audioContext=new(e.AudioContext||e.webkitAudioContext)),!this.audioContext||!this.mediaStream)return;let t=this.audioContext,o=(s=(a=this.config)==null?void 0:a.silenceThreshold)!=null?s:.01;this.vad.start(t,this.mediaStream,"speech",{threshold:o,duration:200},()=>this.handleBargeIn())}handleBargeIn(){this.cancelCurrentPlayback(),this.startListening().catch(e=>{this.errorCallbacks.forEach(t=>t(e instanceof Error?e:new Error(String(e))))})}generateRequestId(){return"vreq_"+Math.random().toString(36).substring(2,10)+Date.now().toString(36)}async sendAudio(e){var t;if(!this.ws||this.ws.readyState!==WebSocket.OPEN){this.errorCallbacks.forEach(o=>o(new Error("WebSocket not connected"))),this.statusCallbacks.forEach(o=>o("error"));return}try{let o=await this.blobToBase64(e),n=this.getFormatFromMimeType(e.type),a=this.generateRequestId();this.currentRequestId=a,this.ws.send(JSON.stringify({type:"audio_input",audio:o,format:n,sampleRate:16e3,voiceId:(t=this.config)==null?void 0:t.voiceId,requestId:a}))}catch(o){this.errorCallbacks.forEach(n=>n(o)),this.statusCallbacks.forEach(n=>n("error"))}}getFormatFromMimeType(e){return e.includes("wav")?"wav":e.includes("mpeg")||e.includes("mp3")?"mp3":"webm"}blobToBase64(e){return new Promise((t,o)=>{let n=new FileReader;n.onload=()=>{let s=n.result.split(",")[1];t(s)},n.onerror=o,n.readAsDataURL(e)})}async playAudio(e){if(!e.base64)return;let t=atob(e.base64),o=new Uint8Array(t.length);for(let l=0;l<t.length;l++)o[l]=t.charCodeAt(l);let n=e.format||"mp3",a=n==="mp3"?"audio/mpeg":`audio/${n}`,s=new Blob([o],{type:a}),i=URL.createObjectURL(s),d=new Audio(i);this.currentAudio=d,this.currentAudioUrl=i,d.onended=()=>{URL.revokeObjectURL(i),this.currentAudio===d&&(this.currentAudio=null,this.currentAudioUrl=null,this.isSpeaking=!1,this.statusCallbacks.forEach(l=>l("idle")))},await d.play()}onResult(e){this.resultCallbacks.push(e)}onError(e){this.errorCallbacks.push(e)}onStatusChange(e){this.statusCallbacks.push(e)}onProcessingStart(e){this.processingStartCallbacks.push(e)}async disconnect(){if(this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.src="",this.currentAudio=null),this.currentAudioUrl&&(URL.revokeObjectURL(this.currentAudioUrl),this.currentAudioUrl=null),this.playbackManager&&(await this.playbackManager.destroy(),this.playbackManager=null),this.currentRequestId=null,this.isSpeaking=!1,this.vad.stop(),await this.stopListening(),this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>e.stop()),this.mediaStream=null),this.audioContext&&(await this.audioContext.close(),this.audioContext=null),this.ws){try{this.ws.close()}catch{}this.ws=null}this.statusCallbacks.forEach(e=>e("disconnected"))}sendHeartbeat(){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"ping"}))}};var va=class{constructor(e={}){this.config=e;this.type="browser";this.recognition=null;this.resultCallbacks=[];this.errorCallbacks=[];this.statusCallbacks=[];this.isListening=!1;this.w=typeof window!="undefined"?window:void 0}async connect(){this.statusCallbacks.forEach(e=>e("connected"))}async startListening(){var e,t;try{if(this.isListening)throw new Error("Already listening");if(!this.w)throw new Error("Window object not available");let o=this.w.SpeechRecognition||this.w.webkitSpeechRecognition;if(!o)throw new Error("Browser speech recognition not supported");this.recognition=new o,this.recognition.lang=((e=this.config)==null?void 0:e.language)||"en-US",this.recognition.continuous=((t=this.config)==null?void 0:t.continuous)||!1,this.recognition.interimResults=!0,this.recognition.onresult=n=>{var i;let a=Array.from(n.results).map(d=>d[0]).map(d=>d.transcript).join(""),s=n.results[n.results.length-1].isFinal;this.resultCallbacks.forEach(d=>d({text:a,confidence:s?.8:.5,provider:"browser"})),s&&!((i=this.config)!=null&&i.continuous)&&this.stopListening()},this.recognition.onerror=n=>{this.errorCallbacks.forEach(a=>a(new Error(n.error))),this.statusCallbacks.forEach(a=>a("error"))},this.recognition.onstart=()=>{this.isListening=!0,this.statusCallbacks.forEach(n=>n("listening"))},this.recognition.onend=()=>{this.isListening=!1,this.statusCallbacks.forEach(n=>n("idle"))},this.recognition.start()}catch(o){throw this.errorCallbacks.forEach(n=>n(o)),this.statusCallbacks.forEach(n=>n("error")),o}}async stopListening(){this.recognition&&(this.recognition.stop(),this.recognition=null),this.isListening=!1,this.statusCallbacks.forEach(e=>e("idle"))}onResult(e){this.resultCallbacks.push(e)}onError(e){this.errorCallbacks.push(e)}onStatusChange(e){this.statusCallbacks.push(e)}async disconnect(){await this.stopListening(),this.statusCallbacks.forEach(e=>e("disconnected"))}static isSupported(){return"SpeechRecognition"in window||"webkitSpeechRecognition"in window}};function Ca(r){switch(r.type){case"runtype":if(!r.runtype)throw new Error("Runtype voice provider requires configuration");return new Ys(r.runtype);case"browser":if(!va.isSupported())throw new Error("Browser speech recognition not supported");return new va(r.browser||{});case"custom":throw new Error("Custom voice providers not yet implemented");default:throw new Error(`Unknown voice provider type: ${r.type}`)}}function ul(r){if((r==null?void 0:r.type)==="runtype"&&r.runtype)return Ca({type:"runtype",runtype:r.runtype});if(va.isSupported())return Ca({type:"browser",browser:(r==null?void 0:r.browser)||{language:"en-US"}});throw new Error("No supported voice providers available")}function Js(r){try{return ul(r),!0}catch{return!1}}var Av=["apiUrl","clientToken","flowId","agent","agentOptions","headers","getHeaders","webmcp","streamParser","parserType","contextProviders","requestMiddleware","customFetch","parseSSEEvent","onSessionInit","onSessionExpired","getStoredSessionId","setStoredSessionId"];function Sv(r,e){return Av.some(t=>r[t]!==e[t])}function fx(r,e){let t=r instanceof Error?r:new Error(String(r));if(typeof e=="string")return e;if(typeof e=="function")return e(t);let o="Sorry \u2014 I couldn't reach the assistant. The chat service didn't respond. Please check that your proxy or backend is running and reachable, then try again.";return t.message?`${o}
|
|
60
61
|
|
|
61
|
-
_Details: ${t.message}_`:n}var _s=r=>({isError:!0,content:[{type:"text",text:r}]}),Fh=(r,e="WebMCP tool execution failed.")=>r instanceof Error&&r.message?r.message:typeof r=="string"&&r?r:e,_a=class r{constructor(e={},t){this.config=e;this.callbacks=t;this.status="idle";this.streaming=!1;this.abortController=null;this.sequenceCounter=Date.now();this.clientSession=null;this.agentExecution=null;this.artifacts=new Map;this.selectedArtifactId=null;this.webMcpInflightKeys=new Set;this.webMcpResolvedKeys=new Set;this.webMcpResolveControllers=new Set;this.webMcpEpoch=0;this.webMcpApprovalResolvers=new Map;this.webMcpApprovalSeq=0;this.webMcpAwaitBatches=new Map;this.voiceProvider=null;this.voiceActive=!1;this.voiceStatus="disconnected";this.pendingVoiceUserMessageId=null;this.pendingVoiceAssistantMessageId=null;this.ttsSpokenMessageIds=new Set;this.handleEvent=e=>{var t,n,o,a,s,i,d,l;if(e.type==="message"){this.upsertMessage(e.message);let p=e.message.toolCall;((t=e.message.agentMetadata)==null?void 0:t.awaitingLocalTool)===!0&&(p!=null&&p.name)&&Bo(p.name)&&this.enqueueWebMcpAwait(e.message),(n=e.message.agentMetadata)!=null&&n.executionId&&(this.agentExecution?e.message.agentMetadata.iteration!==void 0&&(this.agentExecution.currentIteration=e.message.agentMetadata.iteration):this.agentExecution={executionId:e.message.agentMetadata.executionId,agentId:"",agentName:(o=e.message.agentMetadata.agentName)!=null?o:"",status:"running",currentIteration:(a=e.message.agentMetadata.iteration)!=null?a:0,maxTurns:0})}else if(e.type==="status"){if(this.setStatus(e.status),e.status==="connecting")this.setStreaming(!0);else if(e.status==="idle"||e.status==="error"){this.webMcpResolveControllers.size===0&&(this.setStreaming(!1),this.abortController=null);let p=this.webMcpAwaitBatches.size>0||this.webMcpResolveControllers.size>0;((s=this.agentExecution)==null?void 0:s.status)==="running"&&(e.status==="error"?this.agentExecution.status="error":p||(this.agentExecution.status="complete")),this.scheduleWebMcpBatchFlush()}}else e.type==="error"?(this.setStatus("error"),this.webMcpResolveControllers.size===0&&(this.setStreaming(!1),this.abortController=null),((i=this.agentExecution)==null?void 0:i.status)==="running"&&(this.agentExecution.status="error"),(l=(d=this.callbacks).onError)==null||l.call(d,e.error)):(e.type==="artifact_start"||e.type==="artifact_delta"||e.type==="artifact_update"||e.type==="artifact_complete")&&this.applyArtifactStreamEvent(e)};var n,o;this.messages=[...(n=e.initialMessages)!=null?n:[]].map(a=>{var s;return{...a,sequence:(s=a.sequence)!=null?s:this.nextSequence()}}),this.messages=this.sortMessages(this.messages),this.client=new da(e),this.wireDefaultWebMcpConfirm();for(let a of(o=e.initialArtifacts)!=null?o:[])this.artifacts.set(a.id,{...a,status:"complete"});e.initialSelectedArtifactId!=null&&(this.selectedArtifactId=e.initialSelectedArtifactId),this.messages.length&&this.callbacks.onMessagesChanged([...this.messages]),this.artifacts.size>0&&this.emitArtifactsState(),this.callbacks.onStatusChanged(this.status)}setSSEEventCallback(e){this.client.setSSEEventCallback(e)}isClientTokenMode(){return this.client.isClientTokenMode()}isAgentMode(){return this.client.isAgentMode()}getAgentExecution(){return this.agentExecution}isAgentExecuting(){var e;return((e=this.agentExecution)==null?void 0:e.status)==="running"}isVoiceSupported(){var e;return Os((e=this.config.voiceRecognition)==null?void 0:e.provider)}isVoiceActive(){return this.voiceActive}getVoiceStatus(){return this.voiceStatus}getVoiceInterruptionMode(){var e;return(e=this.voiceProvider)!=null&&e.getInterruptionMode?this.voiceProvider.getInterruptionMode():"none"}stopVoicePlayback(){var e;(e=this.voiceProvider)!=null&&e.stopPlayback&&this.voiceProvider.stopPlayback()}isBargeInActive(){var e,t,n;return(n=(t=(e=this.voiceProvider)==null?void 0:e.isBargeInActive)==null?void 0:t.call(e))!=null?n:!1}async deactivateBargeIn(){var e;(e=this.voiceProvider)!=null&&e.deactivateBargeIn&&await this.voiceProvider.deactivateBargeIn()}setupVoice(e){var t,n,o;try{let a=e||this.getVoiceConfigFromConfig();if(!a)throw new Error("Voice configuration not provided");this.voiceProvider=ua(a);let s=(t=this.config.voiceRecognition)!=null?t:{},i=(n=s.processingText)!=null?n:"\u{1F3A4} Processing voice...",d=(o=s.processingErrorText)!=null?o:"Voice processing failed. Please try again.";this.voiceProvider.onProcessingStart&&this.voiceProvider.onProcessingStart(()=>{let l=this.injectMessage({role:"user",content:i,streaming:!1,voiceProcessing:!0});this.pendingVoiceUserMessageId=l.id;let p=this.injectMessage({role:"assistant",content:"",streaming:!0,voiceProcessing:!0});this.pendingVoiceAssistantMessageId=p.id,this.setStreaming(!0)}),this.voiceProvider.onResult(l=>{var p,f,u,m,v,x;if(l.provider==="browser")l.text&&l.text.trim()&&this.sendMessage(l.text,{viaVoice:!0});else if(l.provider==="runtype"){this.pendingVoiceUserMessageId&&((p=l.transcript)!=null&&p.trim())?this.upsertMessage({id:this.pendingVoiceUserMessageId,role:"user",content:l.transcript.trim(),createdAt:new Date().toISOString(),streaming:!1,voiceProcessing:!1}):(f=l.transcript)!=null&&f.trim()&&this.injectUserMessage({content:l.transcript.trim()}),this.pendingVoiceAssistantMessageId&&((u=l.text)!=null&&u.trim())?this.upsertMessage({id:this.pendingVoiceAssistantMessageId,role:"assistant",content:l.text.trim(),createdAt:new Date().toISOString(),streaming:!1,voiceProcessing:!1}):(m=l.text)!=null&&m.trim()&&this.injectAssistantMessage({content:l.text.trim()});{let S=(x=this.pendingVoiceAssistantMessageId)!=null?x:(v=[...this.messages].reverse().find(M=>M.role==="assistant"))==null?void 0:v.id;S&&this.ttsSpokenMessageIds.add(S)}this.setStreaming(!1),this.pendingVoiceUserMessageId=null,this.pendingVoiceAssistantMessageId=null}}),this.voiceProvider.onError(l=>{console.error("Voice error:",l),this.pendingVoiceAssistantMessageId&&(this.upsertMessage({id:this.pendingVoiceAssistantMessageId,role:"assistant",content:d,createdAt:new Date().toISOString(),streaming:!1,voiceProcessing:!1}),this.setStreaming(!1),this.pendingVoiceUserMessageId=null,this.pendingVoiceAssistantMessageId=null)}),this.voiceProvider.onStatusChange(l=>{var p,f;this.voiceStatus=l,this.voiceActive=l==="listening",(f=(p=this.callbacks).onVoiceStatusChanged)==null||f.call(p,l)}),this.voiceProvider.connect()}catch(a){console.error("Failed to setup voice:",a)}}async toggleVoice(){if(!this.voiceProvider){console.error("Voice not configured");return}if(this.voiceActive)await this.voiceProvider.stopListening();else{this.stopSpeaking();try{await this.voiceProvider.startListening()}catch(e){console.error("Failed to start voice:",e)}}}cleanupVoice(){this.voiceProvider&&(this.voiceProvider.disconnect(),this.voiceProvider=null),this.voiceActive=!1,this.voiceStatus="disconnected"}getVoiceConfigFromConfig(){var t,n,o,a,s,i,d,l,p;if(!((t=this.config.voiceRecognition)!=null&&t.provider))return;let e=this.config.voiceRecognition.provider;switch(e.type){case"runtype":return{type:"runtype",runtype:{agentId:((n=e.runtype)==null?void 0:n.agentId)||"",clientToken:((o=e.runtype)==null?void 0:o.clientToken)||"",host:(a=e.runtype)==null?void 0:a.host,voiceId:(s=e.runtype)==null?void 0:s.voiceId,pauseDuration:(i=e.runtype)==null?void 0:i.pauseDuration,silenceThreshold:(d=e.runtype)==null?void 0:d.silenceThreshold}};case"browser":return{type:"browser",browser:{language:((l=e.browser)==null?void 0:l.language)||"en-US",continuous:(p=e.browser)==null?void 0:p.continuous}};default:return}}async initClientSession(){var e,t;if(!this.isClientTokenMode())return null;try{let n=await this.client.initSession();return this.setClientSession(n),n}catch(n){return(t=(e=this.callbacks).onError)==null||t.call(e,n instanceof Error?n:new Error(String(n))),null}}setClientSession(e){if(this.clientSession=e,e.config.welcomeMessage&&this.messages.length===0){let t={id:`welcome-${Date.now()}`,role:"assistant",content:e.config.welcomeMessage,createdAt:new Date().toISOString(),sequence:this.nextSequence()};this.appendMessage(t)}}getClientSession(){var e;return(e=this.clientSession)!=null?e:this.client.getClientSession()}isSessionValid(){let e=this.getClientSession();return e?new Date<e.expiresAt:!1}clearClientSession(){this.clientSession=null,this.client.clearClientSession()}getClient(){return this.client}async submitMessageFeedback(e,t){return this.client.submitMessageFeedback(e,t)}async submitCSATFeedback(e,t){return this.client.submitCSATFeedback(e,t)}async submitNPSFeedback(e,t){return this.client.submitNPSFeedback(e,t)}updateConfig(e){this.abortWebMcpResolves(),this.webMcpInflightKeys.clear(),this.webMcpResolvedKeys.clear();let t=this.client.getSSEEventCallback();this.config={...this.config,...e},this.client=new da(this.config),this.wireDefaultWebMcpConfirm(),t&&this.client.setSSEEventCallback(t)}getMessages(){return[...this.messages]}getStatus(){return this.status}isStreaming(){return this.streaming}injectTestEvent(e){this.handleEvent(e)}injectMessage(e){let{role:t,content:n,llmContent:o,contentParts:a,id:s,createdAt:i,sequence:d,streaming:l=!1,voiceProcessing:p,rawContent:f}=e,m={id:s!=null?s:t==="user"?Oa():t==="assistant"?ca():`system-${Date.now()}-${Math.random().toString(16).slice(2)}`,role:t,content:n,createdAt:i!=null?i:new Date().toISOString(),sequence:d!=null?d:this.nextSequence(),streaming:l,...o!==void 0&&{llmContent:o},...a!==void 0&&{contentParts:a},...p!==void 0&&{voiceProcessing:p},...f!==void 0&&{rawContent:f}};return this.upsertMessage(m),m}injectAssistantMessage(e){return this.injectMessage({...e,role:"assistant"})}injectUserMessage(e){return this.injectMessage({...e,role:"user"})}injectSystemMessage(e){return this.injectMessage({...e,role:"system"})}injectMessageBatch(e){let t=[];for(let n of e){let{role:o,content:a,llmContent:s,contentParts:i,id:d,createdAt:l,sequence:p,streaming:f=!1,voiceProcessing:u,rawContent:m}=n,x={id:d!=null?d:o==="user"?Oa():o==="assistant"?ca():`system-${Date.now()}-${Math.random().toString(16).slice(2)}`,role:o,content:a,createdAt:l!=null?l:new Date().toISOString(),sequence:p!=null?p:this.nextSequence(),streaming:f,...s!==void 0&&{llmContent:s},...i!==void 0&&{contentParts:i},...u!==void 0&&{voiceProcessing:u},...m!==void 0&&{rawContent:m}};t.push(x)}return this.messages=this.sortMessages([...this.messages,...t]),this.callbacks.onMessagesChanged([...this.messages]),t}injectComponentDirective(e){let{component:t,props:n={},text:o="",llmContent:a,id:s,createdAt:i,sequence:d}=e,l={text:o,component:t,props:n};return this.injectMessage({role:"assistant",content:o,rawContent:JSON.stringify(l),...a!==void 0&&{llmContent:a},...s!==void 0&&{id:s},...i!==void 0&&{createdAt:i},...d!==void 0&&{sequence:d}})}async sendMessage(e,t){var l,p,f,u,m;let n=e.trim();if(!n&&(!(t!=null&&t.contentParts)||t.contentParts.length===0))return;this.stopSpeaking(),(l=this.abortController)==null||l.abort(),this.abortWebMcpResolves();let o=Oa(),a=ca(),s={id:o,role:"user",content:n||Ki,createdAt:new Date().toISOString(),sequence:this.nextSequence(),viaVoice:(t==null?void 0:t.viaVoice)||!1,...(t==null?void 0:t.contentParts)&&t.contentParts.length>0&&{contentParts:t.contentParts}};this.appendMessage(s),this.setStreaming(!0);let i=new AbortController;this.abortController=i;let d=[...this.messages];try{await this.client.dispatch({messages:d,signal:i.signal,assistantMessageId:a},this.handleEvent)}catch(v){let x=v instanceof Error&&(v.name==="AbortError"||v.message.includes("aborted")||v.message.includes("abort"));if(!x){let S=Dh(v,this.config.errorMessage);if(S){let M={id:a,role:"assistant",createdAt:new Date().toISOString(),content:S,sequence:this.nextSequence()};this.appendMessage(M)}}this.setStatus("idle"),this.setStreaming(!1),this.abortController=null,x||(v instanceof Error?(f=(p=this.callbacks).onError)==null||f.call(p,v):(m=(u=this.callbacks).onError)==null||m.call(u,new Error(String(v))))}}async continueConversation(){var o,a,s,i,d;if(this.streaming)return;(o=this.abortController)==null||o.abort();let e=ca();this.setStreaming(!0);let t=new AbortController;this.abortController=t;let n=[...this.messages];try{await this.client.dispatch({messages:n,signal:t.signal,assistantMessageId:e},this.handleEvent)}catch(l){let p=l instanceof Error&&(l.name==="AbortError"||l.message.includes("aborted")||l.message.includes("abort"));if(!p){let f=Dh(l,this.config.errorMessage);if(f){let u={id:e,role:"assistant",createdAt:new Date().toISOString(),content:f,sequence:this.nextSequence()};this.appendMessage(u)}}this.setStatus("idle"),this.setStreaming(!1),this.abortController=null,p||(l instanceof Error?(s=(a=this.callbacks).onError)==null||s.call(a,l):(d=(i=this.callbacks).onError)==null||d.call(i,new Error(String(l))))}}async connectStream(e,t){var o,a,s;if(this.streaming&&!(t!=null&&t.allowReentry))return;t!=null&&t.allowReentry||(o=this.abortController)==null||o.abort();let n=!1;for(let i of this.messages)i.streaming&&(i.streaming=!1,n=!0);n&&this.callbacks.onMessagesChanged([...this.messages]),this.setStreaming(!0);try{await this.client.processStream(e,this.handleEvent,t==null?void 0:t.assistantMessageId)}catch(i){this.setStatus("error"),this.webMcpResolveControllers.size===0&&(this.setStreaming(!1),this.abortController=null),(s=(a=this.callbacks).onError)==null||s.call(a,i instanceof Error?i:new Error(String(i)))}}wireDefaultWebMcpConfirm(){let e=this.config.webmcp;(e==null?void 0:e.enabled)===!0&&!e.onConfirm&&this.client.setWebMcpConfirmHandler(t=>this.requestWebMcpApproval(t))}requestWebMcpApproval(e){var o,a,s;try{if(((a=(o=this.config.webmcp)==null?void 0:o.autoApprove)==null?void 0:a.call(o,e))===!0)return Promise.resolve(!0)}catch{}let t={id:`webmcp-${++this.webMcpApprovalSeq}`,status:"pending",agentId:"",executionId:"",toolName:e.toolName,toolType:"webmcp",description:(s=e.description)!=null?s:`Allow the assistant to run ${e.toolName}?`,parameters:e.args},n=`approval-${t.id}`;return this.upsertMessage({id:n,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!1,variant:"approval",approval:t}),new Promise(i=>{this.webMcpApprovalResolvers.set(n,i)})}resolveWebMcpApproval(e,t){let n=this.webMcpApprovalResolvers.get(e);if(!n)return;this.webMcpApprovalResolvers.delete(e);let o=this.messages.find(a=>a.id===e);o!=null&&o.approval&&this.upsertMessage({...o,approval:{...o.approval,status:t,resolvedAt:Date.now()}}),n(t==="approved")}async resolveApproval(e,t,n){var p,f,u,m,v;let o=`approval-${e.id}`,a={...e,status:t,resolvedAt:Date.now()},s=this.messages.find(x=>x.id===o),i={id:o,role:"assistant",content:"",createdAt:(p=s==null?void 0:s.createdAt)!=null?p:new Date().toISOString(),...(s==null?void 0:s.sequence)!==void 0?{sequence:s.sequence}:{},streaming:!1,variant:"approval",approval:a};this.upsertMessage(i),(f=this.abortController)==null||f.abort(),this.abortController=new AbortController,this.setStreaming(!0);let d=this.config.approval,l=d&&typeof d=="object"?d.onDecision:void 0;try{let x;if(l?x=await l({approvalId:e.id,executionId:e.executionId,agentId:e.agentId,toolName:e.toolName},t,n):x=await this.client.resolveApproval({agentId:e.agentId,executionId:e.executionId,approvalId:e.id},t),x){let S=null;if(x instanceof Response){if(!x.ok){let M=await x.json().catch(()=>null);throw new Error((u=M==null?void 0:M.error)!=null?u:`Approval request failed: ${x.status}`)}S=x.body}else x instanceof ReadableStream&&(S=x);S?await this.connectStream(S,{allowReentry:!0}):(t==="denied"&&this.appendMessage({id:`denial-${e.id}`,role:"assistant",content:"Tool execution was denied by user.",createdAt:new Date().toISOString(),streaming:!1,sequence:this.nextSequence()}),this.setStreaming(!1),this.abortController=null)}else this.setStreaming(!1),this.abortController=null}catch(x){let S=x instanceof Error&&(x.name==="AbortError"||x.message.includes("aborted")||x.message.includes("abort"));this.setStreaming(!1),this.abortController=null,S||(v=(m=this.callbacks).onError)==null||v.call(m,x instanceof Error?x:new Error(String(x)))}}persistAskUserQuestionProgress(e,t){let n=this.messages.find(o=>o.id===e.id);n&&this.upsertMessage({...n,agentMetadata:{...n.agentMetadata,askUserQuestionAnswers:t.answers,askUserQuestionIndex:t.currentIndex}})}markAskUserQuestionResolved(e,t){let n=this.messages.find(o=>o.id===e.id);n&&this.upsertMessage({...n,agentMetadata:{...n.agentMetadata,awaitingLocalTool:!1,askUserQuestionAnswered:!0,...t?{askUserQuestionAnswers:t}:{}}})}async resolveAskUserQuestion(e,t){var p,f,u,m,v,x,S,M,E,k,h,w;let n=this.messages.find(C=>C.id===e.id);if(((p=n==null?void 0:n.agentMetadata)==null?void 0:p.askUserQuestionAnswered)===!0)return;let o=(f=e.agentMetadata)==null?void 0:f.executionId,a=(u=e.toolCall)==null?void 0:u.name;if(!o||!a){(v=(m=this.callbacks).onError)==null||v.call(m,new Error("resolveAskUserQuestion: message is missing executionId or toolCall.name"));return}let s=typeof t=="string"?void 0:t;if(s===void 0&&typeof t=="string"){let C=(x=e.toolCall)==null?void 0:x.args,T=Array.isArray(C==null?void 0:C.questions)?C.questions:[];if(T.length===1){let W=typeof((S=T[0])==null?void 0:S.question)=="string"?T[0].question:"";W&&(s={[W]:t})}}this.markAskUserQuestionResolved(e,s),(M=this.abortController)==null||M.abort(),this.abortController=new AbortController,this.setStreaming(!0);let i=e.toolCall.id,d=(E=e.toolCall)==null?void 0:E.args,l=Array.isArray(d==null?void 0:d.questions)?d.questions:[];if(l.length===0){let C=typeof t=="string"?t:Object.entries(t).map(([T,W])=>`${T}: ${Array.isArray(W)?W.join(", "):W}`).join(" | ");this.appendMessage({id:`ask-user-answer-${i}`,role:"user",content:C,createdAt:new Date().toISOString(),streaming:!1,sequence:this.nextSequence()})}else{let C=s!=null?s:{};l.forEach((T,W)=>{let R=typeof(T==null?void 0:T.question)=="string"?T.question:"";if(!R)return;let I=C[R],N=Array.isArray(I)?I.join(", "):typeof I=="string"?I:"";this.appendMessage({id:`ask-user-q-${i}-${W}`,role:"assistant",content:R,createdAt:new Date().toISOString(),streaming:!1,sequence:this.nextSequence()}),this.appendMessage({id:`ask-user-a-${i}-${W}`,role:"user",content:N||"*Skipped*",createdAt:new Date().toISOString(),streaming:!1,sequence:this.nextSequence()})})}try{let C=await this.client.resumeFlow(o,{[a]:t});if(!C.ok){let T=await C.json().catch(()=>null);throw new Error((k=T==null?void 0:T.error)!=null?k:`Resume failed: ${C.status}`)}C.body?await this.connectStream(C.body,{allowReentry:!0}):(this.setStreaming(!1),this.abortController=null)}catch(C){let T=C instanceof Error&&(C.name==="AbortError"||C.message.includes("aborted")||C.message.includes("abort"));this.setStreaming(!1),this.abortController=null,T||(w=(h=this.callbacks).onError)==null||w.call(h,C instanceof Error?C:new Error(String(C)))}}enqueueWebMcpAwait(e){var a,s;let t=(a=e.agentMetadata)==null?void 0:a.executionId,n=(s=e.toolCall)==null?void 0:s.id;if(!t||!n){let i=this.webMcpEpoch;queueMicrotask(()=>{i===this.webMcpEpoch&&this.resolveWebMcpToolCall(e)});return}let o=this.webMcpAwaitBatches.get(t);o||(o={snapshots:[],seen:new Set},this.webMcpAwaitBatches.set(t,o)),!o.seen.has(n)&&(o.seen.add(n),o.snapshots.push(e))}scheduleWebMcpBatchFlush(){if(this.webMcpAwaitBatches.size===0)return;let e=this.webMcpEpoch;queueMicrotask(()=>{if(e===this.webMcpEpoch)for(let t of[...this.webMcpAwaitBatches.keys()])this.flushWebMcpAwaitBatch(t)})}flushWebMcpAwaitBatch(e){let t=this.webMcpAwaitBatches.get(e);if(!t)return;this.webMcpAwaitBatches.delete(e);let{snapshots:n}=t;n.length===1?this.resolveWebMcpToolCall(n[0]):n.length>1&&this.resolveWebMcpToolCallBatch(e,n)}resolveWebMcpToolStartedAt(e){var o,a;let t=this.messages.find(s=>s.id===e.id),n=[(o=t==null?void 0:t.toolCall)==null?void 0:o.startedAt,(a=e.toolCall)==null?void 0:a.startedAt];for(let s of n)if(typeof s=="number"&&Number.isFinite(s))return s;return Date.now()}markWebMcpToolRunning(e){let t=this.resolveWebMcpToolStartedAt(e);return this.upsertMessage({...e,streaming:!0,agentMetadata:{...e.agentMetadata,awaitingLocalTool:!1},toolCall:e.toolCall?{...e.toolCall,status:"running",startedAt:t,completedAt:void 0,duration:void 0,durationMs:void 0}:e.toolCall}),t}markWebMcpToolComplete(e,t,n,o=Date.now()){this.messages.some(a=>a.id===e.id)&&this.upsertMessage({...e,streaming:!1,agentMetadata:{...e.agentMetadata,awaitingLocalTool:!1},toolCall:e.toolCall?{...e.toolCall,status:"complete",result:t,startedAt:n,completedAt:o,duration:void 0,durationMs:Math.max(0,o-n)}:e.toolCall})}async resolveWebMcpToolCallBatch(e,t){var d,l,p;let n=[],o=[],a=new AbortController;this.webMcpResolveControllers.add(a),this.setStreaming(!0);let s=await Promise.all(t.map(async f=>{var h,w,C,T,W,R,I;let u=(h=f.toolCall)==null?void 0:h.name,m=(w=f.toolCall)==null?void 0:w.id;if(!u||!m)return null;let v=`${e}:${m}`;if(this.webMcpInflightKeys.has(v)||this.webMcpResolvedKeys.has(v))return null;this.webMcpInflightKeys.add(v),n.push(v);let x=this.markWebMcpToolRunning(f),S=new AbortController;this.webMcpResolveControllers.add(S),o.push(S);let M=(T=(C=f.agentMetadata)==null?void 0:C.webMcpToolCallId)!=null?T:u,E=this.client.executeWebMcpToolCall(u,(W=f.toolCall)==null?void 0:W.args,S.signal),k;if(!E)k={isError:!0,content:[{type:"text",text:"WebMCP not enabled on this widget."}]};else try{k=await E}catch(N){let V=N instanceof Error&&(N.name==="AbortError"||N.message.includes("aborted")||N.message.includes("abort"));return V||(I=(R=this.callbacks).onError)==null||I.call(R,N instanceof Error?N:new Error(String(N))),this.markWebMcpToolComplete(f,_s(V?"Aborted by cancel()":Fh(N)),x),this.webMcpInflightKeys.delete(v),null}return S.signal.aborted?(this.markWebMcpToolComplete(f,_s("Aborted by cancel()"),x),this.webMcpInflightKeys.delete(v),null):{dedupeKey:v,resumeKey:M,output:k,toolMessage:f,startedAt:x,completedAt:Date.now()}})),i=[];try{if(i=s.filter(m=>m!==null),i.length===0)return;let f={};for(let m of i)f[m.resumeKey]=m.output;let u=await this.client.resumeFlow(e,f,{signal:a.signal});if(!u.ok){let m=await u.json().catch(()=>null);throw new Error((d=m==null?void 0:m.error)!=null?d:`Resume failed: ${u.status}`)}for(let m of i)this.webMcpResolvedKeys.add(m.dedupeKey),this.markWebMcpToolComplete(m.toolMessage,m.output,m.startedAt,m.completedAt);u.body&&await this.connectStream(u.body,{allowReentry:!0})}catch(f){if(!(f instanceof Error&&(f.name==="AbortError"||f.message.includes("aborted")||f.message.includes("abort"))))(p=(l=this.callbacks).onError)==null||p.call(l,f instanceof Error?f:new Error(String(f)));else for(let m of i)this.markWebMcpToolComplete(m.toolMessage,_s("Aborted by cancel()"),m.startedAt)}finally{for(let f of n)this.webMcpInflightKeys.delete(f);for(let f of o)this.webMcpResolveControllers.delete(f);this.webMcpResolveControllers.delete(a),this.webMcpResolveControllers.size===0&&!this.abortController&&this.setStreaming(!1)}}async resolveWebMcpToolCall(e){var m,v,x,S,M,E,k,h,w,C,T,W;let t=(m=e.agentMetadata)==null?void 0:m.executionId,n=(v=e.toolCall)==null?void 0:v.name,o=(x=e.toolCall)==null?void 0:x.id;if(!t){(M=(S=this.callbacks).onError)==null||M.call(S,new Error("WebMCP step_await missing executionId \u2014 dispatch left paused."));return}if(!n)return;if(!o){let R=`${t}:__no_tool_id__:${n}`;if(this.webMcpInflightKeys.has(R)||this.webMcpResolvedKeys.has(R))return;this.webMcpInflightKeys.add(R);try{await this.resumeWithToolOutput(t,n,{isError:!0,content:[{type:"text",text:"WebMCP step_await missing toolCall.id \u2014 cannot execute the page tool."}]}),this.webMcpResolvedKeys.add(R)}catch(I){(k=(E=this.callbacks).onError)==null||k.call(E,I instanceof Error?I:new Error(String(I)))}finally{this.webMcpInflightKeys.delete(R)}return}let a=`${t}:${o}`;if(this.webMcpInflightKeys.has(a)||this.webMcpResolvedKeys.has(a))return;this.webMcpInflightKeys.add(a);let s=this.markWebMcpToolRunning(e),i=new AbortController;this.webMcpResolveControllers.add(i);let{signal:d}=i;this.setStreaming(!0);let l=(h=e.toolCall)==null?void 0:h.args,p=this.client.executeWebMcpToolCall(n,l,d),f="execute",u=s;try{let R;if(p?R=await p:R={isError:!0,content:[{type:"text",text:"WebMCP not enabled on this widget."}]},u=Date.now(),d.aborted){this.markWebMcpToolComplete(e,_s("Aborted by cancel()"),s);return}let I=(C=(w=e.agentMetadata)==null?void 0:w.webMcpToolCallId)!=null?C:n;f="resume",await this.resumeWithToolOutput(t,I,R,{onHttpOk:()=>{this.webMcpResolvedKeys.add(a),this.markWebMcpToolComplete(e,R,s,u)},signal:d})}catch(R){let I=R instanceof Error&&(R.name==="AbortError"||R.message.includes("aborted")||R.message.includes("abort"));(f==="execute"||I||d.aborted)&&this.markWebMcpToolComplete(e,_s(I||d.aborted?"Aborted by cancel()":Fh(R)),s),I||(W=(T=this.callbacks).onError)==null||W.call(T,R instanceof Error?R:new Error(String(R)))}finally{this.webMcpInflightKeys.delete(a),this.webMcpResolveControllers.delete(i),this.webMcpResolveControllers.size===0&&!this.abortController&&this.setStreaming(!1)}}async resumeWithToolOutput(e,t,n,o){var s,i;let a=await this.client.resumeFlow(e,{[t]:n},{signal:o==null?void 0:o.signal});if(!a.ok){let d=await a.json().catch(()=>null);throw new Error((s=d==null?void 0:d.error)!=null?s:`Resume failed: ${a.status}`)}(i=o==null?void 0:o.onHttpOk)==null||i.call(o),a.body?await this.connectStream(a.body,{allowReentry:!0}):this.webMcpResolveControllers.size===0&&(this.setStreaming(!1),this.abortController=null)}abortWebMcpResolves(){for(let e of this.webMcpResolveControllers)e.abort();this.webMcpResolveControllers.clear();for(let e of[...this.webMcpApprovalResolvers.keys()])this.resolveWebMcpApproval(e,"denied");this.webMcpAwaitBatches.clear(),this.webMcpEpoch++}cancel(){var e;(e=this.abortController)==null||e.abort(),this.abortController=null,this.abortWebMcpResolves(),this.webMcpInflightKeys.clear(),this.stopSpeaking(),this.stopVoicePlayback(),this.setStreaming(!1),this.setStatus("idle")}clearMessages(){var e;this.stopSpeaking(),(e=this.abortController)==null||e.abort(),this.abortController=null,this.abortWebMcpResolves(),this.messages=[],this.agentExecution=null,this.clearArtifactState(),this.webMcpInflightKeys.clear(),this.webMcpResolvedKeys.clear(),this.client.resetClientToolsFingerprint(),this.setStreaming(!1),this.setStatus("idle"),this.callbacks.onMessagesChanged([...this.messages])}getArtifacts(){return[...this.artifacts.values()]}getArtifactById(e){return this.artifacts.get(e)}getSelectedArtifactId(){return this.selectedArtifactId}selectArtifact(e){this.selectedArtifactId=e,this.emitArtifactsState()}clearArtifacts(){this.clearArtifactState()}upsertArtifact(e){var o;let t=e.id||`art_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,9)}`;if(e.artifactType==="markdown"){let a={id:t,artifactType:"markdown",title:e.title,status:"complete",markdown:e.content};return this.artifacts.set(t,a),this.selectedArtifactId=t,this.emitArtifactsState(),a}let n={id:t,artifactType:"component",title:e.title,status:"complete",component:e.component,props:(o=e.props)!=null?o:{}};return this.artifacts.set(t,n),this.selectedArtifactId=t,this.emitArtifactsState(),n}clearArtifactState(){this.artifacts.size===0&&this.selectedArtifactId===null||(this.artifacts.clear(),this.selectedArtifactId=null,this.emitArtifactsState())}emitArtifactsState(){var e,t;(t=(e=this.callbacks).onArtifactsState)==null||t.call(e,{artifacts:[...this.artifacts.values()],selectedId:this.selectedArtifactId})}applyArtifactStreamEvent(e){var t,n;switch(e.type){case"artifact_start":{e.artifactType==="markdown"?this.artifacts.set(e.id,{id:e.id,artifactType:"markdown",title:e.title,status:"streaming",markdown:""}):this.artifacts.set(e.id,{id:e.id,artifactType:"component",title:e.title,status:"streaming",component:(t=e.component)!=null?t:"",props:{}}),this.selectedArtifactId=e.id;break}case"artifact_delta":{let o=this.artifacts.get(e.id);(o==null?void 0:o.artifactType)==="markdown"&&(o.markdown=((n=o.markdown)!=null?n:"")+e.artDelta);break}case"artifact_update":{let o=this.artifacts.get(e.id);(o==null?void 0:o.artifactType)==="component"&&(o.props={...o.props,...e.props},e.component&&(o.component=e.component));break}case"artifact_complete":{let o=this.artifacts.get(e.id);o&&(o.status="complete");break}default:return}this.emitArtifactsState()}hydrateMessages(e){var t;(t=this.abortController)==null||t.abort(),this.abortController=null,this.abortWebMcpResolves(),this.webMcpInflightKeys.clear(),this.webMcpResolvedKeys.clear(),this.messages=this.sortMessages(e.map(n=>{var o;return{...n,streaming:!1,sequence:(o=n.sequence)!=null?o:this.nextSequence()}})),this.setStreaming(!1),this.setStatus("idle"),this.callbacks.onMessagesChanged([...this.messages])}hydrateArtifacts(e,t=null){this.artifacts.clear();for(let n of e)this.artifacts.set(n.id,{...n,status:"complete"});this.selectedArtifactId=t,this.emitArtifactsState()}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.onStatusChanged(e))}setStreaming(e){if(this.streaming===e)return;let t=this.streaming;this.streaming=e,this.callbacks.onStreamingChanged(e),t&&!e&&this.speakLatestAssistantMessage()}speakLatestAssistantMessage(){let e=this.config.textToSpeech;if(!(e!=null&&e.enabled)||!(!e.provider||e.provider==="browser"||e.provider==="runtype"&&e.browserFallback))return;let n=[...this.messages].reverse().find(a=>a.role==="assistant"&&a.content&&!a.voiceProcessing);if(!n)return;if(this.ttsSpokenMessageIds.has(n.id)){this.ttsSpokenMessageIds.delete(n.id);return}let o=n.content;o.trim()&&this.speak(o,e)}speak(e,t){if(typeof window=="undefined"||!("speechSynthesis"in window))return;let n=window.speechSynthesis;n.cancel();let o=new SpeechSynthesisUtterance(e),a=n.getVoices();if(t.voice){let s=a.find(i=>i.name===t.voice);s&&(o.voice=s)}else a.length>0&&(o.voice=t.pickVoice?t.pickVoice(a):r.pickBestVoice(a));t.rate!==void 0&&(o.rate=t.rate),t.pitch!==void 0&&(o.pitch=t.pitch),setTimeout(()=>n.speak(o),50)}static pickBestVoice(e){var n;let t=["Microsoft Jenny Online (Natural) - English (United States)","Microsoft Aria Online (Natural) - English (United States)","Microsoft Guy Online (Natural) - English (United States)","Google US English","Google UK English Female","Ava (Premium)","Evan (Enhanced)","Samantha (Enhanced)","Samantha","Daniel","Karen","Microsoft David Desktop - English (United States)","Microsoft Zira Desktop - English (United States)"];for(let o of t){let a=e.find(s=>s.name===o);if(a)return a}return(n=e.find(o=>o.lang.startsWith("en")))!=null?n:e[0]}stopSpeaking(){typeof window!="undefined"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}appendMessage(e){let t=this.ensureSequence(e);this.messages=this.sortMessages([...this.messages,t]),this.callbacks.onMessagesChanged([...this.messages])}upsertMessage(e){let t=this.ensureSequence(e),n=this.messages.findIndex(o=>o.id===t.id);if(n===-1){this.appendMessage(t);return}this.messages=this.messages.map((o,a)=>{var p,f,u,m,v,x,S,M,E,k,h,w,C;if(a!==n)return o;let s={...o,...t};if(((p=o.agentMetadata)==null?void 0:p.askUserQuestionAnswered)===!0&&t.agentMetadata&&(s.agentMetadata={...t.agentMetadata,askUserQuestionAnswered:!0,...o.agentMetadata.askUserQuestionAnswers?{askUserQuestionAnswers:o.agentMetadata.askUserQuestionAnswers}:{},awaitingLocalTool:!1}),o.approval&&t.approval&&o.approval.id===t.approval.id){let T=o.approval,W=t.approval;s.approval={...T,...W,executionId:W.executionId||T.executionId,toolName:W.toolName||T.toolName,description:W.description||T.description,toolType:(f=W.toolType)!=null?f:T.toolType,reason:(u=W.reason)!=null?u:T.reason,parameters:(m=W.parameters)!=null?m:T.parameters}}let i=(v=t.toolCall)==null?void 0:v.name,d=(x=t.agentMetadata)==null?void 0:x.executionId,l=(S=t.toolCall)==null?void 0:S.id;if(i&&Bo(i)&&d&&l&&((M=t.agentMetadata)==null?void 0:M.awaitingLocalTool)===!0){let T=`${d}:${l}`,W=this.webMcpInflightKeys.has(T),R=this.webMcpResolvedKeys.has(T),I=(E=o.toolCall)==null?void 0:E.name,N=((k=o.agentMetadata)==null?void 0:k.executionId)===d&&((h=o.toolCall)==null?void 0:h.id)===l&&I!==void 0&&Bo(I)&&((w=o.toolCall)==null?void 0:w.status)==="complete";(W||R||N)&&(s.agentMetadata={...(C=s.agentMetadata)!=null?C:{},awaitingLocalTool:!1},s.toolCall=o.toolCall,s.streaming=o.streaming)}return s}),this.messages=this.sortMessages(this.messages),this.callbacks.onMessagesChanged([...this.messages])}ensureSequence(e){return e.sequence!==void 0?{...e}:{...e,sequence:this.nextSequence()}}nextSequence(){return this.sequenceCounter++}sortMessages(e){return[...e].sort((t,n)=>{var d,l;let o=new Date(t.createdAt).getTime(),a=new Date(n.createdAt).getTime();if(!Number.isNaN(o)&&!Number.isNaN(a)&&o!==a)return o-a;let s=(d=t.sequence)!=null?d:0,i=(l=n.sequence)!=null?l:0;return s!==i?s-i:t.id.localeCompare(n.id)})}};var y=(r,e)=>{let t=document.createElement(r);return e&&(t.className=e),t},to=(r,e,t)=>{let n=r.createElement(e);return t&&(n.className=t),n};var Ed=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"}]];var Ld=[["path",{d:"M12 5v14"}],["path",{d:"m19 12-7 7-7-7"}]];var Pd=[["path",{d:"m12 19-7-7 7-7"}],["path",{d:"M19 12H5"}]];var Rd=[["path",{d:"M5 12h14"}],["path",{d:"m12 5 7 7-7 7"}]];var Id=[["path",{d:"M7 7h10v10"}],["path",{d:"M7 17 17 7"}]];var Wd=[["path",{d:"m5 12 7-7 7 7"}],["path",{d:"M12 19V5"}]];var Hd=[["circle",{cx:"12",cy:"12",r:"4"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"}]];var Bd=[["path",{d:"M4.929 4.929 19.07 19.071"}],["circle",{cx:"12",cy:"12",r:"10"}]];var Dd=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"}]];var Fd=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z"}]];var Nd=[["path",{d:"M12 8V4H8"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}],["path",{d:"M2 14h2"}],["path",{d:"M20 14h2"}],["path",{d:"M15 13v2"}],["path",{d:"M9 13v2"}]];var Od=[["path",{d:"M12 10h.01"}],["path",{d:"M12 14h.01"}],["path",{d:"M12 6h.01"}],["path",{d:"M16 10h.01"}],["path",{d:"M16 14h.01"}],["path",{d:"M16 6h.01"}],["path",{d:"M8 10h.01"}],["path",{d:"M8 14h.01"}],["path",{d:"M8 6h.01"}],["path",{d:"M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2"}]];var _d=[["path",{d:"M8 2v4"}],["path",{d:"M16 2v4"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}],["path",{d:"M3 10h18"}],["path",{d:"M8 14h.01"}],["path",{d:"M12 14h.01"}],["path",{d:"M16 14h.01"}],["path",{d:"M8 18h.01"}],["path",{d:"M12 18h.01"}],["path",{d:"M16 18h.01"}]];var Ud=[["path",{d:"M8 2v4"}],["path",{d:"M16 2v4"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}],["path",{d:"M3 10h18"}]];var qd=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z"}],["circle",{cx:"12",cy:"13",r:"3"}]];var zd=[["path",{d:"M20 6 9 17l-5-5"}]];var $d=[["path",{d:"m6 9 6 6 6-6"}]];var Vd=[["path",{d:"m15 18-6-6 6-6"}]];var jd=[["path",{d:"m9 18 6-6-6-6"}]];var Gd=[["path",{d:"m18 15-6-6-6 6"}]];var Zi=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"m9 12 2 2 4-4"}]];var el=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"m15 9-6 6"}],["path",{d:"m9 9 6 6"}]];var Kd=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4"}],["path",{d:"M21 14H11"}],["path",{d:"m15 10-4 4 4 4"}]];var Xd=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}]];var Qd=[["path",{d:"M12 6v6l4 2"}],["circle",{cx:"12",cy:"12",r:"10"}]];var Jd=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"}]];var Yd=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10"}]];var Zd=[["line",{x1:"12",x2:"12",y1:"2",y2:"22"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"}]];var ec=[["path",{d:"M12 15V3"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}],["path",{d:"m7 10 5 5 5-5"}]];var tl=[["circle",{cx:"12",cy:"12",r:"1"}],["circle",{cx:"12",cy:"5",r:"1"}],["circle",{cx:"12",cy:"19",r:"1"}]];var rl=[["circle",{cx:"12",cy:"12",r:"1"}],["circle",{cx:"19",cy:"12",r:"1"}],["circle",{cx:"5",cy:"12",r:"1"}]];var tc=[["path",{d:"M15 3h6v6"}],["path",{d:"M10 14 21 3"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}]];var rc=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}],["path",{d:"m2 2 20 20"}]];var nc=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}],["circle",{cx:"12",cy:"12",r:"3"}]];var oc=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 12.5 8 15l2 2.5"}],["path",{d:"m14 12.5 2 2.5-2 2.5"}]];var ac=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M8 13h2"}],["path",{d:"M14 13h2"}],["path",{d:"M8 17h2"}],["path",{d:"M14 17h2"}]];var sc=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 9H8"}],["path",{d:"M16 13H8"}],["path",{d:"M16 17H8"}]];var ic=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}]];var lc=[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1"}]];var dc=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}],["path",{d:"M7 3v18"}],["path",{d:"M3 7.5h4"}],["path",{d:"M3 12h18"}],["path",{d:"M3 16.5h4"}],["path",{d:"M17 3v18"}],["path",{d:"M17 7.5h4"}],["path",{d:"M17 16.5h4"}]];var cc=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528"}]];var pc=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"}]];var uc=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"}]];var nl=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"}]];var fc=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1"}],["path",{d:"M12 8v13"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5"}]];var mc=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}],["path",{d:"M2 12h20"}]];var gc=[["line",{x1:"4",x2:"20",y1:"9",y2:"9"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21"}]];var hc=[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3"}]];var xc=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"}]];var bc=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}],["path",{d:"M3 3v5h5"}],["path",{d:"M12 7v5l4 2"}]];var ol=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}]];var yc=[["path",{d:"M16 5h6"}],["path",{d:"M19 2v6"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"}],["circle",{cx:"9",cy:"9",r:"2"}]];var vc=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}],["circle",{cx:"9",cy:"9",r:"2"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"}]];var Cc=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 16v-4"}],["path",{d:"M12 8h.01"}]];var wc=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4"}],["path",{d:"m21 2-9.6 9.6"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5"}]];var Ac=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"}]];var al=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56"}]];var Sc=[["path",{d:"M12 2v4"}],["path",{d:"m16.2 7.8 2.9-2.9"}],["path",{d:"M18 12h4"}],["path",{d:"m16.2 16.2 2.9 2.9"}],["path",{d:"M12 18v4"}],["path",{d:"m4.9 19.1 2.9-2.9"}],["path",{d:"M2 12h4"}],["path",{d:"m4.9 4.9 2.9 2.9"}]];var Tc=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}]];var Mc=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}]];var kc=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"}],["circle",{cx:"12",cy:"10",r:"3"}]];var Ec=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3"}]];var Lc=[["path",{d:"M4 5h16"}],["path",{d:"M4 12h16"}],["path",{d:"M4 19h16"}]];var Pc=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"}]];var Rc=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"}]];var Ic=[["path",{d:"M12 19v3"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3"}]];var Wc=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3"}]];var Hc=[["path",{d:"M5 12h14"}]];var Bc=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21"}]];var Dc=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"}]];var Fc=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z"}],["path",{d:"M12 22V12"}],["polyline",{points:"3.29 7 12 12 20.71 7"}],["path",{d:"m7.5 4.27 9 5.15"}]];var Nc=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551"}]];var Oc=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1"}]];var _c=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}],["path",{d:"m15 5 4 4"}]];var Uc=[["line",{x1:"19",x2:"5",y1:"5",y2:"19"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5"}]];var qc=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384"}]];var zc=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"}]];var $c=[["path",{d:"M5 12h14"}],["path",{d:"M12 5v14"}]];var Vc=[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8"}],["path",{d:"M12 17.5v-11"}]];var jc=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}],["path",{d:"M8 16H3v5"}]];var Gc=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}]];var Kc=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7"}]];var Xc=[["path",{d:"m21 21-4.34-4.34"}],["circle",{cx:"11",cy:"11",r:"8"}]];var Qc=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"}],["path",{d:"m21.854 2.147-10.94 10.939"}]];var Jc=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}],["circle",{cx:"12",cy:"12",r:"3"}]];var Yc=[["path",{d:"M12 2v13"}],["path",{d:"m16 6-4-4-4 4"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"}]];var Zc=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"M12 8v4"}],["path",{d:"M12 16h.01"}]];var ep=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"m9 12 2 2 4-4"}]];var sl=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"m14.5 9.5-5 5"}],["path",{d:"m9.5 9.5 5 5"}]];var tp=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}]];var rp=[["path",{d:"M16 10a4 4 0 0 1-8 0"}],["path",{d:"M3.103 6.034h17.794"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z"}]];var np=[["circle",{cx:"8",cy:"21",r:"1"}],["circle",{cx:"19",cy:"21",r:"1"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"}]];var op=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2"}],["path",{d:"M12 18h.01"}]];var il=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z"}],["path",{d:"M20 2v4"}],["path",{d:"M22 4h-4"}],["circle",{cx:"4",cy:"20",r:"2"}]];var ap=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}]];var sp=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"}]];var ip=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05"}]];var lp=[["circle",{cx:"12",cy:"12",r:"4"}],["path",{d:"M12 2v2"}],["path",{d:"M12 20v2"}],["path",{d:"m4.93 4.93 1.41 1.41"}],["path",{d:"m17.66 17.66 1.41 1.41"}],["path",{d:"M2 12h2"}],["path",{d:"M20 12h2"}],["path",{d:"m6.34 17.66-1.41 1.41"}],["path",{d:"m19.07 4.93-1.41 1.41"}]];var dp=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor"}]];var cp=[["path",{d:"M17 14V2"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"}]];var pp=[["path",{d:"M7 10v12"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"}]];var up=[["line",{x1:"10",x2:"14",y1:"2",y2:"2"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11"}],["circle",{cx:"12",cy:"14",r:"8"}]];var fp=[["path",{d:"M10 11v6"}],["path",{d:"M14 11v6"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];var mp=[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];var ll=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}],["path",{d:"M12 9v4"}],["path",{d:"M12 17h.01"}]];var gp=[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2"}],["path",{d:"M15 18H9"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14"}],["circle",{cx:"17",cy:"18",r:"2"}],["circle",{cx:"7",cy:"18",r:"2"}]];var hp=[["path",{d:"M12 3v12"}],["path",{d:"m17 8-5-5-5 5"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}]];var xp=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}],["circle",{cx:"12",cy:"7",r:"4"}]];var bp=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"}],["path",{d:"M16 9a5 5 0 0 1 0 6"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728"}]];var yp=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15"}]];var vp=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"}]];var Cp=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];var wp=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"}]];var S0={activity:Ed,"arrow-down":Ld,"arrow-up":Wd,"arrow-up-right":Id,bot:Nd,"chevron-down":$d,"chevron-up":Gd,"chevron-right":jd,"chevron-left":Vd,check:zd,clipboard:Xd,"clipboard-copy":Kd,copy:Jd,file:ic,"file-code":oc,"file-spreadsheet":ac,"file-text":sc,"image-plus":yc,loader:Sc,"loader-circle":al,mic:Ic,paperclip:Nc,"refresh-cw":jc,search:Xc,send:Qc,"shield-alert":Zc,"shield-check":ep,"shield-x":sl,square:ap,"thumbs-down":cp,"thumbs-up":pp,upload:hp,"volume-2":bp,x:Cp,user:xp,mail:Mc,phone:qc,calendar:Ud,clock:Qd,building:Od,"map-pin":kc,lock:Tc,key:wc,"credit-card":Yd,"at-sign":Hd,hash:gc,globe:mc,link:Ac,"circle-check":Zi,"circle-x":el,"triangle-alert":ll,info:Cc,ban:Bd,shield:tp,"arrow-left":Pd,"arrow-right":Rd,"external-link":tc,ellipsis:rl,"ellipsis-vertical":tl,menu:Lc,house:ol,plus:$c,minus:Hc,pencil:_c,trash:mp,"trash-2":fp,save:Kc,download:ec,share:Yc,funnel:nl,settings:Jc,"rotate-cw":Gc,maximize:Ec,minimize:Wc,"shopping-cart":np,"shopping-bag":rp,package:Fc,truck:gp,tag:dp,gift:fc,receipt:Vc,wallet:vp,store:ip,"dollar-sign":Zd,percent:Uc,play:zc,pause:Oc,"volume-x":yp,camera:qd,image:vc,film:dc,headphones:hc,"message-circle":Pc,"message-square":Rc,bell:Dd,heart:xc,star:sp,eye:nc,"eye-off":rc,bookmark:Fd,"calendar-days":_d,history:bc,timer:up,folder:uc,"folder-open":pc,files:lc,sparkles:il,zap:wp,sun:lp,moon:Dc,flag:cc,monitor:Bc,smartphone:op},Me=(r,e=24,t="currentColor",n=2)=>{let o=S0[r];return o?T0(o,e,t,n):(console.warn(`Lucide icon "${r}" is not in the Persona registry. Add it to packages/widget/src/utils/icons.ts (see docs/icon-registry-shortlist.md).`),null)};function T0(r,e,t,n){if(!Array.isArray(r))return null;let o=document.createElementNS("http://www.w3.org/2000/svg","svg");return o.setAttribute("width",String(e)),o.setAttribute("height",String(e)),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("fill","none"),o.setAttribute("stroke",t),o.setAttribute("stroke-width",String(n)),o.setAttribute("stroke-linecap","round"),o.setAttribute("stroke-linejoin","round"),o.setAttribute("aria-hidden","true"),r.forEach(a=>{if(!Array.isArray(a)||a.length<2)return;let s=a[0],i=a[1];if(!i)return;let d=document.createElementNS("http://www.w3.org/2000/svg",s);Object.entries(i).forEach(([l,p])=>{l!=="stroke"&&d.setAttribute(l,String(p))}),o.appendChild(d)}),o}var dl={allowedTypes:ho,maxFileSize:10*1024*1024,maxFiles:4};function M0(){return`attach_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function k0(r){return r==="application/pdf"||r.startsWith("text/")||r.includes("word")?"file-text":r.includes("excel")||r.includes("spreadsheet")?"file-spreadsheet":r==="application/json"?"file-code":"file"}var fa=class r{constructor(e={}){this.attachments=[];this.previewsContainer=null;var t,n,o;this.config={allowedTypes:(t=e.allowedTypes)!=null?t:dl.allowedTypes,maxFileSize:(n=e.maxFileSize)!=null?n:dl.maxFileSize,maxFiles:(o=e.maxFiles)!=null?o:dl.maxFiles,onFileRejected:e.onFileRejected,onAttachmentsChange:e.onAttachmentsChange}}setPreviewsContainer(e){this.previewsContainer=e}updateConfig(e){e.allowedTypes!==void 0&&(this.config.allowedTypes=e.allowedTypes.length>0?e.allowedTypes:dl.allowedTypes),e.maxFileSize!==void 0&&(this.config.maxFileSize=e.maxFileSize),e.maxFiles!==void 0&&(this.config.maxFiles=e.maxFiles),e.onFileRejected!==void 0&&(this.config.onFileRejected=e.onFileRejected),e.onAttachmentsChange!==void 0&&(this.config.onAttachmentsChange=e.onAttachmentsChange)}getAttachments(){return[...this.attachments]}getContentParts(){return this.attachments.map(e=>e.contentPart)}hasAttachments(){return this.attachments.length>0}count(){return this.attachments.length}async handleFileSelect(e){!e||e.length===0||await this.handleFiles(Array.from(e))}async handleFiles(e){var t,n,o,a,s,i,d;if(e.length){for(let l of e){if(this.attachments.length>=this.config.maxFiles){(n=(t=this.config).onFileRejected)==null||n.call(t,l,"count");continue}let p=Hh(l,this.config.allowedTypes,this.config.maxFileSize);if(!p.valid){let f=(o=p.error)!=null&&o.includes("type")?"type":"size";(s=(a=this.config).onFileRejected)==null||s.call(a,l,f);continue}try{let f=await Wh(l),u=Xi(l)?URL.createObjectURL(l):null,m={id:M0(),file:l,previewUrl:u,contentPart:f};this.attachments.push(m),this.renderPreview(m)}catch(f){console.error("[AttachmentManager] Failed to process file:",f)}}this.updatePreviewsVisibility(),(d=(i=this.config).onAttachmentsChange)==null||d.call(i,this.getAttachments())}}removeAttachment(e){var a,s,i;let t=this.attachments.findIndex(d=>d.id===e);if(t===-1)return;let n=this.attachments[t];n.previewUrl&&URL.revokeObjectURL(n.previewUrl),this.attachments.splice(t,1);let o=(a=this.previewsContainer)==null?void 0:a.querySelector(`[data-attachment-id="${e}"]`);o&&o.remove(),this.updatePreviewsVisibility(),(i=(s=this.config).onAttachmentsChange)==null||i.call(s,this.getAttachments())}clearAttachments(){var e,t;for(let n of this.attachments)n.previewUrl&&URL.revokeObjectURL(n.previewUrl);this.attachments=[],this.previewsContainer&&(this.previewsContainer.innerHTML=""),this.updatePreviewsVisibility(),(t=(e=this.config).onAttachmentsChange)==null||t.call(e,this.getAttachments())}renderPreview(e){if(!this.previewsContainer)return;let t=Xi(e.file),n=y("div","persona-attachment-preview persona-relative persona-inline-block");if(n.setAttribute("data-attachment-id",e.id),n.style.width="48px",n.style.height="48px",t&&e.previewUrl){let s=y("img");s.src=e.previewUrl,s.alt=e.file.name,s.className="persona-w-full persona-h-full persona-object-cover persona-rounded-lg persona-border persona-border-gray-200",s.style.width="48px",s.style.height="48px",s.style.objectFit="cover",s.style.borderRadius="8px",n.appendChild(s)}else{let s=y("div");s.style.width="48px",s.style.height="48px",s.style.borderRadius="8px",s.style.backgroundColor="var(--persona-container, #f3f4f6)",s.style.border="1px solid var(--persona-border, #e5e7eb)",s.style.display="flex",s.style.flexDirection="column",s.style.alignItems="center",s.style.justifyContent="center",s.style.gap="2px",s.style.overflow="hidden";let i=k0(e.file.type),d=Me(i,20,"var(--persona-muted, #6b7280)",1.5);d&&s.appendChild(d);let l=y("span");l.textContent=Bh(e.file.type,e.file.name),l.style.fontSize="8px",l.style.fontWeight="600",l.style.color="var(--persona-muted, #6b7280)",l.style.textTransform="uppercase",l.style.lineHeight="1",s.appendChild(l),n.appendChild(s)}let o=y("button","persona-attachment-remove persona-absolute persona-flex persona-items-center persona-justify-center");o.type="button",o.setAttribute("aria-label","Remove attachment"),o.style.position="absolute",o.style.top="-4px",o.style.right="-4px",o.style.width="18px",o.style.height="18px",o.style.borderRadius="50%",o.style.backgroundColor="var(--persona-palette-colors-black-alpha-60, rgba(0, 0, 0, 0.6))",o.style.border="none",o.style.cursor="pointer",o.style.display="flex",o.style.alignItems="center",o.style.justifyContent="center",o.style.padding="0";let a=Me("x",10,"var(--persona-text-inverse, #ffffff)",2);a?o.appendChild(a):(o.textContent="\xD7",o.style.color="var(--persona-text-inverse, #ffffff)",o.style.fontSize="14px",o.style.lineHeight="1"),o.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),this.removeAttachment(e.id)}),n.appendChild(o),this.previewsContainer.appendChild(n)}updatePreviewsVisibility(){this.previewsContainer&&(this.previewsContainer.style.display=this.attachments.length>0?"flex":"none")}static fromConfig(e,t){return new r({allowedTypes:e==null?void 0:e.allowedTypes,maxFileSize:e==null?void 0:e.maxFileSize,maxFiles:e==null?void 0:e.maxFiles,onFileRejected:e==null?void 0:e.onFileRejected,onAttachmentsChange:t})}};var Nh=r=>typeof r=="object"&&r!==null&&!Array.isArray(r);function Us(r,e){if(!r)return e;if(!e)return r;let t={...r};for(let[n,o]of Object.entries(e)){let a=t[n];Nh(a)&&Nh(o)?t[n]=Us(a,o):t[n]=o}return t}var Cn="min(440px, calc(100vw - 24px))",cl="440px",Xt={apiUrl:"https://api.runtype.com/api/chat/dispatch",clientToken:void 0,theme:void 0,darkTheme:void 0,colorScheme:"light",launcher:{enabled:!0,mountMode:"floating",dock:{side:"right",width:"420px"},title:"Chat Assistant",subtitle:"Here to help you get answers fast",agentIconText:"\u{1F4AC}",agentIconName:"bot",headerIconName:"bot",position:"bottom-right",width:Cn,heightOffset:0,autoExpand:!1,callToActionIconHidden:!1,agentIconSize:"40px",headerIconSize:"40px",closeButtonSize:"32px",closeButtonPaddingX:"0px",closeButtonPaddingY:"0px",callToActionIconName:"arrow-up-right",callToActionIconText:"",callToActionIconSize:"32px",callToActionIconPadding:"5px",callToActionIconColor:void 0,callToActionIconBackgroundColor:void 0,closeButtonBackgroundColor:"transparent",clearChat:{backgroundColor:"transparent",borderColor:"transparent",enabled:!0,placement:"inline",iconName:"refresh-cw",size:"32px",showTooltip:!0,tooltipText:"Clear chat",paddingX:"0px",paddingY:"0px"},headerIconHidden:!1,border:void 0,shadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)"},copy:{welcomeTitle:"Hello \u{1F44B}",welcomeSubtitle:"Ask anything about your account or products.",inputPlaceholder:"How can I help...",sendButtonLabel:"Send"},sendButton:{borderWidth:"0px",paddingX:"12px",paddingY:"10px",borderColor:void 0,useIcon:!0,iconText:"\u2191",size:"40px",showTooltip:!0,tooltipText:"Send message",iconName:"send"},statusIndicator:{visible:!0,idleText:"Online",connectingText:"Connecting\u2026",connectedText:"Streaming\u2026",errorText:"Offline"},voiceRecognition:{enabled:!0,pauseDuration:2e3,iconName:"mic",iconSize:"39px",borderWidth:"0px",paddingX:"9px",paddingY:"14px",iconColor:void 0,backgroundColor:"transparent",borderColor:"transparent",recordingIconColor:void 0,recordingBackgroundColor:void 0,recordingBorderColor:"transparent",showTooltip:!0,tooltipText:"Start voice recognition"},features:{showReasoning:!0,showToolCalls:!0,scrollToBottom:{enabled:!0,iconName:"arrow-down",label:""},scrollBehavior:{mode:"follow",anchorTopOffset:16},toolCallDisplay:{collapsedMode:"tool-call",activePreview:!1,grouped:!1,previewMaxLines:3,expandable:!0,loadingAnimation:"none"},reasoningDisplay:{activePreview:!1,previewMaxLines:3,expandable:!0,loadingAnimation:"none"},streamAnimation:{type:"none",placeholder:"none",speed:120,duration:1800},askUserQuestion:{enabled:!0,slideInMs:180,freeTextLabel:"Other\u2026",freeTextPlaceholder:"Type your answer\u2026",submitLabel:"Send"}},suggestionChips:["What can you help me with?","Tell me about your features","How does this work?"],suggestionChipsConfig:{fontFamily:"sans-serif",fontWeight:"500",paddingX:"12px",paddingY:"6px"},layout:{header:{layout:"default",showIcon:!0,showTitle:!0,showSubtitle:!0,showCloseButton:!0,showClearChat:!0},messages:{layout:"bubble",avatar:{show:!1,position:"left"},timestamp:{show:!1,position:"below"},groupConsecutive:!1},slots:{}},markdown:{options:{gfm:!0,breaks:!0},disableDefaultStyles:!1},messageActions:{enabled:!0,showCopy:!0,showUpvote:!1,showDownvote:!1,visibility:"hover",align:"right",layout:"pill-inside"},debug:!1};function Oh(r,e){if(!(!r&&!e))return r?e?Us(r,e):r:e}function pl(r){var e,t,n,o,a,s,i,d,l,p,f,u,m,v,x,S,M,E,k,h,w;return r?{...Xt,...r,theme:Oh(Xt.theme,r.theme),darkTheme:Oh(Xt.darkTheme,r.darkTheme),launcher:{...Xt.launcher,...r.launcher,dock:{...(e=Xt.launcher)==null?void 0:e.dock,...(t=r.launcher)==null?void 0:t.dock},clearChat:{...(n=Xt.launcher)==null?void 0:n.clearChat,...(o=r.launcher)==null?void 0:o.clearChat}},copy:{...Xt.copy,...r.copy},sendButton:{...Xt.sendButton,...r.sendButton},statusIndicator:{...Xt.statusIndicator,...r.statusIndicator},voiceRecognition:{...Xt.voiceRecognition,...r.voiceRecognition},features:(()=>{var J,re,Q,ge,Z,G,pe,ke,le,ne;let C=(J=Xt.features)==null?void 0:J.artifacts,T=(re=r.features)==null?void 0:re.artifacts,W=(Q=Xt.features)==null?void 0:Q.scrollToBottom,R=(ge=r.features)==null?void 0:ge.scrollToBottom,I=(Z=Xt.features)==null?void 0:Z.scrollBehavior,N=(G=r.features)==null?void 0:G.scrollBehavior,V=(pe=Xt.features)==null?void 0:pe.streamAnimation,ie=(ke=r.features)==null?void 0:ke.streamAnimation,xe=(le=Xt.features)==null?void 0:le.askUserQuestion,Je=(ne=r.features)==null?void 0:ne.askUserQuestion,we=C===void 0&&T===void 0?void 0:{...C,...T,layout:{...C==null?void 0:C.layout,...T==null?void 0:T.layout}},De=W===void 0&&R===void 0?void 0:{...W,...R},Ae=I===void 0&&N===void 0?void 0:{...I,...N},qe=V===void 0&&ie===void 0?void 0:{...V,...ie},Ie=xe===void 0&&Je===void 0?void 0:{...xe,...Je,styles:{...xe==null?void 0:xe.styles,...Je==null?void 0:Je.styles}};return{...Xt.features,...r.features,...De!==void 0?{scrollToBottom:De}:{},...Ae!==void 0?{scrollBehavior:Ae}:{},...we!==void 0?{artifacts:we}:{},...qe!==void 0?{streamAnimation:qe}:{},...Ie!==void 0?{askUserQuestion:Ie}:{}}})(),suggestionChips:(a=r.suggestionChips)!=null?a:Xt.suggestionChips,suggestionChipsConfig:{...Xt.suggestionChipsConfig,...r.suggestionChipsConfig},layout:{...Xt.layout,...r.layout,header:{...(s=Xt.layout)==null?void 0:s.header,...(i=r.layout)==null?void 0:i.header},messages:{...(d=Xt.layout)==null?void 0:d.messages,...(l=r.layout)==null?void 0:l.messages,avatar:{...(f=(p=Xt.layout)==null?void 0:p.messages)==null?void 0:f.avatar,...(m=(u=r.layout)==null?void 0:u.messages)==null?void 0:m.avatar},timestamp:{...(x=(v=Xt.layout)==null?void 0:v.messages)==null?void 0:x.timestamp,...(M=(S=r.layout)==null?void 0:S.messages)==null?void 0:M.timestamp}},slots:{...(E=Xt.layout)==null?void 0:E.slots,...(k=r.layout)==null?void 0:k.slots}},markdown:{...Xt.markdown,...r.markdown,options:{...(h=Xt.markdown)==null?void 0:h.options,...(w=r.markdown)==null?void 0:w.options}},messageActions:{...Xt.messageActions,...r.messageActions}}:Xt}var Ap={colors:{primary:{50:"#ffffff",100:"#f5f5f5",200:"#d4d4d4",300:"#a3a3a3",400:"#737373",500:"#171717",600:"#0f0f0f",700:"#0a0a0a",800:"#050505",900:"#030303",950:"#000000"},secondary:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},accent:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},success:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d"},warning:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12"},error:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d"},info:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"}},spacing:{0:"0px",1:"0.25rem",2:"0.5rem",3:"0.75rem",4:"1rem",5:"1.25rem",6:"1.5rem",8:"2rem",10:"2.5rem",12:"3rem",16:"4rem",20:"5rem",24:"6rem",32:"8rem",40:"10rem",48:"12rem",56:"14rem",64:"16rem"},typography:{fontFamily:{sans:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',serif:'Georgia, Cambria, "Times New Roman", Times, serif',mono:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"},fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem"},fontWeight:{normal:"400",medium:"500",semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5",relaxed:"1.625"}},shadows:{none:"none",sm:"0 1px 2px 0 rgb(0 0 0 / 0.05)",md:"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",lg:"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)",xl:"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)","2xl":"0 25px 50px -12px rgb(0 0 0 / 0.25)"},borders:{none:"none",sm:"1px solid",md:"2px solid",lg:"4px solid"},radius:{none:"0px",sm:"0.125rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem",full:"9999px"}},Sp={colors:{primary:"palette.colors.primary.500",secondary:"palette.colors.secondary.500",accent:"palette.colors.primary.600",surface:"palette.colors.gray.50",background:"palette.colors.gray.50",container:"palette.colors.gray.50",text:"palette.colors.gray.900",textMuted:"palette.colors.gray.500",textInverse:"palette.colors.gray.50",border:"palette.colors.gray.200",divider:"palette.colors.gray.200",interactive:{default:"palette.colors.primary.600",hover:"palette.colors.primary.700",focus:"palette.colors.primary.600",active:"palette.colors.primary.600",disabled:"palette.colors.gray.300"},feedback:{success:"palette.colors.success.500",warning:"palette.colors.warning.500",error:"palette.colors.error.500",info:"palette.colors.info.500"}},spacing:{xs:"palette.spacing.1",sm:"palette.spacing.2",md:"palette.spacing.4",lg:"palette.spacing.6",xl:"palette.spacing.8","2xl":"palette.spacing.10"},typography:{fontFamily:"palette.typography.fontFamily.sans",fontSize:"palette.typography.fontSize.base",fontWeight:"palette.typography.fontWeight.normal",lineHeight:"palette.typography.lineHeight.normal"}},Tp={button:{primary:{background:"palette.colors.primary.500",foreground:"palette.colors.primary.50",borderRadius:"palette.radius.lg",padding:"semantic.spacing.md"},secondary:{background:"semantic.colors.surface",foreground:"semantic.colors.secondary",borderRadius:"palette.radius.lg",padding:"semantic.spacing.md"},ghost:{background:"transparent",foreground:"semantic.colors.text",borderRadius:"palette.radius.md",padding:"semantic.spacing.sm"}},input:{background:"palette.colors.gray.50",placeholder:"palette.colors.gray.400",borderRadius:"palette.radius.lg",padding:"semantic.spacing.md",focus:{border:"palette.colors.gray.400",ring:"palette.colors.gray.400"}},launcher:{background:"palette.colors.primary.500",foreground:"palette.colors.primary.50",border:"palette.colors.gray.200",size:"60px",iconSize:"28px",borderRadius:"palette.radius.full",shadow:"palette.shadows.lg"},panel:{width:Cn,maxWidth:cl,height:"600px",maxHeight:"calc(100vh - 80px)",borderRadius:"palette.radius.xl",shadow:"palette.shadows.xl"},header:{background:"palette.colors.primary.500",border:"palette.colors.primary.600",borderRadius:"palette.radius.xl palette.radius.xl 0 0",padding:"semantic.spacing.md",iconBackground:"palette.colors.primary.600",iconForeground:"palette.colors.primary.50",titleForeground:"palette.colors.primary.50",subtitleForeground:"palette.colors.primary.200",actionIconForeground:"palette.colors.primary.200"},message:{user:{background:"palette.colors.primary.500",text:"palette.colors.primary.50",borderRadius:"palette.radius.lg",shadow:"palette.shadows.sm"},assistant:{background:"palette.colors.gray.50",text:"palette.colors.gray.900",borderRadius:"palette.radius.lg",border:"palette.colors.gray.200",shadow:"palette.shadows.sm"},border:"semantic.colors.border"},introCard:{background:"semantic.colors.surface",borderRadius:"palette.radius.2xl",padding:"semantic.spacing.lg",shadow:"0 5px 15px rgba(15, 23, 42, 0.08)"},toolBubble:{shadow:"palette.shadows.sm"},reasoningBubble:{shadow:"palette.shadows.sm"},composer:{shadow:"palette.shadows.none"},markdown:{inlineCode:{background:"palette.colors.gray.50",foreground:"palette.colors.gray.900"},link:{foreground:"palette.colors.primary.600"},prose:{fontFamily:"inherit"},codeBlock:{background:"semantic.colors.container",borderColor:"semantic.colors.border",textColor:"inherit"},table:{headerBackground:"semantic.colors.container",borderColor:"semantic.colors.border"},hr:{color:"semantic.colors.divider"},blockquote:{borderColor:"palette.colors.gray.900",background:"transparent",textColor:"palette.colors.gray.500"}},collapsibleWidget:{container:"palette.colors.gray.50",surface:"semantic.colors.surface",border:"semantic.colors.border"},voice:{recording:{indicator:"palette.colors.error.500",background:"palette.colors.error.50",border:"palette.colors.error.200"},processing:{icon:"palette.colors.primary.500",background:"palette.colors.primary.50"},speaking:{icon:"palette.colors.success.500"}},approval:{requested:{background:"palette.colors.warning.50",border:"palette.colors.warning.200",text:"palette.colors.gray.900",shadow:"0 5px 15px rgba(15, 23, 42, 0.08)"},approve:{background:"palette.colors.success.500",foreground:"palette.colors.gray.50",borderRadius:"palette.radius.md",padding:"semantic.spacing.sm"},deny:{background:"palette.colors.error.500",foreground:"palette.colors.gray.50",borderRadius:"palette.radius.md",padding:"semantic.spacing.sm"}},attachment:{image:{background:"palette.colors.gray.100",border:"palette.colors.gray.200"}},scrollToBottom:{background:"components.button.primary.background",foreground:"components.button.primary.foreground",border:"semantic.colors.primary",size:"40px",borderRadius:"palette.radius.full",shadow:"palette.shadows.sm",padding:"0.5rem 0.875rem",gap:"0.5rem",fontSize:"0.875rem",iconSize:"14px"},artifact:{pane:{background:"semantic.colors.container",toolbarBackground:"semantic.colors.container"}}};function Ua(r,e){if(!e.startsWith("palette.")&&!e.startsWith("semantic.")&&!e.startsWith("components."))return e;let t=e.split("."),n=r;for(let o of t){if(n==null)return;n=n[o]}return typeof n=="string"&&(n.startsWith("palette.")||n.startsWith("semantic.")||n.startsWith("components."))?Ua(r,n):n}function ul(r){let e={};function t(n,o){for(let[a,s]of Object.entries(n)){let i=`${o}.${a}`;if(typeof s=="string"){let d=Ua(r,s);d!==void 0&&(e[i]={path:i,value:d,type:o.includes("color")?"color":o.includes("spacing")?"spacing":o.includes("typography")?"typography":o.includes("shadow")?"shadow":o.includes("border")?"border":"color"})}else typeof s=="object"&&s!==null&&t(s,i)}}return t(r.palette,"palette"),t(r.semantic,"semantic"),t(r.components,"components"),e}function Mp(r){let e=[],t=[];return r.palette||e.push({path:"palette",message:"Theme must include a palette",severity:"error"}),r.semantic||t.push({path:"semantic",message:"No semantic tokens defined - defaults will be used",severity:"warning"}),r.components||t.push({path:"components",message:"No component tokens defined - defaults will be used",severity:"warning"}),{valid:e.length===0,errors:e,warnings:t}}function _h(r,e){let t={...r};for(let[n,o]of Object.entries(e)){let a=t[n];a&&typeof a=="object"&&!Array.isArray(a)&&o&&typeof o=="object"&&!Array.isArray(o)?t[n]=_h(a,o):t[n]=o}return t}function E0(r,e){return e?_h(r,e):r}function qa(r,e={}){var o,a,s,i,d,l,p,f,u,m,v,x,S;let t={palette:Ap,semantic:Sp,components:Tp},n={palette:{...t.palette,...r==null?void 0:r.palette,colors:{...t.palette.colors,...(o=r==null?void 0:r.palette)==null?void 0:o.colors},spacing:{...t.palette.spacing,...(a=r==null?void 0:r.palette)==null?void 0:a.spacing},typography:{...t.palette.typography,...(s=r==null?void 0:r.palette)==null?void 0:s.typography},shadows:{...t.palette.shadows,...(i=r==null?void 0:r.palette)==null?void 0:i.shadows},borders:{...t.palette.borders,...(d=r==null?void 0:r.palette)==null?void 0:d.borders},radius:{...t.palette.radius,...(l=r==null?void 0:r.palette)==null?void 0:l.radius}},semantic:{...t.semantic,...r==null?void 0:r.semantic,colors:{...t.semantic.colors,...(p=r==null?void 0:r.semantic)==null?void 0:p.colors,interactive:{...t.semantic.colors.interactive,...(u=(f=r==null?void 0:r.semantic)==null?void 0:f.colors)==null?void 0:u.interactive},feedback:{...t.semantic.colors.feedback,...(v=(m=r==null?void 0:r.semantic)==null?void 0:m.colors)==null?void 0:v.feedback}},spacing:{...t.semantic.spacing,...(x=r==null?void 0:r.semantic)==null?void 0:x.spacing},typography:{...t.semantic.typography,...(S=r==null?void 0:r.semantic)==null?void 0:S.typography}},components:E0(t.components,r==null?void 0:r.components)};if(e.validate!==!1){let M=Mp(n);if(!M.valid)throw new Error(`Theme validation failed: ${M.errors.map(E=>E.message).join(", ")}`)}if(e.plugins)for(let M of e.plugins)n=M.transform(n);return n}function fl(r){var x,S,M,E,k,h,w,C,T,W,R,I,N,V,ie,xe,Je,we,De,Ae,qe,Ie,J,re,Q,ge,Z,G,pe,ke,le,ne,de,Lt,St,We,he,at,Pe,j,ue,nt,It,ee,je,Fr,Dt,ar,gr,nn,F,fe,Re,Xe,Fe,Oe,Ye,Tt,Qt,sr,K,ft,it,ye,se,st,ur,ct,xr,Ir,pt,Pt,et,$t,br,ir,fr,Sr,cn,Mt,_r,hr,An,on,Ct,jn,Sn,_e,P,ae,Ee,Ot,Ze,_t,Zt,dr,wt,Ur,Vt,qr,Fn,no,wo,pn,jt,Kr,Tn,Ao,oo,So,Gn,un,Nn,kt,yr,vr,fn,To;let e=ul(r),t={};for(let[ve,Mn]of Object.entries(e)){let kn=ve.replace(/\./g,"-");t[`--persona-${kn}`]=Mn.value}t["--persona-primary"]=(x=t["--persona-semantic-colors-primary"])!=null?x:t["--persona-palette-colors-primary-500"],t["--persona-secondary"]=(S=t["--persona-semantic-colors-secondary"])!=null?S:t["--persona-palette-colors-secondary-500"],t["--persona-accent"]=(M=t["--persona-semantic-colors-accent"])!=null?M:t["--persona-palette-colors-accent-500"],t["--persona-surface"]=(E=t["--persona-semantic-colors-surface"])!=null?E:t["--persona-palette-colors-gray-50"],t["--persona-background"]=(k=t["--persona-semantic-colors-background"])!=null?k:t["--persona-palette-colors-gray-50"],t["--persona-container"]=(h=t["--persona-semantic-colors-container"])!=null?h:t["--persona-palette-colors-gray-100"],t["--persona-text"]=(w=t["--persona-semantic-colors-text"])!=null?w:t["--persona-palette-colors-gray-900"],t["--persona-text-muted"]=(C=t["--persona-semantic-colors-text-muted"])!=null?C:t["--persona-palette-colors-gray-500"],t["--persona-text-inverse"]=(T=t["--persona-semantic-colors-text-inverse"])!=null?T:t["--persona-palette-colors-gray-50"],t["--persona-border"]=(W=t["--persona-semantic-colors-border"])!=null?W:t["--persona-palette-colors-gray-200"],t["--persona-divider"]=(R=t["--persona-semantic-colors-divider"])!=null?R:t["--persona-palette-colors-gray-200"],t["--persona-muted"]=t["--persona-text-muted"],t["--persona-voice-recording-indicator"]=(I=t["--persona-components-voice-recording-indicator"])!=null?I:t["--persona-palette-colors-error-500"],t["--persona-voice-recording-bg"]=(N=t["--persona-components-voice-recording-background"])!=null?N:t["--persona-palette-colors-error-50"],t["--persona-voice-processing-icon"]=(V=t["--persona-components-voice-processing-icon"])!=null?V:t["--persona-palette-colors-primary-500"],t["--persona-voice-speaking-icon"]=(ie=t["--persona-components-voice-speaking-icon"])!=null?ie:t["--persona-palette-colors-success-500"],t["--persona-approval-bg"]=(xe=t["--persona-components-approval-requested-background"])!=null?xe:t["--persona-palette-colors-warning-50"],t["--persona-approval-border"]=(Je=t["--persona-components-approval-requested-border"])!=null?Je:t["--persona-palette-colors-warning-200"],t["--persona-approval-text"]=(we=t["--persona-components-approval-requested-text"])!=null?we:t["--persona-palette-colors-gray-900"],t["--persona-approval-shadow"]=(De=t["--persona-components-approval-requested-shadow"])!=null?De:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-approval-approve-bg"]=(Ae=t["--persona-components-approval-approve-background"])!=null?Ae:t["--persona-palette-colors-success-500"],t["--persona-approval-deny-bg"]=(qe=t["--persona-components-approval-deny-background"])!=null?qe:t["--persona-palette-colors-error-500"],t["--persona-attachment-image-bg"]=(Ie=t["--persona-components-attachment-image-background"])!=null?Ie:t["--persona-palette-colors-gray-100"],t["--persona-attachment-image-border"]=(J=t["--persona-components-attachment-image-border"])!=null?J:t["--persona-palette-colors-gray-200"],t["--persona-font-family"]=(re=t["--persona-semantic-typography-fontFamily"])!=null?re:t["--persona-palette-typography-fontFamily-sans"],t["--persona-font-size"]=(Q=t["--persona-semantic-typography-fontSize"])!=null?Q:t["--persona-palette-typography-fontSize-base"],t["--persona-font-weight"]=(ge=t["--persona-semantic-typography-fontWeight"])!=null?ge:t["--persona-palette-typography-fontWeight-normal"],t["--persona-line-height"]=(Z=t["--persona-semantic-typography-lineHeight"])!=null?Z:t["--persona-palette-typography-lineHeight-normal"],t["--persona-input-font-family"]=t["--persona-font-family"],t["--persona-input-font-weight"]=t["--persona-font-weight"],t["--persona-radius-sm"]=(G=t["--persona-palette-radius-sm"])!=null?G:"0.125rem",t["--persona-radius-md"]=(pe=t["--persona-palette-radius-md"])!=null?pe:"0.375rem",t["--persona-radius-lg"]=(ke=t["--persona-palette-radius-lg"])!=null?ke:"0.5rem",t["--persona-radius-xl"]=(le=t["--persona-palette-radius-xl"])!=null?le:"0.75rem",t["--persona-radius-full"]=(ne=t["--persona-palette-radius-full"])!=null?ne:"9999px",t["--persona-launcher-radius"]=(Lt=(de=t["--persona-components-launcher-borderRadius"])!=null?de:t["--persona-palette-radius-full"])!=null?Lt:"9999px",t["--persona-launcher-bg"]=(St=t["--persona-components-launcher-background"])!=null?St:t["--persona-primary"],t["--persona-launcher-fg"]=(We=t["--persona-components-launcher-foreground"])!=null?We:t["--persona-text-inverse"],t["--persona-launcher-border"]=(he=t["--persona-components-launcher-border"])!=null?he:t["--persona-border"],t["--persona-button-primary-bg"]=(at=t["--persona-components-button-primary-background"])!=null?at:t["--persona-primary"],t["--persona-button-primary-fg"]=(Pe=t["--persona-components-button-primary-foreground"])!=null?Pe:t["--persona-text-inverse"],t["--persona-button-radius"]=(ue=(j=t["--persona-components-button-primary-borderRadius"])!=null?j:t["--persona-palette-radius-full"])!=null?ue:"9999px",t["--persona-panel-radius"]=(It=(nt=t["--persona-components-panel-borderRadius"])!=null?nt:t["--persona-radius-xl"])!=null?It:"0.75rem",t["--persona-panel-border"]=(ee=t["--persona-components-panel-border"])!=null?ee:`1px solid ${t["--persona-border"]}`,t["--persona-panel-shadow"]=(Fr=(je=t["--persona-components-panel-shadow"])!=null?je:t["--persona-palette-shadows-xl"])!=null?Fr:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",t["--persona-launcher-shadow"]=(Dt=t["--persona-components-launcher-shadow"])!=null?Dt:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",t["--persona-input-radius"]=(gr=(ar=t["--persona-components-input-borderRadius"])!=null?ar:t["--persona-radius-lg"])!=null?gr:"0.5rem",t["--persona-message-user-radius"]=(F=(nn=t["--persona-components-message-user-borderRadius"])!=null?nn:t["--persona-radius-lg"])!=null?F:"0.5rem",t["--persona-message-assistant-radius"]=(Re=(fe=t["--persona-components-message-assistant-borderRadius"])!=null?fe:t["--persona-radius-lg"])!=null?Re:"0.5rem",t["--persona-header-bg"]=(Xe=t["--persona-components-header-background"])!=null?Xe:t["--persona-surface"],t["--persona-header-border"]=(Fe=t["--persona-components-header-border"])!=null?Fe:t["--persona-divider"],t["--persona-header-icon-bg"]=(Oe=t["--persona-components-header-iconBackground"])!=null?Oe:t["--persona-primary"],t["--persona-header-icon-fg"]=(Ye=t["--persona-components-header-iconForeground"])!=null?Ye:t["--persona-text-inverse"],t["--persona-header-title-fg"]=(Tt=t["--persona-components-header-titleForeground"])!=null?Tt:t["--persona-primary"],t["--persona-header-subtitle-fg"]=(Qt=t["--persona-components-header-subtitleForeground"])!=null?Qt:t["--persona-text-muted"],t["--persona-header-action-icon-fg"]=(sr=t["--persona-components-header-actionIconForeground"])!=null?sr:t["--persona-muted"];let n=(K=r.components)==null?void 0:K.header;n!=null&&n.shadow&&(t["--persona-header-shadow"]=n.shadow),n!=null&&n.borderBottom&&(t["--persona-header-border-bottom"]=n.borderBottom);let o=(ft=r.components)==null?void 0:ft.introCard;t["--persona-intro-card-bg"]=(it=t["--persona-components-introCard-background"])!=null?it:t["--persona-surface"],t["--persona-intro-card-radius"]=(ye=t["--persona-components-introCard-borderRadius"])!=null?ye:"1rem",t["--persona-intro-card-padding"]=(se=t["--persona-components-introCard-padding"])!=null?se:"1.5rem",t["--persona-intro-card-shadow"]=(ur=(st=o==null?void 0:o.shadow)!=null?st:t["--persona-components-introCard-shadow"])!=null?ur:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-input-background"]=(ct=t["--persona-components-input-background"])!=null?ct:t["--persona-surface"],t["--persona-input-placeholder"]=(xr=t["--persona-components-input-placeholder"])!=null?xr:t["--persona-text-muted"],t["--persona-message-user-bg"]=(Ir=t["--persona-components-message-user-background"])!=null?Ir:t["--persona-accent"],t["--persona-message-user-text"]=(pt=t["--persona-components-message-user-text"])!=null?pt:t["--persona-text-inverse"],t["--persona-message-user-shadow"]=(Pt=t["--persona-components-message-user-shadow"])!=null?Pt:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-message-assistant-bg"]=(et=t["--persona-components-message-assistant-background"])!=null?et:t["--persona-surface"],t["--persona-message-assistant-text"]=($t=t["--persona-components-message-assistant-text"])!=null?$t:t["--persona-text"],t["--persona-message-assistant-border"]=(br=t["--persona-components-message-assistant-border"])!=null?br:t["--persona-border"],t["--persona-message-assistant-shadow"]=(ir=t["--persona-components-message-assistant-shadow"])!=null?ir:"0 1px 2px 0 rgb(0 0 0 / 0.05)",t["--persona-scroll-to-bottom-bg"]=(Sr=(fr=t["--persona-components-scrollToBottom-background"])!=null?fr:t["--persona-button-primary-bg"])!=null?Sr:t["--persona-accent"],t["--persona-scroll-to-bottom-fg"]=(Mt=(cn=t["--persona-components-scrollToBottom-foreground"])!=null?cn:t["--persona-button-primary-fg"])!=null?Mt:t["--persona-text-inverse"],t["--persona-scroll-to-bottom-border"]=(_r=t["--persona-components-scrollToBottom-border"])!=null?_r:t["--persona-primary"],t["--persona-scroll-to-bottom-size"]=(hr=t["--persona-components-scrollToBottom-size"])!=null?hr:"40px",t["--persona-scroll-to-bottom-radius"]=(Ct=(on=(An=t["--persona-components-scrollToBottom-borderRadius"])!=null?An:t["--persona-button-radius"])!=null?on:t["--persona-radius-full"])!=null?Ct:"9999px",t["--persona-scroll-to-bottom-shadow"]=(Sn=(jn=t["--persona-components-scrollToBottom-shadow"])!=null?jn:t["--persona-palette-shadows-sm"])!=null?Sn:"0 1px 2px 0 rgb(0 0 0 / 0.05)",t["--persona-scroll-to-bottom-padding"]=(_e=t["--persona-components-scrollToBottom-padding"])!=null?_e:"0.5rem 0.875rem",t["--persona-scroll-to-bottom-gap"]=(P=t["--persona-components-scrollToBottom-gap"])!=null?P:"0.5rem",t["--persona-scroll-to-bottom-font-size"]=(Ee=(ae=t["--persona-components-scrollToBottom-fontSize"])!=null?ae:t["--persona-palette-typography-fontSize-sm"])!=null?Ee:"0.875rem",t["--persona-scroll-to-bottom-icon-size"]=(Ot=t["--persona-components-scrollToBottom-iconSize"])!=null?Ot:"14px",t["--persona-tool-bubble-shadow"]=(Ze=t["--persona-components-toolBubble-shadow"])!=null?Ze:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-reasoning-bubble-shadow"]=(_t=t["--persona-components-reasoningBubble-shadow"])!=null?_t:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-composer-shadow"]=(Zt=t["--persona-components-composer-shadow"])!=null?Zt:"none",t["--persona-md-inline-code-bg"]=(dr=t["--persona-components-markdown-inlineCode-background"])!=null?dr:t["--persona-container"],t["--persona-md-inline-code-color"]=(wt=t["--persona-components-markdown-inlineCode-foreground"])!=null?wt:t["--persona-text"],t["--persona-md-link-color"]=(Vt=(Ur=t["--persona-components-markdown-link-foreground"])!=null?Ur:t["--persona-accent"])!=null?Vt:"#0f0f0f";let a=t["--persona-components-markdown-heading-h1-fontSize"];a&&(t["--persona-md-h1-size"]=a);let s=t["--persona-components-markdown-heading-h1-fontWeight"];s&&(t["--persona-md-h1-weight"]=s);let i=t["--persona-components-markdown-heading-h2-fontSize"];i&&(t["--persona-md-h2-size"]=i);let d=t["--persona-components-markdown-heading-h2-fontWeight"];d&&(t["--persona-md-h2-weight"]=d);let l=t["--persona-components-markdown-prose-fontFamily"];l&&l!=="inherit"&&(t["--persona-md-prose-font-family"]=l),t["--persona-md-code-block-bg"]=(qr=t["--persona-components-markdown-codeBlock-background"])!=null?qr:t["--persona-container"],t["--persona-md-code-block-border-color"]=(Fn=t["--persona-components-markdown-codeBlock-borderColor"])!=null?Fn:t["--persona-border"],t["--persona-md-code-block-text-color"]=(no=t["--persona-components-markdown-codeBlock-textColor"])!=null?no:"inherit",t["--persona-md-table-header-bg"]=(wo=t["--persona-components-markdown-table-headerBackground"])!=null?wo:t["--persona-container"],t["--persona-md-table-border-color"]=(pn=t["--persona-components-markdown-table-borderColor"])!=null?pn:t["--persona-border"],t["--persona-md-hr-color"]=(jt=t["--persona-components-markdown-hr-color"])!=null?jt:t["--persona-divider"],t["--persona-md-blockquote-border-color"]=(Kr=t["--persona-components-markdown-blockquote-borderColor"])!=null?Kr:t["--persona-palette-colors-gray-900"],t["--persona-md-blockquote-bg"]=(Tn=t["--persona-components-markdown-blockquote-background"])!=null?Tn:"transparent",t["--persona-md-blockquote-text-color"]=(Ao=t["--persona-components-markdown-blockquote-textColor"])!=null?Ao:t["--persona-palette-colors-gray-500"],t["--cw-container"]=(oo=t["--persona-components-collapsibleWidget-container"])!=null?oo:t["--persona-surface"],t["--cw-surface"]=(So=t["--persona-components-collapsibleWidget-surface"])!=null?So:t["--persona-surface"],t["--cw-border"]=(Gn=t["--persona-components-collapsibleWidget-border"])!=null?Gn:t["--persona-border"],t["--persona-message-border"]=(un=t["--persona-components-message-border"])!=null?un:t["--persona-border"];let p=r.components,f=p==null?void 0:p.iconButton;f&&(f.background&&(t["--persona-icon-btn-bg"]=f.background),f.border&&(t["--persona-icon-btn-border"]=f.border),f.color&&(t["--persona-icon-btn-color"]=f.color),f.padding&&(t["--persona-icon-btn-padding"]=f.padding),f.borderRadius&&(t["--persona-icon-btn-radius"]=f.borderRadius),f.hoverBackground&&(t["--persona-icon-btn-hover-bg"]=f.hoverBackground),f.hoverColor&&(t["--persona-icon-btn-hover-color"]=f.hoverColor),f.activeBackground&&(t["--persona-icon-btn-active-bg"]=f.activeBackground),f.activeBorder&&(t["--persona-icon-btn-active-border"]=f.activeBorder));let u=p==null?void 0:p.labelButton;u&&(u.background&&(t["--persona-label-btn-bg"]=u.background),u.border&&(t["--persona-label-btn-border"]=u.border),u.color&&(t["--persona-label-btn-color"]=u.color),u.padding&&(t["--persona-label-btn-padding"]=u.padding),u.borderRadius&&(t["--persona-label-btn-radius"]=u.borderRadius),u.hoverBackground&&(t["--persona-label-btn-hover-bg"]=u.hoverBackground),u.fontSize&&(t["--persona-label-btn-font-size"]=u.fontSize),u.gap&&(t["--persona-label-btn-gap"]=u.gap));let m=p==null?void 0:p.toggleGroup;m&&(m.gap&&(t["--persona-toggle-group-gap"]=m.gap),m.borderRadius&&(t["--persona-toggle-group-radius"]=m.borderRadius));let v=p==null?void 0:p.artifact;if(v!=null&&v.toolbar){let ve=v.toolbar;ve.iconHoverColor&&(t["--persona-artifact-toolbar-icon-hover-color"]=ve.iconHoverColor),ve.iconHoverBackground&&(t["--persona-artifact-toolbar-icon-hover-bg"]=ve.iconHoverBackground),ve.iconPadding&&(t["--persona-artifact-toolbar-icon-padding"]=ve.iconPadding),ve.iconBorderRadius&&(t["--persona-artifact-toolbar-icon-radius"]=ve.iconBorderRadius),ve.iconBorder&&(t["--persona-artifact-toolbar-icon-border"]=ve.iconBorder),ve.toggleGroupGap&&(t["--persona-artifact-toolbar-toggle-group-gap"]=ve.toggleGroupGap),ve.toggleBorderRadius&&(t["--persona-artifact-toolbar-toggle-radius"]=ve.toggleBorderRadius),ve.copyBackground&&(t["--persona-artifact-toolbar-copy-bg"]=ve.copyBackground),ve.copyBorder&&(t["--persona-artifact-toolbar-copy-border"]=ve.copyBorder),ve.copyColor&&(t["--persona-artifact-toolbar-copy-color"]=ve.copyColor),ve.copyBorderRadius&&(t["--persona-artifact-toolbar-copy-radius"]=ve.copyBorderRadius),ve.copyPadding&&(t["--persona-artifact-toolbar-copy-padding"]=ve.copyPadding),ve.copyMenuBackground&&(t["--persona-artifact-toolbar-copy-menu-bg"]=ve.copyMenuBackground,t["--persona-dropdown-bg"]=(Nn=t["--persona-dropdown-bg"])!=null?Nn:ve.copyMenuBackground),ve.copyMenuBorder&&(t["--persona-artifact-toolbar-copy-menu-border"]=ve.copyMenuBorder,t["--persona-dropdown-border"]=(kt=t["--persona-dropdown-border"])!=null?kt:ve.copyMenuBorder),ve.copyMenuShadow&&(t["--persona-artifact-toolbar-copy-menu-shadow"]=ve.copyMenuShadow,t["--persona-dropdown-shadow"]=(yr=t["--persona-dropdown-shadow"])!=null?yr:ve.copyMenuShadow),ve.copyMenuBorderRadius&&(t["--persona-artifact-toolbar-copy-menu-radius"]=ve.copyMenuBorderRadius,t["--persona-dropdown-radius"]=(vr=t["--persona-dropdown-radius"])!=null?vr:ve.copyMenuBorderRadius),ve.copyMenuItemHoverBackground&&(t["--persona-artifact-toolbar-copy-menu-item-hover-bg"]=ve.copyMenuItemHoverBackground,t["--persona-dropdown-item-hover-bg"]=(fn=t["--persona-dropdown-item-hover-bg"])!=null?fn:ve.copyMenuItemHoverBackground),ve.iconBackground&&(t["--persona-artifact-toolbar-icon-bg"]=ve.iconBackground),ve.toolbarBorder&&(t["--persona-artifact-toolbar-border"]=ve.toolbarBorder)}if(v!=null&&v.tab){let ve=v.tab;ve.background&&(t["--persona-artifact-tab-bg"]=ve.background),ve.activeBackground&&(t["--persona-artifact-tab-active-bg"]=ve.activeBackground),ve.activeBorder&&(t["--persona-artifact-tab-active-border"]=ve.activeBorder),ve.borderRadius&&(t["--persona-artifact-tab-radius"]=ve.borderRadius),ve.textColor&&(t["--persona-artifact-tab-color"]=ve.textColor),ve.hoverBackground&&(t["--persona-artifact-tab-hover-bg"]=ve.hoverBackground),ve.listBackground&&(t["--persona-artifact-tab-list-bg"]=ve.listBackground),ve.listBorderColor&&(t["--persona-artifact-tab-list-border-color"]=ve.listBorderColor),ve.listPadding&&(t["--persona-artifact-tab-list-padding"]=ve.listPadding)}if(v!=null&&v.pane){let ve=v.pane;if(ve.toolbarBackground){let Mn=(To=Ua(r,ve.toolbarBackground))!=null?To:ve.toolbarBackground;t["--persona-artifact-toolbar-bg"]=Mn}}return t}var Uh={header:"Widget header bar",messages:"Message list area","user-message":"User message bubble","assistant-message":"Assistant message bubble",composer:"Footer / composer area",container:"Main widget container","artifact-pane":"Artifact sidebar","artifact-toolbar":"Artifact toolbar"};var L0={colors:{primary:{50:"#ffffff",100:"#f5f5f5",200:"#d4d4d4",300:"#a3a3a3",400:"#737373",500:"#171717",600:"#0f0f0f",700:"#0a0a0a",800:"#050505",900:"#030303",950:"#000000"},secondary:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},accent:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},success:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d"},warning:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12"},error:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d"}}},qh=r=>{if(!(!r||typeof r!="object"||Array.isArray(r)))return r},qs=()=>{var r;return typeof document!="undefined"&&document.documentElement.classList.contains("dark")||typeof window!="undefined"&&((r=window.matchMedia)!=null&&r.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light"},P0=r=>{var t;let e=(t=r==null?void 0:r.colorScheme)!=null?t:"light";return e==="light"?"light":e==="dark"?"dark":qs()},kp=r=>P0(r),R0=r=>qa(r),I0=r=>{var t;let e=qa(void 0,{validate:!1});return qa({...r,palette:{...e.palette,colors:{...L0.colors,...(t=r==null?void 0:r.palette)==null?void 0:t.colors}}},{validate:!1})},za=r=>{let e=kp(r),t=qh(r==null?void 0:r.theme),n=qh(r==null?void 0:r.darkTheme);return e==="dark"?I0(Us(t!=null?t:{},n!=null?n:{})):R0(t)},W0=r=>fl(r),Do=(r,e)=>{let t=za(e),n=W0(t);for(let[o,a]of Object.entries(n))r.style.setProperty(o,a)},ml=r=>{let e=[];if(typeof document!="undefined"&&typeof MutationObserver!="undefined"){let t=new MutationObserver(()=>{r(qs())});t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),e.push(()=>t.disconnect())}if(typeof window!="undefined"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>r(qs());t.addEventListener?(t.addEventListener("change",n),e.push(()=>t.removeEventListener("change",n))):t.addListener&&(t.addListener(n),e.push(()=>t.removeListener(n)))}return()=>{e.forEach(t=>t())}};var zh=(function(){"use strict";let r=()=>{},e={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:r,afterNodeAdded:r,beforeNodeMorphed:r,afterNodeMorphed:r,beforeNodeRemoved:r,afterNodeRemoved:r,beforeAttributeUpdated:r},head:{style:"merge",shouldPreserve:u=>u.getAttribute("im-preserve")==="true",shouldReAppend:u=>u.getAttribute("im-re-append")==="true",shouldRemove:r,afterHeadMorphed:r},restoreFocus:!0};function t(u,m,v={}){u=p(u);let x=f(m),S=l(u,x,v),M=o(S,()=>i(S,u,x,E=>E.morphStyle==="innerHTML"?(a(E,u,x),Array.from(u.childNodes)):n(E,u,x)));return S.pantry.remove(),M}function n(u,m,v){let x=f(m);return a(u,x,v,m,m.nextSibling),Array.from(x.childNodes)}function o(u,m){var k;if(!u.config.restoreFocus)return m();let v=document.activeElement;if(!(v instanceof HTMLInputElement||v instanceof HTMLTextAreaElement))return m();let{id:x,selectionStart:S,selectionEnd:M}=v,E=m();return x&&x!==((k=document.activeElement)==null?void 0:k.getAttribute("id"))&&(v=u.target.querySelector(`[id="${x}"]`),v==null||v.focus()),v&&!v.selectionEnd&&M&&v.setSelectionRange(S,M),E}let a=(function(){function u(h,w,C,T=null,W=null){w instanceof HTMLTemplateElement&&C instanceof HTMLTemplateElement&&(w=w.content,C=C.content),T||(T=w.firstChild);for(let R of C.childNodes){if(T&&T!=W){let N=v(h,R,T,W);if(N){N!==T&&S(h,T,N),s(N,R,h),T=N.nextSibling;continue}}if(R instanceof Element){let N=R.getAttribute("id");if(h.persistentIds.has(N)){let V=M(w,N,T,h);s(V,R,h),T=V.nextSibling;continue}}let I=m(w,R,T,h);I&&(T=I.nextSibling)}for(;T&&T!=W;){let R=T;T=T.nextSibling,x(h,R)}}function m(h,w,C,T){if(T.callbacks.beforeNodeAdded(w)===!1)return null;if(T.idMap.has(w)){let W=document.createElement(w.tagName);return h.insertBefore(W,C),s(W,w,T),T.callbacks.afterNodeAdded(W),W}else{let W=document.importNode(w,!0);return h.insertBefore(W,C),T.callbacks.afterNodeAdded(W),W}}let v=(function(){function h(T,W,R,I){let N=null,V=W.nextSibling,ie=0,xe=R;for(;xe&&xe!=I;){if(C(xe,W)){if(w(T,xe,W))return xe;N===null&&(T.idMap.has(xe)||(N=xe))}if(N===null&&V&&C(xe,V)&&(ie++,V=V.nextSibling,ie>=2&&(N=void 0)),T.activeElementAndParents.includes(xe))break;xe=xe.nextSibling}return N||null}function w(T,W,R){let I=T.idMap.get(W),N=T.idMap.get(R);if(!N||!I)return!1;for(let V of I)if(N.has(V))return!0;return!1}function C(T,W){var N,V,ie;let R=T,I=W;return R.nodeType===I.nodeType&&R.tagName===I.tagName&&(!((N=R.getAttribute)!=null&&N.call(R,"id"))||((V=R.getAttribute)==null?void 0:V.call(R,"id"))===((ie=I.getAttribute)==null?void 0:ie.call(I,"id")))}return h})();function x(h,w){var C;if(h.idMap.has(w))k(h.pantry,w,null);else{if(h.callbacks.beforeNodeRemoved(w)===!1)return;(C=w.parentNode)==null||C.removeChild(w),h.callbacks.afterNodeRemoved(w)}}function S(h,w,C){let T=w;for(;T&&T!==C;){let W=T;T=T.nextSibling,x(h,W)}return T}function M(h,w,C,T){var R,I;let W=((I=(R=T.target).getAttribute)==null?void 0:I.call(R,"id"))===w&&T.target||T.target.querySelector(`[id="${w}"]`)||T.pantry.querySelector(`[id="${w}"]`);return E(W,T),k(h,W,C),W}function E(h,w){let C=h.getAttribute("id");for(;h=h.parentNode;){let T=w.idMap.get(h);T&&(T.delete(C),T.size||w.idMap.delete(h))}}function k(h,w,C){if(h.moveBefore)try{h.moveBefore(w,C)}catch{h.insertBefore(w,C)}else h.insertBefore(w,C)}return u})(),s=(function(){function u(E,k,h){return h.ignoreActive&&E===document.activeElement?null:(h.callbacks.beforeNodeMorphed(E,k)===!1||(E instanceof HTMLHeadElement&&h.head.ignore||(E instanceof HTMLHeadElement&&h.head.style!=="morph"?d(E,k,h):(m(E,k,h),M(E,h)||a(h,E,k))),h.callbacks.afterNodeMorphed(E,k)),E)}function m(E,k,h){let w=k.nodeType;if(w===1){let C=E,T=k,W=C.attributes,R=T.attributes;for(let I of R)S(I.name,C,"update",h)||C.getAttribute(I.name)!==I.value&&C.setAttribute(I.name,I.value);for(let I=W.length-1;0<=I;I--){let N=W[I];if(N&&!T.hasAttribute(N.name)){if(S(N.name,C,"remove",h))continue;C.removeAttribute(N.name)}}M(C,h)||v(C,T,h)}(w===8||w===3)&&E.nodeValue!==k.nodeValue&&(E.nodeValue=k.nodeValue)}function v(E,k,h){if(E instanceof HTMLInputElement&&k instanceof HTMLInputElement&&k.type!=="file"){let w=k.value,C=E.value;x(E,k,"checked",h),x(E,k,"disabled",h),k.hasAttribute("value")?C!==w&&(S("value",E,"update",h)||(E.setAttribute("value",w),E.value=w)):S("value",E,"remove",h)||(E.value="",E.removeAttribute("value"))}else if(E instanceof HTMLOptionElement&&k instanceof HTMLOptionElement)x(E,k,"selected",h);else if(E instanceof HTMLTextAreaElement&&k instanceof HTMLTextAreaElement){let w=k.value,C=E.value;if(S("value",E,"update",h))return;w!==C&&(E.value=w),E.firstChild&&E.firstChild.nodeValue!==w&&(E.firstChild.nodeValue=w)}}function x(E,k,h,w){let C=k[h],T=E[h];if(C!==T){let W=S(h,E,"update",w);W||(E[h]=k[h]),C?W||E.setAttribute(h,""):S(h,E,"remove",w)||E.removeAttribute(h)}}function S(E,k,h,w){return E==="value"&&w.ignoreActiveValue&&k===document.activeElement?!0:w.callbacks.beforeAttributeUpdated(E,k,h)===!1}function M(E,k){return!!k.ignoreActiveValue&&E===document.activeElement&&E!==document.body}return u})();function i(u,m,v,x){if(u.head.block){let S=m.querySelector("head"),M=v.querySelector("head");if(S&&M){let E=d(S,M,u);return Promise.all(E).then(()=>{let k=Object.assign(u,{head:{block:!1,ignore:!0}});return x(k)})}}return x(u)}function d(u,m,v){let x=[],S=[],M=[],E=[],k=new Map;for(let w of m.children)k.set(w.outerHTML,w);for(let w of u.children){let C=k.has(w.outerHTML),T=v.head.shouldReAppend(w),W=v.head.shouldPreserve(w);C||W?T?S.push(w):(k.delete(w.outerHTML),M.push(w)):v.head.style==="append"?T&&(S.push(w),E.push(w)):v.head.shouldRemove(w)!==!1&&S.push(w)}E.push(...k.values());let h=[];for(let w of E){let C=document.createRange().createContextualFragment(w.outerHTML).firstChild;if(v.callbacks.beforeNodeAdded(C)!==!1){if("href"in C&&C.href||"src"in C&&C.src){let T,W=new Promise(function(R){T=R});C.addEventListener("load",function(){T()}),h.push(W)}u.appendChild(C),v.callbacks.afterNodeAdded(C),x.push(C)}}for(let w of S)v.callbacks.beforeNodeRemoved(w)!==!1&&(u.removeChild(w),v.callbacks.afterNodeRemoved(w));return v.head.afterHeadMorphed(u,{added:x,kept:M,removed:S}),h}let l=(function(){function u(h,w,C){let{persistentIds:T,idMap:W}=E(h,w),R=m(C),I=R.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(I))throw`Do not understand how to morph style ${I}`;return{target:h,newContent:w,config:R,morphStyle:I,ignoreActive:R.ignoreActive,ignoreActiveValue:R.ignoreActiveValue,restoreFocus:R.restoreFocus,idMap:W,persistentIds:T,pantry:v(),activeElementAndParents:x(h),callbacks:R.callbacks,head:R.head}}function m(h){let w=Object.assign({},e);return Object.assign(w,h),w.callbacks=Object.assign({},e.callbacks,h.callbacks),w.head=Object.assign({},e.head,h.head),w}function v(){let h=document.createElement("div");return h.hidden=!0,document.body.insertAdjacentElement("afterend",h),h}function x(h){let w=[],C=document.activeElement;if((C==null?void 0:C.tagName)!=="BODY"&&h.contains(C))for(;C&&(w.push(C),C!==h);)C=C.parentElement;return w}function S(h){var C;let w=Array.from(h.querySelectorAll("[id]"));return(C=h.getAttribute)!=null&&C.call(h,"id")&&w.push(h),w}function M(h,w,C,T){for(let W of T){let R=W.getAttribute("id");if(w.has(R)){let I=W;for(;I;){let N=h.get(I);if(N==null&&(N=new Set,h.set(I,N)),N.add(R),I===C)break;I=I.parentElement}}}}function E(h,w){let C=S(h),T=S(w),W=k(C,T),R=new Map;M(R,W,h,C);let I=w.__idiomorphRoot||w;return M(R,W,I,T),{persistentIds:W,idMap:R}}function k(h,w){let C=new Set,T=new Map;for(let{id:R,tagName:I}of h)T.has(R)?C.add(R):T.set(R,I);let W=new Set;for(let{id:R,tagName:I}of w)W.has(R)?C.add(R):T.get(R)===I&&W.add(R);for(let R of C)W.delete(R);return W}return u})(),{normalizeElement:p,normalizeParent:f}=(function(){let u=new WeakSet;function m(M){return M instanceof Document?M.documentElement:M}function v(M){if(M==null)return document.createElement("div");if(typeof M=="string")return v(S(M));if(u.has(M))return M;if(M instanceof Node){if(M.parentNode)return new x(M);{let E=document.createElement("div");return E.append(M),E}}else{let E=document.createElement("div");for(let k of[...M])E.append(k);return E}}class x{constructor(E){this.originalNode=E,this.realParentNode=E.parentNode,this.previousSibling=E.previousSibling,this.nextSibling=E.nextSibling}get childNodes(){let E=[],k=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;k&&k!=this.nextSibling;)E.push(k),k=k.nextSibling;return E}querySelectorAll(E){return this.childNodes.reduce((k,h)=>{if(h instanceof Element){h.matches(E)&&k.push(h);let w=h.querySelectorAll(E);for(let C=0;C<w.length;C++)k.push(w[C])}return k},[])}insertBefore(E,k){return this.realParentNode.insertBefore(E,k)}moveBefore(E,k){return this.realParentNode.moveBefore(E,k)}get __idiomorphRoot(){return this.originalNode}}function S(M){let E=new DOMParser,k=M.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(k.match(/<\/html>/)||k.match(/<\/head>/)||k.match(/<\/body>/)){let h=E.parseFromString(M,"text/html");if(k.match(/<\/html>/))return u.add(h),h;{let w=h.firstChild;return w&&u.add(w),w}}else{let w=E.parseFromString("<body><template>"+M+"</template></body>","text/html").body.querySelector("template").content;return u.add(w),w}}return{normalizeElement:m,normalizeParent:v}})();return{morph:t,defaults:e}})();var gl=(r,e,t={})=>{let{preserveTypingAnimation:n=!0}=t;zh.morph(r,e.innerHTML,{morphStyle:"innerHTML",callbacks:{beforeNodeMorphed(o,a){var s,i;if(o instanceof HTMLElement&&n){if(o.classList.contains("persona-animate-typing")||o.hasAttribute("data-preserve-runtime"))return!1;if(o.hasAttribute("data-preserve-animation")){if(a instanceof HTMLElement&&!a.hasAttribute("data-preserve-animation"))return;if(a instanceof HTMLElement&&a.hasAttribute("data-preserve-animation")){let d=(s=o.textContent)!=null?s:"",l=(i=a.textContent)!=null?i:"";if(d!==l)return}return!1}}}}})};var hl={index:-1,draft:""};function $h(r){let{direction:e,history:t,currentValue:n,atStart:o,state:a}=r,s=a.index!==-1;if(t.length===0)return{handled:!1,state:a};if(e==="up"){if(!s&&!o)return{handled:!1,state:a};if(!s){let i=t.length-1;return{handled:!0,value:t[i],state:{index:i,draft:n}}}if(a.index>0){let i=a.index-1;return{handled:!0,value:t[i],state:{index:i,draft:a.draft}}}return{handled:!0,state:a}}if(!s)return{handled:!1,state:a};if(a.index<t.length-1){let i=a.index+1;return{handled:!0,value:t[i],state:{index:i,draft:a.draft}}}return{handled:!0,value:a.draft,state:{...hl}}}function Vh(r,e){var t,n,o,a,s,i,d,l,p,f,u,m,v,x,S,M,E,k,h,w,C,T,W,R,I,N,V,ie,xe,Je,we,De,Ae,qe,Ie,J,re,Q;return[r.id,r.role,(n=(t=r.content)==null?void 0:t.length)!=null?n:0,(a=(o=r.content)==null?void 0:o.slice(-32))!=null?a:"",r.streaming?"1":"0",(s=r.variant)!=null?s:"",(d=(i=r.rawContent)==null?void 0:i.length)!=null?d:0,(p=(l=r.llmContent)==null?void 0:l.length)!=null?p:0,(u=(f=r.approval)==null?void 0:f.status)!=null?u:"",(v=(m=r.toolCall)==null?void 0:m.status)!=null?v:"",(S=(x=r.toolCall)==null?void 0:x.name)!=null?S:"",(k=(E=(M=r.toolCall)==null?void 0:M.chunks)==null?void 0:E.length)!=null?k:0,(T=(C=(w=(h=r.toolCall)==null?void 0:h.chunks)==null?void 0:w[r.toolCall.chunks.length-1])==null?void 0:C.slice(-32))!=null?T:"",typeof((W=r.toolCall)==null?void 0:W.args)=="string"?r.toolCall.args.length:(R=r.toolCall)!=null&&R.args?JSON.stringify(r.toolCall.args).length:0,(V=(N=(I=r.reasoning)==null?void 0:I.chunks)==null?void 0:N.length)!=null?V:0,(we=(Je=(xe=(ie=r.reasoning)==null?void 0:ie.chunks)==null?void 0:xe[r.reasoning.chunks.length-1])==null?void 0:Je.length)!=null?we:0,(Ie=(qe=(Ae=(De=r.reasoning)==null?void 0:De.chunks)==null?void 0:Ae[r.reasoning.chunks.length-1])==null?void 0:qe.slice(-32))!=null?Ie:"",(re=(J=r.contentParts)==null?void 0:J.length)!=null?re:0,(Q=r.stopReason)!=null?Q:"",e].join("\0")}function jh(){return new Map}function Gh(r,e,t){let n=r.get(e);return n&&n.fingerprint===t?n.wrapper:null}function Kh(r,e,t,n){r.set(e,{fingerprint:t,wrapper:n})}function Xh(r,e){for(let t of r.keys())e.has(t)||r.delete(t)}function xl(r=!0){let e=r;return{isFollowing:()=>e,pause:()=>e?(e=!1,!0):!1,resume:()=>e?!1:(e=!0,!0)}}function xo(r){return Math.max(0,r.scrollHeight-r.clientHeight)}function ma(r,e){return xo(r)-r.scrollTop<=e}function bl(r){let{following:e,currentScrollTop:t,lastScrollTop:n,nearBottom:o,userScrollThreshold:a,isAutoScrolling:s=!1,pauseOnUpwardScroll:i=!1,pauseWhenAwayFromBottom:d=!0,resumeRequiresDownwardScroll:l=!1}=r,p=t-n;return s||Math.abs(p)<a?{action:"none",delta:p,nextLastScrollTop:t}:!e&&o&&(!l||p>0)?{action:"resume",delta:p,nextLastScrollTop:t}:e&&i&&p<0?{action:"pause",delta:p,nextLastScrollTop:t}:e&&d&&!o?{action:"pause",delta:p,nextLastScrollTop:t}:{action:"none",delta:p,nextLastScrollTop:t}}function yl(r){let{following:e,deltaY:t,nearBottom:n=!1,resumeWhenNearBottom:o=!1}=r;return e&&t<0?"pause":!e&&o&&t>0&&n?"resume":"none"}function Qh(r,e){return!r||r.isCollapsed?!1:e.contains(r.anchorNode)||e.contains(r.focusNode)}function Jh(r){let e=Math.max(0,r.anchorOffsetTop-r.topOffset),t=Math.max(0,e+r.viewportHeight-r.contentHeight);return{targetScrollTop:e,spacerHeight:t}}function Yh(r){let e=Math.max(0,r.currentContentHeight-r.contentHeightAtAnchor);return Math.max(0,r.initialSpacerHeight-e)}var jr={idle:"Online",connecting:"Connecting\u2026",connected:"Streaming\u2026",error:"Offline"},Gr=1e5,Fo=Gr+1;var zs={type:"none",placeholder:"none",speed:120,duration:1800,buffer:"none"},H0=["pre","code","a","script","style"],vl=r=>{var e,t,n,o,a;return{type:(e=r==null?void 0:r.type)!=null?e:zs.type,placeholder:(t=r==null?void 0:r.placeholder)!=null?t:zs.placeholder,speed:(n=r==null?void 0:r.speed)!=null?n:zs.speed,duration:(o=r==null?void 0:r.duration)!=null?o:zs.duration,buffer:(a=r==null?void 0:r.buffer)!=null?a:zs.buffer}},ex=[{name:"typewriter",containerClass:"persona-stream-typewriter",wrap:"char",useCaret:!0},{name:"pop-bubble",bubbleClass:"persona-stream-pop",wrap:"none"},{name:"letter-rise",containerClass:"persona-stream-letter-rise",wrap:"char"},{name:"word-fade",containerClass:"persona-stream-word-fade",wrap:"word"}],$s=new Map;for(let r of ex)$s.set(r.name,r);var ga=r=>{$s.set(r.name,r)},Pp=r=>{ex.some(e=>e.name===r)||$s.delete(r)},Rp=()=>Array.from($s.keys()),Vs=(r,e)=>{var t,n;return r==="none"?null:e&&Object.prototype.hasOwnProperty.call(e,r)?(t=e[r])!=null?t:null:(n=$s.get(r))!=null?n:null},Cl=(r,e,t,n,o)=>{if(!o)return r;if(t!=null&&t.bufferContent)return t.bufferContent(r,n);if(!r)return r;if(e==="word"){let a=r.search(/\s(?=\S*$)/);return a<0?"":r.slice(0,a)}if(e==="line"){let a=r.lastIndexOf(`
|
|
62
|
-
`);return a<0?"":r.slice(0,a)}return r},
|
|
62
|
+
_Details: ${t.message}_`:o}var Zs=r=>({isError:!0,content:[{type:"text",text:r}]}),mx=(r,e="WebMCP tool execution failed.")=>r instanceof Error&&r.message?r.message:typeof r=="string"&&r?r:e,gx=r=>ga(r)||r===en,Za=class r{constructor(e={},t){this.config=e;this.callbacks=t;this.status="idle";this.streaming=!1;this.abortController=null;this.sequenceCounter=Date.now();this.clientSession=null;this.agentExecution=null;this.artifacts=new Map;this.selectedArtifactId=null;this.webMcpInflightKeys=new Set;this.webMcpResolvedKeys=new Set;this.webMcpResolveControllers=new Set;this.webMcpEpoch=0;this.webMcpApprovalResolvers=new Map;this.webMcpApprovalSeq=0;this.webMcpAwaitBatches=new Map;this.voiceProvider=null;this.voiceActive=!1;this.voiceStatus="disconnected";this.pendingVoiceUserMessageId=null;this.pendingVoiceAssistantMessageId=null;this.ttsSpokenMessageIds=new Set;this.handleEvent=e=>{var t,o,n,a,s,i,d,l,u,f;if(e.type==="message"){this.upsertMessage(e.message);let p=e.message.toolCall,m=!!(p!=null&&p.name)&&(ga(p.name)||p.name===en&&((o=(t=this.config.features)==null?void 0:t.suggestReplies)==null?void 0:o.enabled)!==!1);((n=e.message.agentMetadata)==null?void 0:n.awaitingLocalTool)===!0&&m&&this.enqueueWebMcpAwait(e.message),(a=e.message.agentMetadata)!=null&&a.executionId&&(this.agentExecution?e.message.agentMetadata.iteration!==void 0&&(this.agentExecution.currentIteration=e.message.agentMetadata.iteration):this.agentExecution={executionId:e.message.agentMetadata.executionId,agentId:"",agentName:(s=e.message.agentMetadata.agentName)!=null?s:"",status:"running",currentIteration:(i=e.message.agentMetadata.iteration)!=null?i:0,maxTurns:0})}else if(e.type==="status"){if(this.setStatus(e.status),e.status==="connecting")this.setStreaming(!0);else if(e.status==="idle"||e.status==="error"){this.webMcpResolveControllers.size===0&&(this.setStreaming(!1),this.abortController=null);let p=this.webMcpAwaitBatches.size>0||this.webMcpResolveControllers.size>0;((d=this.agentExecution)==null?void 0:d.status)==="running"&&(e.status==="error"?this.agentExecution.status="error":p||(this.agentExecution.status="complete")),this.scheduleWebMcpBatchFlush()}}else e.type==="error"?(this.setStatus("error"),this.webMcpResolveControllers.size===0&&(this.setStreaming(!1),this.abortController=null),((l=this.agentExecution)==null?void 0:l.status)==="running"&&(this.agentExecution.status="error"),(f=(u=this.callbacks).onError)==null||f.call(u,e.error)):(e.type==="artifact_start"||e.type==="artifact_delta"||e.type==="artifact_update"||e.type==="artifact_complete")&&this.applyArtifactStreamEvent(e)};var o,n;this.messages=[...(o=e.initialMessages)!=null?o:[]].map(a=>{var s;return{...a,sequence:(s=a.sequence)!=null?s:this.nextSequence()}}),this.messages=this.sortMessages(this.messages),this.client=new ya(e),this.wireDefaultWebMcpConfirm();for(let a of(n=e.initialArtifacts)!=null?n:[])this.artifacts.set(a.id,{...a,status:"complete"});e.initialSelectedArtifactId!=null&&(this.selectedArtifactId=e.initialSelectedArtifactId),this.messages.length&&this.callbacks.onMessagesChanged([...this.messages]),this.artifacts.size>0&&this.emitArtifactsState(),this.callbacks.onStatusChanged(this.status)}setSSEEventCallback(e){this.client.setSSEEventCallback(e)}isClientTokenMode(){return this.client.isClientTokenMode()}isAgentMode(){return this.client.isAgentMode()}getAgentExecution(){return this.agentExecution}isAgentExecuting(){var e;return((e=this.agentExecution)==null?void 0:e.status)==="running"}isVoiceSupported(){var e;return Js((e=this.config.voiceRecognition)==null?void 0:e.provider)}isVoiceActive(){return this.voiceActive}getVoiceStatus(){return this.voiceStatus}getVoiceInterruptionMode(){var e;return(e=this.voiceProvider)!=null&&e.getInterruptionMode?this.voiceProvider.getInterruptionMode():"none"}stopVoicePlayback(){var e;(e=this.voiceProvider)!=null&&e.stopPlayback&&this.voiceProvider.stopPlayback()}isBargeInActive(){var e,t,o;return(o=(t=(e=this.voiceProvider)==null?void 0:e.isBargeInActive)==null?void 0:t.call(e))!=null?o:!1}async deactivateBargeIn(){var e;(e=this.voiceProvider)!=null&&e.deactivateBargeIn&&await this.voiceProvider.deactivateBargeIn()}setupVoice(e){var t,o,n;try{let a=e||this.getVoiceConfigFromConfig();if(!a)throw new Error("Voice configuration not provided");this.voiceProvider=Ca(a);let s=(t=this.config.voiceRecognition)!=null?t:{},i=(o=s.processingText)!=null?o:"\u{1F3A4} Processing voice...",d=(n=s.processingErrorText)!=null?n:"Voice processing failed. Please try again.";this.voiceProvider.onProcessingStart&&this.voiceProvider.onProcessingStart(()=>{let l=this.injectMessage({role:"user",content:i,streaming:!1,voiceProcessing:!0});this.pendingVoiceUserMessageId=l.id;let u=this.injectMessage({role:"assistant",content:"",streaming:!0,voiceProcessing:!0});this.pendingVoiceAssistantMessageId=u.id,this.setStreaming(!0)}),this.voiceProvider.onResult(l=>{var u,f,p,m,y,h;if(l.provider==="browser")l.text&&l.text.trim()&&this.sendMessage(l.text,{viaVoice:!0});else if(l.provider==="runtype"){this.pendingVoiceUserMessageId&&((u=l.transcript)!=null&&u.trim())?this.upsertMessage({id:this.pendingVoiceUserMessageId,role:"user",content:l.transcript.trim(),createdAt:new Date().toISOString(),streaming:!1,voiceProcessing:!1}):(f=l.transcript)!=null&&f.trim()&&this.injectUserMessage({content:l.transcript.trim()}),this.pendingVoiceAssistantMessageId&&((p=l.text)!=null&&p.trim())?this.upsertMessage({id:this.pendingVoiceAssistantMessageId,role:"assistant",content:l.text.trim(),createdAt:new Date().toISOString(),streaming:!1,voiceProcessing:!1}):(m=l.text)!=null&&m.trim()&&this.injectAssistantMessage({content:l.text.trim()});{let T=(h=this.pendingVoiceAssistantMessageId)!=null?h:(y=[...this.messages].reverse().find(M=>M.role==="assistant"))==null?void 0:y.id;T&&this.ttsSpokenMessageIds.add(T)}this.setStreaming(!1),this.pendingVoiceUserMessageId=null,this.pendingVoiceAssistantMessageId=null}}),this.voiceProvider.onError(l=>{console.error("Voice error:",l),this.pendingVoiceAssistantMessageId&&(this.upsertMessage({id:this.pendingVoiceAssistantMessageId,role:"assistant",content:d,createdAt:new Date().toISOString(),streaming:!1,voiceProcessing:!1}),this.setStreaming(!1),this.pendingVoiceUserMessageId=null,this.pendingVoiceAssistantMessageId=null)}),this.voiceProvider.onStatusChange(l=>{var u,f;this.voiceStatus=l,this.voiceActive=l==="listening",(f=(u=this.callbacks).onVoiceStatusChanged)==null||f.call(u,l)}),this.voiceProvider.connect()}catch(a){console.error("Failed to setup voice:",a)}}async toggleVoice(){if(!this.voiceProvider){console.error("Voice not configured");return}if(this.voiceActive)await this.voiceProvider.stopListening();else{this.stopSpeaking();try{await this.voiceProvider.startListening()}catch(e){console.error("Failed to start voice:",e)}}}cleanupVoice(){this.voiceProvider&&(this.voiceProvider.disconnect(),this.voiceProvider=null),this.voiceActive=!1,this.voiceStatus="disconnected"}getVoiceConfigFromConfig(){var t,o,n,a,s,i,d,l,u;if(!((t=this.config.voiceRecognition)!=null&&t.provider))return;let e=this.config.voiceRecognition.provider;switch(e.type){case"runtype":return{type:"runtype",runtype:{agentId:((o=e.runtype)==null?void 0:o.agentId)||"",clientToken:((n=e.runtype)==null?void 0:n.clientToken)||"",host:(a=e.runtype)==null?void 0:a.host,voiceId:(s=e.runtype)==null?void 0:s.voiceId,pauseDuration:(i=e.runtype)==null?void 0:i.pauseDuration,silenceThreshold:(d=e.runtype)==null?void 0:d.silenceThreshold}};case"browser":return{type:"browser",browser:{language:((l=e.browser)==null?void 0:l.language)||"en-US",continuous:(u=e.browser)==null?void 0:u.continuous}};default:return}}async initClientSession(){var e,t;if(!this.isClientTokenMode())return null;try{let o=await this.client.initSession();return this.setClientSession(o),o}catch(o){return(t=(e=this.callbacks).onError)==null||t.call(e,o instanceof Error?o:new Error(String(o))),null}}setClientSession(e){if(this.clientSession=e,e.config.welcomeMessage&&this.messages.length===0){let t={id:`welcome-${Date.now()}`,role:"assistant",content:e.config.welcomeMessage,createdAt:new Date().toISOString(),sequence:this.nextSequence()};this.appendMessage(t)}}getClientSession(){var e;return(e=this.clientSession)!=null?e:this.client.getClientSession()}isSessionValid(){let e=this.getClientSession();return e?new Date<e.expiresAt:!1}clearClientSession(){this.clientSession=null,this.client.clearClientSession()}getClient(){return this.client}async submitMessageFeedback(e,t){return this.client.submitMessageFeedback(e,t)}async submitCSATFeedback(e,t){return this.client.submitCSATFeedback(e,t)}async submitNPSFeedback(e,t){return this.client.submitNPSFeedback(e,t)}updateConfig(e){let t={...this.config,...e};if(!Sv(this.config,t)){this.config=t,this.client.updateConfig(t);return}this.abortWebMcpResolves(),this.webMcpInflightKeys.clear(),this.webMcpResolvedKeys.clear();let o=this.client.getSSEEventCallback();this.config=t,this.client=new ya(this.config),this.wireDefaultWebMcpConfirm(),o&&this.client.setSSEEventCallback(o)}getMessages(){return[...this.messages]}getStatus(){return this.status}isStreaming(){return this.streaming}injectTestEvent(e){this.handleEvent(e)}injectMessage(e){let{role:t,content:o,llmContent:n,contentParts:a,id:s,createdAt:i,sequence:d,streaming:l=!1,voiceProcessing:u,rawContent:f}=e,m={id:s!=null?s:t==="user"?Ja():t==="assistant"?ba():`system-${Date.now()}-${Math.random().toString(16).slice(2)}`,role:t,content:o,createdAt:i!=null?i:new Date().toISOString(),sequence:d!=null?d:this.nextSequence(),streaming:l,...n!==void 0&&{llmContent:n},...a!==void 0&&{contentParts:a},...u!==void 0&&{voiceProcessing:u},...f!==void 0&&{rawContent:f}};return this.upsertMessage(m),m}injectAssistantMessage(e){return this.injectMessage({...e,role:"assistant"})}injectUserMessage(e){return this.injectMessage({...e,role:"user"})}injectSystemMessage(e){return this.injectMessage({...e,role:"system"})}injectMessageBatch(e){let t=[];for(let o of e){let{role:n,content:a,llmContent:s,contentParts:i,id:d,createdAt:l,sequence:u,streaming:f=!1,voiceProcessing:p,rawContent:m}=o,h={id:d!=null?d:n==="user"?Ja():n==="assistant"?ba():`system-${Date.now()}-${Math.random().toString(16).slice(2)}`,role:n,content:a,createdAt:l!=null?l:new Date().toISOString(),sequence:u!=null?u:this.nextSequence(),streaming:f,...s!==void 0&&{llmContent:s},...i!==void 0&&{contentParts:i},...p!==void 0&&{voiceProcessing:p},...m!==void 0&&{rawContent:m}};t.push(h)}return this.messages=this.sortMessages([...this.messages,...t]),this.callbacks.onMessagesChanged([...this.messages]),t}injectComponentDirective(e){let{component:t,props:o={},text:n="",llmContent:a,id:s,createdAt:i,sequence:d}=e,l={text:n,component:t,props:o};return this.injectMessage({role:"assistant",content:n,rawContent:JSON.stringify(l),...a!==void 0&&{llmContent:a},...s!==void 0&&{id:s},...i!==void 0&&{createdAt:i},...d!==void 0&&{sequence:d}})}async sendMessage(e,t){var l,u,f,p,m;let o=e.trim();if(!o&&(!(t!=null&&t.contentParts)||t.contentParts.length===0))return;this.stopSpeaking(),(l=this.abortController)==null||l.abort(),this.abortWebMcpResolves();let n=Ja(),a=ba(),s={id:n,role:"user",content:o||ll,createdAt:new Date().toISOString(),sequence:this.nextSequence(),viaVoice:(t==null?void 0:t.viaVoice)||!1,...(t==null?void 0:t.contentParts)&&t.contentParts.length>0&&{contentParts:t.contentParts}};this.appendMessage(s),this.setStreaming(!0);let i=new AbortController;this.abortController=i;let d=[...this.messages];try{await this.client.dispatch({messages:d,signal:i.signal,assistantMessageId:a},this.handleEvent)}catch(y){let h=y instanceof Error&&(y.name==="AbortError"||y.message.includes("aborted")||y.message.includes("abort"));if(!h){let T=fx(y,this.config.errorMessage);if(T){let M={id:a,role:"assistant",createdAt:new Date().toISOString(),content:T,sequence:this.nextSequence()};this.appendMessage(M)}}this.setStatus("idle"),this.setStreaming(!1),this.abortController=null,h||(y instanceof Error?(f=(u=this.callbacks).onError)==null||f.call(u,y):(m=(p=this.callbacks).onError)==null||m.call(p,new Error(String(y))))}}async continueConversation(){var n,a,s,i,d;if(this.streaming)return;(n=this.abortController)==null||n.abort();let e=ba();this.setStreaming(!0);let t=new AbortController;this.abortController=t;let o=[...this.messages];try{await this.client.dispatch({messages:o,signal:t.signal,assistantMessageId:e},this.handleEvent)}catch(l){let u=l instanceof Error&&(l.name==="AbortError"||l.message.includes("aborted")||l.message.includes("abort"));if(!u){let f=fx(l,this.config.errorMessage);if(f){let p={id:e,role:"assistant",createdAt:new Date().toISOString(),content:f,sequence:this.nextSequence()};this.appendMessage(p)}}this.setStatus("idle"),this.setStreaming(!1),this.abortController=null,u||(l instanceof Error?(s=(a=this.callbacks).onError)==null||s.call(a,l):(d=(i=this.callbacks).onError)==null||d.call(i,new Error(String(l))))}}async connectStream(e,t){var n,a,s;if(this.streaming&&!(t!=null&&t.allowReentry))return;t!=null&&t.allowReentry||(n=this.abortController)==null||n.abort();let o=!1;for(let i of this.messages)i.streaming&&(i.streaming=!1,o=!0);o&&this.callbacks.onMessagesChanged([...this.messages]),this.setStreaming(!0);try{await this.client.processStream(e,this.handleEvent,t==null?void 0:t.assistantMessageId)}catch(i){this.setStatus("error"),this.webMcpResolveControllers.size===0&&(this.setStreaming(!1),this.abortController=null),(s=(a=this.callbacks).onError)==null||s.call(a,i instanceof Error?i:new Error(String(i)))}}wireDefaultWebMcpConfirm(){let e=this.config.webmcp;(e==null?void 0:e.enabled)===!0&&!e.onConfirm&&this.client.setWebMcpConfirmHandler(t=>this.requestWebMcpApproval(t))}requestWebMcpApproval(e){var n,a,s;try{if(((a=(n=this.config.webmcp)==null?void 0:n.autoApprove)==null?void 0:a.call(n,e))===!0)return Promise.resolve(!0)}catch{}let t={id:`webmcp-${++this.webMcpApprovalSeq}`,status:"pending",agentId:"",executionId:"",toolName:e.toolName,toolType:"webmcp",description:(s=e.description)!=null?s:`Allow the assistant to run ${e.toolName}?`,parameters:e.args},o=`approval-${t.id}`;return this.upsertMessage({id:o,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!1,variant:"approval",approval:t}),new Promise(i=>{this.webMcpApprovalResolvers.set(o,i)})}resolveWebMcpApproval(e,t){let o=this.webMcpApprovalResolvers.get(e);if(!o)return;this.webMcpApprovalResolvers.delete(e);let n=this.messages.find(a=>a.id===e);n!=null&&n.approval&&this.upsertMessage({...n,approval:{...n.approval,status:t,resolvedAt:Date.now()}}),o(t==="approved")}async resolveApproval(e,t,o){var u,f,p,m,y;let n=`approval-${e.id}`,a={...e,status:t,resolvedAt:Date.now()},s=this.messages.find(h=>h.id===n),i={id:n,role:"assistant",content:"",createdAt:(u=s==null?void 0:s.createdAt)!=null?u:new Date().toISOString(),...(s==null?void 0:s.sequence)!==void 0?{sequence:s.sequence}:{},streaming:!1,variant:"approval",approval:a};this.upsertMessage(i),(f=this.abortController)==null||f.abort(),this.abortController=new AbortController,this.setStreaming(!0);let d=this.config.approval,l=d&&typeof d=="object"?d.onDecision:void 0;try{let h;if(l?h=await l({approvalId:e.id,executionId:e.executionId,agentId:e.agentId,toolName:e.toolName},t,o):h=await this.client.resolveApproval({agentId:e.agentId,executionId:e.executionId,approvalId:e.id},t),h){let T=null;if(h instanceof Response){if(!h.ok){let M=await h.json().catch(()=>null);throw new Error((p=M==null?void 0:M.error)!=null?p:`Approval request failed: ${h.status}`)}T=h.body}else h instanceof ReadableStream&&(T=h);T?await this.connectStream(T,{allowReentry:!0}):(t==="denied"&&this.appendMessage({id:`denial-${e.id}`,role:"assistant",content:"Tool execution was denied by user.",createdAt:new Date().toISOString(),streaming:!1,sequence:this.nextSequence()}),this.setStreaming(!1),this.abortController=null)}else this.setStreaming(!1),this.abortController=null}catch(h){let T=h instanceof Error&&(h.name==="AbortError"||h.message.includes("aborted")||h.message.includes("abort"));this.setStreaming(!1),this.abortController=null,T||(y=(m=this.callbacks).onError)==null||y.call(m,h instanceof Error?h:new Error(String(h)))}}persistAskUserQuestionProgress(e,t){let o=this.messages.find(n=>n.id===e.id);o&&this.upsertMessage({...o,agentMetadata:{...o.agentMetadata,askUserQuestionAnswers:t.answers,askUserQuestionIndex:t.currentIndex}})}markAskUserQuestionResolved(e,t){let o=this.messages.find(n=>n.id===e.id);o&&this.upsertMessage({...o,agentMetadata:{...o.agentMetadata,awaitingLocalTool:!1,askUserQuestionAnswered:!0,...t?{askUserQuestionAnswers:t}:{}}})}async resolveAskUserQuestion(e,t){var u,f,p,m,y,h,T,M,k,L,x,w;let o=this.messages.find(v=>v.id===e.id);if(((u=o==null?void 0:o.agentMetadata)==null?void 0:u.askUserQuestionAnswered)===!0)return;let n=(f=e.agentMetadata)==null?void 0:f.executionId,a=(p=e.toolCall)==null?void 0:p.name;if(!n||!a){(y=(m=this.callbacks).onError)==null||y.call(m,new Error("resolveAskUserQuestion: message is missing executionId or toolCall.name"));return}let s=typeof t=="string"?void 0:t;if(s===void 0&&typeof t=="string"){let v=(h=e.toolCall)==null?void 0:h.args,E=Array.isArray(v==null?void 0:v.questions)?v.questions:[];if(E.length===1){let H=typeof((T=E[0])==null?void 0:T.question)=="string"?E[0].question:"";H&&(s={[H]:t})}}this.markAskUserQuestionResolved(e,s),(M=this.abortController)==null||M.abort(),this.abortController=new AbortController,this.setStreaming(!0);let i=e.toolCall.id,d=(k=e.toolCall)==null?void 0:k.args,l=Array.isArray(d==null?void 0:d.questions)?d.questions:[];if(l.length===0){let v=typeof t=="string"?t:Object.entries(t).map(([E,H])=>`${E}: ${Array.isArray(H)?H.join(", "):H}`).join(" | ");this.appendMessage({id:`ask-user-answer-${i}`,role:"user",content:v,createdAt:new Date().toISOString(),streaming:!1,sequence:this.nextSequence()})}else{let v=s!=null?s:{};l.forEach((E,H)=>{let I=typeof(E==null?void 0:E.question)=="string"?E.question:"";if(!I)return;let P=v[I],z=Array.isArray(P)?P.join(", "):typeof P=="string"?P:"";this.appendMessage({id:`ask-user-q-${i}-${H}`,role:"assistant",content:I,createdAt:new Date().toISOString(),streaming:!1,sequence:this.nextSequence()}),this.appendMessage({id:`ask-user-a-${i}-${H}`,role:"user",content:z||"*Skipped*",createdAt:new Date().toISOString(),streaming:!1,sequence:this.nextSequence()})})}try{let v=await this.client.resumeFlow(n,{[a]:t});if(!v.ok){let E=await v.json().catch(()=>null);throw new Error((L=E==null?void 0:E.error)!=null?L:`Resume failed: ${v.status}`)}v.body?await this.connectStream(v.body,{allowReentry:!0}):(this.setStreaming(!1),this.abortController=null)}catch(v){let E=v instanceof Error&&(v.name==="AbortError"||v.message.includes("aborted")||v.message.includes("abort"));this.setStreaming(!1),this.abortController=null,E||(w=(x=this.callbacks).onError)==null||w.call(x,v instanceof Error?v:new Error(String(v)))}}enqueueWebMcpAwait(e){var a,s;let t=(a=e.agentMetadata)==null?void 0:a.executionId,o=(s=e.toolCall)==null?void 0:s.id;if(!t||!o){let i=this.webMcpEpoch;queueMicrotask(()=>{i===this.webMcpEpoch&&this.resolveWebMcpToolCall(e)});return}let n=this.webMcpAwaitBatches.get(t);n||(n={snapshots:[],seen:new Set},this.webMcpAwaitBatches.set(t,n)),!n.seen.has(o)&&(n.seen.add(o),n.snapshots.push(e))}scheduleWebMcpBatchFlush(){if(this.webMcpAwaitBatches.size===0)return;let e=this.webMcpEpoch;queueMicrotask(()=>{if(e===this.webMcpEpoch)for(let t of[...this.webMcpAwaitBatches.keys()])this.flushWebMcpAwaitBatch(t)})}flushWebMcpAwaitBatch(e){let t=this.webMcpAwaitBatches.get(e);if(!t)return;this.webMcpAwaitBatches.delete(e);let{snapshots:o}=t;o.length===1?this.resolveWebMcpToolCall(o[0]):o.length>1&&this.resolveWebMcpToolCallBatch(e,o)}resolveWebMcpToolStartedAt(e){var n,a;let t=this.messages.find(s=>s.id===e.id),o=[(n=t==null?void 0:t.toolCall)==null?void 0:n.startedAt,(a=e.toolCall)==null?void 0:a.startedAt];for(let s of o)if(typeof s=="number"&&Number.isFinite(s))return s;return Date.now()}isSuggestRepliesAlreadyResolved(e){var o,n;if(((o=e.toolCall)==null?void 0:o.name)!==en)return!1;let t=this.messages.find(a=>a.id===e.id);return((n=(t!=null?t:e).agentMetadata)==null?void 0:n.suggestRepliesResolved)===!0}markWebMcpToolRunning(e){let t=this.resolveWebMcpToolStartedAt(e);return this.upsertMessage({...e,streaming:!0,agentMetadata:{...e.agentMetadata,awaitingLocalTool:!1},toolCall:e.toolCall?{...e.toolCall,status:"running",startedAt:t,completedAt:void 0,duration:void 0,durationMs:void 0}:e.toolCall}),t}markWebMcpToolComplete(e,t,o,n=Date.now(),a){this.messages.some(s=>s.id===e.id)&&this.upsertMessage({...e,streaming:!1,agentMetadata:{...e.agentMetadata,awaitingLocalTool:!1,...a},toolCall:e.toolCall?{...e.toolCall,status:"complete",result:t,startedAt:o,completedAt:n,duration:void 0,durationMs:Math.max(0,n-o)}:e.toolCall})}async resolveWebMcpToolCallBatch(e,t){var d,l,u,f;let o=[],n=[],a=new AbortController;this.webMcpResolveControllers.add(a),this.setStreaming(!0);let s=await Promise.all(t.map(async p=>{var w,v,E,H,I,P,z;let m=(w=p.toolCall)==null?void 0:w.name,y=(v=p.toolCall)==null?void 0:v.id;if(!m||!y)return null;let h=`${e}:${y}`;if(this.webMcpInflightKeys.has(h)||this.webMcpResolvedKeys.has(h)||this.isSuggestRepliesAlreadyResolved(p))return null;this.webMcpInflightKeys.add(h),o.push(h);let T=this.markWebMcpToolRunning(p),M=(H=(E=p.agentMetadata)==null?void 0:E.webMcpToolCallId)!=null?H:m;if(m===en)return{dedupeKey:h,resumeKey:M,output:Ud(),toolMessage:p,startedAt:T,completedAt:Date.now()};let k=new AbortController;this.webMcpResolveControllers.add(k),n.push(k);let L=this.client.executeWebMcpToolCall(m,(I=p.toolCall)==null?void 0:I.args,k.signal),x;if(!L)x={isError:!0,content:[{type:"text",text:"WebMCP not enabled on this widget."}]};else try{x=await L}catch(j){let ie=j instanceof Error&&(j.name==="AbortError"||j.message.includes("aborted")||j.message.includes("abort"));return ie||(z=(P=this.callbacks).onError)==null||z.call(P,j instanceof Error?j:new Error(String(j))),this.markWebMcpToolComplete(p,Zs(ie?"Aborted by cancel()":mx(j)),T),this.webMcpInflightKeys.delete(h),null}return k.signal.aborted?(this.markWebMcpToolComplete(p,Zs("Aborted by cancel()"),T),this.webMcpInflightKeys.delete(h),null):{dedupeKey:h,resumeKey:M,output:x,toolMessage:p,startedAt:T,completedAt:Date.now()}})),i=[];try{if(i=s.filter(y=>y!==null),i.length===0)return;let p={};for(let y of i)p[y.resumeKey]=y.output;let m=await this.client.resumeFlow(e,p,{signal:a.signal});if(!m.ok){let y=await m.json().catch(()=>null);throw new Error((d=y==null?void 0:y.error)!=null?d:`Resume failed: ${m.status}`)}for(let y of i)this.webMcpResolvedKeys.add(y.dedupeKey),this.markWebMcpToolComplete(y.toolMessage,y.output,y.startedAt,y.completedAt,((l=y.toolMessage.toolCall)==null?void 0:l.name)===en?{suggestRepliesResolved:!0}:void 0);m.body&&await this.connectStream(m.body,{allowReentry:!0})}catch(p){if(!(p instanceof Error&&(p.name==="AbortError"||p.message.includes("aborted")||p.message.includes("abort"))))(f=(u=this.callbacks).onError)==null||f.call(u,p instanceof Error?p:new Error(String(p)));else for(let y of i)this.markWebMcpToolComplete(y.toolMessage,Zs("Aborted by cancel()"),y.startedAt)}finally{for(let p of o)this.webMcpInflightKeys.delete(p);for(let p of n)this.webMcpResolveControllers.delete(p);this.webMcpResolveControllers.delete(a),this.webMcpResolveControllers.size===0&&!this.abortController&&this.setStreaming(!1)}}async resolveWebMcpToolCall(e){var y,h,T,M,k,L,x,w,v,E,H,I;let t=(y=e.agentMetadata)==null?void 0:y.executionId,o=(h=e.toolCall)==null?void 0:h.name,n=(T=e.toolCall)==null?void 0:T.id;if(!t){(k=(M=this.callbacks).onError)==null||k.call(M,new Error("WebMCP step_await missing executionId \u2014 dispatch left paused."));return}if(!o)return;if(!n){let P=`${t}:__no_tool_id__:${o}`;if(this.webMcpInflightKeys.has(P)||this.webMcpResolvedKeys.has(P))return;this.webMcpInflightKeys.add(P);try{await this.resumeWithToolOutput(t,o,{isError:!0,content:[{type:"text",text:"WebMCP step_await missing toolCall.id \u2014 cannot execute the page tool."}]}),this.webMcpResolvedKeys.add(P)}catch(z){(x=(L=this.callbacks).onError)==null||x.call(L,z instanceof Error?z:new Error(String(z)))}finally{this.webMcpInflightKeys.delete(P)}return}let a=`${t}:${n}`;if(this.webMcpInflightKeys.has(a)||this.webMcpResolvedKeys.has(a)||this.isSuggestRepliesAlreadyResolved(e))return;this.webMcpInflightKeys.add(a);let s=this.markWebMcpToolRunning(e),i=new AbortController;this.webMcpResolveControllers.add(i);let{signal:d}=i;this.setStreaming(!0);let l=o===en,u=(w=e.toolCall)==null?void 0:w.args,f=l?null:this.client.executeWebMcpToolCall(o,u,d),p="execute",m=s;try{let P;if(l?P=Ud():f?P=await f:P={isError:!0,content:[{type:"text",text:"WebMCP not enabled on this widget."}]},m=Date.now(),d.aborted){this.markWebMcpToolComplete(e,Zs("Aborted by cancel()"),s);return}let z=(E=(v=e.agentMetadata)==null?void 0:v.webMcpToolCallId)!=null?E:o;p="resume",await this.resumeWithToolOutput(t,z,P,{onHttpOk:()=>{this.webMcpResolvedKeys.add(a),this.markWebMcpToolComplete(e,P,s,m,l?{suggestRepliesResolved:!0}:void 0)},signal:d})}catch(P){let z=P instanceof Error&&(P.name==="AbortError"||P.message.includes("aborted")||P.message.includes("abort"));(p==="execute"||z||d.aborted)&&this.markWebMcpToolComplete(e,Zs(z||d.aborted?"Aborted by cancel()":mx(P)),s),z||(I=(H=this.callbacks).onError)==null||I.call(H,P instanceof Error?P:new Error(String(P)))}finally{this.webMcpInflightKeys.delete(a),this.webMcpResolveControllers.delete(i),this.webMcpResolveControllers.size===0&&!this.abortController&&this.setStreaming(!1)}}async resumeWithToolOutput(e,t,o,n){var s,i;let a=await this.client.resumeFlow(e,{[t]:o},{signal:n==null?void 0:n.signal});if(!a.ok){let d=await a.json().catch(()=>null);throw new Error((s=d==null?void 0:d.error)!=null?s:`Resume failed: ${a.status}`)}(i=n==null?void 0:n.onHttpOk)==null||i.call(n),a.body?await this.connectStream(a.body,{allowReentry:!0}):this.webMcpResolveControllers.size===0&&(this.setStreaming(!1),this.abortController=null)}abortWebMcpResolves(){for(let e of this.webMcpResolveControllers)e.abort();this.webMcpResolveControllers.clear();for(let e of[...this.webMcpApprovalResolvers.keys()])this.resolveWebMcpApproval(e,"denied");this.webMcpAwaitBatches.clear(),this.webMcpEpoch++}cancel(){var e;(e=this.abortController)==null||e.abort(),this.abortController=null,this.abortWebMcpResolves(),this.webMcpInflightKeys.clear(),this.stopSpeaking(),this.stopVoicePlayback(),this.setStreaming(!1),this.setStatus("idle")}clearMessages(){var e;this.stopSpeaking(),(e=this.abortController)==null||e.abort(),this.abortController=null,this.abortWebMcpResolves(),this.messages=[],this.agentExecution=null,this.clearArtifactState(),this.webMcpInflightKeys.clear(),this.webMcpResolvedKeys.clear(),this.client.resetClientToolsFingerprint(),this.setStreaming(!1),this.setStatus("idle"),this.callbacks.onMessagesChanged([...this.messages])}getArtifacts(){return[...this.artifacts.values()]}getArtifactById(e){return this.artifacts.get(e)}getSelectedArtifactId(){return this.selectedArtifactId}selectArtifact(e){this.selectedArtifactId=e,this.emitArtifactsState()}clearArtifacts(){this.clearArtifactState()}upsertArtifact(e){var n;let t=e.id||`art_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,9)}`;if(e.artifactType==="markdown"){let a={id:t,artifactType:"markdown",title:e.title,status:"complete",markdown:e.content};return this.artifacts.set(t,a),this.selectedArtifactId=t,this.emitArtifactsState(),a}let o={id:t,artifactType:"component",title:e.title,status:"complete",component:e.component,props:(n=e.props)!=null?n:{}};return this.artifacts.set(t,o),this.selectedArtifactId=t,this.emitArtifactsState(),o}clearArtifactState(){this.artifacts.size===0&&this.selectedArtifactId===null||(this.artifacts.clear(),this.selectedArtifactId=null,this.emitArtifactsState())}emitArtifactsState(){var e,t;(t=(e=this.callbacks).onArtifactsState)==null||t.call(e,{artifacts:[...this.artifacts.values()],selectedId:this.selectedArtifactId})}applyArtifactStreamEvent(e){var t,o;switch(e.type){case"artifact_start":{e.artifactType==="markdown"?this.artifacts.set(e.id,{id:e.id,artifactType:"markdown",title:e.title,status:"streaming",markdown:""}):this.artifacts.set(e.id,{id:e.id,artifactType:"component",title:e.title,status:"streaming",component:(t=e.component)!=null?t:"",props:{}}),this.selectedArtifactId=e.id;break}case"artifact_delta":{let n=this.artifacts.get(e.id);(n==null?void 0:n.artifactType)==="markdown"&&(n.markdown=((o=n.markdown)!=null?o:"")+e.artDelta);break}case"artifact_update":{let n=this.artifacts.get(e.id);(n==null?void 0:n.artifactType)==="component"&&(n.props={...n.props,...e.props},e.component&&(n.component=e.component));break}case"artifact_complete":{let n=this.artifacts.get(e.id);n&&(n.status="complete");break}default:return}this.emitArtifactsState()}hydrateMessages(e){var t;(t=this.abortController)==null||t.abort(),this.abortController=null,this.abortWebMcpResolves(),this.webMcpInflightKeys.clear(),this.webMcpResolvedKeys.clear(),this.messages=this.sortMessages(e.map(o=>{var n;return{...o,streaming:!1,sequence:(n=o.sequence)!=null?n:this.nextSequence()}})),this.setStreaming(!1),this.setStatus("idle"),this.callbacks.onMessagesChanged([...this.messages])}hydrateArtifacts(e,t=null){this.artifacts.clear();for(let o of e)this.artifacts.set(o.id,{...o,status:"complete"});this.selectedArtifactId=t,this.emitArtifactsState()}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.onStatusChanged(e))}setStreaming(e){if(this.streaming===e)return;let t=this.streaming;this.streaming=e,this.callbacks.onStreamingChanged(e),t&&!e&&this.speakLatestAssistantMessage()}speakLatestAssistantMessage(){let e=this.config.textToSpeech;if(!(e!=null&&e.enabled)||!(!e.provider||e.provider==="browser"||e.provider==="runtype"&&e.browserFallback))return;let o=[...this.messages].reverse().find(a=>a.role==="assistant"&&a.content&&!a.voiceProcessing);if(!o)return;if(this.ttsSpokenMessageIds.has(o.id)){this.ttsSpokenMessageIds.delete(o.id);return}let n=o.content;n.trim()&&this.speak(n,e)}speak(e,t){if(typeof window=="undefined"||!("speechSynthesis"in window))return;let o=window.speechSynthesis;o.cancel();let n=new SpeechSynthesisUtterance(e),a=o.getVoices();if(t.voice){let s=a.find(i=>i.name===t.voice);s&&(n.voice=s)}else a.length>0&&(n.voice=t.pickVoice?t.pickVoice(a):r.pickBestVoice(a));t.rate!==void 0&&(n.rate=t.rate),t.pitch!==void 0&&(n.pitch=t.pitch),setTimeout(()=>o.speak(n),50)}static pickBestVoice(e){var o;let t=["Microsoft Jenny Online (Natural) - English (United States)","Microsoft Aria Online (Natural) - English (United States)","Microsoft Guy Online (Natural) - English (United States)","Google US English","Google UK English Female","Ava (Premium)","Evan (Enhanced)","Samantha (Enhanced)","Samantha","Daniel","Karen","Microsoft David Desktop - English (United States)","Microsoft Zira Desktop - English (United States)"];for(let n of t){let a=e.find(s=>s.name===n);if(a)return a}return(o=e.find(n=>n.lang.startsWith("en")))!=null?o:e[0]}stopSpeaking(){typeof window!="undefined"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}appendMessage(e){let t=this.ensureSequence(e);this.messages=this.sortMessages([...this.messages,t]),this.callbacks.onMessagesChanged([...this.messages])}upsertMessage(e){let t=this.ensureSequence(e),o=this.messages.findIndex(n=>n.id===t.id);if(o===-1){this.appendMessage(t);return}this.messages=this.messages.map((n,a)=>{var u,f,p,m,y,h,T,M,k,L,x,w,v,E,H;if(a!==o)return n;let s={...n,...t};if(((u=n.agentMetadata)==null?void 0:u.askUserQuestionAnswered)===!0&&t.agentMetadata&&(s.agentMetadata={...t.agentMetadata,askUserQuestionAnswered:!0,...n.agentMetadata.askUserQuestionAnswers?{askUserQuestionAnswers:n.agentMetadata.askUserQuestionAnswers}:{},awaitingLocalTool:!1}),((f=n.agentMetadata)==null?void 0:f.suggestRepliesResolved)===!0&&t.agentMetadata&&(s.agentMetadata={...(p=s.agentMetadata)!=null?p:t.agentMetadata,suggestRepliesResolved:!0,awaitingLocalTool:!1}),n.approval&&t.approval&&n.approval.id===t.approval.id){let I=n.approval,P=t.approval;s.approval={...I,...P,executionId:P.executionId||I.executionId,toolName:P.toolName||I.toolName,description:P.description||I.description,toolType:(m=P.toolType)!=null?m:I.toolType,reason:(y=P.reason)!=null?y:I.reason,parameters:(h=P.parameters)!=null?h:I.parameters}}let i=(T=t.toolCall)==null?void 0:T.name,d=(M=t.agentMetadata)==null?void 0:M.executionId,l=(k=t.toolCall)==null?void 0:k.id;if(i&&gx(i)&&d&&l&&((L=t.agentMetadata)==null?void 0:L.awaitingLocalTool)===!0){let I=`${d}:${l}`,P=this.webMcpInflightKeys.has(I),z=this.webMcpResolvedKeys.has(I),j=(x=n.toolCall)==null?void 0:x.name,ie=((w=n.agentMetadata)==null?void 0:w.executionId)===d&&((v=n.toolCall)==null?void 0:v.id)===l&&j!==void 0&&gx(j)&&((E=n.toolCall)==null?void 0:E.status)==="complete";(P||z||ie)&&(s.agentMetadata={...(H=s.agentMetadata)!=null?H:{},awaitingLocalTool:!1},s.toolCall=n.toolCall,s.streaming=n.streaming)}return s}),this.messages=this.sortMessages(this.messages),this.callbacks.onMessagesChanged([...this.messages])}ensureSequence(e){return e.sequence!==void 0?{...e}:{...e,sequence:this.nextSequence()}}nextSequence(){return this.sequenceCounter++}sortMessages(e){return[...e].sort((t,o)=>{var d,l;let n=new Date(t.createdAt).getTime(),a=new Date(o.createdAt).getTime();if(!Number.isNaN(n)&&!Number.isNaN(a)&&n!==a)return n-a;let s=(d=t.sequence)!=null?d:0,i=(l=o.sequence)!=null?l:0;return s!==i?s-i:t.id.localeCompare(o.id)})}};var Gd=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"}]];var Kd=[["path",{d:"M12 5v14"}],["path",{d:"m19 12-7 7-7-7"}]];var Xd=[["path",{d:"m12 19-7-7 7-7"}],["path",{d:"M19 12H5"}]];var Qd=[["path",{d:"M5 12h14"}],["path",{d:"m12 5 7 7-7 7"}]];var Yd=[["path",{d:"M7 7h10v10"}],["path",{d:"M7 17 17 7"}]];var Jd=[["path",{d:"m5 12 7-7 7 7"}],["path",{d:"M12 19V5"}]];var Zd=[["circle",{cx:"12",cy:"12",r:"4"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"}]];var ec=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M4.929 4.929 19.07 19.071"}]];var tc=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"}]];var rc=[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z"}]];var oc=[["path",{d:"M12 8V4H8"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}],["path",{d:"M2 14h2"}],["path",{d:"M20 14h2"}],["path",{d:"M15 13v2"}],["path",{d:"M9 13v2"}]];var nc=[["path",{d:"M12 10h.01"}],["path",{d:"M12 14h.01"}],["path",{d:"M12 6h.01"}],["path",{d:"M16 10h.01"}],["path",{d:"M16 14h.01"}],["path",{d:"M16 6h.01"}],["path",{d:"M8 10h.01"}],["path",{d:"M8 14h.01"}],["path",{d:"M8 6h.01"}],["path",{d:"M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2"}]];var ac=[["path",{d:"M8 2v4"}],["path",{d:"M16 2v4"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}],["path",{d:"M3 10h18"}],["path",{d:"M8 14h.01"}],["path",{d:"M12 14h.01"}],["path",{d:"M16 14h.01"}],["path",{d:"M8 18h.01"}],["path",{d:"M12 18h.01"}],["path",{d:"M16 18h.01"}]];var sc=[["path",{d:"M8 2v4"}],["path",{d:"M16 2v4"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}],["path",{d:"M3 10h18"}]];var ic=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z"}],["circle",{cx:"12",cy:"13",r:"3"}]];var lc=[["path",{d:"M20 6 9 17l-5-5"}]];var dc=[["path",{d:"m6 9 6 6 6-6"}]];var cc=[["path",{d:"m15 18-6-6 6-6"}]];var pc=[["path",{d:"m9 18 6-6-6-6"}]];var uc=[["path",{d:"m18 15-6-6-6 6"}]];var fl=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"m9 12 2 2 4-4"}]];var ml=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"m15 9-6 6"}],["path",{d:"m9 9 6 6"}]];var fc=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4"}],["path",{d:"M21 14H11"}],["path",{d:"m15 10-4 4 4 4"}]];var mc=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}]];var gc=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 6v6l4 2"}]];var hc=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"}]];var xc=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10"}]];var yc=[["line",{x1:"12",x2:"12",y1:"2",y2:"22"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"}]];var bc=[["path",{d:"M12 15V3"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}],["path",{d:"m7 10 5 5 5-5"}]];var gl=[["circle",{cx:"12",cy:"12",r:"1"}],["circle",{cx:"12",cy:"5",r:"1"}],["circle",{cx:"12",cy:"19",r:"1"}]];var hl=[["circle",{cx:"12",cy:"12",r:"1"}],["circle",{cx:"19",cy:"12",r:"1"}],["circle",{cx:"5",cy:"12",r:"1"}]];var vc=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}],["path",{d:"m2 2 20 20"}]];var Cc=[["path",{d:"M15 3h6v6"}],["path",{d:"M10 14 21 3"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}]];var wc=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}],["circle",{cx:"12",cy:"12",r:"3"}]];var Ac=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 12.5 8 15l2 2.5"}],["path",{d:"m14 12.5 2 2.5-2 2.5"}]];var Sc=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M8 13h2"}],["path",{d:"M14 13h2"}],["path",{d:"M8 17h2"}],["path",{d:"M14 17h2"}]];var Tc=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 9H8"}],["path",{d:"M16 13H8"}],["path",{d:"M16 17H8"}]];var Mc=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}]];var kc=[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1"}]];var Ec=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}],["path",{d:"M7 3v18"}],["path",{d:"M3 7.5h4"}],["path",{d:"M3 12h18"}],["path",{d:"M3 16.5h4"}],["path",{d:"M17 3v18"}],["path",{d:"M17 7.5h4"}],["path",{d:"M17 16.5h4"}]];var Lc=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528"}]];var Pc=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"}]];var Rc=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"}]];var xl=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"}]];var Ic=[["path",{d:"M12 7v14"}],["path",{d:"M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8"}],["path",{d:"M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5"}],["rect",{x:"3",y:"7",width:"18",height:"4",rx:"1"}]];var Hc=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}],["path",{d:"M2 12h20"}]];var Wc=[["line",{x1:"4",x2:"20",y1:"9",y2:"9"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21"}]];var Bc=[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3"}]];var Dc=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"}]];var Oc=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}],["path",{d:"M3 3v5h5"}],["path",{d:"M12 7v5l4 2"}]];var yl=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}]];var _c=[["path",{d:"M16 5h6"}],["path",{d:"M19 2v6"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"}],["circle",{cx:"9",cy:"9",r:"2"}]];var Nc=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}],["circle",{cx:"9",cy:"9",r:"2"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"}]];var Fc=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 16v-4"}],["path",{d:"M12 8h.01"}]];var Uc=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4"}],["path",{d:"m21 2-9.6 9.6"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5"}]];var qc=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"}]];var bl=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56"}]];var zc=[["path",{d:"M12 2v4"}],["path",{d:"m16.2 7.8 2.9-2.9"}],["path",{d:"M18 12h4"}],["path",{d:"m16.2 16.2 2.9 2.9"}],["path",{d:"M12 18v4"}],["path",{d:"m4.9 19.1 2.9-2.9"}],["path",{d:"M2 12h4"}],["path",{d:"m4.9 4.9 2.9 2.9"}]];var $c=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}]];var Vc=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}]];var jc=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"}],["circle",{cx:"12",cy:"10",r:"3"}]];var Gc=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3"}]];var Kc=[["path",{d:"M4 5h16"}],["path",{d:"M4 12h16"}],["path",{d:"M4 19h16"}]];var Xc=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"}]];var Qc=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"}]];var Yc=[["path",{d:"M12 19v3"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3"}]];var Jc=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3"}]];var Zc=[["path",{d:"M5 12h14"}]];var ep=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21"}]];var tp=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"}]];var rp=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z"}],["path",{d:"M12 22V12"}],["polyline",{points:"3.29 7 12 12 20.71 7"}],["path",{d:"m7.5 4.27 9 5.15"}]];var op=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551"}]];var np=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1"}]];var ap=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}],["path",{d:"m15 5 4 4"}]];var sp=[["line",{x1:"19",x2:"5",y1:"5",y2:"19"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5"}]];var ip=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384"}]];var lp=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"}]];var dp=[["path",{d:"M5 12h14"}],["path",{d:"M12 5v14"}]];var cp=[["path",{d:"M12 17V7"}],["path",{d:"M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8"}],["path",{d:"M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z"}]];var pp=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}],["path",{d:"M8 16H3v5"}]];var up=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}]];var fp=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7"}]];var mp=[["path",{d:"m21 21-4.34-4.34"}],["circle",{cx:"11",cy:"11",r:"8"}]];var gp=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"}],["path",{d:"m21.854 2.147-10.94 10.939"}]];var hp=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}],["circle",{cx:"12",cy:"12",r:"3"}]];var xp=[["path",{d:"M12 2v13"}],["path",{d:"m16 6-4-4-4 4"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"}]];var yp=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"M12 8v4"}],["path",{d:"M12 16h.01"}]];var bp=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"m9 12 2 2 4-4"}]];var vl=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"m14.5 9.5-5 5"}],["path",{d:"m9.5 9.5 5 5"}]];var vp=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}]];var Cp=[["path",{d:"M16 10a4 4 0 0 1-8 0"}],["path",{d:"M3.103 6.034h17.794"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z"}]];var wp=[["circle",{cx:"8",cy:"21",r:"1"}],["circle",{cx:"19",cy:"21",r:"1"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"}]];var Ap=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2"}],["path",{d:"M12 18h.01"}]];var Cl=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z"}],["path",{d:"M20 2v4"}],["path",{d:"M22 4h-4"}],["circle",{cx:"4",cy:"20",r:"2"}]];var Sp=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}]];var Tp=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"}]];var Mp=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05"}]];var kp=[["circle",{cx:"12",cy:"12",r:"4"}],["path",{d:"M12 2v2"}],["path",{d:"M12 20v2"}],["path",{d:"m4.93 4.93 1.41 1.41"}],["path",{d:"m17.66 17.66 1.41 1.41"}],["path",{d:"M2 12h2"}],["path",{d:"M20 12h2"}],["path",{d:"m6.34 17.66-1.41 1.41"}],["path",{d:"m19.07 4.93-1.41 1.41"}]];var Ep=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor"}]];var Lp=[["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"}],["path",{d:"M17 14V2"}]];var Pp=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"}],["path",{d:"M7 10v12"}]];var Rp=[["line",{x1:"10",x2:"14",y1:"2",y2:"2"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11"}],["circle",{cx:"12",cy:"14",r:"8"}]];var Ip=[["path",{d:"M10 11v6"}],["path",{d:"M14 11v6"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];var Hp=[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];var wl=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}],["path",{d:"M12 9v4"}],["path",{d:"M12 17h.01"}]];var Wp=[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2"}],["path",{d:"M15 18H9"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14"}],["circle",{cx:"17",cy:"18",r:"2"}],["circle",{cx:"7",cy:"18",r:"2"}]];var Bp=[["path",{d:"M12 3v12"}],["path",{d:"m17 8-5-5-5 5"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}]];var Dp=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}],["circle",{cx:"12",cy:"7",r:"4"}]];var Op=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"}],["path",{d:"M16 9a5 5 0 0 1 0 6"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728"}]];var _p=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15"}]];var Np=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"}]];var Fp=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];var Up=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"}]];var Tv={activity:Gd,"arrow-down":Kd,"arrow-up":Jd,"arrow-up-right":Yd,bot:oc,"chevron-down":dc,"chevron-up":uc,"chevron-right":pc,"chevron-left":cc,check:lc,clipboard:mc,"clipboard-copy":fc,copy:hc,file:Mc,"file-code":Ac,"file-spreadsheet":Sc,"file-text":Tc,"image-plus":_c,loader:zc,"loader-circle":bl,mic:Yc,paperclip:op,"refresh-cw":pp,search:mp,send:gp,"shield-alert":yp,"shield-check":bp,"shield-x":vl,square:Sp,"thumbs-down":Lp,"thumbs-up":Pp,upload:Bp,"volume-2":Op,x:Fp,user:Dp,mail:Vc,phone:ip,calendar:sc,clock:gc,building:nc,"map-pin":jc,lock:$c,key:Uc,"credit-card":xc,"at-sign":Zd,hash:Wc,globe:Hc,link:qc,"circle-check":fl,"circle-x":ml,"triangle-alert":wl,info:Fc,ban:ec,shield:vp,"arrow-left":Xd,"arrow-right":Qd,"external-link":Cc,ellipsis:hl,"ellipsis-vertical":gl,menu:Kc,house:yl,plus:dp,minus:Zc,pencil:ap,trash:Hp,"trash-2":Ip,save:fp,download:bc,share:xp,funnel:xl,settings:hp,"rotate-cw":up,maximize:Gc,minimize:Jc,"shopping-cart":wp,"shopping-bag":Cp,package:rp,truck:Wp,tag:Ep,gift:Ic,receipt:cp,wallet:Np,store:Mp,"dollar-sign":yc,percent:sp,play:lp,pause:np,"volume-x":_p,camera:ic,image:Nc,film:Ec,headphones:Bc,"message-circle":Xc,"message-square":Qc,bell:tc,heart:Dc,star:Tp,eye:wc,"eye-off":vc,bookmark:rc,"calendar-days":ac,history:Oc,timer:Rp,folder:Rc,"folder-open":Pc,files:kc,sparkles:Cl,zap:Up,sun:kp,moon:tp,flag:Lc,monitor:ep,smartphone:Ap},Ee=(r,e=24,t="currentColor",o=2)=>{let n=Tv[r];return n?Mv(n,e,t,o):(console.warn(`Lucide icon "${r}" is not in the Persona registry. Add it to packages/widget/src/utils/icons.ts (see docs/icon-registry-shortlist.md).`),null)};function Mv(r,e,t,o){if(!Array.isArray(r))return null;let n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("width",String(e)),n.setAttribute("height",String(e)),n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("fill","none"),n.setAttribute("stroke",t),n.setAttribute("stroke-width",String(o)),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true"),r.forEach(a=>{if(!Array.isArray(a)||a.length<2)return;let s=a[0],i=a[1];if(!i)return;let d=document.createElementNS("http://www.w3.org/2000/svg",s);Object.entries(i).forEach(([l,u])=>{l!=="stroke"&&d.setAttribute(l,String(u))}),n.appendChild(d)}),n}var Al={allowedTypes:Tn,maxFileSize:10*1024*1024,maxFiles:4};function kv(){return`attach_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function Ev(r){return r==="application/pdf"||r.startsWith("text/")||r.includes("word")?"file-text":r.includes("excel")||r.includes("spreadsheet")?"file-spreadsheet":r==="application/json"?"file-code":"file"}var wa=class r{constructor(e={}){this.attachments=[];this.previewsContainer=null;var t,o,n;this.config={allowedTypes:(t=e.allowedTypes)!=null?t:Al.allowedTypes,maxFileSize:(o=e.maxFileSize)!=null?o:Al.maxFileSize,maxFiles:(n=e.maxFiles)!=null?n:Al.maxFiles,onFileRejected:e.onFileRejected,onAttachmentsChange:e.onAttachmentsChange}}setPreviewsContainer(e){this.previewsContainer=e}updateConfig(e){e.allowedTypes!==void 0&&(this.config.allowedTypes=e.allowedTypes.length>0?e.allowedTypes:Al.allowedTypes),e.maxFileSize!==void 0&&(this.config.maxFileSize=e.maxFileSize),e.maxFiles!==void 0&&(this.config.maxFiles=e.maxFiles),e.onFileRejected!==void 0&&(this.config.onFileRejected=e.onFileRejected),e.onAttachmentsChange!==void 0&&(this.config.onAttachmentsChange=e.onAttachmentsChange)}getAttachments(){return[...this.attachments]}getContentParts(){return this.attachments.map(e=>e.contentPart)}hasAttachments(){return this.attachments.length>0}count(){return this.attachments.length}async handleFileSelect(e){!e||e.length===0||await this.handleFiles(Array.from(e))}async handleFiles(e){var t,o,n,a,s,i,d;if(e.length){for(let l of e){if(this.attachments.length>=this.config.maxFiles){(o=(t=this.config).onFileRejected)==null||o.call(t,l,"count");continue}let u=px(l,this.config.allowedTypes,this.config.maxFileSize);if(!u.valid){let f=(n=u.error)!=null&&n.includes("type")?"type":"size";(s=(a=this.config).onFileRejected)==null||s.call(a,l,f);continue}try{let f=await cx(l),p=dl(l)?URL.createObjectURL(l):null,m={id:kv(),file:l,previewUrl:p,contentPart:f};this.attachments.push(m),this.renderPreview(m)}catch(f){console.error("[AttachmentManager] Failed to process file:",f)}}this.updatePreviewsVisibility(),(d=(i=this.config).onAttachmentsChange)==null||d.call(i,this.getAttachments())}}removeAttachment(e){var a,s,i;let t=this.attachments.findIndex(d=>d.id===e);if(t===-1)return;let o=this.attachments[t];o.previewUrl&&URL.revokeObjectURL(o.previewUrl),this.attachments.splice(t,1);let n=(a=this.previewsContainer)==null?void 0:a.querySelector(`[data-attachment-id="${e}"]`);n&&n.remove(),this.updatePreviewsVisibility(),(i=(s=this.config).onAttachmentsChange)==null||i.call(s,this.getAttachments())}clearAttachments(){var e,t;for(let o of this.attachments)o.previewUrl&&URL.revokeObjectURL(o.previewUrl);this.attachments=[],this.previewsContainer&&(this.previewsContainer.innerHTML=""),this.updatePreviewsVisibility(),(t=(e=this.config).onAttachmentsChange)==null||t.call(e,this.getAttachments())}renderPreview(e){if(!this.previewsContainer)return;let t=dl(e.file),o=C("div","persona-attachment-preview persona-relative persona-inline-block");if(o.setAttribute("data-attachment-id",e.id),o.style.width="48px",o.style.height="48px",t&&e.previewUrl){let s=C("img");s.src=e.previewUrl,s.alt=e.file.name,s.className="persona-w-full persona-h-full persona-object-cover persona-rounded-lg persona-border persona-border-gray-200",s.style.width="48px",s.style.height="48px",s.style.objectFit="cover",s.style.borderRadius="8px",o.appendChild(s)}else{let s=C("div");s.style.width="48px",s.style.height="48px",s.style.borderRadius="8px",s.style.backgroundColor="var(--persona-container, #f3f4f6)",s.style.border="1px solid var(--persona-border, #e5e7eb)",s.style.display="flex",s.style.flexDirection="column",s.style.alignItems="center",s.style.justifyContent="center",s.style.gap="2px",s.style.overflow="hidden";let i=Ev(e.file.type),d=Ee(i,20,"var(--persona-muted, #6b7280)",1.5);d&&s.appendChild(d);let l=C("span");l.textContent=ux(e.file.type,e.file.name),l.style.fontSize="8px",l.style.fontWeight="600",l.style.color="var(--persona-muted, #6b7280)",l.style.textTransform="uppercase",l.style.lineHeight="1",s.appendChild(l),o.appendChild(s)}let n=C("button","persona-attachment-remove persona-absolute persona-flex persona-items-center persona-justify-center");n.type="button",n.setAttribute("aria-label","Remove attachment"),n.style.position="absolute",n.style.top="-4px",n.style.right="-4px",n.style.width="18px",n.style.height="18px",n.style.borderRadius="50%",n.style.backgroundColor="var(--persona-palette-colors-black-alpha-60, rgba(0, 0, 0, 0.6))",n.style.border="none",n.style.cursor="pointer",n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="center",n.style.padding="0";let a=Ee("x",10,"var(--persona-text-inverse, #ffffff)",2);a?n.appendChild(a):(n.textContent="\xD7",n.style.color="var(--persona-text-inverse, #ffffff)",n.style.fontSize="14px",n.style.lineHeight="1"),n.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),this.removeAttachment(e.id)}),o.appendChild(n),this.previewsContainer.appendChild(o)}updatePreviewsVisibility(){this.previewsContainer&&(this.previewsContainer.style.display=this.attachments.length>0?"flex":"none")}static fromConfig(e,t){return new r({allowedTypes:e==null?void 0:e.allowedTypes,maxFileSize:e==null?void 0:e.maxFileSize,maxFiles:e==null?void 0:e.maxFiles,onFileRejected:e==null?void 0:e.onFileRejected,onAttachmentsChange:t})}};var hx=r=>typeof r=="object"&&r!==null&&!Array.isArray(r);function ei(r,e){if(!r)return e;if(!e)return r;let t={...r};for(let[o,n]of Object.entries(e)){let a=t[o];hx(a)&&hx(n)?t[o]=ei(a,n):t[o]=n}return t}var Wo="min(440px, calc(100vw - 24px))",Sl="440px",Xt={apiUrl:"https://api.runtype.com/api/chat/dispatch",clientToken:void 0,theme:void 0,darkTheme:void 0,colorScheme:"light",launcher:{enabled:!0,mountMode:"floating",dock:{side:"right",width:"420px"},title:"Chat Assistant",subtitle:"Here to help you get answers fast",agentIconText:"\u{1F4AC}",agentIconName:"bot",headerIconName:"bot",position:"bottom-right",width:Wo,heightOffset:0,autoExpand:!1,callToActionIconHidden:!1,agentIconSize:"40px",headerIconSize:"40px",closeButtonSize:"32px",closeButtonPaddingX:"0px",closeButtonPaddingY:"0px",callToActionIconName:"arrow-up-right",callToActionIconText:"",callToActionIconSize:"32px",callToActionIconPadding:"5px",callToActionIconColor:void 0,callToActionIconBackgroundColor:void 0,closeButtonBackgroundColor:"transparent",clearChat:{backgroundColor:"transparent",borderColor:"transparent",enabled:!0,placement:"inline",iconName:"refresh-cw",size:"32px",showTooltip:!0,tooltipText:"Clear chat",paddingX:"0px",paddingY:"0px"},headerIconHidden:!1,border:void 0,shadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)"},copy:{welcomeTitle:"Hello \u{1F44B}",welcomeSubtitle:"Ask anything about your account or products.",inputPlaceholder:"How can I help...",sendButtonLabel:"Send"},sendButton:{borderWidth:"0px",paddingX:"12px",paddingY:"10px",borderColor:void 0,useIcon:!0,iconText:"\u2191",size:"40px",showTooltip:!0,tooltipText:"Send message",iconName:"send"},statusIndicator:{visible:!0,idleText:"Online",connectingText:"Connecting\u2026",connectedText:"Streaming\u2026",errorText:"Offline"},voiceRecognition:{enabled:!0,pauseDuration:2e3,iconName:"mic",iconSize:"39px",borderWidth:"0px",paddingX:"9px",paddingY:"14px",iconColor:void 0,backgroundColor:"transparent",borderColor:"transparent",recordingIconColor:void 0,recordingBackgroundColor:void 0,recordingBorderColor:"transparent",showTooltip:!0,tooltipText:"Start voice recognition"},features:{showReasoning:!0,showToolCalls:!0,scrollToBottom:{enabled:!0,iconName:"arrow-down",label:""},scrollBehavior:{mode:"follow",anchorTopOffset:16},toolCallDisplay:{collapsedMode:"tool-call",activePreview:!1,grouped:!1,previewMaxLines:3,expandable:!0,loadingAnimation:"none"},reasoningDisplay:{activePreview:!1,previewMaxLines:3,expandable:!0,loadingAnimation:"none"},streamAnimation:{type:"none",placeholder:"none",speed:120,duration:1800},askUserQuestion:{enabled:!0,slideInMs:180,freeTextLabel:"Other\u2026",freeTextPlaceholder:"Type your answer\u2026",submitLabel:"Send"}},suggestionChips:["What can you help me with?","Tell me about your features","How does this work?"],suggestionChipsConfig:{fontFamily:"sans-serif",fontWeight:"500",paddingX:"12px",paddingY:"6px"},layout:{header:{layout:"default",showIcon:!0,showTitle:!0,showSubtitle:!0,showCloseButton:!0,showClearChat:!0},messages:{layout:"bubble",avatar:{show:!1,position:"left"},timestamp:{show:!1,position:"below"},groupConsecutive:!1},slots:{}},markdown:{options:{gfm:!0,breaks:!0},disableDefaultStyles:!1},messageActions:{enabled:!0,showCopy:!0,showUpvote:!1,showDownvote:!1,visibility:"hover",align:"right",layout:"pill-inside"},debug:!1};function xx(r,e){if(!(!r&&!e))return r?e?ei(r,e):r:e}function Tl(r){var e,t,o,n,a,s,i,d,l,u,f,p,m,y,h,T,M,k,L,x,w;return r?{...Xt,...r,theme:xx(Xt.theme,r.theme),darkTheme:xx(Xt.darkTheme,r.darkTheme),launcher:{...Xt.launcher,...r.launcher,dock:{...(e=Xt.launcher)==null?void 0:e.dock,...(t=r.launcher)==null?void 0:t.dock},clearChat:{...(o=Xt.launcher)==null?void 0:o.clearChat,...(n=r.launcher)==null?void 0:n.clearChat}},copy:{...Xt.copy,...r.copy},sendButton:{...Xt.sendButton,...r.sendButton},statusIndicator:{...Xt.statusIndicator,...r.statusIndicator},voiceRecognition:{...Xt.voiceRecognition,...r.voiceRecognition},features:(()=>{var Z,ne,me,be,ye,Y,ge,Oe,ce,ae;let v=(Z=Xt.features)==null?void 0:Z.artifacts,E=(ne=r.features)==null?void 0:ne.artifacts,H=(me=Xt.features)==null?void 0:me.scrollToBottom,I=(be=r.features)==null?void 0:be.scrollToBottom,P=(ye=Xt.features)==null?void 0:ye.scrollBehavior,z=(Y=r.features)==null?void 0:Y.scrollBehavior,j=(ge=Xt.features)==null?void 0:ge.streamAnimation,ie=(Oe=r.features)==null?void 0:Oe.streamAnimation,ve=(ce=Xt.features)==null?void 0:ce.askUserQuestion,Xe=(ae=r.features)==null?void 0:ae.askUserQuestion,Ae=v===void 0&&E===void 0?void 0:{...v,...E,layout:{...v==null?void 0:v.layout,...E==null?void 0:E.layout}},We=H===void 0&&I===void 0?void 0:{...H,...I},Me=P===void 0&&z===void 0?void 0:{...P,...z},Ue=j===void 0&&ie===void 0?void 0:{...j,...ie},Be=ve===void 0&&Xe===void 0?void 0:{...ve,...Xe,styles:{...ve==null?void 0:ve.styles,...Xe==null?void 0:Xe.styles}};return{...Xt.features,...r.features,...We!==void 0?{scrollToBottom:We}:{},...Me!==void 0?{scrollBehavior:Me}:{},...Ae!==void 0?{artifacts:Ae}:{},...Ue!==void 0?{streamAnimation:Ue}:{},...Be!==void 0?{askUserQuestion:Be}:{}}})(),suggestionChips:(a=r.suggestionChips)!=null?a:Xt.suggestionChips,suggestionChipsConfig:{...Xt.suggestionChipsConfig,...r.suggestionChipsConfig},layout:{...Xt.layout,...r.layout,header:{...(s=Xt.layout)==null?void 0:s.header,...(i=r.layout)==null?void 0:i.header},messages:{...(d=Xt.layout)==null?void 0:d.messages,...(l=r.layout)==null?void 0:l.messages,avatar:{...(f=(u=Xt.layout)==null?void 0:u.messages)==null?void 0:f.avatar,...(m=(p=r.layout)==null?void 0:p.messages)==null?void 0:m.avatar},timestamp:{...(h=(y=Xt.layout)==null?void 0:y.messages)==null?void 0:h.timestamp,...(M=(T=r.layout)==null?void 0:T.messages)==null?void 0:M.timestamp}},slots:{...(k=Xt.layout)==null?void 0:k.slots,...(L=r.layout)==null?void 0:L.slots}},markdown:{...Xt.markdown,...r.markdown,options:{...(x=Xt.markdown)==null?void 0:x.options,...(w=r.markdown)==null?void 0:w.options}},messageActions:{...Xt.messageActions,...r.messageActions}}:Xt}var qp={colors:{primary:{50:"#ffffff",100:"#f5f5f5",200:"#d4d4d4",300:"#a3a3a3",400:"#737373",500:"#171717",600:"#0f0f0f",700:"#0a0a0a",800:"#050505",900:"#030303",950:"#000000"},secondary:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},accent:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},success:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d"},warning:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12"},error:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d"},info:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"}},spacing:{0:"0px",1:"0.25rem",2:"0.5rem",3:"0.75rem",4:"1rem",5:"1.25rem",6:"1.5rem",8:"2rem",10:"2.5rem",12:"3rem",16:"4rem",20:"5rem",24:"6rem",32:"8rem",40:"10rem",48:"12rem",56:"14rem",64:"16rem"},typography:{fontFamily:{sans:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',serif:'Georgia, Cambria, "Times New Roman", Times, serif',mono:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"},fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem"},fontWeight:{normal:"400",medium:"500",semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5",relaxed:"1.625"}},shadows:{none:"none",sm:"0 1px 2px 0 rgb(0 0 0 / 0.05)",md:"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",lg:"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)",xl:"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)","2xl":"0 25px 50px -12px rgb(0 0 0 / 0.25)"},borders:{none:"none",sm:"1px solid",md:"2px solid",lg:"4px solid"},radius:{none:"0px",sm:"0.125rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem",full:"9999px"}},zp={colors:{primary:"palette.colors.primary.500",secondary:"palette.colors.secondary.500",accent:"palette.colors.primary.600",surface:"palette.colors.gray.50",background:"palette.colors.gray.50",container:"palette.colors.gray.50",text:"palette.colors.gray.900",textMuted:"palette.colors.gray.500",textInverse:"palette.colors.gray.50",border:"palette.colors.gray.200",divider:"palette.colors.gray.200",interactive:{default:"palette.colors.primary.600",hover:"palette.colors.primary.700",focus:"palette.colors.primary.600",active:"palette.colors.primary.600",disabled:"palette.colors.gray.300"},feedback:{success:"palette.colors.success.500",warning:"palette.colors.warning.500",error:"palette.colors.error.500",info:"palette.colors.info.500"}},spacing:{xs:"palette.spacing.1",sm:"palette.spacing.2",md:"palette.spacing.4",lg:"palette.spacing.6",xl:"palette.spacing.8","2xl":"palette.spacing.10"},typography:{fontFamily:"palette.typography.fontFamily.sans",fontSize:"palette.typography.fontSize.base",fontWeight:"palette.typography.fontWeight.normal",lineHeight:"palette.typography.lineHeight.normal"}},$p={button:{primary:{background:"palette.colors.primary.500",foreground:"palette.colors.primary.50",borderRadius:"palette.radius.lg",padding:"semantic.spacing.md"},secondary:{background:"semantic.colors.surface",foreground:"semantic.colors.secondary",borderRadius:"palette.radius.lg",padding:"semantic.spacing.md"},ghost:{background:"transparent",foreground:"semantic.colors.text",borderRadius:"palette.radius.md",padding:"semantic.spacing.sm"}},input:{background:"palette.colors.gray.50",placeholder:"palette.colors.gray.400",borderRadius:"palette.radius.lg",padding:"semantic.spacing.md",focus:{border:"palette.colors.gray.400",ring:"palette.colors.gray.400"}},launcher:{background:"palette.colors.primary.500",foreground:"palette.colors.primary.50",border:"palette.colors.gray.200",size:"60px",iconSize:"28px",borderRadius:"palette.radius.full",shadow:"palette.shadows.lg"},panel:{width:Wo,maxWidth:Sl,height:"600px",maxHeight:"calc(100vh - 80px)",borderRadius:"palette.radius.xl",shadow:"palette.shadows.xl"},header:{background:"palette.colors.primary.500",border:"palette.colors.primary.600",borderRadius:"palette.radius.xl palette.radius.xl 0 0",padding:"semantic.spacing.md",iconBackground:"palette.colors.primary.600",iconForeground:"palette.colors.primary.50",titleForeground:"palette.colors.primary.50",subtitleForeground:"palette.colors.primary.200",actionIconForeground:"palette.colors.primary.200"},message:{user:{background:"palette.colors.primary.500",text:"palette.colors.primary.50",borderRadius:"palette.radius.lg",shadow:"palette.shadows.sm"},assistant:{background:"palette.colors.gray.50",text:"palette.colors.gray.900",borderRadius:"palette.radius.lg",border:"palette.colors.gray.200",shadow:"palette.shadows.sm"},border:"semantic.colors.border"},introCard:{background:"semantic.colors.surface",borderRadius:"palette.radius.2xl",padding:"semantic.spacing.lg",shadow:"0 5px 15px rgba(15, 23, 42, 0.08)"},toolBubble:{shadow:"palette.shadows.sm"},reasoningBubble:{shadow:"palette.shadows.sm"},composer:{shadow:"palette.shadows.none"},markdown:{inlineCode:{background:"palette.colors.gray.50",foreground:"palette.colors.gray.900"},link:{foreground:"palette.colors.primary.600"},prose:{fontFamily:"inherit"},codeBlock:{background:"semantic.colors.container",borderColor:"semantic.colors.border",textColor:"inherit"},table:{headerBackground:"semantic.colors.container",borderColor:"semantic.colors.border"},hr:{color:"semantic.colors.divider"},blockquote:{borderColor:"palette.colors.gray.900",background:"transparent",textColor:"palette.colors.gray.500"}},collapsibleWidget:{container:"palette.colors.gray.50",surface:"semantic.colors.surface",border:"semantic.colors.border"},voice:{recording:{indicator:"palette.colors.error.500",background:"palette.colors.error.50",border:"palette.colors.error.200"},processing:{icon:"palette.colors.primary.500",background:"palette.colors.primary.50"},speaking:{icon:"palette.colors.success.500"}},approval:{requested:{background:"palette.colors.warning.50",border:"palette.colors.warning.200",text:"palette.colors.gray.900",shadow:"0 5px 15px rgba(15, 23, 42, 0.08)"},approve:{background:"palette.colors.success.500",foreground:"palette.colors.gray.50",borderRadius:"palette.radius.md",padding:"semantic.spacing.sm"},deny:{background:"palette.colors.error.500",foreground:"palette.colors.gray.50",borderRadius:"palette.radius.md",padding:"semantic.spacing.sm"}},attachment:{image:{background:"palette.colors.gray.100",border:"palette.colors.gray.200"}},scrollToBottom:{background:"components.button.primary.background",foreground:"components.button.primary.foreground",border:"semantic.colors.primary",size:"40px",borderRadius:"palette.radius.full",shadow:"palette.shadows.sm",padding:"0.5rem 0.875rem",gap:"0.5rem",fontSize:"0.875rem",iconSize:"14px"},artifact:{pane:{background:"semantic.colors.container",toolbarBackground:"semantic.colors.container"}}};function es(r,e){if(!e.startsWith("palette.")&&!e.startsWith("semantic.")&&!e.startsWith("components."))return e;let t=e.split("."),o=r;for(let n of t){if(o==null)return;o=o[n]}return typeof o=="string"&&(o.startsWith("palette.")||o.startsWith("semantic.")||o.startsWith("components."))?es(r,o):o}function Ml(r){let e={};function t(o,n){for(let[a,s]of Object.entries(o)){let i=`${n}.${a}`;if(typeof s=="string"){let d=es(r,s);d!==void 0&&(e[i]={path:i,value:d,type:n.includes("color")?"color":n.includes("spacing")?"spacing":n.includes("typography")?"typography":n.includes("shadow")?"shadow":n.includes("border")?"border":"color"})}else typeof s=="object"&&s!==null&&t(s,i)}}return t(r.palette,"palette"),t(r.semantic,"semantic"),t(r.components,"components"),e}function Vp(r){let e=[],t=[];return r.palette||e.push({path:"palette",message:"Theme must include a palette",severity:"error"}),r.semantic||t.push({path:"semantic",message:"No semantic tokens defined - defaults will be used",severity:"warning"}),r.components||t.push({path:"components",message:"No component tokens defined - defaults will be used",severity:"warning"}),{valid:e.length===0,errors:e,warnings:t}}function yx(r,e){let t={...r};for(let[o,n]of Object.entries(e)){let a=t[o];a&&typeof a=="object"&&!Array.isArray(a)&&n&&typeof n=="object"&&!Array.isArray(n)?t[o]=yx(a,n):t[o]=n}return t}function Lv(r,e){return e?yx(r,e):r}function ts(r,e={}){var n,a,s,i,d,l,u,f,p,m,y,h,T;let t={palette:qp,semantic:zp,components:$p},o={palette:{...t.palette,...r==null?void 0:r.palette,colors:{...t.palette.colors,...(n=r==null?void 0:r.palette)==null?void 0:n.colors},spacing:{...t.palette.spacing,...(a=r==null?void 0:r.palette)==null?void 0:a.spacing},typography:{...t.palette.typography,...(s=r==null?void 0:r.palette)==null?void 0:s.typography},shadows:{...t.palette.shadows,...(i=r==null?void 0:r.palette)==null?void 0:i.shadows},borders:{...t.palette.borders,...(d=r==null?void 0:r.palette)==null?void 0:d.borders},radius:{...t.palette.radius,...(l=r==null?void 0:r.palette)==null?void 0:l.radius}},semantic:{...t.semantic,...r==null?void 0:r.semantic,colors:{...t.semantic.colors,...(u=r==null?void 0:r.semantic)==null?void 0:u.colors,interactive:{...t.semantic.colors.interactive,...(p=(f=r==null?void 0:r.semantic)==null?void 0:f.colors)==null?void 0:p.interactive},feedback:{...t.semantic.colors.feedback,...(y=(m=r==null?void 0:r.semantic)==null?void 0:m.colors)==null?void 0:y.feedback}},spacing:{...t.semantic.spacing,...(h=r==null?void 0:r.semantic)==null?void 0:h.spacing},typography:{...t.semantic.typography,...(T=r==null?void 0:r.semantic)==null?void 0:T.typography}},components:Lv(t.components,r==null?void 0:r.components)};if(e.validate!==!1){let M=Vp(o);if(!M.valid)throw new Error(`Theme validation failed: ${M.errors.map(k=>k.message).join(", ")}`)}if(e.plugins)for(let M of e.plugins)o=M.transform(o);return o}function kl(r){var h,T,M,k,L,x,w,v,E,H,I,P,z,j,ie,ve,Xe,Ae,We,Me,Ue,Be,Z,ne,me,be,ye,Y,ge,Oe,ce,ae,Q,Tt,Ye,De,le,nt,Re,K,he,it,Pt,te,_e,Ar,Rt,dr,Yr,zr,O,fe,Ie,Je,qe,ze,lt,Mt,Dt,or,X,wt,ct,Ce,de,rt,Ft,zt,Pr,vr,xt,It,tt,jt,cr,Dr,hr,Sr,Oo,je,Tr,io,_o,lo,At,rn,No,mn,Jr,Ln,$r,Fo,mt,co,po,Or,Wt,Vr,Zr,_r,uo,fo,Nr,mo,$t,Fr,go,on,Uo,nn,qo,eo,to,gt,re,A,_,ue;let e=Ml(r),t={};for(let[$,at]of Object.entries(e)){let ut=$.replace(/\./g,"-");t[`--persona-${ut}`]=at.value}t["--persona-primary"]=(h=t["--persona-semantic-colors-primary"])!=null?h:t["--persona-palette-colors-primary-500"],t["--persona-secondary"]=(T=t["--persona-semantic-colors-secondary"])!=null?T:t["--persona-palette-colors-secondary-500"],t["--persona-accent"]=(M=t["--persona-semantic-colors-accent"])!=null?M:t["--persona-palette-colors-accent-500"],t["--persona-surface"]=(k=t["--persona-semantic-colors-surface"])!=null?k:t["--persona-palette-colors-gray-50"],t["--persona-background"]=(L=t["--persona-semantic-colors-background"])!=null?L:t["--persona-palette-colors-gray-50"],t["--persona-container"]=(x=t["--persona-semantic-colors-container"])!=null?x:t["--persona-palette-colors-gray-100"],t["--persona-text"]=(w=t["--persona-semantic-colors-text"])!=null?w:t["--persona-palette-colors-gray-900"],t["--persona-text-muted"]=(v=t["--persona-semantic-colors-text-muted"])!=null?v:t["--persona-palette-colors-gray-500"],t["--persona-text-inverse"]=(E=t["--persona-semantic-colors-text-inverse"])!=null?E:t["--persona-palette-colors-gray-50"],t["--persona-border"]=(H=t["--persona-semantic-colors-border"])!=null?H:t["--persona-palette-colors-gray-200"],t["--persona-divider"]=(I=t["--persona-semantic-colors-divider"])!=null?I:t["--persona-palette-colors-gray-200"],t["--persona-muted"]=t["--persona-text-muted"],t["--persona-voice-recording-indicator"]=(P=t["--persona-components-voice-recording-indicator"])!=null?P:t["--persona-palette-colors-error-500"],t["--persona-voice-recording-bg"]=(z=t["--persona-components-voice-recording-background"])!=null?z:t["--persona-palette-colors-error-50"],t["--persona-voice-processing-icon"]=(j=t["--persona-components-voice-processing-icon"])!=null?j:t["--persona-palette-colors-primary-500"],t["--persona-voice-speaking-icon"]=(ie=t["--persona-components-voice-speaking-icon"])!=null?ie:t["--persona-palette-colors-success-500"],t["--persona-approval-bg"]=(ve=t["--persona-components-approval-requested-background"])!=null?ve:t["--persona-palette-colors-warning-50"],t["--persona-approval-border"]=(Xe=t["--persona-components-approval-requested-border"])!=null?Xe:t["--persona-palette-colors-warning-200"],t["--persona-approval-text"]=(Ae=t["--persona-components-approval-requested-text"])!=null?Ae:t["--persona-palette-colors-gray-900"],t["--persona-approval-shadow"]=(We=t["--persona-components-approval-requested-shadow"])!=null?We:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-approval-approve-bg"]=(Me=t["--persona-components-approval-approve-background"])!=null?Me:t["--persona-palette-colors-success-500"],t["--persona-approval-deny-bg"]=(Ue=t["--persona-components-approval-deny-background"])!=null?Ue:t["--persona-palette-colors-error-500"],t["--persona-attachment-image-bg"]=(Be=t["--persona-components-attachment-image-background"])!=null?Be:t["--persona-palette-colors-gray-100"],t["--persona-attachment-image-border"]=(Z=t["--persona-components-attachment-image-border"])!=null?Z:t["--persona-palette-colors-gray-200"],t["--persona-font-family"]=(ne=t["--persona-semantic-typography-fontFamily"])!=null?ne:t["--persona-palette-typography-fontFamily-sans"],t["--persona-font-size"]=(me=t["--persona-semantic-typography-fontSize"])!=null?me:t["--persona-palette-typography-fontSize-base"],t["--persona-font-weight"]=(be=t["--persona-semantic-typography-fontWeight"])!=null?be:t["--persona-palette-typography-fontWeight-normal"],t["--persona-line-height"]=(ye=t["--persona-semantic-typography-lineHeight"])!=null?ye:t["--persona-palette-typography-lineHeight-normal"],t["--persona-input-font-family"]=t["--persona-font-family"],t["--persona-input-font-weight"]=t["--persona-font-weight"],t["--persona-radius-sm"]=(Y=t["--persona-palette-radius-sm"])!=null?Y:"0.125rem",t["--persona-radius-md"]=(ge=t["--persona-palette-radius-md"])!=null?ge:"0.375rem",t["--persona-radius-lg"]=(Oe=t["--persona-palette-radius-lg"])!=null?Oe:"0.5rem",t["--persona-radius-xl"]=(ce=t["--persona-palette-radius-xl"])!=null?ce:"0.75rem",t["--persona-radius-full"]=(ae=t["--persona-palette-radius-full"])!=null?ae:"9999px",t["--persona-launcher-radius"]=(Tt=(Q=t["--persona-components-launcher-borderRadius"])!=null?Q:t["--persona-palette-radius-full"])!=null?Tt:"9999px",t["--persona-launcher-bg"]=(Ye=t["--persona-components-launcher-background"])!=null?Ye:t["--persona-primary"],t["--persona-launcher-fg"]=(De=t["--persona-components-launcher-foreground"])!=null?De:t["--persona-text-inverse"],t["--persona-launcher-border"]=(le=t["--persona-components-launcher-border"])!=null?le:t["--persona-border"],t["--persona-button-primary-bg"]=(nt=t["--persona-components-button-primary-background"])!=null?nt:t["--persona-primary"],t["--persona-button-primary-fg"]=(Re=t["--persona-components-button-primary-foreground"])!=null?Re:t["--persona-text-inverse"],t["--persona-button-radius"]=(he=(K=t["--persona-components-button-primary-borderRadius"])!=null?K:t["--persona-palette-radius-full"])!=null?he:"9999px",t["--persona-panel-radius"]=(Pt=(it=t["--persona-components-panel-borderRadius"])!=null?it:t["--persona-radius-xl"])!=null?Pt:"0.75rem",t["--persona-panel-border"]=(te=t["--persona-components-panel-border"])!=null?te:`1px solid ${t["--persona-border"]}`,t["--persona-panel-shadow"]=(Ar=(_e=t["--persona-components-panel-shadow"])!=null?_e:t["--persona-palette-shadows-xl"])!=null?Ar:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",t["--persona-launcher-shadow"]=(Rt=t["--persona-components-launcher-shadow"])!=null?Rt:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",t["--persona-input-radius"]=(Yr=(dr=t["--persona-components-input-borderRadius"])!=null?dr:t["--persona-radius-lg"])!=null?Yr:"0.5rem",t["--persona-message-user-radius"]=(O=(zr=t["--persona-components-message-user-borderRadius"])!=null?zr:t["--persona-radius-lg"])!=null?O:"0.5rem",t["--persona-message-assistant-radius"]=(Ie=(fe=t["--persona-components-message-assistant-borderRadius"])!=null?fe:t["--persona-radius-lg"])!=null?Ie:"0.5rem",t["--persona-header-bg"]=(Je=t["--persona-components-header-background"])!=null?Je:t["--persona-surface"],t["--persona-header-border"]=(qe=t["--persona-components-header-border"])!=null?qe:t["--persona-divider"],t["--persona-header-icon-bg"]=(ze=t["--persona-components-header-iconBackground"])!=null?ze:t["--persona-primary"],t["--persona-header-icon-fg"]=(lt=t["--persona-components-header-iconForeground"])!=null?lt:t["--persona-text-inverse"],t["--persona-header-title-fg"]=(Mt=t["--persona-components-header-titleForeground"])!=null?Mt:t["--persona-primary"],t["--persona-header-subtitle-fg"]=(Dt=t["--persona-components-header-subtitleForeground"])!=null?Dt:t["--persona-text-muted"],t["--persona-header-action-icon-fg"]=(or=t["--persona-components-header-actionIconForeground"])!=null?or:t["--persona-muted"];let o=(X=r.components)==null?void 0:X.header;o!=null&&o.shadow&&(t["--persona-header-shadow"]=o.shadow),o!=null&&o.borderBottom&&(t["--persona-header-border-bottom"]=o.borderBottom);let n=(wt=r.components)==null?void 0:wt.introCard;t["--persona-intro-card-bg"]=(ct=t["--persona-components-introCard-background"])!=null?ct:t["--persona-surface"],t["--persona-intro-card-radius"]=(Ce=t["--persona-components-introCard-borderRadius"])!=null?Ce:"1rem",t["--persona-intro-card-padding"]=(de=t["--persona-components-introCard-padding"])!=null?de:"1.5rem",t["--persona-intro-card-shadow"]=(Ft=(rt=n==null?void 0:n.shadow)!=null?rt:t["--persona-components-introCard-shadow"])!=null?Ft:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-input-background"]=(zt=t["--persona-components-input-background"])!=null?zt:t["--persona-surface"],t["--persona-input-placeholder"]=(Pr=t["--persona-components-input-placeholder"])!=null?Pr:t["--persona-text-muted"],t["--persona-message-user-bg"]=(vr=t["--persona-components-message-user-background"])!=null?vr:t["--persona-accent"],t["--persona-message-user-text"]=(xt=t["--persona-components-message-user-text"])!=null?xt:t["--persona-text-inverse"],t["--persona-message-user-shadow"]=(It=t["--persona-components-message-user-shadow"])!=null?It:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-message-assistant-bg"]=(tt=t["--persona-components-message-assistant-background"])!=null?tt:t["--persona-surface"],t["--persona-message-assistant-text"]=(jt=t["--persona-components-message-assistant-text"])!=null?jt:t["--persona-text"],t["--persona-message-assistant-border"]=(cr=t["--persona-components-message-assistant-border"])!=null?cr:t["--persona-border"],t["--persona-message-assistant-shadow"]=(Dr=t["--persona-components-message-assistant-shadow"])!=null?Dr:"0 1px 2px 0 rgb(0 0 0 / 0.05)",t["--persona-scroll-to-bottom-bg"]=(Sr=(hr=t["--persona-components-scrollToBottom-background"])!=null?hr:t["--persona-button-primary-bg"])!=null?Sr:t["--persona-accent"],t["--persona-scroll-to-bottom-fg"]=(je=(Oo=t["--persona-components-scrollToBottom-foreground"])!=null?Oo:t["--persona-button-primary-fg"])!=null?je:t["--persona-text-inverse"],t["--persona-scroll-to-bottom-border"]=(Tr=t["--persona-components-scrollToBottom-border"])!=null?Tr:t["--persona-primary"],t["--persona-scroll-to-bottom-size"]=(io=t["--persona-components-scrollToBottom-size"])!=null?io:"40px",t["--persona-scroll-to-bottom-radius"]=(At=(lo=(_o=t["--persona-components-scrollToBottom-borderRadius"])!=null?_o:t["--persona-button-radius"])!=null?lo:t["--persona-radius-full"])!=null?At:"9999px",t["--persona-scroll-to-bottom-shadow"]=(No=(rn=t["--persona-components-scrollToBottom-shadow"])!=null?rn:t["--persona-palette-shadows-sm"])!=null?No:"0 1px 2px 0 rgb(0 0 0 / 0.05)",t["--persona-scroll-to-bottom-padding"]=(mn=t["--persona-components-scrollToBottom-padding"])!=null?mn:"0.5rem 0.875rem",t["--persona-scroll-to-bottom-gap"]=(Jr=t["--persona-components-scrollToBottom-gap"])!=null?Jr:"0.5rem",t["--persona-scroll-to-bottom-font-size"]=($r=(Ln=t["--persona-components-scrollToBottom-fontSize"])!=null?Ln:t["--persona-palette-typography-fontSize-sm"])!=null?$r:"0.875rem",t["--persona-scroll-to-bottom-icon-size"]=(Fo=t["--persona-components-scrollToBottom-iconSize"])!=null?Fo:"14px",t["--persona-tool-bubble-shadow"]=(mt=t["--persona-components-toolBubble-shadow"])!=null?mt:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-reasoning-bubble-shadow"]=(co=t["--persona-components-reasoningBubble-shadow"])!=null?co:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-composer-shadow"]=(po=t["--persona-components-composer-shadow"])!=null?po:"none",t["--persona-md-inline-code-bg"]=(Or=t["--persona-components-markdown-inlineCode-background"])!=null?Or:t["--persona-container"],t["--persona-md-inline-code-color"]=(Wt=t["--persona-components-markdown-inlineCode-foreground"])!=null?Wt:t["--persona-text"],t["--persona-md-link-color"]=(Zr=(Vr=t["--persona-components-markdown-link-foreground"])!=null?Vr:t["--persona-accent"])!=null?Zr:"#0f0f0f";let a=t["--persona-components-markdown-heading-h1-fontSize"];a&&(t["--persona-md-h1-size"]=a);let s=t["--persona-components-markdown-heading-h1-fontWeight"];s&&(t["--persona-md-h1-weight"]=s);let i=t["--persona-components-markdown-heading-h2-fontSize"];i&&(t["--persona-md-h2-size"]=i);let d=t["--persona-components-markdown-heading-h2-fontWeight"];d&&(t["--persona-md-h2-weight"]=d);let l=t["--persona-components-markdown-prose-fontFamily"];l&&l!=="inherit"&&(t["--persona-md-prose-font-family"]=l),t["--persona-md-code-block-bg"]=(_r=t["--persona-components-markdown-codeBlock-background"])!=null?_r:t["--persona-container"],t["--persona-md-code-block-border-color"]=(uo=t["--persona-components-markdown-codeBlock-borderColor"])!=null?uo:t["--persona-border"],t["--persona-md-code-block-text-color"]=(fo=t["--persona-components-markdown-codeBlock-textColor"])!=null?fo:"inherit",t["--persona-md-table-header-bg"]=(Nr=t["--persona-components-markdown-table-headerBackground"])!=null?Nr:t["--persona-container"],t["--persona-md-table-border-color"]=(mo=t["--persona-components-markdown-table-borderColor"])!=null?mo:t["--persona-border"],t["--persona-md-hr-color"]=($t=t["--persona-components-markdown-hr-color"])!=null?$t:t["--persona-divider"],t["--persona-md-blockquote-border-color"]=(Fr=t["--persona-components-markdown-blockquote-borderColor"])!=null?Fr:t["--persona-palette-colors-gray-900"],t["--persona-md-blockquote-bg"]=(go=t["--persona-components-markdown-blockquote-background"])!=null?go:"transparent",t["--persona-md-blockquote-text-color"]=(on=t["--persona-components-markdown-blockquote-textColor"])!=null?on:t["--persona-palette-colors-gray-500"],t["--cw-container"]=(Uo=t["--persona-components-collapsibleWidget-container"])!=null?Uo:t["--persona-surface"],t["--cw-surface"]=(nn=t["--persona-components-collapsibleWidget-surface"])!=null?nn:t["--persona-surface"],t["--cw-border"]=(qo=t["--persona-components-collapsibleWidget-border"])!=null?qo:t["--persona-border"],t["--persona-message-border"]=(eo=t["--persona-components-message-border"])!=null?eo:t["--persona-border"];let u=r.components,f=u==null?void 0:u.iconButton;f&&(f.background&&(t["--persona-icon-btn-bg"]=f.background),f.border&&(t["--persona-icon-btn-border"]=f.border),f.color&&(t["--persona-icon-btn-color"]=f.color),f.padding&&(t["--persona-icon-btn-padding"]=f.padding),f.borderRadius&&(t["--persona-icon-btn-radius"]=f.borderRadius),f.hoverBackground&&(t["--persona-icon-btn-hover-bg"]=f.hoverBackground),f.hoverColor&&(t["--persona-icon-btn-hover-color"]=f.hoverColor),f.activeBackground&&(t["--persona-icon-btn-active-bg"]=f.activeBackground),f.activeBorder&&(t["--persona-icon-btn-active-border"]=f.activeBorder));let p=u==null?void 0:u.labelButton;p&&(p.background&&(t["--persona-label-btn-bg"]=p.background),p.border&&(t["--persona-label-btn-border"]=p.border),p.color&&(t["--persona-label-btn-color"]=p.color),p.padding&&(t["--persona-label-btn-padding"]=p.padding),p.borderRadius&&(t["--persona-label-btn-radius"]=p.borderRadius),p.hoverBackground&&(t["--persona-label-btn-hover-bg"]=p.hoverBackground),p.fontSize&&(t["--persona-label-btn-font-size"]=p.fontSize),p.gap&&(t["--persona-label-btn-gap"]=p.gap));let m=u==null?void 0:u.toggleGroup;m&&(m.gap&&(t["--persona-toggle-group-gap"]=m.gap),m.borderRadius&&(t["--persona-toggle-group-radius"]=m.borderRadius));let y=u==null?void 0:u.artifact;if(y!=null&&y.toolbar){let $=y.toolbar;$.iconHoverColor&&(t["--persona-artifact-toolbar-icon-hover-color"]=$.iconHoverColor),$.iconHoverBackground&&(t["--persona-artifact-toolbar-icon-hover-bg"]=$.iconHoverBackground),$.iconPadding&&(t["--persona-artifact-toolbar-icon-padding"]=$.iconPadding),$.iconBorderRadius&&(t["--persona-artifact-toolbar-icon-radius"]=$.iconBorderRadius),$.iconBorder&&(t["--persona-artifact-toolbar-icon-border"]=$.iconBorder),$.toggleGroupGap&&(t["--persona-artifact-toolbar-toggle-group-gap"]=$.toggleGroupGap),$.toggleBorderRadius&&(t["--persona-artifact-toolbar-toggle-radius"]=$.toggleBorderRadius),$.copyBackground&&(t["--persona-artifact-toolbar-copy-bg"]=$.copyBackground),$.copyBorder&&(t["--persona-artifact-toolbar-copy-border"]=$.copyBorder),$.copyColor&&(t["--persona-artifact-toolbar-copy-color"]=$.copyColor),$.copyBorderRadius&&(t["--persona-artifact-toolbar-copy-radius"]=$.copyBorderRadius),$.copyPadding&&(t["--persona-artifact-toolbar-copy-padding"]=$.copyPadding),$.copyMenuBackground&&(t["--persona-artifact-toolbar-copy-menu-bg"]=$.copyMenuBackground,t["--persona-dropdown-bg"]=(to=t["--persona-dropdown-bg"])!=null?to:$.copyMenuBackground),$.copyMenuBorder&&(t["--persona-artifact-toolbar-copy-menu-border"]=$.copyMenuBorder,t["--persona-dropdown-border"]=(gt=t["--persona-dropdown-border"])!=null?gt:$.copyMenuBorder),$.copyMenuShadow&&(t["--persona-artifact-toolbar-copy-menu-shadow"]=$.copyMenuShadow,t["--persona-dropdown-shadow"]=(re=t["--persona-dropdown-shadow"])!=null?re:$.copyMenuShadow),$.copyMenuBorderRadius&&(t["--persona-artifact-toolbar-copy-menu-radius"]=$.copyMenuBorderRadius,t["--persona-dropdown-radius"]=(A=t["--persona-dropdown-radius"])!=null?A:$.copyMenuBorderRadius),$.copyMenuItemHoverBackground&&(t["--persona-artifact-toolbar-copy-menu-item-hover-bg"]=$.copyMenuItemHoverBackground,t["--persona-dropdown-item-hover-bg"]=(_=t["--persona-dropdown-item-hover-bg"])!=null?_:$.copyMenuItemHoverBackground),$.iconBackground&&(t["--persona-artifact-toolbar-icon-bg"]=$.iconBackground),$.toolbarBorder&&(t["--persona-artifact-toolbar-border"]=$.toolbarBorder)}if(y!=null&&y.tab){let $=y.tab;$.background&&(t["--persona-artifact-tab-bg"]=$.background),$.activeBackground&&(t["--persona-artifact-tab-active-bg"]=$.activeBackground),$.activeBorder&&(t["--persona-artifact-tab-active-border"]=$.activeBorder),$.borderRadius&&(t["--persona-artifact-tab-radius"]=$.borderRadius),$.textColor&&(t["--persona-artifact-tab-color"]=$.textColor),$.hoverBackground&&(t["--persona-artifact-tab-hover-bg"]=$.hoverBackground),$.listBackground&&(t["--persona-artifact-tab-list-bg"]=$.listBackground),$.listBorderColor&&(t["--persona-artifact-tab-list-border-color"]=$.listBorderColor),$.listPadding&&(t["--persona-artifact-tab-list-padding"]=$.listPadding)}if(y!=null&&y.pane){let $=y.pane;if($.toolbarBackground){let at=(ue=es(r,$.toolbarBackground))!=null?ue:$.toolbarBackground;t["--persona-artifact-toolbar-bg"]=at}}return t}var bx={header:"Widget header bar",messages:"Message list area","user-message":"User message bubble","assistant-message":"Assistant message bubble",composer:"Footer / composer area",container:"Main widget container","artifact-pane":"Artifact sidebar","artifact-toolbar":"Artifact toolbar"};var Pv={colors:{primary:{50:"#ffffff",100:"#f5f5f5",200:"#d4d4d4",300:"#a3a3a3",400:"#737373",500:"#171717",600:"#0f0f0f",700:"#0a0a0a",800:"#050505",900:"#030303",950:"#000000"},secondary:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},accent:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},success:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d"},warning:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12"},error:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d"}}},vx=r=>{if(!(!r||typeof r!="object"||Array.isArray(r)))return r},ti=()=>{var r;return typeof document!="undefined"&&document.documentElement.classList.contains("dark")||typeof window!="undefined"&&((r=window.matchMedia)!=null&&r.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light"},Rv=r=>{var t;let e=(t=r==null?void 0:r.colorScheme)!=null?t:"light";return e==="light"?"light":e==="dark"?"dark":ti()},jp=r=>Rv(r),Iv=r=>ts(r),Hv=r=>{var t;let e=ts(void 0,{validate:!1});return ts({...r,palette:{...e.palette,colors:{...Pv.colors,...(t=r==null?void 0:r.palette)==null?void 0:t.colors}}},{validate:!1})},rs=r=>{let e=jp(r),t=vx(r==null?void 0:r.theme),o=vx(r==null?void 0:r.darkTheme);return e==="dark"?Hv(ei(t!=null?t:{},o!=null?o:{})):Iv(t)},Wv=r=>kl(r),Vn=(r,e)=>{let t=rs(e),o=Wv(t);for(let[n,a]of Object.entries(o))r.style.setProperty(n,a)},El=r=>{let e=[];if(typeof document!="undefined"&&typeof MutationObserver!="undefined"){let t=new MutationObserver(()=>{r(ti())});t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),e.push(()=>t.disconnect())}if(typeof window!="undefined"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>r(ti());t.addEventListener?(t.addEventListener("change",o),e.push(()=>t.removeEventListener("change",o))):t.addListener&&(t.addListener(o),e.push(()=>t.removeListener(o)))}return()=>{e.forEach(t=>t())}};var Cx=(function(){"use strict";let r=()=>{},e={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:r,afterNodeAdded:r,beforeNodeMorphed:r,afterNodeMorphed:r,beforeNodeRemoved:r,afterNodeRemoved:r,beforeAttributeUpdated:r},head:{style:"merge",shouldPreserve:p=>p.getAttribute("im-preserve")==="true",shouldReAppend:p=>p.getAttribute("im-re-append")==="true",shouldRemove:r,afterHeadMorphed:r},restoreFocus:!0};function t(p,m,y={}){p=u(p);let h=f(m),T=l(p,h,y),M=n(T,()=>i(T,p,h,k=>k.morphStyle==="innerHTML"?(a(k,p,h),Array.from(p.childNodes)):o(k,p,h)));return T.pantry.remove(),M}function o(p,m,y){let h=f(m);return a(p,h,y,m,m.nextSibling),Array.from(h.childNodes)}function n(p,m){var L;if(!p.config.restoreFocus)return m();let y=document.activeElement;if(!(y instanceof HTMLInputElement||y instanceof HTMLTextAreaElement))return m();let{id:h,selectionStart:T,selectionEnd:M}=y,k=m();return h&&h!==((L=document.activeElement)==null?void 0:L.getAttribute("id"))&&(y=p.target.querySelector(`[id="${h}"]`),y==null||y.focus()),y&&!y.selectionEnd&&M&&y.setSelectionRange(T,M),k}let a=(function(){function p(x,w,v,E=null,H=null){w instanceof HTMLTemplateElement&&v instanceof HTMLTemplateElement&&(w=w.content,v=v.content),E||(E=w.firstChild);for(let I of v.childNodes){if(E&&E!=H){let z=y(x,I,E,H);if(z){z!==E&&T(x,E,z),s(z,I,x),E=z.nextSibling;continue}}if(I instanceof Element){let z=I.getAttribute("id");if(x.persistentIds.has(z)){let j=M(w,z,E,x);s(j,I,x),E=j.nextSibling;continue}}let P=m(w,I,E,x);P&&(E=P.nextSibling)}for(;E&&E!=H;){let I=E;E=E.nextSibling,h(x,I)}}function m(x,w,v,E){if(E.callbacks.beforeNodeAdded(w)===!1)return null;if(E.idMap.has(w)){let H=document.createElement(w.tagName);return x.insertBefore(H,v),s(H,w,E),E.callbacks.afterNodeAdded(H),H}else{let H=document.importNode(w,!0);return x.insertBefore(H,v),E.callbacks.afterNodeAdded(H),H}}let y=(function(){function x(E,H,I,P){let z=null,j=H.nextSibling,ie=0,ve=I;for(;ve&&ve!=P;){if(v(ve,H)){if(w(E,ve,H))return ve;z===null&&(E.idMap.has(ve)||(z=ve))}if(z===null&&j&&v(ve,j)&&(ie++,j=j.nextSibling,ie>=2&&(z=void 0)),E.activeElementAndParents.includes(ve))break;ve=ve.nextSibling}return z||null}function w(E,H,I){let P=E.idMap.get(H),z=E.idMap.get(I);if(!z||!P)return!1;for(let j of P)if(z.has(j))return!0;return!1}function v(E,H){var z,j,ie;let I=E,P=H;return I.nodeType===P.nodeType&&I.tagName===P.tagName&&(!((z=I.getAttribute)!=null&&z.call(I,"id"))||((j=I.getAttribute)==null?void 0:j.call(I,"id"))===((ie=P.getAttribute)==null?void 0:ie.call(P,"id")))}return x})();function h(x,w){var v;if(x.idMap.has(w))L(x.pantry,w,null);else{if(x.callbacks.beforeNodeRemoved(w)===!1)return;(v=w.parentNode)==null||v.removeChild(w),x.callbacks.afterNodeRemoved(w)}}function T(x,w,v){let E=w;for(;E&&E!==v;){let H=E;E=E.nextSibling,h(x,H)}return E}function M(x,w,v,E){var I,P;let H=((P=(I=E.target).getAttribute)==null?void 0:P.call(I,"id"))===w&&E.target||E.target.querySelector(`[id="${w}"]`)||E.pantry.querySelector(`[id="${w}"]`);return k(H,E),L(x,H,v),H}function k(x,w){let v=x.getAttribute("id");for(;x=x.parentNode;){let E=w.idMap.get(x);E&&(E.delete(v),E.size||w.idMap.delete(x))}}function L(x,w,v){if(x.moveBefore)try{x.moveBefore(w,v)}catch{x.insertBefore(w,v)}else x.insertBefore(w,v)}return p})(),s=(function(){function p(k,L,x){return x.ignoreActive&&k===document.activeElement?null:(x.callbacks.beforeNodeMorphed(k,L)===!1||(k instanceof HTMLHeadElement&&x.head.ignore||(k instanceof HTMLHeadElement&&x.head.style!=="morph"?d(k,L,x):(m(k,L,x),M(k,x)||a(x,k,L))),x.callbacks.afterNodeMorphed(k,L)),k)}function m(k,L,x){let w=L.nodeType;if(w===1){let v=k,E=L,H=v.attributes,I=E.attributes;for(let P of I)T(P.name,v,"update",x)||v.getAttribute(P.name)!==P.value&&v.setAttribute(P.name,P.value);for(let P=H.length-1;0<=P;P--){let z=H[P];if(z&&!E.hasAttribute(z.name)){if(T(z.name,v,"remove",x))continue;v.removeAttribute(z.name)}}M(v,x)||y(v,E,x)}(w===8||w===3)&&k.nodeValue!==L.nodeValue&&(k.nodeValue=L.nodeValue)}function y(k,L,x){if(k instanceof HTMLInputElement&&L instanceof HTMLInputElement&&L.type!=="file"){let w=L.value,v=k.value;h(k,L,"checked",x),h(k,L,"disabled",x),L.hasAttribute("value")?v!==w&&(T("value",k,"update",x)||(k.setAttribute("value",w),k.value=w)):T("value",k,"remove",x)||(k.value="",k.removeAttribute("value"))}else if(k instanceof HTMLOptionElement&&L instanceof HTMLOptionElement)h(k,L,"selected",x);else if(k instanceof HTMLTextAreaElement&&L instanceof HTMLTextAreaElement){let w=L.value,v=k.value;if(T("value",k,"update",x))return;w!==v&&(k.value=w),k.firstChild&&k.firstChild.nodeValue!==w&&(k.firstChild.nodeValue=w)}}function h(k,L,x,w){let v=L[x],E=k[x];if(v!==E){let H=T(x,k,"update",w);H||(k[x]=L[x]),v?H||k.setAttribute(x,""):T(x,k,"remove",w)||k.removeAttribute(x)}}function T(k,L,x,w){return k==="value"&&w.ignoreActiveValue&&L===document.activeElement?!0:w.callbacks.beforeAttributeUpdated(k,L,x)===!1}function M(k,L){return!!L.ignoreActiveValue&&k===document.activeElement&&k!==document.body}return p})();function i(p,m,y,h){if(p.head.block){let T=m.querySelector("head"),M=y.querySelector("head");if(T&&M){let k=d(T,M,p);return Promise.all(k).then(()=>{let L=Object.assign(p,{head:{block:!1,ignore:!0}});return h(L)})}}return h(p)}function d(p,m,y){let h=[],T=[],M=[],k=[],L=new Map;for(let w of m.children)L.set(w.outerHTML,w);for(let w of p.children){let v=L.has(w.outerHTML),E=y.head.shouldReAppend(w),H=y.head.shouldPreserve(w);v||H?E?T.push(w):(L.delete(w.outerHTML),M.push(w)):y.head.style==="append"?E&&(T.push(w),k.push(w)):y.head.shouldRemove(w)!==!1&&T.push(w)}k.push(...L.values());let x=[];for(let w of k){let v=document.createRange().createContextualFragment(w.outerHTML).firstChild;if(y.callbacks.beforeNodeAdded(v)!==!1){if("href"in v&&v.href||"src"in v&&v.src){let E,H=new Promise(function(I){E=I});v.addEventListener("load",function(){E()}),x.push(H)}p.appendChild(v),y.callbacks.afterNodeAdded(v),h.push(v)}}for(let w of T)y.callbacks.beforeNodeRemoved(w)!==!1&&(p.removeChild(w),y.callbacks.afterNodeRemoved(w));return y.head.afterHeadMorphed(p,{added:h,kept:M,removed:T}),x}let l=(function(){function p(x,w,v){let{persistentIds:E,idMap:H}=k(x,w),I=m(v),P=I.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(P))throw`Do not understand how to morph style ${P}`;return{target:x,newContent:w,config:I,morphStyle:P,ignoreActive:I.ignoreActive,ignoreActiveValue:I.ignoreActiveValue,restoreFocus:I.restoreFocus,idMap:H,persistentIds:E,pantry:y(),activeElementAndParents:h(x),callbacks:I.callbacks,head:I.head}}function m(x){let w=Object.assign({},e);return Object.assign(w,x),w.callbacks=Object.assign({},e.callbacks,x.callbacks),w.head=Object.assign({},e.head,x.head),w}function y(){let x=document.createElement("div");return x.hidden=!0,document.body.insertAdjacentElement("afterend",x),x}function h(x){let w=[],v=document.activeElement;if((v==null?void 0:v.tagName)!=="BODY"&&x.contains(v))for(;v&&(w.push(v),v!==x);)v=v.parentElement;return w}function T(x){var v;let w=Array.from(x.querySelectorAll("[id]"));return(v=x.getAttribute)!=null&&v.call(x,"id")&&w.push(x),w}function M(x,w,v,E){for(let H of E){let I=H.getAttribute("id");if(w.has(I)){let P=H;for(;P;){let z=x.get(P);if(z==null&&(z=new Set,x.set(P,z)),z.add(I),P===v)break;P=P.parentElement}}}}function k(x,w){let v=T(x),E=T(w),H=L(v,E),I=new Map;M(I,H,x,v);let P=w.__idiomorphRoot||w;return M(I,H,P,E),{persistentIds:H,idMap:I}}function L(x,w){let v=new Set,E=new Map;for(let{id:I,tagName:P}of x)E.has(I)?v.add(I):E.set(I,P);let H=new Set;for(let{id:I,tagName:P}of w)H.has(I)?v.add(I):E.get(I)===P&&H.add(I);for(let I of v)H.delete(I);return H}return p})(),{normalizeElement:u,normalizeParent:f}=(function(){let p=new WeakSet;function m(M){return M instanceof Document?M.documentElement:M}function y(M){if(M==null)return document.createElement("div");if(typeof M=="string")return y(T(M));if(p.has(M))return M;if(M instanceof Node){if(M.parentNode)return new h(M);{let k=document.createElement("div");return k.append(M),k}}else{let k=document.createElement("div");for(let L of[...M])k.append(L);return k}}class h{constructor(k){this.originalNode=k,this.realParentNode=k.parentNode,this.previousSibling=k.previousSibling,this.nextSibling=k.nextSibling}get childNodes(){let k=[],L=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;L&&L!=this.nextSibling;)k.push(L),L=L.nextSibling;return k}querySelectorAll(k){return this.childNodes.reduce((L,x)=>{if(x instanceof Element){x.matches(k)&&L.push(x);let w=x.querySelectorAll(k);for(let v=0;v<w.length;v++)L.push(w[v])}return L},[])}insertBefore(k,L){return this.realParentNode.insertBefore(k,L)}moveBefore(k,L){return this.realParentNode.moveBefore(k,L)}get __idiomorphRoot(){return this.originalNode}}function T(M){let k=new DOMParser,L=M.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(L.match(/<\/html>/)||L.match(/<\/head>/)||L.match(/<\/body>/)){let x=k.parseFromString(M,"text/html");if(L.match(/<\/html>/))return p.add(x),x;{let w=x.firstChild;return w&&p.add(w),w}}else{let w=k.parseFromString("<body><template>"+M+"</template></body>","text/html").body.querySelector("template").content;return p.add(w),w}}return{normalizeElement:m,normalizeParent:y}})();return{morph:t,defaults:e}})();var Ll=(r,e,t={})=>{let{preserveTypingAnimation:o=!0}=t;Cx.morph(r,e.innerHTML,{morphStyle:"innerHTML",callbacks:{beforeNodeMorphed(n,a){var s,i;if(n instanceof HTMLElement&&o){if(n.classList.contains("persona-animate-typing")||n.hasAttribute("data-preserve-runtime"))return!1;if(n.hasAttribute("data-preserve-animation")){if(a instanceof HTMLElement&&!a.hasAttribute("data-preserve-animation"))return;if(a instanceof HTMLElement&&a.hasAttribute("data-preserve-animation")){let d=(s=n.textContent)!=null?s:"",l=(i=a.textContent)!=null?i:"";if(d!==l)return}return!1}}}}})};var Pl={index:-1,draft:""};function wx(r){let{direction:e,history:t,currentValue:o,atStart:n,state:a}=r,s=a.index!==-1;if(t.length===0)return{handled:!1,state:a};if(e==="up"){if(!s&&!n)return{handled:!1,state:a};if(!s){let i=t.length-1;return{handled:!0,value:t[i],state:{index:i,draft:o}}}if(a.index>0){let i=a.index-1;return{handled:!0,value:t[i],state:{index:i,draft:a.draft}}}return{handled:!0,state:a}}if(!s)return{handled:!1,state:a};if(a.index<t.length-1){let i=a.index+1;return{handled:!0,value:t[i],state:{index:i,draft:a.draft}}}return{handled:!0,value:a.draft,state:{...Pl}}}function Ax(r,e){var t,o,n,a,s,i,d,l,u,f,p,m,y,h,T,M,k,L,x,w,v,E,H,I,P,z,j,ie,ve,Xe,Ae,We,Me,Ue,Be,Z,ne,me;return[r.id,r.role,(o=(t=r.content)==null?void 0:t.length)!=null?o:0,(a=(n=r.content)==null?void 0:n.slice(-32))!=null?a:"",r.streaming?"1":"0",(s=r.variant)!=null?s:"",(d=(i=r.rawContent)==null?void 0:i.length)!=null?d:0,(u=(l=r.llmContent)==null?void 0:l.length)!=null?u:0,(p=(f=r.approval)==null?void 0:f.status)!=null?p:"",(y=(m=r.toolCall)==null?void 0:m.status)!=null?y:"",(T=(h=r.toolCall)==null?void 0:h.name)!=null?T:"",(L=(k=(M=r.toolCall)==null?void 0:M.chunks)==null?void 0:k.length)!=null?L:0,(E=(v=(w=(x=r.toolCall)==null?void 0:x.chunks)==null?void 0:w[r.toolCall.chunks.length-1])==null?void 0:v.slice(-32))!=null?E:"",typeof((H=r.toolCall)==null?void 0:H.args)=="string"?r.toolCall.args.length:(I=r.toolCall)!=null&&I.args?JSON.stringify(r.toolCall.args).length:0,(j=(z=(P=r.reasoning)==null?void 0:P.chunks)==null?void 0:z.length)!=null?j:0,(Ae=(Xe=(ve=(ie=r.reasoning)==null?void 0:ie.chunks)==null?void 0:ve[r.reasoning.chunks.length-1])==null?void 0:Xe.length)!=null?Ae:0,(Be=(Ue=(Me=(We=r.reasoning)==null?void 0:We.chunks)==null?void 0:Me[r.reasoning.chunks.length-1])==null?void 0:Ue.slice(-32))!=null?Be:"",(ne=(Z=r.contentParts)==null?void 0:Z.length)!=null?ne:0,(me=r.stopReason)!=null?me:"",e].join("\0")}function Sx(){return new Map}function Tx(r,e,t){let o=r.get(e);return o&&o.fingerprint===t?o.wrapper:null}function Mx(r,e,t,o){r.set(e,{fingerprint:t,wrapper:o})}function kx(r,e){for(let t of r.keys())e.has(t)||r.delete(t)}function Rl(r=!0){let e=r;return{isFollowing:()=>e,pause:()=>e?(e=!1,!0):!1,resume:()=>e?!1:(e=!0,!0)}}function Mn(r){return Math.max(0,r.scrollHeight-r.clientHeight)}function Aa(r,e){return Mn(r)-r.scrollTop<=e}function Il(r){let{following:e,currentScrollTop:t,lastScrollTop:o,nearBottom:n,userScrollThreshold:a,isAutoScrolling:s=!1,pauseOnUpwardScroll:i=!1,pauseWhenAwayFromBottom:d=!0,resumeRequiresDownwardScroll:l=!1}=r,u=t-o;return s||Math.abs(u)<a?{action:"none",delta:u,nextLastScrollTop:t}:!e&&n&&(!l||u>0)?{action:"resume",delta:u,nextLastScrollTop:t}:e&&i&&u<0?{action:"pause",delta:u,nextLastScrollTop:t}:e&&d&&!n?{action:"pause",delta:u,nextLastScrollTop:t}:{action:"none",delta:u,nextLastScrollTop:t}}function Hl(r){let{following:e,deltaY:t,nearBottom:o=!1,resumeWhenNearBottom:n=!1}=r;return e&&t<0?"pause":!e&&n&&t>0&&o?"resume":"none"}function Ex(r,e){return!r||r.isCollapsed?!1:e.contains(r.anchorNode)||e.contains(r.focusNode)}function Lx(r){let e=Math.max(0,r.anchorOffsetTop-r.topOffset),t=Math.max(0,e+r.viewportHeight-r.contentHeight);return{targetScrollTop:e,spacerHeight:t}}function Px(r){let e=Math.max(0,r.currentContentHeight-r.contentHeightAtAnchor);return Math.max(0,r.initialSpacerHeight-e)}var ao={idle:"Online",connecting:"Connecting\u2026",connected:"Streaming\u2026",error:"Offline"},so=1e5,jn=so+1;var ri={type:"none",placeholder:"none",speed:120,duration:1800,buffer:"none"},Bv=["pre","code","a","script","style"],Wl=r=>{var e,t,o,n,a;return{type:(e=r==null?void 0:r.type)!=null?e:ri.type,placeholder:(t=r==null?void 0:r.placeholder)!=null?t:ri.placeholder,speed:(o=r==null?void 0:r.speed)!=null?o:ri.speed,duration:(n=r==null?void 0:r.duration)!=null?n:ri.duration,buffer:(a=r==null?void 0:r.buffer)!=null?a:ri.buffer}},Ix=[{name:"typewriter",containerClass:"persona-stream-typewriter",wrap:"char",useCaret:!0},{name:"pop-bubble",bubbleClass:"persona-stream-pop",wrap:"none"},{name:"letter-rise",containerClass:"persona-stream-letter-rise",wrap:"char"},{name:"word-fade",containerClass:"persona-stream-word-fade",wrap:"word"}],oi=new Map;for(let r of Ix)oi.set(r.name,r);var Sa=r=>{oi.set(r.name,r)},Xp=r=>{Ix.some(e=>e.name===r)||oi.delete(r)},Qp=()=>Array.from(oi.keys()),ni=(r,e)=>{var t,o;return r==="none"?null:e&&Object.prototype.hasOwnProperty.call(e,r)?(t=e[r])!=null?t:null:(o=oi.get(r))!=null?o:null},Bl=(r,e,t,o,n)=>{if(!n)return r;if(t!=null&&t.bufferContent)return t.bufferContent(r,o);if(!r)return r;if(e==="word"){let a=r.search(/\s(?=\S*$)/);return a<0?"":r.slice(0,a)}if(e==="line"){let a=r.lastIndexOf(`
|
|
63
|
+
`);return a<0?"":r.slice(0,a)}return r},Dv=(r,e,t,o)=>{let n=r.createElement("span");return n.className="persona-stream-char",n.id=`stream-c-${t}-${o}`,n.style.setProperty("--char-index",String(o)),n.textContent=e,n},Ov=(r,e,t,o)=>{let n=r.createElement("span");return n.className="persona-stream-word",n.id=`stream-w-${t}-${o}`,n.style.setProperty("--word-index",String(o)),n.textContent=e,n},Gp=/\s/,_v=(r,e)=>{let t=r.parentNode;for(;t;){if(t.nodeType===1){let o=t;if(e.has(o.tagName.toLowerCase()))return!0}t=t.parentNode}return!1},Nv=(r,e,t)=>{var d;let o=r.ownerDocument,n=r.parentNode;if(!o||!n)return;let a=(d=r.nodeValue)!=null?d:"";if(!a)return;let s=o.createDocumentFragment(),i=0;for(;i<a.length;)if(Gp.test(a[i])){let l=i;for(;l<a.length&&Gp.test(a[l]);)l+=1;s.appendChild(o.createTextNode(a.slice(i,l))),i=l}else{let l=o.createElement("span");l.className="persona-stream-word-group";let u=i;for(;u<a.length&&!Gp.test(a[u]);)l.appendChild(Dv(o,a[u],e,t.value)),t.value+=1,u+=1;s.appendChild(l),i=u}n.replaceChild(s,r)},Fv=(r,e,t)=>{var d;let o=r.ownerDocument,n=r.parentNode;if(!o||!n)return;let a=(d=r.nodeValue)!=null?d:"";if(!a)return;let s=o.createDocumentFragment(),i=a.split(/(\s+)/);for(let l of i)l&&(/^\s+$/.test(l)?s.appendChild(o.createTextNode(l)):(s.appendChild(Ov(o,l,e,t.value)),t.value+=1));n.replaceChild(s,r)},ai=(r,e,t,o)=>{var f,p;if(!r||typeof document=="undefined")return r;let n=document.createElement("div");n.innerHTML=r;let a=new Set(((f=o==null?void 0:o.skipTags)!=null?f:Bv).map(m=>m.toLowerCase())),s=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null),i=[],d=s.nextNode();for(;d;)_v(d,a)||i.push(d),d=s.nextNode();let l={value:(p=o==null?void 0:o.startIndex)!=null?p:0},u=e==="char"?Nv:Fv;for(let m of i)u(m,t,l);return n.innerHTML},Dl=(r=document)=>{let e=r.createElement("span");return e.className="persona-stream-caret",e.setAttribute("aria-hidden","true"),e.setAttribute("data-preserve-animation","stream-caret"),e},si=(r=document)=>{let e=r.createElement("div");e.className="persona-stream-skeleton",e.setAttribute("data-preserve-animation","stream-skeleton"),e.setAttribute("aria-hidden","true");let t=r.createElement("div");return t.className="persona-stream-skeleton-line",e.appendChild(t),e},Rx=new WeakMap,Uv=(r,e)=>{var a;if(!r.styles)return;let t=Rx.get(e);if(t||(t=new Set,Rx.set(e,t)),t.has(r.name)){let s=r.name.replace(/["\\]/g,"\\$&");if(e.querySelector(`style[data-persona-animation="${s}"]`))return;t.delete(r.name)}t.add(r.name);let n=(e instanceof ShadowRoot?e.ownerDocument:(a=e.ownerDocument)!=null?a:document).createElement("style");n.setAttribute("data-persona-animation",r.name),n.textContent=r.styles,e.appendChild(n)},Kp=new WeakMap,qv=(r,e)=>{if(!r.onAttach)return;let t=Kp.get(e);if(t||(t=new Map,Kp.set(e,t)),t.has(r.name))return;let o=r.onAttach(e);t.set(r.name,o)},Hx=r=>{let e=Kp.get(r);if(e){for(let t of e.values())typeof t=="function"&&t();e.clear()}},Yp=(r,e)=>{Uv(r,e),qv(r,e)};function Jp(r,e=so){let t=r.style.position,o=r.style.zIndex,n=r.style.isolation,a=getComputedStyle(r),s=a.position==="static"||a.position==="";return s&&(r.style.position="relative"),r.style.zIndex=String(e),r.style.isolation="isolate",()=>{s&&(r.style.position=t),r.style.zIndex=o,r.style.isolation=n}}var ii=0,Gn=null;function Zp(r=document){var t;if(ii++,ii===1){let o=r.body,a=((t=r.defaultView)!=null?t:window).scrollY||r.documentElement.scrollTop;Gn={originalOverflow:o.style.overflow,originalPosition:o.style.position,originalTop:o.style.top,originalWidth:o.style.width,scrollY:a},o.style.overflow="hidden",o.style.position="fixed",o.style.top=`-${a}px`,o.style.width="100%"}let e=!1;return()=>{var o;if(!e&&(e=!0,ii=Math.max(0,ii-1),ii===0&&Gn)){let n=r.body,a=(o=r.defaultView)!=null?o:window;n.style.overflow=Gn.originalOverflow,n.style.position=Gn.originalPosition,n.style.top=Gn.originalTop,n.style.width=Gn.originalWidth,a.scrollTo(0,Gn.scrollY),Gn=null}}}var li={side:"right",width:"420px",animate:!0,reveal:"resize",maxHeight:"100dvh"},Lr=r=>{var e,t;return((t=(e=r==null?void 0:r.launcher)==null?void 0:e.mountMode)!=null?t:"floating")==="docked"},Kn=r=>{var e,t;return((t=(e=r==null?void 0:r.launcher)==null?void 0:e.mountMode)!=null?t:"floating")==="composer-bar"},Bo=r=>{var t,o,n,a,s,i;let e=(t=r==null?void 0:r.launcher)==null?void 0:t.dock;return{side:(o=e==null?void 0:e.side)!=null?o:li.side,width:(n=e==null?void 0:e.width)!=null?n:li.width,animate:(a=e==null?void 0:e.animate)!=null?a:li.animate,reveal:(s=e==null?void 0:e.reveal)!=null?s:li.reveal,maxHeight:(i=e==null?void 0:e.maxHeight)!=null?i:li.maxHeight}};var tn={"bottom-right":"persona-bottom-6 persona-right-6","bottom-left":"persona-bottom-6 persona-left-6","top-right":"persona-top-6 persona-right-6","top-left":"persona-top-6 persona-left-6"};var di=(r,e)=>{let t=C("button");t.type="button",t.innerHTML=`
|
|
63
64
|
<span class="persona-inline-flex persona-items-center persona-justify-center persona-rounded-full persona-bg-persona-primary persona-text-white" data-role="launcher-icon">\u{1F4AC}</span>
|
|
64
65
|
<img data-role="launcher-image" class="persona-rounded-full persona-object-cover" alt="" style="display:none" />
|
|
65
66
|
<span class="persona-flex persona-min-w-0 persona-flex-1 persona-flex-col persona-items-start persona-text-left">
|
|
@@ -67,14 +68,14 @@ _Details: ${t.message}_`:n}var _s=r=>({isError:!0,content:[{type:"text",text:r}]
|
|
|
67
68
|
<span class="persona-block persona-w-full persona-truncate persona-text-xs persona-text-persona-muted" data-role="launcher-subtitle"></span>
|
|
68
69
|
</span>
|
|
69
70
|
<span class="persona-ml-2 persona-grid persona-place-items-center persona-rounded-full persona-bg-persona-primary persona-text-persona-call-to-action" data-role="launcher-call-to-action-icon">\u2197</span>
|
|
70
|
-
`,t.addEventListener("click",e);let n=a=>{var k,h,w,C,T,W,R,I,N,V,ie,xe,Je;let s=(k=a.launcher)!=null?k:{},i=Rr(a),d=t.querySelector("[data-role='launcher-title']");if(d){let we=(h=s.title)!=null?h:"Chat Assistant";d.textContent=we,d.setAttribute("title",we)}let l=t.querySelector("[data-role='launcher-subtitle']");if(l){let we=(w=s.subtitle)!=null?w:"Get answers fast";l.textContent=we,l.setAttribute("title",we)}let p=t.querySelector(".persona-flex-col");p&&(s.textHidden||i?p.style.display="none":p.style.display="");let f=t.querySelector("[data-role='launcher-icon']");if(f)if(s.agentIconHidden)f.style.display="none";else{let we=(C=s.agentIconSize)!=null?C:"40px";if(f.style.height=we,f.style.width=we,f.innerHTML="",s.agentIconName){let De=parseFloat(we)||24,Ae=Me(s.agentIconName,De*.6,"var(--persona-text-inverse, #ffffff)",2);Ae?(f.appendChild(Ae),f.style.display=""):(f.textContent=(T=s.agentIconText)!=null?T:"\u{1F4AC}",f.style.display="")}else s.iconUrl?f.style.display="none":(f.textContent=(W=s.agentIconText)!=null?W:"\u{1F4AC}",f.style.display="")}let u=t.querySelector("[data-role='launcher-image']");if(u){let we=(R=s.agentIconSize)!=null?R:"40px";u.style.height=we,u.style.width=we,s.iconUrl&&!s.agentIconName&&!s.agentIconHidden?(u.src=s.iconUrl,u.style.display="block"):u.style.display="none"}let m=t.querySelector("[data-role='launcher-call-to-action-icon']");if(m){let we=(I=s.callToActionIconSize)!=null?I:"32px";m.style.height=we,m.style.width=we,s.callToActionIconBackgroundColor?(m.style.backgroundColor=s.callToActionIconBackgroundColor,m.classList.remove("persona-bg-persona-primary")):(m.style.backgroundColor="",m.classList.add("persona-bg-persona-primary")),s.callToActionIconColor?(m.style.color=s.callToActionIconColor,m.classList.remove("persona-text-persona-call-to-action")):(m.style.color="",m.classList.add("persona-text-persona-call-to-action"));let De=0;if(s.callToActionIconPadding?(m.style.boxSizing="border-box",m.style.padding=s.callToActionIconPadding,De=(parseFloat(s.callToActionIconPadding)||0)*2):(m.style.boxSizing="",m.style.padding=""),s.callToActionIconHidden)m.style.display="none";else if(m.style.display=i?"none":"",m.innerHTML="",s.callToActionIconName){let Ae=parseFloat(we)||24,qe=Math.max(Ae-De,8),Ie=Me(s.callToActionIconName,qe,"currentColor",2);Ie?m.appendChild(Ie):m.textContent=(N=s.callToActionIconText)!=null?N:"\u2197"}else m.textContent=(V=s.callToActionIconText)!=null?V:"\u2197"}let v=s.position&&Vn[s.position]?Vn[s.position]:Vn["bottom-right"],x="persona-fixed persona-flex persona-items-center persona-gap-3 persona-rounded-launcher persona-bg-persona-surface persona-py-2.5 persona-pl-3 persona-pr-3 persona-transition hover:persona-translate-y-[-2px] persona-cursor-pointer",S="persona-relative persona-mt-4 persona-mb-4 persona-mx-auto persona-flex persona-items-center persona-justify-center persona-rounded-launcher persona-bg-persona-surface persona-transition hover:persona-translate-y-[-2px] persona-cursor-pointer";t.className=i?S:`${x} ${v}`,i||(t.style.zIndex=String((ie=s.zIndex)!=null?ie:Gr));let M="1px solid var(--persona-border, #e5e7eb)",E="var(--persona-launcher-shadow, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1))";t.style.border=(xe=s.border)!=null?xe:M,t.style.boxShadow=s.shadow!==void 0?s.shadow.trim()===""?"none":s.shadow:E,i?(t.style.width="0",t.style.minWidth="0",t.style.maxWidth="0",t.style.padding="0",t.style.overflow="hidden",t.style.border="none",t.style.boxShadow="none"):(t.style.width="",t.style.minWidth="",t.style.maxWidth=(Je=s.collapsedMaxWidth)!=null?Je:"",t.style.justifyContent="",t.style.padding="",t.style.overflow="")},o=()=>{t.removeEventListener("click",e),t.remove()};return r&&n(r),{element:t,update:n,destroy:o}};var q0="persona-relative persona-ml-auto persona-inline-flex persona-items-center persona-justify-center",Sl=(r,e={})=>{var x,S,M,E,k,h;let{showClose:t=!0,wrapperClassName:n=q0,buttonSize:o,iconSize:a="28px"}=e,s=(x=r==null?void 0:r.launcher)!=null?x:{},i=(S=o!=null?o:s.closeButtonSize)!=null?S:"32px",d=y("div",n),l=y("button","persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-bg-gray-100 persona-cursor-pointer persona-border-none");l.style.height=i,l.style.width=i,l.type="button";let p=(M=s.closeButtonTooltipText)!=null?M:"Close chat",f=(E=s.closeButtonShowTooltip)!=null?E:!0;l.setAttribute("aria-label",p),l.style.display=t?"":"none";let u=(k=s.closeButtonIconName)!=null?k:"x",m=(h=s.closeButtonIconText)!=null?h:"\xD7";l.style.color=s.closeButtonColor||rn.actionIconColor;let v=Me(u,a,"currentColor",1);if(v?(v.style.display="block",l.appendChild(v)):l.textContent=m,s.closeButtonBackgroundColor?(l.style.backgroundColor=s.closeButtonBackgroundColor,l.classList.remove("hover:persona-bg-gray-100")):(l.style.backgroundColor="",l.classList.add("hover:persona-bg-gray-100")),s.closeButtonBorderWidth||s.closeButtonBorderColor){let w=s.closeButtonBorderWidth||"0px",C=s.closeButtonBorderColor||"transparent";l.style.border=`${w} solid ${C}`,l.classList.remove("persona-border-none")}else l.style.border="",l.classList.add("persona-border-none");if(s.closeButtonBorderRadius?(l.style.borderRadius=s.closeButtonBorderRadius,l.classList.remove("persona-rounded-full")):(l.style.borderRadius="",l.classList.add("persona-rounded-full")),s.closeButtonPaddingX?(l.style.paddingLeft=s.closeButtonPaddingX,l.style.paddingRight=s.closeButtonPaddingX):(l.style.paddingLeft="",l.style.paddingRight=""),s.closeButtonPaddingY?(l.style.paddingTop=s.closeButtonPaddingY,l.style.paddingBottom=s.closeButtonPaddingY):(l.style.paddingTop="",l.style.paddingBottom=""),d.appendChild(l),f&&p){let w=null,C=()=>{if(w)return;let W=l.ownerDocument,R=W.body;if(!R)return;w=to(W,"div","persona-clear-chat-tooltip"),w.textContent=p;let I=to(W,"div");I.className="persona-clear-chat-tooltip-arrow",w.appendChild(I);let N=l.getBoundingClientRect();w.style.position="fixed",w.style.zIndex=String(Fo),w.style.left=`${N.left+N.width/2}px`,w.style.top=`${N.top-8}px`,w.style.transform="translate(-50%, -100%)",R.appendChild(w)},T=()=>{w&&w.parentNode&&(w.parentNode.removeChild(w),w=null)};d.addEventListener("mouseenter",C),d.addEventListener("mouseleave",T),l.addEventListener("focus",C),l.addEventListener("blur",T),d._cleanupTooltip=()=>{T(),d.removeEventListener("mouseenter",C),d.removeEventListener("mouseleave",T),l.removeEventListener("focus",C),l.removeEventListener("blur",T)}}return{button:l,wrapper:d}},z0="persona-relative persona-ml-auto persona-clear-chat-button-wrapper",Tl=(r,e={})=>{var w,C,T,W,R,I,N,V,ie,xe,Je,we,De;let{wrapperClassName:t=z0,buttonSize:n,iconSize:o="20px"}=e,s=(C=((w=r==null?void 0:r.launcher)!=null?w:{}).clearChat)!=null?C:{},i=(T=n!=null?n:s.size)!=null?T:"32px",d=(W=s.iconName)!=null?W:"refresh-cw",l=(R=s.iconColor)!=null?R:"",p=(I=s.backgroundColor)!=null?I:"",f=(N=s.borderWidth)!=null?N:"",u=(V=s.borderColor)!=null?V:"",m=(ie=s.borderRadius)!=null?ie:"",v=(xe=s.paddingX)!=null?xe:"",x=(Je=s.paddingY)!=null?Je:"",S=(we=s.tooltipText)!=null?we:"Clear chat",M=(De=s.showTooltip)!=null?De:!0,E=y("div",t),k=y("button","persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-bg-gray-100 persona-cursor-pointer persona-border-none");k.style.height=i,k.style.width=i,k.type="button",k.setAttribute("aria-label",S),k.style.color=l||rn.actionIconColor;let h=Me(d,o,"currentColor",1);if(h&&(h.style.display="block",k.appendChild(h)),p&&(k.style.backgroundColor=p,k.classList.remove("hover:persona-bg-gray-100")),f||u){let Ae=f||"0px",qe=u||"transparent";k.style.border=`${Ae} solid ${qe}`,k.classList.remove("persona-border-none")}if(m&&(k.style.borderRadius=m,k.classList.remove("persona-rounded-full")),v&&(k.style.paddingLeft=v,k.style.paddingRight=v),x&&(k.style.paddingTop=x,k.style.paddingBottom=x),E.appendChild(k),M&&S){let Ae=null,qe=()=>{if(Ae)return;let J=k.ownerDocument,re=J.body;if(!re)return;Ae=to(J,"div","persona-clear-chat-tooltip"),Ae.textContent=S;let Q=to(J,"div");Q.className="persona-clear-chat-tooltip-arrow",Ae.appendChild(Q);let ge=k.getBoundingClientRect();Ae.style.position="fixed",Ae.style.zIndex=String(Fo),Ae.style.left=`${ge.left+ge.width/2}px`,Ae.style.top=`${ge.top-8}px`,Ae.style.transform="translate(-50%, -100%)",re.appendChild(Ae)},Ie=()=>{Ae&&Ae.parentNode&&(Ae.parentNode.removeChild(Ae),Ae=null)};E.addEventListener("mouseenter",qe),E.addEventListener("mouseleave",Ie),k.addEventListener("focus",qe),k.addEventListener("blur",Ie),E._cleanupTooltip=()=>{Ie(),E.removeEventListener("mouseenter",qe),E.removeEventListener("mouseleave",Ie),k.removeEventListener("focus",qe),k.removeEventListener("blur",Ie)}}return{button:k,wrapper:E}};var rn={titleColor:"var(--persona-header-title-fg, var(--persona-primary, #0f0f0f))",subtitleColor:"var(--persona-header-subtitle-fg, var(--persona-text-muted, var(--persona-muted, #9ca3af)))",actionIconColor:"var(--persona-header-action-icon-fg, var(--persona-muted, #9ca3af))"},bo=r=>{var w,C,T,W,R,I,N,V,ie,xe,Je,we,De,Ae,qe,Ie;let{config:e,showClose:t=!0}=r,n=y("div","persona-widget-header persona-flex persona-items-center persona-gap-3 persona-px-6 persona-py-5");n.setAttribute("data-persona-theme-zone","header"),n.style.backgroundColor="var(--persona-header-bg, var(--persona-surface, #ffffff))",n.style.borderBottomColor="var(--persona-header-border, var(--persona-divider, #f1f5f9))",n.style.boxShadow="var(--persona-header-shadow, none)",n.style.borderBottom="var(--persona-header-border-bottom, 1px solid var(--persona-header-border, var(--persona-divider, #f1f5f9)))";let o=(w=e==null?void 0:e.launcher)!=null?w:{},a=(C=o.headerIconSize)!=null?C:"48px",s=(T=o.closeButtonPlacement)!=null?T:"inline",i=(W=o.headerIconHidden)!=null?W:!1,d=o.headerIconName,l=y("div","persona-flex persona-items-center persona-justify-center persona-rounded-xl persona-text-xl");if(l.style.height=a,l.style.width=a,l.style.backgroundColor="var(--persona-header-icon-bg, var(--persona-primary, #0f0f0f))",l.style.color="var(--persona-header-icon-fg, var(--persona-text-inverse, #ffffff))",!i)if(d){let J=parseFloat(a)||24,re=Me(d,J*.6,"currentColor",1);re?l.replaceChildren(re):l.textContent=(I=(R=e==null?void 0:e.launcher)==null?void 0:R.agentIconText)!=null?I:"\u{1F4AC}"}else if((N=e==null?void 0:e.launcher)!=null&&N.iconUrl){let J=y("img");J.src=e.launcher.iconUrl,J.alt="",J.className="persona-rounded-xl persona-object-cover",J.style.height=a,J.style.width=a,l.replaceChildren(J)}else l.textContent=(ie=(V=e==null?void 0:e.launcher)==null?void 0:V.agentIconText)!=null?ie:"\u{1F4AC}";let p=y("div","persona-flex persona-flex-col persona-flex-1 persona-min-w-0"),f=y("span","persona-text-base persona-font-semibold");f.style.color=rn.titleColor,f.textContent=(Je=(xe=e==null?void 0:e.launcher)==null?void 0:xe.title)!=null?Je:"Chat Assistant";let u=y("span","persona-text-xs");u.style.color=rn.subtitleColor,u.textContent=(De=(we=e==null?void 0:e.launcher)==null?void 0:we.subtitle)!=null?De:"Here to help you get answers fast",p.append(f,u),i?n.append(p):n.append(l,p);let m=(Ae=o.clearChat)!=null?Ae:{},v=(qe=m.enabled)!=null?qe:!0,x=(Ie=m.placement)!=null?Ie:"inline",S=null,M=null;if(v){let re=Tl(e,{wrapperClassName:x==="top-right"?"persona-absolute persona-top-4 persona-z-50":"persona-relative persona-ml-auto persona-clear-chat-button-wrapper"});S=re.button,M=re.wrapper,x==="top-right"&&(M.style.right="48px"),x==="inline"&&n.appendChild(M)}let E=s==="top-right"?"persona-absolute persona-top-4 persona-right-4 persona-z-50":v&&x==="inline"?"persona-relative persona-inline-flex persona-items-center persona-justify-center":"persona-relative persona-ml-auto persona-inline-flex persona-items-center persona-justify-center",{button:k,wrapper:h}=Sl(e,{showClose:t,wrapperClassName:E});return s!=="top-right"&&n.appendChild(h),{header:n,iconHolder:l,headerTitle:f,headerSubtitle:u,closeButton:k,closeButtonWrapper:h,clearChatButton:S,clearChatButtonWrapper:M}},ha=(r,e,t)=>{var s,i,d,l;let n=(s=t==null?void 0:t.launcher)!=null?s:{},o=(i=n.closeButtonPlacement)!=null?i:"inline",a=(l=(d=n.clearChat)==null?void 0:d.placement)!=null?l:"inline";r.appendChild(e.header),o==="top-right"&&(r.style.position="relative",r.appendChild(e.closeButtonWrapper)),e.clearChatButtonWrapper&&a==="top-right"&&(r.style.position="relative",r.appendChild(e.clearChatButtonWrapper))};function _o(r){let{items:e,onSelect:t,anchor:n,position:o="bottom-left",portal:a}=r,s=y("div","persona-dropdown-menu persona-hidden");s.setAttribute("role","menu"),s.setAttribute("data-persona-theme-zone","dropdown"),a?(s.style.position="fixed",s.style.zIndex=String(Fo)):(s.style.position="absolute",s.style.top="100%",s.style.marginTop="4px",o==="bottom-right"?s.style.right="0":s.style.left="0");for(let m of e){if(m.dividerBefore){let S=document.createElement("hr");s.appendChild(S)}let v=document.createElement("button");if(v.type="button",v.setAttribute("role","menuitem"),v.setAttribute("data-dropdown-item-id",m.id),m.destructive&&v.setAttribute("data-destructive",""),m.icon){let S=Me(m.icon,16,"currentColor",1.5);S&&v.appendChild(S)}let x=document.createElement("span");x.textContent=m.label,v.appendChild(x),v.addEventListener("click",S=>{S.stopPropagation(),p(),t(m.id)}),s.appendChild(v)}let i=null;function d(){if(!a)return;let m=n.getBoundingClientRect();s.style.top=`${m.bottom+4}px`,o==="bottom-right"?(s.style.right=`${window.innerWidth-m.right}px`,s.style.left="auto"):(s.style.left=`${m.left}px`,s.style.right="auto")}function l(){d(),s.classList.remove("persona-hidden"),requestAnimationFrame(()=>{let m=v=>{!s.contains(v.target)&&!n.contains(v.target)&&p()};document.addEventListener("click",m,!0),i=()=>document.removeEventListener("click",m,!0)})}function p(){s.classList.add("persona-hidden"),i==null||i(),i=null}function f(){s.classList.contains("persona-hidden")?l():p()}function u(){p(),s.remove()}return a&&a.appendChild(s),{element:s,show:l,hide:p,toggle:f,destroy:u}}function Dr(r){let{icon:e,label:t,size:n,strokeWidth:o,className:a,onClick:s,aria:i}=r,d=y("button","persona-icon-btn"+(a?" "+a:""));d.type="button",d.setAttribute("aria-label",t),d.title=t;let l=Me(e,n!=null?n:16,"currentColor",o!=null?o:2);if(l&&d.appendChild(l),s&&d.addEventListener("click",s),i)for(let[p,f]of Object.entries(i))d.setAttribute(p,f);return d}function Qs(r){let{icon:e,label:t,variant:n="default",size:o="sm",iconSize:a,className:s,onClick:i,aria:d}=r,l="persona-label-btn";n!=="default"&&(l+=" persona-label-btn--"+n),l+=" persona-label-btn--"+o,s&&(l+=" "+s);let p=y("button",l);if(p.type="button",p.setAttribute("aria-label",t),e){let u=Me(e,a!=null?a:14,"currentColor",2);u&&p.appendChild(u)}let f=y("span");if(f.textContent=t,p.appendChild(f),i&&p.addEventListener("click",i),d)for(let[u,m]of Object.entries(d))p.setAttribute(u,m);return p}function rx(r){let{items:e,selectedId:t,onSelect:n,className:o}=r,a=y("div","persona-toggle-group"+(o?" "+o:""));a.setAttribute("role","group");let s=t,i=[];function d(){for(let p of i)p.btn.setAttribute("aria-pressed",p.id===s?"true":"false")}for(let p of e){let f;p.icon?f=Dr({icon:p.icon,label:p.label,onClick:()=>{s=p.id,d(),n(p.id)}}):(f=y("button","persona-icon-btn"),f.type="button",f.setAttribute("aria-label",p.label),f.title=p.label,f.textContent=p.label,f.addEventListener("click",()=>{s=p.id,d(),n(p.id)})),f.setAttribute("aria-pressed",p.id===s?"true":"false"),i.push({id:p.id,btn:f}),a.appendChild(f)}function l(p){s=p,d()}return{element:a,setSelected:l}}function Ml(r){var m,v;let{label:e,icon:t="chevron-down",menuItems:n,onSelect:o,position:a="bottom-left",portal:s,className:i,hover:d}=r,l=y("div","persona-combo-btn"+(i?" "+i:""));l.style.position="relative",l.style.display="inline-flex",l.style.alignItems="center",l.style.cursor="pointer",l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("aria-haspopup","true"),l.setAttribute("aria-expanded","false"),l.setAttribute("aria-label",e);let p=y("span","persona-combo-btn-label");p.textContent=e,l.appendChild(p);let f=Me(t,14,"currentColor",2);f&&(f.style.marginLeft="4px",f.style.opacity="0.6",l.appendChild(f)),d&&(l.style.borderRadius=(m=d.borderRadius)!=null?m:"10px",l.style.padding=(v=d.padding)!=null?v:"6px 4px 6px 12px",l.style.border="1px solid transparent",l.style.transition="background-color 0.15s ease, border-color 0.15s ease",l.addEventListener("mouseenter",()=>{var x,S;l.style.backgroundColor=(x=d.background)!=null?x:"",l.style.borderColor=(S=d.border)!=null?S:""}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor="",l.style.borderColor="transparent"}));let u=_o({items:n,onSelect:x=>{l.setAttribute("aria-expanded","false"),o(x)},anchor:l,position:a,portal:s});return s||l.appendChild(u.element),l.addEventListener("click",x=>{x.stopPropagation();let S=!u.element.classList.contains("persona-hidden");l.setAttribute("aria-expanded",S?"false":"true"),u.toggle()}),l.addEventListener("keydown",x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),l.click())}),{element:l,setLabel:x=>{p.textContent=x,l.setAttribute("aria-label",x)},open:()=>{l.setAttribute("aria-expanded","true"),u.show()},close:()=>{l.setAttribute("aria-expanded","false"),u.hide()},toggle:()=>{let x=!u.element.classList.contains("persona-hidden");l.setAttribute("aria-expanded",x?"false":"true"),u.toggle()},destroy:()=>{u.destroy(),l.remove()}}}var Bp=r=>{var n;let e=bo({config:r.config,showClose:r.showClose,onClose:r.onClose,onClearChat:r.onClearChat}),t=(n=r.layoutHeaderConfig)==null?void 0:n.onTitleClick;if(t){let o=e.headerTitle.parentElement;o&&(o.style.cursor="pointer",o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.addEventListener("click",()=>t()),o.addEventListener("keydown",a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),t())}))}return e};function $0(r,e,t){var n,o,a;if(e!=null&&e.length)for(let s of e){let i=y("button","persona-inline-flex persona-items-center persona-justify-center persona-rounded-md persona-border-none persona-bg-transparent persona-p-0 persona-text-persona-muted hover:persona-opacity-80");if(i.type="button",i.setAttribute("aria-label",(o=(n=s.ariaLabel)!=null?n:s.label)!=null?o:s.id),s.icon){let d=Me(s.icon,14,"currentColor",2);d&&i.appendChild(d)}else s.label&&(i.textContent=s.label);if((a=s.menuItems)!=null&&a.length){let d=y("div","persona-relative");d.appendChild(i);let l=_o({items:s.menuItems,onSelect:p=>t==null?void 0:t(p),anchor:d,position:"bottom-left"});d.appendChild(l.element),i.addEventListener("click",p=>{p.stopPropagation(),l.toggle()}),r.appendChild(d)}else i.addEventListener("click",()=>t==null?void 0:t(s.id)),r.appendChild(i)}}var Dp=r=>{var E,k,h,w,C,T,W,R,I;let{config:e,showClose:t=!0,onClose:n,layoutHeaderConfig:o,onHeaderAction:a}=r,s=(E=e==null?void 0:e.launcher)!=null?E:{},i=y("div","persona-flex persona-items-center persona-justify-between persona-px-6 persona-py-4");i.setAttribute("data-persona-theme-zone","header"),i.style.backgroundColor="var(--persona-header-bg, var(--persona-surface, #ffffff))",i.style.borderBottomColor="var(--persona-header-border, var(--persona-divider, #f1f5f9))",i.style.boxShadow="var(--persona-header-shadow, none)",i.style.borderBottom="var(--persona-header-border-bottom, 1px solid var(--persona-header-border, var(--persona-divider, #f1f5f9)))";let d=o==null?void 0:o.titleMenu,l,p;if(d)l=Ml({label:(k=s.title)!=null?k:"Chat Assistant",menuItems:d.menuItems,onSelect:d.onSelect,hover:d.hover,className:""}).element,l.style.color=rn.titleColor,p=(h=l.querySelector(".persona-combo-btn-label"))!=null?h:l;else{if(l=y("div","persona-flex persona-min-w-0 persona-flex-1 persona-items-center persona-gap-1"),p=y("span","persona-text-base persona-font-semibold persona-truncate"),p.style.color=rn.titleColor,p.textContent=(w=s.title)!=null?w:"Chat Assistant",l.appendChild(p),$0(l,o==null?void 0:o.trailingActions,(C=o==null?void 0:o.onAction)!=null?C:a),o!=null&&o.onTitleClick){l.style.cursor="pointer",l.setAttribute("role","button"),l.setAttribute("tabindex","0");let V=o.onTitleClick;l.addEventListener("click",ie=>{ie.target.closest("button")||V()}),l.addEventListener("keydown",ie=>{(ie.key==="Enter"||ie.key===" ")&&(ie.preventDefault(),V())})}let N=o==null?void 0:o.titleRowHover;N&&(l.style.borderRadius=(T=N.borderRadius)!=null?T:"10px",l.style.padding=(W=N.padding)!=null?W:"6px 4px 6px 12px",l.style.margin="-6px 0 -6px -12px",l.style.border="1px solid transparent",l.style.transition="background-color 0.15s ease, border-color 0.15s ease",l.style.width="fit-content",l.style.flex="none",l.addEventListener("mouseenter",()=>{var V,ie;l.style.backgroundColor=(V=N.background)!=null?V:"",l.style.borderColor=(ie=N.border)!=null?ie:""}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor="",l.style.borderColor="transparent"}))}i.appendChild(l);let f=(R=s.closeButtonSize)!=null?R:"32px",u=y("div",""),m=y("button","persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-bg-gray-100 persona-cursor-pointer persona-border-none");m.style.height=f,m.style.width=f,m.type="button",m.setAttribute("aria-label","Close chat"),m.style.display=t?"":"none",m.style.color=s.closeButtonColor||rn.actionIconColor;let v=(I=s.closeButtonIconName)!=null?I:"x",x=Me(v,"28px","currentColor",1);x?m.appendChild(x):m.textContent="\xD7",n&&m.addEventListener("click",n),u.appendChild(m),i.appendChild(u);let S=y("div");S.style.display="none";let M=y("span");return M.style.display="none",{header:i,iconHolder:S,headerTitle:p,headerSubtitle:M,closeButton:m,closeButtonWrapper:u,clearChatButton:null,clearChatButtonWrapper:null}},kl={default:Bp,minimal:Dp},Fp=r=>{var e;return(e=kl[r])!=null?e:kl.default},$a=(r,e,t)=>{var s,i,d;if(e!=null&&e.render){let l=e.render({config:r,onClose:t==null?void 0:t.onClose,onClearChat:t==null?void 0:t.onClearChat,trailingActions:e.trailingActions,onAction:e.onAction}),p=y("div");p.style.display="none";let f=y("span"),u=y("span"),m=y("button");m.style.display="none";let v=y("div");return v.style.display="none",{header:l,iconHolder:p,headerTitle:f,headerSubtitle:u,closeButton:m,closeButtonWrapper:v,clearChatButton:null,clearChatButtonWrapper:null}}let n=(s=e==null?void 0:e.layout)!=null?s:"default",a=Fp(n)({config:r,showClose:(d=(i=e==null?void 0:e.showCloseButton)!=null?i:t==null?void 0:t.showClose)!=null?d:!0,onClose:t==null?void 0:t.onClose,onClearChat:t==null?void 0:t.onClearChat,layoutHeaderConfig:e,onHeaderAction:e==null?void 0:e.onAction});return e&&(e.showIcon===!1&&(a.iconHolder.style.display="none"),e.showTitle===!1&&(a.headerTitle.style.display="none"),e.showSubtitle===!1&&(a.headerSubtitle.style.display="none"),e.showCloseButton===!1&&(a.closeButton.style.display="none"),e.showClearChat===!1&&a.clearChatButtonWrapper&&(a.clearChatButtonWrapper.style.display="none")),a};var El=r=>{var s,i;let e=y("textarea");e.setAttribute("data-persona-composer-input",""),e.placeholder=(i=(s=r==null?void 0:r.copy)==null?void 0:s.inputPlaceholder)!=null?i:"Type your message\u2026",e.className="persona-w-full persona-min-h-[24px] persona-resize-none persona-border-none persona-bg-transparent persona-text-sm persona-text-persona-primary focus:persona-outline-none focus:persona-border-none persona-composer-textarea",e.rows=1,e.style.fontFamily='var(--persona-input-font-family, var(--persona-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif))',e.style.fontWeight="var(--persona-input-font-weight, var(--persona-font-weight, 400))";let t=3,n=20;e.style.maxHeight=`${t*n}px`,e.style.overflowY="auto";let o=()=>{let d=parseFloat(e.style.maxHeight);return Number.isFinite(d)&&d>0?d:t*n},a=()=>{e.addEventListener("input",()=>{e.style.height="auto";let d=Math.min(e.scrollHeight,o());e.style.height=`${d}px`})};return e.style.border="none",e.style.outline="none",e.style.borderWidth="0",e.style.borderStyle="none",e.style.borderColor="transparent",e.addEventListener("focus",()=>{e.style.border="none",e.style.outline="none",e.style.borderWidth="0",e.style.borderStyle="none",e.style.borderColor="transparent",e.style.boxShadow="none"}),e.addEventListener("blur",()=>{e.style.border="none",e.style.outline="none"}),{textarea:e,attachAutoResize:a}},Ll=r=>{var w,C,T,W,R,I,N,V,ie,xe,Je,we;let e=(w=r==null?void 0:r.sendButton)!=null?w:{},t=(C=e.useIcon)!=null?C:!1,n=(T=e.iconText)!=null?T:"\u2191",o=e.iconName,a=(W=e.stopIconName)!=null?W:"square",s=(R=e.tooltipText)!=null?R:"Send message",i=(I=e.stopTooltipText)!=null?I:"Stop generating",d=(V=(N=r==null?void 0:r.copy)==null?void 0:N.sendButtonLabel)!=null?V:"Send",l=(xe=(ie=r==null?void 0:r.copy)==null?void 0:ie.stopButtonLabel)!=null?xe:"Stop",p=(Je=e.showTooltip)!=null?Je:!1,f=(we=e.size)!=null?we:"40px",u=e.backgroundColor,m=e.textColor,v=y("div","persona-send-button-wrapper"),x=y("button",t?"persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer":"persona-rounded-button persona-bg-persona-accent persona-px-4 persona-py-2 persona-text-sm persona-font-semibold disabled:persona-opacity-50 persona-cursor-pointer");x.type="submit",x.setAttribute("data-persona-composer-submit","");let S=null,M=null;if(t){x.style.width=f,x.style.height=f,x.style.minWidth=f,x.style.minHeight=f,x.style.fontSize="18px",x.style.lineHeight="1",x.innerHTML="",m?x.style.color=m:x.style.color="var(--persona-button-primary-fg, #ffffff)";let De=parseFloat(f)||24,Ae=(m==null?void 0:m.trim())||"currentColor";o?(S=Me(o,De,Ae,2),S?x.appendChild(S):x.textContent=n):x.textContent=n,M=Me(a,De,Ae,2),u?x.style.backgroundColor=u:x.classList.add("persona-bg-persona-primary")}else x.textContent=d,m?x.style.color=m:x.classList.add("persona-text-white");e.borderWidth&&(x.style.borderWidth=e.borderWidth,x.style.borderStyle="solid"),e.borderColor&&(x.style.borderColor=e.borderColor),e.paddingX?(x.style.paddingLeft=e.paddingX,x.style.paddingRight=e.paddingX):(x.style.paddingLeft="",x.style.paddingRight=""),e.paddingY?(x.style.paddingTop=e.paddingY,x.style.paddingBottom=e.paddingY):(x.style.paddingTop="",x.style.paddingBottom="");let E=null;p&&s&&(E=y("div","persona-send-button-tooltip"),E.textContent=s,v.appendChild(E)),x.setAttribute("aria-label",s),v.appendChild(x);let k="send";return{button:x,wrapper:v,setMode:De=>{if(De===k)return;k=De;let Ae=De==="stop"?i:s;if(x.setAttribute("aria-label",Ae),E&&(E.textContent=Ae),t){if(S&&M){let qe=De==="stop"?M:S;x.replaceChildren(qe)}}else x.textContent=De==="stop"?l:d}}},Pl=r=>{var E,k,h,w,C,T,W,R,I,N,V,ie;let e=(E=r==null?void 0:r.voiceRecognition)!=null?E:{};if(!(e.enabled===!0))return null;let n=typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined"),o=((k=e.provider)==null?void 0:k.type)==="runtype";if(!(n||o))return null;let s=(w=(h=r==null?void 0:r.sendButton)==null?void 0:h.size)!=null?w:"40px",i=y("div","persona-send-button-wrapper"),d=y("button","persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer");d.type="button",d.setAttribute("data-persona-composer-mic",""),d.setAttribute("aria-label","Start voice recognition");let l=(C=e.iconName)!=null?C:"mic",p=(T=e.iconSize)!=null?T:s,f=parseFloat(p)||24,u=(R=e.backgroundColor)!=null?R:(W=r==null?void 0:r.sendButton)==null?void 0:W.backgroundColor,m=(N=e.iconColor)!=null?N:(I=r==null?void 0:r.sendButton)==null?void 0:I.textColor;d.style.width=p,d.style.height=p,d.style.minWidth=p,d.style.minHeight=p,d.style.fontSize="18px",d.style.lineHeight="1",m?d.style.color=m:d.style.color="var(--persona-text, #111827)";let x=Me(l,f,m||"currentColor",1.5);x?d.appendChild(x):d.textContent="\u{1F3A4}",u&&(d.style.backgroundColor=u),e.borderWidth&&(d.style.borderWidth=e.borderWidth,d.style.borderStyle="solid"),e.borderColor&&(d.style.borderColor=e.borderColor),e.paddingX&&(d.style.paddingLeft=e.paddingX,d.style.paddingRight=e.paddingX),e.paddingY&&(d.style.paddingTop=e.paddingY,d.style.paddingBottom=e.paddingY),i.appendChild(d);let S=(V=e.tooltipText)!=null?V:"Start voice recognition";if(((ie=e.showTooltip)!=null?ie:!1)&&S){let xe=y("div","persona-send-button-tooltip");xe.textContent=S,i.appendChild(xe)}return{button:d,wrapper:i}},Rl=r=>{var v,x,S,M,E,k,h,w;let e=(v=r==null?void 0:r.attachments)!=null?v:{};if(e.enabled!==!0)return null;let t=(S=(x=r==null?void 0:r.sendButton)==null?void 0:x.size)!=null?S:"40px",n=y("div","persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2");n.style.display="none";let o=y("input");o.type="file",o.accept=((M=e.allowedTypes)!=null?M:ho).join(","),o.multiple=((E=e.maxFiles)!=null?E:4)>1,o.style.display="none",o.setAttribute("aria-label","Attach files");let a=y("div","persona-send-button-wrapper"),s=y("button","persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-attachment-button");s.type="button",s.setAttribute("aria-label",(k=e.buttonTooltipText)!=null?k:"Attach file");let i=(h=e.buttonIconName)!=null?h:"paperclip",d=t,l=parseFloat(d)||40,p=Math.round(l*.6);s.style.width=d,s.style.height=d,s.style.minWidth=d,s.style.minHeight=d,s.style.fontSize="18px",s.style.lineHeight="1",s.style.backgroundColor="transparent",s.style.color="var(--persona-primary, #111827)",s.style.border="none",s.style.borderRadius="6px",s.style.transition="background-color 0.15s ease",s.addEventListener("mouseenter",()=>{s.style.backgroundColor="var(--persona-palette-colors-black-alpha-50, rgba(0, 0, 0, 0.05))"}),s.addEventListener("mouseleave",()=>{s.style.backgroundColor="transparent"});let f=Me(i,p,"currentColor",1.5);f?s.appendChild(f):s.textContent="\u{1F4CE}",s.addEventListener("click",C=>{C.preventDefault(),o.click()}),a.appendChild(s);let u=(w=e.buttonTooltipText)!=null?w:"Attach file",m=y("div","persona-send-button-tooltip");return m.textContent=u,a.appendChild(m),{button:s,wrapper:a,input:o,previewsContainer:n}},Il=r=>{var s,i,d;let e=(s=r==null?void 0:r.statusIndicator)!=null?s:{},t=e.align==="left"?"persona-text-left":e.align==="center"?"persona-text-center":"persona-text-right",n=y("div",`persona-mt-2 ${t} persona-text-xs persona-text-persona-muted`);n.setAttribute("data-persona-composer-status","");let o=(i=e.visible)!=null?i:!0;n.style.display=o?"":"none";let a=(d=e.idleText)!=null?d:"Online";if(e.idleLink){let l=y("a");l.href=e.idleLink,l.target="_blank",l.rel="noopener noreferrer",l.textContent=a,l.style.color="inherit",l.style.textDecoration="none",n.appendChild(l)}else n.textContent=a;return n},Wl=()=>y("div","persona-mb-3 persona-flex persona-flex-wrap persona-gap-2");var Va=r=>{var v,x,S,M,E,k;let{config:e}=r,t=y("div","persona-widget-footer persona-border-t-persona-divider persona-bg-persona-surface persona-px-6 persona-py-4");t.setAttribute("data-persona-theme-zone","composer");let n=Wl(),o=y("form","persona-widget-composer persona-flex persona-flex-col persona-gap-2 persona-rounded-2xl persona-border persona-border-gray-200 persona-bg-persona-input-background persona-px-4 persona-py-3");o.setAttribute("data-persona-composer-form",""),o.style.outline="none";let{textarea:a,attachAutoResize:s}=El(e);s();let i=Ll(e),d=Pl(e),l=Rl(e),p=Il(e);l&&(l.previewsContainer.style.gap="8px",o.append(l.previewsContainer,l.input)),o.append(a);let f=y("div","persona-widget-composer__actions persona-flex persona-items-center persona-justify-between persona-w-full"),u=y("div","persona-widget-composer__left-actions persona-flex persona-items-center persona-gap-2"),m=y("div","persona-widget-composer__right-actions persona-flex persona-items-center persona-gap-1");return l&&u.append(l.wrapper),d&&m.append(d.wrapper),m.append(i.wrapper),f.append(u,m),o.append(f),o.addEventListener("click",h=>{h.target!==i.button&&h.target!==i.wrapper&&h.target!==(d==null?void 0:d.button)&&h.target!==(d==null?void 0:d.wrapper)&&h.target!==(l==null?void 0:l.button)&&h.target!==(l==null?void 0:l.wrapper)&&a.focus()}),t.append(n,o,p),{footer:t,suggestions:n,composerForm:o,textarea:a,sendButton:i.button,sendButtonWrapper:i.wrapper,micButton:(v=d==null?void 0:d.button)!=null?v:null,micButtonWrapper:(x=d==null?void 0:d.wrapper)!=null?x:null,statusText:p,attachmentButton:(S=l==null?void 0:l.button)!=null?S:null,attachmentButtonWrapper:(M=l==null?void 0:l.wrapper)!=null?M:null,attachmentInput:(E=l==null?void 0:l.input)!=null?E:null,attachmentPreviewsContainer:(k=l==null?void 0:l.previewsContainer)!=null?k:null,actionsRow:f,leftActions:u,rightActions:m,setSendButtonMode:i.setMode}};var nx=()=>{let r=y("button","persona-pill-peek");r.type="button",r.setAttribute("data-persona-pill-peek",""),r.setAttribute("aria-label","Show conversation"),r.setAttribute("tabindex","-1");let e=y("span","persona-pill-peek__icon"),t=Me("message-square",16,"currentColor",1.5);t&&e.appendChild(t);let n=y("span","persona-pill-peek__text"),o=y("span","persona-pill-peek__caret"),a=Me("chevron-up",16,"currentColor",1.5);return a&&o.appendChild(a),r.append(e,n,o),{root:r,textNode:n}},ox=r=>{var v,x,S,M,E,k;let{config:e}=r,t=y("div","persona-widget-footer persona-widget-footer--pill");t.setAttribute("data-persona-theme-zone","composer");let n=Wl();n.style.display="none";let o=Il(e);o.style.display="none";let{textarea:a,attachAutoResize:s}=El(e);a.style.maxHeight="100px",s();let i=Ll(e),d=Pl(e),l=Rl(e);l&&l.previewsContainer.classList.add("persona-pill-composer__previews");let p=y("form","persona-widget-composer persona-pill-composer");p.setAttribute("data-persona-composer-form",""),p.style.outline="none";let f=y("div","persona-widget-composer__left-actions persona-pill-composer__left");l&&f.append(l.wrapper);let u=y("div","persona-widget-composer__right-actions persona-pill-composer__right");d&&u.append(d.wrapper),u.append(i.wrapper),p.addEventListener("click",h=>{h.target!==i.button&&h.target!==i.wrapper&&h.target!==(d==null?void 0:d.button)&&h.target!==(d==null?void 0:d.wrapper)&&h.target!==(l==null?void 0:l.button)&&h.target!==(l==null?void 0:l.wrapper)&&a.focus()}),l&&p.append(l.input),p.append(f,a,u),l&&t.append(l.previewsContainer),t.append(p,n,o);let m=p;return{footer:t,suggestions:n,composerForm:p,textarea:a,sendButton:i.button,sendButtonWrapper:i.wrapper,micButton:(v=d==null?void 0:d.button)!=null?v:null,micButtonWrapper:(x=d==null?void 0:d.wrapper)!=null?x:null,statusText:o,attachmentButton:(S=l==null?void 0:l.button)!=null?S:null,attachmentButtonWrapper:(M=l==null?void 0:l.wrapper)!=null?M:null,attachmentInput:(E=l==null?void 0:l.input)!=null?E:null,attachmentPreviewsContainer:(k=l==null?void 0:l.previewsContainer)!=null?k:null,actionsRow:m,leftActions:f,rightActions:u,setSendButtonMode:i.setMode}};var ax=r=>{var p,f,u,m,v,x,S,M,E,k,h,w,C,T,W,R,I;let e=(f=(p=r==null?void 0:r.launcher)==null?void 0:p.enabled)!=null?f:!0,t=Rr(r);if(Oo(r)){let N=(m=(u=r==null?void 0:r.launcher)==null?void 0:u.composerBar)!=null?m:{},V=y("div","persona-widget-wrapper persona-fixed persona-transition");V.setAttribute("data-persona-composer-bar",""),V.dataset.state="collapsed",V.dataset.expandedSize=(v=N.expandedSize)!=null?v:"anchored",V.style.zIndex=String((S=(x=r==null?void 0:r.launcher)==null?void 0:x.zIndex)!=null?S:Gr);let ie=y("div","persona-widget-panel persona-relative persona-flex persona-flex-1 persona-min-h-0 persona-flex-col");ie.style.width="100%",V.appendChild(ie);let xe=y("div","persona-widget-pill-root");return xe.setAttribute("data-persona-composer-bar",""),xe.dataset.state="collapsed",xe.dataset.expandedSize=(M=N.expandedSize)!=null?M:"anchored",xe.style.zIndex=String((k=(E=r==null?void 0:r.launcher)==null?void 0:E.zIndex)!=null?k:Gr),{wrapper:V,panel:ie,pillRoot:xe}}if(t){let N=y("div","persona-relative persona-h-full persona-w-full persona-flex persona-flex-1 persona-min-h-0 persona-flex-col"),V=y("div","persona-relative persona-h-full persona-w-full persona-flex persona-flex-1 persona-min-h-0 persona-flex-col");return N.appendChild(V),{wrapper:N,panel:V}}if(!e){let N=y("div","persona-relative persona-h-full persona-flex persona-flex-col persona-flex-1 persona-min-h-0"),V=y("div","persona-relative persona-flex-1 persona-flex persona-flex-col persona-min-h-0"),ie=(w=(h=r==null?void 0:r.launcher)==null?void 0:h.width)!=null?w:"100%";return N.style.width=ie,V.style.width="100%",N.appendChild(V),{wrapper:N,panel:V}}let o=(C=r==null?void 0:r.launcher)!=null?C:{},a=o.position&&Vn[o.position]?Vn[o.position]:Vn["bottom-right"],s=y("div",`persona-widget-wrapper persona-fixed ${a} persona-transition`);s.style.zIndex=String((W=(T=r==null?void 0:r.launcher)==null?void 0:T.zIndex)!=null?W:Gr);let i=y("div","persona-widget-panel persona-relative persona-min-h-[320px]"),d=(I=(R=r==null?void 0:r.launcher)==null?void 0:R.width)!=null?I:r==null?void 0:r.launcherWidth,l=d!=null?d:Cn;return i.style.width=l,i.style.maxWidth=l,s.appendChild(i),{wrapper:s,panel:i}},V0=(r,e)=>{var h,w,C,T,W,R,I,N,V;let t=y("div","persona-widget-container persona-relative persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-text-persona-primary");t.setAttribute("data-persona-theme-zone","container");let{button:n,wrapper:o}=Sl(r,{showClose:e,wrapperClassName:"persona-composer-bar-close",buttonSize:"16px",iconSize:"14px"});o.style.position="absolute",o.style.top="8px",o.style.right="8px",o.style.zIndex="10";let a=(C=(w=(h=r==null?void 0:r.launcher)==null?void 0:h.clearChat)==null?void 0:w.enabled)!=null?C:!0,s=null,i=null;if(a){let ie=Tl(r,{wrapperClassName:"persona-composer-bar-clear-chat",buttonSize:"16px",iconSize:"14px"});s=ie.button,i=ie.wrapper,i.style.position="absolute",i.style.top="8px",i.style.right="32px",i.style.zIndex="10"}let d=y("span","persona-widget-header");d.setAttribute("data-persona-theme-zone","header"),d.style.display="none";let l=y("div","persona-widget-body persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-gap-6 persona-overflow-y-auto persona-bg-persona-container persona-px-6 persona-py-6");l.style.paddingTop="48px",l.id="persona-scroll-container",l.setAttribute("data-persona-theme-zone","messages"),l.style.setProperty("scrollbar-gutter","stable");let p=y("div","persona-rounded-2xl persona-bg-persona-surface persona-p-6");p.style.boxShadow="var(--persona-intro-card-shadow, 0 5px 15px rgba(15, 23, 42, 0.08))",p.setAttribute("data-persona-intro-card","");let f=y("h2","persona-text-lg persona-font-semibold persona-text-persona-primary");f.textContent=(W=(T=r==null?void 0:r.copy)==null?void 0:T.welcomeTitle)!=null?W:"Hello \u{1F44B}";let u=y("p","persona-mt-2 persona-text-sm persona-text-persona-muted");u.textContent=(I=(R=r==null?void 0:r.copy)==null?void 0:R.welcomeSubtitle)!=null?I:"Ask anything about your account or products.",p.append(f,u);let m=y("div","persona-flex persona-flex-col persona-gap-3"),v=(N=r==null?void 0:r.layout)==null?void 0:N.contentMaxWidth;v&&(m.style.maxWidth=v,m.style.marginLeft="auto",m.style.marginRight="auto",m.style.width="100%"),((V=r==null?void 0:r.copy)==null?void 0:V.showWelcomeCard)!==!1||(p.style.display="none",l.classList.remove("persona-gap-6"),l.classList.add("persona-gap-3")),l.append(p,m);let S=y("div","persona-composer-overlay persona-pointer-events-none");S.setAttribute("data-persona-composer-overlay",""),S.style.position="absolute",S.style.left="0",S.style.right="0",S.style.bottom="0",S.style.zIndex="20";let M=ox({config:r}),{root:E,textNode:k}=nx();return t.append(d,o,l,S),i&&t.appendChild(i),{container:t,body:l,messagesWrapper:m,composerOverlay:S,suggestions:M.suggestions,textarea:M.textarea,sendButton:M.sendButton,sendButtonWrapper:M.sendButtonWrapper,micButton:M.micButton,micButtonWrapper:M.micButtonWrapper,composerForm:M.composerForm,statusText:M.statusText,introTitle:f,introSubtitle:u,closeButton:n,closeButtonWrapper:o,clearChatButton:s,clearChatButtonWrapper:i,iconHolder:y("span"),headerTitle:y("span"),headerSubtitle:y("span"),header:d,footer:M.footer,attachmentButton:M.attachmentButton,attachmentButtonWrapper:M.attachmentButtonWrapper,attachmentInput:M.attachmentInput,attachmentPreviewsContainer:M.attachmentPreviewsContainer,actionsRow:M.actionsRow,leftActions:M.leftActions,rightActions:M.rightActions,setSendButtonMode:M.setSendButtonMode,peekBanner:E,peekTextNode:k}},sx=(r,e=!0)=>{var S,M,E,k,h,w,C,T,W;if(Oo(r))return V0(r,e);let t=y("div","persona-widget-container persona-flex persona-h-full persona-w-full persona-flex-1 persona-min-h-0 persona-flex-col persona-text-persona-primary persona-bg-persona-surface persona-rounded-2xl persona-overflow-hidden persona-border persona-border-persona-border");t.setAttribute("data-persona-theme-zone","container");let n=(S=r==null?void 0:r.layout)==null?void 0:S.header,o=((M=r==null?void 0:r.layout)==null?void 0:M.showHeader)!==!1,a=n?$a(r,n,{showClose:e}):bo({config:r,showClose:e}),s=y("div","persona-widget-body persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-gap-6 persona-overflow-y-auto persona-bg-persona-container persona-px-6 persona-py-6");s.id="persona-scroll-container",s.setAttribute("data-persona-theme-zone","messages"),s.style.setProperty("scrollbar-gutter","stable");let i=y("div","persona-rounded-2xl persona-bg-persona-surface persona-p-6");i.style.boxShadow=Rr(r)?"none":"var(--persona-intro-card-shadow, 0 5px 15px rgba(15, 23, 42, 0.08))";let d=y("h2","persona-text-lg persona-font-semibold persona-text-persona-primary");d.textContent=(k=(E=r==null?void 0:r.copy)==null?void 0:E.welcomeTitle)!=null?k:"Hello \u{1F44B}";let l=y("p","persona-mt-2 persona-text-sm persona-text-persona-muted");l.textContent=(w=(h=r==null?void 0:r.copy)==null?void 0:h.welcomeSubtitle)!=null?w:"Ask anything about your account or products.",i.append(d,l);let p=y("div","persona-flex persona-flex-col persona-gap-3"),f=(C=r==null?void 0:r.layout)==null?void 0:C.contentMaxWidth;f&&(p.style.maxWidth=f,p.style.marginLeft="auto",p.style.marginRight="auto",p.style.width="100%"),i.setAttribute("data-persona-intro-card",""),((T=r==null?void 0:r.copy)==null?void 0:T.showWelcomeCard)!==!1||(i.style.display="none",s.classList.remove("persona-gap-6"),s.classList.add("persona-gap-3")),s.append(i,p);let m=Va({config:r}),v=((W=r==null?void 0:r.layout)==null?void 0:W.showFooter)!==!1;o?ha(t,a,r):(a.header.style.display="none",ha(t,a,r)),t.append(s);let x=y("div","persona-composer-overlay persona-pointer-events-none");return x.setAttribute("data-persona-composer-overlay",""),x.style.position="absolute",x.style.left="0",x.style.right="0",x.style.bottom="0",x.style.zIndex="20",v||(m.footer.style.display="none"),t.append(m.footer),t.append(x),{container:t,body:s,messagesWrapper:p,composerOverlay:x,suggestions:m.suggestions,textarea:m.textarea,sendButton:m.sendButton,sendButtonWrapper:m.sendButtonWrapper,micButton:m.micButton,micButtonWrapper:m.micButtonWrapper,composerForm:m.composerForm,statusText:m.statusText,introTitle:d,introSubtitle:l,closeButton:a.closeButton,closeButtonWrapper:a.closeButtonWrapper,clearChatButton:a.clearChatButton,clearChatButtonWrapper:a.clearChatButtonWrapper,iconHolder:a.iconHolder,headerTitle:a.headerTitle,headerSubtitle:a.headerSubtitle,header:a.header,footer:m.footer,attachmentButton:m.attachmentButton,attachmentButtonWrapper:m.attachmentButtonWrapper,attachmentInput:m.attachmentInput,attachmentPreviewsContainer:m.attachmentPreviewsContainer,actionsRow:m.actionsRow,leftActions:m.leftActions,rightActions:m.rightActions,setSendButtonMode:m.setSendButtonMode}};var j0=r=>{switch(r){case"max_tool_calls":return"Stopped after calling a tool. Send a follow-up to continue.";case"length":return"Response cut off as max tokens reached. Ask for more to continue.";case"content_filter":return"The provider filtered this response.";case"error":return"Something went wrong generating this response.";default:return null}},G0=(r,e)=>{if(!r)return null;let t=j0(r);if(t===null)return null;let n=e==null?void 0:e[r],o=n!==void 0?n:t;return o||null},K0=(r,e)=>{let t=y("div","persona-message-stop-reason persona-text-xs persona-mt-2 persona-italic");return t.setAttribute("data-stop-reason",r),t.setAttribute("role","note"),t.style.opacity="0.75",t.textContent=e,t},X0=r=>{let e=r.toLowerCase();return e.startsWith("data:image/svg+xml")?!1:!!(/^(?:https?|blob):/i.test(r)||e.startsWith("data:image/")||!r.includes(":"))},Np=r=>{let e=r.toLowerCase();return e.startsWith("javascript:")||e.startsWith("data:text/html")||e.startsWith("data:text/javascript")||e.startsWith("data:text/xml")||e.startsWith("data:application/xhtml")||e.startsWith("data:image/svg+xml")?!1:!!(/^(?:https?|blob):/i.test(r)||e.startsWith("data:")||!r.includes(":"))},Op=320,lx=320,Q0=r=>!r.contentParts||r.contentParts.length===0?[]:r.contentParts.filter(e=>e.type==="image"&&typeof e.image=="string"&&e.image.trim().length>0),J0=r=>!r.contentParts||r.contentParts.length===0?[]:r.contentParts.filter(e=>e.type==="audio"&&typeof e.audio=="string"&&e.audio.trim().length>0),Y0=r=>!r.contentParts||r.contentParts.length===0?[]:r.contentParts.filter(e=>e.type==="video"&&typeof e.video=="string"&&e.video.trim().length>0),Z0=r=>!r.contentParts||r.contentParts.length===0?[]:r.contentParts.filter(e=>e.type==="file"&&typeof e.data=="string"&&e.data.trim().length>0),ev=(r,e,t)=>{if(r.length===0)return null;try{let n=y("div","persona-flex persona-flex-col persona-gap-2");n.setAttribute("data-message-attachments","images"),e&&(n.style.marginBottom="8px");let o=0,a=!1,s=()=>{a||(a=!0,n.remove(),t==null||t())};return r.forEach((i,d)=>{var f;let l=y("img");l.alt=((f=i.alt)==null?void 0:f.trim())||`Attached image ${d+1}`,l.loading="lazy",l.decoding="async",l.referrerPolicy="no-referrer",l.style.display="block",l.style.width="100%",l.style.maxWidth=`${Op}px`,l.style.maxHeight=`${lx}px`,l.style.height="auto",l.style.objectFit="contain",l.style.borderRadius="10px",l.style.backgroundColor="var(--persona-attachment-image-bg, var(--persona-container, #f3f4f6))",l.style.border="1px solid var(--persona-attachment-image-border, var(--persona-border, #e5e7eb))";let p=!1;o+=1,l.addEventListener("error",()=>{p||(p=!0,o=Math.max(0,o-1),l.remove(),o===0&&s())}),l.addEventListener("load",()=>{p=!0}),X0(i.image)?(l.src=i.image,n.appendChild(l)):(p=!0,o=Math.max(0,o-1),l.remove())}),o===0?(s(),null):n}catch{return t==null||t(),null}},tv=r=>{if(r.length===0)return null;try{let e=y("div","persona-flex persona-flex-col persona-gap-2");e.setAttribute("data-message-attachments","audio");let t=0;return r.forEach(n=>{if(!Np(n.audio))return;let o=y("audio");o.controls=!0,o.preload="metadata",o.src=n.audio,o.style.display="block",o.style.width="100%",o.style.maxWidth=`${Op}px`,e.appendChild(o),t+=1}),t===0?(e.remove(),null):e}catch{return null}},rv=r=>{if(r.length===0)return null;try{let e=y("div","persona-flex persona-flex-col persona-gap-2");e.setAttribute("data-message-attachments","video");let t=0;return r.forEach(n=>{if(!Np(n.video))return;let o=y("video");o.controls=!0,o.preload="metadata",o.src=n.video,o.style.display="block",o.style.width="100%",o.style.maxWidth=`${Op}px`,o.style.maxHeight=`${lx}px`,o.style.borderRadius="10px",o.style.backgroundColor="var(--persona-attachment-image-bg, var(--persona-container, #f3f4f6))",e.appendChild(o),t+=1}),t===0?(e.remove(),null):e}catch{return null}},nv=r=>{if(r.length===0)return null;try{let e=y("div","persona-flex persona-flex-col persona-gap-2");e.setAttribute("data-message-attachments","files");let t=0;return r.forEach(n=>{if(!Np(n.data))return;let o=y("a");o.href=n.data,o.download=n.filename,o.target="_blank",o.rel="noopener noreferrer",o.textContent=n.filename,o.className="persona-message-file-attachment",o.style.display="inline-flex",o.style.alignItems="center",o.style.gap="6px",o.style.padding="6px 10px",o.style.borderRadius="8px",o.style.fontSize="0.875rem",o.style.textDecoration="underline",o.style.backgroundColor="var(--persona-attachment-file-bg, var(--persona-container, #f3f4f6))",o.style.border="1px solid var(--persona-attachment-file-border, var(--persona-border, #e5e7eb))",o.style.color="inherit",e.appendChild(o),t+=1}),t===0?(e.remove(),null):e}catch{return null}},xa=()=>{let r=document.createElement("div");r.className="persona-flex persona-items-center persona-space-x-1 persona-h-5 persona-mt-2";let e=document.createElement("div");e.className="persona-animate-typing persona-rounded-full persona-h-1.5 persona-w-1.5",e.style.backgroundColor="currentColor",e.style.opacity="0.4",e.style.animationDelay="0ms";let t=document.createElement("div");t.className="persona-animate-typing persona-rounded-full persona-h-1.5 persona-w-1.5",t.style.backgroundColor="currentColor",t.style.opacity="0.4",t.style.animationDelay="250ms";let n=document.createElement("div");n.className="persona-animate-typing persona-rounded-full persona-h-1.5 persona-w-1.5",n.style.backgroundColor="currentColor",n.style.opacity="0.4",n.style.animationDelay="500ms";let o=document.createElement("span");return o.className="persona-sr-only",o.textContent="Loading",r.appendChild(e),r.appendChild(t),r.appendChild(n),r.appendChild(o),r},_p=(r,e,t)=>{let n={config:t!=null?t:{},streaming:!0,location:r,defaultRenderer:xa};if(e){let o=e(n);if(o!==null)return o}return xa()},ov=(r,e)=>{let t=y("div","persona-flex-shrink-0 persona-w-8 persona-h-8 persona-rounded-full persona-flex persona-items-center persona-justify-center persona-text-sm"),n=e==="user"?r.userAvatar:r.assistantAvatar;if(n)if(n.startsWith("http")||n.startsWith("/")||n.startsWith("data:")){let o=y("img");o.src=n,o.alt=e==="user"?"User":"Assistant",o.className="persona-w-full persona-h-full persona-rounded-full persona-object-cover",t.appendChild(o)}else t.textContent=n,t.classList.add(e==="user"?"persona-bg-persona-accent":"persona-bg-persona-primary","persona-text-white");else t.textContent=e==="user"?"U":"A",t.classList.add(e==="user"?"persona-bg-persona-accent":"persona-bg-persona-primary","persona-text-white");return t},ix=(r,e)=>{let t=y("div","persona-text-xs persona-text-persona-muted"),n=new Date(r.createdAt);return e.format?t.textContent=e.format(n):t.textContent=n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),t},av=(r,e="bubble")=>{let t=["persona-message-bubble","persona-max-w-[85%]"];switch(e){case"flat":r==="user"?t.push("persona-message-user-bubble","persona-ml-auto","persona-text-persona-primary","persona-py-2"):t.push("persona-message-assistant-bubble","persona-text-persona-primary","persona-py-2");break;case"minimal":t.push("persona-text-sm","persona-leading-relaxed"),r==="user"?t.push("persona-message-user-bubble","persona-ml-auto","persona-bg-persona-accent","persona-text-white","persona-px-3","persona-py-2","persona-rounded-lg"):t.push("persona-message-assistant-bubble","persona-bg-persona-surface","persona-text-persona-primary","persona-px-3","persona-py-2","persona-rounded-lg");break;default:t.push("persona-rounded-2xl","persona-text-sm","persona-leading-relaxed","persona-shadow-sm"),r==="user"?t.push("persona-message-user-bubble","persona-ml-auto","persona-bg-persona-accent","persona-text-white","persona-px-5","persona-py-3"):t.push("persona-message-assistant-bubble","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-text-persona-primary","persona-px-5","persona-py-3");break}return t},Up=(r,e,t)=>{var m,v,x,S,M,E;let n=(m=e.showCopy)!=null?m:!0,o=(v=e.showUpvote)!=null?v:!0,a=(x=e.showDownvote)!=null?x:!0;if(!n&&!o&&!a){let k=y("div");return k.style.display="none",k.id=`actions-${r.id}`,k.setAttribute("data-actions-for",r.id),k}let s=(S=e.visibility)!=null?S:"hover",i=(M=e.align)!=null?M:"right",d=(E=e.layout)!=null?E:"pill-inside",l={left:"persona-message-actions-left",center:"persona-message-actions-center",right:"persona-message-actions-right"}[i],p={"pill-inside":"persona-message-actions-pill","row-inside":"persona-message-actions-row"}[d],f=y("div",`persona-message-actions persona-flex persona-items-center persona-gap-1 persona-mt-2 ${l} ${p} ${s==="hover"?"persona-message-actions-hover":""}`);f.id=`actions-${r.id}`,f.setAttribute("data-actions-for",r.id);let u=(k,h,w)=>{let C=Dr({icon:k,label:h,size:14,className:"persona-message-action-btn"});return C.setAttribute("data-action",w),C};return n&&f.appendChild(u("copy","Copy message","copy")),o&&f.appendChild(u("thumbs-up","Upvote","upvote")),a&&f.appendChild(u("thumbs-down","Downvote","downvote")),f},ja=(r,e,t,n,o,a)=>{var J,re,Q,ge,Z,G,pe,ke,le,ne,de,Lt,St,We,he,at,Pe;let s=t!=null?t:{},i=(J=s.layout)!=null?J:"bubble",d=s.avatar,l=s.timestamp,p=(re=d==null?void 0:d.show)!=null?re:!1,f=(Q=l==null?void 0:l.show)!=null?Q:!1,u=(ge=d==null?void 0:d.position)!=null?ge:"left",m=(Z=l==null?void 0:l.position)!=null?Z:"below",v=av(r.role,i),x=y("div",v.join(" "));x.id=`bubble-${r.id}`,x.setAttribute("data-message-id",r.id),x.setAttribute("data-persona-theme-zone",r.role==="user"?"user-message":"assistant-message"),r.role==="user"?(x.style.backgroundColor="var(--persona-message-user-bg, var(--persona-accent))",x.style.color="var(--persona-message-user-text, white)"):r.role==="assistant"&&(x.style.backgroundColor="var(--persona-message-assistant-bg, var(--persona-surface))",x.style.color="var(--persona-message-assistant-text, var(--persona-text))");let S=Q0(r),M=(pe=(G=r.content)==null?void 0:G.trim())!=null?pe:"",k=S.length>0&&M===Ki,h=vl((le=(ke=a==null?void 0:a.widgetConfig)==null?void 0:ke.features)==null?void 0:le.streamAnimation),w=(Lt=(de=(ne=a==null?void 0:a.widgetConfig)==null?void 0:ne.features)==null?void 0:de.streamAnimation)==null?void 0:Lt.plugins,C=r.role==="assistant"&&h.type!=="none"?Vs(h.type,w):null,T=r.role==="assistant"&&((St=C==null?void 0:C.isAnimating)==null?void 0:St.call(C,r))===!0,W=r.role==="assistant"&&C!==null&&(!!r.streaming||T);W&&(C!=null&&C.bubbleClass)&&x.classList.add(C.bubbleClass);let R=document.createElement("div");R.classList.add("persona-message-content"),W&&C&&(C.containerClass&&R.classList.add(C.containerClass),R.style.setProperty("--persona-stream-step",`${h.speed}ms`),R.style.setProperty("--persona-stream-duration",`${h.duration}ms`));let I=W?Cl((We=r.content)!=null?We:"",h.buffer,C,r,!!r.streaming):(he=r.content)!=null?he:"",N=e({text:I,message:r,streaming:!!r.streaming,raw:r.rawContent}),V=N;W&&(C==null?void 0:C.wrap)==="char"?V=js(N,"char",r.id,{skipTags:C.skipTags}):W&&(C==null?void 0:C.wrap)==="word"&&(V=js(N,"word",r.id,{skipTags:C.skipTags}));let ie=null;if(k?(ie=document.createElement("div"),ie.innerHTML=V,ie.style.display="none",R.appendChild(ie)):R.innerHTML=V,W&&(C!=null&&C.useCaret)&&!k&&M){let j=wl(),ue=R.querySelectorAll(".persona-stream-char, .persona-stream-word"),nt=ue[ue.length-1];if(nt!=null&&nt.parentNode)nt.parentNode.insertBefore(j,nt.nextSibling);else{let It=R.lastElementChild;It?It.appendChild(j):R.appendChild(j)}}if(f&&m==="inline"&&r.createdAt){let j=ix(r,l);j.classList.add("persona-ml-2","persona-inline"),R.appendChild(j)}if(S.length>0){let j=ev(S,!k&&!!M,()=>{k&&ie&&(ie.style.display="")});j?x.appendChild(j):k&&ie&&(ie.style.display="")}let xe=J0(r);if(xe.length>0){let j=tv(xe);j&&x.appendChild(j)}let Je=Y0(r);if(Je.length>0){let j=rv(Je);j&&x.appendChild(j)}let we=Z0(r);if(we.length>0){let j=nv(we);j&&x.appendChild(j)}if(x.appendChild(R),f&&m==="below"&&r.createdAt){let j=ix(r,l);j.classList.add("persona-mt-1"),x.appendChild(j)}let De=r.role==="assistant"?G0(r.stopReason,(Pe=(at=a==null?void 0:a.widgetConfig)==null?void 0:at.copy)==null?void 0:Pe.stopReasonNotice):null;if(r.streaming&&r.role==="assistant"){let j=!!(I&&I.trim()),ue=h.placeholder==="skeleton",nt=ue&&h.buffer==="line"&&j;if(j)nt&&x.appendChild(Gs());else if(ue)x.appendChild(Gs());else{let It=_p("inline",a==null?void 0:a.loadingIndicatorRenderer,a==null?void 0:a.widgetConfig);It&&x.appendChild(It)}}if(De&&r.stopReason&&!r.streaming&&(M||(R.style.display="none"),x.appendChild(K0(r.stopReason,De))),r.role==="assistant"&&!r.streaming&&r.content&&r.content.trim()&&(n==null?void 0:n.enabled)!==!1&&n){let j=Up(r,n,o);x.appendChild(j)}if(!p||r.role==="system")return x;let qe=y("div",`persona-flex persona-gap-2 ${r.role==="user"?"persona-flex-row-reverse":""}`),Ie=ov(d,r.role);return u==="right"||u==="left"&&r.role==="user"?qe.append(x,Ie):qe.append(Ie,x),x.classList.remove("persona-max-w-[85%]"),x.classList.add("persona-max-w-[calc(85%-2.5rem)]"),qe},dx=(r,e,t,n,o,a)=>{let s=t!=null?t:{};return r.role==="user"&&s.renderUserMessage?s.renderUserMessage({message:r,config:{},streaming:!!r.streaming}):r.role==="assistant"&&s.renderAssistantMessage?s.renderAssistantMessage({message:r,config:{},streaming:!!r.streaming}):ja(r,e,t,n,o,a)};var Ga=new Set,sv=(r,e)=>e==null?!1:typeof e=="string"?(r.textContent=e,!0):(r.appendChild(e),!0),iv=(r,e)=>{var n,o;let t=(o=(n=r.reasoning)==null?void 0:n.chunks.join("").trim())!=null?o:"";return t?t.split(/\r?\n/).map(a=>a.trim()).filter(Boolean).slice(0,e).join(`
|
|
71
|
-
`):""},
|
|
72
|
-
`);let
|
|
73
|
-
`):""},cv=(r,e)=>{var p,f,u,m,v;let t=r.toolCall,n=(p=e==null?void 0:e.features)==null?void 0:p.toolCallDisplay,o=(f=n==null?void 0:n.collapsedMode)!=null?f:"tool-call",a=dv(r,(u=n==null?void 0:n.previewMaxLines)!=null?u:3),s=t?Ch(t):"";if(!t)return{summary:s,previewText:a,isActive:!1};let i=t.status!=="complete",d=(m=e==null?void 0:e.toolCall)!=null?m:{},l=s;return o==="tool-name"?l=((v=t.name)==null?void 0:v.trim())||s:o==="tool-preview"&&a&&(l=a),i&&d.activeTextTemplate?l=Md(t,d.activeTextTemplate,l):!i&&d.completeTextTemplate&&(l=Md(t,d.completeTextTemplate,l)),{summary:l,previewText:a,isActive:i}},px=(r,e,t)=>{var p;let n=Ka.has(r),o=(p=t==null?void 0:t.toolCall)!=null?p:{},a=e.querySelector('button[data-expand-header="true"]'),s=e.querySelector(".persona-border-t"),i=e.querySelector('[data-persona-collapsed-preview="tool"]');if(!a||!s)return;a.setAttribute("aria-expanded",n?"true":"false");let d=a.querySelector(".persona-ml-auto"),l=d==null?void 0:d.querySelector(":scope > .persona-flex.persona-items-center");if(l){l.innerHTML="";let f=o.toggleTextColor||o.headerTextColor||"currentColor",u=Me(n?"chevron-up":"chevron-down",16,f,2);u?l.appendChild(u):l.textContent=n?"Hide":"Show"}s.style.display=n?"":"none",i&&(i.style.display=n?"none":i.textContent||i.childNodes.length?"":"none")},zp=(r,e)=>{var V,ie,xe,Je,we,De,Ae,qe,Ie;let t=r.toolCall,n=(V=e==null?void 0:e.toolCall)!=null?V:{},o=y("div",["persona-message-bubble","persona-tool-bubble","persona-w-full","persona-max-w-[85%]","persona-rounded-2xl","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-text-persona-primary","persona-shadow-sm","persona-overflow-hidden","persona-px-0","persona-py-0"].join(" "));if(o.id=`bubble-${r.id}`,o.setAttribute("data-message-id",r.id),n.backgroundColor&&(o.style.backgroundColor=n.backgroundColor),n.borderColor&&(o.style.borderColor=n.borderColor),n.borderWidth&&(o.style.borderWidth=n.borderWidth),n.borderRadius&&(o.style.borderRadius=n.borderRadius),o.style.boxShadow=n.shadow!==void 0?n.shadow.trim()===""?"none":n.shadow:"var(--persona-tool-bubble-shadow, 0 5px 15px rgba(15, 23, 42, 0.08))",!t)return o;let a=(xe=(ie=e==null?void 0:e.features)==null?void 0:ie.toolCallDisplay)!=null?xe:{},s=a.expandable!==!1,i=s&&Ka.has(r.id),{summary:d,previewText:l,isActive:p}=cv(r,e),f=y("button",s?"persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-pointer persona-border-none":"persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-default persona-border-none");f.type="button",s&&(f.setAttribute("aria-expanded",i?"true":"false"),f.setAttribute("data-expand-header","true")),f.setAttribute("data-bubble-type","tool"),n.headerBackgroundColor&&(f.style.backgroundColor=n.headerBackgroundColor),n.headerPaddingX&&(f.style.paddingLeft=n.headerPaddingX,f.style.paddingRight=n.headerPaddingX),n.headerPaddingY&&(f.style.paddingTop=n.headerPaddingY,f.style.paddingBottom=n.headerPaddingY);let u=y("div","persona-flex persona-flex-col persona-text-left"),m=y("span","persona-text-xs persona-text-persona-primary");n.headerTextColor&&(m.style.color=n.headerTextColor);let v=String((Je=t.startedAt)!=null?Je:Date.now()),x=()=>{let J=y("span","");return J.setAttribute("data-tool-elapsed",v),J.textContent=Ds(t),J},S=(De=n.renderCollapsedSummary)==null?void 0:De.call(n,{message:r,toolCall:t,defaultSummary:d,previewText:l,collapsedMode:(we=a.collapsedMode)!=null?we:"tool-call",isActive:p,config:e!=null?e:{},elapsed:Ds(t),createElapsedElement:x});typeof S=="string"&&S.trim()?(m.textContent=S,u.appendChild(m)):S instanceof HTMLElement?u.appendChild(S):(m.textContent=d,u.appendChild(m));let M=(Ae=a.loadingAnimation)!=null?Ae:"none",E=n.activeTextTemplate,k=n.completeTextTemplate,h=p?E:k,w=S instanceof HTMLElement,C=(J,re,Q)=>{let ge=Q;for(let Z of re){let G=y("span","persona-tool-char");G.style.setProperty("--char-index",String(ge)),G.textContent=Z===" "?"\xA0":Z,J.appendChild(G),ge++}return ge},T=(J,re)=>{var G;m.textContent="";let Q=((G=t.name)==null?void 0:G.trim())||"tool",ge=Ui(J,Q),Z=0;for(let pe of ge){let ke=pe.styles.length>0?(()=>{let le=y("span",pe.styles.map(ne=>`persona-tool-text-${ne}`).join(" "));return m.appendChild(le),le})():m;if(pe.isDuration&&p)ke.appendChild(x());else{let le=pe.isDuration?Ds(t):pe.text;re?Z=C(ke,le,Z):ke.appendChild(document.createTextNode(le))}}};if(!w)if(p&&M!=="none"){let J=(qe=n.loadingAnimationDuration)!=null?qe:2e3;if(m.setAttribute("data-preserve-animation","true"),M==="pulse")m.classList.add("persona-tool-loading-pulse"),m.style.setProperty("--persona-tool-anim-duration",`${J}ms`),h&&T(h,!1);else if(m.classList.add(`persona-tool-loading-${M}`),m.style.setProperty("--persona-tool-anim-duration",`${J}ms`),M==="shimmer-color"&&(n.loadingAnimationColor&&m.style.setProperty("--persona-tool-anim-color",n.loadingAnimationColor),n.loadingAnimationSecondaryColor&&m.style.setProperty("--persona-tool-anim-secondary-color",n.loadingAnimationSecondaryColor)),h)T(h,!0);else{let re=m.textContent||d;m.textContent="",C(m,re,0)}}else h&&T(h,!1);let W=null;if(s){W=y("div","persona-flex persona-items-center");let J=n.toggleTextColor||n.headerTextColor||"currentColor",re=Me(i?"chevron-up":"chevron-down",16,J,2);re?W.appendChild(re):W.textContent=i?"Hide":"Show";let Q=y("div","persona-flex persona-items-center persona-gap-2 persona-ml-auto");Q.append(W),f.append(u,Q)}else f.append(u);let R=y("div","persona-px-4 persona-py-3 persona-text-xs persona-leading-snug persona-text-persona-muted");if(R.setAttribute("data-persona-collapsed-preview","tool"),R.style.display="none",R.style.whiteSpace="pre-wrap",!i&&p&&a.activePreview&&l){let J=(Ie=n.renderCollapsedPreview)==null?void 0:Ie.call(n,{message:r,toolCall:t,defaultPreview:l,isActive:p,config:e!=null?e:{}});lv(R,J)||(R.textContent=l),R.style.display=""}if(!i&&p&&a.activeMinHeight&&(o.style.minHeight=a.activeMinHeight),!s)return o.append(f,R),o;let I=y("div","persona-border-t persona-border-gray-200 persona-bg-gray-50 persona-space-y-3 persona-px-4 persona-py-3");if(I.style.display=i?"":"none",n.contentBackgroundColor&&(I.style.backgroundColor=n.contentBackgroundColor),n.contentTextColor&&(I.style.color=n.contentTextColor),n.contentPaddingX&&(I.style.paddingLeft=n.contentPaddingX,I.style.paddingRight=n.contentPaddingX),n.contentPaddingY&&(I.style.paddingTop=n.contentPaddingY,I.style.paddingBottom=n.contentPaddingY),t.name){let J=y("div","persona-text-xs persona-text-persona-muted persona-italic");n.contentTextColor?J.style.color=n.contentTextColor:n.headerTextColor&&(J.style.color=n.headerTextColor),J.textContent=t.name,I.appendChild(J)}if(t.args!==void 0){let J=y("div","persona-space-y-1"),re=y("div","persona-text-xs persona-text-persona-muted");n.labelTextColor&&(re.style.color=n.labelTextColor),re.textContent="Arguments";let Q=y("pre","persona-max-h-48 persona-overflow-auto persona-whitespace-pre-wrap persona-rounded-lg persona-border persona-border-gray-100 persona-bg-white persona-px-3 persona-py-2 persona-text-xs persona-text-persona-primary");Q.style.fontSize="0.75rem",Q.style.lineHeight="1rem",n.codeBlockBackgroundColor&&(Q.style.backgroundColor=n.codeBlockBackgroundColor),n.codeBlockBorderColor&&(Q.style.borderColor=n.codeBlockBorderColor),n.codeBlockTextColor&&(Q.style.color=n.codeBlockTextColor),Q.textContent=Na(t.args),J.append(re,Q),I.appendChild(J)}if(t.chunks&&t.chunks.length){let J=y("div","persona-space-y-1"),re=y("div","persona-text-xs persona-text-persona-muted");n.labelTextColor&&(re.style.color=n.labelTextColor),re.textContent="Activity";let Q=y("pre","persona-max-h-48 persona-overflow-auto persona-whitespace-pre-wrap persona-rounded-lg persona-border persona-border-gray-100 persona-bg-white persona-px-3 persona-py-2 persona-text-xs persona-text-persona-primary");Q.style.fontSize="0.75rem",Q.style.lineHeight="1rem",n.codeBlockBackgroundColor&&(Q.style.backgroundColor=n.codeBlockBackgroundColor),n.codeBlockBorderColor&&(Q.style.borderColor=n.codeBlockBorderColor),n.codeBlockTextColor&&(Q.style.color=n.codeBlockTextColor),Q.textContent=t.chunks.join(""),J.append(re,Q),I.appendChild(J)}if(t.status==="complete"&&t.result!==void 0){let J=y("div","persona-space-y-1"),re=y("div","persona-text-xs persona-text-persona-muted");n.labelTextColor&&(re.style.color=n.labelTextColor),re.textContent="Result";let Q=y("pre","persona-max-h-48 persona-overflow-auto persona-whitespace-pre-wrap persona-rounded-lg persona-border persona-border-gray-100 persona-bg-white persona-px-3 persona-py-2 persona-text-xs persona-text-persona-primary");Q.style.fontSize="0.75rem",Q.style.lineHeight="1rem",n.codeBlockBackgroundColor&&(Q.style.backgroundColor=n.codeBlockBackgroundColor),n.codeBlockBorderColor&&(Q.style.borderColor=n.codeBlockBorderColor),n.codeBlockTextColor&&(Q.style.color=n.codeBlockTextColor),Q.textContent=Na(t.result),J.append(re,Q),I.appendChild(J)}if(t.status==="complete"&&typeof t.duration=="number"){let J=y("div","persona-text-xs persona-text-persona-muted");n.contentTextColor&&(J.style.color=n.contentTextColor),J.textContent=`Duration: ${t.duration}ms`,I.appendChild(J)}return(()=>{if(f.setAttribute("aria-expanded",i?"true":"false"),W){W.innerHTML="";let J=n.toggleTextColor||n.headerTextColor||"currentColor",re=Me(i?"chevron-up":"chevron-down",16,J,2);re?W.appendChild(re):W.textContent=i?"Hide":"Show"}I.style.display=i?"":"none",R.style.display=i?"none":R.textContent||R.childNodes.length?"":"none"})(),o.append(f,R,I),o};var Uo=Ai(Fi(),1);var Vp="ask_user_question",$p=8,Xa="data-persona-ask-sheet-for",pv="Other",uv="Other\u2026",fx="Type your own answer here",mx="Send",fv="Next",mv="Back",gv="Submit all",hv="Skip",xv=3,jp="data-ask-current-index",Gp="data-ask-question-count",gx="data-ask-answers",Kp="data-ask-grouped",hx="data-ask-layout",bv=r=>r.layout==="pills"?"pills":"rows",yv=r=>r.getAttribute(hx)==="pills"?"pills":"rows",ux=!1,xx=r=>r.replace(/["\\]/g,"\\$&"),yo=r=>r.variant==="tool"&&!!r.toolCall&&r.toolCall.name===Vp,Hl=r=>{var e,t;return(t=(e=r==null?void 0:r.features)==null?void 0:e.askUserQuestion)!=null?t:{}},vo=r=>{let e=r.toolCall;if(!e)return{payload:null,complete:!1};let t=e.status==="complete";if(e.args&&typeof e.args=="object")return{payload:e.args,complete:t};let n=e.chunks;if(!n||n.length===0)return{payload:null,complete:t};try{let o=n.join(""),a=(0,Uo.parse)(o,Uo.STR|Uo.OBJ|Uo.ARR);if(a&&typeof a=="object")return{payload:a,complete:t}}catch{}return{payload:null,complete:t}},Js=r=>{let e=Array.isArray(r==null?void 0:r.questions)?r.questions:[];return e.length>$p&&!ux&&(ux=!0,typeof console!="undefined"&&console.warn(`[AgentWidget] ask_user_question received ${e.length} questions; truncating to ${$p}.`)),e.slice(0,$p)},vv=r=>{var e;return(e=Js(r)[0])!=null?e:null},Cv=(r,e)=>{var t;return(t=Js(r)[e])!=null?t:null},bx=(r,e)=>{let t=e.styles;t&&(t.sheetBackground&&r.style.setProperty("--persona-ask-sheet-bg",t.sheetBackground),t.sheetBorder&&r.style.setProperty("--persona-ask-sheet-border",t.sheetBorder),t.sheetShadow&&r.style.setProperty("--persona-ask-sheet-shadow",t.sheetShadow),t.pillBackground&&r.style.setProperty("--persona-ask-pill-bg",t.pillBackground),t.pillBackgroundSelected&&r.style.setProperty("--persona-ask-pill-bg-selected",t.pillBackgroundSelected),t.pillTextColor&&r.style.setProperty("--persona-ask-pill-fg",t.pillTextColor),t.pillTextColorSelected&&r.style.setProperty("--persona-ask-pill-fg-selected",t.pillTextColorSelected),t.pillBorderRadius&&r.style.setProperty("--persona-ask-pill-radius",t.pillBorderRadius),t.customInputBackground&&r.style.setProperty("--persona-ask-input-bg",t.customInputBackground))},yx=(r,e,t)=>{if(r!=="rows")return null;let n=y("span","persona-ask-row-affordance");if(n.setAttribute("aria-hidden","true"),e){let o=y("span","persona-ask-row-check");n.appendChild(o)}else{let o=y("span","persona-ask-row-badge");o.textContent=String(t+1),n.appendChild(o)}return n},wv=(r,e,t,n)=>{let a=y("button",t==="rows"?"persona-ask-pill persona-ask-row persona-pointer-events-auto":"persona-ask-pill persona-pointer-events-auto");if(a.type="button",a.setAttribute("role",n?"checkbox":"button"),a.setAttribute("aria-pressed","false"),a.setAttribute("data-ask-user-action","pick"),a.setAttribute("data-option-index",String(e)),a.setAttribute("data-option-label",r.label),t==="rows"){let s=y("span","persona-ask-row-content"),i=y("span","persona-ask-row-label");if(i.textContent=r.label,s.appendChild(i),r.description){let l=y("span","persona-ask-row-description");l.textContent=r.description,s.appendChild(l)}a.appendChild(s);let d=yx(t,n,e);d&&a.appendChild(d)}else a.textContent=r.label,r.description&&(a.title=r.description);return a},Av=r=>{let t=y("span",r==="rows"?"persona-ask-pill persona-ask-row persona-ask-pill-skeleton persona-pointer-events-none":"persona-ask-pill persona-ask-pill-skeleton persona-pointer-events-none");return t.setAttribute("aria-hidden","true"),t},Sv=(r,e,t,n)=>{var p,f,u;let a=y("div",n==="rows"?"persona-ask-pills persona-ask-pills--rows persona-flex persona-flex-col persona-gap-2":"persona-ask-pills persona-flex persona-flex-wrap persona-gap-2");a.setAttribute("role","group"),a.setAttribute("data-ask-pill-list","true");let s=!!(r!=null&&r.multiSelect),d=(Array.isArray(r==null?void 0:r.options)?r.options:[]).filter(m=>m&&typeof m.label=="string"&&m.label.length>0);if(d.length===0&&!t){for(let m=0;m<xv;m++)a.appendChild(Av(n));return a}if(d.forEach((m,v)=>{a.appendChild(wv(m,v,n,s))}),(r==null?void 0:r.allowFreeText)!==!1){let m=n==="rows"?pv:uv;if(n==="rows"){let v=y("div","persona-ask-pill persona-ask-row persona-ask-row--other persona-ask-pill-custom persona-pointer-events-auto");v.setAttribute("data-ask-user-action","focus-free-text"),v.setAttribute("data-option-index",String(d.length)),v.setAttribute("data-ask-other-row","true");let x=y("span","persona-ask-row-content"),S=document.createElement("input");S.type="text",S.className="persona-ask-row-input persona-flex-1 persona-pointer-events-auto",S.placeholder=(p=e.freeTextPlaceholder)!=null?p:fx,S.setAttribute("data-ask-free-text-input","true"),S.setAttribute("aria-label",(f=e.freeTextLabel)!=null?f:m),x.appendChild(S),v.appendChild(x);let M=yx(n,s,d.length);M&&v.appendChild(M),a.appendChild(v)}else{let v=y("button","persona-ask-pill persona-ask-pill-custom persona-pointer-events-auto");v.type="button",v.setAttribute("data-ask-user-action","open-free-text"),v.textContent=(u=e.freeTextLabel)!=null?u:m,a.appendChild(v)}}return a},vx=(r,e)=>{var a,s;let n=y("div",e==="rows"?"persona-ask-free-text persona-ask-free-text--rows persona-flex persona-gap-2 persona-mt-2":"persona-ask-free-text persona-hidden persona-flex persona-gap-2 persona-mt-2");n.setAttribute("data-ask-free-text-row","true");let o=document.createElement("input");if(o.type="text",o.className="persona-ask-free-text-input persona-flex-1 persona-pointer-events-auto",o.placeholder=(a=r.freeTextPlaceholder)!=null?a:fx,o.setAttribute("data-ask-free-text-input","true"),n.appendChild(o),e!=="rows"){let i=y("button","persona-ask-free-text-submit persona-pointer-events-auto");i.type="button",i.textContent=(s=r.submitLabel)!=null?s:mx,i.setAttribute("data-ask-user-action","submit-free-text"),n.appendChild(i)}return n},Tv=r=>{var n;let e=y("div","persona-ask-multi-actions persona-flex persona-justify-end persona-mt-2");e.setAttribute("data-ask-multi-actions","true");let t=y("button","persona-ask-multi-submit persona-pointer-events-auto");return t.type="button",t.textContent=(n=r.submitLabel)!=null?n:mx,t.setAttribute("data-ask-user-action","submit-multi"),t.disabled=!0,e.appendChild(t),e},Mv=(r,e,t)=>{var l,p,f,u;let n=y("div","persona-ask-nav persona-flex persona-justify-between persona-items-center persona-gap-2 persona-mt-2");n.setAttribute("data-ask-nav-row","true");let o=y("button","persona-ask-nav-back persona-pointer-events-auto");o.type="button",o.textContent=(l=t.backLabel)!=null?l:mv,o.setAttribute("data-ask-user-action","back"),o.disabled=r===0,n.appendChild(o);let a=y("div","persona-ask-nav-right persona-flex persona-items-center persona-gap-2"),s=y("button","persona-ask-nav-skip persona-pointer-events-auto");s.type="button",s.textContent=(p=t.skipLabel)!=null?p:hv,s.setAttribute("data-ask-user-action","skip"),a.appendChild(s);let i=y("button","persona-ask-nav-next persona-pointer-events-auto");i.type="button";let d=r===e-1;return i.textContent=d?(f=t.submitAllLabel)!=null?f:gv:(u=t.nextLabel)!=null?u:fv,i.setAttribute("data-ask-user-action",d?"submit-all":"next"),i.disabled=!0,a.appendChild(i),n.appendChild(a),n},ba=r=>{let e=r.getAttribute(gx);if(!e)return{};try{let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}},Cx=(r,e)=>{r.setAttribute(gx,JSON.stringify(e))},Bn=r=>{var t;let e=Number((t=r.getAttribute(jp))!=null?t:"0");return Number.isFinite(e)?Math.max(0,Math.floor(e)):0},kv=(r,e)=>{r.setAttribute(jp,String(Math.max(0,Math.floor(e))))},Qa=r=>{var t;let e=Number((t=r.getAttribute(Gp))!=null?t:"1");return Number.isFinite(e)?Math.max(1,Math.floor(e)):1},qo=r=>r.getAttribute(Kp)==="true",Ev=(r,e)=>{var o;let t=(o=r.agentMetadata)==null?void 0:o.askUserQuestionAnswers;if(!t||typeof t!="object")return{};let n={};return e.forEach((a,s)=>{let i=typeof(a==null?void 0:a.question)=="string"?a.question:"";if(i&&Object.prototype.hasOwnProperty.call(t,i)){let d=t[i];(typeof d=="string"||Array.isArray(d))&&(n[s]=d)}}),n},Lv=(r,e)=>{var n;let t=(n=r.agentMetadata)==null?void 0:n.askUserQuestionIndex;return typeof t!="number"||!Number.isFinite(t)?0:Math.max(0,Math.min(e-1,Math.floor(t)))},Bl=(r,e)=>{let{payload:t}=vo(e),n=Js(t),o=ba(r),a={},s=new Set;return n.forEach((i,d)=>{let l=typeof(i==null?void 0:i.question)=="string"?i.question:"";l&&(s.has(l)&&typeof console!="undefined"&&console.warn(`[AgentWidget] ask_user_question has duplicate question text "${l}"; later answer wins.`),s.add(l),Object.prototype.hasOwnProperty.call(o,d)&&(a[l]=o[d]))}),a},wx=r=>{let e=ba(r),t=Bn(r),n=e[t],o=new Set;typeof n=="string"?o.add(n):Array.isArray(n)&&n.forEach(d=>o.add(d));let a=r.querySelectorAll('[data-ask-user-action="pick"][data-option-label]');a.forEach(d=>{var f;let l=(f=d.getAttribute("data-option-label"))!=null?f:"",p=o.has(l);d.setAttribute("aria-pressed",p?"true":"false"),d.classList.toggle("persona-ask-pill-selected",p)});let s=new Set(Array.from(a).map(d=>{var l;return(l=d.getAttribute("data-option-label"))!=null?l:""})),i=r.querySelector('[data-ask-free-text-input="true"]');if(i)if(typeof n=="string"&&n.length>0&&!s.has(n)){i.value=n;let d=i.closest('[data-ask-free-text-row="true"]');d==null||d.classList.remove("persona-hidden")}else i.value=""},Ax=r=>{if(!qo(r))return;let e=ba(r),t=Bn(r),n=e[t],o=typeof n=="string"&&n.length>0||Array.isArray(n)&&n.length>0,a=r.querySelector('[data-ask-user-action="next"], [data-ask-user-action="submit-all"]');a&&(a.disabled=!o);let s=r.querySelector('[data-ask-user-action="submit-multi"]');if(s){let i=Array.from(r.querySelectorAll('[aria-pressed="true"][data-option-label]'));s.disabled=i.length===0}},Xp=(r,e,t)=>{let n=Hl(t),o=yv(r),{payload:a,complete:s}=vo(e),i=qo(r),d=Bn(r),l=Qa(r),p=i?Cv(a,d):vv(a),f=!!(p!=null&&p.multiSelect),u=r.querySelector('[data-ask-step-inline="true"]');u&&(u.textContent=i?`${d+1}/${l}`:"");let m=r.querySelector('[data-ask-stepper="true"]');m&&m.remove();let v=r.querySelector('[data-ask-question="true"]');if(v){let E=typeof(p==null?void 0:p.question)=="string"?p.question:"";v.textContent=E,v.classList.toggle("persona-ask-question-skeleton",!E&&!s)}let x=r.querySelector('[data-ask-pill-list="true"]');if(x){let E=Sv(p,n,s,o);x.replaceWith(E)}if(o!=="rows"){let E=r.querySelector('[data-ask-free-text-row="true"]');E&&E.replaceWith(vx(n,o))}let S=r.querySelector('[data-ask-multi-actions="true"]');!i&&f&&!S?r.appendChild(Tv(n)):(!f||i)&&S&&S.remove(),r.setAttribute("data-multi-select",f?"true":"false");let M=r.querySelector('[data-ask-nav-row="true"]');if(i){let E=Mv(d,l,n);M?M.replaceWith(E):r.appendChild(E)}else M&&M.remove();wx(r),Ax(r)},Pv=(r,e,t)=>{let n=Hl(e),o=bv(n),a=r.toolCall.id,s=Js(t),i=Math.max(1,s.length),d=i>1,l=Ev(r,s),p=d?Lv(r,i):0,f=y("div",["persona-ask-sheet",`persona-ask-sheet--${o}`,"persona-pointer-events-auto","persona-ask-sheet-enter"].join(" "));f.setAttribute(Xa,a),f.setAttribute("data-tool-call-id",a),f.setAttribute("data-message-id",r.id),f.setAttribute(Gp,String(i)),f.setAttribute(jp,String(p)),f.setAttribute(Kp,d?"true":"false"),f.setAttribute(hx,o),Cx(f,l),f.setAttribute("role","group"),f.setAttribute("aria-label","Suggested answers"),n.slideInMs!==void 0&&f.style.setProperty("--persona-ask-sheet-duration",`${n.slideInMs}ms`),bx(f,n);let u=y("div","persona-ask-sheet-header persona-flex persona-items-center persona-gap-3"),m=y("div","persona-ask-sheet-question persona-flex-1");m.setAttribute("data-ask-question","true"),m.textContent="",u.appendChild(m);let v=y("span","persona-ask-sheet-step-inline");v.setAttribute("data-ask-step-inline","true"),v.textContent="",u.appendChild(v),f.appendChild(u);let S=y("div",o==="rows"?"persona-ask-pills persona-ask-pills--rows persona-flex persona-flex-col persona-gap-2":"persona-ask-pills persona-flex persona-flex-wrap persona-gap-2");return S.setAttribute("data-ask-pill-list","true"),S.setAttribute("role","group"),f.appendChild(S),o!=="rows"&&f.appendChild(vx(n,o)),Xp(f,r,e),requestAnimationFrame(()=>{requestAnimationFrame(()=>f.classList.remove("persona-ask-sheet-enter"))}),f},Rv=(r,e,t)=>{let{payload:n}=vo(e),o=Math.max(1,Js(n).length);o>Qa(r)&&(r.setAttribute(Gp,String(o)),o>1&&!qo(r)&&r.setAttribute(Kp,"true")),Xp(r,e,t)},Sx=(r,e)=>{let t=y("div","persona-ask-stub persona-inline-flex persona-items-center persona-gap-2");t.id=`bubble-${r.id}`,t.setAttribute("data-message-id",r.id),t.setAttribute("data-bubble-type","ask-user-question");let n=Hl(e);bx(t,n);let o=y("span","persona-ask-stub-label"),{complete:a}=vo(r);return o.textContent=a?"Awaiting your response\u2026":"Preparing options\u2026",t.appendChild(o),t},Ja=(r,e,t)=>{if(!t||!yo(r)||Hl(e).enabled===!1)return;let o=r.toolCall.id;t.querySelectorAll(`[${Xa}]`).forEach(l=>{l.getAttribute(Xa)!==o&&l.remove()});let s=t.querySelector(`[${Xa}="${xx(o)}"]`);if(s){Rv(s,r,e);return}let{payload:i}=vo(r),d=Pv(r,e,i);t.appendChild(d)},zo=(r,e)=>{if(!r)return;let t=e?`[${Xa}="${xx(e)}"]`:`[${Xa}]`;r.querySelectorAll(t).forEach(o=>{o.classList.add("persona-ask-sheet-leave");let a=Number.parseInt(getComputedStyle(o).getPropertyValue("--persona-ask-sheet-duration")||"180",10);setTimeout(()=>o.remove(),Number.isFinite(a)?a:180)})},Qp=r=>Array.from(r.querySelectorAll('[aria-pressed="true"][data-option-label]')).map(e=>e.getAttribute("data-option-label")).filter(e=>typeof e=="string"&&e.length>0),$o=(r,e)=>{let t=ba(r),n=Bn(r);typeof e=="string"&&e.length===0||Array.isArray(e)&&e.length===0?delete t[n]:t[n]=e,Cx(r,t),wx(r),Ax(r)},Dl=(r,e,t,n)=>{let o=Qa(r),a=Math.max(0,Math.min(o-1,n));kv(r,a),Xp(r,e,t)};var Fl=new Map,Iv=r=>{let t=(r.startsWith(mo)?r.slice(mo.length):r).replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[_\-\s.]+/).filter(Boolean);if(t.length===0)return r;let n=t.join(" ").toLowerCase();return n.charAt(0).toUpperCase()+n.slice(1)},Tx=r=>(r==null?void 0:r.approval)!==!1?r==null?void 0:r.approval:void 0,Mx=(r,e)=>{var n,o,a;let t=(o=(n=Tx(e))==null?void 0:n.detailsDisplay)!=null?o:"collapsed";return(a=Fl.get(r))!=null?a:t==="expanded"},kx=(r,e,t)=>{var s,i;let n=Tx(t);r.setAttribute("aria-expanded",e?"true":"false");let o=r.querySelector("[data-approval-details-label]");o&&(o.textContent=e?(s=n==null?void 0:n.hideDetailsLabel)!=null?s:"Hide details":(i=n==null?void 0:n.showDetailsLabel)!=null?i:"Show details");let a=r.querySelector("[data-approval-details-chevron]");if(a){a.innerHTML="";let d=Me(e?"chevron-up":"chevron-down",14,"currentColor",2);d&&a.appendChild(d)}},Ex=(r,e,t)=>{let n=e.querySelector('button[data-bubble-type="approval"]'),o=e.querySelector("[data-approval-details]");if(!n||!o)return;let a=Mx(r,t);kx(n,a,t),o.style.display=a?"":"none"};var Nl=(r,e)=>{var T,W,R,I,N,V,ie,xe,Je,we,De,Ae,qe,Ie,J;let t=r.approval,n=(e==null?void 0:e.approval)!==!1?e==null?void 0:e.approval:void 0,o=(t==null?void 0:t.status)==="pending",a=y("div",["persona-approval-bubble","persona-w-full","persona-max-w-[85%]","persona-rounded-2xl","persona-border","persona-shadow-sm","persona-overflow-hidden"].join(" "));if(a.id=`bubble-${r.id}`,a.setAttribute("data-message-id",r.id),a.style.backgroundColor=(T=n==null?void 0:n.backgroundColor)!=null?T:"var(--persona-approval-bg, #fefce8)",a.style.borderColor=(W=n==null?void 0:n.borderColor)!=null?W:"var(--persona-approval-border, #fef08a)",a.style.boxShadow=(n==null?void 0:n.shadow)!==void 0?n.shadow.trim()===""?"none":n.shadow:"var(--persona-approval-shadow, 0 5px 15px rgba(15, 23, 42, 0.08))",!t)return a;let s=y("div","persona-flex persona-items-start persona-gap-3 persona-px-4 persona-py-3"),i=y("div","persona-flex-shrink-0 persona-mt-0.5");i.setAttribute("data-approval-icon","true");let d=t.status==="denied"?"shield-x":t.status==="timeout"?"shield-alert":"shield-check",l=t.status==="approved"?"var(--persona-feedback-success, #16a34a)":t.status==="denied"?"var(--persona-feedback-error, #dc2626)":t.status==="timeout"?"var(--persona-feedback-warning, #ca8a04)":(R=n==null?void 0:n.titleColor)!=null?R:"currentColor",p=Me(d,20,l,2);p&&i.appendChild(p);let f=y("div","persona-flex-1 persona-min-w-0"),u=y("div","persona-flex persona-items-center persona-gap-2"),m=y("span","persona-text-sm persona-font-medium persona-text-persona-primary");if(n!=null&&n.titleColor&&(m.style.color=n.titleColor),m.textContent=(I=n==null?void 0:n.title)!=null?I:"Approval Required",u.appendChild(m),!o){let re=y("span","persona-inline-flex persona-items-center persona-px-2 persona-py-0.5 persona-rounded-full persona-text-xs persona-font-medium");re.setAttribute("data-approval-status",t.status),t.status==="approved"?(re.style.backgroundColor="var(--persona-palette-colors-success-100, #dcfce7)",re.style.color="var(--persona-palette-colors-success-700, #15803d)",re.textContent="Approved"):t.status==="denied"?(re.style.backgroundColor="var(--persona-palette-colors-error-100, #fee2e2)",re.style.color="var(--persona-palette-colors-error-700, #b91c1c)",re.textContent="Denied"):t.status==="timeout"&&(re.style.backgroundColor="var(--persona-palette-colors-warning-100, #fef3c7)",re.style.color="var(--persona-palette-colors-warning-700, #b45309)",re.textContent="Timeout"),u.appendChild(re)}f.appendChild(u);let x=t.toolType==="webmcp"||t.toolName.startsWith(mo)?Sd(t.toolName):void 0,S=(N=n==null?void 0:n.formatDescription)==null?void 0:N.call(n,{toolName:t.toolName,toolType:t.toolType,description:t.description,parameters:t.parameters,...x?{displayTitle:x}:{},...t.reason?{reason:t.reason}:{}}),M=!t.toolName,E=S||(M?t.description:`The assistant wants to use \u201C${x!=null?x:Iv(t.toolName)}\u201D.`),k=y("p","persona-text-sm persona-mt-0.5 persona-text-persona-muted");if(k.setAttribute("data-approval-summary","true"),n!=null&&n.descriptionColor&&(k.style.color=n.descriptionColor),k.textContent=E,f.appendChild(k),t.reason){let re=y("p","persona-text-sm persona-mt-1 persona-text-persona-muted");re.setAttribute("data-approval-reason","true"),n!=null&&n.reasonColor?re.style.color=n.reasonColor:n!=null&&n.descriptionColor&&(re.style.color=n.descriptionColor);let Q=y("span","persona-font-medium");Q.textContent=`${(V=n==null?void 0:n.reasonLabel)!=null?V:"Agent's stated reason:"} `,re.appendChild(Q),re.appendChild(document.createTextNode(t.reason)),f.appendChild(re)}let h=(ie=n==null?void 0:n.detailsDisplay)!=null?ie:"collapsed",w=!!t.description&&!M,C=w||!!t.parameters;if(h!=="hidden"&&C){let re=Mx(r.id,e),Q=y("button","persona-inline-flex persona-items-center persona-gap-1 persona-mt-1 persona-p-0 persona-border-none persona-bg-transparent persona-text-xs persona-font-medium persona-cursor-pointer persona-text-persona-muted");Q.type="button",Q.setAttribute("data-expand-header","true"),Q.setAttribute("data-bubble-type","approval"),n!=null&&n.descriptionColor&&(Q.style.color=n.descriptionColor);let ge=y("span");ge.setAttribute("data-approval-details-label","true");let Z=y("span","persona-inline-flex persona-items-center");Z.setAttribute("data-approval-details-chevron","true"),Q.append(ge,Z),kx(Q,re,e),f.appendChild(Q);let G=y("div");if(G.setAttribute("data-approval-details","true"),G.style.display=re?"":"none",w){let pe=y("p","persona-text-sm persona-mt-1 persona-text-persona-muted");n!=null&&n.descriptionColor&&(pe.style.color=n.descriptionColor),pe.textContent=t.description,G.appendChild(pe)}if(t.parameters){let pe=y("pre","persona-mt-2 persona-text-xs persona-p-2 persona-rounded persona-overflow-x-auto persona-max-h-32 persona-bg-persona-container persona-text-persona-primary");n!=null&&n.parameterBackgroundColor&&(pe.style.backgroundColor=n.parameterBackgroundColor),n!=null&&n.parameterTextColor&&(pe.style.color=n.parameterTextColor),pe.style.fontSize="0.75rem",pe.style.lineHeight="1rem",pe.textContent=Na(t.parameters),G.appendChild(pe)}f.appendChild(G)}if(o){let re=y("div","persona-flex persona-gap-2 persona-mt-2");re.setAttribute("data-approval-buttons","true");let Q=y("button","persona-inline-flex persona-items-center persona-px-3 persona-py-1.5 persona-rounded-md persona-text-xs persona-font-medium persona-border-none persona-cursor-pointer");Q.type="button",Q.style.backgroundColor=(xe=n==null?void 0:n.approveButtonColor)!=null?xe:"var(--persona-approval-approve-bg, #22c55e)",Q.style.color=(Je=n==null?void 0:n.approveButtonTextColor)!=null?Je:"#ffffff",Q.setAttribute("data-approval-action","approve");let ge=Me("shield-check",14,(we=n==null?void 0:n.approveButtonTextColor)!=null?we:"#ffffff",2);ge&&(ge.style.marginRight="4px",Q.appendChild(ge));let Z=document.createTextNode((De=n==null?void 0:n.approveLabel)!=null?De:"Approve");Q.appendChild(Z);let G=y("button","persona-inline-flex persona-items-center persona-px-3 persona-py-1.5 persona-rounded-md persona-text-xs persona-font-medium persona-cursor-pointer");G.type="button",G.style.backgroundColor=(Ae=n==null?void 0:n.denyButtonColor)!=null?Ae:"transparent",G.style.color=(qe=n==null?void 0:n.denyButtonTextColor)!=null?qe:"var(--persona-feedback-error, #dc2626)",G.style.border=`1px solid ${n!=null&&n.denyButtonTextColor?n.denyButtonTextColor:"var(--persona-palette-colors-error-200, #fca5a5)"}`,G.setAttribute("data-approval-action","deny");let pe=Me("shield-x",14,(Ie=n==null?void 0:n.denyButtonTextColor)!=null?Ie:"var(--persona-feedback-error, #dc2626)",2);pe&&(pe.style.marginRight="4px",G.appendChild(pe));let ke=document.createTextNode((J=n==null?void 0:n.denyLabel)!=null?J:"Deny");G.appendChild(ke),re.append(Q,G),f.appendChild(re)}return s.append(i,f),a.appendChild(s),a};var Lx=r=>{let e=[];return{buttons:e,render:(n,o,a,s,i)=>{if(r.innerHTML="",e.length=0,!n||!n.length||(s!=null?s:o?o.getMessages():[]).some(m=>m.role==="user"))return;let p=document.createDocumentFragment(),f=o?o.isStreaming():!1,u=m=>{switch(m){case"serif":return'Georgia, "Times New Roman", Times, serif';case"mono":return'"Courier New", Courier, "Lucida Console", Monaco, monospace';default:return'-apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif'}};n.forEach(m=>{let v=y("button","persona-rounded-button persona-bg-persona-surface persona-px-3 persona-py-1.5 persona-text-xs persona-font-medium persona-text-persona-primary hover:persona-opacity-80 persona-cursor-pointer persona-border persona-border-persona-border");v.type="button",v.textContent=m,v.disabled=f,i!=null&&i.fontFamily&&(v.style.fontFamily=u(i.fontFamily)),i!=null&&i.fontWeight&&(v.style.fontWeight=i.fontWeight),i!=null&&i.paddingX&&(v.style.paddingLeft=i.paddingX,v.style.paddingRight=i.paddingX),i!=null&&i.paddingY&&(v.style.paddingTop=i.paddingY,v.style.paddingBottom=i.paddingY),v.addEventListener("click",()=>{!o||o.isStreaming()||(a.value="",o.sendMessage(m))}),p.appendChild(v),e.push(v)}),r.appendChild(p)}}};var Ys=class{constructor(e=2e3,t=null){this.head=0;this.count=0;this.totalCaptured=0;this.eventTypesSet=new Set;this.maxSize=e,this.buffer=new Array(e),this.store=t}push(e){var t;this.buffer[this.head]=e,this.head=(this.head+1)%this.maxSize,this.count<this.maxSize&&this.count++,this.totalCaptured++,this.eventTypesSet.add(e.type),(t=this.store)==null||t.put(e)}getAll(){return this.count===0?[]:this.count<this.maxSize?this.buffer.slice(0,this.count):[...this.buffer.slice(this.head,this.maxSize),...this.buffer.slice(0,this.head)]}async restore(){if(!this.store)return 0;let e=await this.store.getAll();if(e.length===0)return 0;let t=e.length>this.maxSize?e.slice(e.length-this.maxSize):e;for(let n of t)this.buffer[this.head]=n,this.head=(this.head+1)%this.maxSize,this.count<this.maxSize&&this.count++,this.eventTypesSet.add(n.type);return this.totalCaptured=e.length,t.length}getAllFromStore(){return this.store?this.store.getAll():Promise.resolve(this.getAll())}getRecent(e){let t=this.getAll();return e>=t.length?t:t.slice(t.length-e)}getSize(){return this.count}getTotalCaptured(){return this.totalCaptured}getEvictedCount(){return this.totalCaptured-this.count}clear(){var e;this.buffer=new Array(this.maxSize),this.head=0,this.count=0,this.totalCaptured=0,this.eventTypesSet.clear(),(e=this.store)==null||e.clear()}destroy(){var e;this.buffer=[],this.head=0,this.count=0,this.totalCaptured=0,this.eventTypesSet.clear(),(e=this.store)==null||e.destroy()}getEventTypes(){return Array.from(this.eventTypesSet)}};var Zs=class{constructor(e="persona-event-stream",t="events"){this.db=null;this.pendingWrites=[];this.flushScheduled=!1;this.isDestroyed=!1;this.dbName=e,this.storeName=t}open(){return new Promise((e,t)=>{try{let n=indexedDB.open(this.dbName,1);n.onupgradeneeded=()=>{let o=n.result;o.objectStoreNames.contains(this.storeName)||o.createObjectStore(this.storeName,{keyPath:"id"}).createIndex("timestamp","timestamp",{unique:!1})},n.onsuccess=()=>{this.db=n.result,e()},n.onerror=()=>{t(n.error)}}catch(n){t(n)}})}put(e){!this.db||this.isDestroyed||(this.pendingWrites.push(e),this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushWrites())))}putBatch(e){if(!(!this.db||this.isDestroyed||e.length===0))try{let n=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName);for(let o of e)n.put(o)}catch{}}getAll(){return new Promise((e,t)=>{if(!this.db){e([]);return}try{let s=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName).index("timestamp").getAll();s.onsuccess=()=>{e(s.result)},s.onerror=()=>{t(s.error)}}catch(n){t(n)}})}getCount(){return new Promise((e,t)=>{if(!this.db){e(0);return}try{let a=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName).count();a.onsuccess=()=>{e(a.result)},a.onerror=()=>{t(a.error)}}catch(n){t(n)}})}clear(){return new Promise((e,t)=>{if(!this.db){e();return}this.pendingWrites=[];try{let a=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).clear();a.onsuccess=()=>{e()},a.onerror=()=>{t(a.error)}}catch(n){t(n)}})}close(){this.db&&(this.db.close(),this.db=null)}destroy(){return this.isDestroyed=!0,this.pendingWrites=[],this.close(),new Promise((e,t)=>{try{let n=indexedDB.deleteDatabase(this.dbName);n.onsuccess=()=>{e()},n.onerror=()=>{t(n.error)}}catch(n){t(n)}})}flushWrites(){if(this.flushScheduled=!1,!this.db||this.isDestroyed||this.pendingWrites.length===0)return;let e=this.pendingWrites;this.pendingWrites=[];try{let n=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName);for(let o of e)n.put(o)}catch{}}};var Wv=new Set(["flow_start","flow_run_start","agent_start","dispatch_start","run_start"]),Hv=new Set(["step_start","execution_start"]),Bv=new Set(["step_delta","step_chunk","chunk","agent_turn_delta"]),Dv=new Set(["step_complete","agent_turn_complete"]),Fv=new Set(["flow_complete","agent_complete"]),Px=new Set(["step_error","flow_error","agent_error","dispatch_error","error"]),Ix=r=>typeof r=="object"&&r!==null&&!Array.isArray(r),wn=r=>typeof r=="number"&&Number.isFinite(r)?r:void 0,ya=(r,e)=>{let t=r[e];return Ix(t)?t:void 0};function Jp(r){return r>0?Math.max(1,Math.ceil(r/4)):0}function Ol(r,e){if(!(r<=0||e===void 0||e<250))return r/(e/1e3)}function Nv(r,e){return typeof e.type=="string"?e.type:r}function Ov(r){return typeof r.text=="string"?r.text:typeof r.delta=="string"?r.delta:typeof r.content=="string"?r.content:typeof r.chunk=="string"?r.chunk:""}function _v(r,e){return r==="step_delta"||r==="step_chunk"?e.stepType!=="tool"&&e.executionType!=="context":r!=="agent_turn_delta"?!0:(typeof e.contentType=="string"?e.contentType:typeof e.content_type=="string"?e.content_type:void 0)==="text"}function Rx(r){var n,o,a,s,i;let e=ya(r,"result"),t=[ya(r,"tokens"),ya(r,"totalTokens"),e?ya(e,"tokens"):void 0,ya(r,"usage"),e?ya(e,"usage"):void 0];for(let d of t){if(!d)continue;let l=(o=(n=wn(d.output))!=null?n:wn(d.outputTokens))!=null?o:wn(d.completionTokens);if(l!==void 0)return l}return(i=(a=wn(r.outputTokens))!=null?a:wn(r.completionTokens))!=null?i:e?(s=wn(e.outputTokens))!=null?s:wn(e.completionTokens):void 0}function Uv(r){var t,n,o,a,s;let e=ya(r,"result");return(s=(o=(n=(t=wn(r.executionTime))!=null?t:wn(r.executionTimeMs))!=null?n:wn(r.execution_time))!=null?o:wn(r.duration))!=null?s:e?(a=wn(e.executionTime))!=null?a:wn(e.executionTimeMs):void 0}function qv(){return typeof performance!="undefined"&&typeof performance.now=="function"?performance.now():Date.now()}var ei=class{constructor(e=qv){this.metric={status:"idle"};this.run=null;this.now=e}getMetric(){let e=this.run;if(e&&this.metric.status==="running"&&e.firstDeltaAt!==void 0&&this.metric.outputTokens!==void 0){let t=this.now()-e.firstDeltaAt;return{...this.metric,durationMs:t,tokensPerSecond:Ol(this.metric.outputTokens,t)}}return this.metric}reset(){this.run=null,this.metric={status:"idle"}}startRun(e){this.run={startedAt:e,visibleCharCount:0,exactOutputTokens:0},this.metric={status:"running"}}processEvent(e,t){var a;if(!Ix(t)){Px.has(e)&&this.run&&(this.run=null,this.metric={status:"error"});return}let n=Nv(e,t),o=this.now();if(Wv.has(n)){this.startRun(o);return}if(Hv.has(n)){this.run||this.startRun(o);return}if(Bv.has(n)){if(!_v(n,t))return;let s=Ov(t);if(!s)return;this.run||this.startRun(o);let i=this.run;(a=i.firstDeltaAt)!=null||(i.firstDeltaAt=o),i.visibleCharCount+=s.length;let d=i.exactOutputTokens+Jp(i.visibleCharCount),l=o-i.firstDeltaAt;this.metric={status:"running",tokensPerSecond:Ol(d,l),outputTokens:d,durationMs:l,source:i.exactOutputTokens>0?"usage":"estimate"};return}if(Dv.has(n)){if(!this.run)return;let s=this.run,i=Rx(t);i!==void 0&&(s.exactOutputTokens+=i,s.visibleCharCount=0);let d=s.exactOutputTokens>0,l=s.exactOutputTokens+Jp(s.visibleCharCount),p=this.resolveDuration(s,t,o);this.metric={status:"running",tokensPerSecond:Ol(l,p),outputTokens:l,durationMs:p,source:d?"usage":"estimate"};return}if(Fv.has(n)){if(!this.run)return;let s=this.run,i=Rx(t),d=i!=null?i:s.exactOutputTokens+Jp(s.visibleCharCount),l=i!==void 0||s.exactOutputTokens>0?"usage":"estimate",p=this.resolveDuration(s,t,o);this.metric={status:"complete",tokensPerSecond:Ol(d,p),outputTokens:d,durationMs:p,source:l},this.run=null;return}if(Px.has(n)){if(!this.run)return;this.run=null,this.metric={status:"error"}}}resolveDuration(e,t,n){let o=e.firstDeltaAt!==void 0?n-e.firstDeltaAt:void 0;if(o!==void 0&&o>=250)return o;let a=Uv(t);return a!=null?a:n-e.startedAt}};function Ya(r,e){e&&e.split(/\s+/).forEach(t=>t&&r.classList.add(t))}var zv={flow_:{bg:"var(--persona-palette-colors-success-100, #dcfce7)",text:"var(--persona-palette-colors-success-700, #166534)"},step_:{bg:"var(--persona-palette-colors-primary-100, #f5f5f5)",text:"var(--persona-palette-colors-primary-700, #0a0a0a)"},reason_:{bg:"var(--persona-palette-colors-warning-100, #ffedd5)",text:"var(--persona-palette-colors-warning-700, #9a3412)"},tool_:{bg:"var(--persona-palette-colors-purple-100, #f3e8ff)",text:"var(--persona-palette-colors-purple-700, #6b21a8)"},agent_:{bg:"var(--persona-palette-colors-teal-100, #ccfbf1)",text:"var(--persona-palette-colors-teal-700, #115e59)"},error:{bg:"var(--persona-palette-colors-error-100, #fecaca)",text:"var(--persona-palette-colors-error-700, #991b1b)"}},$v={bg:"var(--persona-palette-colors-gray-100, #f3f4f6)",text:"var(--persona-palette-colors-gray-600, #4b5563)"},Vv=["flowName","stepName","reasoningText","text","name","tool","toolName"],jv=100;function Gv(r,e){let t={...zv,...e};if(t[r])return t[r];for(let n of Object.keys(t))if(n.endsWith("_")&&r.startsWith(n))return t[n];return $v}function Kv(r,e){return`+${((r-e)/1e3).toFixed(3)}s`}function Xv(r){let e=new Date(r),t=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0"),o=String(e.getSeconds()).padStart(2,"0"),a=String(e.getMilliseconds()).padStart(3,"0");return`${t}:${n}:${o}.${a}`}function Qv(r,e){try{let t=JSON.parse(r);if(typeof t!="object"||t===null)return null;for(let n of e){let o=n.split("."),a=t;for(let s of o)if(a&&typeof a=="object"&&a!==null)a=a[s];else{a=void 0;break}if(typeof a=="string"&&a.trim())return a.trim()}}catch{}return null}function Jv(r){var e;return(e=navigator.clipboard)!=null&&e.writeText?navigator.clipboard.writeText(r):new Promise(t=>{let n=document.createElement("textarea");n.value=r,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),t()})}function Yv(r){let e;try{e=JSON.parse(r.payload)}catch{e=r.payload}return JSON.stringify({type:r.type,timestamp:new Date(r.timestamp).toISOString(),payload:e},null,2)}function Zv(r){return r.tokensPerSecond===void 0||!Number.isFinite(r.tokensPerSecond)?"-- tok/s":`${r.tokensPerSecond.toFixed(1)} tok/s`}function eC(r){let e=[];return r.outputTokens!==void 0&&e.push(`${r.outputTokens.toLocaleString()} tok`),r.durationMs!==void 0&&e.push(`${(r.durationMs/1e3).toFixed(2)}s`),r.source&&e.push(r.source),e.join(" \xB7 ")}function tC(r,e,t){let n,o;try{o=JSON.parse(r.payload),n=JSON.stringify(o,null,2)}catch{o=r.payload,n=r.payload}let a=e.find(i=>i.renderEventStreamPayload);if(a!=null&&a.renderEventStreamPayload&&t){let i=a.renderEventStreamPayload({event:r,config:t,defaultRenderer:()=>s(),parsedPayload:o});if(i)return i}return s();function s(){let i=y("div","persona-bg-persona-container persona-border-t persona-border-persona-divider persona-px-3 persona-py-2 persona-ml-4 persona-mr-3 persona-mb-1 persona-rounded-b persona-overflow-auto persona-max-h-[300px]"),d=y("pre","persona-m-0 persona-whitespace-pre-wrap persona-break-all persona-text-[11px] persona-text-persona-secondary persona-font-mono");return d.textContent=n,i.appendChild(d),i}}function Yp(r,e,t,n,o,a,s,i){var u;let d=o.has(r.id),l=y("div","persona-border-b persona-border-persona-divider persona-text-xs");Ya(l,(u=n.classNames)==null?void 0:u.eventRow);let p=s.find(m=>m.renderEventStreamRow);if(p!=null&&p.renderEventStreamRow&&i){let m=p.renderEventStreamRow({event:r,index:e,config:i,defaultRenderer:()=>f(),isExpanded:d,onToggleExpand:()=>a(r.id)});if(m)return l.appendChild(m),l}return l.appendChild(f()),l;function f(){var V,ie;let m=y("div",""),v=y("div","persona-flex persona-items-center persona-gap-2 persona-px-3 persona-py-3 hover:persona-bg-persona-container persona-cursor-pointer persona-group");v.setAttribute("data-event-id",r.id);let x=y("span","persona-flex-shrink-0 persona-text-persona-muted persona-w-4 persona-text-center persona-flex persona-items-center persona-justify-center"),S=Me(d?"chevron-down":"chevron-right","14px","currentColor",2);S&&x.appendChild(S);let M=y("span","persona-text-[11px] persona-text-persona-muted persona-whitespace-nowrap persona-flex-shrink-0 persona-font-mono persona-w-[70px]"),E=(V=n.timestampFormat)!=null?V:"relative";M.textContent=E==="relative"?Kv(r.timestamp,t):Xv(r.timestamp);let k=null;n.showSequenceNumbers!==!1&&(k=y("span","persona-text-[11px] persona-text-persona-muted persona-font-mono persona-flex-shrink-0 persona-w-[28px] persona-text-right"),k.textContent=String(e+1));let h=Gv(r.type,n.badgeColors),w=y("span","persona-inline-flex persona-items-center persona-px-2 persona-py-0.5 persona-rounded persona-text-[11px] persona-font-mono persona-font-medium persona-whitespace-nowrap persona-flex-shrink-0 persona-border");w.style.backgroundColor=h.bg,w.style.color=h.text,w.style.borderColor=h.text+"50",w.textContent=r.type;let C=(ie=n.descriptionFields)!=null?ie:Vv,T=Qv(r.payload,C),W=null;T&&(W=y("span","persona-text-[11px] persona-text-persona-secondary persona-truncate persona-min-w-0"),W.textContent=T);let R=y("div","persona-flex-1 persona-min-w-0"),I=y("button","persona-text-persona-muted hover:persona-text-persona-primary persona-cursor-pointer persona-flex-shrink-0 persona-border-none persona-bg-transparent persona-p-0"),N=Me("clipboard","12px","currentColor",1.5);return N&&I.appendChild(N),I.addEventListener("click",async xe=>{xe.stopPropagation(),await Jv(Yv(r)),I.innerHTML="";let Je=Me("check","12px","currentColor",1.5);Je&&I.appendChild(Je),setTimeout(()=>{I.innerHTML="";let we=Me("clipboard","12px","currentColor",1.5);we&&I.appendChild(we)},1500)}),v.appendChild(x),v.appendChild(M),k&&v.appendChild(k),v.appendChild(w),W&&v.appendChild(W),v.appendChild(R),v.appendChild(I),m.appendChild(v),d&&m.appendChild(tC(r,s,i)),m}}function Wx(r){var v,x,S,M,E;let{buffer:e,getFullHistory:t,onClose:n,config:o,plugins:a=[],getThroughput:s}=r,i=(v=o==null?void 0:o.features)==null?void 0:v.scrollToBottom,d=(i==null?void 0:i.enabled)!==!1,l=(x=i==null?void 0:i.iconName)!=null?x:"arrow-down",p=(S=i==null?void 0:i.label)!=null?S:"",f=(E=(M=o==null?void 0:o.features)==null?void 0:M.eventStream)!=null?E:{},u=a.find(k=>k.renderEventStreamView);if(u!=null&&u.renderEventStreamView&&o){let k=u.renderEventStreamView({config:o,events:e.getAll(),defaultRenderer:()=>m().element,onClose:n});if(k)return{element:k,update:()=>{},destroy:()=>{}}}return m();function m(){let k=f.classNames,h=y("div","persona-event-stream-view persona-flex persona-flex-col persona-flex-1 persona-min-h-0");Ya(h,k==null?void 0:k.panel);let w=[],C="",T="",W=null,R=[],I={},N=0,V=xl(),ie=0,xe=0,Je=!1,we=null,De=!1,Ae=0,qe=new Set,Ie=new Map,J="",re="",Q=null,ge,Z,G,pe,ke,le=null,ne=null,de=null;function Lt(){let ye=y("div","persona-relative persona-flex persona-flex-col persona-flex-shrink-0"),se=y("div","persona-flex persona-items-center persona-gap-2 persona-px-4 persona-py-3 persona-pb-0 persona-border-persona-divider persona-bg-persona-surface persona-overflow-hidden");Ya(se,k==null?void 0:k.headerBar);let st=y("span","persona-text-sm persona-font-medium persona-text-persona-primary persona-whitespace-nowrap");if(st.textContent="Events",ge=y("span","persona-text-[11px] persona-font-mono persona-bg-persona-container persona-text-persona-muted persona-px-2 persona-py-0.5 persona-rounded persona-border persona-border-persona-border"),ge.textContent="0",s){ne=y("div","persona-relative persona-flex persona-items-center persona-gap-1.5 persona-whitespace-nowrap persona-ml-1"),ne.style.cursor="help";let ir=y("span","persona-text-sm persona-font-medium persona-text-persona-primary persona-whitespace-nowrap");ir.textContent="Throughput",le=y("span","persona-text-[11px] persona-font-mono persona-bg-persona-container persona-text-persona-muted persona-px-2 persona-py-0.5 persona-rounded persona-border persona-border-persona-border persona-tabular-nums"),le.textContent="-- tok/s",de=y("div","persona-absolute persona-z-50 persona-whitespace-nowrap persona-rounded persona-border persona-border-persona-border persona-bg-persona-container persona-text-persona-primary persona-text-[11px] persona-font-mono persona-px-2 persona-py-1 persona-shadow"),de.style.display="none",de.style.pointerEvents="none";let fr=ne,Sr=de,cn=()=>{if(!Sr.textContent)return;let _r=fr.getBoundingClientRect(),hr=ye.getBoundingClientRect();Sr.style.left=`${_r.left-hr.left}px`,Sr.style.top=`${_r.bottom-hr.top+4}px`,Sr.style.display="block"},Mt=()=>{Sr.style.display="none"};ne.addEventListener("mouseenter",cn),ne.addEventListener("mouseleave",Mt),ne.appendChild(ir),ne.appendChild(le)}let ur=y("div","persona-flex-1");Z=y("select","persona-text-xs persona-bg-persona-surface persona-border persona-border-persona-border persona-rounded persona-px-2.5 persona-py-1 persona-text-persona-primary persona-cursor-pointer");let ct=y("option","");ct.value="",ct.textContent="All events",Z.appendChild(ct),G=y("button","persona-inline-flex persona-items-center persona-gap-1.5 persona-rounded persona-text-xs persona-text-persona-muted hover:persona-bg-persona-container hover:persona-text-persona-primary persona-cursor-pointer persona-border persona-border-persona-border persona-bg-persona-surface persona-flex-shrink-0 persona-px-2.5 persona-py-1"),G.type="button",G.title="Copy All";let Ir=Me("clipboard-copy","12px","currentColor",1.5);Ir&&G.appendChild(Ir);let pt=y("span","persona-text-xs");pt.textContent="Copy All",G.appendChild(pt),se.appendChild(st),se.appendChild(ge),ne&&se.appendChild(ne),se.appendChild(ur),se.appendChild(Z),se.appendChild(G);let Pt=y("div","persona-relative persona-px-4 persona-py-2.5 persona-border-b persona-border-persona-divider persona-bg-persona-surface");Ya(Pt,k==null?void 0:k.searchBar);let et=Me("search","14px","var(--persona-muted, #9ca3af)",1.5),$t=y("span","persona-absolute persona-left-6 persona-top-1/2 persona--translate-y-1/2 persona-pointer-events-none persona-flex persona-items-center");et&&$t.appendChild(et),pe=y("input","persona-text-sm persona-bg-persona-surface persona-border persona-border-persona-border persona-rounded-md persona-pl-8 persona-pr-3 persona-py-1 persona-w-full persona-text-persona-primary"),Ya(pe,k==null?void 0:k.searchInput),pe.type="text",pe.placeholder="Search event payloads...",ke=y("button","persona-absolute persona-right-5 persona-top-1/2 persona--translate-y-1/2 persona-text-persona-muted hover:persona-text-persona-primary persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-0 persona-leading-none"),ke.type="button",ke.style.display="none";let br=Me("x","12px","currentColor",2);return br&&ke.appendChild(br),Pt.appendChild($t),Pt.appendChild(pe),Pt.appendChild(ke),ye.appendChild(se),ye.appendChild(Pt),de&&ye.appendChild(de),ye}let St,We=a.find(ye=>ye.renderEventStreamToolbar);if(We!=null&&We.renderEventStreamToolbar&&o){let ye=We.renderEventStreamToolbar({config:o,defaultRenderer:()=>Lt(),eventCount:e.getSize(),filteredCount:0,onFilterChange:se=>{C=se,ar(),F()},onSearchChange:se=>{T=se,ar(),F()}});St=ye!=null?ye:Lt()}else St=Lt();let he=y("div","persona-text-xs persona-text-persona-muted persona-text-center persona-py-0.5 persona-px-4 persona-bg-persona-container persona-border-b persona-border-persona-divider persona-italic persona-flex-shrink-0");he.style.display="none";function at(){if(!s||!le||!ne)return;let ye=s();le.textContent=Zv(ye);let se=eC(ye);de&&(de.textContent=se,se||(de.style.display="none")),se?ne.setAttribute("aria-label",se):ne.removeAttribute("aria-label")}let Pe=y("div","persona-flex-1 persona-min-h-0 persona-relative"),j=y("div","persona-event-stream-list persona-overflow-y-auto persona-min-h-0");j.style.height="100%";let ue=y("div","persona-scroll-to-bottom-indicator persona-absolute persona-bottom-3 persona-left-1/2 persona-transform persona--translate-x-1/2 persona-cursor-pointer persona-z-10 persona-text-xs");Ya(ue,k==null?void 0:k.scrollIndicator),ue.style.display="none",ue.setAttribute("data-persona-scroll-to-bottom-has-label",p?"true":"false");let nt=Me(l,"14px","currentColor",2);nt&&ue.appendChild(nt);let It=y("span","");It.textContent=p,ue.appendChild(It);let ee=y("div","persona-flex persona-items-center persona-justify-center persona-h-full persona-text-sm persona-text-persona-muted");ee.style.display="none",Pe.appendChild(j),Pe.appendChild(ee),Pe.appendChild(ue),h.setAttribute("tabindex","0"),h.appendChild(St),h.appendChild(he),h.appendChild(Pe);function je(){let ye=e.getAll(),se={};for(let pt of ye)se[pt.type]=(se[pt.type]||0)+1;let st=Object.keys(se).sort(),ur=st.length!==R.length||!st.every((pt,Pt)=>pt===R[Pt]),ct=!ur&&st.some(pt=>se[pt]!==I[pt]),xr=ye.length!==Object.values(I).reduce((pt,Pt)=>pt+Pt,0);if(!ur&&!ct&&!xr||(R=st,I=se,!Z))return;let Ir=Z.value;if(Z.options[0].textContent="All events",ur){for(;Z.options.length>1;)Z.remove(1);for(let pt of st){let Pt=y("option","");Pt.value=pt,Pt.textContent=`${pt} (${se[pt]||0})`,Z.appendChild(Pt)}Ir&&st.includes(Ir)?Z.value=Ir:Ir&&(Z.value="",C="")}else for(let pt=1;pt<Z.options.length;pt++){let Pt=Z.options[pt];Pt.textContent=`${Pt.value} (${se[Pt.value]||0})`}}function Fr(){let ye=e.getAll();if(C&&(ye=ye.filter(se=>se.type===C)),T){let se=T.toLowerCase();ye=ye.filter(st=>st.type.toLowerCase().includes(se)||st.payload.toLowerCase().includes(se))}return ye}function Dt(){return C!==""||T!==""}function ar(){N=0,ie=0,V.resume(),ue.style.display="none"}function gr(ye){qe.has(ye)?qe.delete(ye):qe.add(ye),Q=ye;let se=j.scrollTop,st=V.isFollowing();De=!0,V.pause(),F(),j.scrollTop=se,st&&V.resume(),De=!1}function nn(){return ma(j,50)}function F(){xe=Date.now(),Je=!1,at(),je();let ye=e.getEvictedCount();ye>0?(he.textContent=`${ye.toLocaleString()} older events truncated`,he.style.display=""):he.style.display="none",w=Fr();let se=w.length,st=e.getSize()>0;ge&&(ge.textContent=String(e.getSize())),se===0&&st&&Dt()?(ee.textContent=T?`No events matching '${T}'`:"No events matching filter",ee.style.display="",j.style.display="none"):(ee.style.display="none",j.style.display=""),G&&(G.title=Dt()?`Copy Filtered (${se})`:"Copy All"),d&&!V.isFollowing()&&se>N&&(ie+=se-N,It.textContent=p?`${p}${ie>0?` (${ie})`:""}`:"",ue.style.display=""),N=se;let ur=e.getAll(),ct=ur.length>0?ur[0].timestamp:0,xr=new Set(w.map(Pt=>Pt.id));for(let Pt of qe)xr.has(Pt)||qe.delete(Pt);let Ir=C!==J||T!==re,pt=Ie.size===0&&w.length>0;if(Ir||pt||w.length===0){j.innerHTML="",Ie.clear();let Pt=document.createDocumentFragment();for(let et=0;et<w.length;et++){let $t=Yp(w[et],et,ct,f,qe,gr,a,o);Ie.set(w[et].id,$t),Pt.appendChild($t)}j.appendChild(Pt),J=C,re=T,Q=null}else{if(Q!==null){let et=Ie.get(Q);if(et&&et.parentNode===j){let $t=w.findIndex(br=>br.id===Q);if($t>=0){let br=Yp(w[$t],$t,ct,f,qe,gr,a,o);j.insertBefore(br,et),et.remove(),Ie.set(Q,br)}}Q=null}let Pt=new Set(w.map(et=>et.id));for(let[et,$t]of Ie)Pt.has(et)||($t.remove(),Ie.delete(et));for(let et=0;et<w.length;et++){let $t=w[et];if(!Ie.has($t.id)){let br=Yp($t,et,ct,f,qe,gr,a,o);Ie.set($t.id,br),j.appendChild(br)}}}V.isFollowing()&&(j.scrollTop=j.scrollHeight)}function fe(){if(Date.now()-xe>=jv){we!==null&&(cancelAnimationFrame(we),we=null),F();return}Je||(Je=!0,we=requestAnimationFrame(()=>{we=null,F()}))}let Re=(ye,se)=>{if(!G)return;G.innerHTML="";let st=Me(ye,"12px","currentColor",1.5);st&&G.appendChild(st);let ur=y("span","persona-text-xs");ur.textContent="Copy All",G.appendChild(ur),setTimeout(()=>{G.innerHTML="";let ct=Me("clipboard-copy","12px","currentColor",1.5);ct&&G.appendChild(ct);let xr=y("span","persona-text-xs");xr.textContent="Copy All",G.appendChild(xr),G.disabled=!1},se)},Xe=async()=>{if(G){G.disabled=!0;try{let ye;Dt()?ye=w:t?(ye=await t(),ye.length===0&&(ye=e.getAll())):ye=e.getAll();let se=ye.map(st=>{try{return JSON.parse(st.payload)}catch{return st.payload}});await navigator.clipboard.writeText(JSON.stringify(se,null,2)),Re("check",1500)}catch{Re("x",1500)}}},Fe=()=>{Z&&(C=Z.value,ar(),F())},Oe=()=>{!pe||!ke||(ke.style.display=pe.value?"":"none",W&&clearTimeout(W),W=setTimeout(()=>{T=pe.value,ar(),F()},150))},Ye=()=>{!pe||!ke||(pe.value="",T="",ke.style.display="none",W&&clearTimeout(W),ar(),F())},Tt=()=>{if(De)return;let ye=j.scrollTop,{action:se,nextLastScrollTop:st}=bl({following:V.isFollowing(),currentScrollTop:ye,lastScrollTop:Ae,nearBottom:nn(),userScrollThreshold:1,resumeRequiresDownwardScroll:!0});Ae=st,se==="resume"?(V.resume(),ie=0,ue.style.display="none"):se==="pause"&&(V.pause(),d&&(It.textContent=p,ue.style.display=""))},Qt=ye=>{let se=yl({following:V.isFollowing(),deltaY:ye.deltaY,nearBottom:nn(),resumeWhenNearBottom:!0});se==="pause"?(V.pause(),d&&(It.textContent=p,ue.style.display="")):se==="resume"&&(V.resume(),ie=0,ue.style.display="none")},sr=()=>{d&&(j.scrollTop=j.scrollHeight,V.resume(),ie=0,ue.style.display="none")},K=ye=>{let se=ye.target;if(!se||se.closest("button"))return;let st=se.closest("[data-event-id]");if(!st)return;let ur=st.getAttribute("data-event-id");ur&&gr(ur)},ft=ye=>{if((ye.metaKey||ye.ctrlKey)&&ye.key==="f"){ye.preventDefault(),pe==null||pe.focus(),pe==null||pe.select();return}ye.key==="Escape"&&(pe&&document.activeElement===pe?(Ye(),pe.blur(),h.focus()):n&&n())};G&&G.addEventListener("click",Xe),Z&&Z.addEventListener("change",Fe),pe&&pe.addEventListener("input",Oe),ke&&ke.addEventListener("click",Ye),j.addEventListener("scroll",Tt),j.addEventListener("wheel",Qt,{passive:!0}),j.addEventListener("click",K),ue.addEventListener("click",sr),h.addEventListener("keydown",ft);function it(){W&&clearTimeout(W),we!==null&&(cancelAnimationFrame(we),we=null),Je=!1,Ie.clear(),G&&G.removeEventListener("click",Xe),Z&&Z.removeEventListener("change",Fe),pe&&pe.removeEventListener("input",Oe),ke&&ke.removeEventListener("click",Ye),j.removeEventListener("scroll",Tt),j.removeEventListener("wheel",Qt),j.removeEventListener("click",K),ue.removeEventListener("click",sr),h.removeEventListener("keydown",ft)}return{element:h,update:fe,destroy:it}}}function Hx(r,e){let t=typeof r.title=="string"&&r.title?r.title:"Untitled artifact",n=typeof r.artifactId=="string"?r.artifactId:"",o=r.status==="streaming"?"streaming":"complete",s=(typeof r.artifactType=="string"?r.artifactType:"markdown")==="component"?"Component":"Document",i=document.createElement("div");i.className="persona-flex persona-w-full persona-max-w-full persona-items-center persona-gap-3 persona-rounded-xl persona-px-4 persona-py-3",i.style.border="1px solid var(--persona-border, #e5e7eb)",i.style.backgroundColor="var(--persona-surface, #ffffff)",i.style.cursor="pointer",i.tabIndex=0,i.setAttribute("role","button"),i.setAttribute("aria-label",`Open ${t} in artifact panel`),n&&i.setAttribute("data-open-artifact",n);let d=document.createElement("div");d.className="persona-flex persona-h-10 persona-w-10 persona-flex-shrink-0 persona-items-center persona-justify-center persona-rounded-lg",d.style.border="1px solid var(--persona-border, #e5e7eb)",d.style.color="var(--persona-muted, #9ca3af)",d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/></svg>';let l=document.createElement("div");l.className="persona-min-w-0 persona-flex-1 persona-flex persona-flex-col persona-gap-0.5";let p=document.createElement("div");p.className="persona-truncate persona-text-sm persona-font-medium",p.style.color="var(--persona-text, #1f2937)",p.textContent=t;let f=document.createElement("div");if(f.className="persona-text-xs persona-flex persona-items-center persona-gap-1.5",f.style.color="var(--persona-muted, #9ca3af)",o==="streaming"){let u=document.createElement("span");u.className="persona-inline-block persona-w-1.5 persona-h-1.5 persona-rounded-full",u.style.backgroundColor="var(--persona-primary, #171717)",u.style.animation="persona-pulse 1.5s ease-in-out infinite",f.appendChild(u);let m=document.createElement("span");m.textContent=`Generating ${s.toLowerCase()}...`,f.appendChild(m)}else f.textContent=s;if(l.append(p,f),i.append(d,l),o==="complete"){let u=document.createElement("button");u.type="button",u.textContent="Download",u.title=`Download ${t}`,u.className="persona-flex-shrink-0 persona-rounded-md persona-px-3 persona-py-1.5 persona-text-xs persona-font-medium",u.style.border="1px solid var(--persona-border, #e5e7eb)",u.style.color="var(--persona-text, #1f2937)",u.style.backgroundColor="transparent",u.style.cursor="pointer",u.setAttribute("data-download-artifact",n),i.append(u)}return i}var Bx=(r,e)=>{var n,o,a;let t=(a=(o=(n=e==null?void 0:e.config)==null?void 0:n.features)==null?void 0:o.artifacts)==null?void 0:a.renderCard;if(t){let s=typeof r.title=="string"&&r.title?r.title:"Untitled artifact",i=typeof r.artifactId=="string"?r.artifactId:"",d=r.status==="streaming"?"streaming":"complete",l=typeof r.artifactType=="string"?r.artifactType:"markdown",p=t({artifact:{artifactId:i,title:s,artifactType:l,status:d},config:e.config,defaultRenderer:()=>Hx(r,e)});if(p)return p}return Hx(r,e)};var Zp=class{constructor(){this.components=new Map}register(e,t){this.components.has(e)&&console.warn(`[ComponentRegistry] Component "${e}" is already registered. Overwriting.`),this.components.set(e,t)}unregister(e){this.components.delete(e)}get(e){return this.components.get(e)}has(e){return this.components.has(e)}getAllNames(){return Array.from(this.components.keys())}clear(){this.components.clear()}registerAll(e){Object.entries(e).forEach(([t,n])=>{this.register(t,n)})}},Co=new Zp;Co.register("PersonaArtifactCard",Bx);function rC(r){var o;let e=y("div","persona-rounded-lg persona-border persona-border-persona-border persona-p-3 persona-text-persona-primary"),t=y("div","persona-font-semibold persona-text-sm persona-mb-2");t.textContent=r.component?`Component: ${r.component}`:"Component";let n=y("pre","persona-font-mono persona-text-xs persona-whitespace-pre-wrap persona-overflow-x-auto");return n.textContent=JSON.stringify((o=r.props)!=null?o:{},null,2),e.appendChild(t),e.appendChild(n),e}function Dx(r,e){var Z,G,pe,ke;let t=(G=(Z=r.features)==null?void 0:Z.artifacts)==null?void 0:G.layout,o=((pe=t==null?void 0:t.toolbarPreset)!=null?pe:"default")==="document",a=(ke=t==null?void 0:t.panePadding)==null?void 0:ke.trim(),s=r.markdown?sa(r.markdown):null,i=Da(r.sanitize),d=le=>{let ne=s?s(le):ia(le);return i?i(ne):ne},l=typeof document!="undefined"?y("div","persona-artifact-backdrop persona-fixed persona-inset-0 persona-z-[55] persona-bg-black/30 persona-hidden md:persona-hidden"):null,p=()=>{l==null||l.classList.add("persona-hidden"),f.classList.remove("persona-artifact-drawer-open"),N==null||N.hide()};l&&l.addEventListener("click",()=>{var le;p(),(le=e.onDismiss)==null||le.call(e)});let f=y("aside","persona-artifact-pane persona-flex persona-flex-col persona-min-h-0 persona-min-w-0 persona-bg-persona-surface persona-text-persona-primary persona-border-l persona-border-persona-border");f.setAttribute("data-persona-theme-zone","artifact-pane"),o&&f.classList.add("persona-artifact-pane-document");let u=y("div","persona-artifact-toolbar persona-flex persona-items-center persona-justify-between persona-gap-2 persona-px-2 persona-py-2 persona-border-b persona-border-persona-border persona-shrink-0");u.setAttribute("data-persona-theme-zone","artifact-toolbar"),o&&u.classList.add("persona-artifact-toolbar-document");let m=y("span","persona-text-xs persona-font-medium persona-truncate");m.textContent="Artifacts";let v=y("button","persona-rounded-md persona-border persona-border-persona-border persona-px-2 persona-py-1 persona-text-xs persona-bg-persona-surface");v.type="button",v.textContent="Close",v.setAttribute("aria-label","Close artifacts panel"),v.addEventListener("click",()=>{var le;p(),(le=e.onDismiss)==null||le.call(e)});let x="rendered",S=y("div","persona-flex persona-items-center persona-gap-1 persona-shrink-0 persona-artifact-toggle-group"),M=o?Dr({icon:"eye",label:"Rendered view",className:"persona-artifact-doc-icon-btn persona-artifact-view-btn"}):Dr({icon:"eye",label:"Rendered view"}),E=o?Dr({icon:"code-2",label:"Source",className:"persona-artifact-doc-icon-btn persona-artifact-code-btn"}):Dr({icon:"code-2",label:"Source"}),k=y("div","persona-flex persona-items-center persona-gap-1 persona-shrink-0"),h=(t==null?void 0:t.documentToolbarShowCopyLabel)===!0,w=(t==null?void 0:t.documentToolbarShowCopyChevron)===!0,C=t==null?void 0:t.documentToolbarCopyMenuItems,T=!!(w&&C&&C.length>0),W=null,R,I=null,N=null;if(o&&(h||w)&&!T){if(R=h?Qs({icon:"copy",label:"Copy",iconSize:14,className:"persona-artifact-doc-copy-btn"}):Dr({icon:"copy",label:"Copy",className:"persona-artifact-doc-copy-btn"}),w){let le=Me("chevron-down",14,"currentColor",2);le&&R.appendChild(le)}}else o&&T?(W=y("div","persona-relative persona-inline-flex persona-items-center persona-gap-0 persona-rounded-md"),R=h?Qs({icon:"copy",label:"Copy",iconSize:14,className:"persona-artifact-doc-copy-btn"}):Dr({icon:"copy",label:"Copy",className:"persona-artifact-doc-copy-btn"}),I=Dr({icon:"chevron-down",label:"More copy options",size:14,className:"persona-artifact-doc-copy-menu-chevron persona-artifact-doc-icon-btn",aria:{"aria-haspopup":"true","aria-expanded":"false"}}),W.append(R,I)):o?R=Dr({icon:"copy",label:"Copy",className:"persona-artifact-doc-icon-btn"}):R=Dr({icon:"copy",label:"Copy"});let V=o?Dr({icon:"refresh-cw",label:"Refresh",className:"persona-artifact-doc-icon-btn"}):Dr({icon:"refresh-cw",label:"Refresh"}),ie=o?Dr({icon:"x",label:"Close",className:"persona-artifact-doc-icon-btn"}):Dr({icon:"x",label:"Close"}),xe=()=>{var St,We,he;let le=(St=Ie.find(at=>at.id===J))!=null?St:Ie[Ie.length-1],ne=(We=le==null?void 0:le.id)!=null?We:null,de=(le==null?void 0:le.artifactType)==="markdown"&&(he=le.markdown)!=null?he:"",Lt=le?JSON.stringify({component:le.component,props:le.props},null,2):"";return{markdown:de,jsonPayload:Lt,id:ne}},Je=async()=>{var St;let{markdown:le,jsonPayload:ne}=xe(),de=(St=Ie.find(We=>We.id===J))!=null?St:Ie[Ie.length-1],Lt=(de==null?void 0:de.artifactType)==="markdown"?le:de?ne:"";try{await navigator.clipboard.writeText(Lt)}catch{}};if(R.addEventListener("click",async()=>{let le=t==null?void 0:t.onDocumentToolbarCopyMenuSelect;if(le&&T){let{markdown:ne,jsonPayload:de,id:Lt}=xe();try{await le({actionId:"primary",artifactId:Lt,markdown:ne,jsonPayload:de})}catch{}return}await Je()}),I&&(C!=null&&C.length)){let le=()=>{var de;return(de=f.closest("[data-persona-root]"))!=null?de:document.body},ne=()=>{N=_o({items:C.map(de=>({id:de.id,label:de.label})),onSelect:async de=>{let{markdown:Lt,jsonPayload:St,id:We}=xe(),he=t==null?void 0:t.onDocumentToolbarCopyMenuSelect;try{he?await he({actionId:de,artifactId:We,markdown:Lt,jsonPayload:St}):de==="markdown"||de==="md"?await navigator.clipboard.writeText(Lt):de==="json"||de==="source"?await navigator.clipboard.writeText(St):await navigator.clipboard.writeText(Lt||St)}catch{}},anchor:W!=null?W:I,position:"bottom-right",portal:le()})};f.isConnected?ne():requestAnimationFrame(ne),I.addEventListener("click",de=>{de.stopPropagation(),N==null||N.toggle()})}V.addEventListener("click",async()=>{var le;try{await((le=t==null?void 0:t.onDocumentToolbarRefresh)==null?void 0:le.call(t))}catch{}Q()}),ie.addEventListener("click",()=>{var le;p(),(le=e.onDismiss)==null||le.call(e)});let we=()=>{o&&(M.setAttribute("aria-pressed",x==="rendered"?"true":"false"),E.setAttribute("aria-pressed",x==="source"?"true":"false"))};M.addEventListener("click",()=>{x="rendered",we(),Q()}),E.addEventListener("click",()=>{x="source",we(),Q()});let De=y("span","persona-min-w-0 persona-flex-1 persona-text-xs persona-font-medium persona-text-persona-primary persona-truncate persona-text-center md:persona-text-left");o?(u.replaceChildren(),S.append(M,E),W?k.append(W,V,ie):k.append(R,V,ie),u.append(S,De,k),we()):(u.appendChild(m),u.appendChild(v)),a&&(u.style.paddingLeft=a,u.style.paddingRight=a);let Ae=y("div","persona-artifact-list persona-shrink-0 persona-flex persona-gap-1 persona-overflow-x-auto persona-p-2 persona-border-b persona-border-persona-border"),qe=y("div","persona-artifact-content persona-flex-1 persona-min-h-0 persona-overflow-y-auto persona-p-3");a&&(Ae.style.paddingLeft=a,Ae.style.paddingRight=a,qe.style.padding=a),f.appendChild(u),f.appendChild(Ae),f.appendChild(qe);let Ie=[],J=null,re=!1,Q=()=>{var Lt,St,We,he;let le=o&&Ie.length<=1;Ae.classList.toggle("persona-hidden",le),Ae.replaceChildren();for(let at of Ie){let Pe=y("button","persona-artifact-tab persona-shrink-0 persona-rounded-lg persona-px-2 persona-py-1 persona-text-xs persona-border persona-border-transparent persona-text-persona-primary");Pe.type="button",Pe.textContent=at.title||at.id.slice(0,8),at.id===J&&Pe.classList.add("persona-bg-persona-container","persona-border-persona-border"),Pe.addEventListener("click",()=>e.onSelect(at.id)),Ae.appendChild(Pe)}qe.replaceChildren();let ne=J&&Ie.find(at=>at.id===J)||Ie[Ie.length-1];if(!ne)return;if(o){let at=ne.artifactType==="markdown"?"MD":(Lt=ne.component)!=null?Lt:"Component",j=(ne.title||"Document").trim().replace(/\s*·\s*MD\s*$/i,"").trim()||"Document";De.textContent=`${j} \xB7 ${at}`}else m.textContent="Artifacts";if(ne.artifactType==="markdown"){if(o&&x==="source"){let Pe=y("pre","persona-font-mono persona-text-xs persona-whitespace-pre-wrap persona-break-words persona-text-persona-primary");Pe.textContent=(St=ne.markdown)!=null?St:"",qe.appendChild(Pe);return}let at=y("div","persona-text-sm persona-leading-relaxed persona-markdown-bubble");at.innerHTML=d((We=ne.markdown)!=null?We:""),qe.appendChild(at);return}let de=ne.component?Co.get(ne.component):void 0;if(de){let Pe={message:{id:ne.id,role:"assistant",content:"",createdAt:new Date().toISOString()},config:r,updateProps:()=>{}};try{let j=de((he=ne.props)!=null?he:{},Pe);if(j){qe.appendChild(j);return}}catch{}}qe.appendChild(rC(ne))},ge=()=>{var ne;let le=Ie.length>0;if(f.classList.toggle("persona-hidden",!le),l){let de=typeof f.closest=="function"?f.closest("[data-persona-root]"):null,St=((ne=de==null?void 0:de.classList.contains("persona-artifact-narrow-host"))!=null?ne:!1)||typeof window!="undefined"&&window.matchMedia("(max-width: 640px)").matches;le&&St&&re?(l.classList.remove("persona-hidden"),f.classList.add("persona-artifact-drawer-open")):(l.classList.add("persona-hidden"),f.classList.remove("persona-artifact-drawer-open"))}};return{element:f,backdrop:l,update(le){var ne,de,Lt;Ie=le.artifacts,J=(Lt=(de=le.selectedId)!=null?de:(ne=le.artifacts[le.artifacts.length-1])==null?void 0:ne.id)!=null?Lt:null,Ie.length>0&&(re=!0),Q(),ge()},setMobileOpen(le){re=le,!le&&l?(l.classList.add("persona-hidden"),f.classList.remove("persona-artifact-drawer-open")):ge()}}}function Dn(r){var e,t;return((t=(e=r==null?void 0:r.features)==null?void 0:e.artifacts)==null?void 0:t.enabled)===!0}function Fx(r,e){var a,s,i,d;if(r.classList.remove("persona-artifact-border-full","persona-artifact-border-left"),r.style.removeProperty("--persona-artifact-pane-border"),r.style.removeProperty("--persona-artifact-pane-border-left"),!Dn(e))return;let t=(s=(a=e.features)==null?void 0:a.artifacts)==null?void 0:s.layout,n=(i=t==null?void 0:t.paneBorder)==null?void 0:i.trim(),o=(d=t==null?void 0:t.paneBorderLeft)==null?void 0:d.trim();n?(r.classList.add("persona-artifact-border-full"),r.style.setProperty("--persona-artifact-pane-border",n)):o&&(r.classList.add("persona-artifact-border-left"),r.style.setProperty("--persona-artifact-pane-border-left",o))}function nC(r){r.style.removeProperty("--persona-artifact-doc-toolbar-icon-color"),r.style.removeProperty("--persona-artifact-doc-toggle-active-bg"),r.style.removeProperty("--persona-artifact-doc-toggle-active-border")}function _l(r,e){var d,l,p,f,u,m,v,x,S,M;if(!Dn(e)){r.style.removeProperty("--persona-artifact-split-gap"),r.style.removeProperty("--persona-artifact-pane-width"),r.style.removeProperty("--persona-artifact-pane-max-width"),r.style.removeProperty("--persona-artifact-pane-min-width"),r.style.removeProperty("--persona-artifact-pane-bg"),r.style.removeProperty("--persona-artifact-pane-padding"),nC(r),Fx(r,e);return}let t=(l=(d=e.features)==null?void 0:d.artifacts)==null?void 0:l.layout;r.style.setProperty("--persona-artifact-split-gap",(p=t==null?void 0:t.splitGap)!=null?p:"0.5rem"),r.style.setProperty("--persona-artifact-pane-width",(f=t==null?void 0:t.paneWidth)!=null?f:"40%"),r.style.setProperty("--persona-artifact-pane-max-width",(u=t==null?void 0:t.paneMaxWidth)!=null?u:"28rem"),t!=null&&t.paneMinWidth?r.style.setProperty("--persona-artifact-pane-min-width",t.paneMinWidth):r.style.removeProperty("--persona-artifact-pane-min-width");let n=(m=t==null?void 0:t.paneBackground)==null?void 0:m.trim();n?r.style.setProperty("--persona-artifact-pane-bg",n):r.style.removeProperty("--persona-artifact-pane-bg");let o=(v=t==null?void 0:t.panePadding)==null?void 0:v.trim();o?r.style.setProperty("--persona-artifact-pane-padding",o):r.style.removeProperty("--persona-artifact-pane-padding");let a=(x=t==null?void 0:t.documentToolbarIconColor)==null?void 0:x.trim();a?r.style.setProperty("--persona-artifact-doc-toolbar-icon-color",a):r.style.removeProperty("--persona-artifact-doc-toolbar-icon-color");let s=(S=t==null?void 0:t.documentToolbarToggleActiveBackground)==null?void 0:S.trim();s?r.style.setProperty("--persona-artifact-doc-toggle-active-bg",s):r.style.removeProperty("--persona-artifact-doc-toggle-active-bg");let i=(M=t==null?void 0:t.documentToolbarToggleActiveBorderColor)==null?void 0:M.trim();i?r.style.setProperty("--persona-artifact-doc-toggle-active-border",i):r.style.removeProperty("--persona-artifact-doc-toggle-active-border"),Fx(r,e)}var Nx=["panel","seamless"];function Ul(r,e){var i,d,l,p,f,u;for(let m of Nx)r.classList.remove(`persona-artifact-appearance-${m}`);if(r.classList.remove("persona-artifact-unified-split"),r.style.removeProperty("--persona-artifact-pane-radius"),r.style.removeProperty("--persona-artifact-pane-shadow"),r.style.removeProperty("--persona-artifact-unified-outer-radius"),!Dn(e))return;let t=(d=(i=e.features)==null?void 0:i.artifacts)==null?void 0:d.layout,n=(l=t==null?void 0:t.paneAppearance)!=null?l:"panel",o=Nx.includes(n)?n:"panel";r.classList.add(`persona-artifact-appearance-${o}`);let a=(p=t==null?void 0:t.paneBorderRadius)==null?void 0:p.trim();a&&r.style.setProperty("--persona-artifact-pane-radius",a);let s=(f=t==null?void 0:t.paneShadow)==null?void 0:f.trim();if(s&&r.style.setProperty("--persona-artifact-pane-shadow",s),(t==null?void 0:t.unifiedSplitChrome)===!0){r.classList.add("persona-artifact-unified-split");let m=((u=t.unifiedSplitOuterRadius)==null?void 0:u.trim())||a;m&&r.style.setProperty("--persona-artifact-unified-outer-radius",m)}}function Ox(r,e){var t,n,o;return!e||!Dn(r)?!1:((o=(n=(t=r.features)==null?void 0:t.artifacts)==null?void 0:n.layout)==null?void 0:o.expandLauncherPanelWhenOpen)!==!1}function oC(r,e){if(!(r!=null&&r.trim()))return e;let t=/^(\d+(?:\.\d+)?)px\s*$/i.exec(r.trim());return t?Math.max(0,Number(t[1])):e}function aC(r){if(!(r!=null&&r.trim()))return null;let e=/^(\d+(?:\.\d+)?)px\s*$/i.exec(r.trim());return e?Math.max(0,Number(e[1])):null}function sC(r,e,t){return t<e?e:Math.min(t,Math.max(e,r))}function iC(r,e,t,n){let o=r-n-2*e-t;return Math.max(0,o)}function _x(r,e){var s;let n=(s=(e.getComputedStyle(r).gap||"0px").trim().split(/\s+/)[0])!=null?s:"0px",o=/^([\d.]+)px$/i.exec(n);if(o)return Number(o[1]);let a=/^([\d.]+)/.exec(n);return a?Number(a[1]):8}function Ux(r,e,t,n,o,a){let s=oC(o,200),i=iC(e,t,n,200);i=Math.max(s,i);let d=aC(a);return d!==null&&(i=Math.min(i,d)),sC(r,s,i)}var qx={init:{title:"Schedule a Demo",description:"Share the basics and we'll follow up with a confirmation.",fields:[{name:"name",label:"Full name",placeholder:"Jane Doe",required:!0},{name:"email",label:"Work email",placeholder:"jane@example.com",type:"email",required:!0},{name:"notes",label:"What would you like to cover?",type:"textarea"}],submitLabel:"Submit details"},followup:{title:"Additional Information",description:"Provide any extra details to tailor the next steps.",fields:[{name:"company",label:"Company",placeholder:"Acme Inc."},{name:"context",label:"Context",type:"textarea",placeholder:"Share more about your use case"}],submitLabel:"Send"}},eu=(r,e,t,n)=>{let o=r.querySelectorAll("[data-tv-form]");o.length&&o.forEach(a=>{var v,x,S;if(a.dataset.enhanced==="true")return;let s=(v=a.dataset.tvForm)!=null?v:"init";a.dataset.enhanced="true";let i=(x=qx[s])!=null?x:qx.init;a.classList.add("persona-form-card","persona-space-y-4");let d=y("div","persona-space-y-1"),l=y("h3","persona-text-base persona-font-semibold persona-text-persona-primary");if(l.textContent=i.title,d.appendChild(l),i.description){let M=y("p","persona-text-sm persona-text-persona-muted");M.textContent=i.description,d.appendChild(M)}let p=document.createElement("form");p.className="persona-form-grid persona-space-y-3",i.fields.forEach(M=>{var C,T;let E=y("label","persona-form-field persona-flex persona-flex-col persona-gap-1");E.htmlFor=`${e.id}-${s}-${M.name}`;let k=y("span","persona-text-xs persona-font-medium persona-text-persona-muted");k.textContent=M.label,E.appendChild(k);let h=(C=M.type)!=null?C:"text",w;h==="textarea"?(w=document.createElement("textarea"),w.rows=3):(w=document.createElement("input"),w.type=h),w.className="persona-rounded-xl persona-border persona-border-gray-200 persona-bg-white persona-px-3 persona-py-2 persona-text-sm persona-text-persona-primary focus:persona-outline-none focus:persona-border-persona-primary",w.id=`${e.id}-${s}-${M.name}`,w.name=M.name,w.placeholder=(T=M.placeholder)!=null?T:"",M.required&&(w.required=!0),E.appendChild(w),p.appendChild(E)});let f=y("div","persona-flex persona-items-center persona-justify-between persona-gap-2"),u=y("div","persona-text-xs persona-text-persona-muted persona-min-h-[1.5rem]"),m=y("button","persona-inline-flex persona-items-center persona-rounded-full persona-bg-persona-primary persona-px-4 persona-py-2 persona-text-sm persona-font-semibold persona-text-white disabled:persona-opacity-60 persona-cursor-pointer");m.type="submit",m.textContent=(S=i.submitLabel)!=null?S:"Submit",f.appendChild(u),f.appendChild(m),p.appendChild(f),a.replaceChildren(d,p),p.addEventListener("submit",async M=>{var w,C;M.preventDefault();let E=(w=t.formEndpoint)!=null?w:"/form",k=new FormData(p),h={};k.forEach((T,W)=>{h[W]=T}),h.type=s,m.disabled=!0,u.textContent="Submitting\u2026";try{let T=await fetch(E,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)});if(!T.ok)throw new Error(`Form submission failed (${T.status})`);let W=await T.json();u.textContent=(C=W.message)!=null?C:"Thanks! We'll be in touch soon.",W.success&&W.nextPrompt&&await n.sendMessage(String(W.nextPrompt))}catch(T){u.textContent=T instanceof Error?T.message:"Something went wrong. Please try again."}finally{m.disabled=!1}})})};var tu=class{constructor(){this.plugins=new Map}register(e){var t;this.plugins.has(e.id)&&console.warn(`Plugin "${e.id}" is already registered. Overwriting.`),this.plugins.set(e.id,e),(t=e.onRegister)==null||t.call(e)}unregister(e){var n;let t=this.plugins.get(e);t&&((n=t.onUnregister)==null||n.call(t),this.plugins.delete(e))}getAll(){return Array.from(this.plugins.values()).sort((e,t)=>{var n,o;return((n=t.priority)!=null?n:0)-((o=e.priority)!=null?o:0)})}getForInstance(e){let t=this.getAll();if(!e||e.length===0)return t;let n=new Set(e.map(a=>a.id));return[...t.filter(a=>!n.has(a.id)),...e].sort((a,s)=>{var i,d;return((i=s.priority)!=null?i:0)-((d=a.priority)!=null?d:0)})}clear(){this.plugins.forEach(e=>{var t;return(t=e.onUnregister)==null?void 0:t.call(e)}),this.plugins.clear()}},ti=new tu;var zx=()=>{let r=new Map,e=(o,a)=>(r.has(o)||r.set(o,new Set),r.get(o).add(a),()=>t(o,a)),t=(o,a)=>{var s;(s=r.get(o))==null||s.delete(a)};return{on:e,off:t,emit:(o,a)=>{var s;(s=r.get(o))==null||s.forEach(i=>{try{i(a)}catch(d){typeof console!="undefined"&&console.error("[AgentWidget] Event handler error:",d)}})}}};var lC=r=>{let e=r.match(/```(?:json)?\s*([\s\S]*?)```/i);return e?e[1]:r},dC=r=>{let e=r.trim(),t=e.indexOf("{");if(t===-1)return null;let n=0;for(let o=t;o<e.length;o+=1){let a=e[o];if(a==="{"&&(n+=1),a==="}"&&(n-=1,n===0))return e.slice(t,o+1)}return null},ri=({text:r})=>{if(!r||!r.includes("{"))return null;try{let e=lC(r),t=dC(e);if(!t)return null;let n=JSON.parse(t);if(!n||typeof n!="object"||!n.action)return null;let{action:o,...a}=n;return{type:String(o),payload:a,raw:n}}catch{return null}},ru=r=>typeof r=="string"?r:r==null?"":String(r),va={message:r=>r.type!=="message"?void 0:{handled:!0,displayText:ru(r.payload.text)},messageAndClick:(r,e)=>{var o;if(r.type!=="message_and_click")return;let t=r.payload,n=ru(t.element);if(n&&((o=e.document)!=null&&o.querySelector)){let a=e.document.querySelector(n);a?setTimeout(()=>{a.click()},400):typeof console!="undefined"&&console.warn("[AgentWidget] Element not found for selector:",n)}return{handled:!0,displayText:ru(t.text)}}},$x=r=>Array.isArray(r)?r.map(e=>String(e)):[],ni=r=>{let e=new Set($x(r.getSessionMetadata().processedActionMessageIds)),t=()=>{e=new Set($x(r.getSessionMetadata().processedActionMessageIds))},n=()=>{let a=Array.from(e);r.updateSessionMetadata(s=>({...s,processedActionMessageIds:a}))};return{process:a=>{if(a.streaming||a.message.role!=="assistant"||!a.text||e.has(a.message.id))return null;let s=typeof a.raw=="string"&&a.raw||typeof a.message.rawContent=="string"&&a.message.rawContent||typeof a.text=="string"&&a.text||null;!s&&typeof a.text=="string"&&a.text.trim().startsWith("{")&&typeof console!="undefined"&&console.warn("[AgentWidget] Structured response detected but no raw payload was provided. Ensure your stream parser returns { text, raw }.");let i=s?r.parsers.reduce((l,p)=>l||(p==null?void 0:p({text:s,message:a.message}))||null,null):null;if(!i)return null;e.add(a.message.id),n();let d={action:i,message:a.message};r.emit("action:detected",d);for(let l of r.handlers)if(l)try{let p=()=>{r.emit("action:resubmit",d)},f=l(i,{message:a.message,metadata:r.getSessionMetadata(),updateMetadata:r.updateSessionMetadata,document:r.documentRef,triggerResubmit:p});if(!f)continue;if(f.handled){let u=f.persistMessage!==!1;return{text:f.displayText!==void 0?f.displayText:"",persist:u,resubmit:f.resubmit}}}catch(p){typeof console!="undefined"&&console.error("[AgentWidget] Action handler error:",p)}return{text:"",persist:!0}},syncFromMetadata:t}};var cC=r=>{if(!r)return null;try{return JSON.parse(r)}catch(e){return typeof console!="undefined"&&console.error("[AgentWidget] Failed to parse stored state:",e),null}},pC=r=>r.map(e=>({...e,streaming:!1})),uC=r=>r.map(e=>({...e,status:"complete"})),ql=(r="persona-state")=>{let e=()=>typeof window=="undefined"||!window.localStorage?null:window.localStorage;return{load:()=>{let t=e();return t?cC(t.getItem(r)):null},save:t=>{let n=e();if(n)try{let o={...t,messages:t.messages?pC(t.messages):void 0,artifacts:t.artifacts?uC(t.artifacts):void 0};n.setItem(r,JSON.stringify(o))}catch(o){typeof console!="undefined"&&console.error("[AgentWidget] Failed to persist state:",o)}},clear:()=>{let t=e();if(t)try{t.removeItem(r)}catch(n){typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear stored state:",n)}}}};var Za=Ai(Fi(),1);function fC(r){if(!r||typeof r!="object"||!("component"in r))return!1;let e=r.component;return typeof e=="string"&&e.length>0}function mC(r,e){if(!fC(r))return null;let t=r.props&&typeof r.props=="object"&&r.props!==null?r.props:{};return{component:r.component,props:t,raw:e}}function zl(){let r=null,e=0;return{getExtractedDirective:()=>r,processChunk:t=>{let n=t.trim();if(!n.startsWith("{")&&!n.startsWith("["))return null;if(t.length<=e)return r;try{let o=(0,Za.parse)(t,Za.STR|Za.OBJ),a=mC(o,t);a&&(r=a)}catch{}return e=t.length,r},reset:()=>{r=null,e=0}}}function Vx(r){return typeof r=="object"&&r!==null&&"component"in r&&typeof r.component=="string"&&"props"in r&&typeof r.props=="object"}function $l(r,e){let{config:t,message:n,onPropsUpdate:o}=e,a=Co.get(r.component);if(!a)return console.warn(`[ComponentMiddleware] Component "${r.component}" not found in registry. Falling back to default rendering.`),null;let s={message:n,config:t,updateProps:i=>{o&&o(i)}};try{return a(r.props,s)}catch(i){return console.error(`[ComponentMiddleware] Error rendering component "${r.component}":`,i),null}}function jx(){let r=zl();return{processChunk:e=>r.processChunk(e),getDirective:()=>r.getExtractedDirective(),reset:()=>{r.reset()}}}function Gx(r){if(typeof r.rawContent=="string"&&r.rawContent.length>0)return r.rawContent;if(typeof r.content=="string"){let e=r.content.trim();if(e.startsWith("{")||e.startsWith("["))return r.content}return null}function Vl(r){let e=Gx(r);if(!e)return!1;try{let t=JSON.parse(e);return typeof t=="object"&&t!==null&&"component"in t&&typeof t.component=="string"}catch{return!1}}function jl(r){let e=Gx(r);if(!e)return null;try{let t=JSON.parse(e);if(typeof t=="object"&&t!==null&&"component"in t&&typeof t.component=="string"){let n=t;return{component:n.component,props:n.props&&typeof n.props=="object"&&n.props!==null?n.props:{},raw:e}}}catch{}return null}var gC=["Very dissatisfied","Dissatisfied","Neutral","Satisfied","Very satisfied"];function Gl(r){let{onSubmit:e,onDismiss:t,title:n="How satisfied are you?",subtitle:o="Please rate your experience",commentPlaceholder:a="Share your thoughts (optional)...",submitText:s="Submit",skipText:i="Skip",showComment:d=!0,ratingLabels:l=gC}=r,p=document.createElement("div");p.className="persona-feedback-container persona-feedback-csat",p.setAttribute("role","dialog"),p.setAttribute("aria-label","Customer satisfaction feedback");let f=null,u=document.createElement("div");u.className="persona-feedback-content";let m=document.createElement("div");m.className="persona-feedback-header";let v=document.createElement("h3");v.className="persona-feedback-title",v.textContent=n,m.appendChild(v);let x=document.createElement("p");x.className="persona-feedback-subtitle",x.textContent=o,m.appendChild(x),u.appendChild(m);let S=document.createElement("div");S.className="persona-feedback-rating persona-feedback-rating-csat",S.setAttribute("role","radiogroup"),S.setAttribute("aria-label","Satisfaction rating from 1 to 5");let M=[];for(let C=1;C<=5;C++){let T=document.createElement("button");T.type="button",T.className="persona-feedback-rating-btn persona-feedback-star-btn",T.setAttribute("role","radio"),T.setAttribute("aria-checked","false"),T.setAttribute("aria-label",`${C} star${C>1?"s":""}: ${l[C-1]}`),T.title=l[C-1],T.dataset.rating=String(C),T.innerHTML=`
|
|
71
|
+
`,t.addEventListener("click",e);let o=a=>{var L,x,w,v,E,H,I,P,z,j,ie,ve,Xe;let s=(L=a.launcher)!=null?L:{},i=Lr(a),d=t.querySelector("[data-role='launcher-title']");if(d){let Ae=(x=s.title)!=null?x:"Chat Assistant";d.textContent=Ae,d.setAttribute("title",Ae)}let l=t.querySelector("[data-role='launcher-subtitle']");if(l){let Ae=(w=s.subtitle)!=null?w:"Get answers fast";l.textContent=Ae,l.setAttribute("title",Ae)}let u=t.querySelector(".persona-flex-col");u&&(s.textHidden||i?u.style.display="none":u.style.display="");let f=t.querySelector("[data-role='launcher-icon']");if(f)if(s.agentIconHidden)f.style.display="none";else{let Ae=(v=s.agentIconSize)!=null?v:"40px";if(f.style.height=Ae,f.style.width=Ae,f.innerHTML="",s.agentIconName){let We=parseFloat(Ae)||24,Me=Ee(s.agentIconName,We*.6,"var(--persona-text-inverse, #ffffff)",2);Me?(f.appendChild(Me),f.style.display=""):(f.textContent=(E=s.agentIconText)!=null?E:"\u{1F4AC}",f.style.display="")}else s.iconUrl?f.style.display="none":(f.textContent=(H=s.agentIconText)!=null?H:"\u{1F4AC}",f.style.display="")}let p=t.querySelector("[data-role='launcher-image']");if(p){let Ae=(I=s.agentIconSize)!=null?I:"40px";p.style.height=Ae,p.style.width=Ae,s.iconUrl&&!s.agentIconName&&!s.agentIconHidden?(p.src=s.iconUrl,p.style.display="block"):p.style.display="none"}let m=t.querySelector("[data-role='launcher-call-to-action-icon']");if(m){let Ae=(P=s.callToActionIconSize)!=null?P:"32px";m.style.height=Ae,m.style.width=Ae,s.callToActionIconBackgroundColor?(m.style.backgroundColor=s.callToActionIconBackgroundColor,m.classList.remove("persona-bg-persona-primary")):(m.style.backgroundColor="",m.classList.add("persona-bg-persona-primary")),s.callToActionIconColor?(m.style.color=s.callToActionIconColor,m.classList.remove("persona-text-persona-call-to-action")):(m.style.color="",m.classList.add("persona-text-persona-call-to-action"));let We=0;if(s.callToActionIconPadding?(m.style.boxSizing="border-box",m.style.padding=s.callToActionIconPadding,We=(parseFloat(s.callToActionIconPadding)||0)*2):(m.style.boxSizing="",m.style.padding=""),s.callToActionIconHidden)m.style.display="none";else if(m.style.display=i?"none":"",m.innerHTML="",s.callToActionIconName){let Me=parseFloat(Ae)||24,Ue=Math.max(Me-We,8),Be=Ee(s.callToActionIconName,Ue,"currentColor",2);Be?m.appendChild(Be):m.textContent=(z=s.callToActionIconText)!=null?z:"\u2197"}else m.textContent=(j=s.callToActionIconText)!=null?j:"\u2197"}let y=s.position&&tn[s.position]?tn[s.position]:tn["bottom-right"],h="persona-fixed persona-flex persona-items-center persona-gap-3 persona-rounded-launcher persona-bg-persona-surface persona-py-2.5 persona-pl-3 persona-pr-3 persona-transition hover:persona-translate-y-[-2px] persona-cursor-pointer",T="persona-relative persona-mt-4 persona-mb-4 persona-mx-auto persona-flex persona-items-center persona-justify-center persona-rounded-launcher persona-bg-persona-surface persona-transition hover:persona-translate-y-[-2px] persona-cursor-pointer";t.className=i?T:`${h} ${y}`,i||(t.style.zIndex=String((ie=s.zIndex)!=null?ie:so));let M="1px solid var(--persona-border, #e5e7eb)",k="var(--persona-launcher-shadow, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1))";t.style.border=(ve=s.border)!=null?ve:M,t.style.boxShadow=s.shadow!==void 0?s.shadow.trim()===""?"none":s.shadow:k,i?(t.style.width="0",t.style.minWidth="0",t.style.maxWidth="0",t.style.padding="0",t.style.overflow="hidden",t.style.border="none",t.style.boxShadow="none"):(t.style.width="",t.style.minWidth="",t.style.maxWidth=(Xe=s.collapsedMaxWidth)!=null?Xe:"",t.style.justifyContent="",t.style.padding="",t.style.overflow="")},n=()=>{t.removeEventListener("click",e),t.remove()};return r&&o(r),{element:t,update:o,destroy:n}};var zv="persona-relative persona-ml-auto persona-inline-flex persona-items-center persona-justify-center",Ol=(r,e={})=>{var h,T,M,k,L,x;let{showClose:t=!0,wrapperClassName:o=zv,buttonSize:n,iconSize:a="28px"}=e,s=(h=r==null?void 0:r.launcher)!=null?h:{},i=(T=n!=null?n:s.closeButtonSize)!=null?T:"32px",d=C("div",o),l=C("button","persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-bg-gray-100 persona-cursor-pointer persona-border-none");l.style.height=i,l.style.width=i,l.type="button";let u=(M=s.closeButtonTooltipText)!=null?M:"Close chat",f=(k=s.closeButtonShowTooltip)!=null?k:!0;l.setAttribute("aria-label",u),l.style.display=t?"":"none";let p=(L=s.closeButtonIconName)!=null?L:"x",m=(x=s.closeButtonIconText)!=null?x:"\xD7";l.style.color=s.closeButtonColor||Ao.actionIconColor;let y=Ee(p,a,"currentColor",1);if(y?(y.style.display="block",l.appendChild(y)):l.textContent=m,s.closeButtonBackgroundColor?(l.style.backgroundColor=s.closeButtonBackgroundColor,l.classList.remove("hover:persona-bg-gray-100")):(l.style.backgroundColor="",l.classList.add("hover:persona-bg-gray-100")),s.closeButtonBorderWidth||s.closeButtonBorderColor){let w=s.closeButtonBorderWidth||"0px",v=s.closeButtonBorderColor||"transparent";l.style.border=`${w} solid ${v}`,l.classList.remove("persona-border-none")}else l.style.border="",l.classList.add("persona-border-none");if(s.closeButtonBorderRadius?(l.style.borderRadius=s.closeButtonBorderRadius,l.classList.remove("persona-rounded-full")):(l.style.borderRadius="",l.classList.add("persona-rounded-full")),s.closeButtonPaddingX?(l.style.paddingLeft=s.closeButtonPaddingX,l.style.paddingRight=s.closeButtonPaddingX):(l.style.paddingLeft="",l.style.paddingRight=""),s.closeButtonPaddingY?(l.style.paddingTop=s.closeButtonPaddingY,l.style.paddingBottom=s.closeButtonPaddingY):(l.style.paddingTop="",l.style.paddingBottom=""),d.appendChild(l),f&&u){let w=null,v=()=>{if(w)return;let H=l.ownerDocument,I=H.body;if(!I)return;w=un(H,"div","persona-clear-chat-tooltip"),w.textContent=u;let P=un(H,"div");P.className="persona-clear-chat-tooltip-arrow",w.appendChild(P);let z=l.getBoundingClientRect();w.style.position="fixed",w.style.zIndex=String(jn),w.style.left=`${z.left+z.width/2}px`,w.style.top=`${z.top-8}px`,w.style.transform="translate(-50%, -100%)",I.appendChild(w)},E=()=>{w&&w.parentNode&&(w.parentNode.removeChild(w),w=null)};d.addEventListener("mouseenter",v),d.addEventListener("mouseleave",E),l.addEventListener("focus",v),l.addEventListener("blur",E),d._cleanupTooltip=()=>{E(),d.removeEventListener("mouseenter",v),d.removeEventListener("mouseleave",E),l.removeEventListener("focus",v),l.removeEventListener("blur",E)}}return{button:l,wrapper:d}},$v="persona-relative persona-ml-auto persona-clear-chat-button-wrapper",_l=(r,e={})=>{var w,v,E,H,I,P,z,j,ie,ve,Xe,Ae,We;let{wrapperClassName:t=$v,buttonSize:o,iconSize:n="20px"}=e,s=(v=((w=r==null?void 0:r.launcher)!=null?w:{}).clearChat)!=null?v:{},i=(E=o!=null?o:s.size)!=null?E:"32px",d=(H=s.iconName)!=null?H:"refresh-cw",l=(I=s.iconColor)!=null?I:"",u=(P=s.backgroundColor)!=null?P:"",f=(z=s.borderWidth)!=null?z:"",p=(j=s.borderColor)!=null?j:"",m=(ie=s.borderRadius)!=null?ie:"",y=(ve=s.paddingX)!=null?ve:"",h=(Xe=s.paddingY)!=null?Xe:"",T=(Ae=s.tooltipText)!=null?Ae:"Clear chat",M=(We=s.showTooltip)!=null?We:!0,k=C("div",t),L=C("button","persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-bg-gray-100 persona-cursor-pointer persona-border-none");L.style.height=i,L.style.width=i,L.type="button",L.setAttribute("aria-label",T),L.style.color=l||Ao.actionIconColor;let x=Ee(d,n,"currentColor",1);if(x&&(x.style.display="block",L.appendChild(x)),u&&(L.style.backgroundColor=u,L.classList.remove("hover:persona-bg-gray-100")),f||p){let Me=f||"0px",Ue=p||"transparent";L.style.border=`${Me} solid ${Ue}`,L.classList.remove("persona-border-none")}if(m&&(L.style.borderRadius=m,L.classList.remove("persona-rounded-full")),y&&(L.style.paddingLeft=y,L.style.paddingRight=y),h&&(L.style.paddingTop=h,L.style.paddingBottom=h),k.appendChild(L),M&&T){let Me=null,Ue=()=>{if(Me)return;let Z=L.ownerDocument,ne=Z.body;if(!ne)return;Me=un(Z,"div","persona-clear-chat-tooltip"),Me.textContent=T;let me=un(Z,"div");me.className="persona-clear-chat-tooltip-arrow",Me.appendChild(me);let be=L.getBoundingClientRect();Me.style.position="fixed",Me.style.zIndex=String(jn),Me.style.left=`${be.left+be.width/2}px`,Me.style.top=`${be.top-8}px`,Me.style.transform="translate(-50%, -100%)",ne.appendChild(Me)},Be=()=>{Me&&Me.parentNode&&(Me.parentNode.removeChild(Me),Me=null)};k.addEventListener("mouseenter",Ue),k.addEventListener("mouseleave",Be),L.addEventListener("focus",Ue),L.addEventListener("blur",Be),k._cleanupTooltip=()=>{Be(),k.removeEventListener("mouseenter",Ue),k.removeEventListener("mouseleave",Be),L.removeEventListener("focus",Ue),L.removeEventListener("blur",Be)}}return{button:L,wrapper:k}};var Ao={titleColor:"var(--persona-header-title-fg, var(--persona-primary, #0f0f0f))",subtitleColor:"var(--persona-header-subtitle-fg, var(--persona-text-muted, var(--persona-muted, #9ca3af)))",actionIconColor:"var(--persona-header-action-icon-fg, var(--persona-muted, #9ca3af))"},kn=r=>{var w,v,E,H,I,P,z,j,ie,ve,Xe,Ae,We,Me,Ue,Be;let{config:e,showClose:t=!0}=r,o=C("div","persona-widget-header persona-flex persona-items-center persona-gap-3 persona-px-6 persona-py-5");o.setAttribute("data-persona-theme-zone","header"),o.style.backgroundColor="var(--persona-header-bg, var(--persona-surface, #ffffff))",o.style.borderBottomColor="var(--persona-header-border, var(--persona-divider, #f1f5f9))",o.style.boxShadow="var(--persona-header-shadow, none)",o.style.borderBottom="var(--persona-header-border-bottom, 1px solid var(--persona-header-border, var(--persona-divider, #f1f5f9)))";let n=(w=e==null?void 0:e.launcher)!=null?w:{},a=(v=n.headerIconSize)!=null?v:"48px",s=(E=n.closeButtonPlacement)!=null?E:"inline",i=(H=n.headerIconHidden)!=null?H:!1,d=n.headerIconName,l=C("div","persona-flex persona-items-center persona-justify-center persona-rounded-xl persona-text-xl");if(l.style.height=a,l.style.width=a,l.style.backgroundColor="var(--persona-header-icon-bg, var(--persona-primary, #0f0f0f))",l.style.color="var(--persona-header-icon-fg, var(--persona-text-inverse, #ffffff))",!i)if(d){let Z=parseFloat(a)||24,ne=Ee(d,Z*.6,"currentColor",1);ne?l.replaceChildren(ne):l.textContent=(P=(I=e==null?void 0:e.launcher)==null?void 0:I.agentIconText)!=null?P:"\u{1F4AC}"}else if((z=e==null?void 0:e.launcher)!=null&&z.iconUrl){let Z=C("img");Z.src=e.launcher.iconUrl,Z.alt="",Z.className="persona-rounded-xl persona-object-cover",Z.style.height=a,Z.style.width=a,l.replaceChildren(Z)}else l.textContent=(ie=(j=e==null?void 0:e.launcher)==null?void 0:j.agentIconText)!=null?ie:"\u{1F4AC}";let u=C("div","persona-flex persona-flex-col persona-flex-1 persona-min-w-0"),f=C("span","persona-text-base persona-font-semibold");f.style.color=Ao.titleColor,f.textContent=(Xe=(ve=e==null?void 0:e.launcher)==null?void 0:ve.title)!=null?Xe:"Chat Assistant";let p=C("span","persona-text-xs");p.style.color=Ao.subtitleColor,p.textContent=(We=(Ae=e==null?void 0:e.launcher)==null?void 0:Ae.subtitle)!=null?We:"Here to help you get answers fast",u.append(f,p),i?o.append(u):o.append(l,u);let m=(Me=n.clearChat)!=null?Me:{},y=(Ue=m.enabled)!=null?Ue:!0,h=(Be=m.placement)!=null?Be:"inline",T=null,M=null;if(y){let ne=_l(e,{wrapperClassName:h==="top-right"?"persona-absolute persona-top-4 persona-z-50":"persona-relative persona-ml-auto persona-clear-chat-button-wrapper"});T=ne.button,M=ne.wrapper,h==="top-right"&&(M.style.right="48px"),h==="inline"&&o.appendChild(M)}let k=s==="top-right"?"persona-absolute persona-top-4 persona-right-4 persona-z-50":y&&h==="inline"?"persona-relative persona-inline-flex persona-items-center persona-justify-center":"persona-relative persona-ml-auto persona-inline-flex persona-items-center persona-justify-center",{button:L,wrapper:x}=Ol(e,{showClose:t,wrapperClassName:k});return s!=="top-right"&&o.appendChild(x),{header:o,iconHolder:l,headerTitle:f,headerSubtitle:p,closeButton:L,closeButtonWrapper:x,clearChatButton:T,clearChatButtonWrapper:M}},Ta=(r,e,t)=>{var s,i,d,l;let o=(s=t==null?void 0:t.launcher)!=null?s:{},n=(i=o.closeButtonPlacement)!=null?i:"inline",a=(l=(d=o.clearChat)==null?void 0:d.placement)!=null?l:"inline";r.appendChild(e.header),n==="top-right"&&(r.style.position="relative",r.appendChild(e.closeButtonWrapper)),e.clearChatButtonWrapper&&a==="top-right"&&(r.style.position="relative",r.appendChild(e.clearChatButtonWrapper))};function Xn(r){let{items:e,onSelect:t,anchor:o,position:n="bottom-left",portal:a}=r,s=C("div","persona-dropdown-menu persona-hidden");s.setAttribute("role","menu"),s.setAttribute("data-persona-theme-zone","dropdown"),a?(s.style.position="fixed",s.style.zIndex=String(jn)):(s.style.position="absolute",s.style.top="100%",s.style.marginTop="4px",n==="bottom-right"?s.style.right="0":s.style.left="0");for(let m of e){if(m.dividerBefore){let T=document.createElement("hr");s.appendChild(T)}let y=document.createElement("button");if(y.type="button",y.setAttribute("role","menuitem"),y.setAttribute("data-dropdown-item-id",m.id),m.destructive&&y.setAttribute("data-destructive",""),m.icon){let T=Ee(m.icon,16,"currentColor",1.5);T&&y.appendChild(T)}let h=document.createElement("span");h.textContent=m.label,y.appendChild(h),y.addEventListener("click",T=>{T.stopPropagation(),u(),t(m.id)}),s.appendChild(y)}let i=null;function d(){if(!a)return;let m=o.getBoundingClientRect();s.style.top=`${m.bottom+4}px`,n==="bottom-right"?(s.style.right=`${window.innerWidth-m.right}px`,s.style.left="auto"):(s.style.left=`${m.left}px`,s.style.right="auto")}function l(){d(),s.classList.remove("persona-hidden"),requestAnimationFrame(()=>{let m=y=>{!s.contains(y.target)&&!o.contains(y.target)&&u()};document.addEventListener("click",m,!0),i=()=>document.removeEventListener("click",m,!0)})}function u(){s.classList.add("persona-hidden"),i==null||i(),i=null}function f(){s.classList.contains("persona-hidden")?l():u()}function p(){u(),s.remove()}return a&&a.appendChild(s),{element:s,show:l,hide:u,toggle:f,destroy:p}}function Br(r){let{icon:e,label:t,size:o,strokeWidth:n,className:a,onClick:s,aria:i}=r,d=C("button","persona-icon-btn"+(a?" "+a:""));d.type="button",d.setAttribute("aria-label",t),d.title=t;let l=Ee(e,o!=null?o:16,"currentColor",n!=null?n:2);if(l&&d.appendChild(l),s&&d.addEventListener("click",s),i)for(let[u,f]of Object.entries(i))d.setAttribute(u,f);return d}function ci(r){let{icon:e,label:t,variant:o="default",size:n="sm",iconSize:a,className:s,onClick:i,aria:d}=r,l="persona-label-btn";o!=="default"&&(l+=" persona-label-btn--"+o),l+=" persona-label-btn--"+n,s&&(l+=" "+s);let u=C("button",l);if(u.type="button",u.setAttribute("aria-label",t),e){let p=Ee(e,a!=null?a:14,"currentColor",2);p&&u.appendChild(p)}let f=C("span");if(f.textContent=t,u.appendChild(f),i&&u.addEventListener("click",i),d)for(let[p,m]of Object.entries(d))u.setAttribute(p,m);return u}function Wx(r){let{items:e,selectedId:t,onSelect:o,className:n}=r,a=C("div","persona-toggle-group"+(n?" "+n:""));a.setAttribute("role","group");let s=t,i=[];function d(){for(let u of i)u.btn.setAttribute("aria-pressed",u.id===s?"true":"false")}for(let u of e){let f;u.icon?f=Br({icon:u.icon,label:u.label,onClick:()=>{s=u.id,d(),o(u.id)}}):(f=C("button","persona-icon-btn"),f.type="button",f.setAttribute("aria-label",u.label),f.title=u.label,f.textContent=u.label,f.addEventListener("click",()=>{s=u.id,d(),o(u.id)})),f.setAttribute("aria-pressed",u.id===s?"true":"false"),i.push({id:u.id,btn:f}),a.appendChild(f)}function l(u){s=u,d()}return{element:a,setSelected:l}}function Nl(r){var m,y;let{label:e,icon:t="chevron-down",menuItems:o,onSelect:n,position:a="bottom-left",portal:s,className:i,hover:d}=r,l=C("div","persona-combo-btn"+(i?" "+i:""));l.style.position="relative",l.style.display="inline-flex",l.style.alignItems="center",l.style.cursor="pointer",l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("aria-haspopup","true"),l.setAttribute("aria-expanded","false"),l.setAttribute("aria-label",e);let u=C("span","persona-combo-btn-label");u.textContent=e,l.appendChild(u);let f=Ee(t,14,"currentColor",2);f&&(f.style.marginLeft="4px",f.style.opacity="0.6",l.appendChild(f)),d&&(l.style.borderRadius=(m=d.borderRadius)!=null?m:"10px",l.style.padding=(y=d.padding)!=null?y:"6px 4px 6px 12px",l.style.border="1px solid transparent",l.style.transition="background-color 0.15s ease, border-color 0.15s ease",l.addEventListener("mouseenter",()=>{var h,T;l.style.backgroundColor=(h=d.background)!=null?h:"",l.style.borderColor=(T=d.border)!=null?T:""}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor="",l.style.borderColor="transparent"}));let p=Xn({items:o,onSelect:h=>{l.setAttribute("aria-expanded","false"),n(h)},anchor:l,position:a,portal:s});return s||l.appendChild(p.element),l.addEventListener("click",h=>{h.stopPropagation();let T=!p.element.classList.contains("persona-hidden");l.setAttribute("aria-expanded",T?"false":"true"),p.toggle()}),l.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),l.click())}),{element:l,setLabel:h=>{u.textContent=h,l.setAttribute("aria-label",h)},open:()=>{l.setAttribute("aria-expanded","true"),p.show()},close:()=>{l.setAttribute("aria-expanded","false"),p.hide()},toggle:()=>{let h=!p.element.classList.contains("persona-hidden");l.setAttribute("aria-expanded",h?"false":"true"),p.toggle()},destroy:()=>{p.destroy(),l.remove()}}}var eu=r=>{var o;let e=kn({config:r.config,showClose:r.showClose,onClose:r.onClose,onClearChat:r.onClearChat}),t=(o=r.layoutHeaderConfig)==null?void 0:o.onTitleClick;if(t){let n=e.headerTitle.parentElement;n&&(n.style.cursor="pointer",n.setAttribute("role","button"),n.setAttribute("tabindex","0"),n.addEventListener("click",()=>t()),n.addEventListener("keydown",a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),t())}))}return e};function Vv(r,e,t){var o,n,a;if(e!=null&&e.length)for(let s of e){let i=C("button","persona-inline-flex persona-items-center persona-justify-center persona-rounded-md persona-border-none persona-bg-transparent persona-p-0 persona-text-persona-muted hover:persona-opacity-80");if(i.type="button",i.setAttribute("aria-label",(n=(o=s.ariaLabel)!=null?o:s.label)!=null?n:s.id),s.icon){let d=Ee(s.icon,14,"currentColor",2);d&&i.appendChild(d)}else s.label&&(i.textContent=s.label);if((a=s.menuItems)!=null&&a.length){let d=C("div","persona-relative");d.appendChild(i);let l=Xn({items:s.menuItems,onSelect:u=>t==null?void 0:t(u),anchor:d,position:"bottom-left"});d.appendChild(l.element),i.addEventListener("click",u=>{u.stopPropagation(),l.toggle()}),r.appendChild(d)}else i.addEventListener("click",()=>t==null?void 0:t(s.id)),r.appendChild(i)}}var tu=r=>{var k,L,x,w,v,E,H,I,P;let{config:e,showClose:t=!0,onClose:o,layoutHeaderConfig:n,onHeaderAction:a}=r,s=(k=e==null?void 0:e.launcher)!=null?k:{},i=C("div","persona-flex persona-items-center persona-justify-between persona-px-6 persona-py-4");i.setAttribute("data-persona-theme-zone","header"),i.style.backgroundColor="var(--persona-header-bg, var(--persona-surface, #ffffff))",i.style.borderBottomColor="var(--persona-header-border, var(--persona-divider, #f1f5f9))",i.style.boxShadow="var(--persona-header-shadow, none)",i.style.borderBottom="var(--persona-header-border-bottom, 1px solid var(--persona-header-border, var(--persona-divider, #f1f5f9)))";let d=n==null?void 0:n.titleMenu,l,u;if(d)l=Nl({label:(L=s.title)!=null?L:"Chat Assistant",menuItems:d.menuItems,onSelect:d.onSelect,hover:d.hover,className:""}).element,l.style.color=Ao.titleColor,u=(x=l.querySelector(".persona-combo-btn-label"))!=null?x:l;else{if(l=C("div","persona-flex persona-min-w-0 persona-flex-1 persona-items-center persona-gap-1"),u=C("span","persona-text-base persona-font-semibold persona-truncate"),u.style.color=Ao.titleColor,u.textContent=(w=s.title)!=null?w:"Chat Assistant",l.appendChild(u),Vv(l,n==null?void 0:n.trailingActions,(v=n==null?void 0:n.onAction)!=null?v:a),n!=null&&n.onTitleClick){l.style.cursor="pointer",l.setAttribute("role","button"),l.setAttribute("tabindex","0");let j=n.onTitleClick;l.addEventListener("click",ie=>{ie.target.closest("button")||j()}),l.addEventListener("keydown",ie=>{(ie.key==="Enter"||ie.key===" ")&&(ie.preventDefault(),j())})}let z=n==null?void 0:n.titleRowHover;z&&(l.style.borderRadius=(E=z.borderRadius)!=null?E:"10px",l.style.padding=(H=z.padding)!=null?H:"6px 4px 6px 12px",l.style.margin="-6px 0 -6px -12px",l.style.border="1px solid transparent",l.style.transition="background-color 0.15s ease, border-color 0.15s ease",l.style.width="fit-content",l.style.flex="none",l.addEventListener("mouseenter",()=>{var j,ie;l.style.backgroundColor=(j=z.background)!=null?j:"",l.style.borderColor=(ie=z.border)!=null?ie:""}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor="",l.style.borderColor="transparent"}))}i.appendChild(l);let f=(I=s.closeButtonSize)!=null?I:"32px",p=C("div",""),m=C("button","persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-bg-gray-100 persona-cursor-pointer persona-border-none");m.style.height=f,m.style.width=f,m.type="button",m.setAttribute("aria-label","Close chat"),m.style.display=t?"":"none",m.style.color=s.closeButtonColor||Ao.actionIconColor;let y=(P=s.closeButtonIconName)!=null?P:"x",h=Ee(y,"28px","currentColor",1);h?m.appendChild(h):m.textContent="\xD7",o&&m.addEventListener("click",o),p.appendChild(m),i.appendChild(p);let T=C("div");T.style.display="none";let M=C("span");return M.style.display="none",{header:i,iconHolder:T,headerTitle:u,headerSubtitle:M,closeButton:m,closeButtonWrapper:p,clearChatButton:null,clearChatButtonWrapper:null}},Fl={default:eu,minimal:tu},ru=r=>{var e;return(e=Fl[r])!=null?e:Fl.default},os=(r,e,t)=>{var s,i,d;if(e!=null&&e.render){let l=e.render({config:r,onClose:t==null?void 0:t.onClose,onClearChat:t==null?void 0:t.onClearChat,trailingActions:e.trailingActions,onAction:e.onAction}),u=C("div");u.style.display="none";let f=C("span"),p=C("span"),m=C("button");m.style.display="none";let y=C("div");return y.style.display="none",{header:l,iconHolder:u,headerTitle:f,headerSubtitle:p,closeButton:m,closeButtonWrapper:y,clearChatButton:null,clearChatButtonWrapper:null}}let o=(s=e==null?void 0:e.layout)!=null?s:"default",a=ru(o)({config:r,showClose:(d=(i=e==null?void 0:e.showCloseButton)!=null?i:t==null?void 0:t.showClose)!=null?d:!0,onClose:t==null?void 0:t.onClose,onClearChat:t==null?void 0:t.onClearChat,layoutHeaderConfig:e,onHeaderAction:e==null?void 0:e.onAction});return e&&(e.showIcon===!1&&(a.iconHolder.style.display="none"),e.showTitle===!1&&(a.headerTitle.style.display="none"),e.showSubtitle===!1&&(a.headerSubtitle.style.display="none"),e.showCloseButton===!1&&(a.closeButton.style.display="none"),e.showClearChat===!1&&a.clearChatButtonWrapper&&(a.clearChatButtonWrapper.style.display="none")),a};var Ul=r=>{var s,i;let e=C("textarea");e.setAttribute("data-persona-composer-input",""),e.placeholder=(i=(s=r==null?void 0:r.copy)==null?void 0:s.inputPlaceholder)!=null?i:"Type your message\u2026",e.className="persona-w-full persona-min-h-[24px] persona-resize-none persona-border-none persona-bg-transparent persona-text-sm persona-text-persona-primary focus:persona-outline-none focus:persona-border-none persona-composer-textarea",e.rows=1,e.style.fontFamily='var(--persona-input-font-family, var(--persona-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif))',e.style.fontWeight="var(--persona-input-font-weight, var(--persona-font-weight, 400))";let t=3,o=20;e.style.maxHeight=`${t*o}px`,e.style.overflowY="auto";let n=()=>{let d=parseFloat(e.style.maxHeight);return Number.isFinite(d)&&d>0?d:t*o},a=()=>{e.addEventListener("input",()=>{e.style.height="auto";let d=Math.min(e.scrollHeight,n());e.style.height=`${d}px`})};return e.style.border="none",e.style.outline="none",e.style.borderWidth="0",e.style.borderStyle="none",e.style.borderColor="transparent",e.addEventListener("focus",()=>{e.style.border="none",e.style.outline="none",e.style.borderWidth="0",e.style.borderStyle="none",e.style.borderColor="transparent",e.style.boxShadow="none"}),e.addEventListener("blur",()=>{e.style.border="none",e.style.outline="none"}),{textarea:e,attachAutoResize:a}},ql=r=>{var w,v,E,H,I,P,z,j,ie,ve,Xe,Ae;let e=(w=r==null?void 0:r.sendButton)!=null?w:{},t=(v=e.useIcon)!=null?v:!1,o=(E=e.iconText)!=null?E:"\u2191",n=e.iconName,a=(H=e.stopIconName)!=null?H:"square",s=(I=e.tooltipText)!=null?I:"Send message",i=(P=e.stopTooltipText)!=null?P:"Stop generating",d=(j=(z=r==null?void 0:r.copy)==null?void 0:z.sendButtonLabel)!=null?j:"Send",l=(ve=(ie=r==null?void 0:r.copy)==null?void 0:ie.stopButtonLabel)!=null?ve:"Stop",u=(Xe=e.showTooltip)!=null?Xe:!1,f=(Ae=e.size)!=null?Ae:"40px",p=e.backgroundColor,m=e.textColor,y=C("div","persona-send-button-wrapper"),h=C("button",t?"persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer":"persona-rounded-button persona-bg-persona-accent persona-px-4 persona-py-2 persona-text-sm persona-font-semibold disabled:persona-opacity-50 persona-cursor-pointer");h.type="submit",h.setAttribute("data-persona-composer-submit","");let T=null,M=null;if(t){h.style.width=f,h.style.height=f,h.style.minWidth=f,h.style.minHeight=f,h.style.fontSize="18px",h.style.lineHeight="1",h.innerHTML="",m?h.style.color=m:h.style.color="var(--persona-button-primary-fg, #ffffff)";let We=parseFloat(f)||24,Me=(m==null?void 0:m.trim())||"currentColor";n?(T=Ee(n,We,Me,2),T?h.appendChild(T):h.textContent=o):h.textContent=o,M=Ee(a,We,Me,2),p?h.style.backgroundColor=p:h.classList.add("persona-bg-persona-primary")}else h.textContent=d,m?h.style.color=m:h.classList.add("persona-text-white");e.borderWidth&&(h.style.borderWidth=e.borderWidth,h.style.borderStyle="solid"),e.borderColor&&(h.style.borderColor=e.borderColor),e.paddingX?(h.style.paddingLeft=e.paddingX,h.style.paddingRight=e.paddingX):(h.style.paddingLeft="",h.style.paddingRight=""),e.paddingY?(h.style.paddingTop=e.paddingY,h.style.paddingBottom=e.paddingY):(h.style.paddingTop="",h.style.paddingBottom="");let k=null;u&&s&&(k=C("div","persona-send-button-tooltip"),k.textContent=s,y.appendChild(k)),h.setAttribute("aria-label",s),y.appendChild(h);let L="send";return{button:h,wrapper:y,setMode:We=>{if(We===L)return;L=We;let Me=We==="stop"?i:s;if(h.setAttribute("aria-label",Me),k&&(k.textContent=Me),t){if(T&&M){let Ue=We==="stop"?M:T;h.replaceChildren(Ue)}}else h.textContent=We==="stop"?l:d}}},zl=r=>{var k,L,x,w,v,E,H,I,P,z,j,ie;let e=(k=r==null?void 0:r.voiceRecognition)!=null?k:{};if(!(e.enabled===!0))return null;let o=typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined"),n=((L=e.provider)==null?void 0:L.type)==="runtype";if(!(o||n))return null;let s=(w=(x=r==null?void 0:r.sendButton)==null?void 0:x.size)!=null?w:"40px",i=C("div","persona-send-button-wrapper"),d=C("button","persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer");d.type="button",d.setAttribute("data-persona-composer-mic",""),d.setAttribute("aria-label","Start voice recognition");let l=(v=e.iconName)!=null?v:"mic",u=(E=e.iconSize)!=null?E:s,f=parseFloat(u)||24,p=(I=e.backgroundColor)!=null?I:(H=r==null?void 0:r.sendButton)==null?void 0:H.backgroundColor,m=(z=e.iconColor)!=null?z:(P=r==null?void 0:r.sendButton)==null?void 0:P.textColor;d.style.width=u,d.style.height=u,d.style.minWidth=u,d.style.minHeight=u,d.style.fontSize="18px",d.style.lineHeight="1",m?d.style.color=m:d.style.color="var(--persona-text, #111827)";let h=Ee(l,f,m||"currentColor",1.5);h?d.appendChild(h):d.textContent="\u{1F3A4}",p&&(d.style.backgroundColor=p),e.borderWidth&&(d.style.borderWidth=e.borderWidth,d.style.borderStyle="solid"),e.borderColor&&(d.style.borderColor=e.borderColor),e.paddingX&&(d.style.paddingLeft=e.paddingX,d.style.paddingRight=e.paddingX),e.paddingY&&(d.style.paddingTop=e.paddingY,d.style.paddingBottom=e.paddingY),i.appendChild(d);let T=(j=e.tooltipText)!=null?j:"Start voice recognition";if(((ie=e.showTooltip)!=null?ie:!1)&&T){let ve=C("div","persona-send-button-tooltip");ve.textContent=T,i.appendChild(ve)}return{button:d,wrapper:i}},$l=r=>{var y,h,T,M,k,L,x,w;let e=(y=r==null?void 0:r.attachments)!=null?y:{};if(e.enabled!==!0)return null;let t=(T=(h=r==null?void 0:r.sendButton)==null?void 0:h.size)!=null?T:"40px",o=C("div","persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2");o.style.display="none";let n=C("input");n.type="file",n.accept=((M=e.allowedTypes)!=null?M:Tn).join(","),n.multiple=((k=e.maxFiles)!=null?k:4)>1,n.style.display="none",n.setAttribute("aria-label","Attach files");let a=C("div","persona-send-button-wrapper"),s=C("button","persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-attachment-button");s.type="button",s.setAttribute("aria-label",(L=e.buttonTooltipText)!=null?L:"Attach file");let i=(x=e.buttonIconName)!=null?x:"paperclip",d=t,l=parseFloat(d)||40,u=Math.round(l*.6);s.style.width=d,s.style.height=d,s.style.minWidth=d,s.style.minHeight=d,s.style.fontSize="18px",s.style.lineHeight="1",s.style.backgroundColor="transparent",s.style.color="var(--persona-primary, #111827)",s.style.border="none",s.style.borderRadius="6px",s.style.transition="background-color 0.15s ease",s.addEventListener("mouseenter",()=>{s.style.backgroundColor="var(--persona-palette-colors-black-alpha-50, rgba(0, 0, 0, 0.05))"}),s.addEventListener("mouseleave",()=>{s.style.backgroundColor="transparent"});let f=Ee(i,u,"currentColor",1.5);f?s.appendChild(f):s.textContent="\u{1F4CE}",s.addEventListener("click",v=>{v.preventDefault(),n.click()}),a.appendChild(s);let p=(w=e.buttonTooltipText)!=null?w:"Attach file",m=C("div","persona-send-button-tooltip");return m.textContent=p,a.appendChild(m),{button:s,wrapper:a,input:n,previewsContainer:o}},Vl=r=>{var s,i,d;let e=(s=r==null?void 0:r.statusIndicator)!=null?s:{},t=e.align==="left"?"persona-text-left":e.align==="center"?"persona-text-center":"persona-text-right",o=C("div",`persona-mt-2 ${t} persona-text-xs persona-text-persona-muted`);o.setAttribute("data-persona-composer-status","");let n=(i=e.visible)!=null?i:!0;o.style.display=n?"":"none";let a=(d=e.idleText)!=null?d:"Online";if(e.idleLink){let l=C("a");l.href=e.idleLink,l.target="_blank",l.rel="noopener noreferrer",l.textContent=a,l.style.color="inherit",l.style.textDecoration="none",o.appendChild(l)}else o.textContent=a;return o},jl=()=>C("div","persona-mb-3 persona-flex persona-flex-wrap persona-gap-2");var ns=r=>{var y,h,T,M,k,L;let{config:e}=r,t=C("div","persona-widget-footer persona-border-t-persona-divider persona-bg-persona-surface persona-px-6 persona-py-4");t.setAttribute("data-persona-theme-zone","composer");let o=jl(),n=C("form","persona-widget-composer persona-flex persona-flex-col persona-gap-2 persona-rounded-2xl persona-border persona-border-gray-200 persona-bg-persona-input-background persona-px-4 persona-py-3");n.setAttribute("data-persona-composer-form",""),n.style.outline="none";let{textarea:a,attachAutoResize:s}=Ul(e);s();let i=ql(e),d=zl(e),l=$l(e),u=Vl(e);l&&(l.previewsContainer.style.gap="8px",n.append(l.previewsContainer,l.input)),n.append(a);let f=C("div","persona-widget-composer__actions persona-flex persona-items-center persona-justify-between persona-w-full"),p=C("div","persona-widget-composer__left-actions persona-flex persona-items-center persona-gap-2"),m=C("div","persona-widget-composer__right-actions persona-flex persona-items-center persona-gap-1");return l&&p.append(l.wrapper),d&&m.append(d.wrapper),m.append(i.wrapper),f.append(p,m),n.append(f),n.addEventListener("click",x=>{x.target!==i.button&&x.target!==i.wrapper&&x.target!==(d==null?void 0:d.button)&&x.target!==(d==null?void 0:d.wrapper)&&x.target!==(l==null?void 0:l.button)&&x.target!==(l==null?void 0:l.wrapper)&&a.focus()}),t.append(o,n,u),{footer:t,suggestions:o,composerForm:n,textarea:a,sendButton:i.button,sendButtonWrapper:i.wrapper,micButton:(y=d==null?void 0:d.button)!=null?y:null,micButtonWrapper:(h=d==null?void 0:d.wrapper)!=null?h:null,statusText:u,attachmentButton:(T=l==null?void 0:l.button)!=null?T:null,attachmentButtonWrapper:(M=l==null?void 0:l.wrapper)!=null?M:null,attachmentInput:(k=l==null?void 0:l.input)!=null?k:null,attachmentPreviewsContainer:(L=l==null?void 0:l.previewsContainer)!=null?L:null,actionsRow:f,leftActions:p,rightActions:m,setSendButtonMode:i.setMode}};var Bx=()=>{let r=C("button","persona-pill-peek");r.type="button",r.setAttribute("data-persona-pill-peek",""),r.setAttribute("aria-label","Show conversation"),r.setAttribute("tabindex","-1");let e=C("span","persona-pill-peek__icon"),t=Ee("message-square",16,"currentColor",1.5);t&&e.appendChild(t);let o=C("span","persona-pill-peek__text"),n=C("span","persona-pill-peek__caret"),a=Ee("chevron-up",16,"currentColor",1.5);return a&&n.appendChild(a),r.append(e,o,n),{root:r,textNode:o}},Dx=r=>{var y,h,T,M,k,L;let{config:e}=r,t=C("div","persona-widget-footer persona-widget-footer--pill");t.setAttribute("data-persona-theme-zone","composer");let o=jl();o.style.display="none";let n=Vl(e);n.style.display="none";let{textarea:a,attachAutoResize:s}=Ul(e);a.style.maxHeight="100px",s();let i=ql(e),d=zl(e),l=$l(e);l&&l.previewsContainer.classList.add("persona-pill-composer__previews");let u=C("form","persona-widget-composer persona-pill-composer");u.setAttribute("data-persona-composer-form",""),u.style.outline="none";let f=C("div","persona-widget-composer__left-actions persona-pill-composer__left");l&&f.append(l.wrapper);let p=C("div","persona-widget-composer__right-actions persona-pill-composer__right");d&&p.append(d.wrapper),p.append(i.wrapper),u.addEventListener("click",x=>{x.target!==i.button&&x.target!==i.wrapper&&x.target!==(d==null?void 0:d.button)&&x.target!==(d==null?void 0:d.wrapper)&&x.target!==(l==null?void 0:l.button)&&x.target!==(l==null?void 0:l.wrapper)&&a.focus()}),l&&u.append(l.input),u.append(f,a,p),l&&t.append(l.previewsContainer),t.append(u,o,n);let m=u;return{footer:t,suggestions:o,composerForm:u,textarea:a,sendButton:i.button,sendButtonWrapper:i.wrapper,micButton:(y=d==null?void 0:d.button)!=null?y:null,micButtonWrapper:(h=d==null?void 0:d.wrapper)!=null?h:null,statusText:n,attachmentButton:(T=l==null?void 0:l.button)!=null?T:null,attachmentButtonWrapper:(M=l==null?void 0:l.wrapper)!=null?M:null,attachmentInput:(k=l==null?void 0:l.input)!=null?k:null,attachmentPreviewsContainer:(L=l==null?void 0:l.previewsContainer)!=null?L:null,actionsRow:m,leftActions:f,rightActions:p,setSendButtonMode:i.setMode}};var Ox=r=>{var u,f,p,m,y,h,T,M,k,L,x,w,v,E,H,I,P;let e=(f=(u=r==null?void 0:r.launcher)==null?void 0:u.enabled)!=null?f:!0,t=Lr(r);if(Kn(r)){let z=(m=(p=r==null?void 0:r.launcher)==null?void 0:p.composerBar)!=null?m:{},j=C("div","persona-widget-wrapper persona-fixed persona-transition");j.setAttribute("data-persona-composer-bar",""),j.dataset.state="collapsed",j.dataset.expandedSize=(y=z.expandedSize)!=null?y:"anchored",j.style.zIndex=String((T=(h=r==null?void 0:r.launcher)==null?void 0:h.zIndex)!=null?T:so);let ie=C("div","persona-widget-panel persona-relative persona-flex persona-flex-1 persona-min-h-0 persona-flex-col");ie.style.width="100%",j.appendChild(ie);let ve=C("div","persona-widget-pill-root");return ve.setAttribute("data-persona-composer-bar",""),ve.dataset.state="collapsed",ve.dataset.expandedSize=(M=z.expandedSize)!=null?M:"anchored",ve.style.zIndex=String((L=(k=r==null?void 0:r.launcher)==null?void 0:k.zIndex)!=null?L:so),{wrapper:j,panel:ie,pillRoot:ve}}if(t){let z=C("div","persona-relative persona-h-full persona-w-full persona-flex persona-flex-1 persona-min-h-0 persona-flex-col"),j=C("div","persona-relative persona-h-full persona-w-full persona-flex persona-flex-1 persona-min-h-0 persona-flex-col");return z.appendChild(j),{wrapper:z,panel:j}}if(!e){let z=C("div","persona-relative persona-h-full persona-flex persona-flex-col persona-flex-1 persona-min-h-0"),j=C("div","persona-relative persona-flex-1 persona-flex persona-flex-col persona-min-h-0"),ie=(w=(x=r==null?void 0:r.launcher)==null?void 0:x.width)!=null?w:"100%";return z.style.width=ie,j.style.width="100%",z.appendChild(j),{wrapper:z,panel:j}}let n=(v=r==null?void 0:r.launcher)!=null?v:{},a=n.position&&tn[n.position]?tn[n.position]:tn["bottom-right"],s=C("div",`persona-widget-wrapper persona-fixed ${a} persona-transition`);s.style.zIndex=String((H=(E=r==null?void 0:r.launcher)==null?void 0:E.zIndex)!=null?H:so);let i=C("div","persona-widget-panel persona-relative persona-min-h-[320px]"),d=(P=(I=r==null?void 0:r.launcher)==null?void 0:I.width)!=null?P:r==null?void 0:r.launcherWidth,l=d!=null?d:Wo;return i.style.width=l,i.style.maxWidth=l,s.appendChild(i),{wrapper:s,panel:i}},jv=(r,e)=>{var x,w,v,E,H,I,P,z,j;let t=C("div","persona-widget-container persona-relative persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-text-persona-primary");t.setAttribute("data-persona-theme-zone","container");let{button:o,wrapper:n}=Ol(r,{showClose:e,wrapperClassName:"persona-composer-bar-close",buttonSize:"16px",iconSize:"14px"});n.style.position="absolute",n.style.top="8px",n.style.right="8px",n.style.zIndex="10";let a=(v=(w=(x=r==null?void 0:r.launcher)==null?void 0:x.clearChat)==null?void 0:w.enabled)!=null?v:!0,s=null,i=null;if(a){let ie=_l(r,{wrapperClassName:"persona-composer-bar-clear-chat",buttonSize:"16px",iconSize:"14px"});s=ie.button,i=ie.wrapper,i.style.position="absolute",i.style.top="8px",i.style.right="32px",i.style.zIndex="10"}let d=C("span","persona-widget-header");d.setAttribute("data-persona-theme-zone","header"),d.style.display="none";let l=C("div","persona-widget-body persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-gap-6 persona-overflow-y-auto persona-bg-persona-container persona-px-6 persona-py-6");l.style.paddingTop="48px",l.id="persona-scroll-container",l.setAttribute("data-persona-theme-zone","messages"),l.style.setProperty("scrollbar-gutter","stable");let u=C("div","persona-rounded-2xl persona-bg-persona-surface persona-p-6");u.style.boxShadow="var(--persona-intro-card-shadow, 0 5px 15px rgba(15, 23, 42, 0.08))",u.setAttribute("data-persona-intro-card","");let f=C("h2","persona-text-lg persona-font-semibold persona-text-persona-primary");f.textContent=(H=(E=r==null?void 0:r.copy)==null?void 0:E.welcomeTitle)!=null?H:"Hello \u{1F44B}";let p=C("p","persona-mt-2 persona-text-sm persona-text-persona-muted");p.textContent=(P=(I=r==null?void 0:r.copy)==null?void 0:I.welcomeSubtitle)!=null?P:"Ask anything about your account or products.",u.append(f,p);let m=C("div","persona-flex persona-flex-col persona-gap-3"),y=(z=r==null?void 0:r.layout)==null?void 0:z.contentMaxWidth;y&&(m.style.maxWidth=y,m.style.marginLeft="auto",m.style.marginRight="auto",m.style.width="100%"),((j=r==null?void 0:r.copy)==null?void 0:j.showWelcomeCard)!==!1||(u.style.display="none",l.classList.remove("persona-gap-6"),l.classList.add("persona-gap-3")),l.append(u,m);let T=C("div","persona-composer-overlay persona-pointer-events-none");T.setAttribute("data-persona-composer-overlay",""),T.style.position="absolute",T.style.left="0",T.style.right="0",T.style.bottom="0",T.style.zIndex="20";let M=Dx({config:r}),{root:k,textNode:L}=Bx();return t.append(d,n,l,T),i&&t.appendChild(i),{container:t,body:l,messagesWrapper:m,composerOverlay:T,suggestions:M.suggestions,textarea:M.textarea,sendButton:M.sendButton,sendButtonWrapper:M.sendButtonWrapper,micButton:M.micButton,micButtonWrapper:M.micButtonWrapper,composerForm:M.composerForm,statusText:M.statusText,introTitle:f,introSubtitle:p,closeButton:o,closeButtonWrapper:n,clearChatButton:s,clearChatButtonWrapper:i,iconHolder:C("span"),headerTitle:C("span"),headerSubtitle:C("span"),header:d,footer:M.footer,attachmentButton:M.attachmentButton,attachmentButtonWrapper:M.attachmentButtonWrapper,attachmentInput:M.attachmentInput,attachmentPreviewsContainer:M.attachmentPreviewsContainer,actionsRow:M.actionsRow,leftActions:M.leftActions,rightActions:M.rightActions,setSendButtonMode:M.setSendButtonMode,peekBanner:k,peekTextNode:L}},_x=(r,e=!0)=>{var T,M,k,L,x,w,v,E,H;if(Kn(r))return jv(r,e);let t=C("div","persona-widget-container persona-flex persona-h-full persona-w-full persona-flex-1 persona-min-h-0 persona-flex-col persona-text-persona-primary persona-bg-persona-surface persona-rounded-2xl persona-overflow-hidden persona-border persona-border-persona-border");t.setAttribute("data-persona-theme-zone","container");let o=(T=r==null?void 0:r.layout)==null?void 0:T.header,n=((M=r==null?void 0:r.layout)==null?void 0:M.showHeader)!==!1,a=o?os(r,o,{showClose:e}):kn({config:r,showClose:e}),s=C("div","persona-widget-body persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-gap-6 persona-overflow-y-auto persona-bg-persona-container persona-px-6 persona-py-6");s.id="persona-scroll-container",s.setAttribute("data-persona-theme-zone","messages"),s.style.setProperty("scrollbar-gutter","stable");let i=C("div","persona-rounded-2xl persona-bg-persona-surface persona-p-6");i.style.boxShadow=Lr(r)?"none":"var(--persona-intro-card-shadow, 0 5px 15px rgba(15, 23, 42, 0.08))";let d=C("h2","persona-text-lg persona-font-semibold persona-text-persona-primary");d.textContent=(L=(k=r==null?void 0:r.copy)==null?void 0:k.welcomeTitle)!=null?L:"Hello \u{1F44B}";let l=C("p","persona-mt-2 persona-text-sm persona-text-persona-muted");l.textContent=(w=(x=r==null?void 0:r.copy)==null?void 0:x.welcomeSubtitle)!=null?w:"Ask anything about your account or products.",i.append(d,l);let u=C("div","persona-flex persona-flex-col persona-gap-3"),f=(v=r==null?void 0:r.layout)==null?void 0:v.contentMaxWidth;f&&(u.style.maxWidth=f,u.style.marginLeft="auto",u.style.marginRight="auto",u.style.width="100%"),i.setAttribute("data-persona-intro-card",""),((E=r==null?void 0:r.copy)==null?void 0:E.showWelcomeCard)!==!1||(i.style.display="none",s.classList.remove("persona-gap-6"),s.classList.add("persona-gap-3")),s.append(i,u);let m=ns({config:r}),y=((H=r==null?void 0:r.layout)==null?void 0:H.showFooter)!==!1;n?Ta(t,a,r):(a.header.style.display="none",Ta(t,a,r)),t.append(s);let h=C("div","persona-composer-overlay persona-pointer-events-none");return h.setAttribute("data-persona-composer-overlay",""),h.style.position="absolute",h.style.left="0",h.style.right="0",h.style.bottom="0",h.style.zIndex="20",y||(m.footer.style.display="none"),t.append(m.footer),t.append(h),{container:t,body:s,messagesWrapper:u,composerOverlay:h,suggestions:m.suggestions,textarea:m.textarea,sendButton:m.sendButton,sendButtonWrapper:m.sendButtonWrapper,micButton:m.micButton,micButtonWrapper:m.micButtonWrapper,composerForm:m.composerForm,statusText:m.statusText,introTitle:d,introSubtitle:l,closeButton:a.closeButton,closeButtonWrapper:a.closeButtonWrapper,clearChatButton:a.clearChatButton,clearChatButtonWrapper:a.clearChatButtonWrapper,iconHolder:a.iconHolder,headerTitle:a.headerTitle,headerSubtitle:a.headerSubtitle,header:a.header,footer:m.footer,attachmentButton:m.attachmentButton,attachmentButtonWrapper:m.attachmentButtonWrapper,attachmentInput:m.attachmentInput,attachmentPreviewsContainer:m.attachmentPreviewsContainer,actionsRow:m.actionsRow,leftActions:m.leftActions,rightActions:m.rightActions,setSendButtonMode:m.setSendButtonMode}};var Gv=r=>{switch(r){case"max_tool_calls":return"Stopped after calling a tool. Send a follow-up to continue.";case"length":return"Response cut off as max tokens reached. Ask for more to continue.";case"content_filter":return"The provider filtered this response.";case"error":return"Something went wrong generating this response.";default:return null}},Kv=(r,e)=>{if(!r)return null;let t=Gv(r);if(t===null)return null;let o=e==null?void 0:e[r],n=o!==void 0?o:t;return n||null},Xv=(r,e)=>{let t=C("div","persona-message-stop-reason persona-text-xs persona-mt-2 persona-italic");return t.setAttribute("data-stop-reason",r),t.setAttribute("role","note"),t.style.opacity="0.75",t.textContent=e,t},Qv=r=>{let e=r.toLowerCase();return e.startsWith("data:image/svg+xml")?!1:!!(/^(?:https?|blob):/i.test(r)||e.startsWith("data:image/")||!r.includes(":"))},ou=r=>{let e=r.toLowerCase();return e.startsWith("javascript:")||e.startsWith("data:text/html")||e.startsWith("data:text/javascript")||e.startsWith("data:text/xml")||e.startsWith("data:application/xhtml")||e.startsWith("data:image/svg+xml")?!1:!!(/^(?:https?|blob):/i.test(r)||e.startsWith("data:")||!r.includes(":"))},nu=320,Fx=320,Yv=r=>!r.contentParts||r.contentParts.length===0?[]:r.contentParts.filter(e=>e.type==="image"&&typeof e.image=="string"&&e.image.trim().length>0),Jv=r=>!r.contentParts||r.contentParts.length===0?[]:r.contentParts.filter(e=>e.type==="audio"&&typeof e.audio=="string"&&e.audio.trim().length>0),Zv=r=>!r.contentParts||r.contentParts.length===0?[]:r.contentParts.filter(e=>e.type==="video"&&typeof e.video=="string"&&e.video.trim().length>0),eC=r=>!r.contentParts||r.contentParts.length===0?[]:r.contentParts.filter(e=>e.type==="file"&&typeof e.data=="string"&&e.data.trim().length>0),tC=(r,e,t)=>{if(r.length===0)return null;try{let o=C("div","persona-flex persona-flex-col persona-gap-2");o.setAttribute("data-message-attachments","images"),e&&(o.style.marginBottom="8px");let n=0,a=!1,s=()=>{a||(a=!0,o.remove(),t==null||t())};return r.forEach((i,d)=>{var f;let l=C("img");l.alt=((f=i.alt)==null?void 0:f.trim())||`Attached image ${d+1}`,l.loading="lazy",l.decoding="async",l.referrerPolicy="no-referrer",l.style.display="block",l.style.width="100%",l.style.maxWidth=`${nu}px`,l.style.maxHeight=`${Fx}px`,l.style.height="auto",l.style.objectFit="contain",l.style.borderRadius="10px",l.style.backgroundColor="var(--persona-attachment-image-bg, var(--persona-container, #f3f4f6))",l.style.border="1px solid var(--persona-attachment-image-border, var(--persona-border, #e5e7eb))";let u=!1;n+=1,l.addEventListener("error",()=>{u||(u=!0,n=Math.max(0,n-1),l.remove(),n===0&&s())}),l.addEventListener("load",()=>{u=!0}),Qv(i.image)?(l.src=i.image,o.appendChild(l)):(u=!0,n=Math.max(0,n-1),l.remove())}),n===0?(s(),null):o}catch{return t==null||t(),null}},rC=r=>{if(r.length===0)return null;try{let e=C("div","persona-flex persona-flex-col persona-gap-2");e.setAttribute("data-message-attachments","audio");let t=0;return r.forEach(o=>{if(!ou(o.audio))return;let n=C("audio");n.controls=!0,n.preload="metadata",n.src=o.audio,n.style.display="block",n.style.width="100%",n.style.maxWidth=`${nu}px`,e.appendChild(n),t+=1}),t===0?(e.remove(),null):e}catch{return null}},oC=r=>{if(r.length===0)return null;try{let e=C("div","persona-flex persona-flex-col persona-gap-2");e.setAttribute("data-message-attachments","video");let t=0;return r.forEach(o=>{if(!ou(o.video))return;let n=C("video");n.controls=!0,n.preload="metadata",n.src=o.video,n.style.display="block",n.style.width="100%",n.style.maxWidth=`${nu}px`,n.style.maxHeight=`${Fx}px`,n.style.borderRadius="10px",n.style.backgroundColor="var(--persona-attachment-image-bg, var(--persona-container, #f3f4f6))",e.appendChild(n),t+=1}),t===0?(e.remove(),null):e}catch{return null}},nC=r=>{if(r.length===0)return null;try{let e=C("div","persona-flex persona-flex-col persona-gap-2");e.setAttribute("data-message-attachments","files");let t=0;return r.forEach(o=>{if(!ou(o.data))return;let n=C("a");n.href=o.data,n.download=o.filename,n.target="_blank",n.rel="noopener noreferrer",n.textContent=o.filename,n.className="persona-message-file-attachment",n.style.display="inline-flex",n.style.alignItems="center",n.style.gap="6px",n.style.padding="6px 10px",n.style.borderRadius="8px",n.style.fontSize="0.875rem",n.style.textDecoration="underline",n.style.backgroundColor="var(--persona-attachment-file-bg, var(--persona-container, #f3f4f6))",n.style.border="1px solid var(--persona-attachment-file-border, var(--persona-border, #e5e7eb))",n.style.color="inherit",e.appendChild(n),t+=1}),t===0?(e.remove(),null):e}catch{return null}},Ma=()=>{let r=document.createElement("div");r.className="persona-flex persona-items-center persona-space-x-1 persona-h-5 persona-mt-2";let e=document.createElement("div");e.className="persona-animate-typing persona-rounded-full persona-h-1.5 persona-w-1.5",e.style.backgroundColor="currentColor",e.style.opacity="0.4",e.style.animationDelay="0ms";let t=document.createElement("div");t.className="persona-animate-typing persona-rounded-full persona-h-1.5 persona-w-1.5",t.style.backgroundColor="currentColor",t.style.opacity="0.4",t.style.animationDelay="250ms";let o=document.createElement("div");o.className="persona-animate-typing persona-rounded-full persona-h-1.5 persona-w-1.5",o.style.backgroundColor="currentColor",o.style.opacity="0.4",o.style.animationDelay="500ms";let n=document.createElement("span");return n.className="persona-sr-only",n.textContent="Loading",r.appendChild(e),r.appendChild(t),r.appendChild(o),r.appendChild(n),r},au=(r,e,t)=>{let o={config:t!=null?t:{},streaming:!0,location:r,defaultRenderer:Ma};if(e){let n=e(o);if(n!==null)return n}return Ma()},aC=(r,e)=>{let t=C("div","persona-flex-shrink-0 persona-w-8 persona-h-8 persona-rounded-full persona-flex persona-items-center persona-justify-center persona-text-sm"),o=e==="user"?r.userAvatar:r.assistantAvatar;if(o)if(o.startsWith("http")||o.startsWith("/")||o.startsWith("data:")){let n=C("img");n.src=o,n.alt=e==="user"?"User":"Assistant",n.className="persona-w-full persona-h-full persona-rounded-full persona-object-cover",t.appendChild(n)}else t.textContent=o,t.classList.add(e==="user"?"persona-bg-persona-accent":"persona-bg-persona-primary","persona-text-white");else t.textContent=e==="user"?"U":"A",t.classList.add(e==="user"?"persona-bg-persona-accent":"persona-bg-persona-primary","persona-text-white");return t},Nx=(r,e)=>{let t=C("div","persona-text-xs persona-text-persona-muted"),o=new Date(r.createdAt);return e.format?t.textContent=e.format(o):t.textContent=o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),t},sC=(r,e="bubble")=>{let t=["persona-message-bubble","persona-max-w-[85%]"];switch(e){case"flat":r==="user"?t.push("persona-message-user-bubble","persona-ml-auto","persona-text-persona-primary","persona-py-2"):t.push("persona-message-assistant-bubble","persona-text-persona-primary","persona-py-2");break;case"minimal":t.push("persona-text-sm","persona-leading-relaxed"),r==="user"?t.push("persona-message-user-bubble","persona-ml-auto","persona-bg-persona-accent","persona-text-white","persona-px-3","persona-py-2","persona-rounded-lg"):t.push("persona-message-assistant-bubble","persona-bg-persona-surface","persona-text-persona-primary","persona-px-3","persona-py-2","persona-rounded-lg");break;default:t.push("persona-rounded-2xl","persona-text-sm","persona-leading-relaxed","persona-shadow-sm"),r==="user"?t.push("persona-message-user-bubble","persona-ml-auto","persona-bg-persona-accent","persona-text-white","persona-px-5","persona-py-3"):t.push("persona-message-assistant-bubble","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-text-persona-primary","persona-px-5","persona-py-3");break}return t},su=(r,e,t)=>{var m,y,h,T,M,k;let o=(m=e.showCopy)!=null?m:!0,n=(y=e.showUpvote)!=null?y:!0,a=(h=e.showDownvote)!=null?h:!0;if(!o&&!n&&!a){let L=C("div");return L.style.display="none",L.id=`actions-${r.id}`,L.setAttribute("data-actions-for",r.id),L}let s=(T=e.visibility)!=null?T:"hover",i=(M=e.align)!=null?M:"right",d=(k=e.layout)!=null?k:"pill-inside",l={left:"persona-message-actions-left",center:"persona-message-actions-center",right:"persona-message-actions-right"}[i],u={"pill-inside":"persona-message-actions-pill","row-inside":"persona-message-actions-row"}[d],f=C("div",`persona-message-actions persona-flex persona-items-center persona-gap-1 persona-mt-2 ${l} ${u} ${s==="hover"?"persona-message-actions-hover":""}`);f.id=`actions-${r.id}`,f.setAttribute("data-actions-for",r.id);let p=(L,x,w)=>{let v=Br({icon:L,label:x,size:14,className:"persona-message-action-btn"});return v.setAttribute("data-action",w),v};return o&&f.appendChild(p("copy","Copy message","copy")),n&&f.appendChild(p("thumbs-up","Upvote","upvote")),a&&f.appendChild(p("thumbs-down","Downvote","downvote")),f},as=(r,e,t,o,n,a)=>{var Z,ne,me,be,ye,Y,ge,Oe,ce,ae,Q,Tt,Ye,De,le,nt,Re;let s=t!=null?t:{},i=(Z=s.layout)!=null?Z:"bubble",d=s.avatar,l=s.timestamp,u=(ne=d==null?void 0:d.show)!=null?ne:!1,f=(me=l==null?void 0:l.show)!=null?me:!1,p=(be=d==null?void 0:d.position)!=null?be:"left",m=(ye=l==null?void 0:l.position)!=null?ye:"below",y=sC(r.role,i),h=C("div",y.join(" "));h.id=`bubble-${r.id}`,h.setAttribute("data-message-id",r.id),h.setAttribute("data-persona-theme-zone",r.role==="user"?"user-message":"assistant-message"),r.role==="user"?(h.style.backgroundColor="var(--persona-message-user-bg, var(--persona-accent))",h.style.color="var(--persona-message-user-text, white)"):r.role==="assistant"&&(h.style.backgroundColor="var(--persona-message-assistant-bg, var(--persona-surface))",h.style.color="var(--persona-message-assistant-text, var(--persona-text))");let T=Yv(r),M=(ge=(Y=r.content)==null?void 0:Y.trim())!=null?ge:"",L=T.length>0&&M===ll,x=Wl((ce=(Oe=a==null?void 0:a.widgetConfig)==null?void 0:Oe.features)==null?void 0:ce.streamAnimation),w=(Tt=(Q=(ae=a==null?void 0:a.widgetConfig)==null?void 0:ae.features)==null?void 0:Q.streamAnimation)==null?void 0:Tt.plugins,v=r.role==="assistant"&&x.type!=="none"?ni(x.type,w):null,E=r.role==="assistant"&&((Ye=v==null?void 0:v.isAnimating)==null?void 0:Ye.call(v,r))===!0,H=r.role==="assistant"&&v!==null&&(!!r.streaming||E);H&&(v!=null&&v.bubbleClass)&&h.classList.add(v.bubbleClass);let I=document.createElement("div");I.classList.add("persona-message-content"),H&&v&&(v.containerClass&&I.classList.add(v.containerClass),I.style.setProperty("--persona-stream-step",`${x.speed}ms`),I.style.setProperty("--persona-stream-duration",`${x.duration}ms`));let P=H?Bl((De=r.content)!=null?De:"",x.buffer,v,r,!!r.streaming):(le=r.content)!=null?le:"",z=e({text:P,message:r,streaming:!!r.streaming,raw:r.rawContent}),j=z;H&&(v==null?void 0:v.wrap)==="char"?j=ai(z,"char",r.id,{skipTags:v.skipTags}):H&&(v==null?void 0:v.wrap)==="word"&&(j=ai(z,"word",r.id,{skipTags:v.skipTags}));let ie=null;if(L?(ie=document.createElement("div"),ie.innerHTML=j,ie.style.display="none",I.appendChild(ie)):I.innerHTML=j,H&&(v!=null&&v.useCaret)&&!L&&M){let K=Dl(),he=I.querySelectorAll(".persona-stream-char, .persona-stream-word"),it=he[he.length-1];if(it!=null&&it.parentNode)it.parentNode.insertBefore(K,it.nextSibling);else{let Pt=I.lastElementChild;Pt?Pt.appendChild(K):I.appendChild(K)}}if(f&&m==="inline"&&r.createdAt){let K=Nx(r,l);K.classList.add("persona-ml-2","persona-inline"),I.appendChild(K)}if(T.length>0){let K=tC(T,!L&&!!M,()=>{L&&ie&&(ie.style.display="")});K?h.appendChild(K):L&&ie&&(ie.style.display="")}let ve=Jv(r);if(ve.length>0){let K=rC(ve);K&&h.appendChild(K)}let Xe=Zv(r);if(Xe.length>0){let K=oC(Xe);K&&h.appendChild(K)}let Ae=eC(r);if(Ae.length>0){let K=nC(Ae);K&&h.appendChild(K)}if(h.appendChild(I),f&&m==="below"&&r.createdAt){let K=Nx(r,l);K.classList.add("persona-mt-1"),h.appendChild(K)}let We=r.role==="assistant"?Kv(r.stopReason,(Re=(nt=a==null?void 0:a.widgetConfig)==null?void 0:nt.copy)==null?void 0:Re.stopReasonNotice):null;if(r.streaming&&r.role==="assistant"){let K=!!(P&&P.trim()),he=x.placeholder==="skeleton",it=he&&x.buffer==="line"&&K;if(K)it&&h.appendChild(si());else if(he)h.appendChild(si());else{let Pt=au("inline",a==null?void 0:a.loadingIndicatorRenderer,a==null?void 0:a.widgetConfig);Pt&&h.appendChild(Pt)}}if(We&&r.stopReason&&!r.streaming&&(M||(I.style.display="none"),h.appendChild(Xv(r.stopReason,We))),r.role==="assistant"&&!r.streaming&&r.content&&r.content.trim()&&(o==null?void 0:o.enabled)!==!1&&o){let K=su(r,o,n);h.appendChild(K)}if(!u||r.role==="system")return h;let Ue=C("div",`persona-flex persona-gap-2 ${r.role==="user"?"persona-flex-row-reverse":""}`),Be=aC(d,r.role);return p==="right"||p==="left"&&r.role==="user"?Ue.append(h,Be):Ue.append(Be,h),h.classList.remove("persona-max-w-[85%]"),h.classList.add("persona-max-w-[calc(85%-2.5rem)]"),Ue},Ux=(r,e,t,o,n,a)=>{let s=t!=null?t:{};return r.role==="user"&&s.renderUserMessage?s.renderUserMessage({message:r,config:{},streaming:!!r.streaming}):r.role==="assistant"&&s.renderAssistantMessage?s.renderAssistantMessage({message:r,config:{},streaming:!!r.streaming}):as(r,e,t,o,n,a)};var ss=new Set,iC=(r,e)=>e==null?!1:typeof e=="string"?(r.textContent=e,!0):(r.appendChild(e),!0),lC=(r,e)=>{var o,n;let t=(n=(o=r.reasoning)==null?void 0:o.chunks.join("").trim())!=null?n:"";return t?t.split(/\r?\n/).map(a=>a.trim()).filter(Boolean).slice(0,e).join(`
|
|
72
|
+
`):""},qx=(r,e)=>{let t=ss.has(r),o=e.querySelector('button[data-expand-header="true"]'),n=e.querySelector(".persona-border-t"),a=e.querySelector('[data-persona-collapsed-preview="reasoning"]');if(!o||!n)return;o.setAttribute("aria-expanded",t?"true":"false");let s=o.querySelector(".persona-ml-auto"),i=s==null?void 0:s.querySelector(":scope > .persona-flex.persona-items-center");if(i){i.innerHTML="";let l=Ee(t?"chevron-up":"chevron-down",16,"currentColor",2);l?i.appendChild(l):i.textContent=t?"Hide":"Show"}n.style.display=t?"":"none",a&&(a.style.display=t?"none":a.textContent||a.childNodes.length?"":"none")},iu=(r,e)=>{var Xe,Ae,We,Me,Ue,Be,Z,ne,me,be,ye;let t=r.reasoning,o=C("div",["persona-message-bubble","persona-reasoning-bubble","persona-w-full","persona-max-w-[85%]","persona-rounded-2xl","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-text-persona-primary","persona-shadow-sm","persona-overflow-hidden","persona-px-0","persona-py-0"].join(" "));if(o.id=`bubble-${r.id}`,o.setAttribute("data-message-id",r.id),!t)return o;let n=(Ae=(Xe=e==null?void 0:e.features)==null?void 0:Xe.reasoningDisplay)!=null?Ae:{},a=n.expandable!==!1,s=a&&ss.has(r.id),i=t.status!=="complete",d=lC(r,(We=n.previewMaxLines)!=null?We:3),l=C("button",a?"persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-pointer persona-border-none":"persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-default persona-border-none");l.type="button",a&&(l.setAttribute("aria-expanded",s?"true":"false"),l.setAttribute("data-expand-header","true")),l.setAttribute("data-bubble-type","reasoning");let u=C("div","persona-flex persona-flex-col persona-text-left"),f=C("span","persona-text-xs persona-text-persona-primary"),p="Thinking...",m=(Me=e==null?void 0:e.reasoning)!=null?Me:{},y=String((Ue=t.startedAt)!=null?Ue:Date.now()),h=()=>{let Y=C("span","");return Y.setAttribute("data-tool-elapsed",y),Y.textContent=el(t),Y},T=(Be=m.renderCollapsedSummary)==null?void 0:Be.call(m,{message:r,reasoning:t,defaultSummary:p,previewText:d,isActive:i,config:e!=null?e:{},elapsed:el(t),createElapsedElement:h});typeof T=="string"&&T.trim()?(f.textContent=T,u.appendChild(f)):T instanceof HTMLElement?u.appendChild(T):(f.textContent=p,u.appendChild(f));let M=C("span","persona-text-xs persona-text-persona-primary");M.textContent=Yh(t),u.appendChild(M);let k=(Z=n.loadingAnimation)!=null?Z:"none",L=m.activeTextTemplate,x=m.completeTextTemplate,w=i?L:x,v=T instanceof HTMLElement,E=(Y,ge,Oe)=>{let ce=Oe;for(let ae of ge){let Q=C("span","persona-tool-char");Q.style.setProperty("--char-index",String(ce)),Q.textContent=ae===" "?"\xA0":ae,Y.appendChild(Q),ce++}return ce},H=(Y,ge)=>{f.textContent="";let Oe=tl(Y,""),ce=0;for(let ae of Oe){let Q=ae.styles.length>0?(()=>{let Tt=C("span",ae.styles.map(Ye=>`persona-tool-text-${Ye}`).join(" "));return f.appendChild(Tt),Tt})():f;if(ae.isDuration&&i)Q.appendChild(h());else{let Tt=ae.isDuration?el(t):ae.text;ge?ce=E(Q,Tt,ce):Q.appendChild(document.createTextNode(Tt))}}};if(!v&&w)if(M.style.display="none",f.style.display="",i&&k!=="none"){let Y=(ne=m.loadingAnimationDuration)!=null?ne:2e3;f.setAttribute("data-preserve-animation","true"),k==="pulse"?(f.classList.add("persona-tool-loading-pulse"),f.style.setProperty("--persona-tool-anim-duration",`${Y}ms`),H(w,!1)):(f.classList.add(`persona-tool-loading-${k}`),f.style.setProperty("--persona-tool-anim-duration",`${Y}ms`),k==="shimmer-color"&&(m.loadingAnimationColor&&f.style.setProperty("--persona-tool-anim-color",m.loadingAnimationColor),m.loadingAnimationSecondaryColor&&f.style.setProperty("--persona-tool-anim-secondary-color",m.loadingAnimationSecondaryColor)),H(w,!0))}else H(w,!1);else if(!v&&i&&k!=="none"){f.style.display="";let Y=(me=m.loadingAnimationDuration)!=null?me:2e3;if(f.setAttribute("data-preserve-animation","true"),k==="pulse")f.classList.add("persona-tool-loading-pulse"),f.style.setProperty("--persona-tool-anim-duration",`${Y}ms`);else{f.classList.add(`persona-tool-loading-${k}`),f.style.setProperty("--persona-tool-anim-duration",`${Y}ms`),k==="shimmer-color"&&(m.loadingAnimationColor&&f.style.setProperty("--persona-tool-anim-color",m.loadingAnimationColor),m.loadingAnimationSecondaryColor&&f.style.setProperty("--persona-tool-anim-secondary-color",m.loadingAnimationSecondaryColor));let ge=f.textContent||p;f.textContent="",E(f,ge,0)}t.status==="complete"&&(f.style.display="none")}else v||(t.status==="complete"?f.style.display="none":f.style.display="");let I=null;if(a){I=C("div","persona-flex persona-items-center");let ge=Ee(s?"chevron-up":"chevron-down",16,"currentColor",2);ge?I.appendChild(ge):I.textContent=s?"Hide":"Show";let Oe=C("div","persona-flex persona-items-center persona-ml-auto");Oe.append(I),l.append(u,Oe)}else l.append(u);let P=C("div","persona-px-4 persona-py-3 persona-text-xs persona-leading-snug persona-text-persona-muted");if(P.setAttribute("data-persona-collapsed-preview","reasoning"),P.style.display="none",P.style.whiteSpace="pre-wrap",!s&&i&&n.activePreview&&d){let Y=(ye=(be=e==null?void 0:e.reasoning)==null?void 0:be.renderCollapsedPreview)==null?void 0:ye.call(be,{message:r,reasoning:t,defaultPreview:d,isActive:i,config:e!=null?e:{}});iC(P,Y)||(P.textContent=d),P.style.display=""}if(!s&&i&&n.activeMinHeight&&(o.style.minHeight=n.activeMinHeight),!a)return o.append(l,P),o;let z=C("div","persona-border-t persona-border-gray-200 persona-bg-gray-50 persona-px-4 persona-py-3");z.style.display=s?"":"none";let j=t.chunks.join(""),ie=C("div","persona-whitespace-pre-wrap persona-text-xs persona-leading-snug persona-text-persona-muted");return ie.textContent=j||(t.status==="complete"?"No additional context was shared.":"Waiting for details\u2026"),z.appendChild(ie),(()=>{if(l.setAttribute("aria-expanded",s?"true":"false"),I){I.innerHTML="";let ge=Ee(s?"chevron-up":"chevron-down",16,"currentColor",2);ge?I.appendChild(ge):I.textContent=s?"Hide":"Show"}z.style.display=s?"":"none",P.style.display=s?"none":P.textContent||P.childNodes.length?"":"none"})(),o.append(l,P,z),o};var is=new Set,dC=(r,e)=>e==null?!1:typeof e=="string"?(r.textContent=e,!0):(r.appendChild(e),!0),cC=(r,e)=>{var a;let t=r.toolCall;if(!t)return"";let o=((a=t.chunks)!=null?a:[]).join("").trim();if(o)return o.split(/\r?\n/).map(i=>i.trim()).filter(Boolean).slice(-e).join(`
|
|
73
|
+
`);let n=Ya(t.args).trim();return n?n.split(/\r?\n/).map(s=>s.trim()).filter(Boolean).slice(0,e).join(`
|
|
74
|
+
`):""},pC=(r,e)=>{var u,f,p,m,y;let t=r.toolCall,o=(u=e==null?void 0:e.features)==null?void 0:u.toolCallDisplay,n=(f=o==null?void 0:o.collapsedMode)!=null?f:"tool-call",a=cC(r,(p=o==null?void 0:o.previewMaxLines)!=null?p:3),s=t?Jh(t):"";if(!t)return{summary:s,previewText:a,isActive:!1};let i=t.status!=="complete",d=(m=e==null?void 0:e.toolCall)!=null?m:{},l=s;return n==="tool-name"?l=((y=t.name)==null?void 0:y.trim())||s:n==="tool-preview"&&a&&(l=a),i&&d.activeTextTemplate?l=Vd(t,d.activeTextTemplate,l):!i&&d.completeTextTemplate&&(l=Vd(t,d.completeTextTemplate,l)),{summary:l,previewText:a,isActive:i}},zx=(r,e,t)=>{var u;let o=is.has(r),n=(u=t==null?void 0:t.toolCall)!=null?u:{},a=e.querySelector('button[data-expand-header="true"]'),s=e.querySelector(".persona-border-t"),i=e.querySelector('[data-persona-collapsed-preview="tool"]');if(!a||!s)return;a.setAttribute("aria-expanded",o?"true":"false");let d=a.querySelector(".persona-ml-auto"),l=d==null?void 0:d.querySelector(":scope > .persona-flex.persona-items-center");if(l){l.innerHTML="";let f=n.toggleTextColor||n.headerTextColor||"currentColor",p=Ee(o?"chevron-up":"chevron-down",16,f,2);p?l.appendChild(p):l.textContent=o?"Hide":"Show"}s.style.display=o?"":"none",i&&(i.style.display=o?"none":i.textContent||i.childNodes.length?"":"none")},lu=(r,e)=>{var j,ie,ve,Xe,Ae,We,Me,Ue,Be;let t=r.toolCall,o=(j=e==null?void 0:e.toolCall)!=null?j:{},n=C("div",["persona-message-bubble","persona-tool-bubble","persona-w-full","persona-max-w-[85%]","persona-rounded-2xl","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-text-persona-primary","persona-shadow-sm","persona-overflow-hidden","persona-px-0","persona-py-0"].join(" "));if(n.id=`bubble-${r.id}`,n.setAttribute("data-message-id",r.id),o.backgroundColor&&(n.style.backgroundColor=o.backgroundColor),o.borderColor&&(n.style.borderColor=o.borderColor),o.borderWidth&&(n.style.borderWidth=o.borderWidth),o.borderRadius&&(n.style.borderRadius=o.borderRadius),n.style.boxShadow=o.shadow!==void 0?o.shadow.trim()===""?"none":o.shadow:"var(--persona-tool-bubble-shadow, 0 5px 15px rgba(15, 23, 42, 0.08))",!t)return n;let a=(ve=(ie=e==null?void 0:e.features)==null?void 0:ie.toolCallDisplay)!=null?ve:{},s=a.expandable!==!1,i=s&&is.has(r.id),{summary:d,previewText:l,isActive:u}=pC(r,e),f=C("button",s?"persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-pointer persona-border-none":"persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-default persona-border-none");f.type="button",s&&(f.setAttribute("aria-expanded",i?"true":"false"),f.setAttribute("data-expand-header","true")),f.setAttribute("data-bubble-type","tool"),o.headerBackgroundColor&&(f.style.backgroundColor=o.headerBackgroundColor),o.headerPaddingX&&(f.style.paddingLeft=o.headerPaddingX,f.style.paddingRight=o.headerPaddingX),o.headerPaddingY&&(f.style.paddingTop=o.headerPaddingY,f.style.paddingBottom=o.headerPaddingY);let p=C("div","persona-flex persona-flex-col persona-text-left"),m=C("span","persona-text-xs persona-text-persona-primary");o.headerTextColor&&(m.style.color=o.headerTextColor);let y=String((Xe=t.startedAt)!=null?Xe:Date.now()),h=()=>{let Z=C("span","");return Z.setAttribute("data-tool-elapsed",y),Z.textContent=Xs(t),Z},T=(We=o.renderCollapsedSummary)==null?void 0:We.call(o,{message:r,toolCall:t,defaultSummary:d,previewText:l,collapsedMode:(Ae=a.collapsedMode)!=null?Ae:"tool-call",isActive:u,config:e!=null?e:{},elapsed:Xs(t),createElapsedElement:h});typeof T=="string"&&T.trim()?(m.textContent=T,p.appendChild(m)):T instanceof HTMLElement?p.appendChild(T):(m.textContent=d,p.appendChild(m));let M=(Me=a.loadingAnimation)!=null?Me:"none",k=o.activeTextTemplate,L=o.completeTextTemplate,x=u?k:L,w=T instanceof HTMLElement,v=(Z,ne,me)=>{let be=me;for(let ye of ne){let Y=C("span","persona-tool-char");Y.style.setProperty("--char-index",String(be)),Y.textContent=ye===" "?"\xA0":ye,Z.appendChild(Y),be++}return be},E=(Z,ne)=>{var Y;m.textContent="";let me=((Y=t.name)==null?void 0:Y.trim())||"tool",be=tl(Z,me),ye=0;for(let ge of be){let Oe=ge.styles.length>0?(()=>{let ce=C("span",ge.styles.map(ae=>`persona-tool-text-${ae}`).join(" "));return m.appendChild(ce),ce})():m;if(ge.isDuration&&u)Oe.appendChild(h());else{let ce=ge.isDuration?Xs(t):ge.text;ne?ye=v(Oe,ce,ye):Oe.appendChild(document.createTextNode(ce))}}};if(!w)if(u&&M!=="none"){let Z=(Ue=o.loadingAnimationDuration)!=null?Ue:2e3;if(m.setAttribute("data-preserve-animation","true"),M==="pulse")m.classList.add("persona-tool-loading-pulse"),m.style.setProperty("--persona-tool-anim-duration",`${Z}ms`),x&&E(x,!1);else if(m.classList.add(`persona-tool-loading-${M}`),m.style.setProperty("--persona-tool-anim-duration",`${Z}ms`),M==="shimmer-color"&&(o.loadingAnimationColor&&m.style.setProperty("--persona-tool-anim-color",o.loadingAnimationColor),o.loadingAnimationSecondaryColor&&m.style.setProperty("--persona-tool-anim-secondary-color",o.loadingAnimationSecondaryColor)),x)E(x,!0);else{let ne=m.textContent||d;m.textContent="",v(m,ne,0)}}else x&&E(x,!1);let H=null;if(s){H=C("div","persona-flex persona-items-center");let Z=o.toggleTextColor||o.headerTextColor||"currentColor",ne=Ee(i?"chevron-up":"chevron-down",16,Z,2);ne?H.appendChild(ne):H.textContent=i?"Hide":"Show";let me=C("div","persona-flex persona-items-center persona-gap-2 persona-ml-auto");me.append(H),f.append(p,me)}else f.append(p);let I=C("div","persona-px-4 persona-py-3 persona-text-xs persona-leading-snug persona-text-persona-muted");if(I.setAttribute("data-persona-collapsed-preview","tool"),I.style.display="none",I.style.whiteSpace="pre-wrap",!i&&u&&a.activePreview&&l){let Z=(Be=o.renderCollapsedPreview)==null?void 0:Be.call(o,{message:r,toolCall:t,defaultPreview:l,isActive:u,config:e!=null?e:{}});dC(I,Z)||(I.textContent=l),I.style.display=""}if(!i&&u&&a.activeMinHeight&&(n.style.minHeight=a.activeMinHeight),!s)return n.append(f,I),n;let P=C("div","persona-border-t persona-border-gray-200 persona-bg-gray-50 persona-space-y-3 persona-px-4 persona-py-3");if(P.style.display=i?"":"none",o.contentBackgroundColor&&(P.style.backgroundColor=o.contentBackgroundColor),o.contentTextColor&&(P.style.color=o.contentTextColor),o.contentPaddingX&&(P.style.paddingLeft=o.contentPaddingX,P.style.paddingRight=o.contentPaddingX),o.contentPaddingY&&(P.style.paddingTop=o.contentPaddingY,P.style.paddingBottom=o.contentPaddingY),t.name){let Z=C("div","persona-text-xs persona-text-persona-muted persona-italic");o.contentTextColor?Z.style.color=o.contentTextColor:o.headerTextColor&&(Z.style.color=o.headerTextColor),Z.textContent=t.name,P.appendChild(Z)}if(t.args!==void 0){let Z=C("div","persona-space-y-1"),ne=C("div","persona-text-xs persona-text-persona-muted");o.labelTextColor&&(ne.style.color=o.labelTextColor),ne.textContent="Arguments";let me=C("pre","persona-max-h-48 persona-overflow-auto persona-whitespace-pre-wrap persona-rounded-lg persona-border persona-border-gray-100 persona-bg-white persona-px-3 persona-py-2 persona-text-xs persona-text-persona-primary");me.style.fontSize="0.75rem",me.style.lineHeight="1rem",o.codeBlockBackgroundColor&&(me.style.backgroundColor=o.codeBlockBackgroundColor),o.codeBlockBorderColor&&(me.style.borderColor=o.codeBlockBorderColor),o.codeBlockTextColor&&(me.style.color=o.codeBlockTextColor),me.textContent=Ya(t.args),Z.append(ne,me),P.appendChild(Z)}if(t.chunks&&t.chunks.length){let Z=C("div","persona-space-y-1"),ne=C("div","persona-text-xs persona-text-persona-muted");o.labelTextColor&&(ne.style.color=o.labelTextColor),ne.textContent="Activity";let me=C("pre","persona-max-h-48 persona-overflow-auto persona-whitespace-pre-wrap persona-rounded-lg persona-border persona-border-gray-100 persona-bg-white persona-px-3 persona-py-2 persona-text-xs persona-text-persona-primary");me.style.fontSize="0.75rem",me.style.lineHeight="1rem",o.codeBlockBackgroundColor&&(me.style.backgroundColor=o.codeBlockBackgroundColor),o.codeBlockBorderColor&&(me.style.borderColor=o.codeBlockBorderColor),o.codeBlockTextColor&&(me.style.color=o.codeBlockTextColor),me.textContent=t.chunks.join(""),Z.append(ne,me),P.appendChild(Z)}if(t.status==="complete"&&t.result!==void 0){let Z=C("div","persona-space-y-1"),ne=C("div","persona-text-xs persona-text-persona-muted");o.labelTextColor&&(ne.style.color=o.labelTextColor),ne.textContent="Result";let me=C("pre","persona-max-h-48 persona-overflow-auto persona-whitespace-pre-wrap persona-rounded-lg persona-border persona-border-gray-100 persona-bg-white persona-px-3 persona-py-2 persona-text-xs persona-text-persona-primary");me.style.fontSize="0.75rem",me.style.lineHeight="1rem",o.codeBlockBackgroundColor&&(me.style.backgroundColor=o.codeBlockBackgroundColor),o.codeBlockBorderColor&&(me.style.borderColor=o.codeBlockBorderColor),o.codeBlockTextColor&&(me.style.color=o.codeBlockTextColor),me.textContent=Ya(t.result),Z.append(ne,me),P.appendChild(Z)}if(t.status==="complete"&&typeof t.duration=="number"){let Z=C("div","persona-text-xs persona-text-persona-muted");o.contentTextColor&&(Z.style.color=o.contentTextColor),Z.textContent=`Duration: ${t.duration}ms`,P.appendChild(Z)}return(()=>{if(f.setAttribute("aria-expanded",i?"true":"false"),H){H.innerHTML="";let Z=o.toggleTextColor||o.headerTextColor||"currentColor",ne=Ee(i?"chevron-up":"chevron-down",16,Z,2);ne?H.appendChild(ne):H.textContent=i?"Hide":"Show"}P.style.display=i?"":"none",I.style.display=i?"none":I.textContent||I.childNodes.length?"":"none"})(),n.append(f,I,P),n};var Gl=new Map,uC=r=>{let t=(r.startsWith(Cn)?r.slice(Cn.length):r).replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[_\-\s.]+/).filter(Boolean);if(t.length===0)return r;let o=t.join(" ").toLowerCase();return o.charAt(0).toUpperCase()+o.slice(1)},$x=r=>(r==null?void 0:r.approval)!==!1?r==null?void 0:r.approval:void 0,Vx=(r,e)=>{var o,n,a;let t=(n=(o=$x(e))==null?void 0:o.detailsDisplay)!=null?n:"collapsed";return(a=Gl.get(r))!=null?a:t==="expanded"},jx=(r,e,t)=>{var s,i;let o=$x(t);r.setAttribute("aria-expanded",e?"true":"false");let n=r.querySelector("[data-approval-details-label]");n&&(n.textContent=e?(s=o==null?void 0:o.hideDetailsLabel)!=null?s:"Hide details":(i=o==null?void 0:o.showDetailsLabel)!=null?i:"Show details");let a=r.querySelector("[data-approval-details-chevron]");if(a){a.innerHTML="";let d=Ee(e?"chevron-up":"chevron-down",14,"currentColor",2);d&&a.appendChild(d)}},Gx=(r,e,t)=>{let o=e.querySelector('button[data-bubble-type="approval"]'),n=e.querySelector("[data-approval-details]");if(!o||!n)return;let a=Vx(r,t);jx(o,a,t),n.style.display=a?"":"none"};var Kl=(r,e)=>{var E,H,I,P,z,j,ie,ve,Xe,Ae,We,Me,Ue,Be,Z;let t=r.approval,o=(e==null?void 0:e.approval)!==!1?e==null?void 0:e.approval:void 0,n=(t==null?void 0:t.status)==="pending",a=C("div",["persona-approval-bubble","persona-w-full","persona-max-w-[85%]","persona-rounded-2xl","persona-border","persona-shadow-sm","persona-overflow-hidden"].join(" "));if(a.id=`bubble-${r.id}`,a.setAttribute("data-message-id",r.id),a.style.backgroundColor=(E=o==null?void 0:o.backgroundColor)!=null?E:"var(--persona-approval-bg, #fefce8)",a.style.borderColor=(H=o==null?void 0:o.borderColor)!=null?H:"var(--persona-approval-border, #fef08a)",a.style.boxShadow=(o==null?void 0:o.shadow)!==void 0?o.shadow.trim()===""?"none":o.shadow:"var(--persona-approval-shadow, 0 5px 15px rgba(15, 23, 42, 0.08))",!t)return a;let s=C("div","persona-flex persona-items-start persona-gap-3 persona-px-4 persona-py-3"),i=C("div","persona-flex-shrink-0 persona-mt-0.5");i.setAttribute("data-approval-icon","true");let d=t.status==="denied"?"shield-x":t.status==="timeout"?"shield-alert":"shield-check",l=t.status==="approved"?"var(--persona-feedback-success, #16a34a)":t.status==="denied"?"var(--persona-feedback-error, #dc2626)":t.status==="timeout"?"var(--persona-feedback-warning, #ca8a04)":(I=o==null?void 0:o.titleColor)!=null?I:"currentColor",u=Ee(d,20,l,2);u&&i.appendChild(u);let f=C("div","persona-flex-1 persona-min-w-0"),p=C("div","persona-flex persona-items-center persona-gap-2"),m=C("span","persona-text-sm persona-font-medium persona-text-persona-primary");if(o!=null&&o.titleColor&&(m.style.color=o.titleColor),m.textContent=(P=o==null?void 0:o.title)!=null?P:"Approval Required",p.appendChild(m),!n){let ne=C("span","persona-inline-flex persona-items-center persona-px-2 persona-py-0.5 persona-rounded-full persona-text-xs persona-font-medium");ne.setAttribute("data-approval-status",t.status),t.status==="approved"?(ne.style.backgroundColor="var(--persona-palette-colors-success-100, #dcfce7)",ne.style.color="var(--persona-palette-colors-success-700, #15803d)",ne.textContent="Approved"):t.status==="denied"?(ne.style.backgroundColor="var(--persona-palette-colors-error-100, #fee2e2)",ne.style.color="var(--persona-palette-colors-error-700, #b91c1c)",ne.textContent="Denied"):t.status==="timeout"&&(ne.style.backgroundColor="var(--persona-palette-colors-warning-100, #fef3c7)",ne.style.color="var(--persona-palette-colors-warning-700, #b45309)",ne.textContent="Timeout"),p.appendChild(ne)}f.appendChild(p);let h=t.toolType==="webmcp"||t.toolName.startsWith(Cn)?Hd(t.toolName):void 0,T=(z=o==null?void 0:o.formatDescription)==null?void 0:z.call(o,{toolName:t.toolName,toolType:t.toolType,description:t.description,parameters:t.parameters,...h?{displayTitle:h}:{},...t.reason?{reason:t.reason}:{}}),M=!t.toolName,k=T||(M?t.description:`The assistant wants to use \u201C${h!=null?h:uC(t.toolName)}\u201D.`),L=C("p","persona-text-sm persona-mt-0.5 persona-text-persona-muted");if(L.setAttribute("data-approval-summary","true"),o!=null&&o.descriptionColor&&(L.style.color=o.descriptionColor),L.textContent=k,f.appendChild(L),t.reason){let ne=C("p","persona-text-sm persona-mt-1 persona-text-persona-muted");ne.setAttribute("data-approval-reason","true"),o!=null&&o.reasonColor?ne.style.color=o.reasonColor:o!=null&&o.descriptionColor&&(ne.style.color=o.descriptionColor);let me=C("span","persona-font-medium");me.textContent=`${(j=o==null?void 0:o.reasonLabel)!=null?j:"Agent's stated reason:"} `,ne.appendChild(me),ne.appendChild(document.createTextNode(t.reason)),f.appendChild(ne)}let x=(ie=o==null?void 0:o.detailsDisplay)!=null?ie:"collapsed",w=!!t.description&&!M,v=w||!!t.parameters;if(x!=="hidden"&&v){let ne=Vx(r.id,e),me=C("button","persona-inline-flex persona-items-center persona-gap-1 persona-mt-1 persona-p-0 persona-border-none persona-bg-transparent persona-text-xs persona-font-medium persona-cursor-pointer persona-text-persona-muted");me.type="button",me.setAttribute("data-expand-header","true"),me.setAttribute("data-bubble-type","approval"),o!=null&&o.descriptionColor&&(me.style.color=o.descriptionColor);let be=C("span");be.setAttribute("data-approval-details-label","true");let ye=C("span","persona-inline-flex persona-items-center");ye.setAttribute("data-approval-details-chevron","true"),me.append(be,ye),jx(me,ne,e),f.appendChild(me);let Y=C("div");if(Y.setAttribute("data-approval-details","true"),Y.style.display=ne?"":"none",w){let ge=C("p","persona-text-sm persona-mt-1 persona-text-persona-muted");o!=null&&o.descriptionColor&&(ge.style.color=o.descriptionColor),ge.textContent=t.description,Y.appendChild(ge)}if(t.parameters){let ge=C("pre","persona-mt-2 persona-text-xs persona-p-2 persona-rounded persona-overflow-x-auto persona-max-h-32 persona-bg-persona-container persona-text-persona-primary");o!=null&&o.parameterBackgroundColor&&(ge.style.backgroundColor=o.parameterBackgroundColor),o!=null&&o.parameterTextColor&&(ge.style.color=o.parameterTextColor),ge.style.fontSize="0.75rem",ge.style.lineHeight="1rem",ge.textContent=Ya(t.parameters),Y.appendChild(ge)}f.appendChild(Y)}if(n){let ne=C("div","persona-flex persona-gap-2 persona-mt-2");ne.setAttribute("data-approval-buttons","true");let me=C("button","persona-inline-flex persona-items-center persona-px-3 persona-py-1.5 persona-rounded-md persona-text-xs persona-font-medium persona-border-none persona-cursor-pointer");me.type="button",me.style.backgroundColor=(ve=o==null?void 0:o.approveButtonColor)!=null?ve:"var(--persona-approval-approve-bg, #22c55e)",me.style.color=(Xe=o==null?void 0:o.approveButtonTextColor)!=null?Xe:"#ffffff",me.setAttribute("data-approval-action","approve");let be=Ee("shield-check",14,(Ae=o==null?void 0:o.approveButtonTextColor)!=null?Ae:"#ffffff",2);be&&(be.style.marginRight="4px",me.appendChild(be));let ye=document.createTextNode((We=o==null?void 0:o.approveLabel)!=null?We:"Approve");me.appendChild(ye);let Y=C("button","persona-inline-flex persona-items-center persona-px-3 persona-py-1.5 persona-rounded-md persona-text-xs persona-font-medium persona-cursor-pointer");Y.type="button",Y.style.backgroundColor=(Me=o==null?void 0:o.denyButtonColor)!=null?Me:"transparent",Y.style.color=(Ue=o==null?void 0:o.denyButtonTextColor)!=null?Ue:"var(--persona-feedback-error, #dc2626)",Y.style.border=`1px solid ${o!=null&&o.denyButtonTextColor?o.denyButtonTextColor:"var(--persona-palette-colors-error-200, #fca5a5)"}`,Y.setAttribute("data-approval-action","deny");let ge=Ee("shield-x",14,(Be=o==null?void 0:o.denyButtonTextColor)!=null?Be:"var(--persona-feedback-error, #dc2626)",2);ge&&(ge.style.marginRight="4px",Y.appendChild(ge));let Oe=document.createTextNode((Z=o==null?void 0:o.denyLabel)!=null?Z:"Deny");Y.appendChild(Oe),ne.append(me,Y),f.appendChild(ne)}return s.append(i,f),a.appendChild(s),a};var Kx=r=>{let e=[],t=null;return{buttons:e,render:(n,a,s,i,d,l)=>{r.innerHTML="",e.length=0;let u=(l==null?void 0:l.agentPushed)===!0;if(u||(t=null),!n||!n.length||!u&&(i!=null?i:a?a.getMessages():[]).some(T=>T.role==="user"))return;let f=document.createDocumentFragment(),p=a?a.isStreaming():!1,m=y=>{switch(y){case"serif":return'Georgia, "Times New Roman", Times, serif';case"mono":return'"Courier New", Courier, "Lucida Console", Monaco, monospace';default:return'-apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif'}};if(n.forEach(y=>{let h=C("button","persona-rounded-button persona-bg-persona-surface persona-px-3 persona-py-1.5 persona-text-xs persona-font-medium persona-text-persona-primary hover:persona-opacity-80 persona-cursor-pointer persona-border persona-border-persona-border");h.type="button",h.textContent=y,h.disabled=p,d!=null&&d.fontFamily&&(h.style.fontFamily=m(d.fontFamily)),d!=null&&d.fontWeight&&(h.style.fontWeight=d.fontWeight),d!=null&&d.paddingX&&(h.style.paddingLeft=d.paddingX,h.style.paddingRight=d.paddingX),d!=null&&d.paddingY&&(h.style.paddingTop=d.paddingY,h.style.paddingBottom=d.paddingY),h.addEventListener("click",()=>{!a||a.isStreaming()||(s.value="",u&&r.dispatchEvent(new CustomEvent("persona:suggestReplies:selected",{detail:{suggestion:y},bubbles:!0,composed:!0})),a.sendMessage(y))}),f.appendChild(h),e.push(h)}),r.appendChild(f),u){let y=JSON.stringify(n);y!==t&&(t=y,r.dispatchEvent(new CustomEvent("persona:suggestReplies:shown",{detail:{suggestions:[...n]},bubbles:!0,composed:!0})))}}}};var pi=class{constructor(e=2e3,t=null){this.head=0;this.count=0;this.totalCaptured=0;this.eventTypesSet=new Set;this.maxSize=e,this.buffer=new Array(e),this.store=t}push(e){var t;this.buffer[this.head]=e,this.head=(this.head+1)%this.maxSize,this.count<this.maxSize&&this.count++,this.totalCaptured++,this.eventTypesSet.add(e.type),(t=this.store)==null||t.put(e)}getAll(){return this.count===0?[]:this.count<this.maxSize?this.buffer.slice(0,this.count):[...this.buffer.slice(this.head,this.maxSize),...this.buffer.slice(0,this.head)]}async restore(){if(!this.store)return 0;let e=await this.store.getAll();if(e.length===0)return 0;let t=e.length>this.maxSize?e.slice(e.length-this.maxSize):e;for(let o of t)this.buffer[this.head]=o,this.head=(this.head+1)%this.maxSize,this.count<this.maxSize&&this.count++,this.eventTypesSet.add(o.type);return this.totalCaptured=e.length,t.length}getAllFromStore(){return this.store?this.store.getAll():Promise.resolve(this.getAll())}getRecent(e){let t=this.getAll();return e>=t.length?t:t.slice(t.length-e)}getSize(){return this.count}getTotalCaptured(){return this.totalCaptured}getEvictedCount(){return this.totalCaptured-this.count}clear(){var e;this.buffer=new Array(this.maxSize),this.head=0,this.count=0,this.totalCaptured=0,this.eventTypesSet.clear(),(e=this.store)==null||e.clear()}destroy(){var e;this.buffer=[],this.head=0,this.count=0,this.totalCaptured=0,this.eventTypesSet.clear(),(e=this.store)==null||e.destroy()}getEventTypes(){return Array.from(this.eventTypesSet)}};var ui=class{constructor(e="persona-event-stream",t="events"){this.db=null;this.pendingWrites=[];this.flushScheduled=!1;this.isDestroyed=!1;this.dbName=e,this.storeName=t}open(){return new Promise((e,t)=>{try{let o=indexedDB.open(this.dbName,1);o.onupgradeneeded=()=>{let n=o.result;n.objectStoreNames.contains(this.storeName)||n.createObjectStore(this.storeName,{keyPath:"id"}).createIndex("timestamp","timestamp",{unique:!1})},o.onsuccess=()=>{this.db=o.result,e()},o.onerror=()=>{t(o.error)}}catch(o){t(o)}})}put(e){!this.db||this.isDestroyed||(this.pendingWrites.push(e),this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushWrites())))}putBatch(e){if(!(!this.db||this.isDestroyed||e.length===0))try{let o=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName);for(let n of e)o.put(n)}catch{}}getAll(){return new Promise((e,t)=>{if(!this.db){e([]);return}try{let s=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName).index("timestamp").getAll();s.onsuccess=()=>{e(s.result)},s.onerror=()=>{t(s.error)}}catch(o){t(o)}})}getCount(){return new Promise((e,t)=>{if(!this.db){e(0);return}try{let a=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName).count();a.onsuccess=()=>{e(a.result)},a.onerror=()=>{t(a.error)}}catch(o){t(o)}})}clear(){return new Promise((e,t)=>{if(!this.db){e();return}this.pendingWrites=[];try{let a=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).clear();a.onsuccess=()=>{e()},a.onerror=()=>{t(a.error)}}catch(o){t(o)}})}close(){this.db&&(this.db.close(),this.db=null)}destroy(){return this.isDestroyed=!0,this.pendingWrites=[],this.close(),new Promise((e,t)=>{try{let o=indexedDB.deleteDatabase(this.dbName);o.onsuccess=()=>{e()},o.onerror=()=>{t(o.error)}}catch(o){t(o)}})}flushWrites(){if(this.flushScheduled=!1,!this.db||this.isDestroyed||this.pendingWrites.length===0)return;let e=this.pendingWrites;this.pendingWrites=[];try{let o=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName);for(let n of e)o.put(n)}catch{}}};var fC=new Set(["flow_start","flow_run_start","agent_start","dispatch_start","run_start"]),mC=new Set(["step_start","execution_start"]),gC=new Set(["step_delta","step_chunk","chunk","agent_turn_delta"]),hC=new Set(["step_complete","agent_turn_complete"]),xC=new Set(["flow_complete","agent_complete"]),Xx=new Set(["step_error","flow_error","agent_error","dispatch_error","error"]),Yx=r=>typeof r=="object"&&r!==null&&!Array.isArray(r),Do=r=>typeof r=="number"&&Number.isFinite(r)?r:void 0,ka=(r,e)=>{let t=r[e];return Yx(t)?t:void 0};function du(r){return r>0?Math.max(1,Math.ceil(r/4)):0}function Xl(r,e){if(!(r<=0||e===void 0||e<250))return r/(e/1e3)}function yC(r,e){return typeof e.type=="string"?e.type:r}function bC(r){return typeof r.text=="string"?r.text:typeof r.delta=="string"?r.delta:typeof r.content=="string"?r.content:typeof r.chunk=="string"?r.chunk:""}function vC(r,e){return r==="step_delta"||r==="step_chunk"?e.stepType!=="tool"&&e.executionType!=="context":r!=="agent_turn_delta"?!0:(typeof e.contentType=="string"?e.contentType:typeof e.content_type=="string"?e.content_type:void 0)==="text"}function Qx(r){var o,n,a,s,i;let e=ka(r,"result"),t=[ka(r,"tokens"),ka(r,"totalTokens"),e?ka(e,"tokens"):void 0,ka(r,"usage"),e?ka(e,"usage"):void 0];for(let d of t){if(!d)continue;let l=(n=(o=Do(d.output))!=null?o:Do(d.outputTokens))!=null?n:Do(d.completionTokens);if(l!==void 0)return l}return(i=(a=Do(r.outputTokens))!=null?a:Do(r.completionTokens))!=null?i:e?(s=Do(e.outputTokens))!=null?s:Do(e.completionTokens):void 0}function CC(r){var t,o,n,a,s;let e=ka(r,"result");return(s=(n=(o=(t=Do(r.executionTime))!=null?t:Do(r.executionTimeMs))!=null?o:Do(r.execution_time))!=null?n:Do(r.duration))!=null?s:e?(a=Do(e.executionTime))!=null?a:Do(e.executionTimeMs):void 0}function wC(){return typeof performance!="undefined"&&typeof performance.now=="function"?performance.now():Date.now()}var fi=class{constructor(e=wC){this.metric={status:"idle"};this.run=null;this.now=e}getMetric(){let e=this.run;if(e&&this.metric.status==="running"&&e.firstDeltaAt!==void 0&&this.metric.outputTokens!==void 0){let t=this.now()-e.firstDeltaAt;return{...this.metric,durationMs:t,tokensPerSecond:Xl(this.metric.outputTokens,t)}}return this.metric}reset(){this.run=null,this.metric={status:"idle"}}startRun(e){this.run={startedAt:e,visibleCharCount:0,exactOutputTokens:0},this.metric={status:"running"}}processEvent(e,t){var a;if(!Yx(t)){Xx.has(e)&&this.run&&(this.run=null,this.metric={status:"error"});return}let o=yC(e,t),n=this.now();if(fC.has(o)){this.startRun(n);return}if(mC.has(o)){this.run||this.startRun(n);return}if(gC.has(o)){if(!vC(o,t))return;let s=bC(t);if(!s)return;this.run||this.startRun(n);let i=this.run;(a=i.firstDeltaAt)!=null||(i.firstDeltaAt=n),i.visibleCharCount+=s.length;let d=i.exactOutputTokens+du(i.visibleCharCount),l=n-i.firstDeltaAt;this.metric={status:"running",tokensPerSecond:Xl(d,l),outputTokens:d,durationMs:l,source:i.exactOutputTokens>0?"usage":"estimate"};return}if(hC.has(o)){if(!this.run)return;let s=this.run,i=Qx(t);i!==void 0&&(s.exactOutputTokens+=i,s.visibleCharCount=0);let d=s.exactOutputTokens>0,l=s.exactOutputTokens+du(s.visibleCharCount),u=this.resolveDuration(s,t,n);this.metric={status:"running",tokensPerSecond:Xl(l,u),outputTokens:l,durationMs:u,source:d?"usage":"estimate"};return}if(xC.has(o)){if(!this.run)return;let s=this.run,i=Qx(t),d=i!=null?i:s.exactOutputTokens+du(s.visibleCharCount),l=i!==void 0||s.exactOutputTokens>0?"usage":"estimate",u=this.resolveDuration(s,t,n);this.metric={status:"complete",tokensPerSecond:Xl(d,u),outputTokens:d,durationMs:u,source:l},this.run=null;return}if(Xx.has(o)){if(!this.run)return;this.run=null,this.metric={status:"error"}}}resolveDuration(e,t,o){let n=e.firstDeltaAt!==void 0?o-e.firstDeltaAt:void 0;if(n!==void 0&&n>=250)return n;let a=CC(t);return a!=null?a:o-e.startedAt}};function ls(r,e){e&&e.split(/\s+/).forEach(t=>t&&r.classList.add(t))}var AC={flow_:{bg:"var(--persona-palette-colors-success-100, #dcfce7)",text:"var(--persona-palette-colors-success-700, #166534)"},step_:{bg:"var(--persona-palette-colors-primary-100, #f5f5f5)",text:"var(--persona-palette-colors-primary-700, #0a0a0a)"},reason_:{bg:"var(--persona-palette-colors-warning-100, #ffedd5)",text:"var(--persona-palette-colors-warning-700, #9a3412)"},tool_:{bg:"var(--persona-palette-colors-purple-100, #f3e8ff)",text:"var(--persona-palette-colors-purple-700, #6b21a8)"},agent_:{bg:"var(--persona-palette-colors-teal-100, #ccfbf1)",text:"var(--persona-palette-colors-teal-700, #115e59)"},error:{bg:"var(--persona-palette-colors-error-100, #fecaca)",text:"var(--persona-palette-colors-error-700, #991b1b)"}},SC={bg:"var(--persona-palette-colors-gray-100, #f3f4f6)",text:"var(--persona-palette-colors-gray-600, #4b5563)"},TC=["flowName","stepName","reasoningText","text","name","tool","toolName"],MC=100;function kC(r,e){let t={...AC,...e};if(t[r])return t[r];for(let o of Object.keys(t))if(o.endsWith("_")&&r.startsWith(o))return t[o];return SC}function EC(r,e){return`+${((r-e)/1e3).toFixed(3)}s`}function LC(r){let e=new Date(r),t=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),n=String(e.getSeconds()).padStart(2,"0"),a=String(e.getMilliseconds()).padStart(3,"0");return`${t}:${o}:${n}.${a}`}function PC(r,e){try{let t=JSON.parse(r);if(typeof t!="object"||t===null)return null;for(let o of e){let n=o.split("."),a=t;for(let s of n)if(a&&typeof a=="object"&&a!==null)a=a[s];else{a=void 0;break}if(typeof a=="string"&&a.trim())return a.trim()}}catch{}return null}function RC(r){var e;return(e=navigator.clipboard)!=null&&e.writeText?navigator.clipboard.writeText(r):new Promise(t=>{let o=document.createElement("textarea");o.value=r,o.style.position="fixed",o.style.opacity="0",document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o),t()})}function IC(r){let e;try{e=JSON.parse(r.payload)}catch{e=r.payload}return JSON.stringify({type:r.type,timestamp:new Date(r.timestamp).toISOString(),payload:e},null,2)}function HC(r){return r.tokensPerSecond===void 0||!Number.isFinite(r.tokensPerSecond)?"-- tok/s":`${r.tokensPerSecond.toFixed(1)} tok/s`}function WC(r){let e=[];return r.outputTokens!==void 0&&e.push(`${r.outputTokens.toLocaleString()} tok`),r.durationMs!==void 0&&e.push(`${(r.durationMs/1e3).toFixed(2)}s`),r.source&&e.push(r.source),e.join(" \xB7 ")}function BC(r,e,t){let o,n;try{n=JSON.parse(r.payload),o=JSON.stringify(n,null,2)}catch{n=r.payload,o=r.payload}let a=e.find(i=>i.renderEventStreamPayload);if(a!=null&&a.renderEventStreamPayload&&t){let i=a.renderEventStreamPayload({event:r,config:t,defaultRenderer:()=>s(),parsedPayload:n});if(i)return i}return s();function s(){let i=C("div","persona-bg-persona-container persona-border-t persona-border-persona-divider persona-px-3 persona-py-2 persona-ml-4 persona-mr-3 persona-mb-1 persona-rounded-b persona-overflow-auto persona-max-h-[300px]"),d=C("pre","persona-m-0 persona-whitespace-pre-wrap persona-break-all persona-text-[11px] persona-text-persona-secondary persona-font-mono");return d.textContent=o,i.appendChild(d),i}}function cu(r,e,t,o,n,a,s,i){var p;let d=n.has(r.id),l=C("div","persona-border-b persona-border-persona-divider persona-text-xs");ls(l,(p=o.classNames)==null?void 0:p.eventRow);let u=s.find(m=>m.renderEventStreamRow);if(u!=null&&u.renderEventStreamRow&&i){let m=u.renderEventStreamRow({event:r,index:e,config:i,defaultRenderer:()=>f(),isExpanded:d,onToggleExpand:()=>a(r.id)});if(m)return l.appendChild(m),l}return l.appendChild(f()),l;function f(){var j,ie;let m=C("div",""),y=C("div","persona-flex persona-items-center persona-gap-2 persona-px-3 persona-py-3 hover:persona-bg-persona-container persona-cursor-pointer persona-group");y.setAttribute("data-event-id",r.id);let h=C("span","persona-flex-shrink-0 persona-text-persona-muted persona-w-4 persona-text-center persona-flex persona-items-center persona-justify-center"),T=Ee(d?"chevron-down":"chevron-right","14px","currentColor",2);T&&h.appendChild(T);let M=C("span","persona-text-[11px] persona-text-persona-muted persona-whitespace-nowrap persona-flex-shrink-0 persona-font-mono persona-w-[70px]"),k=(j=o.timestampFormat)!=null?j:"relative";M.textContent=k==="relative"?EC(r.timestamp,t):LC(r.timestamp);let L=null;o.showSequenceNumbers!==!1&&(L=C("span","persona-text-[11px] persona-text-persona-muted persona-font-mono persona-flex-shrink-0 persona-w-[28px] persona-text-right"),L.textContent=String(e+1));let x=kC(r.type,o.badgeColors),w=C("span","persona-inline-flex persona-items-center persona-px-2 persona-py-0.5 persona-rounded persona-text-[11px] persona-font-mono persona-font-medium persona-whitespace-nowrap persona-flex-shrink-0 persona-border");w.style.backgroundColor=x.bg,w.style.color=x.text,w.style.borderColor=x.text+"50",w.textContent=r.type;let v=(ie=o.descriptionFields)!=null?ie:TC,E=PC(r.payload,v),H=null;E&&(H=C("span","persona-text-[11px] persona-text-persona-secondary persona-truncate persona-min-w-0"),H.textContent=E);let I=C("div","persona-flex-1 persona-min-w-0"),P=C("button","persona-text-persona-muted hover:persona-text-persona-primary persona-cursor-pointer persona-flex-shrink-0 persona-border-none persona-bg-transparent persona-p-0"),z=Ee("clipboard","12px","currentColor",1.5);return z&&P.appendChild(z),P.addEventListener("click",async ve=>{ve.stopPropagation(),await RC(IC(r)),P.innerHTML="";let Xe=Ee("check","12px","currentColor",1.5);Xe&&P.appendChild(Xe),setTimeout(()=>{P.innerHTML="";let Ae=Ee("clipboard","12px","currentColor",1.5);Ae&&P.appendChild(Ae)},1500)}),y.appendChild(h),y.appendChild(M),L&&y.appendChild(L),y.appendChild(w),H&&y.appendChild(H),y.appendChild(I),y.appendChild(P),m.appendChild(y),d&&m.appendChild(BC(r,s,i)),m}}function Jx(r){var y,h,T,M,k;let{buffer:e,getFullHistory:t,onClose:o,config:n,plugins:a=[],getThroughput:s}=r,i=(y=n==null?void 0:n.features)==null?void 0:y.scrollToBottom,d=(i==null?void 0:i.enabled)!==!1,l=(h=i==null?void 0:i.iconName)!=null?h:"arrow-down",u=(T=i==null?void 0:i.label)!=null?T:"",f=(k=(M=n==null?void 0:n.features)==null?void 0:M.eventStream)!=null?k:{},p=a.find(L=>L.renderEventStreamView);if(p!=null&&p.renderEventStreamView&&n){let L=p.renderEventStreamView({config:n,events:e.getAll(),defaultRenderer:()=>m().element,onClose:o});if(L)return{element:L,update:()=>{},destroy:()=>{}}}return m();function m(){let L=f.classNames,x=C("div","persona-event-stream-view persona-flex persona-flex-col persona-flex-1 persona-min-h-0");ls(x,L==null?void 0:L.panel);let w=[],v="",E="",H=null,I=[],P={},z=0,j=Rl(),ie=0,ve=0,Xe=!1,Ae=null,We=!1,Me=0,Ue=new Set,Be=new Map,Z="",ne="",me=null,be,ye,Y,ge,Oe,ce=null,ae=null,Q=null;function Tt(){let Ce=C("div","persona-relative persona-flex persona-flex-col persona-flex-shrink-0"),de=C("div","persona-flex persona-items-center persona-gap-2 persona-px-4 persona-py-3 persona-pb-0 persona-border-persona-divider persona-bg-persona-surface persona-overflow-hidden");ls(de,L==null?void 0:L.headerBar);let rt=C("span","persona-text-sm persona-font-medium persona-text-persona-primary persona-whitespace-nowrap");if(rt.textContent="Events",be=C("span","persona-text-[11px] persona-font-mono persona-bg-persona-container persona-text-persona-muted persona-px-2 persona-py-0.5 persona-rounded persona-border persona-border-persona-border"),be.textContent="0",s){ae=C("div","persona-relative persona-flex persona-items-center persona-gap-1.5 persona-whitespace-nowrap persona-ml-1"),ae.style.cursor="help";let Dr=C("span","persona-text-sm persona-font-medium persona-text-persona-primary persona-whitespace-nowrap");Dr.textContent="Throughput",ce=C("span","persona-text-[11px] persona-font-mono persona-bg-persona-container persona-text-persona-muted persona-px-2 persona-py-0.5 persona-rounded persona-border persona-border-persona-border persona-tabular-nums"),ce.textContent="-- tok/s",Q=C("div","persona-absolute persona-z-50 persona-whitespace-nowrap persona-rounded persona-border persona-border-persona-border persona-bg-persona-container persona-text-persona-primary persona-text-[11px] persona-font-mono persona-px-2 persona-py-1 persona-shadow"),Q.style.display="none",Q.style.pointerEvents="none";let hr=ae,Sr=Q,Oo=()=>{if(!Sr.textContent)return;let Tr=hr.getBoundingClientRect(),io=Ce.getBoundingClientRect();Sr.style.left=`${Tr.left-io.left}px`,Sr.style.top=`${Tr.bottom-io.top+4}px`,Sr.style.display="block"},je=()=>{Sr.style.display="none"};ae.addEventListener("mouseenter",Oo),ae.addEventListener("mouseleave",je),ae.appendChild(Dr),ae.appendChild(ce)}let Ft=C("div","persona-flex-1");ye=C("select","persona-text-xs persona-bg-persona-surface persona-border persona-border-persona-border persona-rounded persona-px-2.5 persona-py-1 persona-text-persona-primary persona-cursor-pointer");let zt=C("option","");zt.value="",zt.textContent="All events",ye.appendChild(zt),Y=C("button","persona-inline-flex persona-items-center persona-gap-1.5 persona-rounded persona-text-xs persona-text-persona-muted hover:persona-bg-persona-container hover:persona-text-persona-primary persona-cursor-pointer persona-border persona-border-persona-border persona-bg-persona-surface persona-flex-shrink-0 persona-px-2.5 persona-py-1"),Y.type="button",Y.title="Copy All";let vr=Ee("clipboard-copy","12px","currentColor",1.5);vr&&Y.appendChild(vr);let xt=C("span","persona-text-xs");xt.textContent="Copy All",Y.appendChild(xt),de.appendChild(rt),de.appendChild(be),ae&&de.appendChild(ae),de.appendChild(Ft),de.appendChild(ye),de.appendChild(Y);let It=C("div","persona-relative persona-px-4 persona-py-2.5 persona-border-b persona-border-persona-divider persona-bg-persona-surface");ls(It,L==null?void 0:L.searchBar);let tt=Ee("search","14px","var(--persona-muted, #9ca3af)",1.5),jt=C("span","persona-absolute persona-left-6 persona-top-1/2 persona--translate-y-1/2 persona-pointer-events-none persona-flex persona-items-center");tt&&jt.appendChild(tt),ge=C("input","persona-text-sm persona-bg-persona-surface persona-border persona-border-persona-border persona-rounded-md persona-pl-8 persona-pr-3 persona-py-1 persona-w-full persona-text-persona-primary"),ls(ge,L==null?void 0:L.searchInput),ge.type="text",ge.placeholder="Search event payloads...",Oe=C("button","persona-absolute persona-right-5 persona-top-1/2 persona--translate-y-1/2 persona-text-persona-muted hover:persona-text-persona-primary persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-0 persona-leading-none"),Oe.type="button",Oe.style.display="none";let cr=Ee("x","12px","currentColor",2);return cr&&Oe.appendChild(cr),It.appendChild(jt),It.appendChild(ge),It.appendChild(Oe),Ce.appendChild(de),Ce.appendChild(It),Q&&Ce.appendChild(Q),Ce}let Ye,De=a.find(Ce=>Ce.renderEventStreamToolbar);if(De!=null&&De.renderEventStreamToolbar&&n){let Ce=De.renderEventStreamToolbar({config:n,defaultRenderer:()=>Tt(),eventCount:e.getSize(),filteredCount:0,onFilterChange:de=>{v=de,dr(),O()},onSearchChange:de=>{E=de,dr(),O()}});Ye=Ce!=null?Ce:Tt()}else Ye=Tt();let le=C("div","persona-text-xs persona-text-persona-muted persona-text-center persona-py-0.5 persona-px-4 persona-bg-persona-container persona-border-b persona-border-persona-divider persona-italic persona-flex-shrink-0");le.style.display="none";function nt(){if(!s||!ce||!ae)return;let Ce=s();ce.textContent=HC(Ce);let de=WC(Ce);Q&&(Q.textContent=de,de||(Q.style.display="none")),de?ae.setAttribute("aria-label",de):ae.removeAttribute("aria-label")}let Re=C("div","persona-flex-1 persona-min-h-0 persona-relative"),K=C("div","persona-event-stream-list persona-overflow-y-auto persona-min-h-0");K.style.height="100%";let he=C("div","persona-scroll-to-bottom-indicator persona-absolute persona-bottom-3 persona-left-1/2 persona-transform persona--translate-x-1/2 persona-cursor-pointer persona-z-10 persona-text-xs");ls(he,L==null?void 0:L.scrollIndicator),he.style.display="none",he.setAttribute("data-persona-scroll-to-bottom-has-label",u?"true":"false");let it=Ee(l,"14px","currentColor",2);it&&he.appendChild(it);let Pt=C("span","");Pt.textContent=u,he.appendChild(Pt);let te=C("div","persona-flex persona-items-center persona-justify-center persona-h-full persona-text-sm persona-text-persona-muted");te.style.display="none",Re.appendChild(K),Re.appendChild(te),Re.appendChild(he),x.setAttribute("tabindex","0"),x.appendChild(Ye),x.appendChild(le),x.appendChild(Re);function _e(){let Ce=e.getAll(),de={};for(let xt of Ce)de[xt.type]=(de[xt.type]||0)+1;let rt=Object.keys(de).sort(),Ft=rt.length!==I.length||!rt.every((xt,It)=>xt===I[It]),zt=!Ft&&rt.some(xt=>de[xt]!==P[xt]),Pr=Ce.length!==Object.values(P).reduce((xt,It)=>xt+It,0);if(!Ft&&!zt&&!Pr||(I=rt,P=de,!ye))return;let vr=ye.value;if(ye.options[0].textContent="All events",Ft){for(;ye.options.length>1;)ye.remove(1);for(let xt of rt){let It=C("option","");It.value=xt,It.textContent=`${xt} (${de[xt]||0})`,ye.appendChild(It)}vr&&rt.includes(vr)?ye.value=vr:vr&&(ye.value="",v="")}else for(let xt=1;xt<ye.options.length;xt++){let It=ye.options[xt];It.textContent=`${It.value} (${de[It.value]||0})`}}function Ar(){let Ce=e.getAll();if(v&&(Ce=Ce.filter(de=>de.type===v)),E){let de=E.toLowerCase();Ce=Ce.filter(rt=>rt.type.toLowerCase().includes(de)||rt.payload.toLowerCase().includes(de))}return Ce}function Rt(){return v!==""||E!==""}function dr(){z=0,ie=0,j.resume(),he.style.display="none"}function Yr(Ce){Ue.has(Ce)?Ue.delete(Ce):Ue.add(Ce),me=Ce;let de=K.scrollTop,rt=j.isFollowing();We=!0,j.pause(),O(),K.scrollTop=de,rt&&j.resume(),We=!1}function zr(){return Aa(K,50)}function O(){ve=Date.now(),Xe=!1,nt(),_e();let Ce=e.getEvictedCount();Ce>0?(le.textContent=`${Ce.toLocaleString()} older events truncated`,le.style.display=""):le.style.display="none",w=Ar();let de=w.length,rt=e.getSize()>0;be&&(be.textContent=String(e.getSize())),de===0&&rt&&Rt()?(te.textContent=E?`No events matching '${E}'`:"No events matching filter",te.style.display="",K.style.display="none"):(te.style.display="none",K.style.display=""),Y&&(Y.title=Rt()?`Copy Filtered (${de})`:"Copy All"),d&&!j.isFollowing()&&de>z&&(ie+=de-z,Pt.textContent=u?`${u}${ie>0?` (${ie})`:""}`:"",he.style.display=""),z=de;let Ft=e.getAll(),zt=Ft.length>0?Ft[0].timestamp:0,Pr=new Set(w.map(It=>It.id));for(let It of Ue)Pr.has(It)||Ue.delete(It);let vr=v!==Z||E!==ne,xt=Be.size===0&&w.length>0;if(vr||xt||w.length===0){K.innerHTML="",Be.clear();let It=document.createDocumentFragment();for(let tt=0;tt<w.length;tt++){let jt=cu(w[tt],tt,zt,f,Ue,Yr,a,n);Be.set(w[tt].id,jt),It.appendChild(jt)}K.appendChild(It),Z=v,ne=E,me=null}else{if(me!==null){let tt=Be.get(me);if(tt&&tt.parentNode===K){let jt=w.findIndex(cr=>cr.id===me);if(jt>=0){let cr=cu(w[jt],jt,zt,f,Ue,Yr,a,n);K.insertBefore(cr,tt),tt.remove(),Be.set(me,cr)}}me=null}let It=new Set(w.map(tt=>tt.id));for(let[tt,jt]of Be)It.has(tt)||(jt.remove(),Be.delete(tt));for(let tt=0;tt<w.length;tt++){let jt=w[tt];if(!Be.has(jt.id)){let cr=cu(jt,tt,zt,f,Ue,Yr,a,n);Be.set(jt.id,cr),K.appendChild(cr)}}}j.isFollowing()&&(K.scrollTop=K.scrollHeight)}function fe(){if(Date.now()-ve>=MC){Ae!==null&&(cancelAnimationFrame(Ae),Ae=null),O();return}Xe||(Xe=!0,Ae=requestAnimationFrame(()=>{Ae=null,O()}))}let Ie=(Ce,de)=>{if(!Y)return;Y.innerHTML="";let rt=Ee(Ce,"12px","currentColor",1.5);rt&&Y.appendChild(rt);let Ft=C("span","persona-text-xs");Ft.textContent="Copy All",Y.appendChild(Ft),setTimeout(()=>{Y.innerHTML="";let zt=Ee("clipboard-copy","12px","currentColor",1.5);zt&&Y.appendChild(zt);let Pr=C("span","persona-text-xs");Pr.textContent="Copy All",Y.appendChild(Pr),Y.disabled=!1},de)},Je=async()=>{if(Y){Y.disabled=!0;try{let Ce;Rt()?Ce=w:t?(Ce=await t(),Ce.length===0&&(Ce=e.getAll())):Ce=e.getAll();let de=Ce.map(rt=>{try{return JSON.parse(rt.payload)}catch{return rt.payload}});await navigator.clipboard.writeText(JSON.stringify(de,null,2)),Ie("check",1500)}catch{Ie("x",1500)}}},qe=()=>{ye&&(v=ye.value,dr(),O())},ze=()=>{!ge||!Oe||(Oe.style.display=ge.value?"":"none",H&&clearTimeout(H),H=setTimeout(()=>{E=ge.value,dr(),O()},150))},lt=()=>{!ge||!Oe||(ge.value="",E="",Oe.style.display="none",H&&clearTimeout(H),dr(),O())},Mt=()=>{if(We)return;let Ce=K.scrollTop,{action:de,nextLastScrollTop:rt}=Il({following:j.isFollowing(),currentScrollTop:Ce,lastScrollTop:Me,nearBottom:zr(),userScrollThreshold:1,resumeRequiresDownwardScroll:!0});Me=rt,de==="resume"?(j.resume(),ie=0,he.style.display="none"):de==="pause"&&(j.pause(),d&&(Pt.textContent=u,he.style.display=""))},Dt=Ce=>{let de=Hl({following:j.isFollowing(),deltaY:Ce.deltaY,nearBottom:zr(),resumeWhenNearBottom:!0});de==="pause"?(j.pause(),d&&(Pt.textContent=u,he.style.display="")):de==="resume"&&(j.resume(),ie=0,he.style.display="none")},or=()=>{d&&(K.scrollTop=K.scrollHeight,j.resume(),ie=0,he.style.display="none")},X=Ce=>{let de=Ce.target;if(!de||de.closest("button"))return;let rt=de.closest("[data-event-id]");if(!rt)return;let Ft=rt.getAttribute("data-event-id");Ft&&Yr(Ft)},wt=Ce=>{if((Ce.metaKey||Ce.ctrlKey)&&Ce.key==="f"){Ce.preventDefault(),ge==null||ge.focus(),ge==null||ge.select();return}Ce.key==="Escape"&&(ge&&document.activeElement===ge?(lt(),ge.blur(),x.focus()):o&&o())};Y&&Y.addEventListener("click",Je),ye&&ye.addEventListener("change",qe),ge&&ge.addEventListener("input",ze),Oe&&Oe.addEventListener("click",lt),K.addEventListener("scroll",Mt),K.addEventListener("wheel",Dt,{passive:!0}),K.addEventListener("click",X),he.addEventListener("click",or),x.addEventListener("keydown",wt);function ct(){H&&clearTimeout(H),Ae!==null&&(cancelAnimationFrame(Ae),Ae=null),Xe=!1,Be.clear(),Y&&Y.removeEventListener("click",Je),ye&&ye.removeEventListener("change",qe),ge&&ge.removeEventListener("input",ze),Oe&&Oe.removeEventListener("click",lt),K.removeEventListener("scroll",Mt),K.removeEventListener("wheel",Dt),K.removeEventListener("click",X),he.removeEventListener("click",or),x.removeEventListener("keydown",wt)}return{element:x,update:fe,destroy:ct}}}function Zx(r,e){let t=typeof r.title=="string"&&r.title?r.title:"Untitled artifact",o=typeof r.artifactId=="string"?r.artifactId:"",n=r.status==="streaming"?"streaming":"complete",s=(typeof r.artifactType=="string"?r.artifactType:"markdown")==="component"?"Component":"Document",i=document.createElement("div");i.className="persona-flex persona-w-full persona-max-w-full persona-items-center persona-gap-3 persona-rounded-xl persona-px-4 persona-py-3",i.style.border="1px solid var(--persona-border, #e5e7eb)",i.style.backgroundColor="var(--persona-surface, #ffffff)",i.style.cursor="pointer",i.tabIndex=0,i.setAttribute("role","button"),i.setAttribute("aria-label",`Open ${t} in artifact panel`),o&&i.setAttribute("data-open-artifact",o);let d=document.createElement("div");d.className="persona-flex persona-h-10 persona-w-10 persona-flex-shrink-0 persona-items-center persona-justify-center persona-rounded-lg",d.style.border="1px solid var(--persona-border, #e5e7eb)",d.style.color="var(--persona-muted, #9ca3af)",d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/></svg>';let l=document.createElement("div");l.className="persona-min-w-0 persona-flex-1 persona-flex persona-flex-col persona-gap-0.5";let u=document.createElement("div");u.className="persona-truncate persona-text-sm persona-font-medium",u.style.color="var(--persona-text, #1f2937)",u.textContent=t;let f=document.createElement("div");if(f.className="persona-text-xs persona-flex persona-items-center persona-gap-1.5",f.style.color="var(--persona-muted, #9ca3af)",n==="streaming"){let p=document.createElement("span");p.className="persona-inline-block persona-w-1.5 persona-h-1.5 persona-rounded-full",p.style.backgroundColor="var(--persona-primary, #171717)",p.style.animation="persona-pulse 1.5s ease-in-out infinite",f.appendChild(p);let m=document.createElement("span");m.textContent=`Generating ${s.toLowerCase()}...`,f.appendChild(m)}else f.textContent=s;if(l.append(u,f),i.append(d,l),n==="complete"){let p=document.createElement("button");p.type="button",p.textContent="Download",p.title=`Download ${t}`,p.className="persona-flex-shrink-0 persona-rounded-md persona-px-3 persona-py-1.5 persona-text-xs persona-font-medium",p.style.border="1px solid var(--persona-border, #e5e7eb)",p.style.color="var(--persona-text, #1f2937)",p.style.backgroundColor="transparent",p.style.cursor="pointer",p.setAttribute("data-download-artifact",o),i.append(p)}return i}var ey=(r,e)=>{var o,n,a;let t=(a=(n=(o=e==null?void 0:e.config)==null?void 0:o.features)==null?void 0:n.artifacts)==null?void 0:a.renderCard;if(t){let s=typeof r.title=="string"&&r.title?r.title:"Untitled artifact",i=typeof r.artifactId=="string"?r.artifactId:"",d=r.status==="streaming"?"streaming":"complete",l=typeof r.artifactType=="string"?r.artifactType:"markdown",u=t({artifact:{artifactId:i,title:s,artifactType:l,status:d},config:e.config,defaultRenderer:()=>Zx(r,e)});if(u)return u}return Zx(r,e)};var pu=class{constructor(){this.components=new Map}register(e,t){this.components.has(e)&&console.warn(`[ComponentRegistry] Component "${e}" is already registered. Overwriting.`),this.components.set(e,t)}unregister(e){this.components.delete(e)}get(e){return this.components.get(e)}has(e){return this.components.has(e)}getAllNames(){return Array.from(this.components.keys())}clear(){this.components.clear()}registerAll(e){Object.entries(e).forEach(([t,o])=>{this.register(t,o)})}},En=new pu;En.register("PersonaArtifactCard",ey);function DC(r){var n;let e=C("div","persona-rounded-lg persona-border persona-border-persona-border persona-p-3 persona-text-persona-primary"),t=C("div","persona-font-semibold persona-text-sm persona-mb-2");t.textContent=r.component?`Component: ${r.component}`:"Component";let o=C("pre","persona-font-mono persona-text-xs persona-whitespace-pre-wrap persona-overflow-x-auto");return o.textContent=JSON.stringify((n=r.props)!=null?n:{},null,2),e.appendChild(t),e.appendChild(o),e}function ty(r,e){var ye,Y,ge,Oe;let t=(Y=(ye=r.features)==null?void 0:ye.artifacts)==null?void 0:Y.layout,n=((ge=t==null?void 0:t.toolbarPreset)!=null?ge:"default")==="document",a=(Oe=t==null?void 0:t.panePadding)==null?void 0:Oe.trim(),s=r.markdown?ua(r.markdown):null,i=ja(r.sanitize),d=ce=>{let ae=s?s(ce):fa(ce);return i?i(ae):ae},l=typeof document!="undefined"?C("div","persona-artifact-backdrop persona-fixed persona-inset-0 persona-z-[55] persona-bg-black/30 persona-hidden md:persona-hidden"):null,u=()=>{l==null||l.classList.add("persona-hidden"),f.classList.remove("persona-artifact-drawer-open"),z==null||z.hide()};l&&l.addEventListener("click",()=>{var ce;u(),(ce=e.onDismiss)==null||ce.call(e)});let f=C("aside","persona-artifact-pane persona-flex persona-flex-col persona-min-h-0 persona-min-w-0 persona-bg-persona-surface persona-text-persona-primary persona-border-l persona-border-persona-border");f.setAttribute("data-persona-theme-zone","artifact-pane"),n&&f.classList.add("persona-artifact-pane-document");let p=C("div","persona-artifact-toolbar persona-flex persona-items-center persona-justify-between persona-gap-2 persona-px-2 persona-py-2 persona-border-b persona-border-persona-border persona-shrink-0");p.setAttribute("data-persona-theme-zone","artifact-toolbar"),n&&p.classList.add("persona-artifact-toolbar-document");let m=C("span","persona-text-xs persona-font-medium persona-truncate");m.textContent="Artifacts";let y=C("button","persona-rounded-md persona-border persona-border-persona-border persona-px-2 persona-py-1 persona-text-xs persona-bg-persona-surface");y.type="button",y.textContent="Close",y.setAttribute("aria-label","Close artifacts panel"),y.addEventListener("click",()=>{var ce;u(),(ce=e.onDismiss)==null||ce.call(e)});let h="rendered",T=C("div","persona-flex persona-items-center persona-gap-1 persona-shrink-0 persona-artifact-toggle-group"),M=n?Br({icon:"eye",label:"Rendered view",className:"persona-artifact-doc-icon-btn persona-artifact-view-btn"}):Br({icon:"eye",label:"Rendered view"}),k=n?Br({icon:"code-2",label:"Source",className:"persona-artifact-doc-icon-btn persona-artifact-code-btn"}):Br({icon:"code-2",label:"Source"}),L=C("div","persona-flex persona-items-center persona-gap-1 persona-shrink-0"),x=(t==null?void 0:t.documentToolbarShowCopyLabel)===!0,w=(t==null?void 0:t.documentToolbarShowCopyChevron)===!0,v=t==null?void 0:t.documentToolbarCopyMenuItems,E=!!(w&&v&&v.length>0),H=null,I,P=null,z=null;if(n&&(x||w)&&!E){if(I=x?ci({icon:"copy",label:"Copy",iconSize:14,className:"persona-artifact-doc-copy-btn"}):Br({icon:"copy",label:"Copy",className:"persona-artifact-doc-copy-btn"}),w){let ce=Ee("chevron-down",14,"currentColor",2);ce&&I.appendChild(ce)}}else n&&E?(H=C("div","persona-relative persona-inline-flex persona-items-center persona-gap-0 persona-rounded-md"),I=x?ci({icon:"copy",label:"Copy",iconSize:14,className:"persona-artifact-doc-copy-btn"}):Br({icon:"copy",label:"Copy",className:"persona-artifact-doc-copy-btn"}),P=Br({icon:"chevron-down",label:"More copy options",size:14,className:"persona-artifact-doc-copy-menu-chevron persona-artifact-doc-icon-btn",aria:{"aria-haspopup":"true","aria-expanded":"false"}}),H.append(I,P)):n?I=Br({icon:"copy",label:"Copy",className:"persona-artifact-doc-icon-btn"}):I=Br({icon:"copy",label:"Copy"});let j=n?Br({icon:"refresh-cw",label:"Refresh",className:"persona-artifact-doc-icon-btn"}):Br({icon:"refresh-cw",label:"Refresh"}),ie=n?Br({icon:"x",label:"Close",className:"persona-artifact-doc-icon-btn"}):Br({icon:"x",label:"Close"}),ve=()=>{var Ye,De,le;let ce=(Ye=Be.find(nt=>nt.id===Z))!=null?Ye:Be[Be.length-1],ae=(De=ce==null?void 0:ce.id)!=null?De:null,Q=(ce==null?void 0:ce.artifactType)==="markdown"&&(le=ce.markdown)!=null?le:"",Tt=ce?JSON.stringify({component:ce.component,props:ce.props},null,2):"";return{markdown:Q,jsonPayload:Tt,id:ae}},Xe=async()=>{var Ye;let{markdown:ce,jsonPayload:ae}=ve(),Q=(Ye=Be.find(De=>De.id===Z))!=null?Ye:Be[Be.length-1],Tt=(Q==null?void 0:Q.artifactType)==="markdown"?ce:Q?ae:"";try{await navigator.clipboard.writeText(Tt)}catch{}};if(I.addEventListener("click",async()=>{let ce=t==null?void 0:t.onDocumentToolbarCopyMenuSelect;if(ce&&E){let{markdown:ae,jsonPayload:Q,id:Tt}=ve();try{await ce({actionId:"primary",artifactId:Tt,markdown:ae,jsonPayload:Q})}catch{}return}await Xe()}),P&&(v!=null&&v.length)){let ce=()=>{var Q;return(Q=f.closest("[data-persona-root]"))!=null?Q:document.body},ae=()=>{z=Xn({items:v.map(Q=>({id:Q.id,label:Q.label})),onSelect:async Q=>{let{markdown:Tt,jsonPayload:Ye,id:De}=ve(),le=t==null?void 0:t.onDocumentToolbarCopyMenuSelect;try{le?await le({actionId:Q,artifactId:De,markdown:Tt,jsonPayload:Ye}):Q==="markdown"||Q==="md"?await navigator.clipboard.writeText(Tt):Q==="json"||Q==="source"?await navigator.clipboard.writeText(Ye):await navigator.clipboard.writeText(Tt||Ye)}catch{}},anchor:H!=null?H:P,position:"bottom-right",portal:ce()})};f.isConnected?ae():requestAnimationFrame(ae),P.addEventListener("click",Q=>{Q.stopPropagation(),z==null||z.toggle()})}j.addEventListener("click",async()=>{var ce;try{await((ce=t==null?void 0:t.onDocumentToolbarRefresh)==null?void 0:ce.call(t))}catch{}me()}),ie.addEventListener("click",()=>{var ce;u(),(ce=e.onDismiss)==null||ce.call(e)});let Ae=()=>{n&&(M.setAttribute("aria-pressed",h==="rendered"?"true":"false"),k.setAttribute("aria-pressed",h==="source"?"true":"false"))};M.addEventListener("click",()=>{h="rendered",Ae(),me()}),k.addEventListener("click",()=>{h="source",Ae(),me()});let We=C("span","persona-min-w-0 persona-flex-1 persona-text-xs persona-font-medium persona-text-persona-primary persona-truncate persona-text-center md:persona-text-left");n?(p.replaceChildren(),T.append(M,k),H?L.append(H,j,ie):L.append(I,j,ie),p.append(T,We,L),Ae()):(p.appendChild(m),p.appendChild(y)),a&&(p.style.paddingLeft=a,p.style.paddingRight=a);let Me=C("div","persona-artifact-list persona-shrink-0 persona-flex persona-gap-1 persona-overflow-x-auto persona-p-2 persona-border-b persona-border-persona-border"),Ue=C("div","persona-artifact-content persona-flex-1 persona-min-h-0 persona-overflow-y-auto persona-p-3");a&&(Me.style.paddingLeft=a,Me.style.paddingRight=a,Ue.style.padding=a),f.appendChild(p),f.appendChild(Me),f.appendChild(Ue);let Be=[],Z=null,ne=!1,me=()=>{var Tt,Ye,De,le;let ce=n&&Be.length<=1;Me.classList.toggle("persona-hidden",ce),Me.replaceChildren();for(let nt of Be){let Re=C("button","persona-artifact-tab persona-shrink-0 persona-rounded-lg persona-px-2 persona-py-1 persona-text-xs persona-border persona-border-transparent persona-text-persona-primary");Re.type="button",Re.textContent=nt.title||nt.id.slice(0,8),nt.id===Z&&Re.classList.add("persona-bg-persona-container","persona-border-persona-border"),Re.addEventListener("click",()=>e.onSelect(nt.id)),Me.appendChild(Re)}Ue.replaceChildren();let ae=Z&&Be.find(nt=>nt.id===Z)||Be[Be.length-1];if(!ae)return;if(n){let nt=ae.artifactType==="markdown"?"MD":(Tt=ae.component)!=null?Tt:"Component",K=(ae.title||"Document").trim().replace(/\s*·\s*MD\s*$/i,"").trim()||"Document";We.textContent=`${K} \xB7 ${nt}`}else m.textContent="Artifacts";if(ae.artifactType==="markdown"){if(n&&h==="source"){let Re=C("pre","persona-font-mono persona-text-xs persona-whitespace-pre-wrap persona-break-words persona-text-persona-primary");Re.textContent=(Ye=ae.markdown)!=null?Ye:"",Ue.appendChild(Re);return}let nt=C("div","persona-text-sm persona-leading-relaxed persona-markdown-bubble");nt.innerHTML=d((De=ae.markdown)!=null?De:""),Ue.appendChild(nt);return}let Q=ae.component?En.get(ae.component):void 0;if(Q){let Re={message:{id:ae.id,role:"assistant",content:"",createdAt:new Date().toISOString()},config:r,updateProps:()=>{}};try{let K=Q((le=ae.props)!=null?le:{},Re);if(K){Ue.appendChild(K);return}}catch{}}Ue.appendChild(DC(ae))},be=()=>{var ae;let ce=Be.length>0;if(f.classList.toggle("persona-hidden",!ce),l){let Q=typeof f.closest=="function"?f.closest("[data-persona-root]"):null,Ye=((ae=Q==null?void 0:Q.classList.contains("persona-artifact-narrow-host"))!=null?ae:!1)||typeof window!="undefined"&&window.matchMedia("(max-width: 640px)").matches;ce&&Ye&&ne?(l.classList.remove("persona-hidden"),f.classList.add("persona-artifact-drawer-open")):(l.classList.add("persona-hidden"),f.classList.remove("persona-artifact-drawer-open"))}};return{element:f,backdrop:l,update(ce){var ae,Q,Tt;Be=ce.artifacts,Z=(Tt=(Q=ce.selectedId)!=null?Q:(ae=ce.artifacts[ce.artifacts.length-1])==null?void 0:ae.id)!=null?Tt:null,Be.length>0&&(ne=!0),me(),be()},setMobileOpen(ce){ne=ce,!ce&&l?(l.classList.add("persona-hidden"),f.classList.remove("persona-artifact-drawer-open")):be()}}}function Go(r){var e,t;return((t=(e=r==null?void 0:r.features)==null?void 0:e.artifacts)==null?void 0:t.enabled)===!0}function ry(r,e){var a,s,i,d;if(r.classList.remove("persona-artifact-border-full","persona-artifact-border-left"),r.style.removeProperty("--persona-artifact-pane-border"),r.style.removeProperty("--persona-artifact-pane-border-left"),!Go(e))return;let t=(s=(a=e.features)==null?void 0:a.artifacts)==null?void 0:s.layout,o=(i=t==null?void 0:t.paneBorder)==null?void 0:i.trim(),n=(d=t==null?void 0:t.paneBorderLeft)==null?void 0:d.trim();o?(r.classList.add("persona-artifact-border-full"),r.style.setProperty("--persona-artifact-pane-border",o)):n&&(r.classList.add("persona-artifact-border-left"),r.style.setProperty("--persona-artifact-pane-border-left",n))}function OC(r){r.style.removeProperty("--persona-artifact-doc-toolbar-icon-color"),r.style.removeProperty("--persona-artifact-doc-toggle-active-bg"),r.style.removeProperty("--persona-artifact-doc-toggle-active-border")}function Ql(r,e){var d,l,u,f,p,m,y,h,T,M;if(!Go(e)){r.style.removeProperty("--persona-artifact-split-gap"),r.style.removeProperty("--persona-artifact-pane-width"),r.style.removeProperty("--persona-artifact-pane-max-width"),r.style.removeProperty("--persona-artifact-pane-min-width"),r.style.removeProperty("--persona-artifact-pane-bg"),r.style.removeProperty("--persona-artifact-pane-padding"),OC(r),ry(r,e);return}let t=(l=(d=e.features)==null?void 0:d.artifacts)==null?void 0:l.layout;r.style.setProperty("--persona-artifact-split-gap",(u=t==null?void 0:t.splitGap)!=null?u:"0.5rem"),r.style.setProperty("--persona-artifact-pane-width",(f=t==null?void 0:t.paneWidth)!=null?f:"40%"),r.style.setProperty("--persona-artifact-pane-max-width",(p=t==null?void 0:t.paneMaxWidth)!=null?p:"28rem"),t!=null&&t.paneMinWidth?r.style.setProperty("--persona-artifact-pane-min-width",t.paneMinWidth):r.style.removeProperty("--persona-artifact-pane-min-width");let o=(m=t==null?void 0:t.paneBackground)==null?void 0:m.trim();o?r.style.setProperty("--persona-artifact-pane-bg",o):r.style.removeProperty("--persona-artifact-pane-bg");let n=(y=t==null?void 0:t.panePadding)==null?void 0:y.trim();n?r.style.setProperty("--persona-artifact-pane-padding",n):r.style.removeProperty("--persona-artifact-pane-padding");let a=(h=t==null?void 0:t.documentToolbarIconColor)==null?void 0:h.trim();a?r.style.setProperty("--persona-artifact-doc-toolbar-icon-color",a):r.style.removeProperty("--persona-artifact-doc-toolbar-icon-color");let s=(T=t==null?void 0:t.documentToolbarToggleActiveBackground)==null?void 0:T.trim();s?r.style.setProperty("--persona-artifact-doc-toggle-active-bg",s):r.style.removeProperty("--persona-artifact-doc-toggle-active-bg");let i=(M=t==null?void 0:t.documentToolbarToggleActiveBorderColor)==null?void 0:M.trim();i?r.style.setProperty("--persona-artifact-doc-toggle-active-border",i):r.style.removeProperty("--persona-artifact-doc-toggle-active-border"),ry(r,e)}var oy=["panel","seamless"];function Yl(r,e){var i,d,l,u,f,p;for(let m of oy)r.classList.remove(`persona-artifact-appearance-${m}`);if(r.classList.remove("persona-artifact-unified-split"),r.style.removeProperty("--persona-artifact-pane-radius"),r.style.removeProperty("--persona-artifact-pane-shadow"),r.style.removeProperty("--persona-artifact-unified-outer-radius"),!Go(e))return;let t=(d=(i=e.features)==null?void 0:i.artifacts)==null?void 0:d.layout,o=(l=t==null?void 0:t.paneAppearance)!=null?l:"panel",n=oy.includes(o)?o:"panel";r.classList.add(`persona-artifact-appearance-${n}`);let a=(u=t==null?void 0:t.paneBorderRadius)==null?void 0:u.trim();a&&r.style.setProperty("--persona-artifact-pane-radius",a);let s=(f=t==null?void 0:t.paneShadow)==null?void 0:f.trim();if(s&&r.style.setProperty("--persona-artifact-pane-shadow",s),(t==null?void 0:t.unifiedSplitChrome)===!0){r.classList.add("persona-artifact-unified-split");let m=((p=t.unifiedSplitOuterRadius)==null?void 0:p.trim())||a;m&&r.style.setProperty("--persona-artifact-unified-outer-radius",m)}}function ny(r,e){var t,o,n;return!e||!Go(r)?!1:((n=(o=(t=r.features)==null?void 0:t.artifacts)==null?void 0:o.layout)==null?void 0:n.expandLauncherPanelWhenOpen)!==!1}function _C(r,e){if(!(r!=null&&r.trim()))return e;let t=/^(\d+(?:\.\d+)?)px\s*$/i.exec(r.trim());return t?Math.max(0,Number(t[1])):e}function NC(r){if(!(r!=null&&r.trim()))return null;let e=/^(\d+(?:\.\d+)?)px\s*$/i.exec(r.trim());return e?Math.max(0,Number(e[1])):null}function FC(r,e,t){return t<e?e:Math.min(t,Math.max(e,r))}function UC(r,e,t,o){let n=r-o-2*e-t;return Math.max(0,n)}function ay(r,e){var s;let o=(s=(e.getComputedStyle(r).gap||"0px").trim().split(/\s+/)[0])!=null?s:"0px",n=/^([\d.]+)px$/i.exec(o);if(n)return Number(n[1]);let a=/^([\d.]+)/.exec(o);return a?Number(a[1]):8}function sy(r,e,t,o,n,a){let s=_C(n,200),i=UC(e,t,o,200);i=Math.max(s,i);let d=NC(a);return d!==null&&(i=Math.min(i,d)),FC(r,s,i)}var iy={init:{title:"Schedule a Demo",description:"Share the basics and we'll follow up with a confirmation.",fields:[{name:"name",label:"Full name",placeholder:"Jane Doe",required:!0},{name:"email",label:"Work email",placeholder:"jane@example.com",type:"email",required:!0},{name:"notes",label:"What would you like to cover?",type:"textarea"}],submitLabel:"Submit details"},followup:{title:"Additional Information",description:"Provide any extra details to tailor the next steps.",fields:[{name:"company",label:"Company",placeholder:"Acme Inc."},{name:"context",label:"Context",type:"textarea",placeholder:"Share more about your use case"}],submitLabel:"Send"}},uu=(r,e,t,o)=>{let n=r.querySelectorAll("[data-tv-form]");n.length&&n.forEach(a=>{var y,h,T;if(a.dataset.enhanced==="true")return;let s=(y=a.dataset.tvForm)!=null?y:"init";a.dataset.enhanced="true";let i=(h=iy[s])!=null?h:iy.init;a.classList.add("persona-form-card","persona-space-y-4");let d=C("div","persona-space-y-1"),l=C("h3","persona-text-base persona-font-semibold persona-text-persona-primary");if(l.textContent=i.title,d.appendChild(l),i.description){let M=C("p","persona-text-sm persona-text-persona-muted");M.textContent=i.description,d.appendChild(M)}let u=document.createElement("form");u.className="persona-form-grid persona-space-y-3",i.fields.forEach(M=>{var v,E;let k=C("label","persona-form-field persona-flex persona-flex-col persona-gap-1");k.htmlFor=`${e.id}-${s}-${M.name}`;let L=C("span","persona-text-xs persona-font-medium persona-text-persona-muted");L.textContent=M.label,k.appendChild(L);let x=(v=M.type)!=null?v:"text",w;x==="textarea"?(w=document.createElement("textarea"),w.rows=3):(w=document.createElement("input"),w.type=x),w.className="persona-rounded-xl persona-border persona-border-gray-200 persona-bg-white persona-px-3 persona-py-2 persona-text-sm persona-text-persona-primary focus:persona-outline-none focus:persona-border-persona-primary",w.id=`${e.id}-${s}-${M.name}`,w.name=M.name,w.placeholder=(E=M.placeholder)!=null?E:"",M.required&&(w.required=!0),k.appendChild(w),u.appendChild(k)});let f=C("div","persona-flex persona-items-center persona-justify-between persona-gap-2"),p=C("div","persona-text-xs persona-text-persona-muted persona-min-h-[1.5rem]"),m=C("button","persona-inline-flex persona-items-center persona-rounded-full persona-bg-persona-primary persona-px-4 persona-py-2 persona-text-sm persona-font-semibold persona-text-white disabled:persona-opacity-60 persona-cursor-pointer");m.type="submit",m.textContent=(T=i.submitLabel)!=null?T:"Submit",f.appendChild(p),f.appendChild(m),u.appendChild(f),a.replaceChildren(d,u),u.addEventListener("submit",async M=>{var w,v;M.preventDefault();let k=(w=t.formEndpoint)!=null?w:"/form",L=new FormData(u),x={};L.forEach((E,H)=>{x[H]=E}),x.type=s,m.disabled=!0,p.textContent="Submitting\u2026";try{let E=await fetch(k,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!E.ok)throw new Error(`Form submission failed (${E.status})`);let H=await E.json();p.textContent=(v=H.message)!=null?v:"Thanks! We'll be in touch soon.",H.success&&H.nextPrompt&&await o.sendMessage(String(H.nextPrompt))}catch(E){p.textContent=E instanceof Error?E.message:"Something went wrong. Please try again."}finally{m.disabled=!1}})})};var fu=class{constructor(){this.plugins=new Map}register(e){var t;this.plugins.has(e.id)&&console.warn(`Plugin "${e.id}" is already registered. Overwriting.`),this.plugins.set(e.id,e),(t=e.onRegister)==null||t.call(e)}unregister(e){var o;let t=this.plugins.get(e);t&&((o=t.onUnregister)==null||o.call(t),this.plugins.delete(e))}getAll(){return Array.from(this.plugins.values()).sort((e,t)=>{var o,n;return((o=t.priority)!=null?o:0)-((n=e.priority)!=null?n:0)})}getForInstance(e){let t=this.getAll();if(!e||e.length===0)return t;let o=new Set(e.map(a=>a.id));return[...t.filter(a=>!o.has(a.id)),...e].sort((a,s)=>{var i,d;return((i=s.priority)!=null?i:0)-((d=a.priority)!=null?d:0)})}clear(){this.plugins.forEach(e=>{var t;return(t=e.onUnregister)==null?void 0:t.call(e)}),this.plugins.clear()}},mi=new fu;var ly=()=>{let r=new Map,e=(n,a)=>(r.has(n)||r.set(n,new Set),r.get(n).add(a),()=>t(n,a)),t=(n,a)=>{var s;(s=r.get(n))==null||s.delete(a)};return{on:e,off:t,emit:(n,a)=>{var s;(s=r.get(n))==null||s.forEach(i=>{try{i(a)}catch(d){typeof console!="undefined"&&console.error("[AgentWidget] Event handler error:",d)}})}}};var qC=r=>{let e=r.match(/```(?:json)?\s*([\s\S]*?)```/i);return e?e[1]:r},zC=r=>{let e=r.trim(),t=e.indexOf("{");if(t===-1)return null;let o=0;for(let n=t;n<e.length;n+=1){let a=e[n];if(a==="{"&&(o+=1),a==="}"&&(o-=1,o===0))return e.slice(t,n+1)}return null},gi=({text:r})=>{if(!r||!r.includes("{"))return null;try{let e=qC(r),t=zC(e);if(!t)return null;let o=JSON.parse(t);if(!o||typeof o!="object"||!o.action)return null;let{action:n,...a}=o;return{type:String(n),payload:a,raw:o}}catch{return null}},mu=r=>typeof r=="string"?r:r==null?"":String(r),Ea={message:r=>r.type!=="message"?void 0:{handled:!0,displayText:mu(r.payload.text)},messageAndClick:(r,e)=>{var n;if(r.type!=="message_and_click")return;let t=r.payload,o=mu(t.element);if(o&&((n=e.document)!=null&&n.querySelector)){let a=e.document.querySelector(o);a?setTimeout(()=>{a.click()},400):typeof console!="undefined"&&console.warn("[AgentWidget] Element not found for selector:",o)}return{handled:!0,displayText:mu(t.text)}}},dy=r=>Array.isArray(r)?r.map(e=>String(e)):[],hi=r=>{let e=new Set(dy(r.getSessionMetadata().processedActionMessageIds)),t=()=>{e=new Set(dy(r.getSessionMetadata().processedActionMessageIds))},o=()=>{let a=Array.from(e);r.updateSessionMetadata(s=>({...s,processedActionMessageIds:a}))};return{process:a=>{if(a.streaming||a.message.role!=="assistant"||!a.text||e.has(a.message.id))return null;let s=typeof a.raw=="string"&&a.raw||typeof a.message.rawContent=="string"&&a.message.rawContent||typeof a.text=="string"&&a.text||null;!s&&typeof a.text=="string"&&a.text.trim().startsWith("{")&&typeof console!="undefined"&&console.warn("[AgentWidget] Structured response detected but no raw payload was provided. Ensure your stream parser returns { text, raw }.");let i=s?r.parsers.reduce((l,u)=>l||(u==null?void 0:u({text:s,message:a.message}))||null,null):null;if(!i)return null;e.add(a.message.id),o();let d={action:i,message:a.message};r.emit("action:detected",d);for(let l of r.handlers)if(l)try{let u=()=>{r.emit("action:resubmit",d)},f=l(i,{message:a.message,metadata:r.getSessionMetadata(),updateMetadata:r.updateSessionMetadata,document:r.documentRef,triggerResubmit:u});if(!f)continue;if(f.handled){let p=f.persistMessage!==!1;return{text:f.displayText!==void 0?f.displayText:"",persist:p,resubmit:f.resubmit}}}catch(u){typeof console!="undefined"&&console.error("[AgentWidget] Action handler error:",u)}return{text:"",persist:!0}},syncFromMetadata:t}};var $C=r=>{if(!r)return null;try{return JSON.parse(r)}catch(e){return typeof console!="undefined"&&console.error("[AgentWidget] Failed to parse stored state:",e),null}},VC=r=>r.map(e=>({...e,streaming:!1})),jC=r=>r.map(e=>({...e,status:"complete"})),Jl=(r="persona-state")=>{let e=()=>typeof window=="undefined"||!window.localStorage?null:window.localStorage;return{load:()=>{let t=e();return t?$C(t.getItem(r)):null},save:t=>{let o=e();if(o)try{let n={...t,messages:t.messages?VC(t.messages):void 0,artifacts:t.artifacts?jC(t.artifacts):void 0};o.setItem(r,JSON.stringify(n))}catch(n){typeof console!="undefined"&&console.error("[AgentWidget] Failed to persist state:",n)}},clear:()=>{let t=e();if(t)try{t.removeItem(r)}catch(o){typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear stored state:",o)}}}};var ds=Bi(ji(),1);function GC(r){if(!r||typeof r!="object"||!("component"in r))return!1;let e=r.component;return typeof e=="string"&&e.length>0}function KC(r,e){if(!GC(r))return null;let t=r.props&&typeof r.props=="object"&&r.props!==null?r.props:{};return{component:r.component,props:t,raw:e}}function Zl(){let r=null,e=0;return{getExtractedDirective:()=>r,processChunk:t=>{let o=t.trim();if(!o.startsWith("{")&&!o.startsWith("["))return null;if(t.length<=e)return r;try{let n=(0,ds.parse)(t,ds.STR|ds.OBJ),a=KC(n,t);a&&(r=a)}catch{}return e=t.length,r},reset:()=>{r=null,e=0}}}function cy(r){return typeof r=="object"&&r!==null&&"component"in r&&typeof r.component=="string"&&"props"in r&&typeof r.props=="object"}function ed(r,e){let{config:t,message:o,onPropsUpdate:n}=e,a=En.get(r.component);if(!a)return console.warn(`[ComponentMiddleware] Component "${r.component}" not found in registry. Falling back to default rendering.`),null;let s={message:o,config:t,updateProps:i=>{n&&n(i)}};try{return a(r.props,s)}catch(i){return console.error(`[ComponentMiddleware] Error rendering component "${r.component}":`,i),null}}function py(){let r=Zl();return{processChunk:e=>r.processChunk(e),getDirective:()=>r.getExtractedDirective(),reset:()=>{r.reset()}}}function uy(r){if(typeof r.rawContent=="string"&&r.rawContent.length>0)return r.rawContent;if(typeof r.content=="string"){let e=r.content.trim();if(e.startsWith("{")||e.startsWith("["))return r.content}return null}function td(r){let e=uy(r);if(!e)return!1;try{let t=JSON.parse(e);return typeof t=="object"&&t!==null&&"component"in t&&typeof t.component=="string"}catch{return!1}}function rd(r){let e=uy(r);if(!e)return null;try{let t=JSON.parse(e);if(typeof t=="object"&&t!==null&&"component"in t&&typeof t.component=="string"){let o=t;return{component:o.component,props:o.props&&typeof o.props=="object"&&o.props!==null?o.props:{},raw:e}}}catch{}return null}var XC=["Very dissatisfied","Dissatisfied","Neutral","Satisfied","Very satisfied"];function od(r){let{onSubmit:e,onDismiss:t,title:o="How satisfied are you?",subtitle:n="Please rate your experience",commentPlaceholder:a="Share your thoughts (optional)...",submitText:s="Submit",skipText:i="Skip",showComment:d=!0,ratingLabels:l=XC}=r,u=document.createElement("div");u.className="persona-feedback-container persona-feedback-csat",u.setAttribute("role","dialog"),u.setAttribute("aria-label","Customer satisfaction feedback");let f=null,p=document.createElement("div");p.className="persona-feedback-content";let m=document.createElement("div");m.className="persona-feedback-header";let y=document.createElement("h3");y.className="persona-feedback-title",y.textContent=o,m.appendChild(y);let h=document.createElement("p");h.className="persona-feedback-subtitle",h.textContent=n,m.appendChild(h),p.appendChild(m);let T=document.createElement("div");T.className="persona-feedback-rating persona-feedback-rating-csat",T.setAttribute("role","radiogroup"),T.setAttribute("aria-label","Satisfaction rating from 1 to 5");let M=[];for(let v=1;v<=5;v++){let E=document.createElement("button");E.type="button",E.className="persona-feedback-rating-btn persona-feedback-star-btn",E.setAttribute("role","radio"),E.setAttribute("aria-checked","false"),E.setAttribute("aria-label",`${v} star${v>1?"s":""}: ${l[v-1]}`),E.title=l[v-1],E.dataset.rating=String(v),E.innerHTML=`
|
|
74
75
|
<svg class="persona-feedback-star" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
75
76
|
<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon>
|
|
76
77
|
</svg>
|
|
77
|
-
`,T.addEventListener("click",()=>{f=C,M.forEach((W,R)=>{let I=R<C;W.classList.toggle("selected",I),W.setAttribute("aria-checked",R===C-1?"true":"false")})}),M.push(T),S.appendChild(T)}u.appendChild(S);let E=null;if(d){let C=document.createElement("div");C.className="persona-feedback-comment-container",E=document.createElement("textarea"),E.className="persona-feedback-comment",E.placeholder=a,E.rows=3,E.setAttribute("aria-label","Additional comments"),C.appendChild(E),u.appendChild(C)}let k=document.createElement("div");k.className="persona-feedback-actions";let h=document.createElement("button");h.type="button",h.className="persona-feedback-btn persona-feedback-btn-skip",h.textContent=i,h.addEventListener("click",()=>{t==null||t(),p.remove()});let w=document.createElement("button");return w.type="button",w.className="persona-feedback-btn persona-feedback-btn-submit",w.textContent=s,w.addEventListener("click",async()=>{if(f===null){S.classList.add("persona-feedback-shake"),setTimeout(()=>S.classList.remove("persona-feedback-shake"),500);return}w.disabled=!0,w.textContent="Submitting...";try{let C=(E==null?void 0:E.value.trim())||void 0;await e(f,C),p.remove()}catch(C){w.disabled=!1,w.textContent=s,console.error("[CSAT Feedback] Failed to submit:",C)}}),k.appendChild(h),k.appendChild(w),u.appendChild(k),p.appendChild(u),p}function Kl(r){let{onSubmit:e,onDismiss:t,title:n="How likely are you to recommend us?",subtitle:o="On a scale of 0 to 10",commentPlaceholder:a="What could we do better? (optional)...",submitText:s="Submit",skipText:i="Skip",showComment:d=!0,lowLabel:l="Not likely",highLabel:p="Very likely"}=r,f=document.createElement("div");f.className="persona-feedback-container persona-feedback-nps",f.setAttribute("role","dialog"),f.setAttribute("aria-label","Net Promoter Score feedback");let u=null,m=document.createElement("div");m.className="persona-feedback-content";let v=document.createElement("div");v.className="persona-feedback-header";let x=document.createElement("h3");x.className="persona-feedback-title",x.textContent=n,v.appendChild(x);let S=document.createElement("p");S.className="persona-feedback-subtitle",S.textContent=o,v.appendChild(S),m.appendChild(v);let M=document.createElement("div");M.className="persona-feedback-rating persona-feedback-rating-nps",M.setAttribute("role","radiogroup"),M.setAttribute("aria-label","Likelihood rating from 0 to 10");let E=document.createElement("div");E.className="persona-feedback-labels";let k=document.createElement("span");k.className="persona-feedback-label-low",k.textContent=l;let h=document.createElement("span");h.className="persona-feedback-label-high",h.textContent=p,E.appendChild(k),E.appendChild(h);let w=document.createElement("div");w.className="persona-feedback-numbers";let C=[];for(let N=0;N<=10;N++){let V=document.createElement("button");V.type="button",V.className="persona-feedback-rating-btn persona-feedback-number-btn",V.setAttribute("role","radio"),V.setAttribute("aria-checked","false"),V.setAttribute("aria-label",`Rating ${N} out of 10`),V.textContent=String(N),V.dataset.rating=String(N),N<=6?V.classList.add("persona-feedback-detractor"):N<=8?V.classList.add("persona-feedback-passive"):V.classList.add("persona-feedback-promoter"),V.addEventListener("click",()=>{u=N,C.forEach((ie,xe)=>{ie.classList.toggle("selected",xe===N),ie.setAttribute("aria-checked",xe===N?"true":"false")})}),C.push(V),w.appendChild(V)}M.appendChild(E),M.appendChild(w),m.appendChild(M);let T=null;if(d){let N=document.createElement("div");N.className="persona-feedback-comment-container",T=document.createElement("textarea"),T.className="persona-feedback-comment",T.placeholder=a,T.rows=3,T.setAttribute("aria-label","Additional comments"),N.appendChild(T),m.appendChild(N)}let W=document.createElement("div");W.className="persona-feedback-actions";let R=document.createElement("button");R.type="button",R.className="persona-feedback-btn persona-feedback-btn-skip",R.textContent=i,R.addEventListener("click",()=>{t==null||t(),f.remove()});let I=document.createElement("button");return I.type="button",I.className="persona-feedback-btn persona-feedback-btn-submit",I.textContent=s,I.addEventListener("click",async()=>{if(u===null){w.classList.add("persona-feedback-shake"),setTimeout(()=>w.classList.remove("persona-feedback-shake"),500);return}I.disabled=!0,I.textContent="Submitting...";try{let N=(T==null?void 0:T.value.trim())||void 0;await e(u,N),f.remove()}catch(N){I.disabled=!1,I.textContent=s,console.error("[NPS Feedback] Failed to submit:",N)}}),W.appendChild(R),W.appendChild(I),m.appendChild(W),f.appendChild(m),f}var es="persona-chat-history",hC=30*1e3,xC={"image/png":"png","image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg","image/bmp":"bmp","image/tiff":"tiff"};function bC(r){var n,o,a;if(!r)return[];let e=[],t=Array.from((n=r.items)!=null?n:[]);for(let s of t){if(s.kind!=="file"||!s.type.startsWith("image/"))continue;let i=s.getAsFile();if(!i)continue;if(i.name){e.push(i);continue}let d=(o=xC[i.type])!=null?o:"png";e.push(new File([i],`clipboard-image-${Date.now()}.${d}`,{type:i.type,lastModified:Date.now()}))}if(e.length>0)return e;for(let s of Array.from((a=r.files)!=null?a:[]))s.type.startsWith("image/")&&e.push(s);return e}function Xl(r){if(!r)return!1;let e=r.types;return e?typeof e.contains=="function"?e.contains("Files"):Array.from(e).includes("Files"):!1}function yC(r){var e,t,n,o,a,s,i,d,l;return r?r===!0?{storage:"session",keyPrefix:"persona-",persist:{openState:!0,voiceState:!0,focusInput:!0},clearOnChatClear:!0}:{storage:(e=r.storage)!=null?e:"session",keyPrefix:(t=r.keyPrefix)!=null?t:"persona-",persist:{openState:(o=(n=r.persist)==null?void 0:n.openState)!=null?o:!0,voiceState:(s=(a=r.persist)==null?void 0:a.voiceState)!=null?s:!0,focusInput:(d=(i=r.persist)==null?void 0:i.focusInput)!=null?d:!0},clearOnChatClear:(l=r.clearOnChatClear)!=null?l:!0}:null}function vC(r){try{let e=r==="local"?localStorage:sessionStorage,t="__persist_test__";return e.setItem(t,"1"),e.removeItem(t),e}catch{return null}}var nu=r=>!r||typeof r!="object"?{}:{...r},Kx=r=>r.map(e=>({...e,streaming:!1})),Xx=(r,e,t)=>{let n=r!=null&&r.markdown?sa(r.markdown):null,o=Da(r==null?void 0:r.sanitize);return r!=null&&r.postprocessMessage&&o&&(r==null?void 0:r.sanitize)===void 0&&console.warn("[Persona] A custom postprocessMessage is active with the default HTML sanitizer. Tags or attributes not in the built-in allowlist will be stripped. To keep custom HTML, set `sanitize: false` or provide a custom sanitize function."),a=>{var l,p,f;let s=(l=a.text)!=null?l:"",i=(p=a.message.rawContent)!=null?p:null;if(e){let u=e.process({text:s,raw:i!=null?i:s,message:a.message,streaming:a.streaming});u!==null&&(s=u.text,u.persist||(a.message.__skipPersist=!0),u.resubmit&&!a.streaming&&t&&t())}let d;return r!=null&&r.postprocessMessage?d=r.postprocessMessage({...a,text:s,raw:(f=i!=null?i:a.text)!=null?f:""}):n?d=n(s):d=ia(s),o?o(d):d}};function Qx(r){var i,d,l,p;let e=y("div","persona-attachment-drop-overlay");r!=null&&r.background&&e.style.setProperty("--persona-drop-overlay-bg",r.background),(r==null?void 0:r.backdropBlur)!==void 0&&e.style.setProperty("--persona-drop-overlay-blur",r.backdropBlur),r!=null&&r.border&&e.style.setProperty("--persona-drop-overlay-border",r.border),r!=null&&r.borderRadius&&e.style.setProperty("--persona-drop-overlay-radius",r.borderRadius),r!=null&&r.inset&&e.style.setProperty("--persona-drop-overlay-inset",r.inset),r!=null&&r.labelSize&&e.style.setProperty("--persona-drop-overlay-label-size",r.labelSize),r!=null&&r.labelColor&&e.style.setProperty("--persona-drop-overlay-label-color",r.labelColor);let t=(i=r==null?void 0:r.iconName)!=null?i:"upload",n=(d=r==null?void 0:r.iconSize)!=null?d:"48px",o=(l=r==null?void 0:r.iconColor)!=null?l:"rgba(59, 130, 246, 0.6)",a=(p=r==null?void 0:r.iconStrokeWidth)!=null?p:.5,s=Me(t,n,o,a);if(s&&e.appendChild(s),r!=null&&r.label){let f=y("span","persona-drop-overlay-label");f.textContent=r.label,e.appendChild(f)}return e}var Ql=(r,e,t)=>{var Bu,Du,Fu,Nu,Ou,_u,Uu,qu,zu,$u,Vu,ju,Gu,Ku,Xu,Qu,Ju,Yu,Zu,ef,tf,rf,nf,of,af,sf,lf,df,cf,pf,uf,ff,mf,gf,hf,xf,bf,yf,vf,Cf,wf,Af,Sf,Tf,Mf,kf,Ef,Lf,Pf,Rf;if(r==null)throw new Error('createAgentExperience: mount must be a non-null HTMLElement (e.g. pass document.getElementById("my-root") after the node exists).');r.id&&!r.getAttribute("data-persona-instance")&&r.setAttribute("data-persona-instance",r.id),r.hasAttribute("data-persona-root")||r.setAttribute("data-persona-root","true");let n=pl(e),o=ti.getForInstance(n.plugins);n.components&&Co.registerAll(n.components);let a=zx(),i=n.persistState===!1?null:(Bu=n.storageAdapter)!=null?Bu:ql(),d={},l=null,p=!1,f=c=>{if(n.onStateLoaded)try{let g=n.onStateLoaded(c);if(g&&typeof g=="object"&&"state"in g){let{state:b,open:A}=g;return A&&(p=!0),b}return g}catch(g){typeof console!="undefined"&&console.error("[AgentWidget] onStateLoaded hook failed:",g)}return c};if(i!=null&&i.load)try{let c=i.load();if(c&&typeof c.then=="function")l=c.then(g=>{let b=g!=null?g:{messages:[],metadata:{}};return f(b)});else{let g=c!=null?c:{messages:[],metadata:{}},b=f(g);b.metadata&&(d=nu(b.metadata)),(Du=b.messages)!=null&&Du.length&&(n={...n,initialMessages:b.messages}),(Fu=b.artifacts)!=null&&Fu.length&&(n={...n,initialArtifacts:b.artifacts,initialSelectedArtifactId:(Nu=b.selectedArtifactId)!=null?Nu:null})}}catch(c){typeof console!="undefined"&&console.error("[AgentWidget] Failed to load stored state:",c)}else if(n.onStateLoaded)try{let c=f({messages:[],metadata:{}});(Ou=c.messages)!=null&&Ou.length&&(n={...n,initialMessages:c.messages})}catch(c){typeof console!="undefined"&&console.error("[AgentWidget] onStateLoaded hook failed:",c)}let u=()=>d,m=c=>{var b;d=(b=c({...d}))!=null?b:{},Ma()},v=n.actionParsers&&n.actionParsers.length?n.actionParsers:[ri],x=n.actionHandlers&&n.actionHandlers.length?n.actionHandlers:[va.message,va.messageAndClick],S=ni({parsers:v,handlers:x,getSessionMetadata:u,updateSessionMetadata:m,emit:a.emit,documentRef:typeof document!="undefined"?document:null});S.syncFromMetadata();let M=(Uu=(_u=n.launcher)==null?void 0:_u.enabled)!=null?Uu:!0,E=(zu=(qu=n.launcher)==null?void 0:qu.autoExpand)!=null?zu:!1,k=($u=n.autoFocusInput)!=null?$u:!1,h=E,w=M,C=(ju=(Vu=n.layout)==null?void 0:Vu.header)==null?void 0:ju.layout,T=!1,W=()=>Oo(n),R=()=>M||W(),I=W()?!1:M?E:!0,N=!1,V=null,ie=()=>{N=!0,V&&clearTimeout(V),V=setTimeout(()=>{N&&(typeof console!="undefined"&&console.warn("[AgentWidget] Resubmit requested but no injection occurred within 10s"),N=!1)},1e4)},xe=Xx(n,S,ie),Je=(Ku=(Gu=n.features)==null?void 0:Gu.showReasoning)!=null?Ku:!0,we=(Qu=(Xu=n.features)==null?void 0:Xu.showToolCalls)!=null?Qu:!0,De=(Yu=(Ju=n.features)==null?void 0:Ju.showEventStreamToggle)!=null?Yu:!1,Ae=(ef=(Zu=n.features)==null?void 0:Zu.scrollToBottom)!=null?ef:{},qe=(rf=(tf=n.features)==null?void 0:tf.scrollBehavior)!=null?rf:{},J=`${(of=typeof n.persistState=="object"?(nf=n.persistState)==null?void 0:nf.keyPrefix:void 0)!=null?of:"persona-"}event-stream`,re=De?new Zs(J):null,Q=(lf=(sf=(af=n.features)==null?void 0:af.eventStream)==null?void 0:sf.maxEvents)!=null?lf:2e3,ge=De?new Ys(Q,re):null,Z=De?new ei:null,G=null,pe=!1,ke=null,le=0;re==null||re.open().then(()=>ge==null?void 0:ge.restore()).catch(c=>{n.debug&&console.warn("[AgentWidget] IndexedDB not available for event stream:",c)});let ne={onCopy:c=>{var g,b;a.emit("message:copy",c),q!=null&&q.isClientTokenMode()&&q.submitMessageFeedback(c.id,"copy").catch(A=>{n.debug&&console.error("[AgentWidget] Failed to submit copy feedback:",A)}),(b=(g=n.messageActions)==null?void 0:g.onCopy)==null||b.call(g,c)},onFeedback:c=>{var g,b;a.emit("message:feedback",c),q!=null&&q.isClientTokenMode()&&q.submitMessageFeedback(c.messageId,c.type).catch(A=>{n.debug&&console.error("[AgentWidget] Failed to submit feedback:",A)}),(b=(g=n.messageActions)==null?void 0:g.onFeedback)==null||b.call(g,c)}},de=(df=n.statusIndicator)!=null?df:{},Lt=c=>{var g,b,A,H;return c==="idle"?(g=de.idleText)!=null?g:jr.idle:c==="connecting"?(b=de.connectingText)!=null?b:jr.connecting:c==="connected"?(A=de.connectedText)!=null?A:jr.connected:c==="error"?(H=de.errorText)!=null?H:jr.error:jr[c]};function St(c,g,b,A){if(A==="idle"&&b.idleLink){c.textContent="";let H=document.createElement("a");H.href=b.idleLink,H.target="_blank",H.rel="noopener noreferrer",H.textContent=g,H.style.color="inherit",H.style.textDecoration="none",c.appendChild(H)}else c.textContent=g}let{wrapper:We,panel:he,pillRoot:at}=ax(n),Pe=sx(n,R()),{container:j,body:ue,messagesWrapper:nt,suggestions:It,textarea:ee,sendButton:je,sendButtonWrapper:Fr,composerForm:Dt,statusText:ar,introTitle:gr,introSubtitle:nn,closeButton:F,iconHolder:fe,headerTitle:Re,headerSubtitle:Xe,header:Fe,footer:Oe,actionsRow:Ye,leftActions:Tt,rightActions:Qt}=Pe,sr=Pe.setSendButtonMode,K=Pe.micButton,ft=Pe.micButtonWrapper,it=Pe.attachmentButton,ye=Pe.attachmentButtonWrapper,se=Pe.attachmentInput,st=Pe.attachmentPreviewsContainer;j.classList.add("persona-relative"),ue.classList.add("persona-relative");let ur=12,ct=()=>{var c;return(c=Ae.label)!=null?c:""},xr=()=>{var c;return(c=Ae.iconName)!=null?c:"arrow-down"},Ir=()=>Ae.enabled!==!1,pt=()=>{var c;return(c=qe.mode)!=null?c:"follow"},Pt=()=>{var c;return(c=qe.anchorTopOffset)!=null?c:16},et=y("button","persona-scroll-to-bottom-indicator persona-absolute persona-bottom-3 persona-left-1/2 persona-z-10 persona-flex persona-items-center persona-gap-1 persona-text-xs persona-transform persona--translate-x-1/2 persona-cursor-pointer");et.type="button",et.style.display="none",et.setAttribute("data-persona-scroll-to-bottom","true");let $t=y("span","persona-flex persona-items-center"),br=y("span",""),ir=y("span","");ir.setAttribute("data-persona-scroll-to-bottom-count",""),ir.style.display="none",et.append($t,br,ir),j.appendChild(et);let fr=y("div","persona-stream-anchor-spacer");fr.setAttribute("aria-hidden","true"),fr.setAttribute("data-persona-anchor-spacer",""),fr.style.flexShrink="0",fr.style.pointerEvents="none",fr.style.height="0px",ue.appendChild(fr);let Sr=()=>{let g=Oe.style.display==="none"?0:Oe.offsetHeight;et.style.bottom=`${g+ur}px`};Sr();let cn=()=>{let c=!!ct();et.setAttribute("aria-label",ct()||"Jump to latest"),et.title=ct(),et.setAttribute("data-persona-scroll-to-bottom-has-label",c?"true":"false"),$t.innerHTML="";let g=Me(xr(),"14px","currentColor",2);g?($t.appendChild(g),$t.style.display=""):$t.style.display="none",br.textContent=ct(),br.style.display=c?"":"none"};cn();let Mt=null,_r=null,hr=o.find(c=>c.renderHeader);if(hr!=null&&hr.renderHeader){let c=hr.renderHeader({config:n,defaultRenderer:()=>{let g=bo({config:n,showClose:R()});return ha(j,g,n),g.header},onClose:()=>Gt(!1,"user")});if(c){let g=j.querySelector(".persona-border-b-persona-divider");g&&(g.replaceWith(c),Fe=c)}}let An=()=>{var g,b,A,H;if(!ge)return;if(pe=!0,!G&&ge&&(G=Wx({buffer:ge,getFullHistory:()=>ge.getAllFromStore(),onClose:()=>on(),config:n,plugins:o,getThroughput:()=>{var _;return(_=Z==null?void 0:Z.getMetric())!=null?_:{status:"idle"}}})),G&&(ue.style.display="none",(g=Oe.parentNode)==null||g.insertBefore(G.element,Oe),G.update()),Ct){Ct.style.boxShadow=`inset 0 0 0 1.5px ${rn.actionIconColor}`;let _=(H=(A=(b=n.features)==null?void 0:b.eventStream)==null?void 0:A.classNames)==null?void 0:H.toggleButtonActive;_&&_.split(/\s+/).forEach(U=>U&&Ct.classList.add(U))}let c=()=>{if(!pe)return;let _=Date.now();_-le>=200&&(G==null||G.update(),le=_),ke=requestAnimationFrame(c)};le=0,ke=requestAnimationFrame(c),sn(),a.emit("eventStream:opened",{timestamp:Date.now()})},on=()=>{var c,g,b;if(pe){if(pe=!1,G&&G.element.remove(),ue.style.display="",Ct){Ct.style.boxShadow="";let A=(b=(g=(c=n.features)==null?void 0:c.eventStream)==null?void 0:g.classNames)==null?void 0:b.toggleButtonActive;A&&A.split(/\s+/).forEach(H=>H&&Ct.classList.remove(H))}ke!==null&&(cancelAnimationFrame(ke),ke=null),sn(),a.emit("eventStream:closed",{timestamp:Date.now()})}},Ct=null;if(De){let c=(pf=(cf=n.features)==null?void 0:cf.eventStream)==null?void 0:pf.classNames,g="persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-opacity-80 persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-1"+(c!=null&&c.toggleButton?" "+c.toggleButton:"");Ct=y("button",g),Ct.style.width="28px",Ct.style.height="28px",Ct.style.color=rn.actionIconColor,Ct.type="button",Ct.setAttribute("aria-label","Event Stream"),Ct.title="Event Stream";let b=Me("activity","18px","currentColor",1.5);b&&Ct.appendChild(b);let A=Pe.clearChatButtonWrapper,H=Pe.closeButtonWrapper,_=A||H;_&&_.parentNode===Fe?Fe.insertBefore(Ct,_):Fe.appendChild(Ct),Ct.addEventListener("click",()=>{pe?on():An()})}let jn=c=>{var A,H,_;let g=n.attachments;if(!(g!=null&&g.enabled))return;let b=c.querySelector(".persona-attachment-previews");if(!b){b=y("div","persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2"),b.style.display="none";let U=c.querySelector("[data-persona-composer-form]");U!=null&&U.parentNode?U.parentNode.insertBefore(b,U):c.insertBefore(b,c.firstChild)}if(!c.querySelector('input[type="file"]')){let U=y("input");U.type="file",U.accept=((A=g.allowedTypes)!=null?A:ho).join(","),U.multiple=((H=g.maxFiles)!=null?H:4)>1,U.style.display="none",U.setAttribute("aria-label",(_=g.buttonTooltipText)!=null?_:"Attach files"),c.appendChild(U)}},Sn=o.find(c=>c.renderComposer);if(Sn!=null&&Sn.renderComposer){let c=n.composer,g=Sn.renderComposer({config:n,defaultRenderer:()=>Va({config:n}).footer,onSubmit:b=>{var U;if(!q||q.isStreaming())return;let A=b.trim(),H=(U=Mt==null?void 0:Mt.hasAttachments())!=null?U:!1;if(!A&&!H)return;L();let _;H&&(_=[],_.push(...Mt.getContentParts()),A&&_.push(Fs(A))),q.sendMessage(A,{contentParts:_}),H&&Mt.clearAttachments()},streaming:!1,disabled:!1,openAttachmentPicker:()=>{se==null||se.click()},models:c==null?void 0:c.models,selectedModelId:c==null?void 0:c.selectedModelId,onModelChange:b=>{n.composer={...n.composer,selectedModelId:b},n.agent&&(n.agent={...n.agent,model:b})},onVoiceToggle:((uf=n.voiceRecognition)==null?void 0:uf.enabled)===!0?()=>{_r==null||_r()}:void 0});g&&(Oe.replaceWith(g),Oe=g)}let _e=c=>{let g=c.querySelector("[data-persona-composer-form]"),b=c.querySelector("[data-persona-composer-input]"),A=c.querySelector("[data-persona-composer-submit]"),H=c.querySelector("[data-persona-composer-mic]"),_=c.querySelector("[data-persona-composer-status]");g&&(Dt=g),b&&(ee=b),A&&(je=A),H&&(K=H,ft=H.parentElement),_&&(ar=_);let U=c.querySelector(".persona-mb-3.persona-flex.persona-flex-wrap.persona-gap-2");U&&(It=U);let $=c.querySelector(".persona-attachment-button");$&&(it=$,ye=$.parentElement),se=c.querySelector('input[type="file"]'),st=c.querySelector(".persona-attachment-previews");let O=c.querySelector(".persona-widget-composer .persona-flex.persona-items-center.persona-justify-between");O&&(Ye=O)};jn(Oe),_e(Oe);let P=(xf=(ff=n.layout)==null?void 0:ff.contentMaxWidth)!=null?xf:W()?(hf=(gf=(mf=n.launcher)==null?void 0:mf.composerBar)==null?void 0:gf.contentMaxWidth)!=null?hf:"720px":void 0;if(P&&(nt.style.maxWidth=P,nt.style.marginLeft="auto",nt.style.marginRight="auto",nt.style.width="100%"),P&&Dt&&!W()&&(Dt.style.maxWidth=P,Dt.style.marginLeft="auto",Dt.style.marginRight="auto"),P&&It&&!W()&&(It.style.maxWidth=P,It.style.marginLeft="auto",It.style.marginRight="auto"),P&&st&&!W()&&(st.style.maxWidth=P,st.style.marginLeft="auto",st.style.marginRight="auto"),(bf=n.attachments)!=null&&bf.enabled&&se&&st){Mt=fa.fromConfig(n.attachments),Mt.setPreviewsContainer(st),se.addEventListener("change",b=>{let A=b.target;Mt==null||Mt.handleFileSelect(A.files),A.value=""});let c=n.attachments.dropOverlay,g=Qx(c);j.appendChild(g)}(()=>{var A,H;let c=(H=(A=n.layout)==null?void 0:A.slots)!=null?H:{},g=_=>{switch(_){case"body-top":return j.querySelector(".persona-rounded-2xl.persona-bg-persona-surface.persona-p-6")||null;case"messages":return nt;case"footer-top":return It;case"composer":return Dt;case"footer-bottom":return ar;default:return null}},b=(_,U)=>{var $;switch(_){case"header-left":case"header-center":case"header-right":if(_==="header-left")Fe.insertBefore(U,Fe.firstChild);else if(_==="header-right")Fe.appendChild(U);else{let O=Fe.querySelector(".persona-flex-col");O?($=O.parentNode)==null||$.insertBefore(U,O.nextSibling):Fe.appendChild(U)}break;case"body-top":{let O=ue.querySelector(".persona-rounded-2xl.persona-bg-persona-surface.persona-p-6");O?O.replaceWith(U):ue.insertBefore(U,ue.firstChild);break}case"body-bottom":ue.appendChild(U);break;case"footer-top":It.replaceWith(U);break;case"footer-bottom":ar.replaceWith(U);break;default:break}};for(let[_,U]of Object.entries(c))if(U)try{let $=U({config:n,defaultContent:()=>g(_)});$&&b(_,$)}catch($){typeof console!="undefined"&&console.error(`[AgentWidget] Error rendering slot "${_}":`,$)}})();let Ee=c=>{var U,$;let b=c.target.closest('button[data-expand-header="true"]');if(!b)return;let A=b.closest(".persona-reasoning-bubble, .persona-tool-bubble, .persona-approval-bubble");if(!A)return;let H=A.getAttribute("data-message-id");if(!H)return;let _=b.getAttribute("data-bubble-type");if(_==="reasoning")Ga.has(H)?Ga.delete(H):Ga.add(H),cx(H,A);else if(_==="tool")Ka.has(H)?Ka.delete(H):Ka.add(H),px(H,A,n);else if(_==="approval"){let O=n.approval!==!1?n.approval:void 0,Ce=((U=O==null?void 0:O.detailsDisplay)!=null?U:"collapsed")==="expanded",me=($=Fl.get(H))!=null?$:Ce;Fl.set(H,!me),Ex(H,A,n)}ao.delete(H)};nt.addEventListener("pointerdown",c=>{c.target.closest('button[data-expand-header="true"]')&&(c.preventDefault(),Ee(c))}),nt.addEventListener("keydown",c=>{let g=c.target;(c.key==="Enter"||c.key===" ")&&g.closest('button[data-expand-header="true"]')&&(c.preventDefault(),Ee(c))});let Ot=new Map;nt.addEventListener("click",c=>{var U;let b=c.target.closest(".persona-message-action-btn[data-action]");if(!b)return;c.preventDefault(),c.stopPropagation();let A=b.closest("[data-actions-for]");if(!A)return;let H=A.getAttribute("data-actions-for");if(!H)return;let _=b.getAttribute("data-action");if(_==="copy"){let O=q.getMessages().find(Ce=>Ce.id===H);if(O&&ne.onCopy){let Ce=O.content||"";navigator.clipboard.writeText(Ce).then(()=>{b.classList.add("persona-message-action-success");let me=Me("check",14,"currentColor",2);me&&(b.innerHTML="",b.appendChild(me)),setTimeout(()=>{b.classList.remove("persona-message-action-success");let oe=Me("copy",14,"currentColor",2);oe&&(b.innerHTML="",b.appendChild(oe))},2e3)}).catch(me=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to copy message:",me)}),ne.onCopy(O)}}else if(_==="upvote"||_==="downvote"){let O=((U=Ot.get(H))!=null?U:null)===_,Ce=_==="upvote"?"thumbs-up":"thumbs-down";if(O){Ot.delete(H),b.classList.remove("persona-message-action-active");let me=Me(Ce,14,"currentColor",2);me&&(b.innerHTML="",b.appendChild(me))}else{let me=_==="upvote"?"downvote":"upvote",oe=A.querySelector(`[data-action="${me}"]`);if(oe){oe.classList.remove("persona-message-action-active");let Qe=Me(me==="upvote"?"thumbs-up":"thumbs-down",14,"currentColor",2);Qe&&(oe.innerHTML="",oe.appendChild(Qe))}Ot.set(H,_),b.classList.add("persona-message-action-active");let Te=Me(Ce,14,"currentColor",2);Te&&(Te.setAttribute("fill","currentColor"),b.innerHTML="",b.appendChild(Te)),b.classList.remove("persona-message-action-pop"),b.offsetWidth,b.classList.add("persona-message-action-pop");let Se=q.getMessages().find(dt=>dt.id===H);Se&&ne.onFeedback&&ne.onFeedback({type:_,messageId:Se.id,message:Se})}}}),nt.addEventListener("click",c=>{let b=c.target.closest("button[data-approval-action]");if(!b)return;c.preventDefault(),c.stopPropagation();let A=b.closest(".persona-approval-bubble");if(!A)return;let H=A.getAttribute("data-message-id");if(!H)return;let _=b.getAttribute("data-approval-action");if(!_)return;let U=_==="approve"?"approved":"denied",O=q.getMessages().find(me=>me.id===H);if(!(O!=null&&O.approval))return;let Ce=A.querySelector("[data-approval-buttons]");Ce&&Ce.querySelectorAll("button").forEach(oe=>{oe.disabled=!0,oe.style.opacity="0.5",oe.style.cursor="not-allowed"}),O.approval.toolType==="webmcp"?q.resolveWebMcpApproval(H,U):q.resolveApproval(O.approval,U)});let Ze=null,_t=null,Zt={artifacts:[],selectedId:null},dr=!1,wt={current:null};nt.addEventListener("click",c=>{var oe,Te,Ve,Se,dt;let b=c.target.closest("[data-download-artifact]");if(!b)return;c.preventDefault(),c.stopPropagation();let A=b.getAttribute("data-download-artifact");if(!A||((Ve=(Te=(oe=n.features)==null?void 0:oe.artifacts)==null?void 0:Te.onArtifactAction)==null?void 0:Ve.call(Te,{type:"download",artifactId:A}))===!0)return;let _=q.getArtifactById(A),U=_==null?void 0:_.markdown,$=(_==null?void 0:_.title)||"artifact";if(!U){let Qe=b.closest("[data-open-artifact]"),ht=Qe==null?void 0:Qe.closest("[data-message-id]"),xt=ht==null?void 0:ht.getAttribute("data-message-id");if(xt){let Le=q.getMessages().find(Ke=>Ke.id===xt);if(Le!=null&&Le.rawContent)try{let Ke=JSON.parse(Le.rawContent);U=(Se=Ke==null?void 0:Ke.props)==null?void 0:Se.markdown,$=((dt=Ke==null?void 0:Ke.props)==null?void 0:dt.title)||$}catch{}}}if(!U)return;let O=new Blob([U],{type:"text/markdown"}),Ce=URL.createObjectURL(O),me=document.createElement("a");me.href=Ce,me.download=`${$}.md`,me.click(),URL.revokeObjectURL(Ce)}),nt.addEventListener("click",c=>{var _,U,$;let b=c.target.closest("[data-open-artifact]");if(!b)return;let A=b.getAttribute("data-open-artifact");!A||(($=(U=(_=n.features)==null?void 0:_.artifacts)==null?void 0:U.onArtifactAction)==null?void 0:$.call(U,{type:"open",artifactId:A}))===!0||(c.preventDefault(),c.stopPropagation(),dr=!1,q.selectArtifact(A),un())}),nt.addEventListener("keydown",c=>{if(c.key!=="Enter"&&c.key!==" ")return;let g=c.target;g.hasAttribute("data-open-artifact")&&(c.preventDefault(),g.click())});let Ur=Pe.composerOverlay,Vt=(c,g,b)=>{var $,O,Ce,me;let A=g.trim();if(!A||!wt.current)return;let H=($=c.getAttribute("data-tool-call-id"))!=null?$:"",_=b.source==="free-text";r.dispatchEvent(new CustomEvent("persona:askUserQuestion:answered",{detail:{toolUseId:H,answer:A,answers:b.structured,values:(O=b.values)!=null?O:b.source==="multi"?A.split(", "):[A],isFreeText:_,source:b.source},bubbles:!0,composed:!0})),zo(Ur,H);let U=wt.current.getMessages().find(oe=>{var Te;return((Te=oe.toolCall)==null?void 0:Te.id)===H});(Ce=U==null?void 0:U.agentMetadata)!=null&&Ce.awaitingLocalTool?wt.current.resolveAskUserQuestion(U,(me=b.structured)!=null?me:A):wt.current.sendMessage(A)},qr=c=>{var H;let g=wt.current;if(!g)return;let b=(H=c.getAttribute("data-tool-call-id"))!=null?H:"",A=g.getMessages().find(_=>{var U;return((U=_.toolCall)==null?void 0:U.id)===b});A&&g.persistAskUserQuestionProgress(A,{answers:Bl(c,A),currentIndex:Bn(c)})},Fn=c=>Object.entries(c).map(([g,b])=>`${g}: ${Array.isArray(b)?b.join(", "):b}`).join(" | "),no=c=>{var H,_,U;if(((_=(H=n.features)==null?void 0:H.askUserQuestion)==null?void 0:_.groupedAutoAdvance)===!1)return;let g=Bn(c),b=Qa(c);if(g>=b-1)return;let A=(U=wt.current)==null?void 0:U.getMessages().find($=>{var O;return((O=$.toolCall)==null?void 0:O.id)===c.getAttribute("data-tool-call-id")});A&&(Dl(c,A,n,g+1),qr(c))};Ur.addEventListener("click",c=>{var _,U,$,O,Ce,me,oe,Te,Ve,Se,dt,Qe,ht,xt;let b=c.target.closest("[data-ask-user-action]");if(!b)return;let A=b.closest("[data-persona-ask-sheet-for]");if(!A)return;let H=b.getAttribute("data-ask-user-action");if(c.preventDefault(),c.stopPropagation(),H==="dismiss"){let Be=(_=A.getAttribute("data-tool-call-id"))!=null?_:"";r.dispatchEvent(new CustomEvent("persona:askUserQuestion:dismissed",{detail:{toolUseId:Be},bubbles:!0,composed:!0})),zo(Ur,Be);let Le=(U=wt.current)==null?void 0:U.getMessages().find(Ke=>{var rt;return((rt=Ke.toolCall)==null?void 0:rt.id)===Be});($=Le==null?void 0:Le.agentMetadata)!=null&&$.awaitingLocalTool&&((O=wt.current)==null||O.markAskUserQuestionResolved(Le),(Ce=wt.current)==null||Ce.resolveAskUserQuestion(Le,"(dismissed)"));return}if(H==="pick"){let Be=b.getAttribute("data-option-label");if(!Be)return;let Le=A.getAttribute("data-multi-select")==="true",Ke=qo(A);if(Ke&&Le){let rt=ba(A)[Bn(A)],Wt=new Set(Array.isArray(rt)?rt:[]);Wt.has(Be)?Wt.delete(Be):Wt.add(Be),$o(A,Array.from(Wt)),qr(A);return}if(Ke){$o(A,Be),qr(A),no(A);return}if(Le){let rt=b.getAttribute("aria-pressed")==="true";b.setAttribute("aria-pressed",rt?"false":"true"),b.classList.toggle("persona-ask-pill-selected",!rt);let Wt=A.querySelector('[data-ask-user-action="submit-multi"]');Wt&&(Wt.disabled=Qp(A).length===0);return}Vt(A,Be,{source:"pick",values:[Be]});return}if(H==="submit-multi"){let Be=Qp(A);if(Be.length===0)return;Vt(A,Be.join(", "),{source:"multi",values:Be});return}if(H==="open-free-text"){let Be=A.querySelector('[data-ask-free-text-row="true"]');if(Be){Be.classList.remove("persona-hidden");let Le=Be.querySelector('[data-ask-free-text-input="true"]');Le==null||Le.focus()}return}if(H==="focus-free-text"){let Be=A.querySelector('[data-ask-free-text-input="true"]');Be==null||Be.focus();return}if(H==="submit-free-text"){let Be=A.querySelector('[data-ask-free-text-input="true"]'),Le=(me=Be==null?void 0:Be.value)!=null?me:"";if(!Le.trim())return;if(qo(A)){$o(A,Le.trim()),qr(A),no(A);return}Vt(A,Le,{source:"free-text"});return}if(H==="next"||H==="back"){if(!wt.current)return;let Be=(oe=A.getAttribute("data-tool-call-id"))!=null?oe:"",Le=wt.current.getMessages().find(Ne=>{var Ue;return((Ue=Ne.toolCall)==null?void 0:Ue.id)===Be});if(!Le)return;let Ke=A.querySelector('[data-ask-free-text-input="true"]'),rt=(Ve=(Te=Ke==null?void 0:Ke.value)==null?void 0:Te.trim())!=null?Ve:"";if(rt){let Ne=ba(A)[Bn(A)];(typeof Ne!="string"||Ne!==rt)&&$o(A,rt)}let Wt=H==="next"?1:-1,D=Bn(A)+Wt;Dl(A,Le,n,D),qr(A);return}if(H==="submit-all"){if(!wt.current)return;let Be=(Se=A.getAttribute("data-tool-call-id"))!=null?Se:"",Le=wt.current.getMessages().find(Ne=>{var Ue;return((Ue=Ne.toolCall)==null?void 0:Ue.id)===Be});if(!Le)return;let Ke=A.querySelector('[data-ask-free-text-input="true"]'),rt=(Qe=(dt=Ke==null?void 0:Ke.value)==null?void 0:dt.trim())!=null?Qe:"";rt&&$o(A,rt);let Wt=Bl(A,Le);wt.current.persistAskUserQuestionProgress(Le,{answers:Wt,currentIndex:Bn(A)});let D=Fn(Wt);Vt(A,D||"(submitted)",{source:"submit-all",structured:Wt});return}if(H==="skip"){if(!wt.current)return;let Be=(ht=A.getAttribute("data-tool-call-id"))!=null?ht:"",Le=wt.current.getMessages().find(Ue=>{var be;return((be=Ue.toolCall)==null?void 0:be.id)===Be});if(!Le)return;let Ke=qo(A),rt=Bn(A),Wt=Qa(A),D=rt>=Wt-1;if(!Ke){r.dispatchEvent(new CustomEvent("persona:askUserQuestion:dismissed",{detail:{toolUseId:Be},bubbles:!0,composed:!0})),zo(Ur,Be),(xt=Le.agentMetadata)!=null&&xt.awaitingLocalTool&&(wt.current.markAskUserQuestionResolved(Le),wt.current.resolveAskUserQuestion(Le,"(dismissed)"));return}$o(A,"");let Ne=A.querySelector('[data-ask-free-text-input="true"]');if(Ne&&(Ne.value=""),D){let Ue=Bl(A,Le),be=Fn(Ue);Vt(A,be||"(skipped)",{source:"submit-all",structured:Ue});return}Dl(A,Le,n,rt+1),qr(A);return}}),Ur.addEventListener("keydown",c=>{var _;if(c.key!=="Enter")return;let b=c.target;if(!((_=b.matches)!=null&&_.call(b,'[data-ask-free-text-input="true"]')))return;let A=b.closest("[data-persona-ask-sheet-for]");if(!A)return;c.preventDefault();let H=b.value;if(H.trim()){if(qo(A)){$o(A,H.trim()),qr(A),no(A);return}Vt(A,H,{source:"free-text"})}});let wo=c=>{if(!/^[1-9]$/.test(c.key)||c.metaKey||c.ctrlKey||c.altKey)return;let g=c.target;if((g==null?void 0:g.tagName)==="INPUT"||(g==null?void 0:g.tagName)==="TEXTAREA"||g!=null&&g.isContentEditable)return;let b=Ur.querySelector("[data-persona-ask-sheet-for]");if(!b||b.getAttribute("data-ask-layout")!=="rows"||b.getAttribute("data-multi-select")==="true")return;let A=Number(c.key),_=b.querySelectorAll('[data-ask-pill-list="true"] [data-ask-user-action="pick"], [data-ask-pill-list="true"] [data-ask-user-action="focus-free-text"]')[A-1];_&&(c.preventDefault(),_.click())};document.addEventListener("keydown",wo);let pn=null,jt=null,Kr=null,Tn=null,Ao=()=>{};function oo(){Tn==null||Tn(),Tn=null}let So=()=>{var U;if(!pn||!jt)return;let c=r.classList.contains("persona-artifact-appearance-seamless"),b=((U=r.ownerDocument.defaultView)!=null?U:window).innerWidth<=640;if(!c||r.classList.contains("persona-artifact-narrow-host")||b){jt.style.removeProperty("position"),jt.style.removeProperty("left"),jt.style.removeProperty("top"),jt.style.removeProperty("bottom"),jt.style.removeProperty("width"),jt.style.removeProperty("z-index");return}let A=pn.firstElementChild;if(!A||A===jt)return;let H=10;jt.style.position="absolute",jt.style.top="0",jt.style.bottom="0",jt.style.width=`${H}px`,jt.style.zIndex="5";let _=A.offsetWidth-H/2;jt.style.left=`${Math.max(0,_)}px`},Gn=()=>{},un=()=>{var b,A,H,_,U;if(!Ze||!Dn(n))return;_l(r,n),Ul(r,n),Gn();let c=(_=(H=(A=(b=n.features)==null?void 0:b.artifacts)==null?void 0:A.layout)==null?void 0:H.narrowHostMaxWidth)!=null?_:520,g=he.getBoundingClientRect().width||0;r.classList.toggle("persona-artifact-narrow-host",g>0&&g<=c),Ze.update(Zt),dr?(Ze.setMobileOpen(!1),Ze.element.classList.add("persona-hidden"),(U=Ze.backdrop)==null||U.classList.add("persona-hidden")):Zt.artifacts.length>0&&(Ze.element.classList.remove("persona-hidden"),Ze.setMobileOpen(!0)),Ao()};if(Dn(n)){he.style.position="relative";let c=y("div","persona-flex persona-flex-1 persona-flex-col persona-min-w-0 persona-min-h-0"),g=y("div","persona-flex persona-h-full persona-w-full persona-min-h-0 persona-artifact-split-root");c.appendChild(j),Ze=Dx(n,{onSelect:b=>{var A;return(A=wt.current)==null?void 0:A.selectArtifact(b)},onDismiss:()=>{dr=!0,un()}}),Ze.element.classList.add("persona-hidden"),pn=g,g.appendChild(c),g.appendChild(Ze.element),Ze.backdrop&&he.appendChild(Ze.backdrop),he.appendChild(g),Ao=()=>{var A,H,_,U;if(!pn||!Ze)return;if(!(((_=(H=(A=n.features)==null?void 0:A.artifacts)==null?void 0:H.layout)==null?void 0:_.resizable)===!0)){Kr==null||Kr(),Kr=null,oo(),jt&&(jt.remove(),jt=null),Ze.element.style.removeProperty("width"),Ze.element.style.removeProperty("maxWidth");return}if(!jt){let $=y("div","persona-artifact-split-handle persona-shrink-0 persona-h-full");$.setAttribute("role","separator"),$.setAttribute("aria-orientation","vertical"),$.setAttribute("aria-label","Resize artifacts panel"),$.tabIndex=0;let O=r.ownerDocument,Ce=(U=O.defaultView)!=null?U:window,me=oe=>{var ht,xt;if(!Ze||oe.button!==0||r.classList.contains("persona-artifact-narrow-host")||Ce.innerWidth<=640)return;oe.preventDefault(),oo();let Te=oe.clientX,Ve=Ze.element.getBoundingClientRect().width,Se=(xt=(ht=n.features)==null?void 0:ht.artifacts)==null?void 0:xt.layout,dt=Be=>{let Le=pn.getBoundingClientRect().width,Ke=r.classList.contains("persona-artifact-appearance-seamless"),rt=Ke?0:_x(pn,Ce),Wt=Ke?0:$.getBoundingClientRect().width||6,D=Ve-(Be.clientX-Te),Ne=Ux(D,Le,rt,Wt,Se==null?void 0:Se.resizableMinWidth,Se==null?void 0:Se.resizableMaxWidth);Ze.element.style.width=`${Ne}px`,Ze.element.style.maxWidth="none",So()},Qe=()=>{O.removeEventListener("pointermove",dt),O.removeEventListener("pointerup",Qe),O.removeEventListener("pointercancel",Qe),Tn=null;try{$.releasePointerCapture(oe.pointerId)}catch{}};Tn=Qe,O.addEventListener("pointermove",dt),O.addEventListener("pointerup",Qe),O.addEventListener("pointercancel",Qe);try{$.setPointerCapture(oe.pointerId)}catch{}};$.addEventListener("pointerdown",me),jt=$,pn.insertBefore($,Ze.element),Kr=()=>{$.removeEventListener("pointerdown",me)}}if(jt){let $=Zt.artifacts.length>0&&!dr;jt.classList.toggle("persona-hidden",!$),So()}},Gn=()=>{var Ce,me,oe,Te,Ve,Se,dt,Qe,ht,xt,Be,Le,Ke,rt;if(!M||!Ze||((me=(Ce=n.launcher)==null?void 0:Ce.sidebarMode)!=null?me:!1)||Rr(n)&&Hn(n).reveal==="emerge")return;let A=(oe=r.ownerDocument.defaultView)!=null?oe:window,H=(Ve=(Te=n.launcher)==null?void 0:Te.mobileFullscreen)!=null?Ve:!0,_=(dt=(Se=n.launcher)==null?void 0:Se.mobileBreakpoint)!=null?dt:640;if(H&&A.innerWidth<=_||!Ox(n,M))return;let U=(xt=(ht=(Qe=n.launcher)==null?void 0:Qe.width)!=null?ht:n.launcherWidth)!=null?xt:Cn,$=(rt=(Ke=(Le=(Be=n.features)==null?void 0:Be.artifacts)==null?void 0:Le.layout)==null?void 0:Ke.expandedPanelWidth)!=null?rt:"min(720px, calc(100vw - 24px))";Zt.artifacts.length>0&&!dr?(he.style.width=$,he.style.maxWidth=$):(he.style.width=U,he.style.maxWidth=U)},typeof ResizeObserver!="undefined"&&(_t=new ResizeObserver(()=>{un()}),_t.observe(he))}else he.appendChild(j),W()&&at&&(Pe.peekBanner&&at.appendChild(Pe.peekBanner),at.appendChild(Oe));r.appendChild(We),at&&r.appendChild(at);let Nn=()=>{var Ne,Ue,be,Yt,Kt,cr,Bt,lr,hn,Tr,ot,Ut,Er,Rn,xn,Xo,Qo,Ia,Wa,mr,Jo,Wo,Ho,po,ut,Nr,Xr,Mr;if(W()){he.style.width="100%",he.style.maxWidth="100%";let bt=(Ue=(Ne=n.launcher)==null?void 0:Ne.composerBar)!=null?Ue:{},Et=We.dataset.state==="expanded",yt=(be=bt.expandedSize)!=null?be:"anchored";if(!(Et&&yt!=="fullscreen")){j.style.background="",j.style.border="",j.style.borderRadius="",j.style.overflow="",j.style.boxShadow="";return}let Lr=(Kt=(Yt=n.theme)==null?void 0:Yt.components)==null?void 0:Kt.panel,Zn=za(n),Pr=(Zo,wi)=>{var ys;return Zo==null||Zo===""?wi:(ys=Ua(Zn,Zo))!=null?ys:Zo},Qr="1px solid var(--persona-border)",In="var(--persona-palette-shadows-xl, 0 25px 50px -12px rgba(0, 0, 0, 0.25))",Yo="var(--persona-panel-radius, var(--persona-radius-xl, 0.75rem))";j.style.background="var(--persona-surface, #ffffff)",j.style.border=Pr(Lr==null?void 0:Lr.border,Qr),j.style.borderRadius=Pr(Lr==null?void 0:Lr.borderRadius,Yo),j.style.boxShadow=Pr(Lr==null?void 0:Lr.shadow,In),j.style.overflow="hidden";return}let c=Rr(n),g=(Bt=(cr=n.launcher)==null?void 0:cr.sidebarMode)!=null?Bt:!1,b=c||g||((hn=(lr=n.launcher)==null?void 0:lr.fullHeight)!=null?hn:!1),A=((Tr=n.launcher)==null?void 0:Tr.enabled)===!1,H=(Ut=(ot=n.theme)==null?void 0:ot.components)==null?void 0:Ut.panel,_=za(n),U=(bt,Et)=>{var yt;return bt==null||bt===""?Et:(yt=Ua(_,bt))!=null?yt:bt},$=(Er=r.ownerDocument.defaultView)!=null?Er:window,O=(xn=(Rn=n.launcher)==null?void 0:Rn.mobileFullscreen)!=null?xn:!0,Ce=(Qo=(Xo=n.launcher)==null?void 0:Xo.mobileBreakpoint)!=null?Qo:640,me=$.innerWidth<=Ce,oe=O&&me&&M,Te=(Wa=(Ia=n.launcher)==null?void 0:Ia.position)!=null?Wa:"bottom-left",Ve=Te==="bottom-left"||Te==="top-left",Se=(Jo=(mr=n.launcher)==null?void 0:mr.zIndex)!=null?Jo:Gr,dt=g||oe?"none":"1px solid var(--persona-border)",Qe=oe?"none":g?Ve?"var(--persona-palette-shadows-sidebar-left, 2px 0 12px rgba(0, 0, 0, 0.08))":"var(--persona-palette-shadows-sidebar-right, -2px 0 12px rgba(0, 0, 0, 0.08))":"var(--persona-palette-shadows-xl, 0 25px 50px -12px rgba(0, 0, 0, 0.25))";c&&!oe&&(Qe="none",dt="none");let ht=g||oe?"0":"var(--persona-panel-radius, var(--persona-radius-xl, 0.75rem))",xt=U(H==null?void 0:H.border,dt),Be=U(H==null?void 0:H.shadow,Qe),Le=U(H==null?void 0:H.borderRadius,ht),Ke=ue.scrollTop;r.style.cssText="",We.style.cssText="",he.style.cssText="",j.style.cssText="",ue.style.cssText="",Oe.style.cssText="";let rt=()=>{var Et;if(Ke<=0)return;((Et=ue.ownerDocument.defaultView)!=null?Et:window).requestAnimationFrame(()=>{if(ue.scrollTop===Ke)return;let yt=ue.scrollHeight-ue.clientHeight;yt<=0||(ue.scrollTop=Math.min(Ke,yt))})};if(oe){We.classList.remove("persona-bottom-6","persona-right-6","persona-left-6","persona-top-6","persona-bottom-4","persona-right-4","persona-left-4","persona-top-4"),We.style.cssText=`
|
|
78
|
+
`,E.addEventListener("click",()=>{f=v,M.forEach((H,I)=>{let P=I<v;H.classList.toggle("selected",P),H.setAttribute("aria-checked",I===v-1?"true":"false")})}),M.push(E),T.appendChild(E)}p.appendChild(T);let k=null;if(d){let v=document.createElement("div");v.className="persona-feedback-comment-container",k=document.createElement("textarea"),k.className="persona-feedback-comment",k.placeholder=a,k.rows=3,k.setAttribute("aria-label","Additional comments"),v.appendChild(k),p.appendChild(v)}let L=document.createElement("div");L.className="persona-feedback-actions";let x=document.createElement("button");x.type="button",x.className="persona-feedback-btn persona-feedback-btn-skip",x.textContent=i,x.addEventListener("click",()=>{t==null||t(),u.remove()});let w=document.createElement("button");return w.type="button",w.className="persona-feedback-btn persona-feedback-btn-submit",w.textContent=s,w.addEventListener("click",async()=>{if(f===null){T.classList.add("persona-feedback-shake"),setTimeout(()=>T.classList.remove("persona-feedback-shake"),500);return}w.disabled=!0,w.textContent="Submitting...";try{let v=(k==null?void 0:k.value.trim())||void 0;await e(f,v),u.remove()}catch(v){w.disabled=!1,w.textContent=s,console.error("[CSAT Feedback] Failed to submit:",v)}}),L.appendChild(x),L.appendChild(w),p.appendChild(L),u.appendChild(p),u}function nd(r){let{onSubmit:e,onDismiss:t,title:o="How likely are you to recommend us?",subtitle:n="On a scale of 0 to 10",commentPlaceholder:a="What could we do better? (optional)...",submitText:s="Submit",skipText:i="Skip",showComment:d=!0,lowLabel:l="Not likely",highLabel:u="Very likely"}=r,f=document.createElement("div");f.className="persona-feedback-container persona-feedback-nps",f.setAttribute("role","dialog"),f.setAttribute("aria-label","Net Promoter Score feedback");let p=null,m=document.createElement("div");m.className="persona-feedback-content";let y=document.createElement("div");y.className="persona-feedback-header";let h=document.createElement("h3");h.className="persona-feedback-title",h.textContent=o,y.appendChild(h);let T=document.createElement("p");T.className="persona-feedback-subtitle",T.textContent=n,y.appendChild(T),m.appendChild(y);let M=document.createElement("div");M.className="persona-feedback-rating persona-feedback-rating-nps",M.setAttribute("role","radiogroup"),M.setAttribute("aria-label","Likelihood rating from 0 to 10");let k=document.createElement("div");k.className="persona-feedback-labels";let L=document.createElement("span");L.className="persona-feedback-label-low",L.textContent=l;let x=document.createElement("span");x.className="persona-feedback-label-high",x.textContent=u,k.appendChild(L),k.appendChild(x);let w=document.createElement("div");w.className="persona-feedback-numbers";let v=[];for(let z=0;z<=10;z++){let j=document.createElement("button");j.type="button",j.className="persona-feedback-rating-btn persona-feedback-number-btn",j.setAttribute("role","radio"),j.setAttribute("aria-checked","false"),j.setAttribute("aria-label",`Rating ${z} out of 10`),j.textContent=String(z),j.dataset.rating=String(z),z<=6?j.classList.add("persona-feedback-detractor"):z<=8?j.classList.add("persona-feedback-passive"):j.classList.add("persona-feedback-promoter"),j.addEventListener("click",()=>{p=z,v.forEach((ie,ve)=>{ie.classList.toggle("selected",ve===z),ie.setAttribute("aria-checked",ve===z?"true":"false")})}),v.push(j),w.appendChild(j)}M.appendChild(k),M.appendChild(w),m.appendChild(M);let E=null;if(d){let z=document.createElement("div");z.className="persona-feedback-comment-container",E=document.createElement("textarea"),E.className="persona-feedback-comment",E.placeholder=a,E.rows=3,E.setAttribute("aria-label","Additional comments"),z.appendChild(E),m.appendChild(z)}let H=document.createElement("div");H.className="persona-feedback-actions";let I=document.createElement("button");I.type="button",I.className="persona-feedback-btn persona-feedback-btn-skip",I.textContent=i,I.addEventListener("click",()=>{t==null||t(),f.remove()});let P=document.createElement("button");return P.type="button",P.className="persona-feedback-btn persona-feedback-btn-submit",P.textContent=s,P.addEventListener("click",async()=>{if(p===null){w.classList.add("persona-feedback-shake"),setTimeout(()=>w.classList.remove("persona-feedback-shake"),500);return}P.disabled=!0,P.textContent="Submitting...";try{let z=(E==null?void 0:E.value.trim())||void 0;await e(p,z),f.remove()}catch(z){P.disabled=!1,P.textContent=s,console.error("[NPS Feedback] Failed to submit:",z)}}),H.appendChild(I),H.appendChild(P),m.appendChild(H),f.appendChild(m),f}var cs="persona-chat-history",QC=30*1e3,YC={"image/png":"png","image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg","image/bmp":"bmp","image/tiff":"tiff"};function JC(r){var o,n,a;if(!r)return[];let e=[],t=Array.from((o=r.items)!=null?o:[]);for(let s of t){if(s.kind!=="file"||!s.type.startsWith("image/"))continue;let i=s.getAsFile();if(!i)continue;if(i.name){e.push(i);continue}let d=(n=YC[i.type])!=null?n:"png";e.push(new File([i],`clipboard-image-${Date.now()}.${d}`,{type:i.type,lastModified:Date.now()}))}if(e.length>0)return e;for(let s of Array.from((a=r.files)!=null?a:[]))s.type.startsWith("image/")&&e.push(s);return e}function ad(r){if(!r)return!1;let e=r.types;return e?typeof e.contains=="function"?e.contains("Files"):Array.from(e).includes("Files"):!1}function ZC(r){var e,t,o,n,a,s,i,d,l;return r?r===!0?{storage:"session",keyPrefix:"persona-",persist:{openState:!0,voiceState:!0,focusInput:!0},clearOnChatClear:!0}:{storage:(e=r.storage)!=null?e:"session",keyPrefix:(t=r.keyPrefix)!=null?t:"persona-",persist:{openState:(n=(o=r.persist)==null?void 0:o.openState)!=null?n:!0,voiceState:(s=(a=r.persist)==null?void 0:a.voiceState)!=null?s:!0,focusInput:(d=(i=r.persist)==null?void 0:i.focusInput)!=null?d:!0},clearOnChatClear:(l=r.clearOnChatClear)!=null?l:!0}:null}function ew(r){try{let e=r==="local"?localStorage:sessionStorage,t="__persist_test__";return e.setItem(t,"1"),e.removeItem(t),e}catch{return null}}var gu=r=>!r||typeof r!="object"?{}:{...r},fy=r=>r.map(e=>({...e,streaming:!1})),my=(r,e,t)=>{let o=r!=null&&r.markdown?ua(r.markdown):null,n=ja(r==null?void 0:r.sanitize);return r!=null&&r.postprocessMessage&&n&&(r==null?void 0:r.sanitize)===void 0&&console.warn("[Persona] A custom postprocessMessage is active with the default HTML sanitizer. Tags or attributes not in the built-in allowlist will be stripped. To keep custom HTML, set `sanitize: false` or provide a custom sanitize function."),a=>{var l,u,f;let s=(l=a.text)!=null?l:"",i=(u=a.message.rawContent)!=null?u:null;if(e){let p=e.process({text:s,raw:i!=null?i:s,message:a.message,streaming:a.streaming});p!==null&&(s=p.text,p.persist||(a.message.__skipPersist=!0),p.resubmit&&!a.streaming&&t&&t())}let d;return r!=null&&r.postprocessMessage?d=r.postprocessMessage({...a,text:s,raw:(f=i!=null?i:a.text)!=null?f:""}):o?d=o(s):d=fa(s),n?n(d):d}};function gy(r){var i,d,l,u;let e=C("div","persona-attachment-drop-overlay");r!=null&&r.background&&e.style.setProperty("--persona-drop-overlay-bg",r.background),(r==null?void 0:r.backdropBlur)!==void 0&&e.style.setProperty("--persona-drop-overlay-blur",r.backdropBlur),r!=null&&r.border&&e.style.setProperty("--persona-drop-overlay-border",r.border),r!=null&&r.borderRadius&&e.style.setProperty("--persona-drop-overlay-radius",r.borderRadius),r!=null&&r.inset&&e.style.setProperty("--persona-drop-overlay-inset",r.inset),r!=null&&r.labelSize&&e.style.setProperty("--persona-drop-overlay-label-size",r.labelSize),r!=null&&r.labelColor&&e.style.setProperty("--persona-drop-overlay-label-color",r.labelColor);let t=(i=r==null?void 0:r.iconName)!=null?i:"upload",o=(d=r==null?void 0:r.iconSize)!=null?d:"48px",n=(l=r==null?void 0:r.iconColor)!=null?l:"rgba(59, 130, 246, 0.6)",a=(u=r==null?void 0:r.iconStrokeWidth)!=null?u:.5,s=Ee(t,o,n,a);if(s&&e.appendChild(s),r!=null&&r.label){let f=C("span","persona-drop-overlay-label");f.textContent=r.label,e.appendChild(f)}return e}var sd=(r,e,t)=>{var Gu,Ku,Xu,Qu,Yu,Ju,Zu,ef,tf,rf,of,nf,af,sf,lf,df,cf,pf,uf,ff,mf,gf,hf,xf,yf,bf,vf,Cf,wf,Af,Sf,Tf,Mf,kf,Ef,Lf,Pf,Rf,If,Hf,Wf,Bf,Df,Of,_f,Nf,Ff,Uf,qf,zf;if(r==null)throw new Error('createAgentExperience: mount must be a non-null HTMLElement (e.g. pass document.getElementById("my-root") after the node exists).');r.id&&!r.getAttribute("data-persona-instance")&&r.setAttribute("data-persona-instance",r.id),r.hasAttribute("data-persona-root")||r.setAttribute("data-persona-root","true");let o=Tl(e),n=mi.getForInstance(o.plugins);o.components&&En.registerAll(o.components);let a=ly(),i=o.persistState===!1?null:(Gu=o.storageAdapter)!=null?Gu:Jl(),d={},l=null,u=!1,f=c=>{if(o.onStateLoaded)try{let g=o.onStateLoaded(c);if(g&&typeof g=="object"&&"state"in g){let{state:b,open:S}=g;return S&&(u=!0),b}return g}catch(g){typeof console!="undefined"&&console.error("[AgentWidget] onStateLoaded hook failed:",g)}return c};if(i!=null&&i.load)try{let c=i.load();if(c&&typeof c.then=="function")l=c.then(g=>{let b=g!=null?g:{messages:[],metadata:{}};return f(b)});else{let g=c!=null?c:{messages:[],metadata:{}},b=f(g);b.metadata&&(d=gu(b.metadata)),(Ku=b.messages)!=null&&Ku.length&&(o={...o,initialMessages:b.messages}),(Xu=b.artifacts)!=null&&Xu.length&&(o={...o,initialArtifacts:b.artifacts,initialSelectedArtifactId:(Qu=b.selectedArtifactId)!=null?Qu:null})}}catch(c){typeof console!="undefined"&&console.error("[AgentWidget] Failed to load stored state:",c)}else if(o.onStateLoaded)try{let c=f({messages:[],metadata:{}});(Yu=c.messages)!=null&&Yu.length&&(o={...o,initialMessages:c.messages})}catch(c){typeof console!="undefined"&&console.error("[AgentWidget] onStateLoaded hook failed:",c)}let p=()=>d,m=c=>{var b;d=(b=c({...d}))!=null?b:{},Wa()},y=o.actionParsers&&o.actionParsers.length?o.actionParsers:[gi],h=o.actionHandlers&&o.actionHandlers.length?o.actionHandlers:[Ea.message,Ea.messageAndClick],T=hi({parsers:y,handlers:h,getSessionMetadata:p,updateSessionMetadata:m,emit:a.emit,documentRef:typeof document!="undefined"?document:null});T.syncFromMetadata();let M=(Zu=(Ju=o.launcher)==null?void 0:Ju.enabled)!=null?Zu:!0,k=(tf=(ef=o.launcher)==null?void 0:ef.autoExpand)!=null?tf:!1,L=(rf=o.autoFocusInput)!=null?rf:!1,x=k,w=M,v=(nf=(of=o.layout)==null?void 0:of.header)==null?void 0:nf.layout,E=!1,H=()=>Kn(o),I=()=>M||H(),P=H()?!1:M?k:!0,z=!1,j=null,ie=()=>{z=!0,j&&clearTimeout(j),j=setTimeout(()=>{z&&(typeof console!="undefined"&&console.warn("[AgentWidget] Resubmit requested but no injection occurred within 10s"),z=!1)},1e4)},ve=my(o,T,ie),Xe=(sf=(af=o.features)==null?void 0:af.showReasoning)!=null?sf:!0,Ae=(df=(lf=o.features)==null?void 0:lf.showToolCalls)!=null?df:!0,We=(pf=(cf=o.features)==null?void 0:cf.showEventStreamToggle)!=null?pf:!1,Me=(ff=(uf=o.features)==null?void 0:uf.scrollToBottom)!=null?ff:{},Ue=(gf=(mf=o.features)==null?void 0:mf.scrollBehavior)!=null?gf:{},Z=`${(xf=typeof o.persistState=="object"?(hf=o.persistState)==null?void 0:hf.keyPrefix:void 0)!=null?xf:"persona-"}event-stream`,ne=We?new ui(Z):null,me=(vf=(bf=(yf=o.features)==null?void 0:yf.eventStream)==null?void 0:bf.maxEvents)!=null?vf:2e3,be=We?new pi(me,ne):null,ye=We?new fi:null,Y=null,ge=!1,Oe=null,ce=0;ne==null||ne.open().then(()=>be==null?void 0:be.restore()).catch(c=>{o.debug&&console.warn("[AgentWidget] IndexedDB not available for event stream:",c)});let ae={onCopy:c=>{var g,b;a.emit("message:copy",c),U!=null&&U.isClientTokenMode()&&U.submitMessageFeedback(c.id,"copy").catch(S=>{o.debug&&console.error("[AgentWidget] Failed to submit copy feedback:",S)}),(b=(g=o.messageActions)==null?void 0:g.onCopy)==null||b.call(g,c)},onFeedback:c=>{var g,b;a.emit("message:feedback",c),U!=null&&U.isClientTokenMode()&&U.submitMessageFeedback(c.messageId,c.type).catch(S=>{o.debug&&console.error("[AgentWidget] Failed to submit feedback:",S)}),(b=(g=o.messageActions)==null?void 0:g.onFeedback)==null||b.call(g,c)}},Q=(Cf=o.statusIndicator)!=null?Cf:{},Tt=c=>{var g,b,S,W;return c==="idle"?(g=Q.idleText)!=null?g:ao.idle:c==="connecting"?(b=Q.connectingText)!=null?b:ao.connecting:c==="connected"?(S=Q.connectedText)!=null?S:ao.connected:c==="error"?(W=Q.errorText)!=null?W:ao.error:ao[c]};function Ye(c,g,b,S){if(S==="idle"&&b.idleLink){c.textContent="";let W=document.createElement("a");W.href=b.idleLink,W.target="_blank",W.rel="noopener noreferrer",W.textContent=g,W.style.color="inherit",W.style.textDecoration="none",c.appendChild(W)}else c.textContent=g}let{wrapper:De,panel:le,pillRoot:nt}=Ox(o),Re=_x(o,I()),{container:K,body:he,messagesWrapper:it,suggestions:Pt,textarea:te,sendButton:_e,sendButtonWrapper:Ar,composerForm:Rt,statusText:dr,introTitle:Yr,introSubtitle:zr,closeButton:O,iconHolder:fe,headerTitle:Ie,headerSubtitle:Je,header:qe,footer:ze,actionsRow:lt,leftActions:Mt,rightActions:Dt}=Re,or=Re.setSendButtonMode,X=Re.micButton,wt=Re.micButtonWrapper,ct=Re.attachmentButton,Ce=Re.attachmentButtonWrapper,de=Re.attachmentInput,rt=Re.attachmentPreviewsContainer;K.classList.add("persona-relative"),he.classList.add("persona-relative");let Ft=12,zt=()=>{var c;return(c=Me.label)!=null?c:""},Pr=()=>{var c;return(c=Me.iconName)!=null?c:"arrow-down"},vr=()=>Me.enabled!==!1,xt=()=>{var c;return(c=Ue.mode)!=null?c:"follow"},It=()=>{var c;return(c=Ue.anchorTopOffset)!=null?c:16},tt=C("button","persona-scroll-to-bottom-indicator persona-absolute persona-bottom-3 persona-left-1/2 persona-z-10 persona-flex persona-items-center persona-gap-1 persona-text-xs persona-transform persona--translate-x-1/2 persona-cursor-pointer");tt.type="button",tt.style.display="none",tt.setAttribute("data-persona-scroll-to-bottom","true");let jt=C("span","persona-flex persona-items-center"),cr=C("span",""),Dr=C("span","");Dr.setAttribute("data-persona-scroll-to-bottom-count",""),Dr.style.display="none",tt.append(jt,cr,Dr),K.appendChild(tt);let hr=C("div","persona-stream-anchor-spacer");hr.setAttribute("aria-hidden","true"),hr.setAttribute("data-persona-anchor-spacer",""),hr.style.flexShrink="0",hr.style.pointerEvents="none",hr.style.height="0px",he.appendChild(hr);let Sr=()=>{let g=ze.style.display==="none"?0:ze.offsetHeight;tt.style.bottom=`${g+Ft}px`};Sr();let Oo=()=>{let c=!!zt();tt.setAttribute("aria-label",zt()||"Jump to latest"),tt.title=zt(),tt.setAttribute("data-persona-scroll-to-bottom-has-label",c?"true":"false"),jt.innerHTML="";let g=Ee(Pr(),"14px","currentColor",2);g?(jt.appendChild(g),jt.style.display=""):jt.style.display="none",cr.textContent=zt(),cr.style.display=c?"":"none"};Oo();let je=null,Tr=null,io=n.find(c=>c.renderHeader);if(io!=null&&io.renderHeader){let c=io.renderHeader({config:o,defaultRenderer:()=>{let g=kn({config:o,showClose:I()});return Ta(K,g,o),g.header},onClose:()=>Gt(!1,"user")});if(c){let g=K.querySelector(".persona-border-b-persona-divider");g&&(g.replaceWith(c),qe=c)}}let _o=()=>{var g,b,S,W;if(!be)return;if(ge=!0,!Y&&be&&(Y=Jx({buffer:be,getFullHistory:()=>be.getAllFromStore(),onClose:()=>lo(),config:o,plugins:n,getThroughput:()=>{var F;return(F=ye==null?void 0:ye.getMetric())!=null?F:{status:"idle"}}})),Y&&(he.style.display="none",(g=ze.parentNode)==null||g.insertBefore(Y.element,ze),Y.update()),At){At.style.boxShadow=`inset 0 0 0 1.5px ${Ao.actionIconColor}`;let F=(W=(S=(b=o.features)==null?void 0:b.eventStream)==null?void 0:S.classNames)==null?void 0:W.toggleButtonActive;F&&F.split(/\s+/).forEach(q=>q&&At.classList.add(q))}let c=()=>{if(!ge)return;let F=Date.now();F-ce>=200&&(Y==null||Y.update(),ce=F),Oe=requestAnimationFrame(c)};ce=0,Oe=requestAnimationFrame(c),To(),a.emit("eventStream:opened",{timestamp:Date.now()})},lo=()=>{var c,g,b;if(ge){if(ge=!1,Y&&Y.element.remove(),he.style.display="",At){At.style.boxShadow="";let S=(b=(g=(c=o.features)==null?void 0:c.eventStream)==null?void 0:g.classNames)==null?void 0:b.toggleButtonActive;S&&S.split(/\s+/).forEach(W=>W&&At.classList.remove(W))}Oe!==null&&(cancelAnimationFrame(Oe),Oe=null),To(),a.emit("eventStream:closed",{timestamp:Date.now()})}},At=null;if(We){let c=(Af=(wf=o.features)==null?void 0:wf.eventStream)==null?void 0:Af.classNames,g="persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-opacity-80 persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-1"+(c!=null&&c.toggleButton?" "+c.toggleButton:"");At=C("button",g),At.style.width="28px",At.style.height="28px",At.style.color=Ao.actionIconColor,At.type="button",At.setAttribute("aria-label","Event Stream"),At.title="Event Stream";let b=Ee("activity","18px","currentColor",1.5);b&&At.appendChild(b);let S=Re.clearChatButtonWrapper,W=Re.closeButtonWrapper,F=S||W;F&&F.parentNode===qe?qe.insertBefore(At,F):qe.appendChild(At),At.addEventListener("click",()=>{ge?lo():_o()})}let rn=c=>{var S,W,F;let g=o.attachments;if(!(g!=null&&g.enabled))return;let b=c.querySelector(".persona-attachment-previews");if(!b){b=C("div","persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2"),b.style.display="none";let q=c.querySelector("[data-persona-composer-form]");q!=null&&q.parentNode?q.parentNode.insertBefore(b,q):c.insertBefore(b,c.firstChild)}if(!c.querySelector('input[type="file"]')){let q=C("input");q.type="file",q.accept=((S=g.allowedTypes)!=null?S:Tn).join(","),q.multiple=((W=g.maxFiles)!=null?W:4)>1,q.style.display="none",q.setAttribute("aria-label",(F=g.buttonTooltipText)!=null?F:"Attach files"),c.appendChild(q)}},No=n.find(c=>c.renderComposer);if(No!=null&&No.renderComposer){let c=o.composer,g=No.renderComposer({config:o,defaultRenderer:()=>ns({config:o}).footer,onSubmit:b=>{var q;if(!U||U.isStreaming())return;let S=b.trim(),W=(q=je==null?void 0:je.hasAttachments())!=null?q:!1;if(!S&&!W)return;V();let F;W&&(F=[],F.push(...je.getContentParts()),S&&F.push(Qs(S))),U.sendMessage(S,{contentParts:F}),W&&je.clearAttachments()},streaming:!1,disabled:!1,openAttachmentPicker:()=>{de==null||de.click()},models:c==null?void 0:c.models,selectedModelId:c==null?void 0:c.selectedModelId,onModelChange:b=>{o.composer={...o.composer,selectedModelId:b},o.agent&&(o.agent={...o.agent,model:b})},onVoiceToggle:((Sf=o.voiceRecognition)==null?void 0:Sf.enabled)===!0?()=>{Tr==null||Tr()}:void 0});g&&(ze.replaceWith(g),ze=g)}let mn=c=>{let g=c.querySelector("[data-persona-composer-form]"),b=c.querySelector("[data-persona-composer-input]"),S=c.querySelector("[data-persona-composer-submit]"),W=c.querySelector("[data-persona-composer-mic]"),F=c.querySelector("[data-persona-composer-status]");g&&(Rt=g),b&&(te=b),S&&(_e=S),W&&(X=W,wt=W.parentElement),F&&(dr=F);let q=c.querySelector(".persona-mb-3.persona-flex.persona-flex-wrap.persona-gap-2");q&&(Pt=q);let G=c.querySelector(".persona-attachment-button");G&&(ct=G,Ce=G.parentElement),de=c.querySelector('input[type="file"]'),rt=c.querySelector(".persona-attachment-previews");let N=c.querySelector(".persona-widget-composer .persona-flex.persona-items-center.persona-justify-between");N&&(lt=N)};rn(ze),mn(ze);let Jr=(Lf=(Tf=o.layout)==null?void 0:Tf.contentMaxWidth)!=null?Lf:H()?(Ef=(kf=(Mf=o.launcher)==null?void 0:Mf.composerBar)==null?void 0:kf.contentMaxWidth)!=null?Ef:"720px":void 0;if(Jr&&(it.style.maxWidth=Jr,it.style.marginLeft="auto",it.style.marginRight="auto",it.style.width="100%"),Jr&&Rt&&!H()&&(Rt.style.maxWidth=Jr,Rt.style.marginLeft="auto",Rt.style.marginRight="auto"),Jr&&Pt&&!H()&&(Pt.style.maxWidth=Jr,Pt.style.marginLeft="auto",Pt.style.marginRight="auto"),Jr&&rt&&!H()&&(rt.style.maxWidth=Jr,rt.style.marginLeft="auto",rt.style.marginRight="auto"),(Pf=o.attachments)!=null&&Pf.enabled&&de&&rt){je=wa.fromConfig(o.attachments),je.setPreviewsContainer(rt),de.addEventListener("change",b=>{let S=b.target;je==null||je.handleFileSelect(S.files),S.value=""});let c=o.attachments.dropOverlay,g=gy(c);K.appendChild(g)}(()=>{var S,W;let c=(W=(S=o.layout)==null?void 0:S.slots)!=null?W:{},g=F=>{switch(F){case"body-top":return K.querySelector(".persona-rounded-2xl.persona-bg-persona-surface.persona-p-6")||null;case"messages":return it;case"footer-top":return Pt;case"composer":return Rt;case"footer-bottom":return dr;default:return null}},b=(F,q)=>{var G;switch(F){case"header-left":case"header-center":case"header-right":if(F==="header-left")qe.insertBefore(q,qe.firstChild);else if(F==="header-right")qe.appendChild(q);else{let N=qe.querySelector(".persona-flex-col");N?(G=N.parentNode)==null||G.insertBefore(q,N.nextSibling):qe.appendChild(q)}break;case"body-top":{let N=he.querySelector(".persona-rounded-2xl.persona-bg-persona-surface.persona-p-6");N?N.replaceWith(q):he.insertBefore(q,he.firstChild);break}case"body-bottom":he.appendChild(q);break;case"footer-top":Pt.replaceWith(q);break;case"footer-bottom":dr.replaceWith(q);break;default:break}};for(let[F,q]of Object.entries(c))if(q)try{let G=q({config:o,defaultContent:()=>g(F)});G&&b(F,G)}catch(G){typeof console!="undefined"&&console.error(`[AgentWidget] Error rendering slot "${F}":`,G)}})();let $r=c=>{var q,G;let b=c.target.closest('button[data-expand-header="true"]');if(!b)return;let S=b.closest(".persona-reasoning-bubble, .persona-tool-bubble, .persona-approval-bubble");if(!S)return;let W=S.getAttribute("data-message-id");if(!W)return;let F=b.getAttribute("data-bubble-type");if(F==="reasoning")ss.has(W)?ss.delete(W):ss.add(W),qx(W,S);else if(F==="tool")is.has(W)?is.delete(W):is.add(W),zx(W,S,o);else if(F==="approval"){let N=o.approval!==!1?o.approval:void 0,Se=((q=N==null?void 0:N.detailsDisplay)!=null?q:"collapsed")==="expanded",xe=(G=Gl.get(W))!=null?G:Se;Gl.set(W,!xe),Gx(W,S,o)}Cr.delete(W)};it.addEventListener("pointerdown",c=>{c.target.closest('button[data-expand-header="true"]')&&(c.preventDefault(),$r(c))}),it.addEventListener("keydown",c=>{let g=c.target;(c.key==="Enter"||c.key===" ")&&g.closest('button[data-expand-header="true"]')&&(c.preventDefault(),$r(c))});let Fo=new Map;it.addEventListener("click",c=>{var q;let b=c.target.closest(".persona-message-action-btn[data-action]");if(!b)return;c.preventDefault(),c.stopPropagation();let S=b.closest("[data-actions-for]");if(!S)return;let W=S.getAttribute("data-actions-for");if(!W)return;let F=b.getAttribute("data-action");if(F==="copy"){let N=U.getMessages().find(Se=>Se.id===W);if(N&&ae.onCopy){let Se=N.content||"";navigator.clipboard.writeText(Se).then(()=>{b.classList.add("persona-message-action-success");let xe=Ee("check",14,"currentColor",2);xe&&(b.innerHTML="",b.appendChild(xe)),setTimeout(()=>{b.classList.remove("persona-message-action-success");let se=Ee("copy",14,"currentColor",2);se&&(b.innerHTML="",b.appendChild(se))},2e3)}).catch(xe=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to copy message:",xe)}),ae.onCopy(N)}}else if(F==="upvote"||F==="downvote"){let N=((q=Fo.get(W))!=null?q:null)===F,Se=F==="upvote"?"thumbs-up":"thumbs-down";if(N){Fo.delete(W),b.classList.remove("persona-message-action-active");let xe=Ee(Se,14,"currentColor",2);xe&&(b.innerHTML="",b.appendChild(xe))}else{let xe=F==="upvote"?"downvote":"upvote",se=S.querySelector(`[data-action="${xe}"]`);if(se){se.classList.remove("persona-message-action-active");let Ze=Ee(xe==="upvote"?"thumbs-up":"thumbs-down",14,"currentColor",2);Ze&&(se.innerHTML="",se.appendChild(Ze))}Fo.set(W,F),b.classList.add("persona-message-action-active");let ke=Ee(Se,14,"currentColor",2);ke&&(ke.setAttribute("fill","currentColor"),b.innerHTML="",b.appendChild(ke)),b.classList.remove("persona-message-action-pop"),b.offsetWidth,b.classList.add("persona-message-action-pop");let Te=U.getMessages().find(ft=>ft.id===W);Te&&ae.onFeedback&&ae.onFeedback({type:F,messageId:Te.id,message:Te})}}}),it.addEventListener("click",c=>{let b=c.target.closest("button[data-approval-action]");if(!b)return;c.preventDefault(),c.stopPropagation();let S=b.closest(".persona-approval-bubble");if(!S)return;let W=S.getAttribute("data-message-id");if(!W)return;let F=b.getAttribute("data-approval-action");if(!F)return;let q=F==="approve"?"approved":"denied",N=U.getMessages().find(xe=>xe.id===W);if(!(N!=null&&N.approval))return;let Se=S.querySelector("[data-approval-buttons]");Se&&Se.querySelectorAll("button").forEach(se=>{se.disabled=!0,se.style.opacity="0.5",se.style.cursor="not-allowed"}),N.approval.toolType==="webmcp"?U.resolveWebMcpApproval(W,q):U.resolveApproval(N.approval,q)});let mt=null,co=null,po={artifacts:[],selectedId:null},Or=!1,Wt={current:null};it.addEventListener("click",c=>{var se,ke,Ge,Te,ft;let b=c.target.closest("[data-download-artifact]");if(!b)return;c.preventDefault(),c.stopPropagation();let S=b.getAttribute("data-download-artifact");if(!S||((Ge=(ke=(se=o.features)==null?void 0:se.artifacts)==null?void 0:ke.onArtifactAction)==null?void 0:Ge.call(ke,{type:"download",artifactId:S}))===!0)return;let F=U.getArtifactById(S),q=F==null?void 0:F.markdown,G=(F==null?void 0:F.title)||"artifact";if(!q){let Ze=b.closest("[data-open-artifact]"),bt=Ze==null?void 0:Ze.closest("[data-message-id]"),vt=bt==null?void 0:bt.getAttribute("data-message-id");if(vt){let Pe=U.getMessages().find(Qe=>Qe.id===vt);if(Pe!=null&&Pe.rawContent)try{let Qe=JSON.parse(Pe.rawContent);q=(Te=Qe==null?void 0:Qe.props)==null?void 0:Te.markdown,G=((ft=Qe==null?void 0:Qe.props)==null?void 0:ft.title)||G}catch{}}}if(!q)return;let N=new Blob([q],{type:"text/markdown"}),Se=URL.createObjectURL(N),xe=document.createElement("a");xe.href=Se,xe.download=`${G}.md`,xe.click(),URL.revokeObjectURL(Se)}),it.addEventListener("click",c=>{var F,q,G;let b=c.target.closest("[data-open-artifact]");if(!b)return;let S=b.getAttribute("data-open-artifact");!S||((G=(q=(F=o.features)==null?void 0:F.artifacts)==null?void 0:q.onArtifactAction)==null?void 0:G.call(q,{type:"open",artifactId:S}))===!0||(c.preventDefault(),c.stopPropagation(),Or=!1,U.selectArtifact(S),eo())}),it.addEventListener("keydown",c=>{if(c.key!=="Enter"&&c.key!==" ")return;let g=c.target;g.hasAttribute("data-open-artifact")&&(c.preventDefault(),g.click())});let Vr=Re.composerOverlay,Zr=(c,g,b)=>{var G,N,Se,xe;let S=g.trim();if(!S||!Wt.current)return;let W=(G=c.getAttribute("data-tool-call-id"))!=null?G:"",F=b.source==="free-text";r.dispatchEvent(new CustomEvent("persona:askUserQuestion:answered",{detail:{toolUseId:W,answer:S,answers:b.structured,values:(N=b.values)!=null?N:b.source==="multi"?S.split(", "):[S],isFreeText:F,source:b.source},bubbles:!0,composed:!0})),zn(Vr,W);let q=Wt.current.getMessages().find(se=>{var ke;return((ke=se.toolCall)==null?void 0:ke.id)===W});(Se=q==null?void 0:q.agentMetadata)!=null&&Se.awaitingLocalTool?Wt.current.resolveAskUserQuestion(q,(xe=b.structured)!=null?xe:S):Wt.current.sendMessage(S)},_r=c=>{var W;let g=Wt.current;if(!g)return;let b=(W=c.getAttribute("data-tool-call-id"))!=null?W:"",S=g.getMessages().find(F=>{var q;return((q=F.toolCall)==null?void 0:q.id)===b});S&&g.persistAskUserQuestionProgress(S,{answers:Ki(c,S),currentIndex:jo(c)})},uo=c=>Object.entries(c).map(([g,b])=>`${g}: ${Array.isArray(b)?b.join(", "):b}`).join(" | "),fo=c=>{var W,F,q;if(((F=(W=o.features)==null?void 0:W.askUserQuestion)==null?void 0:F.groupedAutoAdvance)===!1)return;let g=jo(c),b=Xa(c);if(g>=b-1)return;let S=(q=Wt.current)==null?void 0:q.getMessages().find(G=>{var N;return((N=G.toolCall)==null?void 0:N.id)===c.getAttribute("data-tool-call-id")});S&&(Xi(c,S,o,g+1),_r(c))};Vr.addEventListener("click",c=>{var F,q,G,N,Se,xe,se,ke,Ge,Te,ft,Ze,bt,vt;let b=c.target.closest("[data-ask-user-action]");if(!b)return;let S=b.closest("[data-persona-ask-sheet-for]");if(!S)return;let W=b.getAttribute("data-ask-user-action");if(c.preventDefault(),c.stopPropagation(),W==="dismiss"){let He=(F=S.getAttribute("data-tool-call-id"))!=null?F:"";r.dispatchEvent(new CustomEvent("persona:askUserQuestion:dismissed",{detail:{toolUseId:He},bubbles:!0,composed:!0})),zn(Vr,He);let Pe=(q=Wt.current)==null?void 0:q.getMessages().find(Qe=>{var ot;return((ot=Qe.toolCall)==null?void 0:ot.id)===He});(G=Pe==null?void 0:Pe.agentMetadata)!=null&&G.awaitingLocalTool&&((N=Wt.current)==null||N.markAskUserQuestionResolved(Pe),(Se=Wt.current)==null||Se.resolveAskUserQuestion(Pe,"(dismissed)"));return}if(W==="pick"){let He=b.getAttribute("data-option-label");if(!He)return;let Pe=S.getAttribute("data-multi-select")==="true",Qe=qn(S);if(Qe&&Pe){let ot=ha(S)[jo(S)],Ht=new Set(Array.isArray(ot)?ot:[]);Ht.has(He)?Ht.delete(He):Ht.add(He),$n(S,Array.from(Ht)),_r(S);return}if(Qe){$n(S,He),_r(S),fo(S);return}if(Pe){let ot=b.getAttribute("aria-pressed")==="true";b.setAttribute("aria-pressed",ot?"false":"true"),b.classList.toggle("persona-ask-pill-selected",!ot);let Ht=S.querySelector('[data-ask-user-action="submit-multi"]');Ht&&(Ht.disabled=Nd(S).length===0);return}Zr(S,He,{source:"pick",values:[He]});return}if(W==="submit-multi"){let He=Nd(S);if(He.length===0)return;Zr(S,He.join(", "),{source:"multi",values:He});return}if(W==="open-free-text"){let He=S.querySelector('[data-ask-free-text-row="true"]');if(He){He.classList.remove("persona-hidden");let Pe=He.querySelector('[data-ask-free-text-input="true"]');Pe==null||Pe.focus()}return}if(W==="focus-free-text"){let He=S.querySelector('[data-ask-free-text-input="true"]');He==null||He.focus();return}if(W==="submit-free-text"){let He=S.querySelector('[data-ask-free-text-input="true"]'),Pe=(xe=He==null?void 0:He.value)!=null?xe:"";if(!Pe.trim())return;if(qn(S)){$n(S,Pe.trim()),_r(S),fo(S);return}Zr(S,Pe,{source:"free-text"});return}if(W==="next"||W==="back"){if(!Wt.current)return;let He=(se=S.getAttribute("data-tool-call-id"))!=null?se:"",Pe=Wt.current.getMessages().find(Ne=>{var Fe;return((Fe=Ne.toolCall)==null?void 0:Fe.id)===He});if(!Pe)return;let Qe=S.querySelector('[data-ask-free-text-input="true"]'),ot=(Ge=(ke=Qe==null?void 0:Qe.value)==null?void 0:ke.trim())!=null?Ge:"";if(ot){let Ne=ha(S)[jo(S)];(typeof Ne!="string"||Ne!==ot)&&$n(S,ot)}let Ht=W==="next"?1:-1,D=jo(S)+Ht;Xi(S,Pe,o,D),_r(S);return}if(W==="submit-all"){if(!Wt.current)return;let He=(Te=S.getAttribute("data-tool-call-id"))!=null?Te:"",Pe=Wt.current.getMessages().find(Ne=>{var Fe;return((Fe=Ne.toolCall)==null?void 0:Fe.id)===He});if(!Pe)return;let Qe=S.querySelector('[data-ask-free-text-input="true"]'),ot=(Ze=(ft=Qe==null?void 0:Qe.value)==null?void 0:ft.trim())!=null?Ze:"";ot&&$n(S,ot);let Ht=Ki(S,Pe);Wt.current.persistAskUserQuestionProgress(Pe,{answers:Ht,currentIndex:jo(S)});let D=uo(Ht);Zr(S,D||"(submitted)",{source:"submit-all",structured:Ht});return}if(W==="skip"){if(!Wt.current)return;let He=(bt=S.getAttribute("data-tool-call-id"))!=null?bt:"",Pe=Wt.current.getMessages().find(Fe=>{var we;return((we=Fe.toolCall)==null?void 0:we.id)===He});if(!Pe)return;let Qe=qn(S),ot=jo(S),Ht=Xa(S),D=ot>=Ht-1;if(!Qe){r.dispatchEvent(new CustomEvent("persona:askUserQuestion:dismissed",{detail:{toolUseId:He},bubbles:!0,composed:!0})),zn(Vr,He),(vt=Pe.agentMetadata)!=null&&vt.awaitingLocalTool&&(Wt.current.markAskUserQuestionResolved(Pe),Wt.current.resolveAskUserQuestion(Pe,"(dismissed)"));return}$n(S,"");let Ne=S.querySelector('[data-ask-free-text-input="true"]');if(Ne&&(Ne.value=""),D){let Fe=Ki(S,Pe),we=uo(Fe);Zr(S,we||"(skipped)",{source:"submit-all",structured:Fe});return}Xi(S,Pe,o,ot+1),_r(S);return}}),Vr.addEventListener("keydown",c=>{var F;if(c.key!=="Enter")return;let b=c.target;if(!((F=b.matches)!=null&&F.call(b,'[data-ask-free-text-input="true"]')))return;let S=b.closest("[data-persona-ask-sheet-for]");if(!S)return;c.preventDefault();let W=b.value;if(W.trim()){if(qn(S)){$n(S,W.trim()),_r(S),fo(S);return}Zr(S,W,{source:"free-text"})}});let Nr=c=>{if(!/^[1-9]$/.test(c.key)||c.metaKey||c.ctrlKey||c.altKey)return;let g=c.target;if((g==null?void 0:g.tagName)==="INPUT"||(g==null?void 0:g.tagName)==="TEXTAREA"||g!=null&&g.isContentEditable)return;let b=Vr.querySelector("[data-persona-ask-sheet-for]");if(!b||b.getAttribute("data-ask-layout")!=="rows"||b.getAttribute("data-multi-select")==="true")return;let S=Number(c.key),F=b.querySelectorAll('[data-ask-pill-list="true"] [data-ask-user-action="pick"], [data-ask-pill-list="true"] [data-ask-user-action="focus-free-text"]')[S-1];F&&(c.preventDefault(),F.click())};document.addEventListener("keydown",Nr);let mo=null,$t=null,Fr=null,go=null,on=()=>{};function Uo(){go==null||go(),go=null}let nn=()=>{var q;if(!mo||!$t)return;let c=r.classList.contains("persona-artifact-appearance-seamless"),b=((q=r.ownerDocument.defaultView)!=null?q:window).innerWidth<=640;if(!c||r.classList.contains("persona-artifact-narrow-host")||b){$t.style.removeProperty("position"),$t.style.removeProperty("left"),$t.style.removeProperty("top"),$t.style.removeProperty("bottom"),$t.style.removeProperty("width"),$t.style.removeProperty("z-index");return}let S=mo.firstElementChild;if(!S||S===$t)return;let W=10;$t.style.position="absolute",$t.style.top="0",$t.style.bottom="0",$t.style.width=`${W}px`,$t.style.zIndex="5";let F=S.offsetWidth-W/2;$t.style.left=`${Math.max(0,F)}px`},qo=()=>{},eo=()=>{var b,S,W,F,q;if(!mt||!Go(o))return;Ql(r,o),Yl(r,o),qo();let c=(F=(W=(S=(b=o.features)==null?void 0:b.artifacts)==null?void 0:S.layout)==null?void 0:W.narrowHostMaxWidth)!=null?F:520,g=le.getBoundingClientRect().width||0;r.classList.toggle("persona-artifact-narrow-host",g>0&&g<=c),mt.update(po),Or?(mt.setMobileOpen(!1),mt.element.classList.add("persona-hidden"),(q=mt.backdrop)==null||q.classList.add("persona-hidden")):po.artifacts.length>0&&(mt.element.classList.remove("persona-hidden"),mt.setMobileOpen(!0)),on()};if(Go(o)){le.style.position="relative";let c=C("div","persona-flex persona-flex-1 persona-flex-col persona-min-w-0 persona-min-h-0"),g=C("div","persona-flex persona-h-full persona-w-full persona-min-h-0 persona-artifact-split-root");c.appendChild(K),mt=ty(o,{onSelect:b=>{var S;return(S=Wt.current)==null?void 0:S.selectArtifact(b)},onDismiss:()=>{Or=!0,eo()}}),mt.element.classList.add("persona-hidden"),mo=g,g.appendChild(c),g.appendChild(mt.element),mt.backdrop&&le.appendChild(mt.backdrop),le.appendChild(g),on=()=>{var S,W,F,q;if(!mo||!mt)return;if(!(((F=(W=(S=o.features)==null?void 0:S.artifacts)==null?void 0:W.layout)==null?void 0:F.resizable)===!0)){Fr==null||Fr(),Fr=null,Uo(),$t&&($t.remove(),$t=null),mt.element.style.removeProperty("width"),mt.element.style.removeProperty("maxWidth");return}if(!$t){let G=C("div","persona-artifact-split-handle persona-shrink-0 persona-h-full");G.setAttribute("role","separator"),G.setAttribute("aria-orientation","vertical"),G.setAttribute("aria-label","Resize artifacts panel"),G.tabIndex=0;let N=r.ownerDocument,Se=(q=N.defaultView)!=null?q:window,xe=se=>{var bt,vt;if(!mt||se.button!==0||r.classList.contains("persona-artifact-narrow-host")||Se.innerWidth<=640)return;se.preventDefault(),Uo();let ke=se.clientX,Ge=mt.element.getBoundingClientRect().width,Te=(vt=(bt=o.features)==null?void 0:bt.artifacts)==null?void 0:vt.layout,ft=He=>{let Pe=mo.getBoundingClientRect().width,Qe=r.classList.contains("persona-artifact-appearance-seamless"),ot=Qe?0:ay(mo,Se),Ht=Qe?0:G.getBoundingClientRect().width||6,D=Ge-(He.clientX-ke),Ne=sy(D,Pe,ot,Ht,Te==null?void 0:Te.resizableMinWidth,Te==null?void 0:Te.resizableMaxWidth);mt.element.style.width=`${Ne}px`,mt.element.style.maxWidth="none",nn()},Ze=()=>{N.removeEventListener("pointermove",ft),N.removeEventListener("pointerup",Ze),N.removeEventListener("pointercancel",Ze),go=null;try{G.releasePointerCapture(se.pointerId)}catch{}};go=Ze,N.addEventListener("pointermove",ft),N.addEventListener("pointerup",Ze),N.addEventListener("pointercancel",Ze);try{G.setPointerCapture(se.pointerId)}catch{}};G.addEventListener("pointerdown",xe),$t=G,mo.insertBefore(G,mt.element),Fr=()=>{G.removeEventListener("pointerdown",xe)}}if($t){let G=po.artifacts.length>0&&!Or;$t.classList.toggle("persona-hidden",!G),nn()}},qo=()=>{var Se,xe,se,ke,Ge,Te,ft,Ze,bt,vt,He,Pe,Qe,ot;if(!M||!mt||((xe=(Se=o.launcher)==null?void 0:Se.sidebarMode)!=null?xe:!1)||Lr(o)&&Bo(o).reveal==="emerge")return;let S=(se=r.ownerDocument.defaultView)!=null?se:window,W=(Ge=(ke=o.launcher)==null?void 0:ke.mobileFullscreen)!=null?Ge:!0,F=(ft=(Te=o.launcher)==null?void 0:Te.mobileBreakpoint)!=null?ft:640;if(W&&S.innerWidth<=F||!ny(o,M))return;let q=(vt=(bt=(Ze=o.launcher)==null?void 0:Ze.width)!=null?bt:o.launcherWidth)!=null?vt:Wo,G=(ot=(Qe=(Pe=(He=o.features)==null?void 0:He.artifacts)==null?void 0:Pe.layout)==null?void 0:Qe.expandedPanelWidth)!=null?ot:"min(720px, calc(100vw - 24px))";po.artifacts.length>0&&!Or?(le.style.width=G,le.style.maxWidth=G):(le.style.width=q,le.style.maxWidth=q)},typeof ResizeObserver!="undefined"&&(co=new ResizeObserver(()=>{eo()}),co.observe(le))}else le.appendChild(K),H()&&nt&&(Re.peekBanner&&nt.appendChild(Re.peekBanner),nt.appendChild(ze));r.appendChild(De),nt&&r.appendChild(nt);let to=()=>{var Ne,Fe,we,Qt,Kt,ir,Bt,ar,Po,wr,st,Ut,kr,Vo,Ro,ta,ra,Fa,Ua,ur,oa,On,_n,yn,na,Yo,pt,Ir;if(H()){le.style.width="100%",le.style.maxWidth="100%";let Zt=(Fe=(Ne=o.launcher)==null?void 0:Ne.composerBar)!=null?Fe:{},Yt=De.dataset.state==="expanded",Et=(we=Zt.expandedSize)!=null?we:"anchored";if(!(Yt&&Et!=="fullscreen")){K.style.background="",K.style.border="",K.style.borderRadius="",K.style.overflow="",K.style.boxShadow="";return}let _t=(Kt=(Qt=o.theme)==null?void 0:Qt.components)==null?void 0:Kt.panel,oo=rs(o),ho=(yo,aa)=>{var Es;return yo==null||yo===""?aa:(Es=es(oo,yo))!=null?Es:yo},dn="1px solid var(--persona-border)",qr="var(--persona-palette-shadows-xl, 0 25px 50px -12px rgba(0, 0, 0, 0.25))",xo="var(--persona-panel-radius, var(--persona-radius-xl, 0.75rem))";K.style.background="var(--persona-surface, #ffffff)",K.style.border=ho(_t==null?void 0:_t.border,dn),K.style.borderRadius=ho(_t==null?void 0:_t.borderRadius,xo),K.style.boxShadow=ho(_t==null?void 0:_t.shadow,qr),K.style.overflow="hidden";return}let c=Lr(o),g=(Bt=(ir=o.launcher)==null?void 0:ir.sidebarMode)!=null?Bt:!1,b=c||g||((Po=(ar=o.launcher)==null?void 0:ar.fullHeight)!=null?Po:!1),S=((wr=o.launcher)==null?void 0:wr.enabled)===!1,W=(Ut=(st=o.theme)==null?void 0:st.components)==null?void 0:Ut.panel,F=rs(o),q=(Zt,Yt)=>{var Et;return Zt==null||Zt===""?Yt:(Et=es(F,Zt))!=null?Et:Zt},G=(kr=r.ownerDocument.defaultView)!=null?kr:window,N=(Ro=(Vo=o.launcher)==null?void 0:Vo.mobileFullscreen)!=null?Ro:!0,Se=(ra=(ta=o.launcher)==null?void 0:ta.mobileBreakpoint)!=null?ra:640,xe=G.innerWidth<=Se,se=N&&xe&&M,ke=(Ua=(Fa=o.launcher)==null?void 0:Fa.position)!=null?Ua:"bottom-left",Ge=ke==="bottom-left"||ke==="top-left",Te=(oa=(ur=o.launcher)==null?void 0:ur.zIndex)!=null?oa:so,ft=g||se?"none":"1px solid var(--persona-border)",Ze=se?"none":g?Ge?"var(--persona-palette-shadows-sidebar-left, 2px 0 12px rgba(0, 0, 0, 0.08))":"var(--persona-palette-shadows-sidebar-right, -2px 0 12px rgba(0, 0, 0, 0.08))":"var(--persona-palette-shadows-xl, 0 25px 50px -12px rgba(0, 0, 0, 0.25))";c&&!se&&(Ze="none",ft="none");let bt=g||se?"0":"var(--persona-panel-radius, var(--persona-radius-xl, 0.75rem))",vt=q(W==null?void 0:W.border,ft),He=q(W==null?void 0:W.shadow,Ze),Pe=q(W==null?void 0:W.borderRadius,bt),Qe=he.scrollTop;r.style.cssText="",De.style.cssText="",le.style.cssText="",K.style.cssText="",he.style.cssText="",ze.style.cssText="";let ot=()=>{var Yt;if(Qe<=0)return;((Yt=he.ownerDocument.defaultView)!=null?Yt:window).requestAnimationFrame(()=>{if(he.scrollTop===Qe)return;let Et=he.scrollHeight-he.clientHeight;Et<=0||(he.scrollTop=Math.min(Qe,Et))})};if(se){De.classList.remove("persona-bottom-6","persona-right-6","persona-left-6","persona-top-6","persona-bottom-4","persona-right-4","persona-left-4","persona-top-4"),De.style.cssText=`
|
|
78
79
|
position: fixed !important;
|
|
79
80
|
inset: 0 !important;
|
|
80
81
|
width: 100% !important;
|
|
@@ -84,9 +85,9 @@ _Details: ${t.message}_`:n}var _s=r=>({isError:!0,content:[{type:"text",text:r}]
|
|
|
84
85
|
padding: 0 !important;
|
|
85
86
|
display: flex !important;
|
|
86
87
|
flex-direction: column !important;
|
|
87
|
-
z-index: ${
|
|
88
|
+
z-index: ${Te} !important;
|
|
88
89
|
background-color: var(--persona-surface, #ffffff) !important;
|
|
89
|
-
`,
|
|
90
|
+
`,le.style.cssText=`
|
|
90
91
|
position: relative !important;
|
|
91
92
|
display: flex !important;
|
|
92
93
|
flex-direction: column !important;
|
|
@@ -99,7 +100,7 @@ _Details: ${t.message}_`:n}var _s=r=>({isError:!0,content:[{type:"text",text:r}]
|
|
|
99
100
|
padding: 0 !important;
|
|
100
101
|
box-shadow: none !important;
|
|
101
102
|
border-radius: 0 !important;
|
|
102
|
-
`,
|
|
103
|
+
`,K.style.cssText=`
|
|
103
104
|
display: flex !important;
|
|
104
105
|
flex-direction: column !important;
|
|
105
106
|
flex: 1 1 0% !important;
|
|
@@ -110,20 +111,20 @@ _Details: ${t.message}_`:n}var _s=r=>({isError:!0,content:[{type:"text",text:r}]
|
|
|
110
111
|
overflow: hidden !important;
|
|
111
112
|
border-radius: 0 !important;
|
|
112
113
|
border: none !important;
|
|
113
|
-
`,
|
|
114
|
+
`,he.style.flex="1 1 0%",he.style.minHeight="0",he.style.overflowY="auto",ze.style.flexShrink="0",E=!0,ot();return}let Ht=(_n=(On=o==null?void 0:o.launcher)==null?void 0:On.width)!=null?_n:o==null?void 0:o.launcherWidth,D=Ht!=null?Ht:Wo;if(!g&&!c)S&&b?(le.style.width="100%",le.style.maxWidth="100%"):(le.style.width=D,le.style.maxWidth=D);else if(c)if(Bo(o).reveal==="emerge"){let Yt=Bo(o).width;le.style.width=Yt,le.style.maxWidth=Yt}else le.style.width="100%",le.style.maxWidth="100%";if(qo(),le.style.boxShadow=He,le.style.borderRadius=Pe,K.style.border=vt,K.style.borderRadius=Pe,c&&!se&&(W==null?void 0:W.border)===void 0&&(K.style.border="none",Bo(o).side==="right"?K.style.borderLeft="1px solid var(--persona-border)":K.style.borderRight="1px solid var(--persona-border)"),b&&(r.style.display="flex",r.style.flexDirection="column",r.style.height="100%",r.style.minHeight="0",S&&(r.style.width="100%"),De.style.display="flex",De.style.flexDirection="column",De.style.flex="1 1 0%",De.style.minHeight="0",De.style.maxHeight="100%",De.style.height="100%",S&&(De.style.overflow="hidden"),le.style.display="flex",le.style.flexDirection="column",le.style.flex="1 1 0%",le.style.minHeight="0",le.style.maxHeight="100%",le.style.height="100%",le.style.overflow="hidden",K.style.display="flex",K.style.flexDirection="column",K.style.flex="1 1 0%",K.style.minHeight="0",K.style.maxHeight="100%",K.style.overflow="hidden",he.style.flex="1 1 0%",he.style.minHeight="0",he.style.overflowY="auto",ze.style.flexShrink="0"),De.classList.remove("persona-bottom-6","persona-right-6","persona-left-6","persona-top-6","persona-bottom-4","persona-right-4","persona-left-4","persona-top-4"),!g&&!S&&!c&&((yn=tn[ke])!=null?yn:tn["bottom-right"]).split(" ").forEach(Yt=>De.classList.add(Yt)),g){let Zt=(Yo=(na=o.launcher)==null?void 0:na.sidebarWidth)!=null?Yo:"420px";De.style.cssText=`
|
|
114
115
|
position: fixed !important;
|
|
115
116
|
top: 0 !important;
|
|
116
117
|
bottom: 0 !important;
|
|
117
|
-
width: ${
|
|
118
|
+
width: ${Zt} !important;
|
|
118
119
|
height: 100vh !important;
|
|
119
120
|
max-height: 100vh !important;
|
|
120
121
|
margin: 0 !important;
|
|
121
122
|
padding: 0 !important;
|
|
122
123
|
display: flex !important;
|
|
123
124
|
flex-direction: column !important;
|
|
124
|
-
z-index: ${
|
|
125
|
-
${
|
|
126
|
-
`,
|
|
125
|
+
z-index: ${Te} !important;
|
|
126
|
+
${Ge?"left: 0 !important; right: auto !important;":"left: auto !important; right: 0 !important;"}
|
|
127
|
+
`,le.style.cssText=`
|
|
127
128
|
position: relative !important;
|
|
128
129
|
display: flex !important;
|
|
129
130
|
flex-direction: column !important;
|
|
@@ -134,9 +135,9 @@ _Details: ${t.message}_`:n}var _s=r=>({isError:!0,content:[{type:"text",text:r}]
|
|
|
134
135
|
min-height: 0 !important;
|
|
135
136
|
margin: 0 !important;
|
|
136
137
|
padding: 0 !important;
|
|
137
|
-
box-shadow: ${
|
|
138
|
-
border-radius: ${
|
|
139
|
-
`,
|
|
138
|
+
box-shadow: ${He} !important;
|
|
139
|
+
border-radius: ${Pe} !important;
|
|
140
|
+
`,le.style.setProperty("width","100%","important"),le.style.setProperty("max-width","100%","important"),K.style.cssText=`
|
|
140
141
|
display: flex !important;
|
|
141
142
|
flex-direction: column !important;
|
|
142
143
|
flex: 1 1 0% !important;
|
|
@@ -145,29 +146,29 @@ _Details: ${t.message}_`:n}var _s=r=>({isError:!0,content:[{type:"text",text:r}]
|
|
|
145
146
|
min-height: 0 !important;
|
|
146
147
|
max-height: 100% !important;
|
|
147
148
|
overflow: hidden !important;
|
|
148
|
-
border-radius: ${
|
|
149
|
-
border: ${
|
|
150
|
-
`,
|
|
149
|
+
border-radius: ${Pe} !important;
|
|
150
|
+
border: ${vt} !important;
|
|
151
|
+
`,ze.style.cssText=`
|
|
151
152
|
flex-shrink: 0 !important;
|
|
152
153
|
border-top: none !important;
|
|
153
154
|
padding: 8px 16px 12px 16px !important;
|
|
154
|
-
`}if(!A&&!c){let bt="max-height: -moz-available !important; max-height: stretch !important;",Et=g?"":"padding-top: 1.25em !important;",yt=g?"":`z-index: ${(Mr=(Xr=n.launcher)==null?void 0:Xr.zIndex)!=null?Mr:Gr} !important;`;We.style.cssText+=bt+Et+yt}rt()};Nn(),Do(r,n),_l(r,n),Ul(r,n);let kt=[];kt.push(()=>{document.removeEventListener("keydown",wo)});let yr=null,vr=null;kt.push(()=>{yr==null||yr(),yr=null,vr==null||vr(),vr=null}),_t&&kt.push(()=>{_t==null||_t.disconnect(),_t=null}),kt.push(()=>{Kr==null||Kr(),Kr=null,oo(),jt&&(jt.remove(),jt=null),Ze==null||Ze.element.style.removeProperty("width"),Ze==null||Ze.element.style.removeProperty("maxWidth")}),De&&kt.push(()=>{ke!==null&&(cancelAnimationFrame(ke),ke=null),G==null||G.destroy(),G=null,ge==null||ge.destroy(),ge=null,re=null});let fn=null,To=()=>{fn&&(fn(),fn=null),n.colorScheme==="auto"&&(fn=ml(()=>{Do(r,n)}))};To(),kt.push(()=>{fn&&(fn(),fn=null)});let ve=(yf=n.features)==null?void 0:yf.streamAnimation;if(ve!=null&&ve.type&&ve.type!=="none"){let c=Vs(ve.type,ve.plugins);c&&(Ip(c,r),kt.push(()=>tx(r)))}let Mn=Lx(It),kn=null,q,Kn=!1,ao=jh(),so=new Map,Xn=new Map,On=new Map,rs=0,mn=xl(),gn=0,_n=null,Un=!1,Vo=!1,io=0,zr=null,Qn=null,wa=!1,jo=!1,Aa=null,si=4,Sa=24,ii=80,Ta=new Map,Rt={active:!1,manuallyDeactivated:!1,lastUserMessageWasVoice:!1,lastUserMessageId:null},ns=(Cf=(vf=n.voiceRecognition)==null?void 0:vf.autoResume)!=null?Cf:!1,En=c=>{a.emit("voice:state",{active:Rt.active,source:c,timestamp:Date.now()})},an=()=>{m(c=>({...c,voiceState:{active:Rt.active,timestamp:Date.now(),manuallyDeactivated:Rt.manuallyDeactivated}}))},li=()=>{var A,H;if(((A=n.voiceRecognition)==null?void 0:A.enabled)===!1)return;let c=nu(d.voiceState),g=!!c.active,b=Number((H=c.timestamp)!=null?H:0);Rt.manuallyDeactivated=!!c.manuallyDeactivated,g&&Date.now()-b<hC&&setTimeout(()=>{var _,U;Rt.active||(Rt.manuallyDeactivated=!1,((U=(_=n.voiceRecognition)==null?void 0:_.provider)==null?void 0:U.type)==="runtype"?q.toggleVoice().then(()=>{Rt.active=q.isVoiceActive(),En("restore"),q.isVoiceActive()&&hs()}):Wr("restore"))},1e3)},di=()=>q?Kx(q.getMessages()).filter(c=>!c.__skipPersist):[];function Ma(c){if(!(i!=null&&i.save))return;let b={messages:c?Kx(c):q?di():[],metadata:d,artifacts:Zt.artifacts,selectedArtifactId:Zt.selectedId};try{let A=i.save(b);A instanceof Promise&&A.catch(H=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to persist state:",H)})}catch(A){typeof console!="undefined"&&console.error("[AgentWidget] Failed to persist state:",A)}}let lo=null,os=()=>We.querySelector("#persona-scroll-container")||ue,Mo=()=>{lo!==null&&(cancelAnimationFrame(lo),lo=null),Un=!1},as=()=>{_n!==null&&(cancelAnimationFrame(_n),_n=null),Vo=!1,Mo()},ss=()=>{io>0?(ir.textContent=String(io),ir.style.display="",et.setAttribute("aria-label",`${ct()||"Jump to latest"} (${io} new)`)):(ir.textContent="",ir.style.display="none",et.setAttribute("aria-label",ct()||"Jump to latest"))},is=()=>{io!==0&&(io=0,ss())},ls=()=>pt()==="follow"?!mn.isFollowing():!ma(ue,Sa),sn=()=>{if(!Ir()||pe){et.parentNode&&et.remove(),et.style.display="none";return}et.parentNode!==j&&j.appendChild(et),Sr();let g=xo(ue)>0&&ls();g||is(),et.style.display=g?"":"none"},ka=()=>{mn.pause()&&(as(),sn())},Jn=()=>{mn.resume(),is(),sn()},Yn=(c=!1)=>{pt()==="follow"&&mn.isFollowing()&&(!c&&!Kn||(_n!==null&&(cancelAnimationFrame(_n),_n=null),Vo=!0,_n=requestAnimationFrame(()=>{_n=null,Vo=!1,mn.isFollowing()&&ci(os(),c?220:140)})))},ds=(c,g,b,A=()=>!0)=>{let H=c.scrollTop,_=g(),U=_-H;Mo();let $=performance.now();Un=!0;let O=me=>1-Math.pow(1-me,3),Ce=me=>{if(!A()){Mo();return}let oe=g();oe!==_&&(_=oe,U=_-H);let Te=me-$,Ve=Math.min(Te/b,1),Se=O(Ve),dt=H+U*Se;c.scrollTop=dt,gn=c.scrollTop,Ve<1?lo=requestAnimationFrame(Ce):(c.scrollTop=_,gn=c.scrollTop,lo=null,Un=!1)};lo=requestAnimationFrame(Ce)},ci=(c,g=500)=>{let b=xo(c)-c.scrollTop;if(Math.abs(b)<1){gn=c.scrollTop;return}if(Math.abs(b)>=ii){Mo(),Un=!0,c.scrollTop=xo(c),gn=c.scrollTop,Un=!1;return}ds(c,()=>xo(c),g,()=>mn.isFollowing())},cs=()=>{let c=os();Un=!0,c.scrollTop=xo(c),gn=c.scrollTop,Un=!1,sn()},ps=c=>{fr.style.height=`${Math.max(0,Math.round(c))}px`,zr&&(zr.spacerHeight=Math.max(0,c))},Go=()=>{Qn!==null&&(cancelAnimationFrame(Qn),Qn=null),Mo(),zr=null,fr.style.height="0px"},pi=c=>{Qn!==null&&cancelAnimationFrame(Qn),Qn=requestAnimationFrame(()=>{var Ce;Qn=null;let g=typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(c):c.replace(/"/g,'\\"'),b=ue.querySelector(`[data-message-id="${g}"]`);if(!b)return;let A=0,H=b;for(;H&&H!==ue;)A+=H.offsetTop,H=H.offsetParent;let _=(Ce=zr==null?void 0:zr.spacerHeight)!=null?Ce:0,U=ue.scrollHeight-_,{targetScrollTop:$,spacerHeight:O}=Jh({anchorOffsetTop:A,topOffset:Pt(),viewportHeight:ue.clientHeight,contentHeight:U});zr={initialSpacerHeight:O,contentHeightAtAnchor:U,spacerHeight:O},ps(O),ds(ue,()=>$,220)})},ui=()=>{if(pt()==="follow"){if(!mn.isFollowing()||ma(ue,1))return;Yn(!Kn);return}if(zr&&zr.initialSpacerHeight>0){let c=ue.scrollHeight-zr.spacerHeight,g=Yh({initialSpacerHeight:zr.initialSpacerHeight,contentHeightAtAnchor:zr.contentHeightAtAnchor,currentContentHeight:c});g!==zr.spacerHeight&&ps(g)}sn()},fi=c=>{let g=pt();g==="follow"?(Jn(),Yn(!0)):g==="anchor-top"&&pi(c)},mi=c=>{let g=new Map;c.forEach(b=>{let A=Ta.get(b.id);g.set(b.id,{streaming:b.streaming,role:b.role}),!A&&b.role==="assistant"&&(a.emit("assistant:message",b),!jo&&pt()!=="anchor-top"&&ls()&&(io+=1,ss(),sn())),b.role==="assistant"&&(A!=null&&A.streaming)&&b.streaming===!1&&a.emit("assistant:complete",b),b.variant==="approval"&&b.approval&&(A?b.approval.status!=="pending"&&a.emit("approval:resolved",{approval:b.approval,decision:b.approval.status}):a.emit("approval:requested",{approval:b.approval,message:b}))}),Ta.clear(),g.forEach((b,A)=>{Ta.set(A,b)})},Ko=(c,g,b)=>{var xt,Be,Le,Ke,rt,Wt;let A=document.createElement("div"),_=(()=>{var Ne;let D=o.find(Ue=>Ue.renderLoadingIndicator);if(D!=null&&D.renderLoadingIndicator)return D.renderLoadingIndicator;if((Ne=n.loadingIndicator)!=null&&Ne.render)return n.loadingIndicator.render})(),U=(D,Ne)=>Ne==null?!1:typeof Ne=="string"?(D.textContent=Ne,!0):(D.appendChild(Ne),!0),$=new Set,O=new Set,Ce=o.some(D=>D.renderAskUserQuestion),me=[],oe=[],Te=n.enableComponentStreaming!==!1,Ve=o.some(D=>D.renderApproval)&&n.approval!==!1,Se=[];if(g.forEach(D=>{var ot,Ut,Er,Rn,xn,Xo,Qo,Ia,Wa,mr,Jo,Wo,Ho,po;$.add(D.id);let Ne=Ce&&yo(D),Ue=Ve&&D.variant==="approval"&&!!D.approval,be=!Ne&&D.role==="assistant"&&!D.variant&&Te&&Vl(D);if(!Ue&&On.has(D.id)){let ut=c.querySelector(`#wrapper-${D.id}`);ut==null||ut.removeAttribute("data-preserve-runtime"),On.delete(D.id)}if(!be&&Xn.has(D.id)){let ut=c.querySelector(`#wrapper-${D.id}`);ut==null||ut.removeAttribute("data-preserve-runtime"),Xn.delete(D.id)}let Yt=yo(D)?`:${(ot=D.agentMetadata)!=null&&ot.askUserQuestionAnswered?"a":"u"}:${(Ut=D.agentMetadata)!=null&&Ut.askUserQuestionAnswers?Object.keys(D.agentMetadata.askUserQuestionAnswers).length:0}`:"",Kt=Vh(D,rs)+Yt,cr=Ne||Ue||be?null:Gh(ao,D.id,Kt);if(cr){A.appendChild(cr.cloneNode(!0)),yo(D)&&((Er=D.toolCall)!=null&&Er.id)&&((Rn=D.agentMetadata)==null?void 0:Rn.awaitingLocalTool)===!0&&!((xn=D.agentMetadata)!=null&&xn.askUserQuestionAnswered)&&(O.add(D.toolCall.id),Ja(D,n,Pe.composerOverlay));return}let Bt=null,lr=o.find(ut=>!!(D.variant==="reasoning"&&ut.renderReasoning||D.variant==="tool"&&ut.renderToolCall||!D.variant&&ut.renderMessage)),hn=(Xo=n.layout)==null?void 0:Xo.messages;if(yo(D)&&((Qo=D.agentMetadata)==null?void 0:Qo.askUserQuestionAnswered)===!0){so.delete(D.id);let ut=c.querySelector(`#wrapper-${D.id}`);ut==null||ut.removeAttribute("data-preserve-runtime");return}if(yo(D)&&((Wa=(Ia=n.features)==null?void 0:Ia.askUserQuestion)==null?void 0:Wa.enabled)!==!1){let ut=o.find(Nr=>typeof Nr.renderAskUserQuestion=="function");if(ut&&wt.current){let Nr=so.get(D.id),Xr=Nr!==Kt,Mr=null;if(Xr){let{payload:yt,complete:ln}=vo(D),Lr=D.id,Zn=()=>{var Pr;return(Pr=wt.current)==null?void 0:Pr.getMessages().find(Qr=>Qr.id===Lr)};Mr=ut.renderAskUserQuestion({message:D,payload:yt,complete:ln,resolve:Pr=>{var In;let Qr=Zn();Qr&&((In=wt.current)==null||In.resolveAskUserQuestion(Qr,Pr))},dismiss:()=>{var Qr,In,Yo;let Pr=Zn();(Qr=Pr==null?void 0:Pr.agentMetadata)!=null&&Qr.awaitingLocalTool&&((In=wt.current)==null||In.markAskUserQuestionResolved(Pr),(Yo=wt.current)==null||Yo.resolveAskUserQuestion(Pr,"(dismissed)"))},config:n})}let bt=Nr!=null;if(Xr&&Mr===null&&!bt){((mr=D.agentMetadata)==null?void 0:mr.awaitingLocalTool)===!0&&!((Jo=D.agentMetadata)!=null&&Jo.askUserQuestionAnswered)&&(O.add(D.toolCall.id),Ja(D,n,Pe.composerOverlay));return}let Et=document.createElement("div");Et.className="persona-flex",Et.id=`wrapper-${D.id}`,Et.setAttribute("data-wrapper-id",D.id),Et.setAttribute("data-ask-plugin-stub","true"),Et.setAttribute("data-preserve-runtime","true"),A.appendChild(Et),me.push({messageId:D.id,fingerprint:Kt,bubble:Mr});return}else{((Wo=D.agentMetadata)==null?void 0:Wo.awaitingLocalTool)===!0&&!((Ho=D.agentMetadata)!=null&&Ho.askUserQuestionAnswered)&&(O.add(D.toolCall.id),Ja(D,n,Pe.composerOverlay));return}}else if(Ue){let ut=o.find(bt=>typeof bt.renderApproval=="function"),Xr=On.get(D.id)!==Kt,Mr=null;if(Xr&&(ut!=null&&ut.renderApproval)){let bt=D.id,Et=(yt,ln)=>{var Zn,Pr,Qr;let Lr=(Zn=wt.current)==null?void 0:Zn.getMessages().find(In=>In.id===bt);Lr!=null&&Lr.approval&&(Lr.approval.toolType==="webmcp"?(Pr=wt.current)==null||Pr.resolveWebMcpApproval(Lr.id,yt):(Qr=wt.current)==null||Qr.resolveApproval(Lr.approval,yt,ln))};Mr=ut.renderApproval({message:D,defaultRenderer:()=>Nl(D,n),config:n,approve:yt=>Et("approved",yt),deny:yt=>Et("denied",yt)})}if(Xr&&Mr===null){let bt=c.querySelector(`#wrapper-${D.id}`);bt==null||bt.removeAttribute("data-preserve-runtime"),On.delete(D.id),Bt=Nl(D,n)}else{let bt=document.createElement("div");bt.className="persona-flex",bt.id=`wrapper-${D.id}`,bt.setAttribute("data-wrapper-id",D.id),bt.setAttribute("data-approval-plugin-stub","true"),bt.setAttribute("data-preserve-runtime","true"),A.appendChild(bt),Se.push({messageId:D.id,fingerprint:Kt,bubble:Mr});return}}else if(lr)if(D.variant==="reasoning"&&D.reasoning&&lr.renderReasoning){if(!Je)return;Bt=lr.renderReasoning({message:D,defaultRenderer:()=>qp(D,n),config:n})}else if(D.variant==="tool"&&D.toolCall&&lr.renderToolCall){if(!we)return;Bt=lr.renderToolCall({message:D,defaultRenderer:()=>zp(D,n),config:n})}else lr.renderMessage&&(Bt=lr.renderMessage({message:D,defaultRenderer:()=>{let ut=ja(D,b,hn,n.messageActions,ne,{loadingIndicatorRenderer:_,widgetConfig:n});return D.role!=="user"&&eu(ut,D,n,q),ut},config:n}));if(!Bt&&be){let ut=jl(D);if(ut){let Nr=Xn.get(D.id),Xr=Nr!==Kt,Mr=n.wrapComponentDirectiveInBubble!==!1,bt=null;if(Xr){let Et=$l(ut,{config:n,message:D,transform:b});if(Et)if(Mr){let yt=document.createElement("div");if(yt.className=["persona-message-bubble","persona-max-w-[85%]","persona-rounded-2xl","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-p-4"].join(" "),yt.id=`bubble-${D.id}`,yt.setAttribute("data-message-id",D.id),D.content&&D.content.trim()){let ln=document.createElement("div");ln.className="persona-mb-3 persona-text-sm persona-leading-relaxed",ln.innerHTML=b({text:D.content,message:D,streaming:!!D.streaming,raw:D.rawContent}),yt.appendChild(ln)}yt.appendChild(Et),bt=yt}else{let yt=document.createElement("div");if(yt.className="persona-flex persona-flex-col persona-w-full persona-max-w-full persona-gap-3 persona-items-stretch",yt.id=`bubble-${D.id}`,yt.setAttribute("data-message-id",D.id),yt.setAttribute("data-persona-component-directive","true"),D.content&&D.content.trim()){let ln=document.createElement("div");ln.className="persona-text-sm persona-leading-relaxed persona-text-persona-primary persona-w-full",ln.innerHTML=b({text:D.content,message:D,streaming:!!D.streaming,raw:D.rawContent}),yt.appendChild(ln)}yt.appendChild(Et),bt=yt}}if(bt||Nr!=null){let Et=document.createElement("div");Et.className="persona-flex",Et.id=`wrapper-${D.id}`,Et.setAttribute("data-wrapper-id",D.id),Et.setAttribute("data-component-directive-stub","true"),Et.setAttribute("data-preserve-runtime","true"),Mr||Et.classList.add("persona-w-full"),A.appendChild(Et),oe.push({messageId:D.id,fingerprint:Kt,bubble:bt});return}}}if(!Bt)if(D.variant==="reasoning"&&D.reasoning){if(!Je)return;Bt=qp(D,n)}else if(D.variant==="tool"&&D.toolCall){if(!we)return;Bt=zp(D,n)}else if(D.variant==="approval"&&D.approval){if(n.approval===!1)return;Bt=Nl(D,n)}else{let ut=(po=n.layout)==null?void 0:po.messages;ut!=null&&ut.renderUserMessage&&D.role==="user"?Bt=ut.renderUserMessage({message:D,config:n,streaming:!!D.streaming}):ut!=null&&ut.renderAssistantMessage&&D.role==="assistant"?Bt=ut.renderAssistantMessage({message:D,config:n,streaming:!!D.streaming}):Bt=ja(D,b,ut,n.messageActions,ne,{loadingIndicatorRenderer:_,widgetConfig:n}),D.role!=="user"&&Bt&&eu(Bt,D,n,q)}let Tr=document.createElement("div");Tr.className="persona-flex",Tr.id=`wrapper-${D.id}`,Tr.setAttribute("data-wrapper-id",D.id),D.role==="user"&&Tr.classList.add("persona-justify-end"),(Bt==null?void 0:Bt.getAttribute("data-persona-component-directive"))==="true"&&Tr.classList.add("persona-w-full"),Tr.appendChild(Bt),Kh(ao,D.id,Kt,Tr),A.appendChild(Tr)}),Pe.composerOverlay&&Pe.composerOverlay.querySelectorAll("[data-persona-ask-sheet-for]").forEach(Ne=>{let Ue=Ne.getAttribute("data-persona-ask-sheet-for");Ue&&!O.has(Ue)&&zo(Pe.composerOverlay,Ue)}),(Be=(xt=n.features)==null?void 0:xt.toolCallDisplay)!=null&&Be.grouped){let D=[],Ne=[];g.forEach(Ue=>{if(Ue.variant==="tool"&&Ue.toolCall&&we){Ne.push(Ue);return}Ne.length>1&&D.push(Ne),Ne=[]}),Ne.length>1&&D.push(Ne),D.forEach((Ue,be)=>{var ot,Ut;let Yt=Ue.map(Er=>Array.from(A.children).find(Rn=>Rn instanceof HTMLElement&&Rn.getAttribute("data-wrapper-id")===Er.id)).filter(Er=>!!Er);if(Yt.length<2)return;let Kt=document.createElement("div");Kt.className="persona-flex",Kt.id=`wrapper-tool-group-${be}-${Ue[0].id}`,Kt.setAttribute("data-wrapper-id",`tool-group-${be}-${Ue[0].id}`);let cr=document.createElement("div");cr.className="persona-tool-group persona-flex persona-w-full persona-flex-col persona-gap-2",cr.setAttribute("data-persona-tool-group","true");let Bt=document.createElement("div");Bt.className="persona-tool-group-summary persona-text-xs persona-text-persona-muted";let lr=`Called ${Ue.length} tools`,hn=(Ut=(ot=n.toolCall)==null?void 0:ot.renderGroupedSummary)==null?void 0:Ut.call(ot,{messages:Ue,toolCalls:Ue.map(Er=>Er.toolCall).filter(Er=>!!Er),defaultSummary:lr,config:n});U(Bt,hn)||(Bt.textContent=lr);let Tr=document.createElement("div");Tr.className="persona-tool-group-stack persona-flex persona-flex-col",cr.append(Bt,Tr),Kt.appendChild(cr),Yt[0].before(Kt),Yt.forEach((Er,Rn)=>{let xn=document.createElement("div");xn.className="persona-tool-group-item persona-relative",xn.setAttribute("data-persona-tool-group-item","true"),Rn<Yt.length-1&&xn.setAttribute("data-persona-tool-group-connector","true"),xn.appendChild(Er),Tr.appendChild(xn)})})}Xh(ao,$);let dt=g.some(D=>D.role==="assistant"&&D.streaming),Qe=g[g.length-1],ht=(Qe==null?void 0:Qe.role)==="assistant"&&!Qe.streaming&&Qe.variant!=="approval";if(Kn&&g.some(D=>D.role==="user")&&!dt&&!ht){let D={config:n,streaming:!0,location:"standalone",defaultRenderer:xa},Ne=o.find(be=>be.renderLoadingIndicator),Ue=null;if(Ne!=null&&Ne.renderLoadingIndicator&&(Ue=Ne.renderLoadingIndicator(D)),Ue===null&&((Le=n.loadingIndicator)!=null&&Le.render)&&(Ue=n.loadingIndicator.render(D)),Ue===null&&(Ue=xa()),Ue){let be=document.createElement("div"),Yt=((Ke=n.loadingIndicator)==null?void 0:Ke.showBubble)!==!1;be.className=Yt?["persona-max-w-[85%]","persona-rounded-2xl","persona-text-sm","persona-leading-relaxed","persona-shadow-sm","persona-bg-persona-surface","persona-border","persona-text-persona-primary","persona-px-5","persona-py-3"].join(" "):["persona-max-w-[85%]","persona-text-sm","persona-leading-relaxed","persona-text-persona-primary"].join(" "),be.setAttribute("data-typing-indicator","true"),be.style.borderColor="var(--persona-message-assistant-border, var(--persona-border, #e5e7eb))",be.appendChild(Ue);let Kt=document.createElement("div");Kt.className="persona-flex",Kt.id="wrapper-typing-indicator",Kt.setAttribute("data-wrapper-id","typing-indicator"),Kt.appendChild(be),A.appendChild(Kt)}}if(!Kn&&g.length>0){let D=g[g.length-1],Ne={config:n,lastMessage:D,messageCount:g.length},Ue=o.find(Yt=>Yt.renderIdleIndicator),be=null;if(Ue!=null&&Ue.renderIdleIndicator&&(be=Ue.renderIdleIndicator(Ne)),be===null&&((rt=n.loadingIndicator)!=null&&rt.renderIdle)&&(be=n.loadingIndicator.renderIdle(Ne)),be){let Yt=document.createElement("div"),Kt=((Wt=n.loadingIndicator)==null?void 0:Wt.showBubble)!==!1;Yt.className=Kt?["persona-max-w-[85%]","persona-rounded-2xl","persona-text-sm","persona-leading-relaxed","persona-shadow-sm","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-text-persona-primary","persona-px-5","persona-py-3"].join(" "):["persona-max-w-[85%]","persona-text-sm","persona-leading-relaxed","persona-text-persona-primary"].join(" "),Yt.setAttribute("data-idle-indicator","true"),Yt.appendChild(be);let cr=document.createElement("div");cr.className="persona-flex",cr.id="wrapper-idle-indicator",cr.setAttribute("data-wrapper-id","idle-indicator"),cr.appendChild(Yt),A.appendChild(cr)}}if(gl(c,A),me.length>0)for(let{messageId:D,fingerprint:Ne,bubble:Ue}of me){let be=c.querySelector(`#wrapper-${D}`);be&&Ue!==null&&(be.replaceChildren(Ue),be.setAttribute("data-bubble-fp",Ne),so.set(D,Ne))}if(so.size>0)for(let D of so.keys())$.has(D)||so.delete(D);if(oe.length>0)for(let{messageId:D,fingerprint:Ne,bubble:Ue}of oe){let be=c.querySelector(`#wrapper-${D}`);be&&Ue!==null&&(be.replaceChildren(Ue),be.setAttribute("data-bubble-fp",Ne),Xn.set(D,Ne))}if(Xn.size>0)for(let D of Xn.keys())$.has(D)||Xn.delete(D);if(Se.length>0)for(let{messageId:D,fingerprint:Ne,bubble:Ue}of Se){let be=c.querySelector(`#wrapper-${D}`);be&&Ue!==null&&(be.replaceChildren(Ue),be.setAttribute("data-bubble-fp",Ne),On.set(D,Ne))}if(On.size>0)for(let D of On.keys())$.has(D)||On.delete(D)},ko=null,gi=()=>{var b;if(ko)return;let c=A=>{let H=A.composedPath();H.includes(We)||at&&H.includes(at)||Gt(!1,"user")};ko=c,((b=r.ownerDocument)!=null?b:document).addEventListener("pointerdown",c,!0)},us=()=>{var g;if(!ko)return;((g=r.ownerDocument)!=null?g:document).removeEventListener("pointerdown",ko,!0),ko=null};kt.push(()=>us());let Eo=null,hi=()=>{var b;if(Eo)return;let c=A=>{A.key==="Escape"&&(A.isComposing||Gt(!1,"user"))};Eo=c,((b=r.ownerDocument)!=null?b:document).addEventListener("keydown",c,!0)},fs=()=>{var g;if(!Eo)return;((g=r.ownerDocument)!=null?g:document).removeEventListener("keydown",Eo,!0),Eo=null};kt.push(()=>fs());let Lo=!1,ms=new Set,xi=()=>{var g,b,A,H;let c=(A=(b=(g=n.launcher)==null?void 0:g.composerBar)==null?void 0:b.peek)==null?void 0:A.streamAnimation;return c||((H=n.features)==null?void 0:H.streamAnimation)},co=()=>{var ht,xt,Be,Le;if(!W())return;let c=Pe.peekBanner,g=Pe.peekTextNode;if(!c||!g)return;if(I){c.classList.remove("persona-pill-peek--visible");return}let b=(ht=q==null?void 0:q.getMessages())!=null?ht:[],A;for(let Ke=b.length-1;Ke>=0;Ke--){let rt=b[Ke];if(rt.role==="assistant"&&rt.content){A=rt;break}}if(!A){c.classList.remove("persona-pill-peek--visible");return}let H=A.content,_=!!A.streaming,U=xi(),$=vl(U),O=$.type!=="none"?Vs($.type,U==null?void 0:U.plugins):null,Ce=((xt=O==null?void 0:O.isAnimating)==null?void 0:xt.call(O,A))===!0,me=O!==null&&(_||Ce);me&&O&&!ms.has(O.name)&&(Ip(O,r),ms.add(O.name));let oe=me&&(O!=null&&O.containerClass)?O.containerClass:null,Te=(Be=g.dataset.personaPeekStreamClass)!=null?Be:null;Te&&Te!==oe&&(g.classList.remove(Te),delete g.dataset.personaPeekStreamClass),oe&&Te!==oe&&(g.classList.add(oe),g.dataset.personaPeekStreamClass=oe),me?(g.style.setProperty("--persona-stream-step",`${$.speed}ms`),g.style.setProperty("--persona-stream-duration",`${$.duration}ms`)):(g.style.removeProperty("--persona-stream-step"),g.style.removeProperty("--persona-stream-duration"));let Ve=me?Cl(H,$.buffer,O,A,_):H;if(me&&$.placeholder==="skeleton"&&_&&(!Ve||!Ve.trim())){let Ke=document.createElement("div"),rt=Gs();rt.classList.add("persona-pill-peek__skeleton"),Ke.appendChild(rt),gl(g,Ke)}else{let Ke=Math.max(0,Ve.length-100),rt=Ve.length>100?Ve.slice(-100):Ve,Wt=ia(rt);if(!me||!O){let D=Ve.length>100?`\u2026${rt}`:rt;g.textContent!==D&&(g.textContent=D)}else{let D=Wt;(O.wrap==="char"||O.wrap==="word")&&(D=js(Wt,O.wrap,`peek-${A.id}`,{skipTags:O.skipTags,startIndex:Ke}));let Ne=document.createElement("div");if(Ne.innerHTML=D,O.useCaret&&rt.length>0){let Ue=wl(),be=Ne.querySelectorAll(".persona-stream-char, .persona-stream-word"),Yt=be[be.length-1];Yt!=null&&Yt.parentNode?Yt.parentNode.insertBefore(Ue,Yt.nextSibling):Ne.appendChild(Ue)}gl(g,Ne),(Le=O.onAfterRender)==null||Le.call(O,{container:g,bubble:c,messageId:A.id,message:A,speed:$.speed,duration:$.duration})}}let Qe=Kn||Lo;c.classList.toggle("persona-pill-peek--visible",Qe)};if(W()){let c=Pe.peekBanner;if(c){let A=H=>{H.preventDefault(),H.stopPropagation(),Gt(!0,"user")};c.addEventListener("pointerdown",A),kt.push(()=>{c.removeEventListener("pointerdown",A)})}let g=()=>{Lo||(Lo=!0,co())},b=()=>{Lo&&(Lo=!1,co())};he.addEventListener("pointerenter",g),he.addEventListener("pointerleave",b),kt.push(()=>{he.removeEventListener("pointerenter",g),he.removeEventListener("pointerleave",b)}),at&&(at.addEventListener("pointerenter",g),at.addEventListener("pointerleave",b),kt.push(()=>{at.removeEventListener("pointerenter",g),at.removeEventListener("pointerleave",b)}))}let bi=c=>{var Te,Ve,Se,dt,Qe,ht,xt,Be;let g=(Ve=(Te=n.launcher)==null?void 0:Te.composerBar)!=null?Ve:{},b=(Se=g.expandedSize)!=null?Se:"anchored",A=(dt=g.bottomOffset)!=null?dt:"16px",H=g.collapsedMaxWidth,_=(Qe=g.expandedMaxWidth)!=null?Qe:"880px",U=(ht=g.expandedTopOffset)!=null?ht:"5vh",$=(xt=g.modalMaxWidth)!=null?xt:"880px",O=(Be=g.modalMaxHeight)!=null?Be:"min(90vh, 800px)",Ce="calc(100vw - 32px)",me="var(--persona-pill-area-height, 80px)",oe=We.style;if(oe.left="",oe.right="",oe.top="",oe.bottom="",oe.transform="",oe.width="",oe.maxWidth="",oe.height="",oe.maxHeight="",at){let Le=at.style;Le.bottom=A,Le.width=H!=null?H:""}if(c&&b!=="fullscreen"){if(b==="modal"){oe.top="50%",oe.left="50%",oe.transform="translate(-50%, -50%)",oe.bottom="auto",oe.right="auto",oe.width=$,oe.maxWidth=Ce,oe.maxHeight=O,oe.height=O;return}oe.left="50%",oe.transform="translateX(-50%)",oe.bottom=`calc(${A} + ${me})`,oe.top=U,oe.width=_,oe.maxWidth=Ce}},Po=()=>{var O,Ce,me,oe,Te,Ve,Se,dt;if(!R())return;if(W()){let ht=(me=((Ce=(O=n.launcher)==null?void 0:O.composerBar)!=null?Ce:{}).expandedSize)!=null?me:"anchored",xt=I?"expanded":"collapsed";We.dataset.state=xt,We.dataset.expandedSize=ht,at&&(at.dataset.state=xt,at.dataset.expandedSize=ht),We.style.removeProperty("display"),We.classList.remove("persona-pointer-events-none","persona-opacity-0"),he.classList.remove("persona-scale-95","persona-opacity-0","persona-scale-100","persona-opacity-100"),bi(I),j.style.display=I?"flex":"none",Nn(),I?(gi(),hi()):(us(),fs()),co();return}let c=Rr(n),g=(oe=r.ownerDocument.defaultView)!=null?oe:window,b=(Ve=(Te=n.launcher)==null?void 0:Te.mobileBreakpoint)!=null?Ve:640,A=(dt=(Se=n.launcher)==null?void 0:Se.mobileFullscreen)!=null?dt:!0,H=g.innerWidth<=b,_=A&&H&&M,U=Hn(n).reveal;I?(We.style.removeProperty("display"),We.style.display=c?"flex":"",We.classList.remove("persona-pointer-events-none","persona-opacity-0"),he.classList.remove("persona-scale-95","persona-opacity-0"),he.classList.add("persona-scale-100","persona-opacity-100"),Cr?Cr.element.style.display="none":wr&&(wr.style.display="none")):(c?c&&(U==="overlay"||U==="push")&&!_?(We.style.removeProperty("display"),We.style.display="flex",We.classList.remove("persona-pointer-events-none","persona-opacity-0"),he.classList.remove("persona-scale-100","persona-opacity-100","persona-scale-95","persona-opacity-0")):(We.style.setProperty("display","none","important"),We.classList.remove("persona-pointer-events-none","persona-opacity-0"),he.classList.remove("persona-scale-100","persona-opacity-100","persona-scale-95","persona-opacity-0")):(We.style.display="",We.classList.add("persona-pointer-events-none","persona-opacity-0"),he.classList.remove("persona-scale-100","persona-opacity-100"),he.classList.add("persona-scale-95","persona-opacity-0")),Cr?Cr.element.style.display=c?"none":"":wr&&(wr.style.display=c?"none":""))},Gt=(c,g="user")=>{var _,U;if(!R()||I===c)return;let b=I;I=c,Po();let A=(()=>{var Se,dt,Qe,ht,xt,Be,Le,Ke,rt,Wt;let $=(dt=(Se=n.launcher)==null?void 0:Se.sidebarMode)!=null?dt:!1,O=(Qe=r.ownerDocument.defaultView)!=null?Qe:window,Ce=(xt=(ht=n.launcher)==null?void 0:ht.mobileFullscreen)!=null?xt:!0,me=(Le=(Be=n.launcher)==null?void 0:Be.mobileBreakpoint)!=null?Le:640,oe=O.innerWidth<=me,Te=Rr(n)&&Ce&&oe,Ve=W()&&((Wt=(rt=(Ke=n.launcher)==null?void 0:Ke.composerBar)==null?void 0:rt.expandedSize)!=null?Wt:"fullscreen")==="fullscreen";return $||Ce&&oe&&M||Te||Ve})();if(I&&A){if(!yr){let $=r.getRootNode(),O=$ instanceof ShadowRoot?$.host:r.closest(".persona-host");O&&(yr=Wp(O,(U=(_=n.launcher)==null?void 0:_.zIndex)!=null?U:Gr))}vr||(vr=Hp(r.ownerDocument))}else I||(yr==null||yr(),yr=null,vr==null||vr(),vr=null);I&&(xs(),pt()==="follow"?Yn(!0):cs());let H={open:I,source:g,timestamp:Date.now()};I&&!b?a.emit("widget:opened",H):!I&&b&&a.emit("widget:closed",H),a.emit("widget:state",{open:I,launcherEnabled:M,voiceActive:Rt.active,streaming:q.isStreaming()})},Ea=c=>{sr(c?"stop":"send"),K&&(K.disabled=c),Mn.buttons.forEach(g=>{g.disabled=c}),Oe.dataset.personaComposerStreaming=c?"true":"false",Oe.querySelectorAll("[data-persona-composer-disable-when-streaming]").forEach(g=>{(g instanceof HTMLButtonElement||g instanceof HTMLInputElement||g instanceof HTMLTextAreaElement||g instanceof HTMLSelectElement)&&(g.disabled=c)})},La=()=>{Rt.active||ee&&ee.focus()};a.on("widget:opened",()=>{n.autoFocusInput&&setTimeout(()=>La(),200)});let gs=()=>{var b,A,H,_,U,$,O,Ce,me,oe,Te;gr.textContent=(A=(b=n.copy)==null?void 0:b.welcomeTitle)!=null?A:"Hello \u{1F44B}",nn.textContent=(_=(H=n.copy)==null?void 0:H.welcomeSubtitle)!=null?_:"Ask anything about your account or products.",ee.placeholder=($=(U=n.copy)==null?void 0:U.inputPlaceholder)!=null?$:"How can I help...";let c=ue.querySelector("[data-persona-intro-card]");if(c){let Ve=((O=n.copy)==null?void 0:O.showWelcomeCard)!==!1;c.style.display=Ve?"":"none",Ve?(ue.classList.remove("persona-gap-3"),ue.classList.add("persona-gap-6")):(ue.classList.remove("persona-gap-6"),ue.classList.add("persona-gap-3"))}!((me=(Ce=n.sendButton)==null?void 0:Ce.useIcon)!=null&&me)&&!(q!=null&&q.isStreaming())&&(je.textContent=(Te=(oe=n.copy)==null?void 0:oe.sendButtonLabel)!=null?Te:"Send"),ee.style.fontFamily='var(--persona-input-font-family, var(--persona-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif))',ee.style.fontWeight="var(--persona-input-font-weight, var(--persona-font-weight, 400))"};n.clientToken&&(n={...n,getStoredSessionId:()=>{let c=d.sessionId;return typeof c=="string"?c:null},setStoredSessionId:c=>{m(g=>({...g,sessionId:c}))}});let Ln=null,tt=()=>{Ln==null&&(Ln=setInterval(()=>{let c=nt.querySelectorAll("[data-tool-elapsed]");if(c.length===0){clearInterval(Ln),Ln=null;return}let g=Date.now();c.forEach(b=>{let A=Number(b.getAttribute("data-tool-elapsed"));A&&(b.textContent=Oi(g-A))})},100))};if(q=new _a(n,{onMessagesChanged(c){var A;Ko(nt,c,xe),tt(),q&&(c.some(_=>_.role==="user")?Mn.render([],q,ee,c):Mn.render(n.suggestionChips,q,ee,c,n.suggestionChipsConfig)),Yn(!Kn),mi(c);let g=[...c].reverse().find(H=>H.role==="user");c.length===0&&Go(),!wa||jo?(wa=!0,Aa=(A=g==null?void 0:g.id)!=null?A:null):g&&g.id!==Aa&&(Aa=g.id,fi(g.id));let b=Rt.lastUserMessageId;g&&g.id!==b&&(Rt.lastUserMessageId=g.id,a.emit("user:message",g)),Rt.lastUserMessageWasVoice=!!(g!=null&&g.viaVoice),Ma(c),co()},onStatusChanged(c){var A;let g=(A=n.statusIndicator)!=null?A:{};St(ar,(H=>{var _,U,$,O;return H==="idle"?(_=g.idleText)!=null?_:jr.idle:H==="connecting"?(U=g.connectingText)!=null?U:jr.connecting:H==="connected"?($=g.connectedText)!=null?$:jr.connected:H==="error"?(O=g.errorText)!=null?O:jr.error:jr[H]})(c),g,c)},onStreamingChanged(c){Kn=c,Ea(c),q&&Ko(nt,q.getMessages(),xe),c||Yn(!0),co()},onVoiceStatusChanged(c){var g,b;if(((b=(g=n.voiceRecognition)==null?void 0:g.provider)==null?void 0:b.type)==="runtype")switch(c){case"listening":break;case"processing":Ro(),Db();break;case"speaking":Ro(),Fb();break;default:c==="idle"&&q.isBargeInActive()?(Ro(),hs(),K==null||K.setAttribute("aria-label","End voice session")):(Rt.active=!1,Ro(),En("system"),an());break}},onArtifactsState(c){Zt=c,un(),Ma()}}),wt.current=q,wa=!0,((Af=(wf=n.voiceRecognition)==null?void 0:wf.provider)==null?void 0:Af.type)==="runtype")try{q.setupVoice()}catch(c){typeof console!="undefined"&&console.warn("[AgentWidget] Runtype voice setup failed:",c)}n.clientToken&&q.initClientSession().catch(c=>{n.debug&&console.warn("[AgentWidget] Pre-init client session failed:",c)}),(ge||n.onSSEEvent)&&q.setSSEEventCallback((c,g)=>{var b;(b=n.onSSEEvent)==null||b.call(n,c,g),Z==null||Z.processEvent(c,g),ge==null||ge.push({id:`evt-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,type:c,timestamp:Date.now(),payload:JSON.stringify(g)})}),l&&l.then(c=>{var g,b,A;if(c){if(c.metadata&&(d=nu(c.metadata),S.syncFromMetadata()),(g=c.messages)!=null&&g.length){jo=!0;try{q.hydrateMessages(c.messages)}finally{jo=!1}}(b=c.artifacts)!=null&&b.length&&q.hydrateArtifacts(c.artifacts,(A=c.selectedArtifactId)!=null?A:null)}}).catch(c=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to hydrate stored state:",c)});let L=()=>{var g,b,A;!W()||I||!((A=(b=(g=n.launcher)==null?void 0:g.composerBar)==null?void 0:b.expandOnSubmit)==null||A)||Gt(!0,"auto")},z=c=>{var H;if(c.preventDefault(),q.isStreaming()){q.cancel(),Z==null||Z.reset(),G==null||G.update();return}let g=ee.value.trim(),b=(H=Mt==null?void 0:Mt.hasAttachments())!=null?H:!1;if(!g&&!b)return;L();let A;b&&(A=[],A.push(...Mt.getContentParts()),g&&A.push(Fs(g))),ee.value="",ee.style.height="auto",X(),q.sendMessage(g,{contentParts:A}),b&&Mt.clearAttachments()},B=()=>{var c;return((c=n.features)==null?void 0:c.composerHistory)!==!1},te={...hl},ce=!1,X=()=>{te={...hl}},He=()=>q.getMessages().filter(c=>c.role==="user").map(c=>{var g;return(g=c.content)!=null?g:""}).filter(c=>c.length>0),$e=c=>{if(!ee)return;ce=!0,ee.value=c,ee.dispatchEvent(new Event("input",{bubbles:!0})),ce=!1;let g=ee.value.length;ee.setSelectionRange(g,g)},mt=()=>{ce||X()},lt=c=>{if(ee){if(B()&&(c.key==="ArrowUp"||c.key==="ArrowDown")&&!c.shiftKey&&!c.metaKey&&!c.ctrlKey&&!c.altKey&&!c.isComposing){let g=ee.selectionStart===0&&ee.selectionEnd===0,b=$h({direction:c.key==="ArrowUp"?"up":"down",history:He(),currentValue:ee.value,atStart:g,state:te});if(te=b.state,b.handled){c.preventDefault(),b.value!==void 0&&$e(b.value);return}}if(c.key==="Enter"&&!c.shiftKey){if(q.isStreaming()){c.preventDefault();return}X(),c.preventDefault(),je.click()}}},zt=c=>{c.key!=="Escape"||c.isComposing||q.isStreaming()&&c.composedPath().includes(j)&&(q.cancel(),Z==null||Z.reset(),G==null||G.update(),X(),c.preventDefault(),c.stopImmediatePropagation())},er=async c=>{var b;if(((b=n.attachments)==null?void 0:b.enabled)!==!0||!Mt)return;let g=bC(c.clipboardData);g.length!==0&&(c.preventDefault(),await Mt.handleFiles(g))},Jt=null,gt=!1,Ft=null,Ge=null,$r=()=>typeof window=="undefined"?null:window.webkitSpeechRecognition||window.SpeechRecognition||null,Wr=(c="user")=>{var _,U,$,O,Ce,me,oe;if(gt||q.isStreaming())return;let g=$r();if(!g)return;Jt=new g;let A=(U=((_=n.voiceRecognition)!=null?_:{}).pauseDuration)!=null?U:2e3;Jt.continuous=!0,Jt.interimResults=!0,Jt.lang="en-US";let H=ee.value;Jt.onresult=Te=>{let Ve="",Se="";for(let Qe=0;Qe<Te.results.length;Qe++){let ht=Te.results[Qe],xt=ht[0].transcript;ht.isFinal?Ve+=xt+" ":Se=xt}let dt=H+Ve+Se;ee.value=dt,Ft&&clearTimeout(Ft),(Ve||Se)&&(Ft=window.setTimeout(()=>{let Qe=ee.value.trim();Qe&&Jt&>&&(tr(),ee.value="",ee.style.height="auto",q.sendMessage(Qe,{viaVoice:!0}))},A))},Jt.onerror=Te=>{Te.error!=="no-speech"&&tr()},Jt.onend=()=>{if(gt){let Te=ee.value.trim();Te&&Te!==H.trim()&&(ee.value="",ee.style.height="auto",q.sendMessage(Te,{viaVoice:!0})),tr()}};try{if(Jt.start(),gt=!0,Rt.active=!0,c!=="system"&&(Rt.manuallyDeactivated=!1),En(c),an(),K){let Te=($=n.voiceRecognition)!=null?$:{};Ge={backgroundColor:K.style.backgroundColor,color:K.style.color,borderColor:K.style.borderColor,iconName:(O=Te.iconName)!=null?O:"mic",iconSize:parseFloat((oe=(me=Te.iconSize)!=null?me:(Ce=n.sendButton)==null?void 0:Ce.size)!=null?oe:"40")||24};let Ve=Te.recordingBackgroundColor,Se=Te.recordingIconColor,dt=Te.recordingBorderColor;if(K.classList.add("persona-voice-recording"),K.style.backgroundColor=Ve!=null?Ve:"var(--persona-voice-recording-bg, #ef4444)",K.style.color=Se!=null?Se:"var(--persona-voice-recording-indicator, #ffffff)",Se){let Qe=K.querySelector("svg");Qe&&Qe.setAttribute("stroke",Se)}dt&&(K.style.borderColor=dt),K.setAttribute("aria-label","Stop voice recognition")}}catch{tr("system")}},tr=(c="user")=>{if(gt){if(gt=!1,Ft&&(clearTimeout(Ft),Ft=null),Jt){try{Jt.stop()}catch{}Jt=null}if(Rt.active=!1,En(c),an(),K){if(K.classList.remove("persona-voice-recording"),Ge){K.style.backgroundColor=Ge.backgroundColor,K.style.color=Ge.color,K.style.borderColor=Ge.borderColor;let g=K.querySelector("svg");g&&g.setAttribute("stroke",Ge.color||"currentColor"),Ge=null}K.setAttribute("aria-label","Start voice recognition")}}},qn=(c,g)=>{var ht,xt,Be,Le,Ke,rt,Wt,D;let b=typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined"),A=((ht=c==null?void 0:c.provider)==null?void 0:ht.type)==="runtype";if(!(b||A))return null;let _=y("div","persona-send-button-wrapper"),U=y("button","persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer");U.type="button",U.setAttribute("aria-label","Start voice recognition");let $=(xt=c==null?void 0:c.iconName)!=null?xt:"mic",O=(Be=g==null?void 0:g.size)!=null?Be:"40px",Ce=(Le=c==null?void 0:c.iconSize)!=null?Le:O,me=parseFloat(Ce)||24,oe=(Ke=c==null?void 0:c.backgroundColor)!=null?Ke:g==null?void 0:g.backgroundColor,Te=(rt=c==null?void 0:c.iconColor)!=null?rt:g==null?void 0:g.textColor;U.style.width=Ce,U.style.height=Ce,U.style.minWidth=Ce,U.style.minHeight=Ce,U.style.fontSize="18px",U.style.lineHeight="1",Te?U.style.color=Te:U.style.color="var(--persona-text, #111827)";let Se=Me($,me,Te||"currentColor",1.5);Se?U.appendChild(Se):U.textContent="\u{1F3A4}",oe?U.style.backgroundColor=oe:U.style.backgroundColor="",c!=null&&c.borderWidth&&(U.style.borderWidth=c.borderWidth,U.style.borderStyle="solid"),c!=null&&c.borderColor&&(U.style.borderColor=c.borderColor),c!=null&&c.paddingX&&(U.style.paddingLeft=c.paddingX,U.style.paddingRight=c.paddingX),c!=null&&c.paddingY&&(U.style.paddingTop=c.paddingY,U.style.paddingBottom=c.paddingY),_.appendChild(U);let dt=(Wt=c==null?void 0:c.tooltipText)!=null?Wt:"Start voice recognition";if(((D=c==null?void 0:c.showTooltip)!=null?D:!1)&&dt){let Ne=y("div","persona-send-button-tooltip");Ne.textContent=dt,_.appendChild(Ne)}return{micButton:U,micButtonWrapper:_}},ed=()=>{var g,b,A,H,_;if(!K||Ge)return;let c=(g=n.voiceRecognition)!=null?g:{};Ge={backgroundColor:K.style.backgroundColor,color:K.style.color,borderColor:K.style.borderColor,iconName:(b=c.iconName)!=null?b:"mic",iconSize:parseFloat((_=(H=c.iconSize)!=null?H:(A=n.sendButton)==null?void 0:A.size)!=null?_:"40")||24}},td=(c,g)=>{var _,U,$,O,Ce;if(!K)return;let b=K.querySelector("svg");b&&b.remove();let A=(Ce=Ge==null?void 0:Ge.iconSize)!=null?Ce:parseFloat((O=($=(_=n.voiceRecognition)==null?void 0:_.iconSize)!=null?$:(U=n.sendButton)==null?void 0:U.size)!=null?O:"40")||24,H=Me(c,A,g,1.5);H&&K.appendChild(H)},yi=()=>{K&&K.classList.remove("persona-voice-recording","persona-voice-processing","persona-voice-speaking")},hs=()=>{var H;if(!K)return;ed();let c=(H=n.voiceRecognition)!=null?H:{},g=c.recordingBackgroundColor,b=c.recordingIconColor,A=c.recordingBorderColor;if(yi(),K.classList.add("persona-voice-recording"),K.style.backgroundColor=g!=null?g:"var(--persona-voice-recording-bg, #ef4444)",K.style.color=b!=null?b:"var(--persona-voice-recording-indicator, #ffffff)",b){let _=K.querySelector("svg");_&&_.setAttribute("stroke",b)}A&&(K.style.borderColor=A),K.setAttribute("aria-label","Stop voice recognition")},Db=()=>{var $,O,Ce,me,oe,Te,Ve,Se;if(!K)return;ed();let c=($=n.voiceRecognition)!=null?$:{},g=q.getVoiceInterruptionMode(),b=(O=c.processingIconName)!=null?O:"loader",A=(me=(Ce=c.processingIconColor)!=null?Ce:Ge==null?void 0:Ge.color)!=null?me:"",H=(Te=(oe=c.processingBackgroundColor)!=null?oe:Ge==null?void 0:Ge.backgroundColor)!=null?Te:"",_=(Se=(Ve=c.processingBorderColor)!=null?Ve:Ge==null?void 0:Ge.borderColor)!=null?Se:"";yi(),K.classList.add("persona-voice-processing"),K.style.backgroundColor=H,K.style.borderColor=_;let U=A||"currentColor";K.style.color=U,td(b,U),K.setAttribute("aria-label","Processing voice input"),g==="none"&&(K.style.cursor="default")},Fb=()=>{var Ce,me,oe,Te,Ve,Se,dt,Qe,ht,xt,Be,Le;if(!K)return;ed();let c=(Ce=n.voiceRecognition)!=null?Ce:{},g=q.getVoiceInterruptionMode(),b=g==="cancel"?"square":g==="barge-in"?"mic":"volume-2",A=(me=c.speakingIconName)!=null?me:b,H=(Se=c.speakingIconColor)!=null?Se:g==="barge-in"?(Te=(oe=c.recordingIconColor)!=null?oe:Ge==null?void 0:Ge.color)!=null?Te:"":(Ve=Ge==null?void 0:Ge.color)!=null?Ve:"",_=(ht=c.speakingBackgroundColor)!=null?ht:g==="barge-in"?(dt=c.recordingBackgroundColor)!=null?dt:"var(--persona-voice-recording-bg, #ef4444)":(Qe=Ge==null?void 0:Ge.backgroundColor)!=null?Qe:"",U=(Le=c.speakingBorderColor)!=null?Le:g==="barge-in"?(xt=c.recordingBorderColor)!=null?xt:"":(Be=Ge==null?void 0:Ge.borderColor)!=null?Be:"";yi(),K.classList.add("persona-voice-speaking"),K.style.backgroundColor=_,K.style.borderColor=U;let $=H||"currentColor";K.style.color=$,td(A,$);let O=g==="cancel"?"Stop playback and re-record":g==="barge-in"?"Speak to interrupt":"Agent is speaking";K.setAttribute("aria-label",O),g==="none"&&(K.style.cursor="default"),g==="barge-in"&&K.classList.add("persona-voice-recording")},Ro=()=>{var c,g,b;K&&(yi(),Ge&&(K.style.backgroundColor=(c=Ge.backgroundColor)!=null?c:"",K.style.color=(g=Ge.color)!=null?g:"",K.style.borderColor=(b=Ge.borderColor)!=null?b:"",td(Ge.iconName,Ge.color||"currentColor"),Ge=null),K.style.cursor="",K.setAttribute("aria-label","Start voice recognition"))},vi=()=>{var c,g;if(((g=(c=n.voiceRecognition)==null?void 0:c.provider)==null?void 0:g.type)==="runtype"){let b=q.getVoiceStatus(),A=q.getVoiceInterruptionMode();if(A==="none"&&(b==="processing"||b==="speaking"))return;if(A==="cancel"&&(b==="processing"||b==="speaking")){q.stopVoicePlayback();return}if(q.isBargeInActive()){q.stopVoicePlayback(),q.deactivateBargeIn().then(()=>{Rt.active=!1,Rt.manuallyDeactivated=!0,an(),En("user"),Ro()});return}q.toggleVoice().then(()=>{Rt.active=q.isVoiceActive(),Rt.manuallyDeactivated=!q.isVoiceActive(),an(),En("user"),q.isVoiceActive()?hs():Ro()});return}if(gt){let b=ee.value.trim();Rt.manuallyDeactivated=!0,an(),tr("user"),b&&(ee.value="",ee.style.height="auto",q.sendMessage(b))}else Rt.manuallyDeactivated=!1,an(),Wr("user")};_r=vi,K&&(K.addEventListener("click",vi),kt.push(()=>{var c,g;((g=(c=n.voiceRecognition)==null?void 0:c.provider)==null?void 0:g.type)==="runtype"?(q.isVoiceActive()&&q.toggleVoice(),Ro()):tr("system"),K&&K.removeEventListener("click",vi)}));let Nb=a.on("assistant:complete",()=>{ns&&(Rt.active||Rt.manuallyDeactivated||ns==="assistant"&&!Rt.lastUserMessageWasVoice||setTimeout(()=>{var c,g;!Rt.active&&!Rt.manuallyDeactivated&&(((g=(c=n.voiceRecognition)==null?void 0:c.provider)==null?void 0:g.type)==="runtype"?q.toggleVoice().then(()=>{Rt.active=q.isVoiceActive(),En("auto"),q.isVoiceActive()&&hs()}):Wr("auto"))},600))});kt.push(Nb);let Ob=a.on("action:resubmit",()=>{setTimeout(()=>{q&&!q.isStreaming()&&q.continueConversation()},100)});kt.push(Ob);let Pa=()=>{Gt(!I,"user")},Cr=null,wr=null;if(M&&!W()){let c=o.find(g=>g.renderLauncher);if(c!=null&&c.renderLauncher){let g=c.renderLauncher({config:n,defaultRenderer:()=>Xs(n,Pa).element,onToggle:Pa});g&&(wr=g)}wr||(Cr=Xs(n,Pa))}Cr?r.appendChild(Cr.element):wr&&r.appendChild(wr),Po(),Mn.render(n.suggestionChips,q,ee,void 0,n.suggestionChipsConfig),gs(),Ea(q.isStreaming()),pt()==="follow"?Yn(!0):cs(),li(),k&&(!M||W()?setTimeout(()=>La(),0):I&&setTimeout(()=>La(),200));let xs=()=>{var O,Ce,me,oe,Te,Ve,Se,dt,Qe,ht,xt,Be,Le,Ke,rt,Wt,D,Ne,Ue,be,Yt,Kt;if(W()){Sr(),Po();return}let c=Rr(n),g=(Ce=(O=n.launcher)==null?void 0:O.sidebarMode)!=null?Ce:!1,b=c||g||((oe=(me=n.launcher)==null?void 0:me.fullHeight)!=null?oe:!1),A=(Te=r.ownerDocument.defaultView)!=null?Te:window,H=(Se=(Ve=n.launcher)==null?void 0:Ve.mobileFullscreen)!=null?Se:!0,_=(Qe=(dt=n.launcher)==null?void 0:dt.mobileBreakpoint)!=null?Qe:640,U=A.innerWidth<=_,$=H&&U&&M;try{if($){Nn(),Do(r,n);return}if(T&&(T=!1,Nn(),Do(r,n)),!M&&!c){he.style.height="",he.style.width="";return}if(!g&&!c){let cr=(xt=(ht=n==null?void 0:n.launcher)==null?void 0:ht.width)!=null?xt:n==null?void 0:n.launcherWidth,Bt=cr!=null?cr:Cn;he.style.width=Bt,he.style.maxWidth=Bt}if(Gn(),!b){let cr=A.innerHeight,Bt=64,lr=(Le=(Be=n.launcher)==null?void 0:Be.heightOffset)!=null?Le:0,hn=Math.max(200,cr-Bt),Tr=Math.min(640,hn),ot=Math.max(200,Tr-lr);he.style.height=`${ot}px`}}finally{if(Sr(),Po(),I&&M){let Bt=((Ke=r.ownerDocument.defaultView)!=null?Ke:window).innerWidth<=((Wt=(rt=n.launcher)==null?void 0:rt.mobileBreakpoint)!=null?Wt:640),lr=(Ne=(D=n.launcher)==null?void 0:D.sidebarMode)!=null?Ne:!1,hn=(be=(Ue=n.launcher)==null?void 0:Ue.mobileFullscreen)!=null?be:!0,Tr=Rr(n)&&hn&&Bt,ot=lr||hn&&Bt&&M||Tr;if(ot&&!vr){let Ut=r.getRootNode(),Er=Ut instanceof ShadowRoot?Ut.host:r.closest(".persona-host");Er&&!yr&&(yr=Wp(Er,(Kt=(Yt=n.launcher)==null?void 0:Yt.zIndex)!=null?Kt:Gr)),vr=Hp(r.ownerDocument)}else ot||(yr==null||yr(),yr=null,vr==null||vr(),vr=null)}}};xs();let vu=(Sf=r.ownerDocument.defaultView)!=null?Sf:window;if(vu.addEventListener("resize",xs),kt.push(()=>vu.removeEventListener("resize",xs)),typeof ResizeObserver!="undefined"){let c=new ResizeObserver(()=>{Sr()});c.observe(Oe),kt.push(()=>c.disconnect())}gn=ue.scrollTop;let Cu=xo(ue),_b=()=>{let c=ue.getRootNode(),g=typeof c.getSelection=="function"?c.getSelection():null;return g!=null?g:ue.ownerDocument.getSelection()},rd=()=>Qh(_b(),ue),wu=()=>{let c=ue.scrollTop,g=xo(ue),b=g<Cu;if(Cu=g,pt()!=="follow"){gn=c,sn();return}let{action:A,nextLastScrollTop:H}=bl({following:mn.isFollowing(),currentScrollTop:c,lastScrollTop:gn,nearBottom:ma(ue,Sa),userScrollThreshold:si,isAutoScrolling:Un||Vo||b,pauseOnUpwardScroll:!0,pauseWhenAwayFromBottom:!1,resumeRequiresDownwardScroll:!0});if(gn=H,A==="resume"){rd()||Jn();return}A==="pause"&&ka()};if(ue.addEventListener("scroll",wu,{passive:!0}),kt.push(()=>ue.removeEventListener("scroll",wu)),typeof ResizeObserver!="undefined"){let c=new ResizeObserver(()=>{ui()});c.observe(nt),c.observe(ue),kt.push(()=>c.disconnect())}let Au=()=>{pt()==="follow"&&mn.isFollowing()&&rd()&&ka()},Su=ue.ownerDocument;Su.addEventListener("selectionchange",Au),kt.push(()=>{Su.removeEventListener("selectionchange",Au)});let Tu=c=>{if(pt()!=="follow")return;let g=yl({following:mn.isFollowing(),deltaY:c.deltaY,nearBottom:ma(ue,Sa),resumeWhenNearBottom:!0});g==="pause"?ka():g==="resume"&&!rd()&&Jn()};ue.addEventListener("wheel",Tu,{passive:!0}),kt.push(()=>ue.removeEventListener("wheel",Tu)),et.addEventListener("click",()=>{Go(),ue.scrollTop=ue.scrollHeight,gn=ue.scrollTop,Jn(),Yn(!0),sn()}),kt.push(()=>et.remove()),kt.push(()=>{as(),Go()});let Mu=()=>{F&&(kn&&(F.removeEventListener("click",kn),kn=null),R()?(F.style.display="",kn=()=>{Gt(!1,"user")},F.addEventListener("click",kn)):F.style.display="none")};Mu(),(()=>{let{clearChatButton:c}=Pe;c&&c.addEventListener("click",()=>{q.clearMessages(),ao.clear(),Jn(),zo(Pe.composerOverlay);try{localStorage.removeItem(es),n.debug&&console.log(`[AgentWidget] Cleared default localStorage key: ${es}`)}catch(b){console.error("[AgentWidget] Failed to clear default localStorage:",b)}if(n.clearChatHistoryStorageKey&&n.clearChatHistoryStorageKey!==es)try{localStorage.removeItem(n.clearChatHistoryStorageKey),n.debug&&console.log(`[AgentWidget] Cleared custom localStorage key: ${n.clearChatHistoryStorageKey}`)}catch(b){console.error("[AgentWidget] Failed to clear custom localStorage:",b)}let g=new CustomEvent("persona:clear-chat",{detail:{timestamp:new Date().toISOString()}});if(window.dispatchEvent(g),i!=null&&i.clear)try{let b=i.clear();b instanceof Promise&&b.catch(A=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear storage adapter:",A)})}catch(b){typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear storage adapter:",b)}d={},S.syncFromMetadata(),ge==null||ge.clear(),Z==null||Z.reset(),G==null||G.update()})})(),Dt&&Dt.addEventListener("submit",z),ee==null||ee.addEventListener("keydown",lt),ee==null||ee.addEventListener("input",mt),ee==null||ee.addEventListener("paste",er);let ku=(Tf=r.ownerDocument)!=null?Tf:document;ku.addEventListener("keydown",zt,!0);let Eu="persona-attachment-drop-active",bs=0,nd=()=>{bs=0,j.classList.remove(Eu)},Ra=()=>{var c;return((c=n.attachments)==null?void 0:c.enabled)===!0&&Mt!==null},Lu=c=>{!Xl(c.dataTransfer)||!Ra()||(bs++,bs===1&&j.classList.add(Eu))},Pu=c=>{!Xl(c.dataTransfer)||!Ra()||(bs--,bs<=0&&nd())},Ru=c=>{!Xl(c.dataTransfer)||!Ra()||(c.preventDefault(),c.dataTransfer.dropEffect="copy")},Iu=c=>{var b;if(!Xl(c.dataTransfer)||!Ra())return;c.preventDefault(),c.stopPropagation(),nd();let g=Array.from((b=c.dataTransfer.files)!=null?b:[]);g.length!==0&&Mt.handleFiles(g)},Io=!0;j.addEventListener("dragenter",Lu,Io),j.addEventListener("dragleave",Pu,Io),r.addEventListener("dragover",Ru,Io),r.addEventListener("drop",Iu,Io);let Ci=r.ownerDocument,Wu=c=>{Ra()&&c.preventDefault()},Hu=c=>{Ra()&&c.preventDefault()};Ci.addEventListener("dragover",Wu),Ci.addEventListener("drop",Hu),kt.push(()=>{Dt&&Dt.removeEventListener("submit",z),ee==null||ee.removeEventListener("keydown",lt),ee==null||ee.removeEventListener("input",mt),ee==null||ee.removeEventListener("paste",er),ku.removeEventListener("keydown",zt,!0)}),kt.push(()=>{j.removeEventListener("dragenter",Lu,Io),j.removeEventListener("dragleave",Pu,Io),r.removeEventListener("dragover",Ru,Io),r.removeEventListener("drop",Iu,Io),Ci.removeEventListener("dragover",Wu),Ci.removeEventListener("drop",Hu),nd()}),kt.push(()=>{q.cancel()}),Cr?kt.push(()=>{Cr==null||Cr.destroy()}):wr&&kt.push(()=>{wr==null||wr.remove()});let kr={update(c){var Zn,Pr,Qr,In,Yo,Zo,wi,ys,If,Wf,Hf,Bf,Df,Ff,Nf,Of,_f,Uf,qf,zf,$f,Vf,jf,Gf,Kf,Xf,Qf,Jf,Yf,Zf,em,tm,rm,nm,om,am,sm,im,lm,dm,cm,pm,um,fm,mm,gm,hm,xm,bm,ym,vm,Cm,wm,Am,Sm,Tm,Mm,km,Em,Lm,Pm,Rm,Im,Wm,Hm,Bm,Dm,Fm,Nm,Om,_m,Um,qm,zm,$m,Vm,jm,Gm,Km,Xm,Qm,Jm,Ym,Zm,eg,tg,rg,ng,og,ag,sg,ig,lg,dg,cg,pg,ug,fg,mg,gg,hg,xg,bg,yg,vg,Cg,wg,Ag,Sg,Tg,Mg,kg,Eg,Lg,Pg;let g=n.toolCall,b=n.messageActions,A=(Zn=n.layout)==null?void 0:Zn.messages,H=n.colorScheme,_=n.loadingIndicator,U=n.iterationDisplay,$=(Pr=n.features)==null?void 0:Pr.showReasoning,O=(Qr=n.features)==null?void 0:Qr.showToolCalls,Ce=(In=n.features)==null?void 0:In.toolCallDisplay,me=(Yo=n.features)==null?void 0:Yo.reasoningDisplay;n={...n,...c},Nn(),Do(r,n),_l(r,n),Ul(r,n),un(),n.colorScheme!==H&&To();let oe=ti.getForInstance(n.plugins);o.length=0,o.push(...oe),M=(wi=(Zo=n.launcher)==null?void 0:Zo.enabled)!=null?wi:!0,E=(If=(ys=n.launcher)==null?void 0:ys.autoExpand)!=null?If:!1,Je=(Hf=(Wf=n.features)==null?void 0:Wf.showReasoning)!=null?Hf:!0,we=(Df=(Bf=n.features)==null?void 0:Bf.showToolCalls)!=null?Df:!0,Ae=(Nf=(Ff=n.features)==null?void 0:Ff.scrollToBottom)!=null?Nf:{};let Te=pt();qe=(_f=(Of=n.features)==null?void 0:Of.scrollBehavior)!=null?_f:{},Te!==pt()&&(Go(),Jn()),cn(),sn();let Ve=De;if(De=(qf=(Uf=n.features)==null?void 0:Uf.showEventStreamToggle)!=null?qf:!1,De&&!Ve){if(ge||(re=new Zs(J),ge=new Ys(Q,re),Z=Z!=null?Z:new ei,re.open().then(()=>ge==null?void 0:ge.restore()).catch(()=>{}),q.setSSEEventCallback((Y,Nt)=>{var rr;(rr=n.onSSEEvent)==null||rr.call(n,Y,Nt),Z==null||Z.processEvent(Y,Nt),ge.push({id:`evt-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,type:Y,timestamp:Date.now(),payload:JSON.stringify(Nt)})})),!Ct&&Fe){let Y=($f=(zf=n.features)==null?void 0:zf.eventStream)==null?void 0:$f.classNames,Nt="persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-opacity-80 persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-1"+(Y!=null&&Y.toggleButton?" "+Y.toggleButton:"");Ct=y("button",Nt),Ct.style.width="28px",Ct.style.height="28px",Ct.style.color=rn.actionIconColor,Ct.type="button",Ct.setAttribute("aria-label","Event Stream"),Ct.title="Event Stream";let rr=Me("activity","18px","currentColor",1.5);rr&&Ct.appendChild(rr);let vt=Pe.clearChatButtonWrapper,qt=Pe.closeButtonWrapper,Hr=vt||qt;Hr&&Hr.parentNode===Fe?Fe.insertBefore(Ct,Hr):Fe.appendChild(Ct),Ct.addEventListener("click",()=>{pe?on():An()})}}else!De&&Ve&&(on(),Ct&&(Ct.remove(),Ct=null),ge==null||ge.clear(),re==null||re.destroy(),ge=null,re=null,Z==null||Z.reset(),Z=null);if(((Vf=n.launcher)==null?void 0:Vf.enabled)===!1&&Cr&&(Cr.destroy(),Cr=null),((jf=n.launcher)==null?void 0:jf.enabled)===!1&&wr&&(wr.remove(),wr=null),((Gf=n.launcher)==null?void 0:Gf.enabled)!==!1&&!Cr&&!wr){let Y=o.find(Nt=>Nt.renderLauncher);if(Y!=null&&Y.renderLauncher){let Nt=Y.renderLauncher({config:n,defaultRenderer:()=>Xs(n,Pa).element,onToggle:Pa});Nt&&(wr=Nt,r.appendChild(wr))}wr||(Cr=Xs(n,Pa),r.appendChild(Cr.element))}Cr&&Cr.update(n),Re&&((Kf=n.launcher)==null?void 0:Kf.title)!==void 0&&(Re.textContent=n.launcher.title),Xe&&((Xf=n.launcher)==null?void 0:Xf.subtitle)!==void 0&&(Xe.textContent=n.launcher.subtitle);let Se=(Qf=n.layout)==null?void 0:Qf.header;if((Se==null?void 0:Se.layout)!==C&&Fe){let Y=Se?$a(n,Se,{showClose:R(),onClose:()=>Gt(!1,"user")}):bo({config:n,showClose:R(),onClose:()=>Gt(!1,"user")});Fe.replaceWith(Y.header),Fe=Y.header,fe=Y.iconHolder,Re=Y.headerTitle,Xe=Y.headerSubtitle,F=Y.closeButton,C=Se==null?void 0:Se.layout}else if(Se&&(fe&&(fe.style.display=Se.showIcon===!1?"none":""),Re&&(Re.style.display=Se.showTitle===!1?"none":""),Xe&&(Xe.style.display=Se.showSubtitle===!1?"none":""),F&&(F.style.display=Se.showCloseButton===!1?"none":""),Pe.clearChatButtonWrapper)){let Y=Se.showClearChat;if(Y!==void 0){Pe.clearChatButtonWrapper.style.display=Y?"":"none";let{closeButtonWrapper:Nt}=Pe;Nt&&!Nt.classList.contains("persona-absolute")&&(Y?Nt.classList.remove("persona-ml-auto"):Nt.classList.add("persona-ml-auto"))}}let Qe=((Jf=n.layout)==null?void 0:Jf.showHeader)!==!1;Fe&&(Fe.style.display=Qe?"":"none");let ht=((Yf=n.layout)==null?void 0:Yf.showFooter)!==!1;Oe&&(Oe.style.display=ht?"":"none"),Sr(),sn(),M!==w?M?Gt(E,"auto"):(I=!0,Po()):E!==h&&Gt(E,"auto"),h=E,w=M,xs(),Mu();let Le=JSON.stringify(c.toolCall)!==JSON.stringify(g),Ke=JSON.stringify(n.messageActions)!==JSON.stringify(b),rt=JSON.stringify((Zf=n.layout)==null?void 0:Zf.messages)!==JSON.stringify(A),Wt=((em=n.loadingIndicator)==null?void 0:em.render)!==(_==null?void 0:_.render)||((tm=n.loadingIndicator)==null?void 0:tm.renderIdle)!==(_==null?void 0:_.renderIdle)||((rm=n.loadingIndicator)==null?void 0:rm.showBubble)!==(_==null?void 0:_.showBubble),D=n.iterationDisplay!==U,Ne=((om=(nm=n.features)==null?void 0:nm.showReasoning)!=null?om:!0)!==($!=null?$:!0)||((sm=(am=n.features)==null?void 0:am.showToolCalls)!=null?sm:!0)!==(O!=null?O:!0)||JSON.stringify((im=n.features)==null?void 0:im.toolCallDisplay)!==JSON.stringify(Ce)||JSON.stringify((lm=n.features)==null?void 0:lm.reasoningDisplay)!==JSON.stringify(me);(Le||Ke||rt||Wt||D||Ne)&&q&&(rs++,Ko(nt,q.getMessages(),xe));let be=(dm=n.launcher)!=null?dm:{},Yt=(cm=be.headerIconHidden)!=null?cm:!1,Kt=(um=(pm=n.layout)==null?void 0:pm.header)==null?void 0:um.showIcon,cr=Yt||Kt===!1,Bt=be.headerIconName,lr=(fm=be.headerIconSize)!=null?fm:"48px";if(fe){let Y=j.querySelector(".persona-border-b-persona-divider"),Nt=Y==null?void 0:Y.querySelector(".persona-flex-col");if(cr)fe.style.display="none",Y&&Nt&&!Y.contains(Nt)&&Y.insertBefore(Nt,Y.firstChild);else{if(fe.style.display="",fe.style.height=lr,fe.style.width=lr,Y&&Nt&&(Y.contains(fe)?fe.nextSibling!==Nt&&(fe.remove(),Y.insertBefore(fe,Nt)):Y.insertBefore(fe,Nt)),Bt){let vt=parseFloat(lr)||24,qt=Me(Bt,vt*.6,"#ffffff",2);qt?fe.replaceChildren(qt):fe.textContent=(mm=be.agentIconText)!=null?mm:"\u{1F4AC}"}else if(be.iconUrl){let vt=fe.querySelector("img");if(vt)vt.src=be.iconUrl,vt.style.height=lr,vt.style.width=lr;else{let qt=document.createElement("img");qt.src=be.iconUrl,qt.alt="",qt.className="persona-rounded-xl persona-object-cover",qt.style.height=lr,qt.style.width=lr,fe.replaceChildren(qt)}}else{let vt=fe.querySelector("svg"),qt=fe.querySelector("img");(vt||qt)&&fe.replaceChildren(),fe.textContent=(gm=be.agentIconText)!=null?gm:"\u{1F4AC}"}let rr=fe.querySelector("img");rr&&(rr.style.height=lr,rr.style.width=lr)}}let hn=(xm=(hm=n.layout)==null?void 0:hm.header)==null?void 0:xm.showTitle,Tr=(ym=(bm=n.layout)==null?void 0:bm.header)==null?void 0:ym.showSubtitle;if(Re&&(Re.style.display=hn===!1?"none":""),Xe&&(Xe.style.display=Tr===!1?"none":""),F){((Cm=(vm=n.layout)==null?void 0:vm.header)==null?void 0:Cm.showCloseButton)===!1?F.style.display="none":F.style.display="";let Nt=(wm=be.closeButtonSize)!=null?wm:"32px",rr=(Am=be.closeButtonPlacement)!=null?Am:"inline";F.style.height=Nt,F.style.width=Nt;let{closeButtonWrapper:vt}=Pe,qt=rr==="top-right",Hr=vt==null?void 0:vt.classList.contains("persona-absolute");if(vt&&qt!==Hr)if(vt.remove(),qt)vt.className="persona-absolute persona-top-4 persona-right-4 persona-z-50",j.style.position="relative",j.appendChild(vt);else{let At=(Tm=(Sm=be.clearChat)==null?void 0:Sm.placement)!=null?Tm:"inline",Br=(km=(Mm=be.clearChat)==null?void 0:Mm.enabled)!=null?km:!0;vt.className=Br&&At==="inline"?"":"persona-ml-auto";let dn=j.querySelector(".persona-border-b-persona-divider");dn&&dn.appendChild(vt)}if(F.style.color=be.closeButtonColor||rn.actionIconColor,be.closeButtonBackgroundColor?(F.style.backgroundColor=be.closeButtonBackgroundColor,F.classList.remove("hover:persona-bg-gray-100")):(F.style.backgroundColor="",F.classList.add("hover:persona-bg-gray-100")),be.closeButtonBorderWidth||be.closeButtonBorderColor){let At=be.closeButtonBorderWidth||"0px",Br=be.closeButtonBorderColor||"transparent";F.style.border=`${At} solid ${Br}`,F.classList.remove("persona-border-none")}else F.style.border="",F.classList.add("persona-border-none");be.closeButtonBorderRadius?(F.style.borderRadius=be.closeButtonBorderRadius,F.classList.remove("persona-rounded-full")):(F.style.borderRadius="",F.classList.add("persona-rounded-full")),be.closeButtonPaddingX?(F.style.paddingLeft=be.closeButtonPaddingX,F.style.paddingRight=be.closeButtonPaddingX):(F.style.paddingLeft="",F.style.paddingRight=""),be.closeButtonPaddingY?(F.style.paddingTop=be.closeButtonPaddingY,F.style.paddingBottom=be.closeButtonPaddingY):(F.style.paddingTop="",F.style.paddingBottom="");let Vr=(Em=be.closeButtonIconName)!=null?Em:"x",zn=(Lm=be.closeButtonIconText)!=null?Lm:"\xD7";F.innerHTML="";let Jr=Me(Vr,"28px","currentColor",1);Jr?F.appendChild(Jr):F.textContent=zn;let Ar=(Pm=be.closeButtonTooltipText)!=null?Pm:"Close chat",bn=(Rm=be.closeButtonShowTooltip)!=null?Rm:!0;if(F.setAttribute("aria-label",Ar),vt&&(vt._cleanupTooltip&&(vt._cleanupTooltip(),delete vt._cleanupTooltip),bn&&Ar)){let At=null,Br=()=>{if(At||!F)return;let ea=F.ownerDocument,vs=ea.body;if(!vs)return;At=to(ea,"div","persona-clear-chat-tooltip"),At.textContent=Ar;let Cs=to(ea,"div");Cs.className="persona-clear-chat-tooltip-arrow",At.appendChild(Cs);let ta=F.getBoundingClientRect();At.style.position="fixed",At.style.zIndex=String(Fo),At.style.left=`${ta.left+ta.width/2}px`,At.style.top=`${ta.top-8}px`,At.style.transform="translate(-50%, -100%)",vs.appendChild(At)},dn=()=>{At&&At.parentNode&&(At.parentNode.removeChild(At),At=null)};vt.addEventListener("mouseenter",Br),vt.addEventListener("mouseleave",dn),F.addEventListener("focus",Br),F.addEventListener("blur",dn),vt._cleanupTooltip=()=>{dn(),vt&&(vt.removeEventListener("mouseenter",Br),vt.removeEventListener("mouseleave",dn)),F&&(F.removeEventListener("focus",Br),F.removeEventListener("blur",dn))}}}let{clearChatButton:ot,clearChatButtonWrapper:Ut}=Pe;if(ot){let Y=(Im=be.clearChat)!=null?Im:{},Nt=(Wm=Y.enabled)!=null?Wm:!0,rr=(Bm=(Hm=n.layout)==null?void 0:Hm.header)==null?void 0:Bm.showClearChat,vt=rr!==void 0?rr:Nt,qt=(Dm=Y.placement)!=null?Dm:"inline";if(Ut){Ut.style.display=vt?"":"none";let{closeButtonWrapper:Hr}=Pe;!W()&&Hr&&!Hr.classList.contains("persona-absolute")&&(vt?Hr.classList.remove("persona-ml-auto"):Hr.classList.add("persona-ml-auto"));let Vr=qt==="top-right",zn=Ut.classList.contains("persona-absolute");if(!W()&&Vr!==zn&&vt){if(Ut.remove(),Vr)Ut.className="persona-absolute persona-top-4 persona-z-50",Ut.style.right="48px",j.style.position="relative",j.appendChild(Ut);else{Ut.className="persona-relative persona-ml-auto persona-clear-chat-button-wrapper",Ut.style.right="";let Ar=j.querySelector(".persona-border-b-persona-divider"),bn=Pe.closeButtonWrapper;Ar&&bn&&bn.parentElement===Ar?Ar.insertBefore(Ut,bn):Ar&&Ar.appendChild(Ut)}let Jr=Pe.closeButtonWrapper;Jr&&!Jr.classList.contains("persona-absolute")&&(Vr?Jr.classList.add("persona-ml-auto"):Jr.classList.remove("persona-ml-auto"))}}if(vt){if(!W()){let At=(Fm=Y.size)!=null?Fm:"32px";ot.style.height=At,ot.style.width=At}let Hr=(Nm=Y.iconName)!=null?Nm:"refresh-cw",Vr=(Om=Y.iconColor)!=null?Om:"";ot.style.color=Vr||rn.actionIconColor,ot.innerHTML="";let zn=W()?"14px":"20px",Jr=Me(Hr,zn,"currentColor",2);if(Jr&&ot.appendChild(Jr),Y.backgroundColor?(ot.style.backgroundColor=Y.backgroundColor,ot.classList.remove("hover:persona-bg-gray-100")):(ot.style.backgroundColor="",ot.classList.add("hover:persona-bg-gray-100")),Y.borderWidth||Y.borderColor){let At=Y.borderWidth||"0px",Br=Y.borderColor||"transparent";ot.style.border=`${At} solid ${Br}`,ot.classList.remove("persona-border-none")}else ot.style.border="",ot.classList.add("persona-border-none");Y.borderRadius?(ot.style.borderRadius=Y.borderRadius,ot.classList.remove("persona-rounded-full")):(ot.style.borderRadius="",ot.classList.add("persona-rounded-full")),Y.paddingX?(ot.style.paddingLeft=Y.paddingX,ot.style.paddingRight=Y.paddingX):(ot.style.paddingLeft="",ot.style.paddingRight=""),Y.paddingY?(ot.style.paddingTop=Y.paddingY,ot.style.paddingBottom=Y.paddingY):(ot.style.paddingTop="",ot.style.paddingBottom="");let Ar=(_m=Y.tooltipText)!=null?_m:"Clear chat",bn=(Um=Y.showTooltip)!=null?Um:!0;if(ot.setAttribute("aria-label",Ar),Ut&&(Ut._cleanupTooltip&&(Ut._cleanupTooltip(),delete Ut._cleanupTooltip),bn&&Ar)){let At=null,Br=()=>{if(At||!ot)return;let ea=ot.ownerDocument,vs=ea.body;if(!vs)return;At=to(ea,"div","persona-clear-chat-tooltip"),At.textContent=Ar;let Cs=to(ea,"div");Cs.className="persona-clear-chat-tooltip-arrow",At.appendChild(Cs);let ta=ot.getBoundingClientRect();At.style.position="fixed",At.style.zIndex=String(Fo),At.style.left=`${ta.left+ta.width/2}px`,At.style.top=`${ta.top-8}px`,At.style.transform="translate(-50%, -100%)",vs.appendChild(At)},dn=()=>{At&&At.parentNode&&(At.parentNode.removeChild(At),At=null)};Ut.addEventListener("mouseenter",Br),Ut.addEventListener("mouseleave",dn),ot.addEventListener("focus",Br),ot.addEventListener("blur",dn),Ut._cleanupTooltip=()=>{dn(),Ut&&(Ut.removeEventListener("mouseenter",Br),Ut.removeEventListener("mouseleave",dn)),ot&&(ot.removeEventListener("focus",Br),ot.removeEventListener("blur",dn))}}}}let Er=n.actionParsers&&n.actionParsers.length?n.actionParsers:[ri],Rn=n.actionHandlers&&n.actionHandlers.length?n.actionHandlers:[va.message,va.messageAndClick];S=ni({parsers:Er,handlers:Rn,getSessionMetadata:u,updateSessionMetadata:m,emit:a.emit,documentRef:typeof document!="undefined"?document:null}),xe=Xx(n,S,ie),q.updateConfig(n),Ko(nt,q.getMessages(),xe),Mn.render(n.suggestionChips,q,ee,void 0,n.suggestionChipsConfig),gs(),Ea(q.isStreaming());let xn=((qm=n.voiceRecognition)==null?void 0:qm.enabled)===!0,Xo=typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined"),Qo=(($m=(zm=n.voiceRecognition)==null?void 0:zm.provider)==null?void 0:$m.type)==="runtype";if(xn&&(Xo||Qo))if(!K||!ft){let Y=qn(n.voiceRecognition,n.sendButton);Y&&(K=Y.micButton,ft=Y.micButtonWrapper,Qt.insertBefore(ft,Fr),K.addEventListener("click",vi),K.disabled=q.isStreaming())}else{let Y=(Vm=n.voiceRecognition)!=null?Vm:{},Nt=(jm=n.sendButton)!=null?jm:{},rr=(Gm=Y.iconName)!=null?Gm:"mic",vt=(Km=Nt.size)!=null?Km:"40px",qt=(Xm=Y.iconSize)!=null?Xm:vt,Hr=parseFloat(qt)||24;K.style.width=qt,K.style.height=qt,K.style.minWidth=qt,K.style.minHeight=qt;let Vr=(Jm=(Qm=Y.iconColor)!=null?Qm:Nt.textColor)!=null?Jm:"currentColor";K.innerHTML="";let zn=Me(rr,Hr,Vr,2);zn?K.appendChild(zn):K.textContent="\u{1F3A4}";let Jr=(Ym=Y.backgroundColor)!=null?Ym:Nt.backgroundColor;Jr?K.style.backgroundColor=Jr:K.style.backgroundColor="",Vr?K.style.color=Vr:K.style.color="var(--persona-text, #111827)",Y.borderWidth?(K.style.borderWidth=Y.borderWidth,K.style.borderStyle="solid"):(K.style.borderWidth="",K.style.borderStyle=""),Y.borderColor?K.style.borderColor=Y.borderColor:K.style.borderColor="",Y.paddingX?(K.style.paddingLeft=Y.paddingX,K.style.paddingRight=Y.paddingX):(K.style.paddingLeft="",K.style.paddingRight=""),Y.paddingY?(K.style.paddingTop=Y.paddingY,K.style.paddingBottom=Y.paddingY):(K.style.paddingTop="",K.style.paddingBottom="");let Ar=ft==null?void 0:ft.querySelector(".persona-send-button-tooltip"),bn=(Zm=Y.tooltipText)!=null?Zm:"Start voice recognition";if(((eg=Y.showTooltip)!=null?eg:!1)&&bn)if(Ar)Ar.textContent=bn,Ar.style.display="";else{let Br=document.createElement("div");Br.className="persona-send-button-tooltip",Br.textContent=bn,ft==null||ft.insertBefore(Br,K)}else Ar&&(Ar.style.display="none");ft.style.display="",K.disabled=q.isStreaming()}else K&&ft&&(ft.style.display="none",((rg=(tg=n.voiceRecognition)==null?void 0:tg.provider)==null?void 0:rg.type)==="runtype"?q.isVoiceActive()&&q.toggleVoice():gt&&tr());if(((ng=n.attachments)==null?void 0:ng.enabled)===!0)if(!ye||!it){let Y=(og=n.attachments)!=null?og:{},rr=(sg=((ag=n.sendButton)!=null?ag:{}).size)!=null?sg:"40px";st||(st=y("div","persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2"),st.style.display="none",Dt.insertBefore(st,ee)),se||(se=document.createElement("input"),se.type="file",se.accept=((ig=Y.allowedTypes)!=null?ig:ho).join(","),se.multiple=((lg=Y.maxFiles)!=null?lg:4)>1,se.style.display="none",se.setAttribute("aria-label","Attach files"),Dt.insertBefore(se,ee)),ye=y("div","persona-send-button-wrapper"),it=y("button","persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-attachment-button"),it.type="button",it.setAttribute("aria-label",(dg=Y.buttonTooltipText)!=null?dg:"Attach file");let vt=(cg=Y.buttonIconName)!=null?cg:"paperclip",qt=rr,Hr=parseFloat(qt)||40,Vr=Math.round(Hr*.6);it.style.width=qt,it.style.height=qt,it.style.minWidth=qt,it.style.minHeight=qt,it.style.fontSize="18px",it.style.lineHeight="1",it.style.backgroundColor="transparent",it.style.color="var(--persona-primary, #111827)",it.style.border="none",it.style.borderRadius="6px",it.style.transition="background-color 0.15s ease",it.addEventListener("mouseenter",()=>{it.style.backgroundColor="var(--persona-palette-colors-black-alpha-50, rgba(0, 0, 0, 0.05))"}),it.addEventListener("mouseleave",()=>{it.style.backgroundColor="transparent"});let zn=Me(vt,Vr,"currentColor",1.5);zn?it.appendChild(zn):it.textContent="\u{1F4CE}",it.addEventListener("click",bn=>{bn.preventDefault(),se==null||se.click()}),ye.appendChild(it);let Jr=(pg=Y.buttonTooltipText)!=null?pg:"Attach file",Ar=y("div","persona-send-button-tooltip");Ar.textContent=Jr,ye.appendChild(Ar),Tt.append(ye),!Mt&&se&&st&&(Mt=fa.fromConfig(Y),Mt.setPreviewsContainer(st),se.addEventListener("change",async()=>{Mt&&(se!=null&&se.files)&&(await Mt.handleFileSelect(se.files),se.value="")})),j.querySelector(".persona-attachment-drop-overlay")||j.appendChild(Qx(Y.dropOverlay))}else{ye.style.display="";let Y=(ug=n.attachments)!=null?ug:{};se&&(se.accept=((fg=Y.allowedTypes)!=null?fg:ho).join(","),se.multiple=((mg=Y.maxFiles)!=null?mg:4)>1),Mt&&Mt.updateConfig({allowedTypes:Y.allowedTypes,maxFileSize:Y.maxFileSize,maxFiles:Y.maxFiles})}else ye&&(ye.style.display="none"),Mt&&Mt.clearAttachments(),(gg=j.querySelector(".persona-attachment-drop-overlay"))==null||gg.remove();let mr=(hg=n.sendButton)!=null?hg:{},Jo=(xg=mr.useIcon)!=null?xg:!1,Wo=(bg=mr.iconText)!=null?bg:"\u2191",Ho=mr.iconName,po=(yg=mr.tooltipText)!=null?yg:"Send message",ut=(vg=mr.showTooltip)!=null?vg:!1,Nr=(Cg=mr.size)!=null?Cg:"40px",Xr=mr.backgroundColor,Mr=mr.textColor;if(Jo){if(je.style.width=Nr,je.style.height=Nr,je.style.minWidth=Nr,je.style.minHeight=Nr,je.style.fontSize="18px",je.style.lineHeight="1",je.innerHTML="",Mr?je.style.color=Mr:je.style.color="var(--persona-button-primary-fg, #ffffff)",Ho){let Y=parseFloat(Nr)||24,Nt=(Mr==null?void 0:Mr.trim())||"currentColor",rr=Me(Ho,Y,Nt,2);rr?je.appendChild(rr):je.textContent=Wo}else je.textContent=Wo;je.className="persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer",Xr?(je.style.backgroundColor=Xr,je.classList.remove("persona-bg-persona-primary")):(je.style.backgroundColor="",je.classList.add("persona-bg-persona-primary"))}else je.textContent=(Ag=(wg=n.copy)==null?void 0:wg.sendButtonLabel)!=null?Ag:"Send",je.style.width="",je.style.height="",je.style.minWidth="",je.style.minHeight="",je.style.fontSize="",je.style.lineHeight="",je.className="persona-rounded-button persona-bg-persona-accent persona-px-4 persona-py-2 persona-text-sm persona-font-semibold persona-text-white disabled:persona-opacity-50 persona-cursor-pointer",Xr?(je.style.backgroundColor=Xr,je.classList.remove("persona-bg-persona-accent")):je.classList.add("persona-bg-persona-accent"),Mr?je.style.color=Mr:je.classList.add("persona-text-white");mr.borderWidth?(je.style.borderWidth=mr.borderWidth,je.style.borderStyle="solid"):(je.style.borderWidth="",je.style.borderStyle=""),mr.borderColor?je.style.borderColor=mr.borderColor:je.style.borderColor="",mr.paddingX?(je.style.paddingLeft=mr.paddingX,je.style.paddingRight=mr.paddingX):(je.style.paddingLeft="",je.style.paddingRight=""),mr.paddingY?(je.style.paddingTop=mr.paddingY,je.style.paddingBottom=mr.paddingY):(je.style.paddingTop="",je.style.paddingBottom="");let bt=Fr==null?void 0:Fr.querySelector(".persona-send-button-tooltip");if(ut&&po)if(bt)bt.textContent=po,bt.style.display="";else{let Y=document.createElement("div");Y.className="persona-send-button-tooltip",Y.textContent=po,Fr==null||Fr.insertBefore(Y,je)}else bt&&(bt.style.display="none");let Et=(Eg=(Sg=n.layout)==null?void 0:Sg.contentMaxWidth)!=null?Eg:W()?(kg=(Mg=(Tg=n.launcher)==null?void 0:Tg.composerBar)==null?void 0:Mg.contentMaxWidth)!=null?kg:"720px":void 0;Et?(nt.style.maxWidth=Et,nt.style.marginLeft="auto",nt.style.marginRight="auto",nt.style.width="100%",Dt&&(Dt.style.maxWidth=Et,Dt.style.marginLeft="auto",Dt.style.marginRight="auto"),It&&(It.style.maxWidth=Et,It.style.marginLeft="auto",It.style.marginRight="auto")):(nt.style.maxWidth="",nt.style.marginLeft="",nt.style.marginRight="",nt.style.width="",Dt&&(Dt.style.maxWidth="",Dt.style.marginLeft="",Dt.style.marginRight=""),It&&(It.style.maxWidth="",It.style.marginLeft="",It.style.marginRight=""));let yt=(Lg=n.statusIndicator)!=null?Lg:{},ln=(Pg=yt.visible)!=null?Pg:!0;if(ar.style.display=ln?"":"none",q){let Y=q.getStatus();St(ar,(rr=>{var vt,qt,Hr,Vr;return rr==="idle"?(vt=yt.idleText)!=null?vt:jr.idle:rr==="connecting"?(qt=yt.connectingText)!=null?qt:jr.connecting:rr==="connected"?(Hr=yt.connectedText)!=null?Hr:jr.connected:rr==="error"?(Vr=yt.errorText)!=null?Vr:jr.error:jr[rr]})(Y),yt,Y)}ar.classList.remove("persona-text-left","persona-text-center","persona-text-right");let Lr=yt.align==="left"?"persona-text-left":yt.align==="center"?"persona-text-center":"persona-text-right";ar.classList.add(Lr)},open(){R()&&Gt(!0,"api")},close(){R()&&Gt(!1,"api")},toggle(){R()&&Gt(!I,"api")},clearChat(){dr=!1,q.clearMessages(),ao.clear(),Jn();try{localStorage.removeItem(es),n.debug&&console.log(`[AgentWidget] Cleared default localStorage key: ${es}`)}catch(g){console.error("[AgentWidget] Failed to clear default localStorage:",g)}if(n.clearChatHistoryStorageKey&&n.clearChatHistoryStorageKey!==es)try{localStorage.removeItem(n.clearChatHistoryStorageKey),n.debug&&console.log(`[AgentWidget] Cleared custom localStorage key: ${n.clearChatHistoryStorageKey}`)}catch(g){console.error("[AgentWidget] Failed to clear custom localStorage:",g)}let c=new CustomEvent("persona:clear-chat",{detail:{timestamp:new Date().toISOString()}});if(window.dispatchEvent(c),i!=null&&i.clear)try{let g=i.clear();g instanceof Promise&&g.catch(b=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear storage adapter:",b)})}catch(g){typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear storage adapter:",g)}d={},S.syncFromMetadata(),ge==null||ge.clear(),Z==null||Z.reset(),G==null||G.update()},setMessage(c){return!ee||q.isStreaming()?!1:(!I&&R()&&Gt(!0,"system"),ee.value=c,ee.dispatchEvent(new Event("input",{bubbles:!0})),!0)},submitMessage(c){if(q.isStreaming())return!1;let g=(c==null?void 0:c.trim())||ee.value.trim();return g?(!I&&R()&&Gt(!0,"system"),ee.value="",ee.style.height="auto",q.sendMessage(g),!0):!1},startVoiceRecognition(){var g,b;return q.isStreaming()?!1:((b=(g=n.voiceRecognition)==null?void 0:g.provider)==null?void 0:b.type)==="runtype"?(q.isVoiceActive()||(!I&&R()&&Gt(!0,"system"),Rt.manuallyDeactivated=!1,an(),q.toggleVoice().then(()=>{Rt.active=q.isVoiceActive(),En("user"),q.isVoiceActive()&&hs()})),!0):gt?!0:$r()?(!I&&R()&&Gt(!0,"system"),Rt.manuallyDeactivated=!1,an(),Wr("user"),!0):!1},stopVoiceRecognition(){var c,g;return((g=(c=n.voiceRecognition)==null?void 0:c.provider)==null?void 0:g.type)==="runtype"?q.isVoiceActive()?(q.toggleVoice().then(()=>{Rt.active=!1,Rt.manuallyDeactivated=!0,an(),En("user"),Ro()}),!0):!1:gt?(Rt.manuallyDeactivated=!0,an(),tr("user"),!0):!1},injectMessage(c){return!I&&R()&&Gt(!0,"system"),q.injectMessage(c)},injectAssistantMessage(c){!I&&R()&&Gt(!0,"system");let g=q.injectAssistantMessage(c);return N&&(N=!1,V&&(clearTimeout(V),V=null),setTimeout(()=>{q&&!q.isStreaming()&&q.continueConversation()},100)),g},injectUserMessage(c){return!I&&R()&&Gt(!0,"system"),q.injectUserMessage(c)},injectSystemMessage(c){return!I&&R()&&Gt(!0,"system"),q.injectSystemMessage(c)},injectMessageBatch(c){return!I&&R()&&Gt(!0,"system"),q.injectMessageBatch(c)},injectComponentDirective(c){return!I&&R()&&Gt(!0,"system"),q.injectComponentDirective(c)},injectTestMessage(c){!I&&R()&&Gt(!0,"system"),q.injectTestEvent(c)},async connectStream(c,g){return q.connectStream(c,g)},__pushEventStreamEvent(c){ge&&(Z==null||Z.processEvent(c.type,c.payload),ge.push({id:`evt-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,type:c.type,timestamp:Date.now(),payload:JSON.stringify(c.payload)}))},showEventStream(){!De||!ge||An()},hideEventStream(){pe&&on()},isEventStreamVisible(){return pe},showArtifacts(){Dn(n)&&(dr=!1,un(),Ze==null||Ze.setMobileOpen(!0))},hideArtifacts(){Dn(n)&&(dr=!0,un())},upsertArtifact(c){return Dn(n)?(dr=!1,q.upsertArtifact(c)):null},selectArtifact(c){Dn(n)&&q.selectArtifact(c)},clearArtifacts(){Dn(n)&&q.clearArtifacts()},getArtifacts(){var c;return(c=q==null?void 0:q.getArtifacts())!=null?c:[]},getSelectedArtifactId(){var c;return(c=q==null?void 0:q.getSelectedArtifactId())!=null?c:null},focusInput(){return M&&!I&&!W()||!ee?!1:(ee.focus(),!0)},async resolveApproval(c,g,b){let H=q.getMessages().find(_=>{var U;return _.variant==="approval"&&((U=_.approval)==null?void 0:U.id)===c});if(!(H!=null&&H.approval))throw new Error(`Approval not found: ${c}`);if(H.approval.toolType==="webmcp"){q.resolveWebMcpApproval(H.id,g);return}return q.resolveApproval(H.approval,g,b)},getMessages(){return q.getMessages()},getStatus(){return q.getStatus()},getPersistentMetadata(){return{...d}},updatePersistentMetadata(c){m(c)},on(c,g){return a.on(c,g)},off(c,g){a.off(c,g)},isOpen(){return R()&&I},isVoiceActive(){return Rt.active},getState(){return{open:R()&&I,launcherEnabled:M,voiceActive:Rt.active,streaming:q.isStreaming()}},showCSATFeedback(c){!I&&R()&&Gt(!0,"system");let g=nt.querySelector(".persona-feedback-container");g&&g.remove();let b=Gl({onSubmit:async(A,H)=>{var _;q.isClientTokenMode()&&await q.submitCSATFeedback(A,H),(_=c==null?void 0:c.onSubmit)==null||_.call(c,A,H)},onDismiss:c==null?void 0:c.onDismiss,...c});nt.appendChild(b),b.scrollIntoView({behavior:"smooth",block:"end"})},showNPSFeedback(c){!I&&R()&&Gt(!0,"system");let g=nt.querySelector(".persona-feedback-container");g&&g.remove();let b=Kl({onSubmit:async(A,H)=>{var _;q.isClientTokenMode()&&await q.submitNPSFeedback(A,H),(_=c==null?void 0:c.onSubmit)==null||_.call(c,A,H)},onDismiss:c==null?void 0:c.onDismiss,...c});nt.appendChild(b),b.scrollIntoView({behavior:"smooth",block:"end"})},async submitCSATFeedback(c,g){return q.submitCSATFeedback(c,g)},async submitNPSFeedback(c,g){return q.submitNPSFeedback(c,g)},destroy(){Ln!=null&&(clearInterval(Ln),Ln=null),kt.forEach(c=>c()),We.remove(),at==null||at.remove(),Cr==null||Cr.destroy(),wr==null||wr.remove(),kn&&F.removeEventListener("click",kn)}};if((((Mf=t==null?void 0:t.debugTools)!=null?Mf:!1)||!!n.debug)&&typeof window!="undefined"){let c=window.AgentWidgetBrowser,g={controller:kr,getMessages:kr.getMessages,getStatus:kr.getStatus,getMetadata:kr.getPersistentMetadata,updateMetadata:kr.updatePersistentMetadata,clearHistory:()=>kr.clearChat(),setVoiceActive:b=>b?kr.startVoiceRecognition():kr.stopVoiceRecognition()};window.AgentWidgetBrowser=g,kt.push(()=>{window.AgentWidgetBrowser===g&&(window.AgentWidgetBrowser=c)})}if(typeof window!="undefined"){let c=r.getAttribute("data-persona-instance")||r.id||"persona-"+Math.random().toString(36).slice(2,8),g=$=>{let O=$.detail;(!(O!=null&&O.instanceId)||O.instanceId===c)&&kr.focusInput()};if(window.addEventListener("persona:focusInput",g),kt.push(()=>{window.removeEventListener("persona:focusInput",g)}),De){let $=Ce=>{let me=Ce.detail;(!(me!=null&&me.instanceId)||me.instanceId===c)&&kr.showEventStream()},O=Ce=>{let me=Ce.detail;(!(me!=null&&me.instanceId)||me.instanceId===c)&&kr.hideEventStream()};window.addEventListener("persona:showEventStream",$),window.addEventListener("persona:hideEventStream",O),kt.push(()=>{window.removeEventListener("persona:showEventStream",$),window.removeEventListener("persona:hideEventStream",O)})}let b=$=>{let O=$.detail;(!(O!=null&&O.instanceId)||O.instanceId===c)&&kr.showArtifacts()},A=$=>{let O=$.detail;(!(O!=null&&O.instanceId)||O.instanceId===c)&&kr.hideArtifacts()},H=$=>{let O=$.detail;O!=null&&O.instanceId&&O.instanceId!==c||O!=null&&O.artifact&&kr.upsertArtifact(O.artifact)},_=$=>{let O=$.detail;O!=null&&O.instanceId&&O.instanceId!==c||typeof(O==null?void 0:O.id)=="string"&&kr.selectArtifact(O.id)},U=$=>{let O=$.detail;(!(O!=null&&O.instanceId)||O.instanceId===c)&&kr.clearArtifacts()};window.addEventListener("persona:showArtifacts",b),window.addEventListener("persona:hideArtifacts",A),window.addEventListener("persona:upsertArtifact",H),window.addEventListener("persona:selectArtifact",_),window.addEventListener("persona:clearArtifacts",U),kt.push(()=>{window.removeEventListener("persona:showArtifacts",b),window.removeEventListener("persona:hideArtifacts",A),window.removeEventListener("persona:upsertArtifact",H),window.removeEventListener("persona:selectArtifact",_),window.removeEventListener("persona:clearArtifacts",U)})}let Pn=yC(n.persistState);if(Pn&&R()){let c=vC(Pn.storage),g=`${Pn.keyPrefix}widget-open`,b=`${Pn.keyPrefix}widget-voice`,A=`${Pn.keyPrefix}widget-voice-mode`;if(c){let H=((kf=Pn.persist)==null?void 0:kf.openState)&&c.getItem(g)==="true",_=((Ef=Pn.persist)==null?void 0:Ef.voiceState)&&c.getItem(b)==="true",U=((Lf=Pn.persist)==null?void 0:Lf.voiceState)&&c.getItem(A)==="true";if(H&&setTimeout(()=>{kr.open(),setTimeout(()=>{var $;if(_||U)kr.startVoiceRecognition();else if(($=Pn.persist)!=null&&$.focusInput){let O=r.querySelector("textarea");O&&O.focus()}},100)},0),(Pf=Pn.persist)!=null&&Pf.openState&&(a.on("widget:opened",()=>{c.setItem(g,"true")}),a.on("widget:closed",()=>{c.setItem(g,"false")})),(Rf=Pn.persist)!=null&&Rf.voiceState&&(a.on("voice:state",$=>{c.setItem(b,$.active?"true":"false")}),a.on("user:message",$=>{c.setItem(A,$.viaVoice?"true":"false")})),Pn.clearOnChatClear){let $=()=>{c.removeItem(g),c.removeItem(b),c.removeItem(A)},O=()=>$();window.addEventListener("persona:clear-chat",O),kt.push(()=>{window.removeEventListener("persona:clear-chat",O)})}}}return p&&R()&&setTimeout(()=>{kr.open()},0),co(),kr};var CC=(r,e)=>{let t=r.trim(),n=/^(\d+(?:\.\d+)?)px$/i.exec(t);if(n)return Math.max(0,parseFloat(n[1]));let o=/^(\d+(?:\.\d+)?)%$/i.exec(t);return o?Math.max(0,e*parseFloat(o[1])/100):420},Jx=(r,e)=>{var n,o;let t=(o=(n=e==null?void 0:e.launcher)==null?void 0:n.enabled)!=null?o:!0;r.className="persona-host",r.style.height=t?"":"100%",r.style.display=t?"":"flex",r.style.flexDirection=t?"":"column",r.style.flex=t?"":"1 1 auto",r.style.minHeight=t?"":"0"},iu=r=>{r.style.position="",r.style.top="",r.style.bottom="",r.style.left="",r.style.right="",r.style.zIndex="",r.style.transform="",r.style.pointerEvents=""},Yx=r=>{r.style.inset="",r.style.width="",r.style.height="",r.style.maxWidth="",r.style.minWidth="",iu(r)},ou=r=>{r.style.transition=""},au=r=>{r.style.display="",r.style.flexDirection="",r.style.flex="",r.style.minHeight="",r.style.minWidth="",r.style.width="",r.style.height="",r.style.alignItems="",r.style.transition="",r.style.transform=""},su=r=>{r.style.width="",r.style.maxWidth="",r.style.minWidth="",r.style.flex="1 1 auto"},Jl=(r,e)=>{r.style.width="",r.style.minWidth="",r.style.maxWidth="",r.style.boxSizing="",e.style.alignItems=""},wC=(r,e,t,n,o)=>{o?t.parentElement!==e&&(r.replaceChildren(),e.replaceChildren(t,n),r.appendChild(e)):t.parentElement===e&&(e.replaceChildren(),r.appendChild(t),r.appendChild(n))},AC=(r,e,t,n,o,a)=>{let s=a?e:r;o==="left"?s.firstElementChild!==n&&s.replaceChildren(n,t):s.lastElementChild!==n&&s.replaceChildren(t,n)},Zx=(r,e,t,n,o,a,s)=>{var v,x,S,M,E,k;let i=Hn(a),d=i.reveal==="push";wC(r,e,t,n,d),AC(r,e,t,n,i.side,d),r.dataset.personaHostLayout="docked",r.dataset.personaDockSide=i.side,r.dataset.personaDockOpen=s?"true":"false",r.style.width="100%",r.style.maxWidth="100%",r.style.minWidth="0",r.style.height="100%",r.style.minHeight="0",r.style.position="relative",t.style.display="flex",t.style.flexDirection="column",t.style.minHeight="0",t.style.position="relative",o.className="persona-host",o.style.height="100%",o.style.minHeight="0",o.style.display="flex",o.style.flexDirection="column",o.style.flex="1 1 auto";let l=r.ownerDocument.defaultView,p=(x=(v=a==null?void 0:a.launcher)==null?void 0:v.mobileFullscreen)!=null?x:!0,f=(M=(S=a==null?void 0:a.launcher)==null?void 0:S.mobileBreakpoint)!=null?M:640,u=l!=null?l.innerWidth<=f:!1;if(p&&u&&s){r.dataset.personaDockMobileFullscreen="true",r.removeAttribute("data-persona-dock-reveal"),au(e),ou(n),Yx(n),su(t),Jl(o,n),r.style.display="flex",r.style.flexDirection="column",r.style.alignItems="stretch",r.style.overflow="hidden",t.style.flex="1 1 auto",t.style.width="100%",t.style.minWidth="0",n.style.display="flex",n.style.flexDirection="column",n.style.position="fixed",n.style.inset="0",n.style.width="100%",n.style.height="100%",n.style.maxWidth="100%",n.style.minWidth="0",n.style.minHeight="0",n.style.overflow="hidden",n.style.zIndex=String((k=(E=a==null?void 0:a.launcher)==null?void 0:E.zIndex)!=null?k:Gr),n.style.transform="none",n.style.transition="none",n.style.pointerEvents="auto",n.style.flex="none",d&&(e.style.display="flex",e.style.flexDirection="column",e.style.width="100%",e.style.height="100%",e.style.minHeight="0",e.style.minWidth="0",e.style.flex="1 1 auto",e.style.alignItems="stretch",e.style.transform="none",e.style.transition="none",t.style.flex="1 1 auto",t.style.width="100%",t.style.maxWidth="100%",t.style.minWidth="0");return}if(r.removeAttribute("data-persona-dock-mobile-fullscreen"),Yx(n),i.reveal==="overlay"){r.style.display="flex",r.style.flexDirection="row",r.style.alignItems="stretch",r.style.overflow="hidden",r.dataset.personaDockReveal="overlay",au(e),ou(n),su(t),Jl(o,n);let h=i.animate?"transform 180ms ease":"none",w=i.side==="right"?"translateX(100%)":"translateX(-100%)",C=s?"translateX(0)":w;n.style.display="flex",n.style.flexDirection="column",n.style.flex="none",n.style.position="absolute",n.style.top="0",n.style.bottom="0",n.style.width=i.width,n.style.maxWidth=i.width,n.style.minWidth=i.width,n.style.minHeight="0",n.style.overflow="hidden",n.style.transition=h,n.style.transform=C,n.style.pointerEvents=s?"auto":"none",n.style.zIndex="2",i.side==="right"?(n.style.right="0",n.style.left=""):(n.style.left="0",n.style.right="")}else if(i.reveal==="push"){r.style.display="flex",r.style.flexDirection="row",r.style.alignItems="stretch",r.style.overflow="hidden",r.dataset.personaDockReveal="push",ou(n),iu(n),Jl(o,n);let h=CC(i.width,r.clientWidth),w=Math.max(0,r.clientWidth),C=i.animate?"transform 180ms ease":"none",T=i.side==="right"?s?`translateX(-${h}px)`:"translateX(0)":s?"translateX(0)":`translateX(-${h}px)`;e.style.display="flex",e.style.flexDirection="row",e.style.flex="0 0 auto",e.style.minHeight="0",e.style.minWidth="0",e.style.alignItems="stretch",e.style.height="100%",e.style.width=`${w+h}px`,e.style.transition=C,e.style.transform=T,t.style.flex="0 0 auto",t.style.flexGrow="0",t.style.flexShrink="0",t.style.width=`${w}px`,t.style.maxWidth=`${w}px`,t.style.minWidth=`${w}px`,n.style.display="flex",n.style.flexDirection="column",n.style.flex="0 0 auto",n.style.flexShrink="0",n.style.width=i.width,n.style.minWidth=i.width,n.style.maxWidth=i.width,n.style.position="relative",n.style.overflow="hidden",n.style.transition="none",n.style.pointerEvents=s?"auto":"none"}else{r.style.display="flex",r.style.flexDirection="row",r.style.alignItems="stretch",r.style.overflow="",au(e),iu(n),su(t),Jl(o,n);let h=i.reveal==="emerge";h?r.dataset.personaDockReveal="emerge":r.removeAttribute("data-persona-dock-reveal");let w=s?i.width:"0px",C=i.animate?"width 180ms ease, min-width 180ms ease, max-width 180ms ease, flex-basis 180ms ease":"none",T=!s;n.style.display="flex",n.style.flexDirection="column",n.style.flex=`0 0 ${w}`,n.style.width=w,n.style.maxWidth=w,n.style.minWidth=w,n.style.minHeight="0",n.style.position="relative",n.style.overflow=h||T?"hidden":"visible",n.style.transition=C,h&&(n.style.alignItems=i.side==="right"?"flex-start":"flex-end",o.style.width=i.width,o.style.minWidth=i.width,o.style.maxWidth=i.width,o.style.boxSizing="border-box")}},SC=(r,e)=>{let t=r.ownerDocument.createElement("div");return Jx(t,e),r.appendChild(t),{mode:"direct",host:t,shell:null,syncWidgetState:()=>{},updateConfig(n){Jx(t,n)},destroy(){t.remove()}}},TC=(r,e)=>{var E,k,h,w;let{ownerDocument:t}=r,n=r.parentElement;if(!n)throw new Error("Docked widget target must be attached to the DOM");let o=r.tagName.toUpperCase();if(o==="BODY"||o==="HTML")throw new Error('Docked widget target must be a concrete container element, not "body" or "html"');let a=r.nextSibling,s=t.createElement("div"),i=t.createElement("div"),d=t.createElement("div"),l=t.createElement("aside"),p=t.createElement("div"),f=(k=(E=e==null?void 0:e.launcher)==null?void 0:E.enabled)==null||k?(w=(h=e==null?void 0:e.launcher)==null?void 0:h.autoExpand)!=null?w:!1:!0;i.dataset.personaDockRole="push-track",d.dataset.personaDockRole="content",l.dataset.personaDockRole="panel",p.dataset.personaDockRole="host",l.appendChild(p),n.insertBefore(s,r),d.appendChild(r);let u=null,m=()=>{u==null||u.disconnect(),u=null},v=()=>{m(),Hn(e).reveal==="push"&&typeof ResizeObserver!="undefined"&&(u=new ResizeObserver(()=>{Zx(s,i,d,l,p,e,f)}),u.observe(s))},x=()=>{Zx(s,i,d,l,p,e,f),v()},S=s.ownerDocument.defaultView,M=()=>{x()};return S==null||S.addEventListener("resize",M),Hn(e).reveal==="push"?(i.appendChild(d),i.appendChild(l),s.appendChild(i)):(s.appendChild(d),s.appendChild(l)),x(),{mode:"docked",host:p,shell:s,syncWidgetState(C){let T=C.launcherEnabled?C.open:!0;f!==T&&(f=T,x())},updateConfig(C){var T,W;e=C,((W=(T=e==null?void 0:e.launcher)==null?void 0:T.enabled)!=null?W:!0)===!1&&(f=!0),x()},destroy(){S==null||S.removeEventListener("resize",M),m(),n.isConnected&&(a&&a.parentNode===n?n.insertBefore(r,a):n.appendChild(r)),s.remove()}}},oi=(r,e)=>Rr(e)?TC(r,e):SC(r,e);var lu={},eb=!1,MC=r=>{if(typeof window=="undefined"||typeof document=="undefined")throw new Error("Chat widget can only be mounted in a browser environment");if(typeof r=="string"){let e=document.querySelector(r);if(!e)throw new Error(`Chat widget target "${r}" was not found`);return e}return r},kC=()=>{try{if(typeof lu!="undefined"&&lu.url)return new URL("../widget.css",lu.url).href}catch{}return null},tb=(r,e)=>{let t=kC(),n=()=>{if(!(r instanceof ShadowRoot)||r.querySelector("link[data-persona]"))return;let o=e.head.querySelector("link[data-persona]");if(!o)return;let a=o.cloneNode(!0);r.insertBefore(a,r.firstChild)};if(r instanceof ShadowRoot)if(t){let o=e.createElement("link");o.rel="stylesheet",o.href=t,o.setAttribute("data-persona","true"),r.insertBefore(o,r.firstChild)}else n();else if(!e.head.querySelector("link[data-persona]")&&t){let a=e.createElement("link");a.rel="stylesheet",a.href=t,a.setAttribute("data-persona","true"),e.head.appendChild(a)}},rb=r=>{let e=MC(r.target),t=r.useShadowDom===!0,n=e.ownerDocument,o=r.config,a=oi(e,o),s,i=[],d=(S,M)=>{var w,C;let k=!((C=(w=M==null?void 0:M.launcher)==null?void 0:w.enabled)!=null?C:!0)||Rr(M),h=n.createElement("div");if(h.setAttribute("data-persona-root","true"),k&&(h.style.height="100%",h.style.display="flex",h.style.flexDirection="column",h.style.flex="1",h.style.minHeight="0"),t){let T=S.attachShadow({mode:"open"});T.appendChild(h),tb(T,n)}else S.appendChild(h),tb(S,n);return e.id&&h.setAttribute("data-persona-instance",e.id),h},l=()=>{a.syncWidgetState(s.getState())},p=()=>{i.forEach(S=>S()),i=[s.on("widget:opened",l),s.on("widget:closed",l)],l()},f=()=>{let S=d(a.host,o);s=Ql(S,o,{debugTools:r.debugTools}),p()},u=()=>{i.forEach(S=>S()),i=[],s.destroy()};f(),r.onChatReady?r.onChatReady():r.onReady&&(eb||(eb=!0,console.warn("[Persona] `onReady` is deprecated \u2014 use `onChatReady`. `onReady` still works but is removed in the next major.")),r.onReady());let m=S=>{u(),a.destroy(),a=oi(e,S),o=S,f()},v={update(S){var C,T,W,R,I,N;let M={...o,...S,launcher:{...(C=o==null?void 0:o.launcher)!=null?C:{},...(T=S==null?void 0:S.launcher)!=null?T:{},dock:{...(R=(W=o==null?void 0:o.launcher)==null?void 0:W.dock)!=null?R:{},...(N=(I=S==null?void 0:S.launcher)==null?void 0:I.dock)!=null?N:{}}}},E=Rr(o),k=Rr(M),h=Oo(o),w=Oo(M);if(E!==k||h!==w){m(M);return}o=M,a.updateConfig(o),s.update(S),l()},destroy(){u(),a.destroy(),r.windowKey&&typeof window!="undefined"&&delete window[r.windowKey]}},x=new Proxy(v,{get(S,M,E){if(M==="host")return a.host;if(M in S)return Reflect.get(S,M,E);let k=s[M];return typeof k=="function"?k.bind(s):k}});return r.windowKey&&typeof window!="undefined"&&(window[r.windowKey]=x),x};var ib=new Set(["script","style","noscript","svg","path","meta","link","br","hr"]),EC=new Set(["button","a","input","select","textarea","details","summary"]),LC=new Set(["button","link","menuitem","tab","option","switch","checkbox","radio","combobox","listbox","slider","spinbutton","textbox"]),du=/\b(product|card|item|listing|result)\b/i,pu=/\$[\d,]+(?:\.\d{2})?|€[\d,]+(?:\.\d{2})?|£[\d,]+(?:\.\d{2})?|USD\s*[\d,]+(?:\.\d{2})?/i,PC=3e3,RC=100;function lb(r){let e=typeof r.className=="string"?r.className:"";if(du.test(e)||r.id&&du.test(r.id))return!0;for(let t=0;t<r.attributes.length;t++){let n=r.attributes[t];if(n.name.startsWith("data-")&&du.test(n.value))return!0}return!1}function db(r){var e;return pu.test(((e=r.textContent)!=null?e:"").trim())}function cb(r){var t;let e=r.querySelectorAll("a[href]");for(let n=0;n<e.length;n++){let o=(t=e[n].getAttribute("href"))!=null?t:"";if(o&&o!=="#"&&!o.toLowerCase().startsWith("javascript:"))return!0}return!1}function IC(r){return!!r.querySelector('button, [role="button"], input[type="submit"], input[type="button"]')}function nb(r){let e=r.match(pu);return e?e[0]:null}function ob(r){var n,o,a;let e=(n=r.querySelector(".product-title a, h1 a, h2 a, h3 a, h4 a, .title a, a[href]"))!=null?n:r.querySelector("a[href]");if(e&&((o=e.textContent)!=null&&o.trim())){let s=e.getAttribute("href");return{title:e.textContent.trim(),href:s&&s!=="#"?s:null}}let t=r.querySelector("h1, h2, h3, h4, h5, h6");return(a=t==null?void 0:t.textContent)!=null&&a.trim()?{title:t.textContent.trim(),href:null}:{title:"",href:null}}function WC(r){let e=[],t=n=>{let o=n.trim();o&&!e.includes(o)&&e.push(o)};return r.querySelectorAll("button").forEach(n=>{var o;return t((o=n.textContent)!=null?o:"")}),r.querySelectorAll('[role="button"]').forEach(n=>{var o;return t((o=n.textContent)!=null?o:"")}),r.querySelectorAll('input[type="submit"], input[type="button"]').forEach(n=>{var o;t((o=n.value)!=null?o:"")}),e.slice(0,6)}var HC="commerce-card",BC="result-card";function ab(r){return!lb(r)||!db(r)||!cb(r)&&!IC(r)?0:5200}function sb(r){var n;return!lb(r)||db(r)||!cb(r)||((n=r.textContent)!=null?n:"").trim().length<20||!(!!r.querySelector("h1, h2, h3, h4, h5, h6, .title")||!!r.querySelector(".snippet, .description, p"))?0:2800}var uu=[{id:HC,scoreElement(r){return ab(r)},shouldSuppressDescendant(r,e,t){if(e===r||!r.contains(e))return!1;if(t.interactivity==="static"){let n=t.text.trim();return!!(n.length===0||pu.test(n)&&n.length<32)}return!0},formatSummary(r,e){var d,l,p;if(ab(r)===0)return null;let{title:t,href:n}=ob(r),o=(p=(l=nb(((d=r.textContent)!=null?d:"").trim()))!=null?l:nb(e.text))!=null?p:"",a=WC(r);return[n&&t?`[${t}](${n})${o?` \u2014 ${o}`:""}`:t?`${t}${o?` \u2014 ${o}`:""}`:o||e.text.trim().slice(0,120),`selector: ${e.selector}`,a.length?`actions: ${a.join(", ")}`:""].filter(Boolean).join(`
|
|
155
|
-
`)}},{id:
|
|
156
|
-
`)}}];function
|
|
155
|
+
`}if(!S&&!c){let Zt="max-height: -moz-available !important; max-height: stretch !important;",Yt=g?"":"padding-top: 1.25em !important;",Et=g?"":`z-index: ${(Ir=(pt=o.launcher)==null?void 0:pt.zIndex)!=null?Ir:so} !important;`;De.style.cssText+=Zt+Yt+Et}ot()};to(),Vn(r,o),Ql(r,o),Yl(r,o);let gt=[];gt.push(()=>{document.removeEventListener("keydown",Nr)});let re=null,A=null;gt.push(()=>{re==null||re(),re=null,A==null||A(),A=null}),co&>.push(()=>{co==null||co.disconnect(),co=null}),gt.push(()=>{Fr==null||Fr(),Fr=null,Uo(),$t&&($t.remove(),$t=null),mt==null||mt.element.style.removeProperty("width"),mt==null||mt.element.style.removeProperty("maxWidth")}),We&>.push(()=>{Oe!==null&&(cancelAnimationFrame(Oe),Oe=null),Y==null||Y.destroy(),Y=null,be==null||be.destroy(),be=null,ne=null});let _=null,ue=()=>{_&&(_(),_=null),o.colorScheme==="auto"&&(_=El(()=>{Vn(r,o)}))};ue(),gt.push(()=>{_&&(_(),_=null)});let $=(Rf=o.features)==null?void 0:Rf.streamAnimation;if($!=null&&$.type&&$.type!=="none"){let c=ni($.type,$.plugins);c&&(Yp(c,r),gt.push(()=>Hx(r)))}let at=Kx(Pt),ut=null,U,nr=c=>{var S,W;if(!U)return;let g=c!=null?c:U.getMessages(),b=((W=(S=o.features)==null?void 0:S.suggestReplies)==null?void 0:W.enabled)!==!1?Yi(g):null;b?at.render(b,U,te,g,o.suggestionChipsConfig,{agentPushed:!0}):g.some(F=>F.role==="user")?at.render([],U,te,g):at.render(o.suggestionChips,U,te,g,o.suggestionChipsConfig)},mr=!1,Cr=Sx(),ko=new Map,sr=new Map,Ko=new Map,us=0,Eo=Rl(),Lo=0,Xo=null,Qo=!1,Qn=!1,gn=0,ro=null,an=null,Pa=!1,Yn=!1,Ra=null,bi=4,Ia=24,vi=80,Ha=new Map,Lt={active:!1,manuallyDeactivated:!1,lastUserMessageWasVoice:!1,lastUserMessageId:null},fs=(Hf=(If=o.voiceRecognition)==null?void 0:If.autoResume)!=null?Hf:!1,zo=c=>{a.emit("voice:state",{active:Lt.active,source:c,timestamp:Date.now()})},So=()=>{m(c=>({...c,voiceState:{active:Lt.active,timestamp:Date.now(),manuallyDeactivated:Lt.manuallyDeactivated}}))},Ci=()=>{var S,W;if(((S=o.voiceRecognition)==null?void 0:S.enabled)===!1)return;let c=gu(d.voiceState),g=!!c.active,b=Number((W=c.timestamp)!=null?W:0);Lt.manuallyDeactivated=!!c.manuallyDeactivated,g&&Date.now()-b<QC&&setTimeout(()=>{var F,q;Lt.active||(Lt.manuallyDeactivated=!1,((q=(F=o.voiceRecognition)==null?void 0:F.provider)==null?void 0:q.type)==="runtype"?U.toggleVoice().then(()=>{Lt.active=U.isVoiceActive(),zo("restore"),U.isVoiceActive()&&Ts()}):pr("restore"))},1e3)},wi=()=>U?fy(U.getMessages()).filter(c=>!c.__skipPersist):[];function Wa(c){if(!(i!=null&&i.save))return;let b={messages:c?fy(c):U?wi():[],metadata:d,artifacts:po.artifacts,selectedArtifactId:po.selectedId};try{let S=i.save(b);S instanceof Promise&&S.catch(W=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to persist state:",W)})}catch(S){typeof console!="undefined"&&console.error("[AgentWidget] Failed to persist state:",S)}}let hn=null,ms=()=>De.querySelector("#persona-scroll-container")||he,Pn=()=>{hn!==null&&(cancelAnimationFrame(hn),hn=null),Qo=!1},gs=()=>{Xo!==null&&(cancelAnimationFrame(Xo),Xo=null),Qn=!1,Pn()},hs=()=>{gn>0?(Dr.textContent=String(gn),Dr.style.display="",tt.setAttribute("aria-label",`${zt()||"Jump to latest"} (${gn} new)`)):(Dr.textContent="",Dr.style.display="none",tt.setAttribute("aria-label",zt()||"Jump to latest"))},xs=()=>{gn!==0&&(gn=0,hs())},ys=()=>xt()==="follow"?!Eo.isFollowing():!Aa(he,Ia),To=()=>{if(!vr()||ge){tt.parentNode&&tt.remove(),tt.style.display="none";return}tt.parentNode!==K&&K.appendChild(tt),Sr();let g=Mn(he)>0&&ys();g||xs(),tt.style.display=g?"":"none"},Ba=()=>{Eo.pause()&&(gs(),To())},sn=()=>{Eo.resume(),xs(),To()},ln=(c=!1)=>{xt()==="follow"&&Eo.isFollowing()&&(!c&&!mr||(Xo!==null&&(cancelAnimationFrame(Xo),Xo=null),Qn=!0,Xo=requestAnimationFrame(()=>{Xo=null,Qn=!1,Eo.isFollowing()&&Ai(ms(),c?220:140)})))},bs=(c,g,b,S=()=>!0)=>{let W=c.scrollTop,F=g(),q=F-W;Pn();let G=performance.now();Qo=!0;let N=xe=>1-Math.pow(1-xe,3),Se=xe=>{if(!S()){Pn();return}let se=g();se!==F&&(F=se,q=F-W);let ke=xe-G,Ge=Math.min(ke/b,1),Te=N(Ge),ft=W+q*Te;c.scrollTop=ft,Lo=c.scrollTop,Ge<1?hn=requestAnimationFrame(Se):(c.scrollTop=F,Lo=c.scrollTop,hn=null,Qo=!1)};hn=requestAnimationFrame(Se)},Ai=(c,g=500)=>{let b=Mn(c)-c.scrollTop;if(Math.abs(b)<1){Lo=c.scrollTop;return}if(Math.abs(b)>=vi){Pn(),Qo=!0,c.scrollTop=Mn(c),Lo=c.scrollTop,Qo=!1;return}bs(c,()=>Mn(c),g,()=>Eo.isFollowing())},vs=()=>{let c=ms();Qo=!0,c.scrollTop=Mn(c),Lo=c.scrollTop,Qo=!1,To()},Cs=c=>{hr.style.height=`${Math.max(0,Math.round(c))}px`,ro&&(ro.spacerHeight=Math.max(0,c))},Jn=()=>{an!==null&&(cancelAnimationFrame(an),an=null),Pn(),ro=null,hr.style.height="0px"},Si=c=>{an!==null&&cancelAnimationFrame(an),an=requestAnimationFrame(()=>{var Se;an=null;let g=typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(c):c.replace(/"/g,'\\"'),b=he.querySelector(`[data-message-id="${g}"]`);if(!b)return;let S=0,W=b;for(;W&&W!==he;)S+=W.offsetTop,W=W.offsetParent;let F=(Se=ro==null?void 0:ro.spacerHeight)!=null?Se:0,q=he.scrollHeight-F,{targetScrollTop:G,spacerHeight:N}=Lx({anchorOffsetTop:S,topOffset:It(),viewportHeight:he.clientHeight,contentHeight:q});ro={initialSpacerHeight:N,contentHeightAtAnchor:q,spacerHeight:N},Cs(N),bs(he,()=>G,220)})},Ti=()=>{if(xt()==="follow"){if(!Eo.isFollowing()||Aa(he,1))return;ln(!mr);return}if(ro&&ro.initialSpacerHeight>0){let c=he.scrollHeight-ro.spacerHeight,g=Px({initialSpacerHeight:ro.initialSpacerHeight,contentHeightAtAnchor:ro.contentHeightAtAnchor,currentContentHeight:c});g!==ro.spacerHeight&&Cs(g)}To()},Mi=c=>{let g=xt();g==="follow"?(sn(),ln(!0)):g==="anchor-top"&&Si(c)},ki=c=>{let g=new Map;c.forEach(b=>{let S=Ha.get(b.id);g.set(b.id,{streaming:b.streaming,role:b.role}),!S&&b.role==="assistant"&&(a.emit("assistant:message",b),!Yn&&xt()!=="anchor-top"&&ys()&&(gn+=1,hs(),To())),b.role==="assistant"&&(S!=null&&S.streaming)&&b.streaming===!1&&a.emit("assistant:complete",b),b.variant==="approval"&&b.approval&&(S?b.approval.status!=="pending"&&a.emit("approval:resolved",{approval:b.approval,decision:b.approval.status}):a.emit("approval:requested",{approval:b.approval,message:b}))}),Ha.clear(),g.forEach((b,S)=>{Ha.set(S,b)})},Zn=(c,g,b)=>{var vt,He,Pe,Qe,ot,Ht;let S=document.createElement("div"),F=(()=>{var Ne;let D=n.find(Fe=>Fe.renderLoadingIndicator);if(D!=null&&D.renderLoadingIndicator)return D.renderLoadingIndicator;if((Ne=o.loadingIndicator)!=null&&Ne.render)return o.loadingIndicator.render})(),q=(D,Ne)=>Ne==null?!1:typeof Ne=="string"?(D.textContent=Ne,!0):(D.appendChild(Ne),!0),G=new Set,N=new Set,Se=n.some(D=>D.renderAskUserQuestion),xe=[],se=[],ke=o.enableComponentStreaming!==!1,Ge=n.some(D=>D.renderApproval)&&o.approval!==!1,Te=[];if(g.forEach(D=>{var st,Ut,kr,Vo,Ro,ta,ra,Fa,Ua,ur,oa,On,_n,yn,na,Yo;G.add(D.id);let Ne=Se&&wn(D),Fe=Ge&&D.variant==="approval"&&!!D.approval,we=!Ne&&D.role==="assistant"&&!D.variant&&ke&&td(D);if(!Fe&&Ko.has(D.id)){let pt=c.querySelector(`#wrapper-${D.id}`);pt==null||pt.removeAttribute("data-preserve-runtime"),Ko.delete(D.id)}if(!we&&sr.has(D.id)){let pt=c.querySelector(`#wrapper-${D.id}`);pt==null||pt.removeAttribute("data-preserve-runtime"),sr.delete(D.id)}let Qt=wn(D)?`:${(st=D.agentMetadata)!=null&&st.askUserQuestionAnswered?"a":"u"}:${(Ut=D.agentMetadata)!=null&&Ut.askUserQuestionAnswers?Object.keys(D.agentMetadata.askUserQuestionAnswers).length:0}`:"",Kt=Ax(D,us)+Qt,ir=Ne||Fe||we?null:Tx(Cr,D.id,Kt);if(ir){S.appendChild(ir.cloneNode(!0)),wn(D)&&((kr=D.toolCall)!=null&&kr.id)&&((Vo=D.agentMetadata)==null?void 0:Vo.awaitingLocalTool)===!0&&!((Ro=D.agentMetadata)!=null&&Ro.askUserQuestionAnswered)&&(N.add(D.toolCall.id),Qa(D,o,Re.composerOverlay));return}let Bt=null,ar=n.find(pt=>!!(D.variant==="reasoning"&&pt.renderReasoning||D.variant==="tool"&&pt.renderToolCall||!D.variant&&pt.renderMessage)),Po=(ta=o.layout)==null?void 0:ta.messages;if(wn(D)&&((ra=D.agentMetadata)==null?void 0:ra.askUserQuestionAnswered)===!0){ko.delete(D.id);let pt=c.querySelector(`#wrapper-${D.id}`);pt==null||pt.removeAttribute("data-preserve-runtime");return}if(js(D)&&((Ua=(Fa=o.features)==null?void 0:Fa.suggestReplies)==null?void 0:Ua.enabled)!==!1)return;if(wn(D)&&((oa=(ur=o.features)==null?void 0:ur.askUserQuestion)==null?void 0:oa.enabled)!==!1){let pt=n.find(Ir=>typeof Ir.renderAskUserQuestion=="function");if(pt&&Wt.current){let Ir=ko.get(D.id),Zt=Ir!==Kt,Yt=null;if(Zt){let{payload:_t,complete:oo}=An(D),ho=D.id,dn=()=>{var qr;return(qr=Wt.current)==null?void 0:qr.getMessages().find(xo=>xo.id===ho)};Yt=pt.renderAskUserQuestion({message:D,payload:_t,complete:oo,resolve:qr=>{var yo;let xo=dn();xo&&((yo=Wt.current)==null||yo.resolveAskUserQuestion(xo,qr))},dismiss:()=>{var xo,yo,aa;let qr=dn();(xo=qr==null?void 0:qr.agentMetadata)!=null&&xo.awaitingLocalTool&&((yo=Wt.current)==null||yo.markAskUserQuestionResolved(qr),(aa=Wt.current)==null||aa.resolveAskUserQuestion(qr,"(dismissed)"))},config:o})}let Et=Ir!=null;if(Zt&&Yt===null&&!Et){((On=D.agentMetadata)==null?void 0:On.awaitingLocalTool)===!0&&!((_n=D.agentMetadata)!=null&&_n.askUserQuestionAnswered)&&(N.add(D.toolCall.id),Qa(D,o,Re.composerOverlay));return}let fr=document.createElement("div");fr.className="persona-flex",fr.id=`wrapper-${D.id}`,fr.setAttribute("data-wrapper-id",D.id),fr.setAttribute("data-ask-plugin-stub","true"),fr.setAttribute("data-preserve-runtime","true"),S.appendChild(fr),xe.push({messageId:D.id,fingerprint:Kt,bubble:Yt});return}else{((yn=D.agentMetadata)==null?void 0:yn.awaitingLocalTool)===!0&&!((na=D.agentMetadata)!=null&&na.askUserQuestionAnswered)&&(N.add(D.toolCall.id),Qa(D,o,Re.composerOverlay));return}}else if(Fe){let pt=n.find(Et=>typeof Et.renderApproval=="function"),Zt=Ko.get(D.id)!==Kt,Yt=null;if(Zt&&(pt!=null&&pt.renderApproval)){let Et=D.id,fr=(_t,oo)=>{var dn,qr,xo;let ho=(dn=Wt.current)==null?void 0:dn.getMessages().find(yo=>yo.id===Et);ho!=null&&ho.approval&&(ho.approval.toolType==="webmcp"?(qr=Wt.current)==null||qr.resolveWebMcpApproval(ho.id,_t):(xo=Wt.current)==null||xo.resolveApproval(ho.approval,_t,oo))};Yt=pt.renderApproval({message:D,defaultRenderer:()=>Kl(D,o),config:o,approve:_t=>fr("approved",_t),deny:_t=>fr("denied",_t)})}if(Zt&&Yt===null){let Et=c.querySelector(`#wrapper-${D.id}`);Et==null||Et.removeAttribute("data-preserve-runtime"),Ko.delete(D.id),Bt=Kl(D,o)}else{let Et=document.createElement("div");Et.className="persona-flex",Et.id=`wrapper-${D.id}`,Et.setAttribute("data-wrapper-id",D.id),Et.setAttribute("data-approval-plugin-stub","true"),Et.setAttribute("data-preserve-runtime","true"),S.appendChild(Et),Te.push({messageId:D.id,fingerprint:Kt,bubble:Yt});return}}else if(ar)if(D.variant==="reasoning"&&D.reasoning&&ar.renderReasoning){if(!Xe)return;Bt=ar.renderReasoning({message:D,defaultRenderer:()=>iu(D,o),config:o})}else if(D.variant==="tool"&&D.toolCall&&ar.renderToolCall){if(!Ae)return;Bt=ar.renderToolCall({message:D,defaultRenderer:()=>lu(D,o),config:o})}else ar.renderMessage&&(Bt=ar.renderMessage({message:D,defaultRenderer:()=>{let pt=as(D,b,Po,o.messageActions,ae,{loadingIndicatorRenderer:F,widgetConfig:o});return D.role!=="user"&&uu(pt,D,o,U),pt},config:o}));if(!Bt&&we){let pt=rd(D);if(pt){let Ir=sr.get(D.id),Zt=Ir!==Kt,Yt=o.wrapComponentDirectiveInBubble!==!1,Et=null;if(Zt){let fr=ed(pt,{config:o,message:D,transform:b});if(fr)if(Yt){let _t=document.createElement("div");if(_t.className=["persona-message-bubble","persona-max-w-[85%]","persona-rounded-2xl","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-p-4"].join(" "),_t.id=`bubble-${D.id}`,_t.setAttribute("data-message-id",D.id),D.content&&D.content.trim()){let oo=document.createElement("div");oo.className="persona-mb-3 persona-text-sm persona-leading-relaxed",oo.innerHTML=b({text:D.content,message:D,streaming:!!D.streaming,raw:D.rawContent}),_t.appendChild(oo)}_t.appendChild(fr),Et=_t}else{let _t=document.createElement("div");if(_t.className="persona-flex persona-flex-col persona-w-full persona-max-w-full persona-gap-3 persona-items-stretch",_t.id=`bubble-${D.id}`,_t.setAttribute("data-message-id",D.id),_t.setAttribute("data-persona-component-directive","true"),D.content&&D.content.trim()){let oo=document.createElement("div");oo.className="persona-text-sm persona-leading-relaxed persona-text-persona-primary persona-w-full",oo.innerHTML=b({text:D.content,message:D,streaming:!!D.streaming,raw:D.rawContent}),_t.appendChild(oo)}_t.appendChild(fr),Et=_t}}if(Et||Ir!=null){let fr=document.createElement("div");fr.className="persona-flex",fr.id=`wrapper-${D.id}`,fr.setAttribute("data-wrapper-id",D.id),fr.setAttribute("data-component-directive-stub","true"),fr.setAttribute("data-preserve-runtime","true"),Yt||fr.classList.add("persona-w-full"),S.appendChild(fr),se.push({messageId:D.id,fingerprint:Kt,bubble:Et});return}}}if(!Bt)if(D.variant==="reasoning"&&D.reasoning){if(!Xe)return;Bt=iu(D,o)}else if(D.variant==="tool"&&D.toolCall){if(!Ae)return;Bt=lu(D,o)}else if(D.variant==="approval"&&D.approval){if(o.approval===!1)return;Bt=Kl(D,o)}else{let pt=(Yo=o.layout)==null?void 0:Yo.messages;pt!=null&&pt.renderUserMessage&&D.role==="user"?Bt=pt.renderUserMessage({message:D,config:o,streaming:!!D.streaming}):pt!=null&&pt.renderAssistantMessage&&D.role==="assistant"?Bt=pt.renderAssistantMessage({message:D,config:o,streaming:!!D.streaming}):Bt=as(D,b,pt,o.messageActions,ae,{loadingIndicatorRenderer:F,widgetConfig:o}),D.role!=="user"&&Bt&&uu(Bt,D,o,U)}let wr=document.createElement("div");wr.className="persona-flex",wr.id=`wrapper-${D.id}`,wr.setAttribute("data-wrapper-id",D.id),D.role==="user"&&wr.classList.add("persona-justify-end"),(Bt==null?void 0:Bt.getAttribute("data-persona-component-directive"))==="true"&&wr.classList.add("persona-w-full"),wr.appendChild(Bt),Mx(Cr,D.id,Kt,wr),S.appendChild(wr)}),Re.composerOverlay&&Re.composerOverlay.querySelectorAll("[data-persona-ask-sheet-for]").forEach(Ne=>{let Fe=Ne.getAttribute("data-persona-ask-sheet-for");Fe&&!N.has(Fe)&&zn(Re.composerOverlay,Fe)}),(He=(vt=o.features)==null?void 0:vt.toolCallDisplay)!=null&&He.grouped){let D=[],Ne=[];g.forEach(Fe=>{if(Fe.variant==="tool"&&Fe.toolCall&&Ae){Ne.push(Fe);return}Ne.length>1&&D.push(Ne),Ne=[]}),Ne.length>1&&D.push(Ne),D.forEach((Fe,we)=>{var st,Ut;let Qt=Fe.map(kr=>Array.from(S.children).find(Vo=>Vo instanceof HTMLElement&&Vo.getAttribute("data-wrapper-id")===kr.id)).filter(kr=>!!kr);if(Qt.length<2)return;let Kt=document.createElement("div");Kt.className="persona-flex",Kt.id=`wrapper-tool-group-${we}-${Fe[0].id}`,Kt.setAttribute("data-wrapper-id",`tool-group-${we}-${Fe[0].id}`);let ir=document.createElement("div");ir.className="persona-tool-group persona-flex persona-w-full persona-flex-col persona-gap-2",ir.setAttribute("data-persona-tool-group","true");let Bt=document.createElement("div");Bt.className="persona-tool-group-summary persona-text-xs persona-text-persona-muted";let ar=`Called ${Fe.length} tools`,Po=(Ut=(st=o.toolCall)==null?void 0:st.renderGroupedSummary)==null?void 0:Ut.call(st,{messages:Fe,toolCalls:Fe.map(kr=>kr.toolCall).filter(kr=>!!kr),defaultSummary:ar,config:o});q(Bt,Po)||(Bt.textContent=ar);let wr=document.createElement("div");wr.className="persona-tool-group-stack persona-flex persona-flex-col",ir.append(Bt,wr),Kt.appendChild(ir),Qt[0].before(Kt),Qt.forEach((kr,Vo)=>{let Ro=document.createElement("div");Ro.className="persona-tool-group-item persona-relative",Ro.setAttribute("data-persona-tool-group-item","true"),Vo<Qt.length-1&&Ro.setAttribute("data-persona-tool-group-connector","true"),Ro.appendChild(kr),wr.appendChild(Ro)})})}kx(Cr,G);let ft=g.some(D=>D.role==="assistant"&&D.streaming),Ze=g[g.length-1],bt=(Ze==null?void 0:Ze.role)==="assistant"&&!Ze.streaming&&Ze.variant!=="approval";if(mr&&g.some(D=>D.role==="user")&&!ft&&!bt){let D={config:o,streaming:!0,location:"standalone",defaultRenderer:Ma},Ne=n.find(we=>we.renderLoadingIndicator),Fe=null;if(Ne!=null&&Ne.renderLoadingIndicator&&(Fe=Ne.renderLoadingIndicator(D)),Fe===null&&((Pe=o.loadingIndicator)!=null&&Pe.render)&&(Fe=o.loadingIndicator.render(D)),Fe===null&&(Fe=Ma()),Fe){let we=document.createElement("div"),Qt=((Qe=o.loadingIndicator)==null?void 0:Qe.showBubble)!==!1;we.className=Qt?["persona-max-w-[85%]","persona-rounded-2xl","persona-text-sm","persona-leading-relaxed","persona-shadow-sm","persona-bg-persona-surface","persona-border","persona-text-persona-primary","persona-px-5","persona-py-3"].join(" "):["persona-max-w-[85%]","persona-text-sm","persona-leading-relaxed","persona-text-persona-primary"].join(" "),we.setAttribute("data-typing-indicator","true"),we.style.borderColor="var(--persona-message-assistant-border, var(--persona-border, #e5e7eb))",we.appendChild(Fe);let Kt=document.createElement("div");Kt.className="persona-flex",Kt.id="wrapper-typing-indicator",Kt.setAttribute("data-wrapper-id","typing-indicator"),Kt.appendChild(we),S.appendChild(Kt)}}if(!mr&&g.length>0){let D=g[g.length-1],Ne={config:o,lastMessage:D,messageCount:g.length},Fe=n.find(Qt=>Qt.renderIdleIndicator),we=null;if(Fe!=null&&Fe.renderIdleIndicator&&(we=Fe.renderIdleIndicator(Ne)),we===null&&((ot=o.loadingIndicator)!=null&&ot.renderIdle)&&(we=o.loadingIndicator.renderIdle(Ne)),we){let Qt=document.createElement("div"),Kt=((Ht=o.loadingIndicator)==null?void 0:Ht.showBubble)!==!1;Qt.className=Kt?["persona-max-w-[85%]","persona-rounded-2xl","persona-text-sm","persona-leading-relaxed","persona-shadow-sm","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-text-persona-primary","persona-px-5","persona-py-3"].join(" "):["persona-max-w-[85%]","persona-text-sm","persona-leading-relaxed","persona-text-persona-primary"].join(" "),Qt.setAttribute("data-idle-indicator","true"),Qt.appendChild(we);let ir=document.createElement("div");ir.className="persona-flex",ir.id="wrapper-idle-indicator",ir.setAttribute("data-wrapper-id","idle-indicator"),ir.appendChild(Qt),S.appendChild(ir)}}if(Ll(c,S),xe.length>0)for(let{messageId:D,fingerprint:Ne,bubble:Fe}of xe){let we=c.querySelector(`#wrapper-${D}`);we&&Fe!==null&&(we.replaceChildren(Fe),we.setAttribute("data-bubble-fp",Ne),ko.set(D,Ne))}if(ko.size>0)for(let D of ko.keys())G.has(D)||ko.delete(D);if(se.length>0)for(let{messageId:D,fingerprint:Ne,bubble:Fe}of se){let we=c.querySelector(`#wrapper-${D}`);we&&Fe!==null&&(we.replaceChildren(Fe),we.setAttribute("data-bubble-fp",Ne),sr.set(D,Ne))}if(sr.size>0)for(let D of sr.keys())G.has(D)||sr.delete(D);if(Te.length>0)for(let{messageId:D,fingerprint:Ne,bubble:Fe}of Te){let we=c.querySelector(`#wrapper-${D}`);we&&Fe!==null&&(we.replaceChildren(Fe),we.setAttribute("data-bubble-fp",Ne),Ko.set(D,Ne))}if(Ko.size>0)for(let D of Ko.keys())G.has(D)||Ko.delete(D)},Rn=null,Ei=()=>{var b;if(Rn)return;let c=S=>{let W=S.composedPath();W.includes(De)||nt&&W.includes(nt)||Gt(!1,"user")};Rn=c,((b=r.ownerDocument)!=null?b:document).addEventListener("pointerdown",c,!0)},ws=()=>{var g;if(!Rn)return;((g=r.ownerDocument)!=null?g:document).removeEventListener("pointerdown",Rn,!0),Rn=null};gt.push(()=>ws());let In=null,Li=()=>{var b;if(In)return;let c=S=>{S.key==="Escape"&&(S.isComposing||Gt(!1,"user"))};In=c,((b=r.ownerDocument)!=null?b:document).addEventListener("keydown",c,!0)},As=()=>{var g;if(!In)return;((g=r.ownerDocument)!=null?g:document).removeEventListener("keydown",In,!0),In=null};gt.push(()=>As());let Hn=!1,Ss=new Set,Pi=()=>{var g,b,S,W;let c=(S=(b=(g=o.launcher)==null?void 0:g.composerBar)==null?void 0:b.peek)==null?void 0:S.streamAnimation;return c||((W=o.features)==null?void 0:W.streamAnimation)},xn=()=>{var bt,vt,He,Pe;if(!H())return;let c=Re.peekBanner,g=Re.peekTextNode;if(!c||!g)return;if(P){c.classList.remove("persona-pill-peek--visible");return}let b=(bt=U==null?void 0:U.getMessages())!=null?bt:[],S;for(let Qe=b.length-1;Qe>=0;Qe--){let ot=b[Qe];if(ot.role==="assistant"&&ot.content){S=ot;break}}if(!S){c.classList.remove("persona-pill-peek--visible");return}let W=S.content,F=!!S.streaming,q=Pi(),G=Wl(q),N=G.type!=="none"?ni(G.type,q==null?void 0:q.plugins):null,Se=((vt=N==null?void 0:N.isAnimating)==null?void 0:vt.call(N,S))===!0,xe=N!==null&&(F||Se);xe&&N&&!Ss.has(N.name)&&(Yp(N,r),Ss.add(N.name));let se=xe&&(N!=null&&N.containerClass)?N.containerClass:null,ke=(He=g.dataset.personaPeekStreamClass)!=null?He:null;ke&&ke!==se&&(g.classList.remove(ke),delete g.dataset.personaPeekStreamClass),se&&ke!==se&&(g.classList.add(se),g.dataset.personaPeekStreamClass=se),xe?(g.style.setProperty("--persona-stream-step",`${G.speed}ms`),g.style.setProperty("--persona-stream-duration",`${G.duration}ms`)):(g.style.removeProperty("--persona-stream-step"),g.style.removeProperty("--persona-stream-duration"));let Ge=xe?Bl(W,G.buffer,N,S,F):W;if(xe&&G.placeholder==="skeleton"&&F&&(!Ge||!Ge.trim())){let Qe=document.createElement("div"),ot=si();ot.classList.add("persona-pill-peek__skeleton"),Qe.appendChild(ot),Ll(g,Qe)}else{let Qe=Math.max(0,Ge.length-100),ot=Ge.length>100?Ge.slice(-100):Ge,Ht=fa(ot);if(!xe||!N){let D=Ge.length>100?`\u2026${ot}`:ot;g.textContent!==D&&(g.textContent=D)}else{let D=Ht;(N.wrap==="char"||N.wrap==="word")&&(D=ai(Ht,N.wrap,`peek-${S.id}`,{skipTags:N.skipTags,startIndex:Qe}));let Ne=document.createElement("div");if(Ne.innerHTML=D,N.useCaret&&ot.length>0){let Fe=Dl(),we=Ne.querySelectorAll(".persona-stream-char, .persona-stream-word"),Qt=we[we.length-1];Qt!=null&&Qt.parentNode?Qt.parentNode.insertBefore(Fe,Qt.nextSibling):Ne.appendChild(Fe)}Ll(g,Ne),(Pe=N.onAfterRender)==null||Pe.call(N,{container:g,bubble:c,messageId:S.id,message:S,speed:G.speed,duration:G.duration})}}let Ze=mr||Hn;c.classList.toggle("persona-pill-peek--visible",Ze)};if(H()){let c=Re.peekBanner;if(c){let S=W=>{W.preventDefault(),W.stopPropagation(),Gt(!0,"user")};c.addEventListener("pointerdown",S),gt.push(()=>{c.removeEventListener("pointerdown",S)})}let g=()=>{Hn||(Hn=!0,xn())},b=()=>{Hn&&(Hn=!1,xn())};le.addEventListener("pointerenter",g),le.addEventListener("pointerleave",b),gt.push(()=>{le.removeEventListener("pointerenter",g),le.removeEventListener("pointerleave",b)}),nt&&(nt.addEventListener("pointerenter",g),nt.addEventListener("pointerleave",b),gt.push(()=>{nt.removeEventListener("pointerenter",g),nt.removeEventListener("pointerleave",b)}))}let Ri=c=>{var ke,Ge,Te,ft,Ze,bt,vt,He;let g=(Ge=(ke=o.launcher)==null?void 0:ke.composerBar)!=null?Ge:{},b=(Te=g.expandedSize)!=null?Te:"anchored",S=(ft=g.bottomOffset)!=null?ft:"16px",W=g.collapsedMaxWidth,F=(Ze=g.expandedMaxWidth)!=null?Ze:"880px",q=(bt=g.expandedTopOffset)!=null?bt:"5vh",G=(vt=g.modalMaxWidth)!=null?vt:"880px",N=(He=g.modalMaxHeight)!=null?He:"min(90vh, 800px)",Se="calc(100vw - 32px)",xe="var(--persona-pill-area-height, 80px)",se=De.style;if(se.left="",se.right="",se.top="",se.bottom="",se.transform="",se.width="",se.maxWidth="",se.height="",se.maxHeight="",nt){let Pe=nt.style;Pe.bottom=S,Pe.width=W!=null?W:""}if(c&&b!=="fullscreen"){if(b==="modal"){se.top="50%",se.left="50%",se.transform="translate(-50%, -50%)",se.bottom="auto",se.right="auto",se.width=G,se.maxWidth=Se,se.maxHeight=N,se.height=N;return}se.left="50%",se.transform="translateX(-50%)",se.bottom=`calc(${S} + ${xe})`,se.top=q,se.width=F,se.maxWidth=Se}},Wn=()=>{var N,Se,xe,se,ke,Ge,Te,ft;if(!I())return;if(H()){let bt=(xe=((Se=(N=o.launcher)==null?void 0:N.composerBar)!=null?Se:{}).expandedSize)!=null?xe:"anchored",vt=P?"expanded":"collapsed";De.dataset.state=vt,De.dataset.expandedSize=bt,nt&&(nt.dataset.state=vt,nt.dataset.expandedSize=bt),De.style.removeProperty("display"),De.classList.remove("persona-pointer-events-none","persona-opacity-0"),le.classList.remove("persona-scale-95","persona-opacity-0","persona-scale-100","persona-opacity-100"),Ri(P),K.style.display=P?"flex":"none",to(),P?(Ei(),Li()):(ws(),As()),xn();return}let c=Lr(o),g=(se=r.ownerDocument.defaultView)!=null?se:window,b=(Ge=(ke=o.launcher)==null?void 0:ke.mobileBreakpoint)!=null?Ge:640,S=(ft=(Te=o.launcher)==null?void 0:Te.mobileFullscreen)!=null?ft:!0,W=g.innerWidth<=b,F=S&&W&&M,q=Bo(o).reveal;P?(De.style.removeProperty("display"),De.style.display=c?"flex":"",De.classList.remove("persona-pointer-events-none","persona-opacity-0"),le.classList.remove("persona-scale-95","persona-opacity-0"),le.classList.add("persona-scale-100","persona-opacity-100"),xr?xr.element.style.display="none":yr&&(yr.style.display="none")):(c?c&&(q==="overlay"||q==="push")&&!F?(De.style.removeProperty("display"),De.style.display="flex",De.classList.remove("persona-pointer-events-none","persona-opacity-0"),le.classList.remove("persona-scale-100","persona-opacity-100","persona-scale-95","persona-opacity-0")):(De.style.setProperty("display","none","important"),De.classList.remove("persona-pointer-events-none","persona-opacity-0"),le.classList.remove("persona-scale-100","persona-opacity-100","persona-scale-95","persona-opacity-0")):(De.style.display="",De.classList.add("persona-pointer-events-none","persona-opacity-0"),le.classList.remove("persona-scale-100","persona-opacity-100"),le.classList.add("persona-scale-95","persona-opacity-0")),xr?xr.element.style.display=c?"none":"":yr&&(yr.style.display=c?"none":""))},Gt=(c,g="user")=>{var F,q;if(!I()||P===c)return;let b=P;P=c,Wn();let S=(()=>{var Te,ft,Ze,bt,vt,He,Pe,Qe,ot,Ht;let G=(ft=(Te=o.launcher)==null?void 0:Te.sidebarMode)!=null?ft:!1,N=(Ze=r.ownerDocument.defaultView)!=null?Ze:window,Se=(vt=(bt=o.launcher)==null?void 0:bt.mobileFullscreen)!=null?vt:!0,xe=(Pe=(He=o.launcher)==null?void 0:He.mobileBreakpoint)!=null?Pe:640,se=N.innerWidth<=xe,ke=Lr(o)&&Se&&se,Ge=H()&&((Ht=(ot=(Qe=o.launcher)==null?void 0:Qe.composerBar)==null?void 0:ot.expandedSize)!=null?Ht:"fullscreen")==="fullscreen";return G||Se&&se&&M||ke||Ge})();if(P&&S){if(!re){let G=r.getRootNode(),N=G instanceof ShadowRoot?G.host:r.closest(".persona-host");N&&(re=Jp(N,(q=(F=o.launcher)==null?void 0:F.zIndex)!=null?q:so))}A||(A=Zp(r.ownerDocument))}else P||(re==null||re(),re=null,A==null||A(),A=null);P&&(Ms(),xt()==="follow"?ln(!0):vs());let W={open:P,source:g,timestamp:Date.now()};P&&!b?a.emit("widget:opened",W):!P&&b&&a.emit("widget:closed",W),a.emit("widget:state",{open:P,launcherEnabled:M,voiceActive:Lt.active,streaming:U.isStreaming()})},Da=c=>{or(c?"stop":"send"),X&&(X.disabled=c),at.buttons.forEach(g=>{g.disabled=c}),ze.dataset.personaComposerStreaming=c?"true":"false",ze.querySelectorAll("[data-persona-composer-disable-when-streaming]").forEach(g=>{(g instanceof HTMLButtonElement||g instanceof HTMLInputElement||g instanceof HTMLTextAreaElement||g instanceof HTMLSelectElement)&&(g.disabled=c)})},Oa=()=>{Lt.active||te&&te.focus()};a.on("widget:opened",()=>{o.autoFocusInput&&setTimeout(()=>Oa(),200)});let ea=()=>{var b,S,W,F,q,G,N,Se,xe,se,ke;Yr.textContent=(S=(b=o.copy)==null?void 0:b.welcomeTitle)!=null?S:"Hello \u{1F44B}",zr.textContent=(F=(W=o.copy)==null?void 0:W.welcomeSubtitle)!=null?F:"Ask anything about your account or products.",te.placeholder=(G=(q=o.copy)==null?void 0:q.inputPlaceholder)!=null?G:"How can I help...";let c=he.querySelector("[data-persona-intro-card]");if(c){let Ge=((N=o.copy)==null?void 0:N.showWelcomeCard)!==!1;c.style.display=Ge?"":"none",Ge?(he.classList.remove("persona-gap-3"),he.classList.add("persona-gap-6")):(he.classList.remove("persona-gap-6"),he.classList.add("persona-gap-3"))}!((xe=(Se=o.sendButton)==null?void 0:Se.useIcon)!=null&&xe)&&!(U!=null&&U.isStreaming())&&(_e.textContent=(ke=(se=o.copy)==null?void 0:se.sendButtonLabel)!=null?ke:"Send"),te.style.fontFamily='var(--persona-input-font-family, var(--persona-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif))',te.style.fontWeight="var(--persona-input-font-weight, var(--persona-font-weight, 400))"};o.clientToken&&(o={...o,getStoredSessionId:()=>{let c=d.sessionId;return typeof c=="string"?c:null},setStoredSessionId:c=>{m(g=>({...g,sessionId:c}))}});let Ke=null,R=()=>{Ke==null&&(Ke=setInterval(()=>{let c=it.querySelectorAll("[data-tool-elapsed]");if(c.length===0){clearInterval(Ke),Ke=null;return}let g=Date.now();c.forEach(b=>{let S=Number(b.getAttribute("data-tool-elapsed"));S&&(b.textContent=Zi(g-S))})},100))};if(U=new Za(o,{onMessagesChanged(c){var S;Zn(it,c,ve),R(),nr(c),ln(!mr),ki(c);let g=[...c].reverse().find(W=>W.role==="user");c.length===0&&Jn(),!Pa||Yn?(Pa=!0,Ra=(S=g==null?void 0:g.id)!=null?S:null):g&&g.id!==Ra&&(Ra=g.id,Mi(g.id));let b=Lt.lastUserMessageId;g&&g.id!==b&&(Lt.lastUserMessageId=g.id,a.emit("user:message",g)),Lt.lastUserMessageWasVoice=!!(g!=null&&g.viaVoice),Wa(c),xn()},onStatusChanged(c){var S;let g=(S=o.statusIndicator)!=null?S:{};Ye(dr,(W=>{var F,q,G,N;return W==="idle"?(F=g.idleText)!=null?F:ao.idle:W==="connecting"?(q=g.connectingText)!=null?q:ao.connecting:W==="connected"?(G=g.connectedText)!=null?G:ao.connected:W==="error"?(N=g.errorText)!=null?N:ao.error:ao[W]})(c),g,c)},onStreamingChanged(c){mr=c,Da(c),U&&Zn(it,U.getMessages(),ve),c||ln(!0),xn()},onVoiceStatusChanged(c){var g,b;if(((b=(g=o.voiceRecognition)==null?void 0:g.provider)==null?void 0:b.type)==="runtype")switch(c){case"listening":break;case"processing":Bn(),rb();break;case"speaking":Bn(),ob();break;default:c==="idle"&&U.isBargeInActive()?(Bn(),Ts(),X==null||X.setAttribute("aria-label","End voice session")):(Lt.active=!1,Bn(),zo("system"),So());break}},onArtifactsState(c){po=c,eo(),Wa()}}),Wt.current=U,Pa=!0,((Bf=(Wf=o.voiceRecognition)==null?void 0:Wf.provider)==null?void 0:Bf.type)==="runtype")try{U.setupVoice()}catch(c){typeof console!="undefined"&&console.warn("[AgentWidget] Runtype voice setup failed:",c)}o.clientToken&&U.initClientSession().catch(c=>{o.debug&&console.warn("[AgentWidget] Pre-init client session failed:",c)}),(be||o.onSSEEvent)&&U.setSSEEventCallback((c,g)=>{var b;(b=o.onSSEEvent)==null||b.call(o,c,g),ye==null||ye.processEvent(c,g),be==null||be.push({id:`evt-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,type:c,timestamp:Date.now(),payload:JSON.stringify(g)})}),l&&l.then(c=>{var g,b,S;if(c){if(c.metadata&&(d=gu(c.metadata),T.syncFromMetadata()),(g=c.messages)!=null&&g.length){Yn=!0;try{U.hydrateMessages(c.messages)}finally{Yn=!1}}(b=c.artifacts)!=null&&b.length&&U.hydrateArtifacts(c.artifacts,(S=c.selectedArtifactId)!=null?S:null)}}).catch(c=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to hydrate stored state:",c)});let V=()=>{var g,b,S;!H()||P||!((S=(b=(g=o.launcher)==null?void 0:g.composerBar)==null?void 0:b.expandOnSubmit)==null||S)||Gt(!0,"auto")},B=c=>{var W;if(c.preventDefault(),U.isStreaming()){U.cancel(),ye==null||ye.reset(),Y==null||Y.update();return}let g=te.value.trim(),b=(W=je==null?void 0:je.hasAttachments())!=null?W:!1;if(!g&&!b)return;V();let S;b&&(S=[],S.push(...je.getContentParts()),g&&S.push(Qs(g))),te.value="",te.style.height="auto",Le(),U.sendMessage(g,{contentParts:S}),b&&je.clearAttachments()},oe=()=>{var c;return((c=o.features)==null?void 0:c.composerHistory)!==!1},pe={...Pl},J=!1,Le=()=>{pe={...Pl}},Ve=()=>U.getMessages().filter(c=>c.role==="user").map(c=>{var g;return(g=c.content)!=null?g:""}).filter(c=>c.length>0),yt=c=>{if(!te)return;J=!0,te.value=c,te.dispatchEvent(new Event("input",{bubbles:!0})),J=!1;let g=te.value.length;te.setSelectionRange(g,g)},dt=()=>{J||Le()},Vt=c=>{if(te){if(oe()&&(c.key==="ArrowUp"||c.key==="ArrowDown")&&!c.shiftKey&&!c.metaKey&&!c.ctrlKey&&!c.altKey&&!c.isComposing){let g=te.selectionStart===0&&te.selectionEnd===0,b=wx({direction:c.key==="ArrowUp"?"up":"down",history:Ve(),currentValue:te.value,atStart:g,state:pe});if(pe=b.state,b.handled){c.preventDefault(),b.value!==void 0&&yt(b.value);return}}if(c.key==="Enter"&&!c.shiftKey){if(U.isStreaming()){c.preventDefault();return}Le(),c.preventDefault(),_e.click()}}},Jt=c=>{c.key!=="Escape"||c.isComposing||U.isStreaming()&&c.composedPath().includes(K)&&(U.cancel(),ye==null||ye.reset(),Y==null||Y.update(),Le(),c.preventDefault(),c.stopImmediatePropagation())},Rr=async c=>{var b;if(((b=o.attachments)==null?void 0:b.enabled)!==!0||!je)return;let g=JC(c.clipboardData);g.length!==0&&(c.preventDefault(),await je.handleFiles(g))},ht=null,kt=!1,gr=null,et=null,jr=()=>typeof window=="undefined"?null:window.webkitSpeechRecognition||window.SpeechRecognition||null,pr=(c="user")=>{var F,q,G,N,Se,xe,se;if(kt||U.isStreaming())return;let g=jr();if(!g)return;ht=new g;let S=(q=((F=o.voiceRecognition)!=null?F:{}).pauseDuration)!=null?q:2e3;ht.continuous=!0,ht.interimResults=!0,ht.lang="en-US";let W=te.value;ht.onresult=ke=>{let Ge="",Te="";for(let Ze=0;Ze<ke.results.length;Ze++){let bt=ke.results[Ze],vt=bt[0].transcript;bt.isFinal?Ge+=vt+" ":Te=vt}let ft=W+Ge+Te;te.value=ft,gr&&clearTimeout(gr),(Ge||Te)&&(gr=window.setTimeout(()=>{let Ze=te.value.trim();Ze&&ht&&kt&&(Ur(),te.value="",te.style.height="auto",U.sendMessage(Ze,{viaVoice:!0}))},S))},ht.onerror=ke=>{ke.error!=="no-speech"&&Ur()},ht.onend=()=>{if(kt){let ke=te.value.trim();ke&&ke!==W.trim()&&(te.value="",te.style.height="auto",U.sendMessage(ke,{viaVoice:!0})),Ur()}};try{if(ht.start(),kt=!0,Lt.active=!0,c!=="system"&&(Lt.manuallyDeactivated=!1),zo(c),So(),X){let ke=(G=o.voiceRecognition)!=null?G:{};et={backgroundColor:X.style.backgroundColor,color:X.style.color,borderColor:X.style.borderColor,iconName:(N=ke.iconName)!=null?N:"mic",iconSize:parseFloat((se=(xe=ke.iconSize)!=null?xe:(Se=o.sendButton)==null?void 0:Se.size)!=null?se:"40")||24};let Ge=ke.recordingBackgroundColor,Te=ke.recordingIconColor,ft=ke.recordingBorderColor;if(X.classList.add("persona-voice-recording"),X.style.backgroundColor=Ge!=null?Ge:"var(--persona-voice-recording-bg, #ef4444)",X.style.color=Te!=null?Te:"var(--persona-voice-recording-indicator, #ffffff)",Te){let Ze=X.querySelector("svg");Ze&&Ze.setAttribute("stroke",Te)}ft&&(X.style.borderColor=ft),X.setAttribute("aria-label","Stop voice recognition")}}catch{Ur("system")}},Ur=(c="user")=>{if(kt){if(kt=!1,gr&&(clearTimeout(gr),gr=null),ht){try{ht.stop()}catch{}ht=null}if(Lt.active=!1,zo(c),So(),X){if(X.classList.remove("persona-voice-recording"),et){X.style.backgroundColor=et.backgroundColor,X.style.color=et.color,X.style.borderColor=et.borderColor;let g=X.querySelector("svg");g&&g.setAttribute("stroke",et.color||"currentColor"),et=null}X.setAttribute("aria-label","Start voice recognition")}}},tb=(c,g)=>{var bt,vt,He,Pe,Qe,ot,Ht,D;let b=typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined"),S=((bt=c==null?void 0:c.provider)==null?void 0:bt.type)==="runtype";if(!(b||S))return null;let F=C("div","persona-send-button-wrapper"),q=C("button","persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer");q.type="button",q.setAttribute("aria-label","Start voice recognition");let G=(vt=c==null?void 0:c.iconName)!=null?vt:"mic",N=(He=g==null?void 0:g.size)!=null?He:"40px",Se=(Pe=c==null?void 0:c.iconSize)!=null?Pe:N,xe=parseFloat(Se)||24,se=(Qe=c==null?void 0:c.backgroundColor)!=null?Qe:g==null?void 0:g.backgroundColor,ke=(ot=c==null?void 0:c.iconColor)!=null?ot:g==null?void 0:g.textColor;q.style.width=Se,q.style.height=Se,q.style.minWidth=Se,q.style.minHeight=Se,q.style.fontSize="18px",q.style.lineHeight="1",ke?q.style.color=ke:q.style.color="var(--persona-text, #111827)";let Te=Ee(G,xe,ke||"currentColor",1.5);Te?q.appendChild(Te):q.textContent="\u{1F3A4}",se?q.style.backgroundColor=se:q.style.backgroundColor="",c!=null&&c.borderWidth&&(q.style.borderWidth=c.borderWidth,q.style.borderStyle="solid"),c!=null&&c.borderColor&&(q.style.borderColor=c.borderColor),c!=null&&c.paddingX&&(q.style.paddingLeft=c.paddingX,q.style.paddingRight=c.paddingX),c!=null&&c.paddingY&&(q.style.paddingTop=c.paddingY,q.style.paddingBottom=c.paddingY),F.appendChild(q);let ft=(Ht=c==null?void 0:c.tooltipText)!=null?Ht:"Start voice recognition";if(((D=c==null?void 0:c.showTooltip)!=null?D:!1)&&ft){let Ne=C("div","persona-send-button-tooltip");Ne.textContent=ft,F.appendChild(Ne)}return{micButton:q,micButtonWrapper:F}},cd=()=>{var g,b,S,W,F;if(!X||et)return;let c=(g=o.voiceRecognition)!=null?g:{};et={backgroundColor:X.style.backgroundColor,color:X.style.color,borderColor:X.style.borderColor,iconName:(b=c.iconName)!=null?b:"mic",iconSize:parseFloat((F=(W=c.iconSize)!=null?W:(S=o.sendButton)==null?void 0:S.size)!=null?F:"40")||24}},pd=(c,g)=>{var F,q,G,N,Se;if(!X)return;let b=X.querySelector("svg");b&&b.remove();let S=(Se=et==null?void 0:et.iconSize)!=null?Se:parseFloat((N=(G=(F=o.voiceRecognition)==null?void 0:F.iconSize)!=null?G:(q=o.sendButton)==null?void 0:q.size)!=null?N:"40")||24,W=Ee(c,S,g,1.5);W&&X.appendChild(W)},Ii=()=>{X&&X.classList.remove("persona-voice-recording","persona-voice-processing","persona-voice-speaking")},Ts=()=>{var W;if(!X)return;cd();let c=(W=o.voiceRecognition)!=null?W:{},g=c.recordingBackgroundColor,b=c.recordingIconColor,S=c.recordingBorderColor;if(Ii(),X.classList.add("persona-voice-recording"),X.style.backgroundColor=g!=null?g:"var(--persona-voice-recording-bg, #ef4444)",X.style.color=b!=null?b:"var(--persona-voice-recording-indicator, #ffffff)",b){let F=X.querySelector("svg");F&&F.setAttribute("stroke",b)}S&&(X.style.borderColor=S),X.setAttribute("aria-label","Stop voice recognition")},rb=()=>{var G,N,Se,xe,se,ke,Ge,Te;if(!X)return;cd();let c=(G=o.voiceRecognition)!=null?G:{},g=U.getVoiceInterruptionMode(),b=(N=c.processingIconName)!=null?N:"loader",S=(xe=(Se=c.processingIconColor)!=null?Se:et==null?void 0:et.color)!=null?xe:"",W=(ke=(se=c.processingBackgroundColor)!=null?se:et==null?void 0:et.backgroundColor)!=null?ke:"",F=(Te=(Ge=c.processingBorderColor)!=null?Ge:et==null?void 0:et.borderColor)!=null?Te:"";Ii(),X.classList.add("persona-voice-processing"),X.style.backgroundColor=W,X.style.borderColor=F;let q=S||"currentColor";X.style.color=q,pd(b,q),X.setAttribute("aria-label","Processing voice input"),g==="none"&&(X.style.cursor="default")},ob=()=>{var Se,xe,se,ke,Ge,Te,ft,Ze,bt,vt,He,Pe;if(!X)return;cd();let c=(Se=o.voiceRecognition)!=null?Se:{},g=U.getVoiceInterruptionMode(),b=g==="cancel"?"square":g==="barge-in"?"mic":"volume-2",S=(xe=c.speakingIconName)!=null?xe:b,W=(Te=c.speakingIconColor)!=null?Te:g==="barge-in"?(ke=(se=c.recordingIconColor)!=null?se:et==null?void 0:et.color)!=null?ke:"":(Ge=et==null?void 0:et.color)!=null?Ge:"",F=(bt=c.speakingBackgroundColor)!=null?bt:g==="barge-in"?(ft=c.recordingBackgroundColor)!=null?ft:"var(--persona-voice-recording-bg, #ef4444)":(Ze=et==null?void 0:et.backgroundColor)!=null?Ze:"",q=(Pe=c.speakingBorderColor)!=null?Pe:g==="barge-in"?(vt=c.recordingBorderColor)!=null?vt:"":(He=et==null?void 0:et.borderColor)!=null?He:"";Ii(),X.classList.add("persona-voice-speaking"),X.style.backgroundColor=F,X.style.borderColor=q;let G=W||"currentColor";X.style.color=G,pd(S,G);let N=g==="cancel"?"Stop playback and re-record":g==="barge-in"?"Speak to interrupt":"Agent is speaking";X.setAttribute("aria-label",N),g==="none"&&(X.style.cursor="default"),g==="barge-in"&&X.classList.add("persona-voice-recording")},Bn=()=>{var c,g,b;X&&(Ii(),et&&(X.style.backgroundColor=(c=et.backgroundColor)!=null?c:"",X.style.color=(g=et.color)!=null?g:"",X.style.borderColor=(b=et.borderColor)!=null?b:"",pd(et.iconName,et.color||"currentColor"),et=null),X.style.cursor="",X.setAttribute("aria-label","Start voice recognition"))},Hi=()=>{var c,g;if(((g=(c=o.voiceRecognition)==null?void 0:c.provider)==null?void 0:g.type)==="runtype"){let b=U.getVoiceStatus(),S=U.getVoiceInterruptionMode();if(S==="none"&&(b==="processing"||b==="speaking"))return;if(S==="cancel"&&(b==="processing"||b==="speaking")){U.stopVoicePlayback();return}if(U.isBargeInActive()){U.stopVoicePlayback(),U.deactivateBargeIn().then(()=>{Lt.active=!1,Lt.manuallyDeactivated=!0,So(),zo("user"),Bn()});return}U.toggleVoice().then(()=>{Lt.active=U.isVoiceActive(),Lt.manuallyDeactivated=!U.isVoiceActive(),So(),zo("user"),U.isVoiceActive()?Ts():Bn()});return}if(kt){let b=te.value.trim();Lt.manuallyDeactivated=!0,So(),Ur("user"),b&&(te.value="",te.style.height="auto",U.sendMessage(b))}else Lt.manuallyDeactivated=!1,So(),pr("user")};Tr=Hi,X&&(X.addEventListener("click",Hi),gt.push(()=>{var c,g;((g=(c=o.voiceRecognition)==null?void 0:c.provider)==null?void 0:g.type)==="runtype"?(U.isVoiceActive()&&U.toggleVoice(),Bn()):Ur("system"),X&&X.removeEventListener("click",Hi)}));let nb=a.on("assistant:complete",()=>{fs&&(Lt.active||Lt.manuallyDeactivated||fs==="assistant"&&!Lt.lastUserMessageWasVoice||setTimeout(()=>{var c,g;!Lt.active&&!Lt.manuallyDeactivated&&(((g=(c=o.voiceRecognition)==null?void 0:c.provider)==null?void 0:g.type)==="runtype"?U.toggleVoice().then(()=>{Lt.active=U.isVoiceActive(),zo("auto"),U.isVoiceActive()&&Ts()}):pr("auto"))},600))});gt.push(nb);let ab=a.on("action:resubmit",()=>{setTimeout(()=>{U&&!U.isStreaming()&&U.continueConversation()},100)});gt.push(ab);let _a=()=>{Gt(!P,"user")},xr=null,yr=null;if(M&&!H()){let c=n.find(g=>g.renderLauncher);if(c!=null&&c.renderLauncher){let g=c.renderLauncher({config:o,defaultRenderer:()=>di(o,_a).element,onToggle:_a});g&&(yr=g)}yr||(xr=di(o,_a))}xr?r.appendChild(xr.element):yr&&r.appendChild(yr),Wn(),nr(),ea(),Da(U.isStreaming()),xt()==="follow"?ln(!0):vs(),Ci(),L&&(!M||H()?setTimeout(()=>Oa(),0):P&&setTimeout(()=>Oa(),200));let Ms=()=>{var N,Se,xe,se,ke,Ge,Te,ft,Ze,bt,vt,He,Pe,Qe,ot,Ht,D,Ne,Fe,we,Qt,Kt;if(H()){Sr(),Wn();return}let c=Lr(o),g=(Se=(N=o.launcher)==null?void 0:N.sidebarMode)!=null?Se:!1,b=c||g||((se=(xe=o.launcher)==null?void 0:xe.fullHeight)!=null?se:!1),S=(ke=r.ownerDocument.defaultView)!=null?ke:window,W=(Te=(Ge=o.launcher)==null?void 0:Ge.mobileFullscreen)!=null?Te:!0,F=(Ze=(ft=o.launcher)==null?void 0:ft.mobileBreakpoint)!=null?Ze:640,q=S.innerWidth<=F,G=W&&q&&M;try{if(G){to(),Vn(r,o);return}if(E&&(E=!1,to(),Vn(r,o)),!M&&!c){le.style.height="",le.style.width="";return}if(!g&&!c){let ir=(vt=(bt=o==null?void 0:o.launcher)==null?void 0:bt.width)!=null?vt:o==null?void 0:o.launcherWidth,Bt=ir!=null?ir:Wo;le.style.width=Bt,le.style.maxWidth=Bt}if(qo(),!b){let ir=S.innerHeight,Bt=64,ar=(Pe=(He=o.launcher)==null?void 0:He.heightOffset)!=null?Pe:0,Po=Math.max(200,ir-Bt),wr=Math.min(640,Po),st=Math.max(200,wr-ar);le.style.height=`${st}px`}}finally{if(Sr(),Wn(),P&&M){let Bt=((Qe=r.ownerDocument.defaultView)!=null?Qe:window).innerWidth<=((Ht=(ot=o.launcher)==null?void 0:ot.mobileBreakpoint)!=null?Ht:640),ar=(Ne=(D=o.launcher)==null?void 0:D.sidebarMode)!=null?Ne:!1,Po=(we=(Fe=o.launcher)==null?void 0:Fe.mobileFullscreen)!=null?we:!0,wr=Lr(o)&&Po&&Bt,st=ar||Po&&Bt&&M||wr;if(st&&!A){let Ut=r.getRootNode(),kr=Ut instanceof ShadowRoot?Ut.host:r.closest(".persona-host");kr&&!re&&(re=Jp(kr,(Kt=(Qt=o.launcher)==null?void 0:Qt.zIndex)!=null?Kt:so)),A=Zp(r.ownerDocument)}else st||(re==null||re(),re=null,A==null||A(),A=null)}}};Ms();let Iu=(Df=r.ownerDocument.defaultView)!=null?Df:window;if(Iu.addEventListener("resize",Ms),gt.push(()=>Iu.removeEventListener("resize",Ms)),typeof ResizeObserver!="undefined"){let c=new ResizeObserver(()=>{Sr()});c.observe(ze),gt.push(()=>c.disconnect())}Lo=he.scrollTop;let Hu=Mn(he),sb=()=>{let c=he.getRootNode(),g=typeof c.getSelection=="function"?c.getSelection():null;return g!=null?g:he.ownerDocument.getSelection()},ud=()=>Ex(sb(),he),Wu=()=>{let c=he.scrollTop,g=Mn(he),b=g<Hu;if(Hu=g,xt()!=="follow"){Lo=c,To();return}let{action:S,nextLastScrollTop:W}=Il({following:Eo.isFollowing(),currentScrollTop:c,lastScrollTop:Lo,nearBottom:Aa(he,Ia),userScrollThreshold:bi,isAutoScrolling:Qo||Qn||b,pauseOnUpwardScroll:!0,pauseWhenAwayFromBottom:!1,resumeRequiresDownwardScroll:!0});if(Lo=W,S==="resume"){ud()||sn();return}S==="pause"&&Ba()};if(he.addEventListener("scroll",Wu,{passive:!0}),gt.push(()=>he.removeEventListener("scroll",Wu)),typeof ResizeObserver!="undefined"){let c=new ResizeObserver(()=>{Ti()});c.observe(it),c.observe(he),gt.push(()=>c.disconnect())}let Bu=()=>{xt()==="follow"&&Eo.isFollowing()&&ud()&&Ba()},Du=he.ownerDocument;Du.addEventListener("selectionchange",Bu),gt.push(()=>{Du.removeEventListener("selectionchange",Bu)});let Ou=c=>{if(xt()!=="follow")return;let g=Hl({following:Eo.isFollowing(),deltaY:c.deltaY,nearBottom:Aa(he,Ia),resumeWhenNearBottom:!0});g==="pause"?Ba():g==="resume"&&!ud()&&sn()};he.addEventListener("wheel",Ou,{passive:!0}),gt.push(()=>he.removeEventListener("wheel",Ou)),tt.addEventListener("click",()=>{Jn(),he.scrollTop=he.scrollHeight,Lo=he.scrollTop,sn(),ln(!0),To()}),gt.push(()=>tt.remove()),gt.push(()=>{gs(),Jn()});let _u=()=>{O&&(ut&&(O.removeEventListener("click",ut),ut=null),I()?(O.style.display="",ut=()=>{Gt(!1,"user")},O.addEventListener("click",ut)):O.style.display="none")};_u(),(()=>{let{clearChatButton:c}=Re;c&&c.addEventListener("click",()=>{U.clearMessages(),Cr.clear(),sn(),zn(Re.composerOverlay);try{localStorage.removeItem(cs),o.debug&&console.log(`[AgentWidget] Cleared default localStorage key: ${cs}`)}catch(b){console.error("[AgentWidget] Failed to clear default localStorage:",b)}if(o.clearChatHistoryStorageKey&&o.clearChatHistoryStorageKey!==cs)try{localStorage.removeItem(o.clearChatHistoryStorageKey),o.debug&&console.log(`[AgentWidget] Cleared custom localStorage key: ${o.clearChatHistoryStorageKey}`)}catch(b){console.error("[AgentWidget] Failed to clear custom localStorage:",b)}let g=new CustomEvent("persona:clear-chat",{detail:{timestamp:new Date().toISOString()}});if(window.dispatchEvent(g),i!=null&&i.clear)try{let b=i.clear();b instanceof Promise&&b.catch(S=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear storage adapter:",S)})}catch(b){typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear storage adapter:",b)}d={},T.syncFromMetadata(),be==null||be.clear(),ye==null||ye.reset(),Y==null||Y.update()})})(),Rt&&Rt.addEventListener("submit",B),te==null||te.addEventListener("keydown",Vt),te==null||te.addEventListener("input",dt),te==null||te.addEventListener("paste",Rr);let Nu=(Of=r.ownerDocument)!=null?Of:document;Nu.addEventListener("keydown",Jt,!0);let Fu="persona-attachment-drop-active",ks=0,fd=()=>{ks=0,K.classList.remove(Fu)},Na=()=>{var c;return((c=o.attachments)==null?void 0:c.enabled)===!0&&je!==null},Uu=c=>{!ad(c.dataTransfer)||!Na()||(ks++,ks===1&&K.classList.add(Fu))},qu=c=>{!ad(c.dataTransfer)||!Na()||(ks--,ks<=0&&fd())},zu=c=>{!ad(c.dataTransfer)||!Na()||(c.preventDefault(),c.dataTransfer.dropEffect="copy")},$u=c=>{var b;if(!ad(c.dataTransfer)||!Na())return;c.preventDefault(),c.stopPropagation(),fd();let g=Array.from((b=c.dataTransfer.files)!=null?b:[]);g.length!==0&&je.handleFiles(g)},Dn=!0;K.addEventListener("dragenter",Uu,Dn),K.addEventListener("dragleave",qu,Dn),r.addEventListener("dragover",zu,Dn),r.addEventListener("drop",$u,Dn);let Wi=r.ownerDocument,Vu=c=>{Na()&&c.preventDefault()},ju=c=>{Na()&&c.preventDefault()};Wi.addEventListener("dragover",Vu),Wi.addEventListener("drop",ju),gt.push(()=>{Rt&&Rt.removeEventListener("submit",B),te==null||te.removeEventListener("keydown",Vt),te==null||te.removeEventListener("input",dt),te==null||te.removeEventListener("paste",Rr),Nu.removeEventListener("keydown",Jt,!0)}),gt.push(()=>{K.removeEventListener("dragenter",Uu,Dn),K.removeEventListener("dragleave",qu,Dn),r.removeEventListener("dragover",zu,Dn),r.removeEventListener("drop",$u,Dn),Wi.removeEventListener("dragover",Vu),Wi.removeEventListener("drop",ju),fd()}),gt.push(()=>{U.cancel()}),xr?gt.push(()=>{xr==null||xr.destroy()}):yr&>.push(()=>{yr==null||yr.remove()});let Mr={update(c){var oo,ho,dn,qr,xo,yo,aa,Es,$f,Vf,jf,Gf,Kf,Xf,Qf,Yf,Jf,Zf,em,tm,rm,om,nm,am,sm,im,lm,dm,cm,pm,um,fm,mm,gm,hm,xm,ym,bm,vm,Cm,wm,Am,Sm,Tm,Mm,km,Em,Lm,Pm,Rm,Im,Hm,Wm,Bm,Dm,Om,_m,Nm,Fm,Um,qm,zm,$m,Vm,jm,Gm,Km,Xm,Qm,Ym,Jm,Zm,eg,tg,rg,og,ng,ag,sg,ig,lg,dg,cg,pg,ug,fg,mg,gg,hg,xg,yg,bg,vg,Cg,wg,Ag,Sg,Tg,Mg,kg,Eg,Lg,Pg,Rg,Ig,Hg,Wg,Bg,Dg,Og,_g,Ng,Fg,Ug,qg;let g=o.toolCall,b=o.messageActions,S=(oo=o.layout)==null?void 0:oo.messages,W=o.colorScheme,F=o.loadingIndicator,q=o.iterationDisplay,G=(ho=o.features)==null?void 0:ho.showReasoning,N=(dn=o.features)==null?void 0:dn.showToolCalls,Se=(qr=o.features)==null?void 0:qr.toolCallDisplay,xe=(xo=o.features)==null?void 0:xo.reasoningDisplay;o={...o,...c},to(),Vn(r,o),Ql(r,o),Yl(r,o),eo(),o.colorScheme!==W&&ue();let se=mi.getForInstance(o.plugins);n.length=0,n.push(...se),M=(aa=(yo=o.launcher)==null?void 0:yo.enabled)!=null?aa:!0,k=($f=(Es=o.launcher)==null?void 0:Es.autoExpand)!=null?$f:!1,Xe=(jf=(Vf=o.features)==null?void 0:Vf.showReasoning)!=null?jf:!0,Ae=(Kf=(Gf=o.features)==null?void 0:Gf.showToolCalls)!=null?Kf:!0,Me=(Qf=(Xf=o.features)==null?void 0:Xf.scrollToBottom)!=null?Qf:{};let ke=xt();Ue=(Jf=(Yf=o.features)==null?void 0:Yf.scrollBehavior)!=null?Jf:{},ke!==xt()&&(Jn(),sn()),Oo(),To();let Ge=We;if(We=(em=(Zf=o.features)==null?void 0:Zf.showEventStreamToggle)!=null?em:!1,We&&!Ge){if(be||(ne=new ui(Z),be=new pi(me,ne),ye=ye!=null?ye:new fi,ne.open().then(()=>be==null?void 0:be.restore()).catch(()=>{}),U.setSSEEventCallback((ee,Ot)=>{var er;(er=o.onSSEEvent)==null||er.call(o,ee,Ot),ye==null||ye.processEvent(ee,Ot),be.push({id:`evt-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,type:ee,timestamp:Date.now(),payload:JSON.stringify(Ot)})})),!At&&qe){let ee=(rm=(tm=o.features)==null?void 0:tm.eventStream)==null?void 0:rm.classNames,Ot="persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-opacity-80 persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-1"+(ee!=null&&ee.toggleButton?" "+ee.toggleButton:"");At=C("button",Ot),At.style.width="28px",At.style.height="28px",At.style.color=Ao.actionIconColor,At.type="button",At.setAttribute("aria-label","Event Stream"),At.title="Event Stream";let er=Ee("activity","18px","currentColor",1.5);er&&At.appendChild(er);let Ct=Re.clearChatButtonWrapper,qt=Re.closeButtonWrapper,Hr=Ct||qt;Hr&&Hr.parentNode===qe?qe.insertBefore(At,Hr):qe.appendChild(At),At.addEventListener("click",()=>{ge?lo():_o()})}}else!We&&Ge&&(lo(),At&&(At.remove(),At=null),be==null||be.clear(),ne==null||ne.destroy(),be=null,ne=null,ye==null||ye.reset(),ye=null);if(((om=o.launcher)==null?void 0:om.enabled)===!1&&xr&&(xr.destroy(),xr=null),((nm=o.launcher)==null?void 0:nm.enabled)===!1&&yr&&(yr.remove(),yr=null),((am=o.launcher)==null?void 0:am.enabled)!==!1&&!xr&&!yr){let ee=n.find(Ot=>Ot.renderLauncher);if(ee!=null&&ee.renderLauncher){let Ot=ee.renderLauncher({config:o,defaultRenderer:()=>di(o,_a).element,onToggle:_a});Ot&&(yr=Ot,r.appendChild(yr))}yr||(xr=di(o,_a),r.appendChild(xr.element))}xr&&xr.update(o),Ie&&((sm=o.launcher)==null?void 0:sm.title)!==void 0&&(Ie.textContent=o.launcher.title),Je&&((im=o.launcher)==null?void 0:im.subtitle)!==void 0&&(Je.textContent=o.launcher.subtitle);let Te=(lm=o.layout)==null?void 0:lm.header;if((Te==null?void 0:Te.layout)!==v&&qe){let ee=Te?os(o,Te,{showClose:I(),onClose:()=>Gt(!1,"user")}):kn({config:o,showClose:I(),onClose:()=>Gt(!1,"user")});qe.replaceWith(ee.header),qe=ee.header,fe=ee.iconHolder,Ie=ee.headerTitle,Je=ee.headerSubtitle,O=ee.closeButton,v=Te==null?void 0:Te.layout}else if(Te&&(fe&&(fe.style.display=Te.showIcon===!1?"none":""),Ie&&(Ie.style.display=Te.showTitle===!1?"none":""),Je&&(Je.style.display=Te.showSubtitle===!1?"none":""),O&&(O.style.display=Te.showCloseButton===!1?"none":""),Re.clearChatButtonWrapper)){let ee=Te.showClearChat;if(ee!==void 0){Re.clearChatButtonWrapper.style.display=ee?"":"none";let{closeButtonWrapper:Ot}=Re;Ot&&!Ot.classList.contains("persona-absolute")&&(ee?Ot.classList.remove("persona-ml-auto"):Ot.classList.add("persona-ml-auto"))}}let Ze=((dm=o.layout)==null?void 0:dm.showHeader)!==!1;qe&&(qe.style.display=Ze?"":"none");let bt=((cm=o.layout)==null?void 0:cm.showFooter)!==!1;ze&&(ze.style.display=bt?"":"none"),Sr(),To(),M!==w?M?Gt(k,"auto"):(P=!0,Wn()):k!==x&&Gt(k,"auto"),x=k,w=M,Ms(),_u();let Pe=JSON.stringify(c.toolCall)!==JSON.stringify(g),Qe=JSON.stringify(o.messageActions)!==JSON.stringify(b),ot=JSON.stringify((pm=o.layout)==null?void 0:pm.messages)!==JSON.stringify(S),Ht=((um=o.loadingIndicator)==null?void 0:um.render)!==(F==null?void 0:F.render)||((fm=o.loadingIndicator)==null?void 0:fm.renderIdle)!==(F==null?void 0:F.renderIdle)||((mm=o.loadingIndicator)==null?void 0:mm.showBubble)!==(F==null?void 0:F.showBubble),D=o.iterationDisplay!==q,Ne=((hm=(gm=o.features)==null?void 0:gm.showReasoning)!=null?hm:!0)!==(G!=null?G:!0)||((ym=(xm=o.features)==null?void 0:xm.showToolCalls)!=null?ym:!0)!==(N!=null?N:!0)||JSON.stringify((bm=o.features)==null?void 0:bm.toolCallDisplay)!==JSON.stringify(Se)||JSON.stringify((vm=o.features)==null?void 0:vm.reasoningDisplay)!==JSON.stringify(xe);(Pe||Qe||ot||Ht||D||Ne)&&U&&(us++,Zn(it,U.getMessages(),ve));let we=(Cm=o.launcher)!=null?Cm:{},Qt=(wm=we.headerIconHidden)!=null?wm:!1,Kt=(Sm=(Am=o.layout)==null?void 0:Am.header)==null?void 0:Sm.showIcon,ir=Qt||Kt===!1,Bt=we.headerIconName,ar=(Tm=we.headerIconSize)!=null?Tm:"48px";if(fe){let ee=K.querySelector(".persona-border-b-persona-divider"),Ot=ee==null?void 0:ee.querySelector(".persona-flex-col");if(ir)fe.style.display="none",ee&&Ot&&!ee.contains(Ot)&&ee.insertBefore(Ot,ee.firstChild);else{if(fe.style.display="",fe.style.height=ar,fe.style.width=ar,ee&&Ot&&(ee.contains(fe)?fe.nextSibling!==Ot&&(fe.remove(),ee.insertBefore(fe,Ot)):ee.insertBefore(fe,Ot)),Bt){let Ct=parseFloat(ar)||24,qt=Ee(Bt,Ct*.6,"#ffffff",2);qt?fe.replaceChildren(qt):fe.textContent=(Mm=we.agentIconText)!=null?Mm:"\u{1F4AC}"}else if(we.iconUrl){let Ct=fe.querySelector("img");if(Ct)Ct.src=we.iconUrl,Ct.style.height=ar,Ct.style.width=ar;else{let qt=document.createElement("img");qt.src=we.iconUrl,qt.alt="",qt.className="persona-rounded-xl persona-object-cover",qt.style.height=ar,qt.style.width=ar,fe.replaceChildren(qt)}}else{let Ct=fe.querySelector("svg"),qt=fe.querySelector("img");(Ct||qt)&&fe.replaceChildren(),fe.textContent=(km=we.agentIconText)!=null?km:"\u{1F4AC}"}let er=fe.querySelector("img");er&&(er.style.height=ar,er.style.width=ar)}}let Po=(Lm=(Em=o.layout)==null?void 0:Em.header)==null?void 0:Lm.showTitle,wr=(Rm=(Pm=o.layout)==null?void 0:Pm.header)==null?void 0:Rm.showSubtitle;if(Ie&&(Ie.style.display=Po===!1?"none":""),Je&&(Je.style.display=wr===!1?"none":""),O){((Hm=(Im=o.layout)==null?void 0:Im.header)==null?void 0:Hm.showCloseButton)===!1?O.style.display="none":O.style.display="";let Ot=(Wm=we.closeButtonSize)!=null?Wm:"32px",er=(Bm=we.closeButtonPlacement)!=null?Bm:"inline";O.style.height=Ot,O.style.width=Ot;let{closeButtonWrapper:Ct}=Re,qt=er==="top-right",Hr=Ct==null?void 0:Ct.classList.contains("persona-absolute");if(Ct&&qt!==Hr)if(Ct.remove(),qt)Ct.className="persona-absolute persona-top-4 persona-right-4 persona-z-50",K.style.position="relative",K.appendChild(Ct);else{let St=(Om=(Dm=we.clearChat)==null?void 0:Dm.placement)!=null?Om:"inline",Wr=(Nm=(_m=we.clearChat)==null?void 0:_m.enabled)!=null?Nm:!0;Ct.className=Wr&&St==="inline"?"":"persona-ml-auto";let Mo=K.querySelector(".persona-border-b-persona-divider");Mo&&Mo.appendChild(Ct)}if(O.style.color=we.closeButtonColor||Ao.actionIconColor,we.closeButtonBackgroundColor?(O.style.backgroundColor=we.closeButtonBackgroundColor,O.classList.remove("hover:persona-bg-gray-100")):(O.style.backgroundColor="",O.classList.add("hover:persona-bg-gray-100")),we.closeButtonBorderWidth||we.closeButtonBorderColor){let St=we.closeButtonBorderWidth||"0px",Wr=we.closeButtonBorderColor||"transparent";O.style.border=`${St} solid ${Wr}`,O.classList.remove("persona-border-none")}else O.style.border="",O.classList.add("persona-border-none");we.closeButtonBorderRadius?(O.style.borderRadius=we.closeButtonBorderRadius,O.classList.remove("persona-rounded-full")):(O.style.borderRadius="",O.classList.add("persona-rounded-full")),we.closeButtonPaddingX?(O.style.paddingLeft=we.closeButtonPaddingX,O.style.paddingRight=we.closeButtonPaddingX):(O.style.paddingLeft="",O.style.paddingRight=""),we.closeButtonPaddingY?(O.style.paddingTop=we.closeButtonPaddingY,O.style.paddingBottom=we.closeButtonPaddingY):(O.style.paddingTop="",O.style.paddingBottom="");let no=(Fm=we.closeButtonIconName)!=null?Fm:"x",Jo=(Um=we.closeButtonIconText)!=null?Um:"\xD7";O.innerHTML="";let bo=Ee(no,"28px","currentColor",1);bo?O.appendChild(bo):O.textContent=Jo;let br=(qm=we.closeButtonTooltipText)!=null?qm:"Close chat",Io=(zm=we.closeButtonShowTooltip)!=null?zm:!0;if(O.setAttribute("aria-label",br),Ct&&(Ct._cleanupTooltip&&(Ct._cleanupTooltip(),delete Ct._cleanupTooltip),Io&&br)){let St=null,Wr=()=>{if(St||!O)return;let sa=O.ownerDocument,Ls=sa.body;if(!Ls)return;St=un(sa,"div","persona-clear-chat-tooltip"),St.textContent=br;let Ps=un(sa,"div");Ps.className="persona-clear-chat-tooltip-arrow",St.appendChild(Ps);let ia=O.getBoundingClientRect();St.style.position="fixed",St.style.zIndex=String(jn),St.style.left=`${ia.left+ia.width/2}px`,St.style.top=`${ia.top-8}px`,St.style.transform="translate(-50%, -100%)",Ls.appendChild(St)},Mo=()=>{St&&St.parentNode&&(St.parentNode.removeChild(St),St=null)};Ct.addEventListener("mouseenter",Wr),Ct.addEventListener("mouseleave",Mo),O.addEventListener("focus",Wr),O.addEventListener("blur",Mo),Ct._cleanupTooltip=()=>{Mo(),Ct&&(Ct.removeEventListener("mouseenter",Wr),Ct.removeEventListener("mouseleave",Mo)),O&&(O.removeEventListener("focus",Wr),O.removeEventListener("blur",Mo))}}}let{clearChatButton:st,clearChatButtonWrapper:Ut}=Re;if(st){let ee=($m=we.clearChat)!=null?$m:{},Ot=(Vm=ee.enabled)!=null?Vm:!0,er=(Gm=(jm=o.layout)==null?void 0:jm.header)==null?void 0:Gm.showClearChat,Ct=er!==void 0?er:Ot,qt=(Km=ee.placement)!=null?Km:"inline";if(Ut){Ut.style.display=Ct?"":"none";let{closeButtonWrapper:Hr}=Re;!H()&&Hr&&!Hr.classList.contains("persona-absolute")&&(Ct?Hr.classList.remove("persona-ml-auto"):Hr.classList.add("persona-ml-auto"));let no=qt==="top-right",Jo=Ut.classList.contains("persona-absolute");if(!H()&&no!==Jo&&Ct){if(Ut.remove(),no)Ut.className="persona-absolute persona-top-4 persona-z-50",Ut.style.right="48px",K.style.position="relative",K.appendChild(Ut);else{Ut.className="persona-relative persona-ml-auto persona-clear-chat-button-wrapper",Ut.style.right="";let br=K.querySelector(".persona-border-b-persona-divider"),Io=Re.closeButtonWrapper;br&&Io&&Io.parentElement===br?br.insertBefore(Ut,Io):br&&br.appendChild(Ut)}let bo=Re.closeButtonWrapper;bo&&!bo.classList.contains("persona-absolute")&&(no?bo.classList.add("persona-ml-auto"):bo.classList.remove("persona-ml-auto"))}}if(Ct){if(!H()){let St=(Xm=ee.size)!=null?Xm:"32px";st.style.height=St,st.style.width=St}let Hr=(Qm=ee.iconName)!=null?Qm:"refresh-cw",no=(Ym=ee.iconColor)!=null?Ym:"";st.style.color=no||Ao.actionIconColor,st.innerHTML="";let Jo=H()?"14px":"20px",bo=Ee(Hr,Jo,"currentColor",2);if(bo&&st.appendChild(bo),ee.backgroundColor?(st.style.backgroundColor=ee.backgroundColor,st.classList.remove("hover:persona-bg-gray-100")):(st.style.backgroundColor="",st.classList.add("hover:persona-bg-gray-100")),ee.borderWidth||ee.borderColor){let St=ee.borderWidth||"0px",Wr=ee.borderColor||"transparent";st.style.border=`${St} solid ${Wr}`,st.classList.remove("persona-border-none")}else st.style.border="",st.classList.add("persona-border-none");ee.borderRadius?(st.style.borderRadius=ee.borderRadius,st.classList.remove("persona-rounded-full")):(st.style.borderRadius="",st.classList.add("persona-rounded-full")),ee.paddingX?(st.style.paddingLeft=ee.paddingX,st.style.paddingRight=ee.paddingX):(st.style.paddingLeft="",st.style.paddingRight=""),ee.paddingY?(st.style.paddingTop=ee.paddingY,st.style.paddingBottom=ee.paddingY):(st.style.paddingTop="",st.style.paddingBottom="");let br=(Jm=ee.tooltipText)!=null?Jm:"Clear chat",Io=(Zm=ee.showTooltip)!=null?Zm:!0;if(st.setAttribute("aria-label",br),Ut&&(Ut._cleanupTooltip&&(Ut._cleanupTooltip(),delete Ut._cleanupTooltip),Io&&br)){let St=null,Wr=()=>{if(St||!st)return;let sa=st.ownerDocument,Ls=sa.body;if(!Ls)return;St=un(sa,"div","persona-clear-chat-tooltip"),St.textContent=br;let Ps=un(sa,"div");Ps.className="persona-clear-chat-tooltip-arrow",St.appendChild(Ps);let ia=st.getBoundingClientRect();St.style.position="fixed",St.style.zIndex=String(jn),St.style.left=`${ia.left+ia.width/2}px`,St.style.top=`${ia.top-8}px`,St.style.transform="translate(-50%, -100%)",Ls.appendChild(St)},Mo=()=>{St&&St.parentNode&&(St.parentNode.removeChild(St),St=null)};Ut.addEventListener("mouseenter",Wr),Ut.addEventListener("mouseleave",Mo),st.addEventListener("focus",Wr),st.addEventListener("blur",Mo),Ut._cleanupTooltip=()=>{Mo(),Ut&&(Ut.removeEventListener("mouseenter",Wr),Ut.removeEventListener("mouseleave",Mo)),st&&(st.removeEventListener("focus",Wr),st.removeEventListener("blur",Mo))}}}}let kr=o.actionParsers&&o.actionParsers.length?o.actionParsers:[gi],Vo=o.actionHandlers&&o.actionHandlers.length?o.actionHandlers:[Ea.message,Ea.messageAndClick];T=hi({parsers:kr,handlers:Vo,getSessionMetadata:p,updateSessionMetadata:m,emit:a.emit,documentRef:typeof document!="undefined"?document:null}),ve=my(o,T,ie),U.updateConfig(o),Zn(it,U.getMessages(),ve),nr(),ea(),Da(U.isStreaming());let Ro=((eg=o.voiceRecognition)==null?void 0:eg.enabled)===!0,ta=typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined"),ra=((rg=(tg=o.voiceRecognition)==null?void 0:tg.provider)==null?void 0:rg.type)==="runtype";if(Ro&&(ta||ra))if(!X||!wt){let ee=tb(o.voiceRecognition,o.sendButton);ee&&(X=ee.micButton,wt=ee.micButtonWrapper,Dt.insertBefore(wt,Ar),X.addEventListener("click",Hi),X.disabled=U.isStreaming())}else{let ee=(og=o.voiceRecognition)!=null?og:{},Ot=(ng=o.sendButton)!=null?ng:{},er=(ag=ee.iconName)!=null?ag:"mic",Ct=(sg=Ot.size)!=null?sg:"40px",qt=(ig=ee.iconSize)!=null?ig:Ct,Hr=parseFloat(qt)||24;X.style.width=qt,X.style.height=qt,X.style.minWidth=qt,X.style.minHeight=qt;let no=(dg=(lg=ee.iconColor)!=null?lg:Ot.textColor)!=null?dg:"currentColor";X.innerHTML="";let Jo=Ee(er,Hr,no,2);Jo?X.appendChild(Jo):X.textContent="\u{1F3A4}";let bo=(cg=ee.backgroundColor)!=null?cg:Ot.backgroundColor;bo?X.style.backgroundColor=bo:X.style.backgroundColor="",no?X.style.color=no:X.style.color="var(--persona-text, #111827)",ee.borderWidth?(X.style.borderWidth=ee.borderWidth,X.style.borderStyle="solid"):(X.style.borderWidth="",X.style.borderStyle=""),ee.borderColor?X.style.borderColor=ee.borderColor:X.style.borderColor="",ee.paddingX?(X.style.paddingLeft=ee.paddingX,X.style.paddingRight=ee.paddingX):(X.style.paddingLeft="",X.style.paddingRight=""),ee.paddingY?(X.style.paddingTop=ee.paddingY,X.style.paddingBottom=ee.paddingY):(X.style.paddingTop="",X.style.paddingBottom="");let br=wt==null?void 0:wt.querySelector(".persona-send-button-tooltip"),Io=(pg=ee.tooltipText)!=null?pg:"Start voice recognition";if(((ug=ee.showTooltip)!=null?ug:!1)&&Io)if(br)br.textContent=Io,br.style.display="";else{let Wr=document.createElement("div");Wr.className="persona-send-button-tooltip",Wr.textContent=Io,wt==null||wt.insertBefore(Wr,X)}else br&&(br.style.display="none");wt.style.display="",X.disabled=U.isStreaming()}else X&&wt&&(wt.style.display="none",((mg=(fg=o.voiceRecognition)==null?void 0:fg.provider)==null?void 0:mg.type)==="runtype"?U.isVoiceActive()&&U.toggleVoice():kt&&Ur());if(((gg=o.attachments)==null?void 0:gg.enabled)===!0)if(!Ce||!ct){let ee=(hg=o.attachments)!=null?hg:{},er=(yg=((xg=o.sendButton)!=null?xg:{}).size)!=null?yg:"40px";rt||(rt=C("div","persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2"),rt.style.display="none",Rt.insertBefore(rt,te)),de||(de=document.createElement("input"),de.type="file",de.accept=((bg=ee.allowedTypes)!=null?bg:Tn).join(","),de.multiple=((vg=ee.maxFiles)!=null?vg:4)>1,de.style.display="none",de.setAttribute("aria-label","Attach files"),Rt.insertBefore(de,te)),Ce=C("div","persona-send-button-wrapper"),ct=C("button","persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-attachment-button"),ct.type="button",ct.setAttribute("aria-label",(Cg=ee.buttonTooltipText)!=null?Cg:"Attach file");let Ct=(wg=ee.buttonIconName)!=null?wg:"paperclip",qt=er,Hr=parseFloat(qt)||40,no=Math.round(Hr*.6);ct.style.width=qt,ct.style.height=qt,ct.style.minWidth=qt,ct.style.minHeight=qt,ct.style.fontSize="18px",ct.style.lineHeight="1",ct.style.backgroundColor="transparent",ct.style.color="var(--persona-primary, #111827)",ct.style.border="none",ct.style.borderRadius="6px",ct.style.transition="background-color 0.15s ease",ct.addEventListener("mouseenter",()=>{ct.style.backgroundColor="var(--persona-palette-colors-black-alpha-50, rgba(0, 0, 0, 0.05))"}),ct.addEventListener("mouseleave",()=>{ct.style.backgroundColor="transparent"});let Jo=Ee(Ct,no,"currentColor",1.5);Jo?ct.appendChild(Jo):ct.textContent="\u{1F4CE}",ct.addEventListener("click",Io=>{Io.preventDefault(),de==null||de.click()}),Ce.appendChild(ct);let bo=(Ag=ee.buttonTooltipText)!=null?Ag:"Attach file",br=C("div","persona-send-button-tooltip");br.textContent=bo,Ce.appendChild(br),Mt.append(Ce),!je&&de&&rt&&(je=wa.fromConfig(ee),je.setPreviewsContainer(rt),de.addEventListener("change",async()=>{je&&(de!=null&&de.files)&&(await je.handleFileSelect(de.files),de.value="")})),K.querySelector(".persona-attachment-drop-overlay")||K.appendChild(gy(ee.dropOverlay))}else{Ce.style.display="";let ee=(Sg=o.attachments)!=null?Sg:{};de&&(de.accept=((Tg=ee.allowedTypes)!=null?Tg:Tn).join(","),de.multiple=((Mg=ee.maxFiles)!=null?Mg:4)>1),je&&je.updateConfig({allowedTypes:ee.allowedTypes,maxFileSize:ee.maxFileSize,maxFiles:ee.maxFiles})}else Ce&&(Ce.style.display="none"),je&&je.clearAttachments(),(kg=K.querySelector(".persona-attachment-drop-overlay"))==null||kg.remove();let ur=(Eg=o.sendButton)!=null?Eg:{},oa=(Lg=ur.useIcon)!=null?Lg:!1,On=(Pg=ur.iconText)!=null?Pg:"\u2191",_n=ur.iconName,yn=(Rg=ur.tooltipText)!=null?Rg:"Send message",na=(Ig=ur.showTooltip)!=null?Ig:!1,Yo=(Hg=ur.size)!=null?Hg:"40px",pt=ur.backgroundColor,Ir=ur.textColor;if(oa){if(_e.style.width=Yo,_e.style.height=Yo,_e.style.minWidth=Yo,_e.style.minHeight=Yo,_e.style.fontSize="18px",_e.style.lineHeight="1",_e.innerHTML="",Ir?_e.style.color=Ir:_e.style.color="var(--persona-button-primary-fg, #ffffff)",_n){let ee=parseFloat(Yo)||24,Ot=(Ir==null?void 0:Ir.trim())||"currentColor",er=Ee(_n,ee,Ot,2);er?_e.appendChild(er):_e.textContent=On}else _e.textContent=On;_e.className="persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer",pt?(_e.style.backgroundColor=pt,_e.classList.remove("persona-bg-persona-primary")):(_e.style.backgroundColor="",_e.classList.add("persona-bg-persona-primary"))}else _e.textContent=(Bg=(Wg=o.copy)==null?void 0:Wg.sendButtonLabel)!=null?Bg:"Send",_e.style.width="",_e.style.height="",_e.style.minWidth="",_e.style.minHeight="",_e.style.fontSize="",_e.style.lineHeight="",_e.className="persona-rounded-button persona-bg-persona-accent persona-px-4 persona-py-2 persona-text-sm persona-font-semibold persona-text-white disabled:persona-opacity-50 persona-cursor-pointer",pt?(_e.style.backgroundColor=pt,_e.classList.remove("persona-bg-persona-accent")):_e.classList.add("persona-bg-persona-accent"),Ir?_e.style.color=Ir:_e.classList.add("persona-text-white");ur.borderWidth?(_e.style.borderWidth=ur.borderWidth,_e.style.borderStyle="solid"):(_e.style.borderWidth="",_e.style.borderStyle=""),ur.borderColor?_e.style.borderColor=ur.borderColor:_e.style.borderColor="",ur.paddingX?(_e.style.paddingLeft=ur.paddingX,_e.style.paddingRight=ur.paddingX):(_e.style.paddingLeft="",_e.style.paddingRight=""),ur.paddingY?(_e.style.paddingTop=ur.paddingY,_e.style.paddingBottom=ur.paddingY):(_e.style.paddingTop="",_e.style.paddingBottom="");let Zt=Ar==null?void 0:Ar.querySelector(".persona-send-button-tooltip");if(na&&yn)if(Zt)Zt.textContent=yn,Zt.style.display="";else{let ee=document.createElement("div");ee.className="persona-send-button-tooltip",ee.textContent=yn,Ar==null||Ar.insertBefore(ee,_e)}else Zt&&(Zt.style.display="none");let Yt=(Fg=(Dg=o.layout)==null?void 0:Dg.contentMaxWidth)!=null?Fg:H()?(Ng=(_g=(Og=o.launcher)==null?void 0:Og.composerBar)==null?void 0:_g.contentMaxWidth)!=null?Ng:"720px":void 0;Yt?(it.style.maxWidth=Yt,it.style.marginLeft="auto",it.style.marginRight="auto",it.style.width="100%",Rt&&(Rt.style.maxWidth=Yt,Rt.style.marginLeft="auto",Rt.style.marginRight="auto"),Pt&&(Pt.style.maxWidth=Yt,Pt.style.marginLeft="auto",Pt.style.marginRight="auto")):(it.style.maxWidth="",it.style.marginLeft="",it.style.marginRight="",it.style.width="",Rt&&(Rt.style.maxWidth="",Rt.style.marginLeft="",Rt.style.marginRight=""),Pt&&(Pt.style.maxWidth="",Pt.style.marginLeft="",Pt.style.marginRight=""));let Et=(Ug=o.statusIndicator)!=null?Ug:{},fr=(qg=Et.visible)!=null?qg:!0;if(dr.style.display=fr?"":"none",U){let ee=U.getStatus();Ye(dr,(er=>{var Ct,qt,Hr,no;return er==="idle"?(Ct=Et.idleText)!=null?Ct:ao.idle:er==="connecting"?(qt=Et.connectingText)!=null?qt:ao.connecting:er==="connected"?(Hr=Et.connectedText)!=null?Hr:ao.connected:er==="error"?(no=Et.errorText)!=null?no:ao.error:ao[er]})(ee),Et,ee)}dr.classList.remove("persona-text-left","persona-text-center","persona-text-right");let _t=Et.align==="left"?"persona-text-left":Et.align==="center"?"persona-text-center":"persona-text-right";dr.classList.add(_t)},open(){I()&&Gt(!0,"api")},close(){I()&&Gt(!1,"api")},toggle(){I()&&Gt(!P,"api")},clearChat(){Or=!1,U.clearMessages(),Cr.clear(),sn();try{localStorage.removeItem(cs),o.debug&&console.log(`[AgentWidget] Cleared default localStorage key: ${cs}`)}catch(g){console.error("[AgentWidget] Failed to clear default localStorage:",g)}if(o.clearChatHistoryStorageKey&&o.clearChatHistoryStorageKey!==cs)try{localStorage.removeItem(o.clearChatHistoryStorageKey),o.debug&&console.log(`[AgentWidget] Cleared custom localStorage key: ${o.clearChatHistoryStorageKey}`)}catch(g){console.error("[AgentWidget] Failed to clear custom localStorage:",g)}let c=new CustomEvent("persona:clear-chat",{detail:{timestamp:new Date().toISOString()}});if(window.dispatchEvent(c),i!=null&&i.clear)try{let g=i.clear();g instanceof Promise&&g.catch(b=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear storage adapter:",b)})}catch(g){typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear storage adapter:",g)}d={},T.syncFromMetadata(),be==null||be.clear(),ye==null||ye.reset(),Y==null||Y.update()},setMessage(c){return!te||U.isStreaming()?!1:(!P&&I()&&Gt(!0,"system"),te.value=c,te.dispatchEvent(new Event("input",{bubbles:!0})),!0)},submitMessage(c){if(U.isStreaming())return!1;let g=(c==null?void 0:c.trim())||te.value.trim();return g?(!P&&I()&&Gt(!0,"system"),te.value="",te.style.height="auto",U.sendMessage(g),!0):!1},startVoiceRecognition(){var g,b;return U.isStreaming()?!1:((b=(g=o.voiceRecognition)==null?void 0:g.provider)==null?void 0:b.type)==="runtype"?(U.isVoiceActive()||(!P&&I()&&Gt(!0,"system"),Lt.manuallyDeactivated=!1,So(),U.toggleVoice().then(()=>{Lt.active=U.isVoiceActive(),zo("user"),U.isVoiceActive()&&Ts()})),!0):kt?!0:jr()?(!P&&I()&&Gt(!0,"system"),Lt.manuallyDeactivated=!1,So(),pr("user"),!0):!1},stopVoiceRecognition(){var c,g;return((g=(c=o.voiceRecognition)==null?void 0:c.provider)==null?void 0:g.type)==="runtype"?U.isVoiceActive()?(U.toggleVoice().then(()=>{Lt.active=!1,Lt.manuallyDeactivated=!0,So(),zo("user"),Bn()}),!0):!1:kt?(Lt.manuallyDeactivated=!0,So(),Ur("user"),!0):!1},injectMessage(c){return!P&&I()&&Gt(!0,"system"),U.injectMessage(c)},injectAssistantMessage(c){!P&&I()&&Gt(!0,"system");let g=U.injectAssistantMessage(c);return z&&(z=!1,j&&(clearTimeout(j),j=null),setTimeout(()=>{U&&!U.isStreaming()&&U.continueConversation()},100)),g},injectUserMessage(c){return!P&&I()&&Gt(!0,"system"),U.injectUserMessage(c)},injectSystemMessage(c){return!P&&I()&&Gt(!0,"system"),U.injectSystemMessage(c)},injectMessageBatch(c){return!P&&I()&&Gt(!0,"system"),U.injectMessageBatch(c)},injectComponentDirective(c){return!P&&I()&&Gt(!0,"system"),U.injectComponentDirective(c)},injectTestMessage(c){!P&&I()&&Gt(!0,"system"),U.injectTestEvent(c)},async connectStream(c,g){return U.connectStream(c,g)},__pushEventStreamEvent(c){be&&(ye==null||ye.processEvent(c.type,c.payload),be.push({id:`evt-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,type:c.type,timestamp:Date.now(),payload:JSON.stringify(c.payload)}))},showEventStream(){!We||!be||_o()},hideEventStream(){ge&&lo()},isEventStreamVisible(){return ge},showArtifacts(){Go(o)&&(Or=!1,eo(),mt==null||mt.setMobileOpen(!0))},hideArtifacts(){Go(o)&&(Or=!0,eo())},upsertArtifact(c){return Go(o)?(Or=!1,U.upsertArtifact(c)):null},selectArtifact(c){Go(o)&&U.selectArtifact(c)},clearArtifacts(){Go(o)&&U.clearArtifacts()},getArtifacts(){var c;return(c=U==null?void 0:U.getArtifacts())!=null?c:[]},getSelectedArtifactId(){var c;return(c=U==null?void 0:U.getSelectedArtifactId())!=null?c:null},focusInput(){return M&&!P&&!H()||!te?!1:(te.focus(),!0)},async resolveApproval(c,g,b){let W=U.getMessages().find(F=>{var q;return F.variant==="approval"&&((q=F.approval)==null?void 0:q.id)===c});if(!(W!=null&&W.approval))throw new Error(`Approval not found: ${c}`);if(W.approval.toolType==="webmcp"){U.resolveWebMcpApproval(W.id,g);return}return U.resolveApproval(W.approval,g,b)},getMessages(){return U.getMessages()},getStatus(){return U.getStatus()},getPersistentMetadata(){return{...d}},updatePersistentMetadata(c){m(c)},on(c,g){return a.on(c,g)},off(c,g){a.off(c,g)},isOpen(){return I()&&P},isVoiceActive(){return Lt.active},getState(){return{open:I()&&P,launcherEnabled:M,voiceActive:Lt.active,streaming:U.isStreaming()}},showCSATFeedback(c){!P&&I()&&Gt(!0,"system");let g=it.querySelector(".persona-feedback-container");g&&g.remove();let b=od({onSubmit:async(S,W)=>{var F;U.isClientTokenMode()&&await U.submitCSATFeedback(S,W),(F=c==null?void 0:c.onSubmit)==null||F.call(c,S,W)},onDismiss:c==null?void 0:c.onDismiss,...c});it.appendChild(b),b.scrollIntoView({behavior:"smooth",block:"end"})},showNPSFeedback(c){!P&&I()&&Gt(!0,"system");let g=it.querySelector(".persona-feedback-container");g&&g.remove();let b=nd({onSubmit:async(S,W)=>{var F;U.isClientTokenMode()&&await U.submitNPSFeedback(S,W),(F=c==null?void 0:c.onSubmit)==null||F.call(c,S,W)},onDismiss:c==null?void 0:c.onDismiss,...c});it.appendChild(b),b.scrollIntoView({behavior:"smooth",block:"end"})},async submitCSATFeedback(c,g){return U.submitCSATFeedback(c,g)},async submitNPSFeedback(c,g){return U.submitNPSFeedback(c,g)},destroy(){Ke!=null&&(clearInterval(Ke),Ke=null),gt.forEach(c=>c()),De.remove(),nt==null||nt.remove(),xr==null||xr.destroy(),yr==null||yr.remove(),ut&&O.removeEventListener("click",ut)}};if((((_f=t==null?void 0:t.debugTools)!=null?_f:!1)||!!o.debug)&&typeof window!="undefined"){let c=window.AgentWidgetBrowser,g={controller:Mr,getMessages:Mr.getMessages,getStatus:Mr.getStatus,getMetadata:Mr.getPersistentMetadata,updateMetadata:Mr.updatePersistentMetadata,clearHistory:()=>Mr.clearChat(),setVoiceActive:b=>b?Mr.startVoiceRecognition():Mr.stopVoiceRecognition()};window.AgentWidgetBrowser=g,gt.push(()=>{window.AgentWidgetBrowser===g&&(window.AgentWidgetBrowser=c)})}if(typeof window!="undefined"){let c=r.getAttribute("data-persona-instance")||r.id||"persona-"+Math.random().toString(36).slice(2,8),g=G=>{let N=G.detail;(!(N!=null&&N.instanceId)||N.instanceId===c)&&Mr.focusInput()};if(window.addEventListener("persona:focusInput",g),gt.push(()=>{window.removeEventListener("persona:focusInput",g)}),We){let G=Se=>{let xe=Se.detail;(!(xe!=null&&xe.instanceId)||xe.instanceId===c)&&Mr.showEventStream()},N=Se=>{let xe=Se.detail;(!(xe!=null&&xe.instanceId)||xe.instanceId===c)&&Mr.hideEventStream()};window.addEventListener("persona:showEventStream",G),window.addEventListener("persona:hideEventStream",N),gt.push(()=>{window.removeEventListener("persona:showEventStream",G),window.removeEventListener("persona:hideEventStream",N)})}let b=G=>{let N=G.detail;(!(N!=null&&N.instanceId)||N.instanceId===c)&&Mr.showArtifacts()},S=G=>{let N=G.detail;(!(N!=null&&N.instanceId)||N.instanceId===c)&&Mr.hideArtifacts()},W=G=>{let N=G.detail;N!=null&&N.instanceId&&N.instanceId!==c||N!=null&&N.artifact&&Mr.upsertArtifact(N.artifact)},F=G=>{let N=G.detail;N!=null&&N.instanceId&&N.instanceId!==c||typeof(N==null?void 0:N.id)=="string"&&Mr.selectArtifact(N.id)},q=G=>{let N=G.detail;(!(N!=null&&N.instanceId)||N.instanceId===c)&&Mr.clearArtifacts()};window.addEventListener("persona:showArtifacts",b),window.addEventListener("persona:hideArtifacts",S),window.addEventListener("persona:upsertArtifact",W),window.addEventListener("persona:selectArtifact",F),window.addEventListener("persona:clearArtifacts",q),gt.push(()=>{window.removeEventListener("persona:showArtifacts",b),window.removeEventListener("persona:hideArtifacts",S),window.removeEventListener("persona:upsertArtifact",W),window.removeEventListener("persona:selectArtifact",F),window.removeEventListener("persona:clearArtifacts",q)})}let $o=ZC(o.persistState);if($o&&I()){let c=ew($o.storage),g=`${$o.keyPrefix}widget-open`,b=`${$o.keyPrefix}widget-voice`,S=`${$o.keyPrefix}widget-voice-mode`;if(c){let W=((Nf=$o.persist)==null?void 0:Nf.openState)&&c.getItem(g)==="true",F=((Ff=$o.persist)==null?void 0:Ff.voiceState)&&c.getItem(b)==="true",q=((Uf=$o.persist)==null?void 0:Uf.voiceState)&&c.getItem(S)==="true";if(W&&setTimeout(()=>{Mr.open(),setTimeout(()=>{var G;if(F||q)Mr.startVoiceRecognition();else if((G=$o.persist)!=null&&G.focusInput){let N=r.querySelector("textarea");N&&N.focus()}},100)},0),(qf=$o.persist)!=null&&qf.openState&&(a.on("widget:opened",()=>{c.setItem(g,"true")}),a.on("widget:closed",()=>{c.setItem(g,"false")})),(zf=$o.persist)!=null&&zf.voiceState&&(a.on("voice:state",G=>{c.setItem(b,G.active?"true":"false")}),a.on("user:message",G=>{c.setItem(S,G.viaVoice?"true":"false")})),$o.clearOnChatClear){let G=()=>{c.removeItem(g),c.removeItem(b),c.removeItem(S)},N=()=>G();window.addEventListener("persona:clear-chat",N),gt.push(()=>{window.removeEventListener("persona:clear-chat",N)})}}}return u&&I()&&setTimeout(()=>{Mr.open()},0),xn(),Mr};var tw=(r,e)=>{let t=r.trim(),o=/^(\d+(?:\.\d+)?)px$/i.exec(t);if(o)return Math.max(0,parseFloat(o[1]));let n=/^(\d+(?:\.\d+)?)%$/i.exec(t);return n?Math.max(0,e*parseFloat(n[1])/100):420},rw=(r,e)=>{if(e===!1){r.style.maxHeight="";return}r.style.maxHeight="100vh",r.style.maxHeight=e},ow=(r,e)=>{e===!1?(r.style.position="relative",r.style.top=""):(r.style.position="sticky",r.style.top="0")},nw=(r,e)=>{let t=r.parentElement;if(!t)return;let o=r.ownerDocument.createElement("div");o.style.cssText="width:0;height:1px;margin:0;padding:0;border:0;visibility:hidden;",t.appendChild(o);let n=o.offsetHeight>0;o.style.height="100%";let a=o.offsetHeight>0;o.remove(),!(!n||a)&&console.warn("[AgentWidget] Docked mode: no ancestor of the dock target provides a definite height, so the dock panel cannot size to your layout."+(e.maxHeight===!1?" The viewport guard is disabled (dock.maxHeight: false), so the panel will grow with the conversation and overflow the viewport.":` Falling back to clamping the panel to ${e.maxHeight} (configurable via launcher.dock.maxHeight).`)+" To size the panel from your layout instead, give the height chain a definite height (e.g. `html, body { height: 100% }`) down to the dock target's parent.")},hy=(r,e)=>{var o,n;let t=(n=(o=e==null?void 0:e.launcher)==null?void 0:o.enabled)!=null?n:!0;r.className="persona-host",r.style.height=t?"":"100%",r.style.display=t?"":"flex",r.style.flexDirection=t?"":"column",r.style.flex=t?"":"1 1 auto",r.style.minHeight=t?"":"0"},bu=r=>{r.style.position="",r.style.top="",r.style.bottom="",r.style.left="",r.style.right="",r.style.zIndex="",r.style.transform="",r.style.pointerEvents=""},xy=r=>{r.style.inset="",r.style.width="",r.style.height="",r.style.maxWidth="",r.style.maxHeight="",r.style.minWidth="",bu(r)},hu=r=>{r.style.transition=""},xu=r=>{r.style.display="",r.style.flexDirection="",r.style.flex="",r.style.minHeight="",r.style.minWidth="",r.style.width="",r.style.height="",r.style.alignItems="",r.style.transition="",r.style.transform="",r.style.marginLeft=""},yu=r=>{r.style.width="",r.style.maxWidth="",r.style.minWidth="",r.style.flex="1 1 auto"},id=(r,e)=>{r.style.width="",r.style.minWidth="",r.style.maxWidth="",r.style.boxSizing="",e.style.alignItems=""},aw=(r,e,t,o,n)=>{n?t.parentElement!==e&&(r.replaceChildren(),e.replaceChildren(t,o),r.appendChild(e)):t.parentElement===e&&(e.replaceChildren(),r.appendChild(t),r.appendChild(o))},sw=(r,e,t,o,n,a)=>{let s=a?e:r;n==="left"?s.firstElementChild!==o&&s.replaceChildren(o,t):s.lastElementChild!==o&&s.replaceChildren(t,o)},yy=(r,e,t,o,n,a,s)=>{var y,h,T,M,k,L;let i=Bo(a),d=i.reveal==="push";aw(r,e,t,o,d),sw(r,e,t,o,i.side,d),r.dataset.personaHostLayout="docked",r.dataset.personaDockSide=i.side,r.dataset.personaDockOpen=s?"true":"false",r.style.width="100%",r.style.maxWidth="100%",r.style.minWidth="0",r.style.height="100%",r.style.minHeight="0",r.style.position="relative",t.style.display="flex",t.style.flexDirection="column",t.style.minHeight="0",t.style.position="relative",n.className="persona-host",n.style.height="100%",n.style.minHeight="0",n.style.display="flex",n.style.flexDirection="column",n.style.flex="1 1 auto";let l=r.ownerDocument.defaultView,u=(h=(y=a==null?void 0:a.launcher)==null?void 0:y.mobileFullscreen)!=null?h:!0,f=(M=(T=a==null?void 0:a.launcher)==null?void 0:T.mobileBreakpoint)!=null?M:640,p=l!=null?l.innerWidth<=f:!1;if(u&&p&&s){r.dataset.personaDockMobileFullscreen="true",r.removeAttribute("data-persona-dock-reveal"),xu(e),hu(o),xy(o),yu(t),id(n,o),r.style.display="flex",r.style.flexDirection="column",r.style.alignItems="stretch",r.style.overflow="hidden",t.style.flex="1 1 auto",t.style.width="100%",t.style.minWidth="0",o.style.display="flex",o.style.flexDirection="column",o.style.position="fixed",o.style.inset="0",o.style.width="100%",o.style.height="100%",o.style.maxWidth="100%",o.style.minWidth="0",o.style.minHeight="0",o.style.overflow="hidden",o.style.zIndex=String((L=(k=a==null?void 0:a.launcher)==null?void 0:k.zIndex)!=null?L:so),o.style.transform="none",o.style.transition="none",o.style.pointerEvents="auto",o.style.flex="none",d&&(e.style.display="flex",e.style.flexDirection="column",e.style.width="100%",e.style.height="100%",e.style.minHeight="0",e.style.minWidth="0",e.style.flex="1 1 auto",e.style.alignItems="stretch",e.style.transform="none",e.style.marginLeft="0",e.style.transition="none",t.style.flex="1 1 auto",t.style.width="100%",t.style.maxWidth="100%",t.style.minWidth="0");return}if(r.removeAttribute("data-persona-dock-mobile-fullscreen"),xy(o),rw(o,i.maxHeight),i.reveal==="overlay"){r.style.display="flex",r.style.flexDirection="row",r.style.alignItems="stretch",r.style.overflow="hidden",r.dataset.personaDockReveal="overlay",xu(e),hu(o),yu(t),id(n,o);let x=i.animate?"transform 180ms ease":"none",w=i.side==="right"?"translateX(100%)":"translateX(-100%)",v=s?"translateX(0)":w;o.style.display="flex",o.style.flexDirection="column",o.style.flex="none",o.style.position="absolute",o.style.top="0",o.style.bottom="0",o.style.width=i.width,o.style.maxWidth=i.width,o.style.minWidth=i.width,o.style.minHeight="0",o.style.overflow="hidden",o.style.transition=x,o.style.transform=v,o.style.pointerEvents=s?"auto":"none",o.style.zIndex="2",i.side==="right"?(o.style.right="0",o.style.left=""):(o.style.left="0",o.style.right="")}else if(i.reveal==="push"){r.style.display="flex",r.style.flexDirection="row",r.style.alignItems="stretch",r.style.overflow="hidden",r.dataset.personaDockReveal="push",hu(o),bu(o),id(n,o);let x=tw(i.width,r.clientWidth),w=Math.max(0,r.clientWidth),v=i.animate?"margin-left 180ms ease":"none",E=i.side==="right"?s?-x:0:s?0:-x;e.style.display="flex",e.style.flexDirection="row",e.style.flex="0 0 auto",e.style.minHeight="0",e.style.minWidth="0",e.style.alignItems="stretch",e.style.height="100%",e.style.width=`${w+x}px`,e.style.transition=v,e.style.marginLeft=`${E}px`,e.style.transform="",t.style.flex="0 0 auto",t.style.flexGrow="0",t.style.flexShrink="0",t.style.width=`${w}px`,t.style.maxWidth=`${w}px`,t.style.minWidth=`${w}px`,o.style.display="flex",o.style.flexDirection="column",o.style.flex="0 0 auto",o.style.flexShrink="0",o.style.width=i.width,o.style.minWidth=i.width,o.style.maxWidth=i.width,o.style.position="relative",o.style.top="",o.style.overflow="hidden",o.style.transition="none",o.style.pointerEvents=s?"auto":"none"}else{r.style.display="flex",r.style.flexDirection="row",r.style.alignItems="stretch",r.style.overflow="",xu(e),bu(o),yu(t),id(n,o);let x=i.reveal==="emerge";x?r.dataset.personaDockReveal="emerge":r.removeAttribute("data-persona-dock-reveal");let w=s?i.width:"0px",v=i.animate?"width 180ms ease, min-width 180ms ease, max-width 180ms ease, flex-basis 180ms ease":"none",E=!s;o.style.display="flex",o.style.flexDirection="column",o.style.flex=`0 0 ${w}`,o.style.width=w,o.style.maxWidth=w,o.style.minWidth=w,o.style.minHeight="0",ow(o,i.maxHeight),o.style.overflow=x||E?"hidden":"visible",o.style.transition=v,x&&(o.style.alignItems=i.side==="right"?"flex-start":"flex-end",n.style.width=i.width,n.style.minWidth=i.width,n.style.maxWidth=i.width,n.style.boxSizing="border-box")}},iw=(r,e)=>{let t=r.ownerDocument.createElement("div");return hy(t,e),r.appendChild(t),{mode:"direct",host:t,shell:null,syncWidgetState:()=>{},updateConfig(o){hy(t,o)},destroy(){t.remove()}}},lw=(r,e)=>{var L,x,w,v;let{ownerDocument:t}=r,o=r.parentElement;if(!o)throw new Error("Docked widget target must be attached to the DOM");let n=r.tagName.toUpperCase();if(n==="BODY"||n==="HTML")throw new Error('Docked widget target must be a concrete container element, not "body" or "html"');let a=r.nextSibling,s=t.createElement("div"),i=t.createElement("div"),d=t.createElement("div"),l=t.createElement("aside"),u=t.createElement("div"),f=(x=(L=e==null?void 0:e.launcher)==null?void 0:L.enabled)==null||x?(v=(w=e==null?void 0:e.launcher)==null?void 0:w.autoExpand)!=null?v:!1:!0;i.dataset.personaDockRole="push-track",d.dataset.personaDockRole="content",l.dataset.personaDockRole="panel",u.dataset.personaDockRole="host",l.appendChild(u),o.insertBefore(s,r),d.appendChild(r);let p=null,m=()=>{p==null||p.disconnect(),p=null},y=()=>{m(),Bo(e).reveal==="push"&&typeof ResizeObserver!="undefined"&&(p=new ResizeObserver(()=>{yy(s,i,d,l,u,e,f)}),p.observe(s))},h=!1,T=()=>{yy(s,i,d,l,u,e,f),y(),f&&!h&&s.dataset.personaDockMobileFullscreen!=="true"&&(h=!0,nw(s,Bo(e)))},M=s.ownerDocument.defaultView,k=()=>{T()};return M==null||M.addEventListener("resize",k),Bo(e).reveal==="push"?(i.appendChild(d),i.appendChild(l),s.appendChild(i)):(s.appendChild(d),s.appendChild(l)),T(),{mode:"docked",host:u,shell:s,syncWidgetState(E){let H=E.launcherEnabled?E.open:!0;f!==H&&(f=H,T())},updateConfig(E){var H,I;e=E,((I=(H=e==null?void 0:e.launcher)==null?void 0:H.enabled)!=null?I:!0)===!1&&(f=!0),T()},destroy(){M==null||M.removeEventListener("resize",k),m(),o.isConnected&&(a&&a.parentNode===o?o.insertBefore(r,a):o.appendChild(r)),s.remove()}}},xi=(r,e)=>Lr(e)?lw(r,e):iw(r,e);var vu={},by=!1,dw=r=>{if(typeof window=="undefined"||typeof document=="undefined")throw new Error("Chat widget can only be mounted in a browser environment");if(typeof r=="string"){let e=document.querySelector(r);if(!e)throw new Error(`Chat widget target "${r}" was not found`);return e}return r},cw=()=>{try{if(typeof vu!="undefined"&&vu.url)return new URL("../widget.css",vu.url).href}catch{}return null},vy=(r,e)=>{let t=cw(),o=()=>{if(!(r instanceof ShadowRoot)||r.querySelector("link[data-persona]"))return;let n=e.head.querySelector("link[data-persona]");if(!n)return;let a=n.cloneNode(!0);r.insertBefore(a,r.firstChild)};if(r instanceof ShadowRoot)if(t){let n=e.createElement("link");n.rel="stylesheet",n.href=t,n.setAttribute("data-persona","true"),r.insertBefore(n,r.firstChild)}else o();else if(!e.head.querySelector("link[data-persona]")&&t){let a=e.createElement("link");a.rel="stylesheet",a.href=t,a.setAttribute("data-persona","true"),e.head.appendChild(a)}},Cy=r=>{let e=dw(r.target),t=r.useShadowDom===!0,o=e.ownerDocument,n=r.config,a=xi(e,n),s,i=[],d=(T,M)=>{var w,v;let L=!((v=(w=M==null?void 0:M.launcher)==null?void 0:w.enabled)!=null?v:!0)||Lr(M),x=o.createElement("div");if(x.setAttribute("data-persona-root","true"),L&&(x.style.height="100%",x.style.display="flex",x.style.flexDirection="column",x.style.flex="1",x.style.minHeight="0"),t){let E=T.attachShadow({mode:"open"});E.appendChild(x),vy(E,o)}else T.appendChild(x),vy(T,o);return e.id&&x.setAttribute("data-persona-instance",e.id),x},l=()=>{a.syncWidgetState(s.getState())},u=()=>{i.forEach(T=>T()),i=[s.on("widget:opened",l),s.on("widget:closed",l)],l()},f=()=>{let T=d(a.host,n);s=sd(T,n,{debugTools:r.debugTools}),u()},p=()=>{i.forEach(T=>T()),i=[],s.destroy()};f(),r.onChatReady?r.onChatReady():r.onReady&&(by||(by=!0,console.warn("[Persona] `onReady` is deprecated \u2014 use `onChatReady`. `onReady` still works but is removed in the next major.")),r.onReady());let m=T=>{p(),a.destroy(),a=xi(e,T),n=T,f()},y={update(T){var v,E,H,I,P,z;let M={...n,...T,launcher:{...(v=n==null?void 0:n.launcher)!=null?v:{},...(E=T==null?void 0:T.launcher)!=null?E:{},dock:{...(I=(H=n==null?void 0:n.launcher)==null?void 0:H.dock)!=null?I:{},...(z=(P=T==null?void 0:T.launcher)==null?void 0:P.dock)!=null?z:{}}}},k=Lr(n),L=Lr(M),x=Kn(n),w=Kn(M);if(k!==L||x!==w){m(M);return}n=M,a.updateConfig(n),s.update(T),l()},destroy(){p(),a.destroy(),r.windowKey&&typeof window!="undefined"&&delete window[r.windowKey]}},h=new Proxy(y,{get(T,M,k){if(M==="host")return a.host;if(M in T)return Reflect.get(T,M,k);let L=s[M];return typeof L=="function"?L.bind(s):L}});return r.windowKey&&typeof window!="undefined"&&(window[r.windowKey]=h),h};var My=new Set(["script","style","noscript","svg","path","meta","link","br","hr"]),pw=new Set(["button","a","input","select","textarea","details","summary"]),uw=new Set(["button","link","menuitem","tab","option","switch","checkbox","radio","combobox","listbox","slider","spinbutton","textbox"]),Cu=/\b(product|card|item|listing|result)\b/i,Au=/\$[\d,]+(?:\.\d{2})?|€[\d,]+(?:\.\d{2})?|£[\d,]+(?:\.\d{2})?|USD\s*[\d,]+(?:\.\d{2})?/i,fw=3e3,mw=100;function ky(r){let e=typeof r.className=="string"?r.className:"";if(Cu.test(e)||r.id&&Cu.test(r.id))return!0;for(let t=0;t<r.attributes.length;t++){let o=r.attributes[t];if(o.name.startsWith("data-")&&Cu.test(o.value))return!0}return!1}function Ey(r){var e;return Au.test(((e=r.textContent)!=null?e:"").trim())}function Ly(r){var t;let e=r.querySelectorAll("a[href]");for(let o=0;o<e.length;o++){let n=(t=e[o].getAttribute("href"))!=null?t:"";if(n&&n!=="#"&&!n.toLowerCase().startsWith("javascript:"))return!0}return!1}function gw(r){return!!r.querySelector('button, [role="button"], input[type="submit"], input[type="button"]')}function wy(r){let e=r.match(Au);return e?e[0]:null}function Ay(r){var o,n,a;let e=(o=r.querySelector(".product-title a, h1 a, h2 a, h3 a, h4 a, .title a, a[href]"))!=null?o:r.querySelector("a[href]");if(e&&((n=e.textContent)!=null&&n.trim())){let s=e.getAttribute("href");return{title:e.textContent.trim(),href:s&&s!=="#"?s:null}}let t=r.querySelector("h1, h2, h3, h4, h5, h6");return(a=t==null?void 0:t.textContent)!=null&&a.trim()?{title:t.textContent.trim(),href:null}:{title:"",href:null}}function hw(r){let e=[],t=o=>{let n=o.trim();n&&!e.includes(n)&&e.push(n)};return r.querySelectorAll("button").forEach(o=>{var n;return t((n=o.textContent)!=null?n:"")}),r.querySelectorAll('[role="button"]').forEach(o=>{var n;return t((n=o.textContent)!=null?n:"")}),r.querySelectorAll('input[type="submit"], input[type="button"]').forEach(o=>{var n;t((n=o.value)!=null?n:"")}),e.slice(0,6)}var xw="commerce-card",yw="result-card";function Sy(r){return!ky(r)||!Ey(r)||!Ly(r)&&!gw(r)?0:5200}function Ty(r){var o;return!ky(r)||Ey(r)||!Ly(r)||((o=r.textContent)!=null?o:"").trim().length<20||!(!!r.querySelector("h1, h2, h3, h4, h5, h6, .title")||!!r.querySelector(".snippet, .description, p"))?0:2800}var Su=[{id:xw,scoreElement(r){return Sy(r)},shouldSuppressDescendant(r,e,t){if(e===r||!r.contains(e))return!1;if(t.interactivity==="static"){let o=t.text.trim();return!!(o.length===0||Au.test(o)&&o.length<32)}return!0},formatSummary(r,e){var d,l,u;if(Sy(r)===0)return null;let{title:t,href:o}=Ay(r),n=(u=(l=wy(((d=r.textContent)!=null?d:"").trim()))!=null?l:wy(e.text))!=null?u:"",a=hw(r);return[o&&t?`[${t}](${o})${n?` \u2014 ${n}`:""}`:t?`${t}${n?` \u2014 ${n}`:""}`:n||e.text.trim().slice(0,120),`selector: ${e.selector}`,a.length?`actions: ${a.join(", ")}`:""].filter(Boolean).join(`
|
|
156
|
+
`)}},{id:yw,scoreElement(r){return Ty(r)},formatSummary(r,e){if(Ty(r)===0)return null;let{title:t,href:o}=Ay(r);return[o&&t?`[${t}](${o})`:t||e.text.trim().slice(0,120),`selector: ${e.selector}`].filter(Boolean).join(`
|
|
157
|
+
`)}}];function bw(){typeof console!="undefined"&&typeof console.warn=="function"&&console.warn('[persona] collectEnrichedPageContext: options.mode is "simple" but `rules` were provided; rules are ignored.')}function vw(r){var u,f,p,m,y,h,T,M,k,L,x,w,v;let e=(u=r.options)!=null?u:{},t=(p=(f=e.maxElements)!=null?f:r.maxElements)!=null?p:80,o=(y=(m=e.excludeSelector)!=null?m:r.excludeSelector)!=null?y:".persona-host",n=(T=(h=e.maxTextLength)!=null?h:r.maxTextLength)!=null?T:200,a=(k=(M=e.visibleOnly)!=null?M:r.visibleOnly)!=null?k:!0,s=(L=e.root)!=null?L:r.root,i=(x=e.mode)!=null?x:"structured",d=(w=e.maxCandidates)!=null?w:Math.max(500,t*10),l=(v=r.rules)!=null?v:Su;return i==="simple"&&r.rules&&r.rules.length>0?(bw(),l=[]):i==="simple"&&(l=[]),{mode:i,maxElements:t,maxCandidates:d,excludeSelector:o,maxTextLength:n,visibleOnly:a,root:s,rules:l}}function wu(r){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(r):r.replace(/([^\w-])/g,"\\$1")}var Cw=["data-testid","data-product","data-action","data-id","data-name","data-type"];function ww(r){let e=r.tagName.toLowerCase(),t=r.getAttribute("role");return e==="a"&&r.hasAttribute("href")?"navigable":e==="input"||e==="select"||e==="textarea"||t==="textbox"||t==="combobox"||t==="listbox"||t==="spinbutton"?"input":e==="button"||t==="button"||pw.has(e)||t&&uw.has(t)||r.hasAttribute("tabindex")||r.hasAttribute("onclick")||r.getAttribute("contenteditable")==="true"?"clickable":"static"}function Py(r){if(r.hidden)return!1;try{let e=getComputedStyle(r);if(e.display==="none"||e.visibility==="hidden")return!1}catch{}return!(r.style.display==="none"||r.style.visibility==="hidden")}function Aw(r){let e={},t=r.id;t&&(e.id=t);let o=r.getAttribute("href");o&&(e.href=o);let n=r.getAttribute("aria-label");n&&(e["aria-label"]=n);let a=r.getAttribute("type");a&&(e.type=a);let s=r.getAttribute("value");s&&(e.value=s);let i=r.getAttribute("name");i&&(e.name=i);let d=r.getAttribute("role");d&&(e.role=d);for(let l=0;l<r.attributes.length;l++){let u=r.attributes[l];u.name.startsWith("data-")&&(e[u.name]=u.value)}return e}function Tu(r){let e=r.tagName.toLowerCase();if(r.id){let n=`#${wu(r.id)}`;try{if(r.ownerDocument.querySelectorAll(n).length===1)return n}catch{}}for(let n of Cw){let a=r.getAttribute(n);if(a){let s=`${e}[${n}="${wu(a)}"]`;try{if(r.ownerDocument.querySelectorAll(s).length===1)return s}catch{}}}let t=Array.from(r.classList).filter(n=>n&&!n.startsWith("persona-")).slice(0,3);if(t.length>0){let n=`${e}.${t.map(s=>wu(s)).join(".")}`;try{if(r.ownerDocument.querySelectorAll(n).length===1)return n}catch{}let a=r.parentElement;if(a){let i=Array.from(a.querySelectorAll(`:scope > ${e}`)).indexOf(r);if(i>=0){let d=`${n}:nth-of-type(${i+1})`;try{if(r.ownerDocument.querySelectorAll(d).length===1)return d}catch{}}}}let o=r.parentElement;if(o){let a=Array.from(o.querySelectorAll(`:scope > ${e}`)).indexOf(r);if(a>=0)return`${e}:nth-of-type(${a+1})`}return e}function Sw(r){return r==="static"?mw:fw}function Ry(r,e){var n;let t=r.tagName.toLowerCase(),o=((n=r.textContent)!=null?n:"").trim().substring(0,e);return{selector:Tu(r),tagName:t,text:o,role:r.getAttribute("role"),interactivity:ww(r),attributes:Aw(r)}}function Tw(r,e,t,o){let n=Sw(e.interactivity),a=null;for(let s of t){let i=s.scoreElement(r,e,o);i>0&&(n+=i,s.formatSummary&&!a&&(a=s))}return{score:n,formattingRule:a}}function Mw(r,e){var t;for(let o of r)if(e.el!==o.el&&(t=o.formattingRule)!=null&&t.shouldSuppressDescendant&&o.el.contains(e.el)&&o.formattingRule.shouldSuppressDescendant(o.el,e.el,e.enriched))return!0;return!1}function kw(r,e){let t={doc:e.ownerDocument,maxTextLength:r.maxTextLength},o=new Set,n=[],a=0,s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null),i=s.currentNode;for(;i&&n.length<r.maxCandidates;){if(i.nodeType===Node.ELEMENT_NODE){let l=i,u=l.tagName.toLowerCase();if(My.has(u)){i=s.nextNode();continue}if(r.excludeSelector)try{if(l.closest(r.excludeSelector)){i=s.nextNode();continue}}catch{}if(r.visibleOnly&&!Py(l)){i=s.nextNode();continue}let f=Ry(l,r.maxTextLength),p=f.text.length>0,m=Object.keys(f.attributes).length>0&&!Object.keys(f.attributes).every(T=>T==="role");if(!p&&!m){i=s.nextNode();continue}if(o.has(f.selector)){i=s.nextNode();continue}o.add(f.selector);let{score:y,formattingRule:h}=Tw(l,f,r.rules,t);n.push({el:l,domIndex:a,enriched:f,score:y,formattingRule:h}),a+=1}i=s.nextNode()}n.sort((l,u)=>{let f=l.enriched.interactivity==="static"?1:0,p=u.enriched.interactivity==="static"?1:0;return f!==p?f-p:u.score!==l.score?u.score-l.score:l.domIndex-u.domIndex});let d=[];for(let l of n){if(d.length>=r.maxElements)break;Mw(d,l)||d.push(l)}return d.sort((l,u)=>{let f=l.enriched.interactivity==="static"?1:0,p=u.enriched.interactivity==="static"?1:0;return f!==p?f-p:f===1&&u.score!==l.score?u.score-l.score:l.domIndex-u.domIndex}),d.map(l=>{var p;let u;if((p=l.formattingRule)!=null&&p.formatSummary){let m=l.formattingRule.formatSummary(l.el,l.enriched,t);m&&(u=m)}let f={...l.enriched};return u&&(f.formattedSummary=u),f})}function Ew(r,e){let t=[],o=new Set,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null),a=n.currentNode;for(;a&&t.length<r.maxElements;){if(a.nodeType===Node.ELEMENT_NODE){let d=a,l=d.tagName.toLowerCase();if(My.has(l)){a=n.nextNode();continue}if(r.excludeSelector)try{if(d.closest(r.excludeSelector)){a=n.nextNode();continue}}catch{}if(r.visibleOnly&&!Py(d)){a=n.nextNode();continue}let u=Ry(d,r.maxTextLength),f=u.text.length>0,p=Object.keys(u.attributes).length>0&&!Object.keys(u.attributes).every(m=>m==="role");if(!f&&!p){a=n.nextNode();continue}o.has(u.selector)||(o.add(u.selector),t.push(u))}a=n.nextNode()}let s=[],i=[];for(let d of t)d.interactivity!=="static"?s.push(d):i.push(d);return[...s,...i].slice(0,r.maxElements)}function Iy(r={}){var o;let e=vw(r),t=(o=e.root)!=null?o:document.body;return t?e.mode==="simple"?Ew(e,t):kw(e,t):[]}var ld=100;function Hy(r,e={}){var a;if(r.length===0)return"No page elements found.";let t=(a=e.mode)!=null?a:"structured",o=[];if(t==="structured"){let s=r.map(i=>i.formattedSummary).filter(i=>!!i&&i.length>0);s.length>0&&o.push(`Structured summaries:
|
|
157
158
|
${s.map(i=>`- ${i.split(`
|
|
158
159
|
`).join(`
|
|
159
160
|
`)}`).join(`
|
|
160
|
-
`)}`)}let
|
|
161
|
+
`)}`)}let n={clickable:[],navigable:[],input:[],static:[]};for(let s of r)t==="structured"&&s.formattedSummary||n[s.interactivity].push(s);if(n.clickable.length>0){let s=n.clickable.map(i=>`- ${i.selector}: "${i.text.substring(0,ld)}" (clickable)`);o.push(`Interactive elements:
|
|
161
162
|
${s.join(`
|
|
162
|
-
`)}`)}if(
|
|
163
|
+
`)}`)}if(n.navigable.length>0){let s=n.navigable.map(i=>`- ${i.selector}${i.attributes.href?`[href="${i.attributes.href}"]`:""}: "${i.text.substring(0,ld)}" (navigable)`);o.push(`Navigation links:
|
|
163
164
|
${s.join(`
|
|
164
|
-
`)}`)}if(
|
|
165
|
+
`)}`)}if(n.input.length>0){let s=n.input.map(i=>`- ${i.selector}${i.attributes.type?`[type="${i.attributes.type}"]`:""}: "${i.text.substring(0,ld)}" (input)`);o.push(`Form inputs:
|
|
165
166
|
${s.join(`
|
|
166
|
-
`)}`)}if(
|
|
167
|
+
`)}`)}if(n.static.length>0){let s=n.static.map(i=>`- ${i.selector}: "${i.text.substring(0,ld)}"`);o.push(`Content:
|
|
167
168
|
${s.join(`
|
|
168
|
-
`)}`)}return
|
|
169
|
+
`)}`)}return o.join(`
|
|
169
170
|
|
|
170
|
-
`)}var
|
|
171
|
+
`)}var Wy="3.34.0";var By=Wy;function Dy(){return{name:"@persona/accessibility",version:"1.0.0",transform(r){return{...r,semantic:{...r.semantic,colors:{...r.semantic.colors,interactive:{...r.semantic.colors.interactive,focus:"palette.colors.primary.700",disabled:"palette.colors.gray.300"}}}}},cssVariables:{"--persona-accessibility-focus-ring":"0 0 0 2px var(--persona-semantic-colors-surface, #fff), 0 0 0 4px var(--persona-semantic-colors-interactive-focus, #0f0f0f)"}}}function Oy(){return{name:"@persona/animations",version:"1.0.0",transform(r){return{...r,palette:{...r.palette,transitions:{fast:"150ms",normal:"200ms",slow:"300ms",bounce:"500ms cubic-bezier(0.68, -0.55, 0.265, 1.55)"},easings:{easeIn:"cubic-bezier(0.4, 0, 1, 1)",easeOut:"cubic-bezier(0, 0, 0.2, 1)",easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)"}}}},cssVariables:{"--persona-transition-fast":"150ms ease","--persona-transition-normal":"200ms ease","--persona-transition-slow":"300ms ease"}}}function _y(r){return{name:"@persona/brand",version:"1.0.0",transform(e){var o;let t={...e.palette};return(o=r.colors)!=null&&o.primary&&(t.colors={...t.colors,primary:{50:fn(r.colors.primary,.95),100:fn(r.colors.primary,.9),200:fn(r.colors.primary,.8),300:fn(r.colors.primary,.7),400:fn(r.colors.primary,.6),500:r.colors.primary,600:fn(r.colors.primary,.8),700:fn(r.colors.primary,.7),800:fn(r.colors.primary,.6),900:fn(r.colors.primary,.5),950:fn(r.colors.primary,.45)}}),{...e,palette:t}}}}function Ny(){return{name:"@persona/reduced-motion",version:"1.0.0",transform(r){return{...r,palette:{...r.palette,transitions:{fast:"0ms",normal:"0ms",slow:"0ms",bounce:"0ms"}}}},afterResolve(r){return{...r,"--persona-transition-fast":"0ms","--persona-transition-normal":"0ms","--persona-transition-slow":"0ms"}}}}function Fy(){return{name:"@persona/high-contrast",version:"1.0.0",transform(r){return{...r,semantic:{...r.semantic,colors:{...r.semantic.colors,text:"palette.colors.gray.950",textMuted:"palette.colors.gray.700",border:"palette.colors.gray.900",divider:"palette.colors.gray.900"}}}}}}function fn(r,e){let t=parseInt(r.slice(1,3),16),o=parseInt(r.slice(3,5),16),n=parseInt(r.slice(5,7),16),a=Math.round(t+(255-t)*(1-e)),s=Math.round(o+(255-o)*(1-e)),i=Math.round(n+(255-n)*(1-e));return`#${a.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}function Uy(r){return{name:r.name,version:r.version,transform:r.transform||(e=>e),cssVariables:r.cssVariables,afterResolve:r.afterResolve}}var Pw={palette:{colors:{primary:{500:"#111827"},accent:{600:"#1d4ed8"},gray:{50:"#ffffff",100:"#f8fafc",200:"#f1f5f9",500:"#6b7280",900:"#000000"}},radius:{sm:"0.75rem",md:"1rem",lg:"1.5rem",launcher:"9999px",button:"9999px"}},semantic:{colors:{primary:"palette.colors.primary.500",textInverse:"palette.colors.gray.50"}}},qy={components:{panel:{borderRadius:"0",shadow:"none"}}},Mu={id:"shop",label:"Shopping Assistant",config:{theme:Pw,launcher:{title:"Shopping Assistant",subtitle:"Here to help you find what you need",agentIconText:"\u{1F6CD}\uFE0F",position:"bottom-right",width:Wo},copy:{welcomeTitle:"Welcome to our shop!",welcomeSubtitle:"I can help you find products and answer questions",inputPlaceholder:"Ask me anything...",sendButtonLabel:"Send"},suggestionChips:["What can you help me with?","Tell me about your features","How does this work?"]}},ku={id:"minimal",label:"Minimal",config:{launcher:{enabled:!1,fullHeight:!0},layout:{header:{layout:"minimal",showCloseButton:!1},messages:{layout:"minimal"}},theme:qy}},Eu={id:"fullscreen",label:"Fullscreen Assistant",config:{launcher:{enabled:!1,fullHeight:!0},layout:{header:{layout:"minimal",showCloseButton:!1},contentMaxWidth:"72ch"},theme:qy}},Lu={shop:Mu,minimal:ku,fullscreen:Eu};function zy(r){return Lu[r]}var Rw=`
|
|
171
172
|
@keyframes persona-stream-wipe {
|
|
172
173
|
from { -webkit-mask-position: 100% 0; mask-position: 100% 0; }
|
|
173
174
|
to { -webkit-mask-position: 0% 0; mask-position: 0% 0; }
|
|
@@ -203,7 +204,7 @@ ${s.join(`
|
|
|
203
204
|
mask-image: none !important;
|
|
204
205
|
}
|
|
205
206
|
}
|
|
206
|
-
`.trim(),
|
|
207
|
+
`.trim(),Iw={name:"wipe",containerClass:"persona-stream-wipe",wrap:"word",styles:Rw};Sa(Iw);var Hw=`
|
|
207
208
|
[data-persona-root] .persona-stream-glyph-cycle .persona-stream-char {
|
|
208
209
|
animation: persona-stream-glyph-cycle-fade
|
|
209
210
|
calc(var(--persona-stream-step, 120ms) * 1.5) ease-out both;
|
|
@@ -221,128 +222,128 @@ ${s.join(`
|
|
|
221
222
|
opacity: 1 !important;
|
|
222
223
|
}
|
|
223
224
|
}
|
|
224
|
-
`.trim(),
|
|
225
|
+
`.trim(),yi="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#$%&@",Ww=10,Bw=120,Pu=120,Dw=.4,Ow=50,_w=r=>{var o;if(!r)return Pu;let t=((o=r.style.getPropertyValue("--persona-stream-step"))==null?void 0:o.trim()).match(/([\d.]+)\s*ms/);return t?parseFloat(t[1]):Pu},Yy=r=>{let e=r.closest(".persona-stream-glyph-cycle"),t=_w(e);return Bw*t/Pu},Ru=r=>{let e=yi[Math.floor(Math.random()*yi.length)];return r&&e===r&&(e=yi[(yi.indexOf(e)+1)%yi.length]),e},Nw=r=>{let e=r.closest(".persona-stream-glyph-cycle");if(!e)return;let t=e.querySelectorAll(".persona-stream-char[data-glyph-cycle-final]"),o=!1;for(let n of Array.from(t)){if(n===r){o=!0;continue}o&&Math.random()<Dw&&(n.textContent=Ru())}},$y=new WeakMap,Vy=25,jy=.5,Fw=6,Gy=.25,Ky=new WeakMap,Xy=new WeakMap,Uw=(r,e)=>{var n;if(!r)return Vy*jy;let t=Ky.get(r);Ky.set(r,e);let o=(n=Xy.get(r))!=null?n:Vy;if(t!==void 0){let a=e-t;a>1&&(o=o*(1-Gy)+a*Gy,Xy.set(r,o))}return Math.max(Fw,o*jy)},ps=new Map,qw=r=>{var t;let e=r.closest("[data-message-id]");return(t=e==null?void 0:e.dataset.messageId)!=null?t:null},zw=r=>{var e;r&&ps.set(r,((e=ps.get(r))!=null?e:0)+1)},$w=r=>{var t;if(!r)return;let e=(t=ps.get(r))!=null?t:0;e<=1?ps.delete(r):ps.set(r,e-1)},Jy=r=>{var l;if(r.dataset.glyphCycleScheduled==="true")return;let e=(l=r.textContent)!=null?l:"";if(!e||/\s/.test(e))return;r.dataset.glyphCycleScheduled="true",r.dataset.glyphCycleFinal=e,r.setAttribute("data-preserve-runtime","stream-glyph-cycle"),r.textContent=Ru();let t=qw(r);t&&(r.dataset.glyphCycleMessageId=t),zw(t);let o=r.closest(".persona-stream-glyph-cycle"),n=Date.now(),a=Uw(o,n),s=Yy(r),i=Ww*s,d=n+i;if(o){let u=$y.get(o);u!==void 0&&(d=Math.max(d,u)),$y.set(o,d+a)}Vw(r,e,d)},Vw=(r,e,t)=>{var s;if(r.dataset.glyphCycleStarted==="true")return;r.dataset.glyphCycleStarted="true";let o=Yy(r),n=(s=r.textContent)!=null?s:void 0,a=()=>{var d;if(!r.isConnected)return;if(Date.now()>=t){r.textContent=e,r.removeAttribute("data-preserve-runtime"),delete r.dataset.glyphCycleStarted,delete r.dataset.glyphCycleFinal,$w((d=r.dataset.glyphCycleMessageId)!=null?d:null),delete r.dataset.glyphCycleMessageId;return}let i=Ru(n);r.textContent=i,n=i,Nw(r),setTimeout(a,o)};setTimeout(a,o)},Qy=r=>{var t;let e=(t=r.querySelectorAll)==null?void 0:t.call(r,".persona-stream-glyph-cycle .persona-stream-char:not([data-glyph-cycle-scheduled])");if(e)for(let o of Array.from(e))Jy(o)},jw=r=>r.nodeType===1,Gw={name:"glyph-cycle",containerClass:"persona-stream-glyph-cycle",wrap:"char",skipTags:["a","script","style"],styles:Hw,bufferContent(r){if(r.length<Ow)return"";let e=0,t=-1,o=0;for(;o<r.length;){if(r[o]==="*"&&r[o+1]==="*"){e+=1,o+=2;continue}/\s/.test(r[o])&&e%2===0&&(t=o),o+=1}return t<0?"":r.slice(0,t)},isAnimating(r){var e;return((e=ps.get(r.id))!=null?e:0)>0},onAttach(r){Qy(r);let e=new MutationObserver(t=>{for(let o of t)for(let n of Array.from(o.addedNodes))jw(n)&&(n.classList.contains("persona-stream-char")&&n.closest(".persona-stream-glyph-cycle")?Jy(n):Qy(n))});return e.observe(r,{childList:!0,subtree:!0}),()=>e.disconnect()}};Sa(Gw);var Zy,eb,La=typeof document!="undefined"&&(eb=(Zy=document.currentScript)==null?void 0:Zy.src)!=null?eb:null;Wh(()=>{let r=La==null?void 0:La.replace(/index\.global\.js($|\?)/,"webmcp-polyfill.js$1");return!r||r===La?Promise.reject(new Error(`Could not derive the webmcp-polyfill.js URL from the widget script URL (${La!=null?La:"unavailable"}). Self-hosted deployments that rename index.global.js should install @mcp-b/webmcp-polyfill on the page themselves before enabling config.webmcp.`)):import(r)});return gb(Kw);})();
|
|
225
226
|
/*! Bundled license information:
|
|
226
227
|
|
|
227
228
|
dompurify/dist/purify.es.mjs:
|
|
228
|
-
(*! @license DOMPurify 3.
|
|
229
|
+
(*! @license DOMPurify 3.4.10 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.10/LICENSE *)
|
|
229
230
|
|
|
230
|
-
lucide/dist/esm/icons/activity.
|
|
231
|
-
lucide/dist/esm/icons/arrow-down.
|
|
232
|
-
lucide/dist/esm/icons/arrow-left.
|
|
233
|
-
lucide/dist/esm/icons/arrow-right.
|
|
234
|
-
lucide/dist/esm/icons/arrow-up-right.
|
|
235
|
-
lucide/dist/esm/icons/arrow-up.
|
|
236
|
-
lucide/dist/esm/icons/at-sign.
|
|
237
|
-
lucide/dist/esm/icons/ban.
|
|
238
|
-
lucide/dist/esm/icons/bell.
|
|
239
|
-
lucide/dist/esm/icons/bookmark.
|
|
240
|
-
lucide/dist/esm/icons/bot.
|
|
241
|
-
lucide/dist/esm/icons/building.
|
|
242
|
-
lucide/dist/esm/icons/calendar-days.
|
|
243
|
-
lucide/dist/esm/icons/calendar.
|
|
244
|
-
lucide/dist/esm/icons/camera.
|
|
245
|
-
lucide/dist/esm/icons/check.
|
|
246
|
-
lucide/dist/esm/icons/chevron-down.
|
|
247
|
-
lucide/dist/esm/icons/chevron-left.
|
|
248
|
-
lucide/dist/esm/icons/chevron-right.
|
|
249
|
-
lucide/dist/esm/icons/chevron-up.
|
|
250
|
-
lucide/dist/esm/icons/circle-check.
|
|
251
|
-
lucide/dist/esm/icons/circle-x.
|
|
252
|
-
lucide/dist/esm/icons/clipboard-copy.
|
|
253
|
-
lucide/dist/esm/icons/clipboard.
|
|
254
|
-
lucide/dist/esm/icons/clock.
|
|
255
|
-
lucide/dist/esm/icons/copy.
|
|
256
|
-
lucide/dist/esm/icons/credit-card.
|
|
257
|
-
lucide/dist/esm/icons/dollar-sign.
|
|
258
|
-
lucide/dist/esm/icons/download.
|
|
259
|
-
lucide/dist/esm/icons/ellipsis-vertical.
|
|
260
|
-
lucide/dist/esm/icons/ellipsis.
|
|
261
|
-
lucide/dist/esm/icons/
|
|
262
|
-
lucide/dist/esm/icons/
|
|
263
|
-
lucide/dist/esm/icons/eye.
|
|
264
|
-
lucide/dist/esm/icons/file-code.
|
|
265
|
-
lucide/dist/esm/icons/file-spreadsheet.
|
|
266
|
-
lucide/dist/esm/icons/file-text.
|
|
267
|
-
lucide/dist/esm/icons/file.
|
|
268
|
-
lucide/dist/esm/icons/files.
|
|
269
|
-
lucide/dist/esm/icons/film.
|
|
270
|
-
lucide/dist/esm/icons/flag.
|
|
271
|
-
lucide/dist/esm/icons/folder-open.
|
|
272
|
-
lucide/dist/esm/icons/folder.
|
|
273
|
-
lucide/dist/esm/icons/funnel.
|
|
274
|
-
lucide/dist/esm/icons/gift.
|
|
275
|
-
lucide/dist/esm/icons/globe.
|
|
276
|
-
lucide/dist/esm/icons/hash.
|
|
277
|
-
lucide/dist/esm/icons/headphones.
|
|
278
|
-
lucide/dist/esm/icons/heart.
|
|
279
|
-
lucide/dist/esm/icons/history.
|
|
280
|
-
lucide/dist/esm/icons/house.
|
|
281
|
-
lucide/dist/esm/icons/image-plus.
|
|
282
|
-
lucide/dist/esm/icons/image.
|
|
283
|
-
lucide/dist/esm/icons/info.
|
|
284
|
-
lucide/dist/esm/icons/key.
|
|
285
|
-
lucide/dist/esm/icons/link.
|
|
286
|
-
lucide/dist/esm/icons/loader-circle.
|
|
287
|
-
lucide/dist/esm/icons/loader.
|
|
288
|
-
lucide/dist/esm/icons/lock.
|
|
289
|
-
lucide/dist/esm/icons/mail.
|
|
290
|
-
lucide/dist/esm/icons/map-pin.
|
|
291
|
-
lucide/dist/esm/icons/maximize.
|
|
292
|
-
lucide/dist/esm/icons/menu.
|
|
293
|
-
lucide/dist/esm/icons/message-circle.
|
|
294
|
-
lucide/dist/esm/icons/message-square.
|
|
295
|
-
lucide/dist/esm/icons/mic.
|
|
296
|
-
lucide/dist/esm/icons/minimize.
|
|
297
|
-
lucide/dist/esm/icons/minus.
|
|
298
|
-
lucide/dist/esm/icons/monitor.
|
|
299
|
-
lucide/dist/esm/icons/moon.
|
|
300
|
-
lucide/dist/esm/icons/package.
|
|
301
|
-
lucide/dist/esm/icons/paperclip.
|
|
302
|
-
lucide/dist/esm/icons/pause.
|
|
303
|
-
lucide/dist/esm/icons/pencil.
|
|
304
|
-
lucide/dist/esm/icons/percent.
|
|
305
|
-
lucide/dist/esm/icons/phone.
|
|
306
|
-
lucide/dist/esm/icons/play.
|
|
307
|
-
lucide/dist/esm/icons/plus.
|
|
308
|
-
lucide/dist/esm/icons/receipt.
|
|
309
|
-
lucide/dist/esm/icons/refresh-cw.
|
|
310
|
-
lucide/dist/esm/icons/rotate-cw.
|
|
311
|
-
lucide/dist/esm/icons/save.
|
|
312
|
-
lucide/dist/esm/icons/search.
|
|
313
|
-
lucide/dist/esm/icons/send.
|
|
314
|
-
lucide/dist/esm/icons/settings.
|
|
315
|
-
lucide/dist/esm/icons/share.
|
|
316
|
-
lucide/dist/esm/icons/shield-alert.
|
|
317
|
-
lucide/dist/esm/icons/shield-check.
|
|
318
|
-
lucide/dist/esm/icons/shield-x.
|
|
319
|
-
lucide/dist/esm/icons/shield.
|
|
320
|
-
lucide/dist/esm/icons/shopping-bag.
|
|
321
|
-
lucide/dist/esm/icons/shopping-cart.
|
|
322
|
-
lucide/dist/esm/icons/smartphone.
|
|
323
|
-
lucide/dist/esm/icons/sparkles.
|
|
324
|
-
lucide/dist/esm/icons/square.
|
|
325
|
-
lucide/dist/esm/icons/star.
|
|
326
|
-
lucide/dist/esm/icons/store.
|
|
327
|
-
lucide/dist/esm/icons/sun.
|
|
328
|
-
lucide/dist/esm/icons/tag.
|
|
329
|
-
lucide/dist/esm/icons/thumbs-down.
|
|
330
|
-
lucide/dist/esm/icons/thumbs-up.
|
|
331
|
-
lucide/dist/esm/icons/timer.
|
|
332
|
-
lucide/dist/esm/icons/trash-2.
|
|
333
|
-
lucide/dist/esm/icons/trash.
|
|
334
|
-
lucide/dist/esm/icons/triangle-alert.
|
|
335
|
-
lucide/dist/esm/icons/truck.
|
|
336
|
-
lucide/dist/esm/icons/upload.
|
|
337
|
-
lucide/dist/esm/icons/user.
|
|
338
|
-
lucide/dist/esm/icons/volume-2.
|
|
339
|
-
lucide/dist/esm/icons/volume-x.
|
|
340
|
-
lucide/dist/esm/icons/wallet.
|
|
341
|
-
lucide/dist/esm/icons/x.
|
|
342
|
-
lucide/dist/esm/icons/zap.
|
|
343
|
-
lucide/dist/esm/lucide.
|
|
231
|
+
lucide/dist/esm/icons/activity.mjs:
|
|
232
|
+
lucide/dist/esm/icons/arrow-down.mjs:
|
|
233
|
+
lucide/dist/esm/icons/arrow-left.mjs:
|
|
234
|
+
lucide/dist/esm/icons/arrow-right.mjs:
|
|
235
|
+
lucide/dist/esm/icons/arrow-up-right.mjs:
|
|
236
|
+
lucide/dist/esm/icons/arrow-up.mjs:
|
|
237
|
+
lucide/dist/esm/icons/at-sign.mjs:
|
|
238
|
+
lucide/dist/esm/icons/ban.mjs:
|
|
239
|
+
lucide/dist/esm/icons/bell.mjs:
|
|
240
|
+
lucide/dist/esm/icons/bookmark.mjs:
|
|
241
|
+
lucide/dist/esm/icons/bot.mjs:
|
|
242
|
+
lucide/dist/esm/icons/building.mjs:
|
|
243
|
+
lucide/dist/esm/icons/calendar-days.mjs:
|
|
244
|
+
lucide/dist/esm/icons/calendar.mjs:
|
|
245
|
+
lucide/dist/esm/icons/camera.mjs:
|
|
246
|
+
lucide/dist/esm/icons/check.mjs:
|
|
247
|
+
lucide/dist/esm/icons/chevron-down.mjs:
|
|
248
|
+
lucide/dist/esm/icons/chevron-left.mjs:
|
|
249
|
+
lucide/dist/esm/icons/chevron-right.mjs:
|
|
250
|
+
lucide/dist/esm/icons/chevron-up.mjs:
|
|
251
|
+
lucide/dist/esm/icons/circle-check.mjs:
|
|
252
|
+
lucide/dist/esm/icons/circle-x.mjs:
|
|
253
|
+
lucide/dist/esm/icons/clipboard-copy.mjs:
|
|
254
|
+
lucide/dist/esm/icons/clipboard.mjs:
|
|
255
|
+
lucide/dist/esm/icons/clock.mjs:
|
|
256
|
+
lucide/dist/esm/icons/copy.mjs:
|
|
257
|
+
lucide/dist/esm/icons/credit-card.mjs:
|
|
258
|
+
lucide/dist/esm/icons/dollar-sign.mjs:
|
|
259
|
+
lucide/dist/esm/icons/download.mjs:
|
|
260
|
+
lucide/dist/esm/icons/ellipsis-vertical.mjs:
|
|
261
|
+
lucide/dist/esm/icons/ellipsis.mjs:
|
|
262
|
+
lucide/dist/esm/icons/eye-off.mjs:
|
|
263
|
+
lucide/dist/esm/icons/external-link.mjs:
|
|
264
|
+
lucide/dist/esm/icons/eye.mjs:
|
|
265
|
+
lucide/dist/esm/icons/file-code.mjs:
|
|
266
|
+
lucide/dist/esm/icons/file-spreadsheet.mjs:
|
|
267
|
+
lucide/dist/esm/icons/file-text.mjs:
|
|
268
|
+
lucide/dist/esm/icons/file.mjs:
|
|
269
|
+
lucide/dist/esm/icons/files.mjs:
|
|
270
|
+
lucide/dist/esm/icons/film.mjs:
|
|
271
|
+
lucide/dist/esm/icons/flag.mjs:
|
|
272
|
+
lucide/dist/esm/icons/folder-open.mjs:
|
|
273
|
+
lucide/dist/esm/icons/folder.mjs:
|
|
274
|
+
lucide/dist/esm/icons/funnel.mjs:
|
|
275
|
+
lucide/dist/esm/icons/gift.mjs:
|
|
276
|
+
lucide/dist/esm/icons/globe.mjs:
|
|
277
|
+
lucide/dist/esm/icons/hash.mjs:
|
|
278
|
+
lucide/dist/esm/icons/headphones.mjs:
|
|
279
|
+
lucide/dist/esm/icons/heart.mjs:
|
|
280
|
+
lucide/dist/esm/icons/history.mjs:
|
|
281
|
+
lucide/dist/esm/icons/house.mjs:
|
|
282
|
+
lucide/dist/esm/icons/image-plus.mjs:
|
|
283
|
+
lucide/dist/esm/icons/image.mjs:
|
|
284
|
+
lucide/dist/esm/icons/info.mjs:
|
|
285
|
+
lucide/dist/esm/icons/key.mjs:
|
|
286
|
+
lucide/dist/esm/icons/link.mjs:
|
|
287
|
+
lucide/dist/esm/icons/loader-circle.mjs:
|
|
288
|
+
lucide/dist/esm/icons/loader.mjs:
|
|
289
|
+
lucide/dist/esm/icons/lock.mjs:
|
|
290
|
+
lucide/dist/esm/icons/mail.mjs:
|
|
291
|
+
lucide/dist/esm/icons/map-pin.mjs:
|
|
292
|
+
lucide/dist/esm/icons/maximize.mjs:
|
|
293
|
+
lucide/dist/esm/icons/menu.mjs:
|
|
294
|
+
lucide/dist/esm/icons/message-circle.mjs:
|
|
295
|
+
lucide/dist/esm/icons/message-square.mjs:
|
|
296
|
+
lucide/dist/esm/icons/mic.mjs:
|
|
297
|
+
lucide/dist/esm/icons/minimize.mjs:
|
|
298
|
+
lucide/dist/esm/icons/minus.mjs:
|
|
299
|
+
lucide/dist/esm/icons/monitor.mjs:
|
|
300
|
+
lucide/dist/esm/icons/moon.mjs:
|
|
301
|
+
lucide/dist/esm/icons/package.mjs:
|
|
302
|
+
lucide/dist/esm/icons/paperclip.mjs:
|
|
303
|
+
lucide/dist/esm/icons/pause.mjs:
|
|
304
|
+
lucide/dist/esm/icons/pencil.mjs:
|
|
305
|
+
lucide/dist/esm/icons/percent.mjs:
|
|
306
|
+
lucide/dist/esm/icons/phone.mjs:
|
|
307
|
+
lucide/dist/esm/icons/play.mjs:
|
|
308
|
+
lucide/dist/esm/icons/plus.mjs:
|
|
309
|
+
lucide/dist/esm/icons/receipt.mjs:
|
|
310
|
+
lucide/dist/esm/icons/refresh-cw.mjs:
|
|
311
|
+
lucide/dist/esm/icons/rotate-cw.mjs:
|
|
312
|
+
lucide/dist/esm/icons/save.mjs:
|
|
313
|
+
lucide/dist/esm/icons/search.mjs:
|
|
314
|
+
lucide/dist/esm/icons/send.mjs:
|
|
315
|
+
lucide/dist/esm/icons/settings.mjs:
|
|
316
|
+
lucide/dist/esm/icons/share.mjs:
|
|
317
|
+
lucide/dist/esm/icons/shield-alert.mjs:
|
|
318
|
+
lucide/dist/esm/icons/shield-check.mjs:
|
|
319
|
+
lucide/dist/esm/icons/shield-x.mjs:
|
|
320
|
+
lucide/dist/esm/icons/shield.mjs:
|
|
321
|
+
lucide/dist/esm/icons/shopping-bag.mjs:
|
|
322
|
+
lucide/dist/esm/icons/shopping-cart.mjs:
|
|
323
|
+
lucide/dist/esm/icons/smartphone.mjs:
|
|
324
|
+
lucide/dist/esm/icons/sparkles.mjs:
|
|
325
|
+
lucide/dist/esm/icons/square.mjs:
|
|
326
|
+
lucide/dist/esm/icons/star.mjs:
|
|
327
|
+
lucide/dist/esm/icons/store.mjs:
|
|
328
|
+
lucide/dist/esm/icons/sun.mjs:
|
|
329
|
+
lucide/dist/esm/icons/tag.mjs:
|
|
330
|
+
lucide/dist/esm/icons/thumbs-down.mjs:
|
|
331
|
+
lucide/dist/esm/icons/thumbs-up.mjs:
|
|
332
|
+
lucide/dist/esm/icons/timer.mjs:
|
|
333
|
+
lucide/dist/esm/icons/trash-2.mjs:
|
|
334
|
+
lucide/dist/esm/icons/trash.mjs:
|
|
335
|
+
lucide/dist/esm/icons/triangle-alert.mjs:
|
|
336
|
+
lucide/dist/esm/icons/truck.mjs:
|
|
337
|
+
lucide/dist/esm/icons/upload.mjs:
|
|
338
|
+
lucide/dist/esm/icons/user.mjs:
|
|
339
|
+
lucide/dist/esm/icons/volume-2.mjs:
|
|
340
|
+
lucide/dist/esm/icons/volume-x.mjs:
|
|
341
|
+
lucide/dist/esm/icons/wallet.mjs:
|
|
342
|
+
lucide/dist/esm/icons/x.mjs:
|
|
343
|
+
lucide/dist/esm/icons/zap.mjs:
|
|
344
|
+
lucide/dist/esm/lucide.mjs:
|
|
344
345
|
(**
|
|
345
|
-
* @license lucide
|
|
346
|
+
* @license lucide v1.18.0 - ISC
|
|
346
347
|
*
|
|
347
348
|
* This source code is licensed under the ISC license.
|
|
348
349
|
* See the LICENSE file in the root directory of this source tree.
|