@runtypelabs/persona 4.34.0 → 4.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/activity-ui.d.cts +3 -3
- package/dist/activity-ui.d.ts +3 -3
- package/dist/animations/glyph-cycle.d.cts +1 -1
- package/dist/animations/glyph-cycle.d.ts +1 -1
- package/dist/animations/wipe.d.cts +1 -1
- package/dist/animations/wipe.d.ts +1 -1
- package/dist/approval-ui.d.cts +3 -3
- package/dist/approval-ui.d.ts +3 -3
- package/dist/artifacts-ui.d.cts +3 -3
- package/dist/artifacts-ui.d.ts +3 -3
- package/dist/background-runtime.d.cts +1 -1
- package/dist/background-runtime.d.ts +1 -1
- package/dist/{chunk-CxNPSY-b.js → chunk-B1P8w9_X.js} +1 -1
- package/dist/{chunk-CV8EPIhT.js → chunk-B30Jdgg6.js} +1 -1
- package/dist/{chunk-6CUrH_jm.js → chunk-Bzo9GaAi.js} +1 -1
- package/dist/chunk-CNBMBx-Y.js +2 -0
- package/dist/chunk-Cd8mp8Sv.js +1 -0
- package/dist/chunk-CsfE8WRG.js +1 -0
- package/dist/{chunk-Co3VVwGe.js → chunk-D2pHRNEq.js} +0 -0
- package/dist/chunk-D3kZO8u-.js +1 -0
- package/dist/chunk-DAthf5H3.js +1 -0
- package/dist/{chunk-YMkMvAsa.js → chunk-DZ_aillY.js} +1 -1
- package/dist/{chunk-6C23QQdP.js → chunk-DgJV9zbK.js} +1 -1
- package/dist/chunk-Dv6KtIT1.js +1 -0
- package/dist/chunk-Dws8IrdR.js +1 -0
- package/dist/{chunk-DsWv3EGF.js → chunk-ThxxD8oK.js} +1 -1
- package/dist/client-dispatch.js +1 -1
- package/dist/client-history.js +1 -1
- package/dist/codegen.cjs +1 -1
- package/dist/codegen.js +1 -1
- package/dist/composer-actions-runtime.cjs +1 -1
- package/dist/composer-actions-runtime.d.cts +3 -3
- package/dist/composer-actions-runtime.d.ts +3 -3
- package/dist/composer-actions-runtime.js +1 -1
- package/dist/{composer-input-i_FiUp6J.d.cts → composer-input-BSDNPOqV.d.cts} +1 -1
- package/dist/{composer-input-i_FiUp6J.d.ts → composer-input-BSDNPOqV.d.ts} +1 -1
- package/dist/{composer-store-DhGNgG7Z.d.cts → composer-store-DC-gAjtN.d.cts} +1 -1
- package/dist/{composer-store-DhGNgG7Z.d.ts → composer-store-DC-gAjtN.d.ts} +1 -1
- package/dist/{context-mention-manager-DL-xwGfL.d.cts → context-mention-manager-CCpeoGL2.d.cts} +2 -2
- package/dist/{context-mention-manager-DL-xwGfL.d.ts → context-mention-manager-CCpeoGL2.d.ts} +2 -2
- package/dist/context-mentions-inline.d.cts +2 -2
- package/dist/context-mentions-inline.d.ts +2 -2
- package/dist/context-mentions.cjs +1 -1
- package/dist/context-mentions.d.cts +3 -3
- package/dist/context-mentions.d.ts +3 -3
- package/dist/context-mentions.js +1 -1
- package/dist/{defaults-Bga2Xrsp.d.cts → defaults-tj5RcN8r.d.cts} +1 -1
- package/dist/{defaults-Bga2Xrsp.d.ts → defaults-tj5RcN8r.d.ts} +1 -1
- package/dist/dictation-runtime.d.cts +2 -2
- package/dist/dictation-runtime.d.ts +2 -2
- package/dist/event-stream-view.d.cts +1 -1
- package/dist/event-stream-view.d.ts +1 -1
- package/dist/{fallback-speech-engine-kLdyPcmk.d.cts → fallback-speech-engine-gkhbjLiZ.d.cts} +1 -1
- package/dist/{fallback-speech-engine-kLdyPcmk.d.ts → fallback-speech-engine-gkhbjLiZ.d.ts} +1 -1
- package/dist/{feature-preferences-CmwZGKrf.d.cts → feature-preferences-CerDWGZ7.d.cts} +1 -1
- package/dist/{feature-preferences-CmwZGKrf.d.ts → feature-preferences-CerDWGZ7.d.ts} +1 -1
- package/dist/forms-ui.d.cts +2 -2
- package/dist/forms-ui.d.ts +2 -2
- package/dist/{history-confirm-dialog-i46-lPN_.d.cts → history-confirm-dialog-CrkSB3Ra.d.cts} +1 -1
- package/dist/{history-confirm-dialog-i46-lPN_.d.ts → history-confirm-dialog-CrkSB3Ra.d.ts} +1 -1
- package/dist/history-shell.d.cts +6 -6
- package/dist/history-shell.d.ts +6 -6
- package/dist/history-view.d.cts +1 -1
- package/dist/history-view.d.ts +1 -1
- package/dist/index.cjs +32 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.global.js +1 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +40 -40
- package/dist/index.js.map +1 -1
- package/dist/install.global.js +1 -1
- package/dist/launcher.global.js +1 -1
- package/dist/{loading-label-runtime-loader-Ccr3ETd3.d.cts → loading-label-runtime-loader-fWIRrhUF.d.cts} +1 -1
- package/dist/{loading-label-runtime-loader-Ccr3ETd3.d.ts → loading-label-runtime-loader-fWIRrhUF.d.ts} +1 -1
- package/dist/loading-label-runtime.d.cts +1 -1
- package/dist/loading-label-runtime.d.ts +1 -1
- package/dist/{message-bubble-C6AVaH7f.d.cts → message-bubble-Czc0lOHr.d.cts} +1 -1
- package/dist/{message-bubble-C6AVaH7f.d.ts → message-bubble-Czc0lOHr.d.ts} +1 -1
- package/dist/{plugin-kit-BVggqE3C.d.cts → plugin-kit-C30jE-cw.d.cts} +3 -1
- package/dist/{plugin-kit-BVggqE3C.d.ts → plugin-kit-C30jE-cw.d.ts} +3 -1
- package/dist/plugin-kit.cjs +1 -1
- package/dist/plugin-kit.d.cts +1 -1
- package/dist/plugin-kit.d.ts +1 -1
- package/dist/plugin-kit.js +1 -1
- package/dist/preferences-runtime.d.cts +1 -1
- package/dist/preferences-runtime.d.ts +1 -1
- package/dist/{preview-BMdRffo4.d.cts → preview-D-osV3FU.d.cts} +2 -2
- package/dist/{preview-BMdRffo4.d.ts → preview-D-osV3FU.d.ts} +2 -2
- package/dist/{registry-B16l8s1b.d.cts → registry-B6w91tx0.d.cts} +1 -1
- package/dist/{registry-B16l8s1b.d.ts → registry-B6w91tx0.d.ts} +1 -1
- package/dist/{session-CtZHe7fc.d.cts → session-BUQrs3Of.d.cts} +10 -9
- package/dist/{session-CtZHe7fc.d.ts → session-BUQrs3Of.d.ts} +10 -9
- package/dist/session-reconnect.d.cts +2 -2
- package/dist/session-reconnect.d.ts +2 -2
- package/dist/smart-dom-reader.d.cts +1 -1
- package/dist/smart-dom-reader.d.ts +1 -1
- package/dist/theme-editor-preview.cjs +43 -43
- package/dist/theme-editor-preview.d.cts +1 -1
- package/dist/theme-editor-preview.d.ts +1 -1
- package/dist/theme-editor-preview.js +3 -3
- package/dist/theme-editor.d.cts +2 -2
- package/dist/theme-editor.d.ts +2 -2
- package/dist/theme-reference.d.cts +2 -2
- package/dist/theme-reference.d.ts +2 -2
- package/dist/{tool-loading-animation-D2cyFvmM.d.cts → tool-loading-animation-B7XUf8TN.d.cts} +1 -1
- package/dist/{tool-loading-animation-D2cyFvmM.d.ts → tool-loading-animation-B7XUf8TN.d.ts} +1 -1
- package/dist/{turn-activity-ui-Do1Nd-Ow.d.cts → turn-activity-ui-CohuNMHT.d.cts} +2 -2
- package/dist/{turn-activity-ui-Do1Nd-Ow.d.ts → turn-activity-ui-CohuNMHT.d.ts} +2 -2
- package/dist/turn-activity-ui.d.cts +1 -1
- package/dist/turn-activity-ui.d.ts +1 -1
- package/dist/{types-BC7MRxO5.d.cts → types-9i0xcAMT.d.cts} +52 -0
- package/dist/{types-BC7MRxO5.d.ts → types-9i0xcAMT.d.ts} +52 -0
- package/dist/voice-client-tools.d.cts +1 -1
- package/dist/voice-client-tools.d.ts +1 -1
- package/dist/voice-runtime.cjs +1 -1
- package/dist/voice-runtime.d.cts +2 -2
- package/dist/voice-runtime.d.ts +2 -2
- package/dist/voice-runtime.js +1 -1
- package/dist/voice-worklet-player.d.cts +2 -2
- package/dist/voice-worklet-player.d.ts +2 -2
- package/dist/{webmcp-runtime-entry-B8g46vS0.d.ts → webmcp-runtime-entry-XNaXa-9h.d.cts} +9 -1
- package/dist/{webmcp-runtime-entry-B8g46vS0.d.cts → webmcp-runtime-entry-XNaXa-9h.d.ts} +9 -1
- package/dist/webmcp-runtime.cjs +1 -1
- package/dist/webmcp-runtime.d.cts +1 -1
- package/dist/webmcp-runtime.d.ts +1 -1
- package/dist/webmcp-runtime.js +1 -1
- package/package.json +2 -2
- package/src/client-dispatch.ts +13 -0
- package/src/client.ts +37 -2
- package/src/client.webmcp-require-confirm.test.ts +212 -0
- package/src/components/composer-model-picker.ts +0 -14
- package/src/components/composer-overflow-menu.ts +0 -15
- package/src/components/composer-tokens.ts +0 -20
- package/src/generated/runtype-openapi-contract.ts +13 -0
- package/src/plugin-kit.test.ts +101 -0
- package/src/plugin-kit.ts +29 -1
- package/src/session.ts +6 -2
- package/src/session.webmcp.test.ts +32 -0
- package/src/types.ts +35 -0
- package/src/ui.composer-models.test.ts +5 -7
- package/src/ui.composer-overflow.test.ts +14 -21
- package/src/utils/context-mention-controller.test.ts +56 -0
- package/src/webmcp-bridge.test.ts +102 -0
- package/src/webmcp-runtime-entry.ts +29 -1
- package/dist/chunk-BAkaTZpd.js +0 -1
- package/dist/chunk-BEDTp-dm.js +0 -1
- package/dist/chunk-C-rux8Q9.js +0 -1
- package/dist/chunk-CNhThrLX.js +0 -1
- package/dist/chunk-CzLEhoB_.js +0 -2
- package/dist/chunk-Dqa_GOcj.js +0 -1
- package/dist/chunk-NUNdcnAZ.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,r as t}from"./chunk-D5BxWOFB.js";import{n}from"./chunk-C8560fIY.js";import{n as r}from"./chunk-CNhThrLX.js";import{t as i}from"./chunk-CLMIHW4_.js";function a(){let e=document.createElement(`div`);e.className=`persona-history-sr-only`,e.setAttribute(`role`,`status`),e.setAttribute(`aria-live`,`polite`),e.setAttribute(`aria-atomic`,`true`),e.setAttribute(`data-persona-history-live-region`,``);let t;return{element:e,announce(n){t!==void 0&&clearTimeout(t),e.textContent=``,t=setTimeout(()=>{t=void 0,e.textContent=n},0)},destroy(){t!==void 0&&clearTimeout(t),e.remove()}}}const o={...i,emptyTitle:`No conversations yet`,emptyDescription:`Start a conversation and it will show up here.`,errorTitle:`Could not load conversations`,errorDescription:`Something went wrong. Please try again.`,retryLabel:`Retry`,rateLimitedTitle:`Too many requests`,rateLimitedDescription:`Please wait a moment before trying again.`,groupStarred:`Starred`,groupToday:`Today`,groupYesterday:`Yesterday`,groupPrevious7Days:`Previous 7 days`,groupPrevious30Days:`Previous 30 days`,groupMonthYear:`{month} {year}`,browserOnlyTitle:`On this device`,browserOnlyDescription:`Another browser or device keeps its own separate history.`,verifyingTitle:`Checking your account`,verifyingDescription:`Looking for messages linked to your account.`,verifiedTitle:`Available across signed-in devices`,verifiedDescription:`This list refreshes when the chat opens rather than syncing live.`,authenticationRequiredTitle:`Sign in to see your messages`,authenticationRequiredDescription:`Your session expired. Sign in again to load account history.`,identityProviderFailedTitle:`Account history is unavailable`,identityProviderFailedDescription:`We could not verify your account, so account history is not shown here.`,proofNotAdmittedTitle:`Account history is unavailable`,proofNotAdmittedDescription:`This assistant is not set up to accept your account identity.`,retryIdentityLabel:`Try again`,backLabel:`Back to conversation`,closeLabel:`Close conversation list`,loadingLabel:`Loading conversations`,loadMoreLabel:`Load more`,loadingMoreLabel:`Loading more conversations`,conversationsTitle:`Conversations`,rowActionsLabel:`Conversation options`,listOptionsLabel:`Conversation options`,deleteConversationLabel:`Delete`,clearHistoryLabel:`Delete all conversations`,resetIdentityLabel:`Forget this device`,messageCountLabel:`{count} messages`,messageCountLabelOne:`1 message`,conversationRemovedNotice:`Conversation deleted.`,historyClearedNotice:`All conversations were deleted.`,unavailableTitle:`Conversation history is unavailable`,unavailableDescription:`Try again later.`,newConversationRequiredTitle:`Start a new conversation`,newConversationRequiredDescription:`The previous conversation is gone. Start a new one to keep chatting.`,rateLimitedWaitDescription:`You can try again in {seconds} seconds.`,openFailedLabel:`Could not open that conversation.`,deleteFailedLabel:`Could not delete that conversation.`,relativeNow:`now`,relativeMinutes:`{value}m`,relativeHours:`{value}h`,relativeDays:`{value}d`,relativeWeeks:`{value}w`,relativeYears:`{value}y`};function s(e){if(!e)return o;let t={...o};for(let[n,r]of Object.entries(e))typeof r==`string`&&r.length>0&&(t[n]=r);return t}function c(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):e)}const l=864e5;function u(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function d(e,t){let n=Date.parse(e);return Number.isFinite(n)?n:t}function f(e,t){let n=d(e,t),r=u(t);if(n>=r)return`today`;if(n>=r-l)return`yesterday`;if(n>=r-7*l)return`previous-7-days`;if(n>=r-30*l)return`previous-30-days`;let i=new Date(n);return`month:${i.getFullYear()}-${i.getMonth()}`}function p(e,t,n,r){if(e===`today`)return r.groupToday;if(e===`yesterday`)return r.groupYesterday;if(e===`previous-7-days`)return r.groupPrevious7Days;if(e===`previous-30-days`)return r.groupPrevious30Days;let i=new Date(d(t,n));return c(r.groupMonthYear,{month:i.toLocaleString(void 0,{month:`long`}),year:i.getFullYear()})}function ee(e,t,n,r=`time`){let i=e.filter(e=>e.starred),a=i.length>0?[{key:`starred`,label:n.groupStarred,items:i}]:[];if(r===`none`){let t=e.filter(e=>!e.starred);return t.length>0&&a.push({key:`recent`,label:n.conversationsTitle,items:t}),a}for(let r of e){if(r.starred)continue;let e=f(r.updatedAt,t),i=a[a.length-1];i&&i.key===e?i.items.push(r):a.push({key:e,label:p(e,r.updatedAt,t,n),items:[r]})}return a}function m(e,t,n){let r=Math.max(0,t-d(e,t)),i=Math.floor(r/6e4);if(i<1)return n.relativeNow;if(i<60)return c(n.relativeMinutes,{value:i});let a=Math.floor(i/60);if(a<24)return c(n.relativeHours,{value:a});let o=Math.floor(a/24);if(o<7)return c(n.relativeDays,{value:o});let s=Math.floor(o/7);return o<365?c(n.relativeWeeks,{value:s}):c(n.relativeYears,{value:Math.floor(o/365)})}function h(e,t){return e===1?t.messageCountLabelOne:c(t.messageCountLabel,{count:e})}const g=`http://www.w3.org/2000/svg`,te={"arrow-left":[`m12 19-7-7 7-7`,`M19 12H5`],plus:[`M5 12h14`,`M12 5v14`],star:[`m12 2 2.9 6.2 6.8.7-5.1 4.5 1.4 6.6-6-3.4-6 3.4 1.4-6.6-5.1-4.5 6.8-.7z`],x:[`M18 6 6 18`,`m6 6 12 12`],"panel-left":[`M9 3v18`],monitor:[`M8 21h8`,`M12 17v4`],ellipsis:[]},_={"panel-left":[3,3,18,18],monitor:[2,3,20,14]};function v(e,t=20){let n=document.createElementNS(g,`svg`);if(n.setAttribute(`width`,String(t)),n.setAttribute(`height`,String(t)),n.setAttribute(`viewBox`,`0 0 24 24`),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`2`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`focusable`,`false`),e===`ellipsis`){for(let e of[12,19,5]){let t=document.createElementNS(g,`circle`);t.setAttribute(`cx`,String(e)),t.setAttribute(`cy`,`12`),t.setAttribute(`r`,`1`),n.appendChild(t)}return n}let r=_[e];if(r){let e=document.createElementNS(g,`rect`);e.setAttribute(`x`,String(r[0])),e.setAttribute(`y`,String(r[1])),e.setAttribute(`width`,String(r[2])),e.setAttribute(`height`,String(r[3])),e.setAttribute(`rx`,`2`),n.appendChild(e)}for(let t of te[e]){let e=document.createElementNS(g,`path`);e.setAttribute(`d`,t),n.appendChild(e)}return n}const y=/^(https?:|\/|data:)/i;function b(e){let n=t(`span`,{className:`persona-history-row-avatar`,attrs:{"aria-hidden":`true`}});return y.test(e)?n.appendChild(t(`img`,{attrs:{src:e,alt:``,loading:`lazy`}})):n.textContent=e,n}const x=e=>`row:${e}`,S=e=>`menu:${e}`,C=e=>`menu-item:${e}`;function ne(n){let{conversation:r,copy:i,busy:a,pending:o}=n,s=a||o!==null,c=r.title.trim().length>0,l=r.starred?(()=>{let e=v(`star`,11);return e.setAttribute(`fill`,`currentColor`),e.setAttribute(`stroke-width`,`1`),t(`span`,{className:`persona-history-row-star`},e,t(`span`,{className:`persona-history-sr-only`,text:i.groupStarred}))})():null,u=t(`div`,{className:`persona-history-row-head`},t(`span`,{className:`persona-history-row-title persona-history-truncate`,text:c?r.title:r.preview??``}),l,t(`time`,{className:`persona-history-row-time`,attrs:{datetime:r.updatedAt},text:m(r.updatedAt,n.nowMs,i)})),d=c&&r.preview?t(`span`,{className:`persona-history-row-preview persona-history-truncate`,text:r.preview}):null,f=t(`button`,{className:e(`persona-history-row`,n.active&&`persona-history-row--active`,o&&`persona-history-row--${o}`),attrs:{type:`button`,"data-persona-history-focus":x(r.id),"data-persona-history-conversation":r.id,...n.active?{"aria-current":`page`}:{},...s?{"aria-disabled":`true`}:{},...o?{"aria-busy":`true`}:{}}},n.avatar?b(n.avatar):null,t(`div`,{className:`persona-history-row-body`},u,d,t(`span`,{className:`persona-history-row-count persona-history-sr-only`,text:h(r.messageCount,i)})));f.addEventListener(`click`,()=>{s||n.onOpen()});let p=n.showDelete?ie({className:`persona-history-row-menu-button`,label:`${i.rowActionsLabel}: ${r.title}`,focusKey:S(r.id),open:n.menuOpen,inert:s,onToggle:n.onToggleMenu}):null;return t(`li`,{className:e(`persona-history-item`,!n.showDelete&&`persona-history-item--no-menu`),attrs:{"data-persona-history-item":r.id}},f,p,n.menuOpen&&n.showDelete?re(n):null,n.error?w(n.error,i,r.id):null)}function re(e){let{conversation:t,copy:n}=e;return ae({label:`${n.rowActionsLabel}: ${t.title}`,items:[{label:n.deleteConversationLabel,focusKey:C(t.id),danger:!0,onSelect:e.onDelete}],onCloseMenu:e.onCloseMenu})}function ie(n){let r=t(`button`,{className:e(`persona-history-icon-button`,n.className),attrs:{type:`button`,"aria-label":n.label,"aria-haspopup":`menu`,"aria-expanded":n.open?`true`:`false`,"data-persona-history-focus":n.focusKey,...n.inert?{"aria-disabled":`true`}:{}}});r.appendChild(v(`ellipsis`,n.iconSize));let i=()=>r.getAttribute(`aria-disabled`)===`true`;return r.addEventListener(`click`,e=>{e.stopPropagation(),!i()&&n.onToggle()}),r.addEventListener(`keydown`,e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),!(i()||r.getAttribute(`aria-expanded`)===`true`)&&n.onToggle())}),r}function ae(n){let r=t(`div`,{className:`persona-history-menu`,attrs:{role:`menu`,"aria-label":n.label}});for(let i of n.items){let a=t(`button`,{className:e(`persona-history-menu-item`,i.danger&&`persona-history-menu-item--danger`),text:i.label,attrs:{type:`button`,role:`menuitem`,tabindex:`0`,"data-persona-history-focus":i.focusKey}});a.addEventListener(`click`,()=>{n.onCloseMenu(),i.onSelect()}),r.appendChild(a)}return r.addEventListener(`keydown`,e=>{let t=Array.from(r.querySelectorAll(`[role="menuitem"]`));if(t.length===0)return;let i=t.indexOf(document.activeElement);e.key===`Tab`?n.onCloseMenu({restoreFocus:!0}):e.key===`ArrowDown`?(e.preventDefault(),t[(i+1+t.length)%t.length]?.focus()):e.key===`ArrowUp`?(e.preventDefault(),t[(i-1+t.length)%t.length]?.focus()):e.key===`Home`?(e.preventDefault(),t[0]?.focus()):e.key===`End`&&(e.preventDefault(),t[t.length-1]?.focus())}),r}function w(e,n,r){let i=t(`button`,{className:`persona-history-secondary persona-history-state-action`,text:n.retryLabel,attrs:{type:`button`,"data-persona-history-focus":`row-retry:${r}`}});return i.addEventListener(`click`,e.retry),t(`div`,{className:`persona-history-row-error`,attrs:{role:`alert`}},t(`span`,{text:e.message}),i)}function oe(e){switch(e){case`authentication_failed`:case`authentication_required`:case`identity_provider_failed`:case`proof_not_admitted`:case`unsupported_scope`:case`unavailable`:return e;default:return`unknown`}}function se(e){if(n(e)){if(e.code===`rate_limited`)return{kind:`rate_limited`,retryAfterSeconds:e.retryAfterSeconds??0};let t=oe(e.code);return{kind:`error`,reason:t,retryable:t!==`unsupported_scope`}}return{kind:`error`,reason:`unknown`,retryable:!0}}function T(e,t){switch(e.state){case`authentication_required`:return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription};case`identity_provider_failed`:return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription};case`configuration_error`:return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription};default:return null}}function E(e,t){switch(e){case`authentication_required`:case`authentication_failed`:return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription};case`identity_provider_failed`:return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription};case`proof_not_admitted`:case`unsupported_scope`:return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription};case`unavailable`:return{title:t.unavailableTitle,description:t.unavailableDescription};default:return{title:t.errorTitle,description:t.errorDescription}}}function D(e,n,r,i){let a=t(`button`,{className:`persona-history-secondary persona-history-state-action`,text:e,attrs:{type:`button`,"data-persona-history-focus":n,...r?{"aria-disabled":`true`}:{}}});return a.addEventListener(`click`,()=>{r||i()}),a}function O(e,n,r,i,a){return t(`div`,{className:`persona-history-state`,attrs:{"data-persona-history-state":e,...a?{role:`alert`}:{role:`status`}}},t(`p`,{className:`persona-history-state-title`,text:n}),t(`p`,{className:`persona-history-state-description`,text:r}),i)}function k(e){let n=[`42%`,`58%`,`34%`],r=[`94%`,`78%`,`88%`],i=[0,1,2].map(e=>t(`div`,{className:`persona-history-skeleton-row`,attrs:{"aria-hidden":`true`}},t(`div`,{className:`persona-history-skeleton-head`},t(`div`,{className:`persona-history-skeleton-bar persona-history-skeleton-bar--title`,style:{width:n[e]}}),t(`div`,{className:`persona-history-skeleton-bar persona-history-skeleton-bar--time`})),t(`div`,{className:`persona-history-skeleton-bar persona-history-skeleton-bar--preview`,style:{width:r[e]}})));return t(`div`,{className:`persona-history-view-loading`,attrs:{"data-persona-history-state":`loading`,role:`status`,"aria-label":e.loadingLabel}},...i)}function ce(e){let{state:t,copy:n,busy:r}=e;if(t.kind===`loading`)return k(n);if(t.kind===`empty`){let t=T(e.identityStatus,n);return t?O(`identity`,t.title,t.description,e.onRetry?D(n.retryIdentityLabel,`state-retry`,r,e.onRetry):null,!0):O(`empty`,n.emptyTitle,n.emptyDescription,null,!1)}if(t.kind===`rate_limited`){let i=t.retryAfterSeconds>0?c(n.rateLimitedWaitDescription,{seconds:t.retryAfterSeconds}):n.rateLimitedDescription;return O(`rate_limited`,n.rateLimitedTitle,i,e.onRetry?D(n.retryLabel,`state-retry`,r,e.onRetry):null,!1)}if(t.kind===`new_conversation_required`)return O(`new_conversation_required`,n.newConversationRequiredTitle,n.newConversationRequiredDescription,e.onStartNew?D(n.newConversationLabel,`state-retry`,r,e.onStartNew):null,!0);let{title:i,description:a}=E(t.reason,n),o=t.reason===`authentication_required`||t.reason===`authentication_failed`||t.reason===`identity_provider_failed`?n.retryIdentityLabel:n.retryLabel;return O(`error`,i,a,t.retryable&&e.onRetry?D(o,`state-retry`,r,e.onRetry):null,!0)}const A=`persona:list-options`,le={panel:20,rail:12},ue=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,de=e=>e.finished?e.finished.then(()=>void 0,()=>void 0):Promise.resolve();function j(e){return`${e.state}:${`reason`in e?e.reason:``}`}function fe(e,t){switch(e.state){case`verified`:return{title:t.verifiedTitle,description:t.verifiedDescription,pending:!1};case`verifying`:case`resetting`:return{title:t.verifyingTitle,description:t.verifyingDescription,pending:!0};case`authentication_required`:return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription,pending:!1};case`identity_provider_failed`:return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription,pending:!1};case`configuration_error`:return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription,pending:!1};case`unavailable`:return{title:t.unavailableTitle,description:t.unavailableDescription,pending:!1};default:return{title:t.browserOnlyTitle,description:t.browserOnlyDescription,pending:!1}}}function pe(e){return e.state===`verified`||e.state===`browser_only`}function me(e){return e.state===`authentication_required`||e.state===`identity_provider_failed`||e.state===`configuration_error`}function M(i){let o=s(i.copy),c=i.now??(()=>Date.now()),l=i.pageSize??25,u=`persona-history-title-${Math.random().toString(36).slice(2,8)}`,d=[],f=null,p={kind:`loading`,phase:`initial`},m=null,h=i.activeConversationId,g=i.provider.getIdentityStatus(),te=j(g),_=null,y=!1,b=!1,x=0,S=i.presentation,re=i.collapsible!==!1,w=i.collapsed===!0,oe=i.railSide===`right`,T=i.renderDom!==!1,E=/* @__PURE__ */ new Map,D=null,O=a(),k=e=>{!T&&i.onAnnounce?i.onAnnounce(e):O.announce(e)},M=()=>m!==null,he=`${u}-body`,N=t(`button`,{className:`persona-history-icon-button persona-history-back`,attrs:{type:`button`}}),P=()=>S===`rail`&&re,ge,_e=()=>{if(i.railBrand){if(!P())N.classList.remove(`persona-history-back--branded`);else{if(ge===void 0){let e=i.railBrand(!0);ge=e?t(`span`,{className:`persona-history-brand-mark persona-history-toggle-brand`,attrs:{"aria-hidden":`true`}},e):null}ge&&(N.classList.add(`persona-history-back--branded`),N.appendChild(ge))}}},ve=()=>{let e=P(),t=S===`rail`;N.setAttribute(`data-persona-history-focus`,e?`collapse`:`close`),N.setAttribute(`aria-label`,e?w?o.expandLabel:o.collapseLabel:t?o.closeLabel:o.backLabel),e?(N.setAttribute(`aria-expanded`,w?`false`:`true`),N.setAttribute(`aria-controls`,he),i.collapseShortcut?.aria&&N.setAttribute(`aria-keyshortcuts`,i.collapseShortcut.aria)):(N.removeAttribute(`aria-expanded`),N.removeAttribute(`aria-controls`),N.removeAttribute(`aria-keyshortcuts`)),N.replaceChildren(v(e?`panel-left`:t?`x`:`arrow-left`)),_e()};ve(),N.addEventListener(`click`,()=>{P()?i.onToggleCollapse?.():i.onClose()});let ye=t(`h2`,{className:`persona-history-title`,text:o.viewTitle,attrs:{id:u}}),be=t(`span`,{className:`persona-history-scope-title`}),F=t(`p`,{className:`persona-history-scope`},t(`span`,{className:`persona-history-scope-icon`,attrs:{"aria-hidden":`true`}},v(`monitor`,14)),be),xe=t(`div`,{className:`persona-history-heading-group`},ye),Se=!1,Ce,we=()=>{let e=S===`rail`,n=e?i.renderRailHeader:void 0,r=null,a=n!==void 0;if(n)try{r=n({collapsed:w,defaultTitle:o.viewTitle})}catch(e){a=!1,Se||(Se=!0,console.warn(`[persona] history rail renderHeader threw`,e))}if(!a&&e&&i.railBrand){if(Ce===void 0){let e=i.railBrand(!1);Ce=e?t(`span`,{className:`persona-history-heading-brand`,attrs:{"aria-hidden":`true`}},t(`span`,{className:`persona-history-brand-mark`},e),t(`span`,{className:`persona-history-wordmark`,text:o.viewTitle})):null}Ce&&(a=!0,r=Ce)}ye.classList.toggle(`persona-history-sr-only`,a),xe.replaceChildren(ye),r&&xe.appendChild(r)};we();let I=t(`button`,{className:`persona-history-icon-button persona-history-new-icon`,attrs:{type:`button`,"data-persona-history-focus":`new-icon`,"aria-label":o.newConversationLabel}});I.appendChild(v(`plus`)),I.addEventListener(`click`,()=>void $());let Te=[N,I].map(e=>i.attachTooltip?.({anchor:e,text:()=>e.getAttribute(`aria-label`)??``,...e===N&&i.collapseShortcut?{hint:()=>P()?i.collapseShortcut.hint:``}:{}})),L=t(`div`,{className:`persona-history-topbar`}),Ee=null,De=()=>{let e=S===`rail`,t=e?oe?`rail-right`:`rail`:`panel`;t!==Ee&&(Ee=t,t===`rail`?L.append(xe,N):L.append(N,xe),e?I.remove():L.appendChild(I),U.classList.toggle(`persona-history-view--rail-right`,t===`rail-right`))},R=t(`div`,{className:`persona-history-scope-alert`}),Oe=`${u}-scope`,ke=v(`plus`,18),Ae=t(`button`,{className:`persona-history-new`,attrs:{type:`button`,"data-persona-history-focus":`new`}},ke,t(`span`,{text:o.newConversationLabel}));Ae.addEventListener(`click`,()=>void $());let je=t(`div`,{className:`persona-history-list-region`}),Me=i.showDeleteAll!==!1,Ne=!!i.provider.resetDevice,Pe=i.listActions??[],z=Me||Ne||Pe.length>0?ie({className:`persona-history-list-options`,label:o.listOptionsLabel,focusKey:`menu:${A}`,open:!1,inert:!0,iconSize:16,onToggle:()=>lt(A)}):null,Fe=t(`h3`,{className:`persona-history-conversations-title`,text:o.conversationsTitle}),B=t(`div`,{className:`persona-history-caption`,attrs:{"data-persona-history-item":A}},Fe,i.showScopeStatus?F:null,z),V=t(`div`,{className:`persona-history-body`,attrs:{id:he}},i.showScopeStatus?R:null,Ae,B,je),H=i.headerPlacement??`inline`;H===`external`&&L.classList.add(`persona-history-topbar--shell`,`persona-history-topbar--shell-enter`);let U=t(`div`,{className:e(`persona-history-view`,`persona-history-view--${i.presentation}`,`persona-history-view--enter`),attrs:{role:`region`,"aria-labelledby":u,"data-persona-history-presentation":i.presentation}},O.element,H===`inline`?L:null,V),Ie=()=>{U.classList.toggle(`persona-history-view--rail-collapsed`,w&&P())};Ie(),De();let Le=(n,r)=>{let i=`${u}-s${r}`,a=t(`div`,{className:e(`persona-history-nav`,n.placement===`footer`&&`persona-history-nav--footer`),attrs:{role:`group`,"data-persona-rail-section":n.id,...n.title?{"aria-labelledby":i}:{"aria-label":n.id}}});n.title&&a.appendChild(t(`h3`,{className:`persona-history-group-heading`,text:n.title,attrs:{id:i}}));for(let r of n.items){let n=r.iconNode?.()??null,i=t(`button`,{className:e(`persona-history-nav-item`,n&&`persona-history-nav-item--icon`),attrs:{type:`button`,"aria-label":r.label,"data-persona-rail-item":r.id}},n?t(`span`,{className:`persona-history-nav-icon`},n):null,t(`span`,{className:`persona-history-nav-label persona-history-truncate`,text:r.label}),r.badge?t(`span`,{className:`persona-history-nav-badge`,text:r.badge}):null);i.addEventListener(`click`,()=>r.onSelect()),a.appendChild(i)}return a},W=null,Re=null,ze=()=>{W&&T&&S===`rail`&&w!==Re&&(Re=w,i.railSections.forEach((e,t)=>{if(!e.render)return;let n=W[t],r=e.title?n.firstElementChild:null,i=null;try{i=e.render(w)}catch(t){e.render=void 0,console.warn(`[persona] history rail section threw`,e.id,t)}n.replaceChildren(...r?[r]:[],...i?[i]:[]),n.hidden=!i}))},Be=()=>{let e=i.railSections;if(U.classList.toggle(`persona-history-view--has-nav`,S===`rail`&&!!e?.some(e=>e.placement===`above-conversations`)),e?.length){if(S!==`rail`)W?.forEach(e=>e.remove());else{W??=e.map(Le);for(let t of[`above-conversations`,`below-conversations`,`footer`]){let n=t===`above-conversations`?B.parentNode===V?B:je:null;e.forEach((e,r)=>{e.placement===t&&V.insertBefore(W[r],n)})}ze()}}};Be(),r(U,`persona-history-view`,`
|
|
1
|
+
import{i as e,r as t}from"./chunk-D5BxWOFB.js";import{n}from"./chunk-C8560fIY.js";import{n as r}from"./chunk-Cd8mp8Sv.js";import{t as i}from"./chunk-CLMIHW4_.js";function a(){let e=document.createElement(`div`);e.className=`persona-history-sr-only`,e.setAttribute(`role`,`status`),e.setAttribute(`aria-live`,`polite`),e.setAttribute(`aria-atomic`,`true`),e.setAttribute(`data-persona-history-live-region`,``);let t;return{element:e,announce(n){t!==void 0&&clearTimeout(t),e.textContent=``,t=setTimeout(()=>{t=void 0,e.textContent=n},0)},destroy(){t!==void 0&&clearTimeout(t),e.remove()}}}const o={...i,emptyTitle:`No conversations yet`,emptyDescription:`Start a conversation and it will show up here.`,errorTitle:`Could not load conversations`,errorDescription:`Something went wrong. Please try again.`,retryLabel:`Retry`,rateLimitedTitle:`Too many requests`,rateLimitedDescription:`Please wait a moment before trying again.`,groupStarred:`Starred`,groupToday:`Today`,groupYesterday:`Yesterday`,groupPrevious7Days:`Previous 7 days`,groupPrevious30Days:`Previous 30 days`,groupMonthYear:`{month} {year}`,browserOnlyTitle:`On this device`,browserOnlyDescription:`Another browser or device keeps its own separate history.`,verifyingTitle:`Checking your account`,verifyingDescription:`Looking for messages linked to your account.`,verifiedTitle:`Available across signed-in devices`,verifiedDescription:`This list refreshes when the chat opens rather than syncing live.`,authenticationRequiredTitle:`Sign in to see your messages`,authenticationRequiredDescription:`Your session expired. Sign in again to load account history.`,identityProviderFailedTitle:`Account history is unavailable`,identityProviderFailedDescription:`We could not verify your account, so account history is not shown here.`,proofNotAdmittedTitle:`Account history is unavailable`,proofNotAdmittedDescription:`This assistant is not set up to accept your account identity.`,retryIdentityLabel:`Try again`,backLabel:`Back to conversation`,closeLabel:`Close conversation list`,loadingLabel:`Loading conversations`,loadMoreLabel:`Load more`,loadingMoreLabel:`Loading more conversations`,conversationsTitle:`Conversations`,rowActionsLabel:`Conversation options`,listOptionsLabel:`Conversation options`,deleteConversationLabel:`Delete`,clearHistoryLabel:`Delete all conversations`,resetIdentityLabel:`Forget this device`,messageCountLabel:`{count} messages`,messageCountLabelOne:`1 message`,conversationRemovedNotice:`Conversation deleted.`,historyClearedNotice:`All conversations were deleted.`,unavailableTitle:`Conversation history is unavailable`,unavailableDescription:`Try again later.`,newConversationRequiredTitle:`Start a new conversation`,newConversationRequiredDescription:`The previous conversation is gone. Start a new one to keep chatting.`,rateLimitedWaitDescription:`You can try again in {seconds} seconds.`,openFailedLabel:`Could not open that conversation.`,deleteFailedLabel:`Could not delete that conversation.`,relativeNow:`now`,relativeMinutes:`{value}m`,relativeHours:`{value}h`,relativeDays:`{value}d`,relativeWeeks:`{value}w`,relativeYears:`{value}y`};function s(e){if(!e)return o;let t={...o};for(let[n,r]of Object.entries(e))typeof r==`string`&&r.length>0&&(t[n]=r);return t}function c(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):e)}const l=864e5;function u(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function d(e,t){let n=Date.parse(e);return Number.isFinite(n)?n:t}function f(e,t){let n=d(e,t),r=u(t);if(n>=r)return`today`;if(n>=r-l)return`yesterday`;if(n>=r-7*l)return`previous-7-days`;if(n>=r-30*l)return`previous-30-days`;let i=new Date(n);return`month:${i.getFullYear()}-${i.getMonth()}`}function p(e,t,n,r){if(e===`today`)return r.groupToday;if(e===`yesterday`)return r.groupYesterday;if(e===`previous-7-days`)return r.groupPrevious7Days;if(e===`previous-30-days`)return r.groupPrevious30Days;let i=new Date(d(t,n));return c(r.groupMonthYear,{month:i.toLocaleString(void 0,{month:`long`}),year:i.getFullYear()})}function ee(e,t,n,r=`time`){let i=e.filter(e=>e.starred),a=i.length>0?[{key:`starred`,label:n.groupStarred,items:i}]:[];if(r===`none`){let t=e.filter(e=>!e.starred);return t.length>0&&a.push({key:`recent`,label:n.conversationsTitle,items:t}),a}for(let r of e){if(r.starred)continue;let e=f(r.updatedAt,t),i=a[a.length-1];i&&i.key===e?i.items.push(r):a.push({key:e,label:p(e,r.updatedAt,t,n),items:[r]})}return a}function m(e,t,n){let r=Math.max(0,t-d(e,t)),i=Math.floor(r/6e4);if(i<1)return n.relativeNow;if(i<60)return c(n.relativeMinutes,{value:i});let a=Math.floor(i/60);if(a<24)return c(n.relativeHours,{value:a});let o=Math.floor(a/24);if(o<7)return c(n.relativeDays,{value:o});let s=Math.floor(o/7);return o<365?c(n.relativeWeeks,{value:s}):c(n.relativeYears,{value:Math.floor(o/365)})}function h(e,t){return e===1?t.messageCountLabelOne:c(t.messageCountLabel,{count:e})}const g=`http://www.w3.org/2000/svg`,te={"arrow-left":[`m12 19-7-7 7-7`,`M19 12H5`],plus:[`M5 12h14`,`M12 5v14`],star:[`m12 2 2.9 6.2 6.8.7-5.1 4.5 1.4 6.6-6-3.4-6 3.4 1.4-6.6-5.1-4.5 6.8-.7z`],x:[`M18 6 6 18`,`m6 6 12 12`],"panel-left":[`M9 3v18`],monitor:[`M8 21h8`,`M12 17v4`],ellipsis:[]},_={"panel-left":[3,3,18,18],monitor:[2,3,20,14]};function v(e,t=20){let n=document.createElementNS(g,`svg`);if(n.setAttribute(`width`,String(t)),n.setAttribute(`height`,String(t)),n.setAttribute(`viewBox`,`0 0 24 24`),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`2`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`focusable`,`false`),e===`ellipsis`){for(let e of[12,19,5]){let t=document.createElementNS(g,`circle`);t.setAttribute(`cx`,String(e)),t.setAttribute(`cy`,`12`),t.setAttribute(`r`,`1`),n.appendChild(t)}return n}let r=_[e];if(r){let e=document.createElementNS(g,`rect`);e.setAttribute(`x`,String(r[0])),e.setAttribute(`y`,String(r[1])),e.setAttribute(`width`,String(r[2])),e.setAttribute(`height`,String(r[3])),e.setAttribute(`rx`,`2`),n.appendChild(e)}for(let t of te[e]){let e=document.createElementNS(g,`path`);e.setAttribute(`d`,t),n.appendChild(e)}return n}const y=/^(https?:|\/|data:)/i;function b(e){let n=t(`span`,{className:`persona-history-row-avatar`,attrs:{"aria-hidden":`true`}});return y.test(e)?n.appendChild(t(`img`,{attrs:{src:e,alt:``,loading:`lazy`}})):n.textContent=e,n}const x=e=>`row:${e}`,S=e=>`menu:${e}`,C=e=>`menu-item:${e}`;function ne(n){let{conversation:r,copy:i,busy:a,pending:o}=n,s=a||o!==null,c=r.title.trim().length>0,l=r.starred?(()=>{let e=v(`star`,11);return e.setAttribute(`fill`,`currentColor`),e.setAttribute(`stroke-width`,`1`),t(`span`,{className:`persona-history-row-star`},e,t(`span`,{className:`persona-history-sr-only`,text:i.groupStarred}))})():null,u=t(`div`,{className:`persona-history-row-head`},t(`span`,{className:`persona-history-row-title persona-history-truncate`,text:c?r.title:r.preview??``}),l,t(`time`,{className:`persona-history-row-time`,attrs:{datetime:r.updatedAt},text:m(r.updatedAt,n.nowMs,i)})),d=c&&r.preview?t(`span`,{className:`persona-history-row-preview persona-history-truncate`,text:r.preview}):null,f=t(`button`,{className:e(`persona-history-row`,n.active&&`persona-history-row--active`,o&&`persona-history-row--${o}`),attrs:{type:`button`,"data-persona-history-focus":x(r.id),"data-persona-history-conversation":r.id,...n.active?{"aria-current":`page`}:{},...s?{"aria-disabled":`true`}:{},...o?{"aria-busy":`true`}:{}}},n.avatar?b(n.avatar):null,t(`div`,{className:`persona-history-row-body`},u,d,t(`span`,{className:`persona-history-row-count persona-history-sr-only`,text:h(r.messageCount,i)})));f.addEventListener(`click`,()=>{s||n.onOpen()});let p=n.showDelete?ie({className:`persona-history-row-menu-button`,label:`${i.rowActionsLabel}: ${r.title}`,focusKey:S(r.id),open:n.menuOpen,inert:s,onToggle:n.onToggleMenu}):null;return t(`li`,{className:e(`persona-history-item`,!n.showDelete&&`persona-history-item--no-menu`),attrs:{"data-persona-history-item":r.id}},f,p,n.menuOpen&&n.showDelete?re(n):null,n.error?w(n.error,i,r.id):null)}function re(e){let{conversation:t,copy:n}=e;return ae({label:`${n.rowActionsLabel}: ${t.title}`,items:[{label:n.deleteConversationLabel,focusKey:C(t.id),danger:!0,onSelect:e.onDelete}],onCloseMenu:e.onCloseMenu})}function ie(n){let r=t(`button`,{className:e(`persona-history-icon-button`,n.className),attrs:{type:`button`,"aria-label":n.label,"aria-haspopup":`menu`,"aria-expanded":n.open?`true`:`false`,"data-persona-history-focus":n.focusKey,...n.inert?{"aria-disabled":`true`}:{}}});r.appendChild(v(`ellipsis`,n.iconSize));let i=()=>r.getAttribute(`aria-disabled`)===`true`;return r.addEventListener(`click`,e=>{e.stopPropagation(),!i()&&n.onToggle()}),r.addEventListener(`keydown`,e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),!(i()||r.getAttribute(`aria-expanded`)===`true`)&&n.onToggle())}),r}function ae(n){let r=t(`div`,{className:`persona-history-menu`,attrs:{role:`menu`,"aria-label":n.label}});for(let i of n.items){let a=t(`button`,{className:e(`persona-history-menu-item`,i.danger&&`persona-history-menu-item--danger`),text:i.label,attrs:{type:`button`,role:`menuitem`,tabindex:`0`,"data-persona-history-focus":i.focusKey}});a.addEventListener(`click`,()=>{n.onCloseMenu(),i.onSelect()}),r.appendChild(a)}return r.addEventListener(`keydown`,e=>{let t=Array.from(r.querySelectorAll(`[role="menuitem"]`));if(t.length===0)return;let i=t.indexOf(document.activeElement);e.key===`Tab`?n.onCloseMenu({restoreFocus:!0}):e.key===`ArrowDown`?(e.preventDefault(),t[(i+1+t.length)%t.length]?.focus()):e.key===`ArrowUp`?(e.preventDefault(),t[(i-1+t.length)%t.length]?.focus()):e.key===`Home`?(e.preventDefault(),t[0]?.focus()):e.key===`End`&&(e.preventDefault(),t[t.length-1]?.focus())}),r}function w(e,n,r){let i=t(`button`,{className:`persona-history-secondary persona-history-state-action`,text:n.retryLabel,attrs:{type:`button`,"data-persona-history-focus":`row-retry:${r}`}});return i.addEventListener(`click`,e.retry),t(`div`,{className:`persona-history-row-error`,attrs:{role:`alert`}},t(`span`,{text:e.message}),i)}function oe(e){switch(e){case`authentication_failed`:case`authentication_required`:case`identity_provider_failed`:case`proof_not_admitted`:case`unsupported_scope`:case`unavailable`:return e;default:return`unknown`}}function se(e){if(n(e)){if(e.code===`rate_limited`)return{kind:`rate_limited`,retryAfterSeconds:e.retryAfterSeconds??0};let t=oe(e.code);return{kind:`error`,reason:t,retryable:t!==`unsupported_scope`}}return{kind:`error`,reason:`unknown`,retryable:!0}}function T(e,t){switch(e.state){case`authentication_required`:return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription};case`identity_provider_failed`:return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription};case`configuration_error`:return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription};default:return null}}function E(e,t){switch(e){case`authentication_required`:case`authentication_failed`:return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription};case`identity_provider_failed`:return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription};case`proof_not_admitted`:case`unsupported_scope`:return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription};case`unavailable`:return{title:t.unavailableTitle,description:t.unavailableDescription};default:return{title:t.errorTitle,description:t.errorDescription}}}function D(e,n,r,i){let a=t(`button`,{className:`persona-history-secondary persona-history-state-action`,text:e,attrs:{type:`button`,"data-persona-history-focus":n,...r?{"aria-disabled":`true`}:{}}});return a.addEventListener(`click`,()=>{r||i()}),a}function O(e,n,r,i,a){return t(`div`,{className:`persona-history-state`,attrs:{"data-persona-history-state":e,...a?{role:`alert`}:{role:`status`}}},t(`p`,{className:`persona-history-state-title`,text:n}),t(`p`,{className:`persona-history-state-description`,text:r}),i)}function k(e){let n=[`42%`,`58%`,`34%`],r=[`94%`,`78%`,`88%`],i=[0,1,2].map(e=>t(`div`,{className:`persona-history-skeleton-row`,attrs:{"aria-hidden":`true`}},t(`div`,{className:`persona-history-skeleton-head`},t(`div`,{className:`persona-history-skeleton-bar persona-history-skeleton-bar--title`,style:{width:n[e]}}),t(`div`,{className:`persona-history-skeleton-bar persona-history-skeleton-bar--time`})),t(`div`,{className:`persona-history-skeleton-bar persona-history-skeleton-bar--preview`,style:{width:r[e]}})));return t(`div`,{className:`persona-history-view-loading`,attrs:{"data-persona-history-state":`loading`,role:`status`,"aria-label":e.loadingLabel}},...i)}function ce(e){let{state:t,copy:n,busy:r}=e;if(t.kind===`loading`)return k(n);if(t.kind===`empty`){let t=T(e.identityStatus,n);return t?O(`identity`,t.title,t.description,e.onRetry?D(n.retryIdentityLabel,`state-retry`,r,e.onRetry):null,!0):O(`empty`,n.emptyTitle,n.emptyDescription,null,!1)}if(t.kind===`rate_limited`){let i=t.retryAfterSeconds>0?c(n.rateLimitedWaitDescription,{seconds:t.retryAfterSeconds}):n.rateLimitedDescription;return O(`rate_limited`,n.rateLimitedTitle,i,e.onRetry?D(n.retryLabel,`state-retry`,r,e.onRetry):null,!1)}if(t.kind===`new_conversation_required`)return O(`new_conversation_required`,n.newConversationRequiredTitle,n.newConversationRequiredDescription,e.onStartNew?D(n.newConversationLabel,`state-retry`,r,e.onStartNew):null,!0);let{title:i,description:a}=E(t.reason,n),o=t.reason===`authentication_required`||t.reason===`authentication_failed`||t.reason===`identity_provider_failed`?n.retryIdentityLabel:n.retryLabel;return O(`error`,i,a,t.retryable&&e.onRetry?D(o,`state-retry`,r,e.onRetry):null,!0)}const A=`persona:list-options`,le={panel:20,rail:12},ue=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,de=e=>e.finished?e.finished.then(()=>void 0,()=>void 0):Promise.resolve();function j(e){return`${e.state}:${`reason`in e?e.reason:``}`}function fe(e,t){switch(e.state){case`verified`:return{title:t.verifiedTitle,description:t.verifiedDescription,pending:!1};case`verifying`:case`resetting`:return{title:t.verifyingTitle,description:t.verifyingDescription,pending:!0};case`authentication_required`:return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription,pending:!1};case`identity_provider_failed`:return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription,pending:!1};case`configuration_error`:return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription,pending:!1};case`unavailable`:return{title:t.unavailableTitle,description:t.unavailableDescription,pending:!1};default:return{title:t.browserOnlyTitle,description:t.browserOnlyDescription,pending:!1}}}function pe(e){return e.state===`verified`||e.state===`browser_only`}function me(e){return e.state===`authentication_required`||e.state===`identity_provider_failed`||e.state===`configuration_error`}function M(i){let o=s(i.copy),c=i.now??(()=>Date.now()),l=i.pageSize??25,u=`persona-history-title-${Math.random().toString(36).slice(2,8)}`,d=[],f=null,p={kind:`loading`,phase:`initial`},m=null,h=i.activeConversationId,g=i.provider.getIdentityStatus(),te=j(g),_=null,y=!1,b=!1,x=0,S=i.presentation,re=i.collapsible!==!1,w=i.collapsed===!0,oe=i.railSide===`right`,T=i.renderDom!==!1,E=/* @__PURE__ */ new Map,D=null,O=a(),k=e=>{!T&&i.onAnnounce?i.onAnnounce(e):O.announce(e)},M=()=>m!==null,he=`${u}-body`,N=t(`button`,{className:`persona-history-icon-button persona-history-back`,attrs:{type:`button`}}),P=()=>S===`rail`&&re,ge,_e=()=>{if(i.railBrand){if(!P())N.classList.remove(`persona-history-back--branded`);else{if(ge===void 0){let e=i.railBrand(!0);ge=e?t(`span`,{className:`persona-history-brand-mark persona-history-toggle-brand`,attrs:{"aria-hidden":`true`}},e):null}ge&&(N.classList.add(`persona-history-back--branded`),N.appendChild(ge))}}},ve=()=>{let e=P(),t=S===`rail`;N.setAttribute(`data-persona-history-focus`,e?`collapse`:`close`),N.setAttribute(`aria-label`,e?w?o.expandLabel:o.collapseLabel:t?o.closeLabel:o.backLabel),e?(N.setAttribute(`aria-expanded`,w?`false`:`true`),N.setAttribute(`aria-controls`,he),i.collapseShortcut?.aria&&N.setAttribute(`aria-keyshortcuts`,i.collapseShortcut.aria)):(N.removeAttribute(`aria-expanded`),N.removeAttribute(`aria-controls`),N.removeAttribute(`aria-keyshortcuts`)),N.replaceChildren(v(e?`panel-left`:t?`x`:`arrow-left`)),_e()};ve(),N.addEventListener(`click`,()=>{P()?i.onToggleCollapse?.():i.onClose()});let ye=t(`h2`,{className:`persona-history-title`,text:o.viewTitle,attrs:{id:u}}),be=t(`span`,{className:`persona-history-scope-title`}),F=t(`p`,{className:`persona-history-scope`},t(`span`,{className:`persona-history-scope-icon`,attrs:{"aria-hidden":`true`}},v(`monitor`,14)),be),xe=t(`div`,{className:`persona-history-heading-group`},ye),Se=!1,Ce,we=()=>{let e=S===`rail`,n=e?i.renderRailHeader:void 0,r=null,a=n!==void 0;if(n)try{r=n({collapsed:w,defaultTitle:o.viewTitle})}catch(e){a=!1,Se||(Se=!0,console.warn(`[persona] history rail renderHeader threw`,e))}if(!a&&e&&i.railBrand){if(Ce===void 0){let e=i.railBrand(!1);Ce=e?t(`span`,{className:`persona-history-heading-brand`,attrs:{"aria-hidden":`true`}},t(`span`,{className:`persona-history-brand-mark`},e),t(`span`,{className:`persona-history-wordmark`,text:o.viewTitle})):null}Ce&&(a=!0,r=Ce)}ye.classList.toggle(`persona-history-sr-only`,a),xe.replaceChildren(ye),r&&xe.appendChild(r)};we();let I=t(`button`,{className:`persona-history-icon-button persona-history-new-icon`,attrs:{type:`button`,"data-persona-history-focus":`new-icon`,"aria-label":o.newConversationLabel}});I.appendChild(v(`plus`)),I.addEventListener(`click`,()=>void $());let Te=[N,I].map(e=>i.attachTooltip?.({anchor:e,text:()=>e.getAttribute(`aria-label`)??``,...e===N&&i.collapseShortcut?{hint:()=>P()?i.collapseShortcut.hint:``}:{}})),L=t(`div`,{className:`persona-history-topbar`}),Ee=null,De=()=>{let e=S===`rail`,t=e?oe?`rail-right`:`rail`:`panel`;t!==Ee&&(Ee=t,t===`rail`?L.append(xe,N):L.append(N,xe),e?I.remove():L.appendChild(I),U.classList.toggle(`persona-history-view--rail-right`,t===`rail-right`))},R=t(`div`,{className:`persona-history-scope-alert`}),Oe=`${u}-scope`,ke=v(`plus`,18),Ae=t(`button`,{className:`persona-history-new`,attrs:{type:`button`,"data-persona-history-focus":`new`}},ke,t(`span`,{text:o.newConversationLabel}));Ae.addEventListener(`click`,()=>void $());let je=t(`div`,{className:`persona-history-list-region`}),Me=i.showDeleteAll!==!1,Ne=!!i.provider.resetDevice,Pe=i.listActions??[],z=Me||Ne||Pe.length>0?ie({className:`persona-history-list-options`,label:o.listOptionsLabel,focusKey:`menu:${A}`,open:!1,inert:!0,iconSize:16,onToggle:()=>lt(A)}):null,Fe=t(`h3`,{className:`persona-history-conversations-title`,text:o.conversationsTitle}),B=t(`div`,{className:`persona-history-caption`,attrs:{"data-persona-history-item":A}},Fe,i.showScopeStatus?F:null,z),V=t(`div`,{className:`persona-history-body`,attrs:{id:he}},i.showScopeStatus?R:null,Ae,B,je),H=i.headerPlacement??`inline`;H===`external`&&L.classList.add(`persona-history-topbar--shell`,`persona-history-topbar--shell-enter`);let U=t(`div`,{className:e(`persona-history-view`,`persona-history-view--${i.presentation}`,`persona-history-view--enter`),attrs:{role:`region`,"aria-labelledby":u,"data-persona-history-presentation":i.presentation}},O.element,H===`inline`?L:null,V),Ie=()=>{U.classList.toggle(`persona-history-view--rail-collapsed`,w&&P())};Ie(),De();let Le=(n,r)=>{let i=`${u}-s${r}`,a=t(`div`,{className:e(`persona-history-nav`,n.placement===`footer`&&`persona-history-nav--footer`),attrs:{role:`group`,"data-persona-rail-section":n.id,...n.title?{"aria-labelledby":i}:{"aria-label":n.id}}});n.title&&a.appendChild(t(`h3`,{className:`persona-history-group-heading`,text:n.title,attrs:{id:i}}));for(let r of n.items){let n=r.iconNode?.()??null,i=t(`button`,{className:e(`persona-history-nav-item`,n&&`persona-history-nav-item--icon`),attrs:{type:`button`,"aria-label":r.label,"data-persona-rail-item":r.id}},n?t(`span`,{className:`persona-history-nav-icon`},n):null,t(`span`,{className:`persona-history-nav-label persona-history-truncate`,text:r.label}),r.badge?t(`span`,{className:`persona-history-nav-badge`,text:r.badge}):null);i.addEventListener(`click`,()=>r.onSelect()),a.appendChild(i)}return a},W=null,Re=null,ze=()=>{W&&T&&S===`rail`&&w!==Re&&(Re=w,i.railSections.forEach((e,t)=>{if(!e.render)return;let n=W[t],r=e.title?n.firstElementChild:null,i=null;try{i=e.render(w)}catch(t){e.render=void 0,console.warn(`[persona] history rail section threw`,e.id,t)}n.replaceChildren(...r?[r]:[],...i?[i]:[]),n.hidden=!i}))},Be=()=>{let e=i.railSections;if(U.classList.toggle(`persona-history-view--has-nav`,S===`rail`&&!!e?.some(e=>e.placement===`above-conversations`)),e?.length){if(S!==`rail`)W?.forEach(e=>e.remove());else{W??=e.map(Le);for(let t of[`above-conversations`,`below-conversations`,`footer`]){let n=t===`above-conversations`?B.parentNode===V?B:je:null;e.forEach((e,r)=>{e.placement===t&&V.insertBefore(W[r],n)})}ze()}}};Be(),r(U,`persona-history-view`,`
|
|
2
2
|
.persona-history-view {
|
|
3
3
|
--persona-history-surface-bg: var(--persona-surface, #ffffff);
|
|
4
4
|
--persona-history-topbar-bg: var(--persona-header-bg, var(--persona-surface, #ffffff));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=`data-persona-tooltip-suppressed`,t=`persona-composer-control`,n=`persona-composer-control--glyph`;export{n,e as r,t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./chunk-D5BxWOFB.js";import{a as n,h as r,i,o as a,p as o,r as s}from"./chunk-CsfE8WRG.js";import{r as c,t as l}from"./chunk-Cd8mp8Sv.js";import{r as u}from"./chunk-Crczk7D3.js";const d=()=>({wrapper:e(`span`,{className:`persona-composer-model-picker-wrapper`,attrs:{"data-persona-composer-model-picker-wrapper":``}}),chevron:e(`span`,{className:`persona-composer-model-picker-chevron`,attrs:{"aria-hidden":`true`}})});function f(n){let r=n.label??`Model`,i=n.presentation??`native`,a=null,o=e=>{let t=n.getSelectedModelId();return e.find(e=>e.id===t)??e[0]},s=()=>{let t=e(`select`,{className:`persona-composer-model-picker`,attrs:{"aria-label":r,"data-persona-composer-model-picker":``}}),i=``,s=()=>{let r=n.getModels(),a=r.map(e=>`${e.id}:${e.label}`).join(`|`);a!==i&&(i=a,t.replaceChildren(...r.map(t=>{let n=e(`option`,{attrs:{value:t.id}});return n.textContent=t.label,n}))),t.value=o(r)?.id??``};s(),a=s;let c=()=>{t.value&&n.onSelect(t.value)};t.addEventListener(`change`,c);let l=e=>e.stopPropagation();t.addEventListener(`click`,l);let{wrapper:u,chevron:f}=d();return u.append(t,f),{element:u,destroy:()=>{a===s&&(a=null),t.removeEventListener(`change`,c),t.removeEventListener(`click`,l)}}},c=()=>{let i=e(`button`,{className:`persona-composer-model-picker persona-composer-model-picker-trigger`,attrs:{type:`button`,"aria-haspopup":`listbox`,"aria-expanded":`false`,"data-persona-composer-model-picker":`popover`}}),s=t(`span`,`persona-composer-model-picker-label`),c=t(`span`,`persona-composer-model-picker-suffix`);i.append(s,c);let u=e(`div`,{className:`persona-composer-model-menu`,attrs:{role:`listbox`,tabindex:`-1`,"aria-label":r,"data-persona-composer-model-menu":``}}),f=/* @__PURE__ */ new Map,p=``,m=null,h=()=>m?.isOpen===!0,g=(e=!1)=>{h()&&(m?.close(),i.setAttribute(`aria-expanded`,`false`),e&&i.focus())},_=e=>{let t=[...f.values()];t.length!==0&&t[(e%t.length+t.length)%t.length].focus()},v=e=>{if(h())return;m||=l({anchor:i,content:u,placement:`top-start`,offset:6,onDismiss:()=>i.setAttribute(`aria-expanded`,`false`)}),m.open(),i.setAttribute(`aria-expanded`,`true`);let t=[...f.keys()].indexOf(o(n.getModels())?.id??``);_(e??(t>=0?t:0))},y=e=>{g(!0),n.onSelect(e)},b=e=>{e.preventDefault(),e.stopPropagation();let t=e.currentTarget.getAttribute(`data-persona-model-option`);t&&y(t)},x=r=>{let i=e(`button`,{className:`persona-composer-model-option`,attrs:{type:`button`,role:`option`,tabindex:`-1`,"aria-selected":`false`,"data-persona-model-option":r.id}});if(r.icon){let e=n.renderIcon(r.icon,16,`currentColor`,1.5);if(e){let n=t(`span`,`persona-composer-model-option-icon`);n.appendChild(e),i.appendChild(n)}}let a=t(`span`,`persona-composer-model-option-body`),o=t(`span`,`persona-composer-model-option-label`);if(o.textContent=r.label,a.appendChild(o),r.description){let e=t(`span`,`persona-composer-model-option-description`);e.textContent=r.description,a.appendChild(e)}i.appendChild(a);let s=t(`span`,`persona-composer-model-option-check`);s.setAttribute(`aria-hidden`,`true`);let c=n.renderIcon(`check`,16,`currentColor`,2);return c&&s.appendChild(c),i.appendChild(s),i.addEventListener(`click`,b),i},S=()=>{let e=n.getModels(),t=e.map(e=>`${e.id}:${e.label}:${e.icon??``}:${e.description??``}`).join(`|`);if(t!==p){p=t;for(let e of f.values())e.removeEventListener(`click`,b);f.clear(),u.replaceChildren(...e.map(e=>{let t=x(e);return f.set(e.id,t),t}))}let a=o(e);for(let[e,t]of f)t.setAttribute(`aria-selected`,String(e===a?.id));s.textContent=a?.label??``;let l=n.getSuffix?.()??``;c.textContent=l,i.setAttribute(`aria-label`,[r,[a?.label,l].filter(Boolean).join(` `)].filter(Boolean).join(`: `))};S(),a=S;let C=e=>{e.preventDefault(),e.stopPropagation(),h()?g(!0):v()},w=e=>{e.key===`ArrowDown`?(e.preventDefault(),h()?_(0):v(0)):e.key===`ArrowUp`&&(e.preventDefault(),h()?_(-1):v(-1))},T=e=>{let t=[...f.values()],n=t.indexOf(e.target?.closest?.(`.persona-composer-model-option`));switch(e.key){case`ArrowDown`:e.preventDefault(),_(n+1);return;case`ArrowUp`:e.preventDefault(),_(n-1);return;case`Home`:e.preventDefault(),_(0);return;case`End`:e.preventDefault(),_(t.length-1);return;case`Escape`:e.preventDefault(),e.stopPropagation(),g(!0);return;case`Tab`:g(!0);return}};i.addEventListener(`click`,C),i.addEventListener(`keydown`,w),u.addEventListener(`keydown`,T);let{wrapper:E,chevron:D}=d();return E.append(i,D),{element:E,destroy:()=>{a===S&&(a=null),i.removeEventListener(`click`,C),i.removeEventListener(`keydown`,w),u.removeEventListener(`keydown`,T);for(let e of f.values())e.removeEventListener(`click`,b);f.clear(),m?.destroy(),m=null,u.remove()}}};return{action:{id:`core:model`,kind:`custom`,placement:`end`,order:700,presentation:i===`popover`?`bar`:`auto`,label:r,render:()=>i===`popover`?c():s()},repaint:()=>a?.()}}function p(n){let r=null;return{action:{id:i(n.groupId),kind:`custom`,placement:`start`,presentation:`bar`,label:n.getGroup()?.label??n.groupId,render:()=>{let i=e(`div`,{className:`persona-composer-segmented`,attrs:{"data-persona-composer-mode-group":n.groupId}}),a=/* @__PURE__ */ new Map,o=``,s=e=>{e.preventDefault(),e.stopPropagation();let t=e.currentTarget.getAttribute(`data-persona-composer-mode`);t&&(n.getActiveIds().includes(t)&&n.getGroup()?.selection===`single`||n.onSelect(t))},c=r=>{let i=e(`button`,{className:`persona-composer-segmented-item`,attrs:{type:`button`,"data-persona-composer-mode":r.id,"aria-label":r.label}});if(r.iconName){let e=n.renderIcon(r.iconName,16,`currentColor`,1.5);e&&i.appendChild(e)}let a=t(`span`,`persona-composer-segmented-label`);return a.textContent=r.shortLabel??r.label,i.appendChild(a),i.addEventListener(`click`,s),i},l=()=>{let e=n.getGroup();e?.label?(i.setAttribute(`role`,`group`),i.setAttribute(`aria-label`,e.label)):(i.removeAttribute(`role`),i.removeAttribute(`aria-label`));let t=n.getModes(),r=t.map(e=>`${e.id}:${e.shortLabel??e.label}:${e.iconName??``}`).join(`|`);if(r!==o){o=r;for(let e of a.values())e.removeEventListener(`click`,s);a.clear();let e=t.map(e=>{let t=c(e);return a.set(e.id,t),t});i.replaceChildren(...e)}let l=n.getActiveIds();for(let[e,t]of a)t.setAttribute(`aria-pressed`,String(l.includes(e)))};return l(),r=l,{element:i,destroy:()=>{r===l&&(r=null);for(let e of a.values())e.removeEventListener(`click`,s);a.clear()}}}},repaint:()=>r?.()}}function m(n){let r=n.row,i=``,a=!1,o=new Set(n.initialIds??[]),s=r=>{let i=e(`span`,{className:`persona-mention-chip persona-composer-mode-chip`,attrs:{"data-persona-composer-mode":r.id}});if(r.iconName){let e=t(`span`,`persona-mention-chip-icon`),a=n.renderIcon(r.iconName,12,`currentColor`,1.5);a&&e.appendChild(a),i.appendChild(e)}let a=t(`span`,`persona-mention-chip-label`);a.textContent=r.shortLabel??r.label,i.appendChild(a);let o=e(`button`,{className:`persona-mention-chip-remove`,attrs:{type:`button`,"aria-label":`Remove ${r.label}`}}),s=n.renderIcon(`x`,12,`currentColor`,2);return s?o.appendChild(s):o.textContent=`×`,o.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),n.onRemove(r.id)}),i.appendChild(o),i},c=()=>Array.from(r.querySelectorAll(`:scope > [data-persona-composer-mode]`)),l=e=>{e.setAttribute(`data-persona-chip-exit`,``),e.setAttribute(`aria-hidden`,`true`),e.style.pointerEvents=`none`;let t=()=>{e.remove(),u(r)},n=r.ownerDocument.defaultView,i=typeof n?.getComputedStyle==`function`?n.getComputedStyle(e).animationName:``;!i||i===`none`?t():(e.addEventListener(`animationend`,t,{once:!0}),e.addEventListener(`animationcancel`,t,{once:!0}))},d=()=>{for(let e of c())e.remove()};return{element:r,render:(e,t)=>{if(a)return;let n=t.filter(t=>e.includes(t.id)),d=n.map(e=>`${e.id}:${e.shortLabel??e.label}`).join(`|`);if(d===i)return;i=d;let f=/* @__PURE__ */ new Map;for(let e of c()){let t=e.getAttribute(`data-persona-composer-mode`);t&&n.some(e=>e.id===t)&&!e.hasAttribute(`data-persona-chip-exit`)?f.set(t,e):e.hasAttribute(`data-persona-chip-exit`)||l(e)}let p=r.firstChild;for(let e of n){let t=f.get(e.id);t||(t=s(e),o.has(e.id)||(t.setAttribute(`data-persona-chip-enter`,``),t.addEventListener(`animationend`,()=>t?.removeAttribute(`data-persona-chip-enter`),{once:!0}))),o.delete(e.id),t!==p&&r.insertBefore(t,p),p=t.nextSibling}u(r)},destroy:()=>{a=!0,d(),u(r)}}}function h(e){let t=null,r=null,i=/* @__PURE__ */ new Map,o=t=>{let n=i.get(t);if(n)return n;let r=p({renderIcon:e.renderIcon,groupId:t,getGroup:()=>e.getConfig().composer?.modeGroups?.find(e=>e.id===t),getModes:()=>e.getModes().filter(e=>e.groupId===t),getActiveIds:()=>e.getState().activeModeIds,onSelect:t=>e.onModeChange(t)});return i.set(t,r),r};return{collect:()=>{let i=[],c=e.getState().activeModeIds,l=new Set(e.getChipModes().map(e=>e.id)),u=/* @__PURE__ */ new Set;if(e.getModes().forEach((t,r)=>{if(a(t.groupId,e.getConfig().composer?.modeGroups)){let a=t.groupId;if(u.has(a))return;u.add(a);let s=o(a);s.action.order=n(r),s.action.label=e.getConfig().composer?.modeGroups?.find(e=>e.id===a)?.label??a,i.push(s.action);return}let d=c.includes(t.id)&&!l.has(t.id);i.push({id:s(t.id),kind:`button`,placement:`start`,order:n(r),presentation:d?`bar`:t.presentation??`auto`,label:t.label,shortLabel:d?t.shortLabel??t.label:t.shortLabel,iconName:t.iconName,trailingIconName:t.trailingIconName,pressed:c.includes(t.id),onSelect:()=>e.onModeChange(t.id)})}),e.getConfig().composer?.models?.length&&!e.hasComposerPlugin()){let n=e.getConfig().composer?.modelPicker?.presentation??`native`;t&&r===n||(r=n,t=f({renderIcon:e.renderIcon,getModels:()=>e.getConfig().composer?.models??[],getSelectedModelId:()=>e.getState().selectedModelId,onSelect:t=>e.onModelChange(t),presentation:n,getSuffix:()=>e.getConfig().composer?.modelPicker?.suffix})),i.push(t.action)}return i},repaint:()=>{for(let[t,n]of i)a(t,e.getConfig().composer?.modeGroups)?n.repaint():i.delete(t);t?.repaint()}}}export{o as createComposerActionRenderer,h as createComposerCoreControls,m as createComposerModeChipRow,f as createComposerModelPickerAction,p as createComposerSegmentedModeAction,l as createPopover,r as ensureComposerActionStyles,c as isEditableEventTarget};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e,m as t,p as n,r,s as i}from"./chunk-CEPM3FOp.js";import{r as a,t as o}from"./chunk-BnfM7-qg.js";import{t as s}from"./chunk-CnxIZOzx.js";import{i as c,r as l,t as u}from"./chunk-D5BxWOFB.js";import{r as d}from"./chunk-Bb41bKyp.js";import{t as f}from"./chunk-BlTD-Wgn.js";import{n as p,t as m}from"./chunk-BAkaTZpd.js";import{i as h,n as g,r as _,t as v}from"./chunk-BGPPJ_ui.js";import{t as y}from"./chunk-Bj8Hnh10.js";import{r as b}from"./chunk-Cy1A8vbF.js";import{Activity as x,ArrowDown as S,ArrowLeft as C,ArrowRight as w,ArrowUp as T,ArrowUpRight as E,AtSign as ee,Bot as D,Check as O,ChevronDown as k,ChevronLeft as A,ChevronRight as j,ChevronUp as M,Clipboard as N,ClipboardCopy as P,CodeXml as te,Copy as ne,Download as re,Ellipsis as ie,ExternalLink as ae,Eye as oe,File as se,FileCode as ce,FileSpreadsheet as le,FileText as ue,History as de,ImagePlus as fe,Loader as pe,LoaderCircle as me,Maximize as he,Menu as ge,MessageSquare as _e,Mic as ve,Minimize as ye,Minus as be,PanelLeft as xe,Paperclip as Se,Pencil as Ce,Plus as we,Quote as Te,RefreshCw as Ee,Search as De,Send as Oe,ShieldAlert as ke,ShieldCheck as Ae,ShieldX as je,Square as Me,Star as Ne,ThumbsDown as Pe,ThumbsUp as Fe,Trash as Ie,Trash2 as Le,Upload as Re,Volume2 as ze,X as Be}from"lucide";const Ve={activity:x,"arrow-down":S,"arrow-up":T,"arrow-up-right":E,bot:D,"chevron-down":k,"chevron-up":M,"chevron-right":j,"chevron-left":A,check:O,clipboard:N,"clipboard-copy":P,"code-xml":te,copy:ne,file:se,"file-code":ce,"file-spreadsheet":le,"file-text":ue,"image-plus":fe,loader:pe,"loader-circle":me,mic:ve,paperclip:Se,quote:Te,"refresh-cw":Ee,search:De,send:Oe,"shield-alert":ke,"shield-check":Ae,"shield-x":je,square:Me,"square-text":[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M7 8h10M7 12h10M7 16h6`}]],"thumbs-down":Pe,"thumbs-up":Fe,upload:Re,"volume-2":ze,"voice-bars":[[`path`,{d:`M4 10v4`}],[`path`,{d:`M8 6v12`}],[`path`,{d:`M12 3v18`}],[`path`,{d:`M16 7v10`}],[`path`,{d:`M20 10v4`}]],x:Be,"at-sign":ee,"arrow-left":C,"arrow-right":w,"external-link":ae,ellipsis:ie,menu:ge,"panel-left":xe,plus:we,minus:be,pencil:Ce,trash:Ie,"trash-2":Le,download:re,maximize:he,minimize:ye,"message-square":_e,star:Ne,eye:oe,history:de},He=/* @__PURE__ */ `brain.toolbox.wrench.circle.database.terminal.user.mail.phone.calendar.clock.building.map-pin.lock.key.credit-card.hash.globe.link.circle-check.circle-x.triangle-alert.info.ban.shield.ellipsis-vertical.house.pen-line.save.share.funnel.settings.rotate-cw.shopping-cart.shopping-bag.package.truck.tag.gift.receipt.wallet.store.dollar-sign.percent.play.pause.volume-x.camera.image.film.headphones.message-circle.bell.heart.eye-off.bookmark.calendar-days.timer.folder.folder-open.files.chart-column.sparkles.zap.sun.moon.flag.lightbulb.monitor.smartphone`.split(`.`),F=new Map(Object.entries(Ve)),I=/* @__PURE__ */ new Map;let L=!1;const Ue=/* @__PURE__ */ new Set,We=e=>{let t=[...Ue];e&&Ue.clear();for(let e of t)try{e()}catch{}},Ge=()=>{let e=0;for(let[t,n]of I){let r=F.get(n);if(!r)continue;I.delete(t),e++;let i=s(r);if(i)for(t.removeAttribute(`data-persona-icon-pending`);i.firstChild;)t.appendChild(i.firstChild)}return e},Ke=e=>{if(!L){for(let[t,n]of Object.entries(e))F.has(t)||F.set(t,n);L=!0,Ge(),We(!0)}},qe=()=>L?null:o().then(e=>Ke(e.EXTRA_LUCIDE_ICONS)),Je=()=>{qe()?.catch(e=>{console.warn(`[Persona] Failed to load the icons-extra chunk`,e)})},Ye=(e,t,n)=>{let r=s([],e,t,n);return r.setAttribute(`data-persona-icon-pending`,`true`),r},R=(e,t=24,n=`currentColor`,r=2)=>{let i=F.get(e);if(i)return s(i,t,n,r);if(He.includes(e)){let i=Ye(t,n,r);return I.size>=500&&I.delete(I.keys().next().value),I.set(i,e),Je(),i}return console.warn(`Unknown Persona icon "${e}". Use registerIcons().`),null},Xe=(e,t)=>e.visible!==!1&&(e.mode!==`transient`||t===`connecting`||t===`paused`||t===`resuming`||t===`error`),Ze=(e,t,n)=>{let r=t.mode===`transient`,i=e.hasAttribute(`data-persona-composer-reason`)||e.hasAttribute(`data-persona-composer-notice`);e.style.display=Xe(t,n)||r&&i&&t.visible!==!1?``:`none`,e.classList.toggle(`persona-mt-2`,!r),e.classList.toggle(`persona-mb-2`,r)},Qe=(e,t,n)=>{t.parentElement&&e.parentElement===t.parentElement&&(n.mode===`transient`?e.nextElementSibling!==t&&t.before(e):t.nextElementSibling!==e&&t.after(e))};function $e(e){let t=e.ownerDocument?.defaultView;if(!t?.getComputedStyle)return 20;let n=t.getComputedStyle(e).lineHeight;if(!n||!n.trim().endsWith(`px`))return 20;let r=parseFloat(n);return Number.isFinite(r)&&r>0?r:20}function et(e,t){return typeof e!=`number`||!Number.isFinite(e)?t:e>0?e:t}function tt(e,t){e.style.maxHeight=`${t*$e(e)}px`,e.style.overflowY=`auto`}function nt(e){let t=e?.ownerDocument?.defaultView??(typeof window<`u`?window:null);if(!t||typeof t.matchMedia!=`function`)return!1;try{return t.matchMedia(`(pointer: coarse)`).matches===!0}catch{return!1}}function rt(e){return e.insertNewlineOnTouchEnter===!0&&e.coarsePointer===!0}function it(e,t){if(e.key!==`Enter`||e.shiftKey||e.isComposing)return!1;let n=e.metaKey===!0||e.ctrlKey===!0,r=t.submitKey??`enter`;return r===`none`?!1:r===`mod-enter`?n:n||!rt(t)}function at(e){return(e.submitKey??`enter`)===`enter`?rt(e)?`enter`:`send`:`enter`}function ot(e,t){e.setAttribute(`enterkeyhint`,at(t))}function z(e,t){let n=t?.autocomplete;e.setAttribute(`autocomplete`,typeof n==`string`&&n?n:`off`);let r=(t,n)=>{n===void 0?e.removeAttribute(t):e.setAttribute(t,n)};r(`autocapitalize`,typeof t?.autocapitalize==`string`?t.autocapitalize:void 0),r(`spellcheck`,typeof t?.spellcheck==`boolean`?String(t.spellcheck):void 0),r(`inputmode`,typeof t?.inputmode==`string`&&t.inputmode?t.inputmode:void 0),r(`aria-label`,typeof t?.ariaLabel==`string`&&t.ariaLabel?t.ariaLabel:void 0)}function st(e){return e===!0?{disabled:!0}:!e||typeof e!=`object`?{disabled:!1}:{disabled:!0,reason:typeof e.reason==`string`&&e.reason?e.reason:void 0}}const{setLoader:ct,load:lt}=a({fallbackImport:()=>import(`./chunk-Co3VVwGe.js`)}),ut=lt,{setLoader:dt,load:ft}=a({fallbackImport:()=>import(`./chunk-CE4seJxF.js`),resetOnSetLoader:!0}),pt=ft;let B=400,V=300,H=0;const U=e=>Math.max(0,e);function mt(e){e.delayMs!==void 0&&(B=U(e.delayMs)),e.skipDelayMs!==void 0&&(V=U(e.skipDelayMs))}const ht=()=>Date.now()<H,gt=e=>{H=e>0?Date.now()+e:0},W=/* @__PURE__ */ new WeakMap,_t=e=>typeof e.closest==`function`&&e.closest(`[data-persona-tooltip-suppressed]`)!==null;function vt(e){W.get(e)?.hide()}const yt=e=>e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&`host`in e,bt=e=>{let t=e.getRootNode?.();return yt(t)?t:e.closest(`dialog[open]`)??e.ownerDocument.body},G=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n)),xt=[...[`background`,`foreground`,`hint-fg`,`radius`,`font-size`,`padding`,`max-width`,`shadow`,`arrow-display`].map(e=>`--persona-tooltip-${e}`),`--persona-font-family`,`--persona-radius-sm`];function K(e){W.get(e.anchor)?.destroy();let{anchor:t,trigger:n=t,text:r,hint:i,enabled:a=!0,gap:o=8,viewportPadding:s=8}=e,c=()=>t.ownerDocument,l=()=>c().defaultView??window,u=null,f=null,p=null,m=null,h,g=!1,_=!1,v=!1,y=()=>(typeof r==`function`?r():r).trim(),b=()=>(typeof i==`function`?i():i??``).trim(),x=()=>U(e.delayMs??B),S=()=>U(e.skipDelayMs??V),C=()=>{h!==void 0&&(l().clearTimeout(h),h=void 0)},w=()=>{C();let e=u!==null;m?.(),m=null,u?.remove(),u=null,f=null,p=null,e&>(S())},T=()=>{if(!u)return;let e=c(),n=l(),r=t.getBoundingClientRect(),i=u.getBoundingClientRect(),a=e.documentElement.clientWidth||n.innerWidth,d=e.documentElement.clientHeight||n.innerHeight,f=a-s-i.width,p=r.left+r.width/2-i.width/2,m=G(p,s,f),h=r.top-s,g=d-s-r.bottom,_=h>=i.height+o||h>=g?`top`:`bottom`,v=_===`top`?r.top-o-i.height:r.bottom+o,y=d-s-i.height,b=G(v,s,y),x=r.left+r.width/2,S=Math.max(10,i.width-10),C=G(x-m,10,S);u.dataset.placement=_,u.style.left=`${m}px`,u.style.top=`${b}px`,u.style.setProperty(`--persona-tooltip-arrow-x`,`${C}px`)},E=()=>{if(v||!a||u||!t.isConnected||_t(t))return;let e=y(),n=bt(t);if(!e||!n)return;let r=c(),i=l();u=r.createElement(`div`),u.className=`persona-control-tooltip`,u.setAttribute(`role`,`tooltip`),u.dataset.state=`measuring`,u.style.zIndex=String(d);let o=i.getComputedStyle?.(t);if(o){for(let e of xt){let t=o.getPropertyValue(e).trim();t&&u.style.setProperty(e,t)}o.fontFamily&&(u.style.fontFamily=o.fontFamily)}f=r.createElement(`span`),f.className=`persona-control-tooltip__label`,f.textContent=e,u.appendChild(f);let s=b();s&&(p=r.createElement(`span`),p.className=`persona-control-tooltip__hint`,p.textContent=s,u.appendChild(p));let h=r.createElement(`span`);h.className=`persona-control-tooltip__arrow`,u.appendChild(h),n.appendChild(u),T(),u.dataset.state=`open`;let g=()=>{if(!t.isConnected){w();return}f&&(f.textContent=y()),p&&(p.textContent=b());let e=bt(t);u&&e&&u.parentNode!==e&&e.appendChild(u),T()};i.addEventListener(`scroll`,g,!0),i.addEventListener(`resize`,g);let _=t.closest(`[data-persona-root]`);_?.addEventListener(`persona:internal:host-moved`,g);let x=t.getRootNode(),S=yt(x)?x:r.documentElement,C=typeof MutationObserver>`u`?null:new MutationObserver(()=>{t.isConnected||w()});C?.observe(S,{childList:!0,subtree:!0}),m=()=>{i.removeEventListener(`scroll`,g,!0),i.removeEventListener(`resize`,g),_?.removeEventListener(`persona:internal:host-moved`,g),C?.disconnect()}},ee=e=>{v||u||(C(),e||x()<=0||ht()?E():h=l().setTimeout(()=>{h=void 0,E()},x()))},D=()=>{g||_?ee(_):w()},O=()=>{let e=l();e.matchMedia&&e.matchMedia(`(hover: none)`).matches||(g=!0,D())},k=()=>{g=!1,D()},A=()=>{try{_=t.matches(`:focus-visible`)}catch{_=!0}D()},j=()=>{_=!1,D()},M=()=>{g=!1,_=!1,w()},N=e=>{e.key===`Escape`&&M()};n.addEventListener(`mouseenter`,O),n.addEventListener(`mouseleave`,k),t.addEventListener(`focus`,A),t.addEventListener(`blur`,j),t.addEventListener(`keydown`,N),t.addEventListener(`click`,M);let P={get isOpen(){return u!==null},show:E,hide:w,reposition:T,destroy:()=>{v||(v=!0,w(),n.removeEventListener(`mouseenter`,O),n.removeEventListener(`mouseleave`,k),t.removeEventListener(`focus`,A),t.removeEventListener(`blur`,j),t.removeEventListener(`keydown`,N),t.removeEventListener(`click`,M),W.delete(t))}};return W.set(t,P),P}const q=(e,t,n,r)=>{let[i,a]=t.split(`.`);return[e?.theme,e?.darkTheme].some(e=>e?.components?.[i]?.[a]?.[n]!==void 0)?`var(--persona-components-${t.replace(`.`,`-`)}-${n}, ${r})`:r},J=(e,t)=>{let n=e&&r(e,t);return typeof n==`string`&&n?n:void 0},Y=(e,t,n,r)=>{let i=t.startsWith(`var(`);e.classList.toggle(`persona-theme-padding`,i),e.style.padding=i?``:t,i?e.style.setProperty(`--persona-theme-padding`,t):e.style.removeProperty(`--persona-theme-padding`),n&&(e.style.paddingLeft=e.style.paddingRight=n),r&&(e.style.paddingTop=e.style.paddingBottom=r)},X=(e,t,n)=>{let r=t.startsWith(`var(`)&&t.includes(`--persona-components-`);e.classList.toggle(`persona-control-size`,r),r?e.style.setProperty(`--persona-control-size`,t):e.style.removeProperty(`--persona-control-size`),e.style.width=e.style.height=t,e.style.minWidth=e.style.minHeight=n??``},St=`min(440px, calc(100vw - 24px))`,Ct=`40px`,wt={apiUrl:`https://api.runtype.com/api/chat/dispatch`,clientToken:void 0,agentId:void 0,target:void 0,theme:void 0,darkTheme:void 0,colorScheme:`light`,tooltip:{delayMs:400,skipDelayMs:300},launcher:{enabled:!0,mountMode:`floating`,dock:{side:`right`,width:`420px`},title:`Chat Assistant`,subtitle:`Here to help you get answers fast`,agentIconText:`💬`,agentIconName:`bot`,headerIconName:`bot`,position:`bottom-right`,width:St,heightOffset:0,autoExpand:!1,callToActionIconHidden:!1,agentIconSize:`40px`,headerIconSize:Ct,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`,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:{inputPlaceholder:`How can I help...`,sendButtonLabel:`Send`},sendButton:{borderWidth:`0px`,paddingX:`12px`,paddingY:`10px`,borderColor:void 0,useIcon:!0,iconText:`↑`,showTooltip:!0,tooltipText:`Send message`,iconName:`send`},statusIndicator:{visible:!0,idleText:`Online`,connectingText:`Connecting…`,connectedText:`Streaming…`,errorText:`Offline`},voiceRecognition:{enabled:!0,pauseDuration:2e3,iconName:`mic`,borderWidth:`0px`,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:``,streamingIndicator:`arrow`,scrollBehavior:`instant`,scrollDurationMs:220,transition:`none`},scrollBehavior:{mode:`anchor-top`,anchorTopOffset:16,showActivityWhilePinned:!0},toolCallDisplay:_,reasoningDisplay:v,streamAnimation:{type:`none`,placeholder:`none`,speed:120,duration:1800},askUserQuestion:{enabled:!0,slideInMs:180,freeTextLabel:`Other…`,freeTextPlaceholder:`Type your answer…`,submitLabel:`Send`},history:{enabled:!1,presentation:`panel`,showScopeStatus:!0,showDelete:!0,showDeleteAll:!0}},suggestionChips:[`Show me what you can help with`,`Walk me through getting started`,`Answer a question about this page`],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},Tt={},Z={colorScheme:`light`,errorDisplay:`block`,messageActions:{visibility:void 0},suggestionChipsConfig:{fontWeight:void 0},approval:y,loadingIndicator:{variant:`label`},launcher:{variant:`circle`,width:`min(400px, calc(100vw - 24px))`,headerIconSize:`20px`},features:{artifacts:{enabled:!0},scrollToBottom:{streamingIndicator:`dots`,transition:`fade`,scrollBehavior:`smooth`},userMessageCollapse:{enabled:!0},toolCallDisplay:h,reasoningDisplay:g},composer:{layout:`single-row`,placement:`overlay`},sendButton:{iconName:`arrow-up`},statusIndicator:{mode:`transient`},layout:{contentMaxWidth:`768px`,topFade:!0,header:{showSubtitle:!1},messages:{assistant:{width:`full`}}}};function Et(e){return e?.future?.v5Defaults===!0?`v5`:`v4`}function Q(t){let n=Et(t)===`v5`?Z:Tt;return e(wt,n)}Q();function Dt(t,n){if(t||n)return t?n?e(t,n):t:n}function Ot(e){let r=Q(e);return e?i(t(b({...r,...e,colorScheme:n(e,[`colorScheme`]).includes(`colorScheme`)?e.colorScheme:e.brand?void 0:r.colorScheme,...r.approval||e.approval!==void 0?{approval:e.approval!==!1&&{...r.approval||{},...e.approval}}:{},theme:Dt(r.theme,e.theme),darkTheme:Dt(r.darkTheme,e.darkTheme),launcher:{...r.launcher,...e.launcher,dock:{...r.launcher?.dock,...e.launcher?.dock},clearChat:{...r.launcher?.clearChat,...e.launcher?.clearChat}},...r.composer||e.composer?{composer:{...r.composer,...e.composer}}:{},tooltip:{...r.tooltip,...e.tooltip},copy:{...r.copy,...e.copy},sendButton:{...r.sendButton,...e.sendButton},statusIndicator:{...r.statusIndicator,...e.statusIndicator},voiceRecognition:{...r.voiceRecognition,...e.voiceRecognition},features:(()=>{let t=r.features?.artifacts,n=e.features?.artifacts,i=r.features?.scrollToBottom,a=e.features?.scrollToBottom,o=r.features?.scrollBehavior,s=e.features?.scrollBehavior,c=r.features?.streamAnimation,l=e.features?.streamAnimation,u=r.features?.askUserQuestion,d=e.features?.askUserQuestion,f=r.features?.userMessageCollapse,p=e.features?.userMessageCollapse,m=r.features?.history,h=e.features?.history,g=t===void 0&&n===void 0?void 0:{...t,...n,layout:{...t?.layout,...n?.layout}},_=i===void 0&&a===void 0?void 0:{...i,...a},v=o===void 0&&s===void 0?void 0:{...o,...s},y=c===void 0&&l===void 0?void 0:{...c,...l},b=u===void 0&&d===void 0?void 0:{...u,...d,styles:{...u?.styles,...d?.styles}},x=m===void 0&&h===void 0?void 0:{...m,...h,copy:{...m?.copy,...h?.copy}};return{...r.features,...e.features,toolCallDisplay:{...r.features?.toolCallDisplay,...e.features?.toolCallDisplay,...e.features?.toolCallDisplay?.layout===void 0&&e.features?.toolCallDisplay?.variant!==void 0?{layout:e.features.toolCallDisplay.variant}:{}},reasoningDisplay:{...r.features?.reasoningDisplay,...e.features?.reasoningDisplay,...e.features?.reasoningDisplay?.layout===void 0&&e.features?.reasoningDisplay?.variant!==void 0?{layout:e.features.reasoningDisplay.variant}:{}},..._===void 0?{}:{scrollToBottom:_},...v===void 0?{}:{scrollBehavior:v},...g===void 0?{}:{artifacts:g},...y===void 0?{}:{streamAnimation:y},...b===void 0?{}:{askUserQuestion:b},...x===void 0?{}:{history:x},...f!==void 0||p!==void 0?{userMessageCollapse:{...f,...p}}:{}}})(),suggestionChips:e.suggestionChips??r.suggestionChips,suggestionChipsConfig:{...r.suggestionChipsConfig,...e.suggestionChipsConfig},layout:{...r.layout,...e.layout,header:{...r.layout?.header,...e.layout?.header},messages:{...r.layout?.messages,...e.layout?.messages,...r.layout?.messages?.user||e.layout?.messages?.user?{user:{...r.layout?.messages?.user,...e.layout?.messages?.user}}:{},...r.layout?.messages?.assistant||e.layout?.messages?.assistant?{assistant:{...r.layout?.messages?.assistant,...e.layout?.messages?.assistant}}:{},avatar:{...r.layout?.messages?.avatar,...e.layout?.messages?.avatar},timestamp:{...r.layout?.messages?.timestamp,...e.layout?.messages?.timestamp}},slots:{...r.layout?.slots,...e.layout?.slots}},markdown:{...r.markdown,...e.markdown,options:{...r.markdown?.options,...e.markdown?.options}},messageActions:{...r.messageActions,...e.messageActions}},e),e,Z),e):i(t(b(r),void 0,Z))}const kt=(e,t)=>{let n=u(`textarea`);n.setAttribute(`data-persona-composer-input`,``),n.placeholder=e?.copy?.inputPlaceholder??`How can I help...`,n.dir=`auto`,ot(n,{submitKey:e?.composer?.submitKey,insertNewlineOnTouchEnter:e?.composer?.insertNewlineOnTouchEnter,coarsePointer:nt(n)}),z(n,e?.composer?.inputAttributes),n.className=`persona-w-full persona-min-h-[24px] persona-resize-none persona-border-none persona-bg-transparent persona-text-sm persona-text-persona-text focus:persona-outline-none focus:persona-border-none persona-composer-textarea`,n.rows=1,n.style.fontFamily=`var(--persona-input-font-family, var(--persona-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif))`,n.style.fontWeight=`var(--persona-input-font-weight, var(--persona-font-weight, 400))`;let r=et(e?.composer?.maxLines,t?.defaultMaxLines??3),i=`${r*20}px`;n.style.maxHeight=i,n.style.overflowY=`auto`;let a=()=>{let e=n.style.maxHeight;if(e!==i){let t=parseFloat(e);if(Number.isFinite(t)&&t>0)return t}let t=r*$e(n);return i=`${t}px`,n.style.maxHeight=i,t},o=()=>{n.addEventListener(`input`,()=>{n.style.height=`auto`;let e=Math.min(n.scrollHeight,a());n.style.height=`${e}px`})};return n.style.border=`none`,n.style.outline=`none`,n.style.borderWidth=`0`,n.style.borderStyle=`none`,n.style.borderColor=`transparent`,n.addEventListener(`focus`,()=>{n.style.border=`none`,n.style.outline=`none`,n.style.borderWidth=`0`,n.style.borderStyle=`none`,n.style.borderColor=`transparent`,n.style.boxShadow=`none`}),n.addEventListener(`blur`,()=>{n.style.border=`none`,n.style.outline=`none`}),{textarea:n,attachAutoResize:o}},At=`[data-persona-glyph-stack]`,jt=(e,t,n=`send`)=>{let r=l(`span`,{className:`persona-composer-glyph-stack`,attrs:{"data-mode":n,"data-persona-glyph-stack":``}});return e.setAttribute(`data-glyph`,`send`),t.setAttribute(`data-glyph`,`stop`),r.append(e,t),r},Mt=/* @__PURE__ */ new WeakMap,$=(e,t,n=!0)=>{Mt.set(e,t);let r=t?.sendButton??{},i=r.useIcon??!1,a=e.getAttribute(`data-persona-send-mode`)===`stop`?`stop`:`send`,o=e=>J(t,`sendButton.${e}`),s=(e,n)=>q(t,`composer.send`,e,n),l=o(`size`)||r.size;e.style.fontSize=i?`18px`:``,e.style.lineHeight=i?`1`:``,e.className=c(`persona-rounded-button disabled:persona-opacity-50 persona-cursor-pointer`,i?`persona-flex persona-items-center persona-justify-center ${m}`:`persona-bg-persona-accent persona-px-4 persona-py-2 persona-text-sm persona-font-semibold`,i&&!o(`backgroundColor`)&&`persona-bg-persona-primary`,!i&&!o(`textColor`)&&`persona-text-white`),X(e,i?l||(s(`size`,``)?s(`size`,`var(--persona-composer-control-size, 40px)`):``):``,i?l:void 0);let u=s(`foreground`,i?`var(--persona-send-button-fg, var(--persona-button-primary-fg, #ffffff))`:`#ffffff`),d=s(`background`,i?`var(--persona-button-primary-bg, var(--persona-primary, #111827))`:`var(--persona-accent, #0f0f0f)`);e.style.color=o(`textColor`)||(a===`stop`&&s(`foreground`,``)?`var(--persona-button-stop-fg, ${u})`:s(`foreground`,``)||(i?u:``)),e.style.backgroundColor=(i?o(`backgroundColor`):void 0)||(s(`background`,``)?a===`stop`?`var(--persona-button-stop-bg, ${d})`:d:``);let f=o(`borderWidth`)||(s(`borderWidth`,``)?s(`borderWidth`,r.borderWidth||`0px`):r.borderWidth||``);e.style.borderWidth=f,e.style.borderStyle=f?`solid`:``,e.style.borderColor=o(`borderColor`)||(s(`borderColor`,``)?s(`borderColor`,r.borderColor||`transparent`):r.borderColor||``),e.style.borderRadius=s(`borderRadius`,``)?s(`borderRadius`,`var(--persona-components-composer-sendButtonRadius, var(--persona-button-radius))`):``,Y(e,s(`padding`,i?`0`:`8px 16px`),i?void 0:o(`paddingX`)||(s(`padding`,``)?void 0:r.paddingX),i?void 0:o(`paddingY`)||(s(`padding`,``)?void 0:r.paddingY));let p=parseFloat(r.iconSize??``)||Math.round((parseFloat(r.size??``)||40)*.5);if(n){if(e.replaceChildren(),i){let t=r.iconStrokeWidth??2,n=r.iconName?R(r.iconName,p,`currentColor`,t):null,i=R(r.stopIconName??`square`,p,`currentColor`,t);n&&i?e.appendChild(jt(n,i,a)):n?e.appendChild(n):e.textContent=r.iconText??`↑`}else e.textContent=a===`stop`?t?.copy?.stopButtonLabel??`Stop`:t?.copy?.sendButtonLabel??`Send`}for(let n of Array.from(e.querySelectorAll(`svg`))){n.style.width=n.style.height=o(`iconSize`)?``:s(`iconSize`,`var(--persona-components-composer-sendIconSize, ${p}px)`);let e=t?.sendButton?.iconStrokeWidth;n.style.strokeWidth=e===void 0?s(`iconStrokeWidth`,``):String(e)}},Nt=e=>{let t=e?.sendButton,n=u(`div`,`persona-send-button-wrapper`),r=l(`button`,{attrs:{type:`submit`,"data-persona-composer-submit":``,"data-persona-send-mode":`send`}});return $(r,e),r.setAttribute(`aria-label`,t?.tooltipText??`Send message`),n.appendChild(r),K({anchor:r,trigger:n,text:()=>r.getAttribute(`aria-label`)??``,enabled:t?.showTooltip??!1}),{button:r,wrapper:n,setMode:e=>{if(r.getAttribute(`data-persona-send-mode`)===e)return;r.setAttribute(`data-persona-send-mode`,e),r.setAttribute(`aria-label`,e===`stop`?t?.stopTooltipText??`Stop generating`:t?.tooltipText??`Send message`);let n=Mt.get(r);$(r,n,!1),r.querySelector(At)?.setAttribute(`data-mode`,e),(n?.sendButton?.useIcon??!1)||(r.textContent=e===`stop`?n?.copy?.stopButtonLabel??`Stop`:n?.copy?.sendButtonLabel??`Send`)},glyphStack:r.querySelector(At)}},Pt=(e,t,n=`idle`,r=`none`)=>{let i=t?.voiceRecognition??{},a=e=>J(t,`voiceRecognition.${e}`),o=(e,n)=>q(t,`voice.control`,e,n),s=a(`iconSize`)||i.iconSize;X(e,s||(o(`size`,``)?o(`size`,`var(--persona-composer-control-size, 40px)`):``),s),e.classList.add(m),e.classList.toggle(p,!s&&!o(`size`,``)),e.style.fontSize=`18px`,e.style.lineHeight=`1`;let c=a(`iconColor`)||J(t,`sendButton.textColor`)||o(`foreground`,`var(--persona-text, #111827)`),l=a(`backgroundColor`)||J(t,`sendButton.backgroundColor`)||o(`background`,i.backgroundColor||`transparent`),u=a(`borderColor`)||o(`borderColor`,i.borderColor||`transparent`),d=a(`borderWidth`)||o(`borderWidth`,i.borderWidth||``);e.style.borderWidth=d,e.style.borderStyle=d?`solid`:``,e.style.borderRadius=o(`borderRadius`,``)?o(`borderRadius`,`var(--persona-button-radius)`):``,Y(e,o(`padding`,``)?o(`padding`,`0px`):``,a(`paddingX`)||(o(`padding`,``)?void 0:i.paddingX),a(`paddingY`)||(o(`padding`,``)?void 0:i.paddingY));let f=a(`recordingBackgroundColor`)||`var(--persona-voice-recording-bg, #ef4444)`,h=a(`recordingIconColor`)||`var(--persona-voice-recording-indicator, #ffffff)`,g=a(`recordingBorderColor`)||`var(--persona-consumer-voice-recording-border, ${i.recordingBorderColor||u})`,_=c,v=l,y=u,b=i.iconName??`mic`;if(n===`recording`)_=h,v=f,y=g;else if(n===`processing`)_=a(`processingIconColor`)||`var(--persona-consumer-voice-processing-icon, ${c})`,v=a(`processingBackgroundColor`)||`var(--persona-consumer-voice-processing-background, ${l})`,y=a(`processingBorderColor`)||`var(--persona-components-voice-processing-border, ${u})`,b=i.processingIconName??`loader`;else if(n===`speaking`){let e=r===`barge-in`;_=a(`speakingIconColor`)||`var(--persona-consumer-voice-speaking-icon, ${e&&a(`recordingIconColor`)||c})`,v=a(`speakingBackgroundColor`)||`var(--persona-components-voice-speaking-background, ${e?f:l})`,y=a(`speakingBorderColor`)||`var(--persona-components-voice-speaking-border, ${e?g:u})`,b=i.speakingIconName??(r===`cancel`?`square`:e?`mic`:`volume-2`)}e.style.color=_,e.style.backgroundColor=v,e.style.borderColor=y,e.setAttribute(`data-state`,n);let x=parseFloat(i.iconSize??``)||24,S=R(b,x,`currentColor`,1.5);if(e.replaceChildren(),S){let t=s||(o(`iconSize`,``)?o(`iconSize`,`var(--persona-composer-control-icon-size, 24px)`):``);S.style.width=S.style.height=t,!s&&o(`iconSize`,``)&&(S.style.flexBasis=t),S.style.strokeWidth=o(`iconStrokeWidth`,`1.5`),e.appendChild(S)}else e.textContent=`🎤`},Ft=e=>{let t=e?.voiceRecognition??{};if(t.enabled!==!0||t.showButton===!1)return null;let n=typeof window<`u`&&(window.webkitSpeechRecognition!==void 0||window.SpeechRecognition!==void 0),r=t.provider?.type===`runtype`,i=t.provider?.type===`custom`||t.dictation?.provider?.type===`custom`;if(!(n||r||i))return null;let a=u(`div`,`persona-send-button-wrapper`),o=l(`button`,{className:`persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-composer-control`,attrs:{type:`button`,"data-persona-composer-mic":``,"data-state":`idle`,"aria-label":t.tooltipText??`Start voice recognition`}});Pt(o,e),a.appendChild(o);let s=t.tooltipText??`Start voice recognition`;return K({anchor:o,trigger:a,text:()=>o.getAttribute(`aria-label`)??s,enabled:t.showTooltip??!1}),{button:o,wrapper:a}},It=e=>{let t=e?.attachments??{};if(t.enabled!==!0)return null;let n=u(`div`,`persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2`);n.setAttribute(`data-persona-composer-attachment-previews`,``),n.style.display=`none`;let r=u(`input`);r.type=`file`,r.setAttribute(`data-persona-composer-attachment-input`,``),r.accept=(t.allowedTypes??f).join(`,`),r.multiple=(t.maxFiles??4)>1,r.style.display=`none`,r.setAttribute(`aria-label`,`Attach files`);let i=t.buttonIconName??`paperclip`,a=u(`div`,`persona-send-button-wrapper`),o=l(`button`,{className:`persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-attachment-button ${m} ${p}`,attrs:{type:`button`,"data-persona-composer-attachment-button":``,"aria-label":t.buttonTooltipText??`Attach file`},style:{fontSize:`18px`,lineHeight:`1`}}),s=R(i,24,`currentColor`,1.5);s?o.appendChild(s):o.textContent=`📎`,o.addEventListener(`click`,e=>{e.preventDefault(),r.click()}),a.appendChild(o);let c=t.buttonTooltipText??`Attach file`;return K({anchor:o,trigger:a,text:()=>o.getAttribute(`aria-label`)??c}),{button:o,wrapper:a,input:r,previewsContainer:n}},Lt=e=>{let t=e?.statusIndicator??{},n=t.align===`left`?`persona-text-left`:t.align===`center`?`persona-text-center`:`persona-text-right`,r=u(`div`,`persona-mt-2 ${n} persona-text-xs persona-text-persona-muted`);r.setAttribute(`data-persona-composer-status`,``),Ze(r,t,`idle`);let i=t.idleText??`Online`;if(t.idleLink){let e=u(`a`);e.href=t.idleLink,e.target=`_blank`,e.rel=`noopener noreferrer`,e.textContent=i,e.style.color=`inherit`,e.style.textDecoration=`none`,r.appendChild(e)}else r.textContent=i;return r},Rt=()=>l(`div`,{className:`persona-mb-3 persona-flex persona-flex-wrap persona-gap-2`,attrs:{"data-persona-composer-suggestions":``}});function zt(e){let{config:t,onOpen:n}=e,r=t.buttonIconName??`plus`,i=t.buttonTooltipText??`Add context`,a=u(`div`,`persona-send-button-wrapper`),o=l(`button`,{className:`persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-mention-button ${m} ${p}`,attrs:{type:`button`,"data-persona-composer-mention-button":``,"aria-label":i,"aria-haspopup":`listbox`,"aria-expanded":`false`},style:{fontSize:`18px`,lineHeight:`1`}}),s=R(r,24,`currentColor`,1.5);return s?o.appendChild(s):o.textContent=`+`,o.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),n()}),a.appendChild(o),K({anchor:o,trigger:a,text:()=>o.getAttribute(`aria-label`)??i}),{button:o,wrapper:a}}function Bt(e,t={}){if(t.render)return t.render({ref:e,readonly:!!t.readonly});let n=l(`span`,{className:c(`persona-mention-token`,t.readonly&&`persona-mention-token-readonly`),attrs:{"data-mention-source":e.sourceId,title:e.label,role:`img`,"aria-label":`${e.label} mention`}});e.color&&n.style.setProperty(`--persona-mention-token-accent`,e.color);let r=R(e.iconName??`at-sign`,13,`currentColor`,2);if(r){let e=u(`span`,`persona-mention-token-icon`);e.appendChild(r),n.appendChild(e)}return n.appendChild(l(`span`,{className:`persona-mention-token-label`,text:`@${e.label}`})),n}export{it as A,vt as C,z as D,ot as E,qe as F,R as I,et as M,Ze as N,tt as O,Qe as P,mt as S,ut as T,Y as _,It as a,J as b,Nt as c,Z as d,St as f,Et as g,Q as h,$ as i,st as j,nt as k,Lt as l,Ot as m,zt as n,kt as o,Ct as p,Pt as r,Ft as s,Bt as t,Rt as u,X as v,pt as w,K as x,q as y};
|
|
1
|
+
import{f as e,m as t,p as n,r,s as i}from"./chunk-CEPM3FOp.js";import{r as a,t as o}from"./chunk-BnfM7-qg.js";import{t as s}from"./chunk-CnxIZOzx.js";import{i as c,r as l,t as u}from"./chunk-D5BxWOFB.js";import{r as d}from"./chunk-Bb41bKyp.js";import{t as f}from"./chunk-BlTD-Wgn.js";import{n as p,t as m}from"./chunk-Dv6KtIT1.js";import{i as h,n as g,r as _,t as v}from"./chunk-BGPPJ_ui.js";import{t as y}from"./chunk-Bj8Hnh10.js";import{r as b}from"./chunk-Cy1A8vbF.js";import{Activity as x,ArrowDown as S,ArrowLeft as C,ArrowRight as w,ArrowUp as T,ArrowUpRight as E,AtSign as ee,Bot as D,Check as O,ChevronDown as k,ChevronLeft as A,ChevronRight as j,ChevronUp as M,Clipboard as N,ClipboardCopy as P,CodeXml as te,Copy as ne,Download as re,Ellipsis as ie,ExternalLink as ae,Eye as oe,File as se,FileCode as ce,FileSpreadsheet as le,FileText as ue,History as de,ImagePlus as fe,Loader as pe,LoaderCircle as me,Maximize as he,Menu as ge,MessageSquare as _e,Mic as ve,Minimize as ye,Minus as be,PanelLeft as xe,Paperclip as Se,Pencil as Ce,Plus as we,Quote as Te,RefreshCw as Ee,Search as De,Send as Oe,ShieldAlert as ke,ShieldCheck as Ae,ShieldX as je,Square as Me,Star as Ne,ThumbsDown as Pe,ThumbsUp as Fe,Trash as Ie,Trash2 as Le,Upload as Re,Volume2 as ze,X as Be}from"lucide";const Ve={activity:x,"arrow-down":S,"arrow-up":T,"arrow-up-right":E,bot:D,"chevron-down":k,"chevron-up":M,"chevron-right":j,"chevron-left":A,check:O,clipboard:N,"clipboard-copy":P,"code-xml":te,copy:ne,file:se,"file-code":ce,"file-spreadsheet":le,"file-text":ue,"image-plus":fe,loader:pe,"loader-circle":me,mic:ve,paperclip:Se,quote:Te,"refresh-cw":Ee,search:De,send:Oe,"shield-alert":ke,"shield-check":Ae,"shield-x":je,square:Me,"square-text":[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M7 8h10M7 12h10M7 16h6`}]],"thumbs-down":Pe,"thumbs-up":Fe,upload:Re,"volume-2":ze,"voice-bars":[[`path`,{d:`M4 10v4`}],[`path`,{d:`M8 6v12`}],[`path`,{d:`M12 3v18`}],[`path`,{d:`M16 7v10`}],[`path`,{d:`M20 10v4`}]],x:Be,"at-sign":ee,"arrow-left":C,"arrow-right":w,"external-link":ae,ellipsis:ie,menu:ge,"panel-left":xe,plus:we,minus:be,pencil:Ce,trash:Ie,"trash-2":Le,download:re,maximize:he,minimize:ye,"message-square":_e,star:Ne,eye:oe,history:de},He=/* @__PURE__ */ `brain.toolbox.wrench.circle.database.terminal.user.mail.phone.calendar.clock.building.map-pin.lock.key.credit-card.hash.globe.link.circle-check.circle-x.triangle-alert.info.ban.shield.ellipsis-vertical.house.pen-line.save.share.funnel.settings.rotate-cw.shopping-cart.shopping-bag.package.truck.tag.gift.receipt.wallet.store.dollar-sign.percent.play.pause.volume-x.camera.image.film.headphones.message-circle.bell.heart.eye-off.bookmark.calendar-days.timer.folder.folder-open.files.chart-column.sparkles.zap.sun.moon.flag.lightbulb.monitor.smartphone`.split(`.`),F=new Map(Object.entries(Ve)),I=/* @__PURE__ */ new Map;let L=!1;const Ue=/* @__PURE__ */ new Set,We=e=>{let t=[...Ue];e&&Ue.clear();for(let e of t)try{e()}catch{}},Ge=()=>{let e=0;for(let[t,n]of I){let r=F.get(n);if(!r)continue;I.delete(t),e++;let i=s(r);if(i)for(t.removeAttribute(`data-persona-icon-pending`);i.firstChild;)t.appendChild(i.firstChild)}return e},Ke=e=>{if(!L){for(let[t,n]of Object.entries(e))F.has(t)||F.set(t,n);L=!0,Ge(),We(!0)}},qe=()=>L?null:o().then(e=>Ke(e.EXTRA_LUCIDE_ICONS)),Je=()=>{qe()?.catch(e=>{console.warn(`[Persona] Failed to load the icons-extra chunk`,e)})},Ye=(e,t,n)=>{let r=s([],e,t,n);return r.setAttribute(`data-persona-icon-pending`,`true`),r},R=(e,t=24,n=`currentColor`,r=2)=>{let i=F.get(e);if(i)return s(i,t,n,r);if(He.includes(e)){let i=Ye(t,n,r);return I.size>=500&&I.delete(I.keys().next().value),I.set(i,e),Je(),i}return console.warn(`Unknown Persona icon "${e}". Use registerIcons().`),null},Xe=(e,t)=>e.visible!==!1&&(e.mode!==`transient`||t===`connecting`||t===`paused`||t===`resuming`||t===`error`),Ze=(e,t,n)=>{let r=t.mode===`transient`,i=e.hasAttribute(`data-persona-composer-reason`)||e.hasAttribute(`data-persona-composer-notice`);e.style.display=Xe(t,n)||r&&i&&t.visible!==!1?``:`none`,e.classList.toggle(`persona-mt-2`,!r),e.classList.toggle(`persona-mb-2`,r)},Qe=(e,t,n)=>{t.parentElement&&e.parentElement===t.parentElement&&(n.mode===`transient`?e.nextElementSibling!==t&&t.before(e):t.nextElementSibling!==e&&t.after(e))};function $e(e){let t=e.ownerDocument?.defaultView;if(!t?.getComputedStyle)return 20;let n=t.getComputedStyle(e).lineHeight;if(!n||!n.trim().endsWith(`px`))return 20;let r=parseFloat(n);return Number.isFinite(r)&&r>0?r:20}function et(e,t){return typeof e!=`number`||!Number.isFinite(e)?t:e>0?e:t}function tt(e,t){e.style.maxHeight=`${t*$e(e)}px`,e.style.overflowY=`auto`}function nt(e){let t=e?.ownerDocument?.defaultView??(typeof window<`u`?window:null);if(!t||typeof t.matchMedia!=`function`)return!1;try{return t.matchMedia(`(pointer: coarse)`).matches===!0}catch{return!1}}function rt(e){return e.insertNewlineOnTouchEnter===!0&&e.coarsePointer===!0}function it(e,t){if(e.key!==`Enter`||e.shiftKey||e.isComposing)return!1;let n=e.metaKey===!0||e.ctrlKey===!0,r=t.submitKey??`enter`;return r===`none`?!1:r===`mod-enter`?n:n||!rt(t)}function at(e){return(e.submitKey??`enter`)===`enter`?rt(e)?`enter`:`send`:`enter`}function ot(e,t){e.setAttribute(`enterkeyhint`,at(t))}function z(e,t){let n=t?.autocomplete;e.setAttribute(`autocomplete`,typeof n==`string`&&n?n:`off`);let r=(t,n)=>{n===void 0?e.removeAttribute(t):e.setAttribute(t,n)};r(`autocapitalize`,typeof t?.autocapitalize==`string`?t.autocapitalize:void 0),r(`spellcheck`,typeof t?.spellcheck==`boolean`?String(t.spellcheck):void 0),r(`inputmode`,typeof t?.inputmode==`string`&&t.inputmode?t.inputmode:void 0),r(`aria-label`,typeof t?.ariaLabel==`string`&&t.ariaLabel?t.ariaLabel:void 0)}function st(e){return e===!0?{disabled:!0}:!e||typeof e!=`object`?{disabled:!1}:{disabled:!0,reason:typeof e.reason==`string`&&e.reason?e.reason:void 0}}const{setLoader:ct,load:lt}=a({fallbackImport:()=>import(`./chunk-D2pHRNEq.js`)}),ut=lt,{setLoader:dt,load:ft}=a({fallbackImport:()=>import(`./chunk-CE4seJxF.js`),resetOnSetLoader:!0}),pt=ft;let B=400,V=300,H=0;const U=e=>Math.max(0,e);function mt(e){e.delayMs!==void 0&&(B=U(e.delayMs)),e.skipDelayMs!==void 0&&(V=U(e.skipDelayMs))}const ht=()=>Date.now()<H,gt=e=>{H=e>0?Date.now()+e:0},W=/* @__PURE__ */ new WeakMap,_t=e=>typeof e.closest==`function`&&e.closest(`[data-persona-tooltip-suppressed]`)!==null;function vt(e){W.get(e)?.hide()}const yt=e=>e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&`host`in e,bt=e=>{let t=e.getRootNode?.();return yt(t)?t:e.closest(`dialog[open]`)??e.ownerDocument.body},G=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n)),xt=[...[`background`,`foreground`,`hint-fg`,`radius`,`font-size`,`padding`,`max-width`,`shadow`,`arrow-display`].map(e=>`--persona-tooltip-${e}`),`--persona-font-family`,`--persona-radius-sm`];function K(e){W.get(e.anchor)?.destroy();let{anchor:t,trigger:n=t,text:r,hint:i,enabled:a=!0,gap:o=8,viewportPadding:s=8}=e,c=()=>t.ownerDocument,l=()=>c().defaultView??window,u=null,f=null,p=null,m=null,h,g=!1,_=!1,v=!1,y=()=>(typeof r==`function`?r():r).trim(),b=()=>(typeof i==`function`?i():i??``).trim(),x=()=>U(e.delayMs??B),S=()=>U(e.skipDelayMs??V),C=()=>{h!==void 0&&(l().clearTimeout(h),h=void 0)},w=()=>{C();let e=u!==null;m?.(),m=null,u?.remove(),u=null,f=null,p=null,e&>(S())},T=()=>{if(!u)return;let e=c(),n=l(),r=t.getBoundingClientRect(),i=u.getBoundingClientRect(),a=e.documentElement.clientWidth||n.innerWidth,d=e.documentElement.clientHeight||n.innerHeight,f=a-s-i.width,p=r.left+r.width/2-i.width/2,m=G(p,s,f),h=r.top-s,g=d-s-r.bottom,_=h>=i.height+o||h>=g?`top`:`bottom`,v=_===`top`?r.top-o-i.height:r.bottom+o,y=d-s-i.height,b=G(v,s,y),x=r.left+r.width/2,S=Math.max(10,i.width-10),C=G(x-m,10,S);u.dataset.placement=_,u.style.left=`${m}px`,u.style.top=`${b}px`,u.style.setProperty(`--persona-tooltip-arrow-x`,`${C}px`)},E=()=>{if(v||!a||u||!t.isConnected||_t(t))return;let e=y(),n=bt(t);if(!e||!n)return;let r=c(),i=l();u=r.createElement(`div`),u.className=`persona-control-tooltip`,u.setAttribute(`role`,`tooltip`),u.dataset.state=`measuring`,u.style.zIndex=String(d);let o=i.getComputedStyle?.(t);if(o){for(let e of xt){let t=o.getPropertyValue(e).trim();t&&u.style.setProperty(e,t)}o.fontFamily&&(u.style.fontFamily=o.fontFamily)}f=r.createElement(`span`),f.className=`persona-control-tooltip__label`,f.textContent=e,u.appendChild(f);let s=b();s&&(p=r.createElement(`span`),p.className=`persona-control-tooltip__hint`,p.textContent=s,u.appendChild(p));let h=r.createElement(`span`);h.className=`persona-control-tooltip__arrow`,u.appendChild(h),n.appendChild(u),T(),u.dataset.state=`open`;let g=()=>{if(!t.isConnected){w();return}f&&(f.textContent=y()),p&&(p.textContent=b());let e=bt(t);u&&e&&u.parentNode!==e&&e.appendChild(u),T()};i.addEventListener(`scroll`,g,!0),i.addEventListener(`resize`,g);let _=t.closest(`[data-persona-root]`);_?.addEventListener(`persona:internal:host-moved`,g);let x=t.getRootNode(),S=yt(x)?x:r.documentElement,C=typeof MutationObserver>`u`?null:new MutationObserver(()=>{t.isConnected||w()});C?.observe(S,{childList:!0,subtree:!0}),m=()=>{i.removeEventListener(`scroll`,g,!0),i.removeEventListener(`resize`,g),_?.removeEventListener(`persona:internal:host-moved`,g),C?.disconnect()}},ee=e=>{v||u||(C(),e||x()<=0||ht()?E():h=l().setTimeout(()=>{h=void 0,E()},x()))},D=()=>{g||_?ee(_):w()},O=()=>{let e=l();e.matchMedia&&e.matchMedia(`(hover: none)`).matches||(g=!0,D())},k=()=>{g=!1,D()},A=()=>{try{_=t.matches(`:focus-visible`)}catch{_=!0}D()},j=()=>{_=!1,D()},M=()=>{g=!1,_=!1,w()},N=e=>{e.key===`Escape`&&M()};n.addEventListener(`mouseenter`,O),n.addEventListener(`mouseleave`,k),t.addEventListener(`focus`,A),t.addEventListener(`blur`,j),t.addEventListener(`keydown`,N),t.addEventListener(`click`,M);let P={get isOpen(){return u!==null},show:E,hide:w,reposition:T,destroy:()=>{v||(v=!0,w(),n.removeEventListener(`mouseenter`,O),n.removeEventListener(`mouseleave`,k),t.removeEventListener(`focus`,A),t.removeEventListener(`blur`,j),t.removeEventListener(`keydown`,N),t.removeEventListener(`click`,M),W.delete(t))}};return W.set(t,P),P}const q=(e,t,n,r)=>{let[i,a]=t.split(`.`);return[e?.theme,e?.darkTheme].some(e=>e?.components?.[i]?.[a]?.[n]!==void 0)?`var(--persona-components-${t.replace(`.`,`-`)}-${n}, ${r})`:r},J=(e,t)=>{let n=e&&r(e,t);return typeof n==`string`&&n?n:void 0},Y=(e,t,n,r)=>{let i=t.startsWith(`var(`);e.classList.toggle(`persona-theme-padding`,i),e.style.padding=i?``:t,i?e.style.setProperty(`--persona-theme-padding`,t):e.style.removeProperty(`--persona-theme-padding`),n&&(e.style.paddingLeft=e.style.paddingRight=n),r&&(e.style.paddingTop=e.style.paddingBottom=r)},X=(e,t,n)=>{let r=t.startsWith(`var(`)&&t.includes(`--persona-components-`);e.classList.toggle(`persona-control-size`,r),r?e.style.setProperty(`--persona-control-size`,t):e.style.removeProperty(`--persona-control-size`),e.style.width=e.style.height=t,e.style.minWidth=e.style.minHeight=n??``},St=`min(440px, calc(100vw - 24px))`,Ct=`40px`,wt={apiUrl:`https://api.runtype.com/api/chat/dispatch`,clientToken:void 0,agentId:void 0,target:void 0,theme:void 0,darkTheme:void 0,colorScheme:`light`,tooltip:{delayMs:400,skipDelayMs:300},launcher:{enabled:!0,mountMode:`floating`,dock:{side:`right`,width:`420px`},title:`Chat Assistant`,subtitle:`Here to help you get answers fast`,agentIconText:`💬`,agentIconName:`bot`,headerIconName:`bot`,position:`bottom-right`,width:St,heightOffset:0,autoExpand:!1,callToActionIconHidden:!1,agentIconSize:`40px`,headerIconSize:Ct,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`,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:{inputPlaceholder:`How can I help...`,sendButtonLabel:`Send`},sendButton:{borderWidth:`0px`,paddingX:`12px`,paddingY:`10px`,borderColor:void 0,useIcon:!0,iconText:`↑`,showTooltip:!0,tooltipText:`Send message`,iconName:`send`},statusIndicator:{visible:!0,idleText:`Online`,connectingText:`Connecting…`,connectedText:`Streaming…`,errorText:`Offline`},voiceRecognition:{enabled:!0,pauseDuration:2e3,iconName:`mic`,borderWidth:`0px`,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:``,streamingIndicator:`arrow`,scrollBehavior:`instant`,scrollDurationMs:220,transition:`none`},scrollBehavior:{mode:`anchor-top`,anchorTopOffset:16,showActivityWhilePinned:!0},toolCallDisplay:_,reasoningDisplay:v,streamAnimation:{type:`none`,placeholder:`none`,speed:120,duration:1800},askUserQuestion:{enabled:!0,slideInMs:180,freeTextLabel:`Other…`,freeTextPlaceholder:`Type your answer…`,submitLabel:`Send`},history:{enabled:!1,presentation:`panel`,showScopeStatus:!0,showDelete:!0,showDeleteAll:!0}},suggestionChips:[`Show me what you can help with`,`Walk me through getting started`,`Answer a question about this page`],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},Tt={},Z={colorScheme:`light`,errorDisplay:`block`,messageActions:{visibility:void 0},suggestionChipsConfig:{fontWeight:void 0},approval:y,loadingIndicator:{variant:`label`},launcher:{variant:`circle`,width:`min(400px, calc(100vw - 24px))`,headerIconSize:`20px`},features:{artifacts:{enabled:!0},scrollToBottom:{streamingIndicator:`dots`,transition:`fade`,scrollBehavior:`smooth`},userMessageCollapse:{enabled:!0},toolCallDisplay:h,reasoningDisplay:g},composer:{layout:`single-row`,placement:`overlay`},sendButton:{iconName:`arrow-up`},statusIndicator:{mode:`transient`},layout:{contentMaxWidth:`768px`,topFade:!0,header:{showSubtitle:!1},messages:{assistant:{width:`full`}}}};function Et(e){return e?.future?.v5Defaults===!0?`v5`:`v4`}function Q(t){let n=Et(t)===`v5`?Z:Tt;return e(wt,n)}Q();function Dt(t,n){if(t||n)return t?n?e(t,n):t:n}function Ot(e){let r=Q(e);return e?i(t(b({...r,...e,colorScheme:n(e,[`colorScheme`]).includes(`colorScheme`)?e.colorScheme:e.brand?void 0:r.colorScheme,...r.approval||e.approval!==void 0?{approval:e.approval!==!1&&{...r.approval||{},...e.approval}}:{},theme:Dt(r.theme,e.theme),darkTheme:Dt(r.darkTheme,e.darkTheme),launcher:{...r.launcher,...e.launcher,dock:{...r.launcher?.dock,...e.launcher?.dock},clearChat:{...r.launcher?.clearChat,...e.launcher?.clearChat}},...r.composer||e.composer?{composer:{...r.composer,...e.composer}}:{},tooltip:{...r.tooltip,...e.tooltip},copy:{...r.copy,...e.copy},sendButton:{...r.sendButton,...e.sendButton},statusIndicator:{...r.statusIndicator,...e.statusIndicator},voiceRecognition:{...r.voiceRecognition,...e.voiceRecognition},features:(()=>{let t=r.features?.artifacts,n=e.features?.artifacts,i=r.features?.scrollToBottom,a=e.features?.scrollToBottom,o=r.features?.scrollBehavior,s=e.features?.scrollBehavior,c=r.features?.streamAnimation,l=e.features?.streamAnimation,u=r.features?.askUserQuestion,d=e.features?.askUserQuestion,f=r.features?.userMessageCollapse,p=e.features?.userMessageCollapse,m=r.features?.history,h=e.features?.history,g=t===void 0&&n===void 0?void 0:{...t,...n,layout:{...t?.layout,...n?.layout}},_=i===void 0&&a===void 0?void 0:{...i,...a},v=o===void 0&&s===void 0?void 0:{...o,...s},y=c===void 0&&l===void 0?void 0:{...c,...l},b=u===void 0&&d===void 0?void 0:{...u,...d,styles:{...u?.styles,...d?.styles}},x=m===void 0&&h===void 0?void 0:{...m,...h,copy:{...m?.copy,...h?.copy}};return{...r.features,...e.features,toolCallDisplay:{...r.features?.toolCallDisplay,...e.features?.toolCallDisplay,...e.features?.toolCallDisplay?.layout===void 0&&e.features?.toolCallDisplay?.variant!==void 0?{layout:e.features.toolCallDisplay.variant}:{}},reasoningDisplay:{...r.features?.reasoningDisplay,...e.features?.reasoningDisplay,...e.features?.reasoningDisplay?.layout===void 0&&e.features?.reasoningDisplay?.variant!==void 0?{layout:e.features.reasoningDisplay.variant}:{}},..._===void 0?{}:{scrollToBottom:_},...v===void 0?{}:{scrollBehavior:v},...g===void 0?{}:{artifacts:g},...y===void 0?{}:{streamAnimation:y},...b===void 0?{}:{askUserQuestion:b},...x===void 0?{}:{history:x},...f!==void 0||p!==void 0?{userMessageCollapse:{...f,...p}}:{}}})(),suggestionChips:e.suggestionChips??r.suggestionChips,suggestionChipsConfig:{...r.suggestionChipsConfig,...e.suggestionChipsConfig},layout:{...r.layout,...e.layout,header:{...r.layout?.header,...e.layout?.header},messages:{...r.layout?.messages,...e.layout?.messages,...r.layout?.messages?.user||e.layout?.messages?.user?{user:{...r.layout?.messages?.user,...e.layout?.messages?.user}}:{},...r.layout?.messages?.assistant||e.layout?.messages?.assistant?{assistant:{...r.layout?.messages?.assistant,...e.layout?.messages?.assistant}}:{},avatar:{...r.layout?.messages?.avatar,...e.layout?.messages?.avatar},timestamp:{...r.layout?.messages?.timestamp,...e.layout?.messages?.timestamp}},slots:{...r.layout?.slots,...e.layout?.slots}},markdown:{...r.markdown,...e.markdown,options:{...r.markdown?.options,...e.markdown?.options}},messageActions:{...r.messageActions,...e.messageActions}},e),e,Z),e):i(t(b(r),void 0,Z))}const kt=(e,t)=>{let n=u(`textarea`);n.setAttribute(`data-persona-composer-input`,``),n.placeholder=e?.copy?.inputPlaceholder??`How can I help...`,n.dir=`auto`,ot(n,{submitKey:e?.composer?.submitKey,insertNewlineOnTouchEnter:e?.composer?.insertNewlineOnTouchEnter,coarsePointer:nt(n)}),z(n,e?.composer?.inputAttributes),n.className=`persona-w-full persona-min-h-[24px] persona-resize-none persona-border-none persona-bg-transparent persona-text-sm persona-text-persona-text focus:persona-outline-none focus:persona-border-none persona-composer-textarea`,n.rows=1,n.style.fontFamily=`var(--persona-input-font-family, var(--persona-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif))`,n.style.fontWeight=`var(--persona-input-font-weight, var(--persona-font-weight, 400))`;let r=et(e?.composer?.maxLines,t?.defaultMaxLines??3),i=`${r*20}px`;n.style.maxHeight=i,n.style.overflowY=`auto`;let a=()=>{let e=n.style.maxHeight;if(e!==i){let t=parseFloat(e);if(Number.isFinite(t)&&t>0)return t}let t=r*$e(n);return i=`${t}px`,n.style.maxHeight=i,t},o=()=>{n.addEventListener(`input`,()=>{n.style.height=`auto`;let e=Math.min(n.scrollHeight,a());n.style.height=`${e}px`})};return n.style.border=`none`,n.style.outline=`none`,n.style.borderWidth=`0`,n.style.borderStyle=`none`,n.style.borderColor=`transparent`,n.addEventListener(`focus`,()=>{n.style.border=`none`,n.style.outline=`none`,n.style.borderWidth=`0`,n.style.borderStyle=`none`,n.style.borderColor=`transparent`,n.style.boxShadow=`none`}),n.addEventListener(`blur`,()=>{n.style.border=`none`,n.style.outline=`none`}),{textarea:n,attachAutoResize:o}},At=`[data-persona-glyph-stack]`,jt=(e,t,n=`send`)=>{let r=l(`span`,{className:`persona-composer-glyph-stack`,attrs:{"data-mode":n,"data-persona-glyph-stack":``}});return e.setAttribute(`data-glyph`,`send`),t.setAttribute(`data-glyph`,`stop`),r.append(e,t),r},Mt=/* @__PURE__ */ new WeakMap,$=(e,t,n=!0)=>{Mt.set(e,t);let r=t?.sendButton??{},i=r.useIcon??!1,a=e.getAttribute(`data-persona-send-mode`)===`stop`?`stop`:`send`,o=e=>J(t,`sendButton.${e}`),s=(e,n)=>q(t,`composer.send`,e,n),l=o(`size`)||r.size;e.style.fontSize=i?`18px`:``,e.style.lineHeight=i?`1`:``,e.className=c(`persona-rounded-button disabled:persona-opacity-50 persona-cursor-pointer`,i?`persona-flex persona-items-center persona-justify-center ${m}`:`persona-bg-persona-accent persona-px-4 persona-py-2 persona-text-sm persona-font-semibold`,i&&!o(`backgroundColor`)&&`persona-bg-persona-primary`,!i&&!o(`textColor`)&&`persona-text-white`),X(e,i?l||(s(`size`,``)?s(`size`,`var(--persona-composer-control-size, 40px)`):``):``,i?l:void 0);let u=s(`foreground`,i?`var(--persona-send-button-fg, var(--persona-button-primary-fg, #ffffff))`:`#ffffff`),d=s(`background`,i?`var(--persona-button-primary-bg, var(--persona-primary, #111827))`:`var(--persona-accent, #0f0f0f)`);e.style.color=o(`textColor`)||(a===`stop`&&s(`foreground`,``)?`var(--persona-button-stop-fg, ${u})`:s(`foreground`,``)||(i?u:``)),e.style.backgroundColor=(i?o(`backgroundColor`):void 0)||(s(`background`,``)?a===`stop`?`var(--persona-button-stop-bg, ${d})`:d:``);let f=o(`borderWidth`)||(s(`borderWidth`,``)?s(`borderWidth`,r.borderWidth||`0px`):r.borderWidth||``);e.style.borderWidth=f,e.style.borderStyle=f?`solid`:``,e.style.borderColor=o(`borderColor`)||(s(`borderColor`,``)?s(`borderColor`,r.borderColor||`transparent`):r.borderColor||``),e.style.borderRadius=s(`borderRadius`,``)?s(`borderRadius`,`var(--persona-components-composer-sendButtonRadius, var(--persona-button-radius))`):``,Y(e,s(`padding`,i?`0`:`8px 16px`),i?void 0:o(`paddingX`)||(s(`padding`,``)?void 0:r.paddingX),i?void 0:o(`paddingY`)||(s(`padding`,``)?void 0:r.paddingY));let p=parseFloat(r.iconSize??``)||Math.round((parseFloat(r.size??``)||40)*.5);if(n){if(e.replaceChildren(),i){let t=r.iconStrokeWidth??2,n=r.iconName?R(r.iconName,p,`currentColor`,t):null,i=R(r.stopIconName??`square`,p,`currentColor`,t);n&&i?e.appendChild(jt(n,i,a)):n?e.appendChild(n):e.textContent=r.iconText??`↑`}else e.textContent=a===`stop`?t?.copy?.stopButtonLabel??`Stop`:t?.copy?.sendButtonLabel??`Send`}for(let n of Array.from(e.querySelectorAll(`svg`))){n.style.width=n.style.height=o(`iconSize`)?``:s(`iconSize`,`var(--persona-components-composer-sendIconSize, ${p}px)`);let e=t?.sendButton?.iconStrokeWidth;n.style.strokeWidth=e===void 0?s(`iconStrokeWidth`,``):String(e)}},Nt=e=>{let t=e?.sendButton,n=u(`div`,`persona-send-button-wrapper`),r=l(`button`,{attrs:{type:`submit`,"data-persona-composer-submit":``,"data-persona-send-mode":`send`}});return $(r,e),r.setAttribute(`aria-label`,t?.tooltipText??`Send message`),n.appendChild(r),K({anchor:r,trigger:n,text:()=>r.getAttribute(`aria-label`)??``,enabled:t?.showTooltip??!1}),{button:r,wrapper:n,setMode:e=>{if(r.getAttribute(`data-persona-send-mode`)===e)return;r.setAttribute(`data-persona-send-mode`,e),r.setAttribute(`aria-label`,e===`stop`?t?.stopTooltipText??`Stop generating`:t?.tooltipText??`Send message`);let n=Mt.get(r);$(r,n,!1),r.querySelector(At)?.setAttribute(`data-mode`,e),(n?.sendButton?.useIcon??!1)||(r.textContent=e===`stop`?n?.copy?.stopButtonLabel??`Stop`:n?.copy?.sendButtonLabel??`Send`)},glyphStack:r.querySelector(At)}},Pt=(e,t,n=`idle`,r=`none`)=>{let i=t?.voiceRecognition??{},a=e=>J(t,`voiceRecognition.${e}`),o=(e,n)=>q(t,`voice.control`,e,n),s=a(`iconSize`)||i.iconSize;X(e,s||(o(`size`,``)?o(`size`,`var(--persona-composer-control-size, 40px)`):``),s),e.classList.add(m),e.classList.toggle(p,!s&&!o(`size`,``)),e.style.fontSize=`18px`,e.style.lineHeight=`1`;let c=a(`iconColor`)||J(t,`sendButton.textColor`)||o(`foreground`,`var(--persona-text, #111827)`),l=a(`backgroundColor`)||J(t,`sendButton.backgroundColor`)||o(`background`,i.backgroundColor||`transparent`),u=a(`borderColor`)||o(`borderColor`,i.borderColor||`transparent`),d=a(`borderWidth`)||o(`borderWidth`,i.borderWidth||``);e.style.borderWidth=d,e.style.borderStyle=d?`solid`:``,e.style.borderRadius=o(`borderRadius`,``)?o(`borderRadius`,`var(--persona-button-radius)`):``,Y(e,o(`padding`,``)?o(`padding`,`0px`):``,a(`paddingX`)||(o(`padding`,``)?void 0:i.paddingX),a(`paddingY`)||(o(`padding`,``)?void 0:i.paddingY));let f=a(`recordingBackgroundColor`)||`var(--persona-voice-recording-bg, #ef4444)`,h=a(`recordingIconColor`)||`var(--persona-voice-recording-indicator, #ffffff)`,g=a(`recordingBorderColor`)||`var(--persona-consumer-voice-recording-border, ${i.recordingBorderColor||u})`,_=c,v=l,y=u,b=i.iconName??`mic`;if(n===`recording`)_=h,v=f,y=g;else if(n===`processing`)_=a(`processingIconColor`)||`var(--persona-consumer-voice-processing-icon, ${c})`,v=a(`processingBackgroundColor`)||`var(--persona-consumer-voice-processing-background, ${l})`,y=a(`processingBorderColor`)||`var(--persona-components-voice-processing-border, ${u})`,b=i.processingIconName??`loader`;else if(n===`speaking`){let e=r===`barge-in`;_=a(`speakingIconColor`)||`var(--persona-consumer-voice-speaking-icon, ${e&&a(`recordingIconColor`)||c})`,v=a(`speakingBackgroundColor`)||`var(--persona-components-voice-speaking-background, ${e?f:l})`,y=a(`speakingBorderColor`)||`var(--persona-components-voice-speaking-border, ${e?g:u})`,b=i.speakingIconName??(r===`cancel`?`square`:e?`mic`:`volume-2`)}e.style.color=_,e.style.backgroundColor=v,e.style.borderColor=y,e.setAttribute(`data-state`,n);let x=parseFloat(i.iconSize??``)||24,S=R(b,x,`currentColor`,1.5);if(e.replaceChildren(),S){let t=s||(o(`iconSize`,``)?o(`iconSize`,`var(--persona-composer-control-icon-size, 24px)`):``);S.style.width=S.style.height=t,!s&&o(`iconSize`,``)&&(S.style.flexBasis=t),S.style.strokeWidth=o(`iconStrokeWidth`,`1.5`),e.appendChild(S)}else e.textContent=`🎤`},Ft=e=>{let t=e?.voiceRecognition??{};if(t.enabled!==!0||t.showButton===!1)return null;let n=typeof window<`u`&&(window.webkitSpeechRecognition!==void 0||window.SpeechRecognition!==void 0),r=t.provider?.type===`runtype`,i=t.provider?.type===`custom`||t.dictation?.provider?.type===`custom`;if(!(n||r||i))return null;let a=u(`div`,`persona-send-button-wrapper`),o=l(`button`,{className:`persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-composer-control`,attrs:{type:`button`,"data-persona-composer-mic":``,"data-state":`idle`,"aria-label":t.tooltipText??`Start voice recognition`}});Pt(o,e),a.appendChild(o);let s=t.tooltipText??`Start voice recognition`;return K({anchor:o,trigger:a,text:()=>o.getAttribute(`aria-label`)??s,enabled:t.showTooltip??!1}),{button:o,wrapper:a}},It=e=>{let t=e?.attachments??{};if(t.enabled!==!0)return null;let n=u(`div`,`persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2`);n.setAttribute(`data-persona-composer-attachment-previews`,``),n.style.display=`none`;let r=u(`input`);r.type=`file`,r.setAttribute(`data-persona-composer-attachment-input`,``),r.accept=(t.allowedTypes??f).join(`,`),r.multiple=(t.maxFiles??4)>1,r.style.display=`none`,r.setAttribute(`aria-label`,`Attach files`);let i=t.buttonIconName??`paperclip`,a=u(`div`,`persona-send-button-wrapper`),o=l(`button`,{className:`persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-attachment-button ${m} ${p}`,attrs:{type:`button`,"data-persona-composer-attachment-button":``,"aria-label":t.buttonTooltipText??`Attach file`},style:{fontSize:`18px`,lineHeight:`1`}}),s=R(i,24,`currentColor`,1.5);s?o.appendChild(s):o.textContent=`📎`,o.addEventListener(`click`,e=>{e.preventDefault(),r.click()}),a.appendChild(o);let c=t.buttonTooltipText??`Attach file`;return K({anchor:o,trigger:a,text:()=>o.getAttribute(`aria-label`)??c}),{button:o,wrapper:a,input:r,previewsContainer:n}},Lt=e=>{let t=e?.statusIndicator??{},n=t.align===`left`?`persona-text-left`:t.align===`center`?`persona-text-center`:`persona-text-right`,r=u(`div`,`persona-mt-2 ${n} persona-text-xs persona-text-persona-muted`);r.setAttribute(`data-persona-composer-status`,``),Ze(r,t,`idle`);let i=t.idleText??`Online`;if(t.idleLink){let e=u(`a`);e.href=t.idleLink,e.target=`_blank`,e.rel=`noopener noreferrer`,e.textContent=i,e.style.color=`inherit`,e.style.textDecoration=`none`,r.appendChild(e)}else r.textContent=i;return r},Rt=()=>l(`div`,{className:`persona-mb-3 persona-flex persona-flex-wrap persona-gap-2`,attrs:{"data-persona-composer-suggestions":``}});function zt(e){let{config:t,onOpen:n}=e,r=t.buttonIconName??`plus`,i=t.buttonTooltipText??`Add context`,a=u(`div`,`persona-send-button-wrapper`),o=l(`button`,{className:`persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-mention-button ${m} ${p}`,attrs:{type:`button`,"data-persona-composer-mention-button":``,"aria-label":i,"aria-haspopup":`listbox`,"aria-expanded":`false`},style:{fontSize:`18px`,lineHeight:`1`}}),s=R(r,24,`currentColor`,1.5);return s?o.appendChild(s):o.textContent=`+`,o.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),n()}),a.appendChild(o),K({anchor:o,trigger:a,text:()=>o.getAttribute(`aria-label`)??i}),{button:o,wrapper:a}}function Bt(e,t={}){if(t.render)return t.render({ref:e,readonly:!!t.readonly});let n=l(`span`,{className:c(`persona-mention-token`,t.readonly&&`persona-mention-token-readonly`),attrs:{"data-mention-source":e.sourceId,title:e.label,role:`img`,"aria-label":`${e.label} mention`}});e.color&&n.style.setProperty(`--persona-mention-token-accent`,e.color);let r=R(e.iconName??`at-sign`,13,`currentColor`,2);if(r){let e=u(`span`,`persona-mention-token-icon`);e.appendChild(r),n.appendChild(e)}return n.appendChild(l(`span`,{className:`persona-mention-token-label`,text:`@${e.label}`})),n}export{it as A,vt as C,z as D,ot as E,qe as F,R as I,et as M,Ze as N,tt as O,Qe as P,mt as S,ut as T,Y as _,It as a,J as b,Nt as c,Z as d,St as f,Et as g,Q as h,$ as i,st as j,nt as k,Lt as l,Ot as m,zt as n,kt as o,Ct as p,Pt as r,Ft as s,Bt as t,Rt as u,X as v,pt as w,K as x,q as y};
|
package/dist/client-dispatch.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}};function t(e){if(e.length===0)return`0:empty`;let t=e.map(e=>[e.name,e.description??``,e.parametersSchema?JSON.stringify(e.parametersSchema):``,e.origin??``,e.annotations?JSON.stringify(e.annotations):``].join(``)).sort();return`${e.length}:${r(t.join(``))}`}function n(e,t){let n=3735928559^t,r=1103547991^t;for(let t=0;t<e.length;t++){let i=e.charCodeAt(t);n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677)}return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}function r(e){return`${n(e,0).toString(36)}.${n(e,2654435761).toString(36)}`}var i=e((()=>{})),a,o,s,c,l=e((()=>{a=e=>e.replace(/[^a-zA-Z0-9_]/g,`_`).toLowerCase().replace(/_+/g,`_`).replace(/^_|_$/g,``),o=e=>typeof e==`object`&&!!e&&!Array.isArray(e),s=e=>{if(e.variant!==`tool`)return null;let t=e.agentMetadata?.clientToolAnswer;if(!t||!t.toolCallId||t.result===void 0)return null;let n=a(t.toolName);return n?{call:{toolCallId:t.toolCallId,toolName:n,args:o(t.args)?t.args:{}},result:{toolCallId:t.toolCallId,toolName:n,result:t.result}}:null},c=(e,t)=>{let n=[],r=[],i=[],a=``,o,c=()=>{r.length!==0&&(n.push({role:`assistant`,content:``,createdAt:a,toolCalls:r},{role:`tool`,content:``,createdAt:a,toolResults:i}),r=[],i=[])};for(let l of e){let e=s(l);if(e){let t=l.agentMetadata?.clientToolAnswer?.batch;r.length>0&&(t===void 0||t!==o)&&c(),r.length===0&&(a=l.createdAt,o=t),r.some(t=>t.toolCallId===e.call.toolCallId)||(r.push(e.call),i.push(e.result));continue}let u=t(l);u&&(c(),n.push(u))}return c(),n}})),u,d,f=e((()=>{u=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`image/bmp`],d=[`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`],[...u,...d]}));function p(e,t=e.contentParts??e.llmContent??e.rawContent??e.content){let n=e.content;if(typeof n!=`string`)return;let r=e.contentParts??e.llmContent??e.rawContent??n;if(n===``&&(t===r||JSON.stringify(t)===JSON.stringify(r)))return;let i=t;if(typeof i!=`string`||i!==n)return n}var m=e((()=>{f()})),h,g=e((()=>{h=e=>e.localOnly===!0||e.role===`assistant`&&typeof e.id==`string`&&e.id.startsWith(`reconnect-failed-`)})),_=`4.34.0`,v,y=e((()=>{v=_})),b,x,S,C,w,T;e((()=>{i(),l(),m(),g(),y(),b=e=>e.voiceCaption||h(e)?!1:!!(e.contentParts&&e.contentParts.length>0||e.llmContent&&e.llmContent.trim().length>0||e.rawContent&&e.rawContent.trim().length>0||e.content&&e.content.trim().length>0),x=e=>typeof e==`string`?!0:Array.isArray(e)?e.every(e=>{if(!e||typeof e!=`object`)return!1;switch(e.type){case`text`:return typeof e.text==`string`;case`image`:return typeof e.image==`string`;case`audio`:return typeof e.audio==`string`;case`video`:return typeof e.video==`string`;case`file`:return typeof e.data==`string`&&typeof e.mimeType==`string`&&typeof e.filename==`string`;default:return!1}}):!1,S=e=>e.slice().sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()),C=e=>{let t=e.agentMetadata?.providerPhase??e.agentMetadata?.phase;return e.role===`assistant`&&(t===`commentary`||t===`partial_answer`||t===`final_answer`)?{phase:t}:{}},w=e=>({role:e.role,content:e.contentParts??e.llmContent??e.rawContent??e.content,createdAt:e.createdAt,...C(e)}),T=class{constructor(e){this.host=e}async initializeSession(){await this.host.historyInternals.historyBootstrapReady;let e=this.host.config.getStoredConversationId?.()||null,t=this.host.historyInternals.shouldResumeDurableConversation?.()===!0;if(!this.host.isHistoryCapable()&&!t)return this.#e(e,!1);let n=await this.host.readVisitorToken();if(e&&n)try{let n=await this.createClientSession({conversationId:e,durableResume:t});return t&&n.durableRecovery?.enabled!==!0&&this.host.historyInternals.setStoredResumableHandle?.(null),this.host.finishInit(n,e,!1)}catch(n){if(!(n instanceof this.host.HistoryClientError&&n.code===`not_found`)&&!(n instanceof this.host.HistoryClientError&&n.code===`visitor_required`)&&!(n instanceof this.host.HistoryClientError&&n.code===`history_disabled`))throw n;return t&&this.host.historyInternals.setStoredResumableHandle?.(null),this.#e(e,!0)}return this.#e(e,!1)}async#e(e,t){let n=this.host.historyInternals.visitorStore;return n&&!await this.host.readVisitorToken()?n.withFirstInitLock(()=>this.#t(e,t)):this.#t(e,t)}async#t(e,t){let n=this.host.config.getStoredSessionId?.()||null,r=await this.createClientSession({storedSessionId:n}),i=await this.#n(r);return this.host.finishInit(i,e,t)}async#n(e){if(!e.visitor?.token||this.host.claimInFlight||!this.host.isHistoryCapable()&&e.durableRecovery?.enabled!==!0)return e;this.host.claimInFlight=!0;try{return await this.createClientSession({storedSessionId:e.sessionId})}catch{return e}finally{this.host.claimInFlight=!1}}async sendWithClientToolsDiff(e,n,r,i){let a=!!(n&&n.length>0),o=a?t(n):void 0,s=this.host.clientToolsFingerprintSessionId===e,c=a&&s&&this.host.lastSentClientToolsFingerprint===o,l=!a&&i?.emptyMeansReplace===!0&&this.host.sentNonEmptyClientToolsSessionId===e,u=!1,d;for(let e=0;d=await r({...a&&(u||!c)&&n?{clientTools:n}:{},...l?{clientTools:[]}:{},...o?{clientToolsFingerprint:o}:{}}),d.status===409&&e===0&&a&&(await d.clone().json().catch(()=>null))?.error===`client_tools_resend_required`;e++)u=!0,this.host.lastSentClientToolsFingerprint=null;return{response:d,commit:()=>{this.host.lastSentClientToolsFingerprint=o??null,this.host.clientToolsFingerprintSessionId=e,a?this.host.sentNonEmptyClientToolsSessionId=e:l&&(this.host.sentNonEmptyClientToolsSessionId=null)}}}async createClientSession(e){let t=this.host.isHistoryCapable()&&!e.omitVisitorFields,n=!e.omitVisitorFields,r=null;(t||n)&&(await this.host.historyInternals.historyBootstrapReady,r=await this.host.readVisitorToken());let i=this.host.routing(),a=i.agentId??i.flowId,o=t||e.durableResume?e.conversationId:void 0,s={token:this.host.config.clientToken,...a&&{flowId:a},...t&&{visitorHistory:!0},...n&&{durableRecovery:!0},...(t||n)&&r?{visitorToken:r}:{},...t&&e.identityProof?{identityProof:e.identityProof}:{},...o?{conversationId:o}:e.storedSessionId?{sessionId:e.storedSessionId}:{}};e.signal?.throwIfAborted();let c=await fetch(this.host.getClientApiUrl(`init`),{method:`POST`,headers:{"Content-Type":`application/json`,"X-Persona-Version":v},body:JSON.stringify(s),signal:e.signal});if(!c.ok){let n=await c.json().catch(()=>({error:`Session initialization failed`}));if(t&&c.status===403&&n.error===`visitor_history_disabled`){if(this.host.markHistoryUnavailable(),o)throw new this.host.HistoryClientError(`history_disabled`,`Visitor history is disabled for this surface`);return this.createClientSession({...e,omitVisitorFields:!0})}throw c.status===403&&n.error===`durable_recovery_disabled`?new this.host.HistoryClientError(`history_disabled`,`Durable recovery is disabled for this surface`):(t||e.durableResume)&&c.status===401&&n.error===`visitor_required`?new this.host.HistoryClientError(`visitor_required`,`Visitor credential no longer resolves`):o&&c.status===404?new this.host.HistoryClientError(`not_found`,`Conversation not found`):c.status===401?Error(`Invalid client token: ${n.hint||n.error}`):c.status===403?Error(`Origin not allowed: ${n.hint||n.error}`):Error(n.error||`Failed to initialize session`)}let l=await c.json();return l.visitor?.token&&await this.host.historyInternals.visitorStore?.set(l.visitor.token),{sessionId:l.sessionId,expiresAt:new Date(l.expiresAt),flow:l.flow,...l.conversationId?{conversationId:l.conversationId}:{},...l.targetId?{targetId:l.targetId}:{},...l.conversationRevision?{conversationRevision:l.conversationRevision}:{},...l.durableRecovery?{durableRecovery:l.durableRecovery}:{},...l.visitor?{visitor:l.visitor}:{},config:{welcomeMessage:l.config.welcomeMessage,placeholder:l.config.placeholder,theme:l.config.theme}}}async sendFeedback(e){if([`upvote`,`downvote`,`copy`].includes(e.type)&&!e.messageId)throw Error(`messageId is required for ${e.type} feedback type`);if(e.type===`csat`&&(e.rating===void 0||e.rating<1||e.rating>5))throw Error(`CSAT rating must be between 1 and 5`);if(e.type===`nps`&&(e.rating===void 0||e.rating<0||e.rating>10))throw Error(`NPS rating must be between 0 and 10`);this.host.debug&&console.debug(`[AgentWidgetClient] sending feedback`,e);let t={...e,...this.host.config.clientToken&&{token:this.host.config.clientToken}},n=await fetch(`${this.host.clientApiBase()}/v1/client/feedback`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Persona-Version":v},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:`Feedback submission failed`}));throw n.status===401?(this.host.clientSession=null,this.host.resetSessionWarmLatch(),this.host.config.onSessionExpired?.(),Error(`Session expired. Please refresh to continue.`)):Error(e.error||`Failed to submit feedback`)}}async dispatchClientToken(e,t,n){let{HistoryClientError:r}=this.host,i=()=>this.host.isCurrentTurn(n),a=e=>{i()&&t(e)};try{let t=()=>{if(e.signal?.throwIfAborted(),!i())throw new DOMException(`Turn superseded`,`AbortError`)},o=this.host.clientSession??await this.host.initSession();t();let s=async()=>{t();let n=o,r=n.durableRecovery?.enabled===!0;if(r&&(!n.conversationId||!await this.host.readVisitorToken()))throw Error(`Renewing this conversation requires its visitor credential.`);t();let i=await this.host.createClientSession({...r||this.host.isHistoryCapable()?{conversationId:n.conversationId,durableResume:r}:{storedSessionId:n.sessionId},signal:e.signal});if(t(),n.conversationId&&i.conversationId!==n.conversationId||r&&i.durableRecovery?.enabled!==!0)throw Error(`Session renewal did not preserve this conversation.`);o=this.host.finishInit(i,n.conversationId??null,!1),this.host.clientSession=o,this.host.resetSessionWarmLatch(),this.host.resetClientToolsFingerprint(),this.host.config.onSessionInit?.(o)};Date.now()>=o.expiresAt.getTime()-6e4&&await s();let c=new Map(S(e.messages).map(e=>[e,this.#s(e)])),l=await this.#l(e.messages,void 0,c),u=l.metadata?Object.fromEntries(Object.entries(l.metadata).filter(([e])=>e!==`sessionId`&&e!==`session_id`)):void 0,d=this.host.isHistoryCapable(),f={sessionId:o.sessionId,messages:S(e.messages).flatMap(e=>{let t=c.get(e);if(!t)return[];let n=d?p(e,t.content):void 0;return[{id:e.id,role:t.role,content:t.content,...n!==void 0&&{displayContent:n}}]}),...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},turnId:n,...e.interrupt&&{submitMode:`interrupt`},...e.voiceSpoken&&{voice:{spoken:!0,...e.voicePriorToolResults?.length&&{priorToolResults:e.voicePriorToolResults}}}},m=async()=>{t();let n=o.durableRecovery?.enabled===!0?await this.host.readVisitorToken():null;return t(),this.host.sendWithClientToolsDiff(o.sessionId,l.clientTools,async r=>{t();let i=await this.host.resolveChatIdentityProof(e.signal);t();let a={...f,sessionId:o.sessionId,...r,...i&&{identityProof:i}};return this.host.debug&&console.debug(`[AgentWidgetClient] client token dispatch`,{...a,...i&&{identityProof:{provider:i.provider,token:`[REDACTED]`}}}),fetch(this.host.getClientApiUrl(`chat`),{method:`POST`,headers:{"Content-Type":`application/json`,"X-Persona-Version":v,...n?{"X-Visitor-Token":n}:{}},body:JSON.stringify(a),signal:e.signal})})},h=await m();if(t(),h.response.status===401){let e=await h.response.clone().json().catch(()=>null);t(),e?.error===`Session not found or expired`&&(await s(),h=await m(),t())}let{response:g,commit:_}=h;if(!g.ok){let e=await g.json().catch(()=>({error:`Chat request failed`}));if(g.status===401&&e.error===`invalid_identity_proof`){let e=new r(`invalid_identity_proof`,`The identity proof was rejected`);throw a({type:`error`,error:e}),e}if(g.status===401){this.host.clearClientSession(),this.host.config.onSessionExpired?.();let e=/* @__PURE__ */ Error(`Session expired. Please refresh to continue.`);throw a({type:`error`,error:e}),e}if(g.status===429){let t=Error(e.hint||`Message limit reached for this session.`);throw a({type:`error`,error:t}),t}if(g.status===410&&e.error===`conversation_deleted`){let e=new r(`conversation_deleted`,`This conversation was deleted`);throw a({type:`error`,error:e}),e}let t=Error(e.error||`Failed to send message`);throw a({type:`error`,error:t}),t}if(!g.body){let e=/* @__PURE__ */ Error(`No response body received`);throw a({type:`error`,error:e}),e}_(),a({type:`status`,status:`connected`});try{await this.host.streamResponse(g.body,a,e.assistantMessageId,void 0,e.signal)}finally{a({type:`status`,status:`idle`})}}catch(e){let t=e instanceof Error?e:Error(String(e));throw t instanceof r||t.message.includes(`Session expired`)||t.message.includes(`Message limit`)||a({type:`error`,error:t}),t}}async dispatchProxy(e,t){let n=await this.#l(e.messages,e.composerOptions);this.host.debug&&console.debug(`[AgentWidgetClient] dispatch payload`,n);let r={...this.host.headers};if(this.host.getHeaders)try{let e=await this.host.getHeaders();r={...r,...e}}catch(e){typeof console<`u`&&console.error(`[AgentWidget] getHeaders error:`,e)}let i;if(this.host.customFetch)try{i=await this.host.customFetch(this.host.apiUrl,{method:`POST`,headers:r,body:JSON.stringify(n),signal:e.signal},n)}catch(e){let n=e instanceof Error?e:Error(String(e));throw t({type:`error`,error:n}),n}else i=await fetch(this.host.apiUrl,{method:`POST`,headers:r,body:JSON.stringify(n),signal:e.signal});if(!i.ok||!i.body){let e=/* @__PURE__ */ Error(`Chat backend request failed: ${i.status} ${i.statusText}`);throw t({type:`error`,error:e}),e}t({type:`status`,status:`connected`});try{await this.host.streamResponse(i.body,t,void 0,void 0,e.signal)}finally{t({type:`status`,status:`idle`})}}async dispatchAgent(e,t){let n=await this.#c(e.messages,e.composerOptions);this.host.debug&&console.debug(`[AgentWidgetClient] agent dispatch payload`,n);let r={...this.host.headers};if(this.host.getHeaders)try{let e=await this.host.getHeaders();r={...r,...e}}catch(e){typeof console<`u`&&console.error(`[AgentWidget] getHeaders error:`,e)}let i;if(this.host.customFetch)try{i=await this.host.customFetch(this.host.apiUrl,{method:`POST`,headers:r,body:JSON.stringify(n),signal:e.signal},n)}catch(e){let n=e instanceof Error?e:Error(String(e));throw t({type:`error`,error:n}),n}else i=await fetch(this.host.apiUrl,{method:`POST`,headers:r,body:JSON.stringify(n),signal:e.signal});if(!i.ok||!i.body){let e=/* @__PURE__ */ Error(`Agent execution request failed: ${i.status} ${i.statusText}`);throw t({type:`error`,error:e}),e}t({type:`status`,status:`connected`});try{await this.host.streamResponse(i.body,t,e.assistantMessageId,void 0,e.signal)}finally{t({type:`status`,status:`idle`})}}#r(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role===`user`)return n.mentionContext&&Object.keys(n.mentionContext).length>0?{mentions:n.mentionContext}:null}return null}async#i(e){let t={};this.host.contextProviders.length&&await Promise.all(this.host.contextProviders.map(async n=>{try{let r=await n({messages:e,config:this.host.config});r&&typeof r==`object`&&Object.assign(t,r)}catch(e){typeof console<`u`&&console.warn(`[AgentWidget] Context provider failed:`,e)}}));let n=this.#r(e);return n&&Object.assign(t,n),Object.keys(t).length?t:null}#a(e){if(!e)return;let t={};return e.selectedModelId&&(t.selectedModelId=e.selectedModelId),e.activeModeIds?.length&&(t.activeModeIds=[...e.activeModeIds]),Object.keys(t).length>0?t:void 0}#o(e,t){let n=t?.selectedModelId;return!n||!(`model`in e)?e:this.host.config.composer?.models?.some(e=>e.id===n)?{...e,model:n}:e}#s(e){if(!b(e))return null;let t=e.contentParts??e.llmContent??e.rawContent??e.content,n=e.role===`operator`?null:w(e),r=this.host.config.modelMessageTransform;if(!r)return n;let i=r({message:e,content:t,modelMessage:n});if(i===null)return null;if(!i||typeof i!=`object`||![`user`,`assistant`,`system`].includes(i.role)||!x(i.content)||typeof i.createdAt!=`string`)throw TypeError(`modelMessageTransform must return a supported model message or null`);return{role:i.role,content:i.content,createdAt:i.createdAt,...i.role===`assistant`&&i.phase&&{phase:i.phase}}}async#c(e,t){let n=this.host.routing().agentId;if(!this.host.config.agent&&!n)throw Error(`Agent configuration required for agent mode`);let r=c(S(e),e=>!e.variant||e.variant===`assistant`?this.#s(e):null),i=this.#a(t),a={agent:this.#o(this.host.config.agent??{agentId:n},i),messages:r,options:{streamResponse:!0,recordMode:`virtual`,...this.host.config.agentOptions}};i&&(a.composerOptions=i);let o=[...this.host.builtInClientTools(this.host.config),...await(await this.host.getWebMcpBridge())?.snapshotForDispatch()??[]];o.length>0&&(a.clientTools=o);let s=await this.#i(e);return s&&(a.context=s),a}async#l(e,t,n){let r=c(S(e),e=>n?n.get(e)??null:this.#s(e)),i=this.host.routing(),a={messages:r,...i.agentId?{agent:{agentId:i.agentId}}:i.flowId?{flowId:i.flowId}:{}};if(i.targetPayload)for(let[e,t]of Object.entries(i.targetPayload))e!==`messages`&&(a[e]=t);let o=[...this.host.builtInClientTools(this.host.config),...await(await this.host.getWebMcpBridge())?.snapshotForDispatch()??[]];o.length>0&&(a.clientTools=o);let s=await this.#i(e);s&&(a.context=s);let l=this.#a(t);if(l&&(a.composerOptions=l),this.host.requestMiddleware)try{let e=await this.host.requestMiddleware({payload:{...a},config:this.host.config});if(e&&typeof e==`object`){let t=e;return a.clientTools!==void 0&&!(`clientTools`in t)&&(t.clientTools=a.clientTools),t}}catch(e){typeof console<`u`&&console.error(`[AgentWidget] Request middleware error:`,e)}return a}}}))();export{T as ClientDispatch};
|
|
1
|
+
var e=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}};function t(e){if(e.length===0)return`0:empty`;let t=e.map(e=>[e.name,e.description??``,e.parametersSchema?JSON.stringify(e.parametersSchema):``,e.origin??``,e.annotations?JSON.stringify(e.annotations):``].join(``)).sort();return`${e.length}:${r(t.join(``))}`}function n(e,t){let n=3735928559^t,r=1103547991^t;for(let t=0;t<e.length;t++){let i=e.charCodeAt(t);n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677)}return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}function r(e){return`${n(e,0).toString(36)}.${n(e,2654435761).toString(36)}`}var i=e((()=>{})),a,o,s,c,l=e((()=>{a=e=>e.replace(/[^a-zA-Z0-9_]/g,`_`).toLowerCase().replace(/_+/g,`_`).replace(/^_|_$/g,``),o=e=>typeof e==`object`&&!!e&&!Array.isArray(e),s=e=>{if(e.variant!==`tool`)return null;let t=e.agentMetadata?.clientToolAnswer;if(!t||!t.toolCallId||t.result===void 0)return null;let n=a(t.toolName);return n?{call:{toolCallId:t.toolCallId,toolName:n,args:o(t.args)?t.args:{}},result:{toolCallId:t.toolCallId,toolName:n,result:t.result}}:null},c=(e,t)=>{let n=[],r=[],i=[],a=``,o,c=()=>{r.length!==0&&(n.push({role:`assistant`,content:``,createdAt:a,toolCalls:r},{role:`tool`,content:``,createdAt:a,toolResults:i}),r=[],i=[])};for(let l of e){let e=s(l);if(e){let t=l.agentMetadata?.clientToolAnswer?.batch;r.length>0&&(t===void 0||t!==o)&&c(),r.length===0&&(a=l.createdAt,o=t),r.some(t=>t.toolCallId===e.call.toolCallId)||(r.push(e.call),i.push(e.result));continue}let u=t(l);u&&(c(),n.push(u))}return c(),n}})),u,d,f=e((()=>{u=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`image/bmp`],d=[`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`],[...u,...d]}));function p(e,t=e.contentParts??e.llmContent??e.rawContent??e.content){let n=e.content;if(typeof n!=`string`)return;let r=e.contentParts??e.llmContent??e.rawContent??n;if(n===``&&(t===r||JSON.stringify(t)===JSON.stringify(r)))return;let i=t;if(typeof i!=`string`||i!==n)return n}var m=e((()=>{f()})),h,g=e((()=>{h=e=>e.localOnly===!0||e.role===`assistant`&&typeof e.id==`string`&&e.id.startsWith(`reconnect-failed-`)})),_=`4.35.1`,v,y=e((()=>{v=_})),b,x,S,C,w,T,E;e((()=>{i(),l(),m(),g(),y(),b=e=>e.voiceCaption||h(e)?!1:!!(e.contentParts&&e.contentParts.length>0||e.llmContent&&e.llmContent.trim().length>0||e.rawContent&&e.rawContent.trim().length>0||e.content&&e.content.trim().length>0),x=e=>typeof e==`string`?!0:Array.isArray(e)?e.every(e=>{if(!e||typeof e!=`object`)return!1;switch(e.type){case`text`:return typeof e.text==`string`;case`image`:return typeof e.image==`string`;case`audio`:return typeof e.audio==`string`;case`video`:return typeof e.video==`string`;case`file`:return typeof e.data==`string`&&typeof e.mimeType==`string`&&typeof e.filename==`string`;default:return!1}}):!1,S=e=>e.slice().sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()),C=e=>{let t=e.agentMetadata?.providerPhase??e.agentMetadata?.phase;return e.role===`assistant`&&(t===`commentary`||t===`partial_answer`||t===`final_answer`)?{phase:t}:{}},w=e=>({role:e.role,content:e.contentParts??e.llmContent??e.rawContent??e.content,createdAt:e.createdAt,...C(e)}),T=class{constructor(e){this.host=e}async initializeSession(){await this.host.historyInternals.historyBootstrapReady;let e=this.host.config.getStoredConversationId?.()||null,t=this.host.historyInternals.shouldResumeDurableConversation?.()===!0;if(!this.host.isHistoryCapable()&&!t)return this.#e(e,!1);let n=await this.host.readVisitorToken();if(e&&n)try{let n=await this.createClientSession({conversationId:e,durableResume:t});return t&&n.durableRecovery?.enabled!==!0&&this.host.historyInternals.setStoredResumableHandle?.(null),this.host.finishInit(n,e,!1)}catch(n){if(!(n instanceof this.host.HistoryClientError&&n.code===`not_found`)&&!(n instanceof this.host.HistoryClientError&&n.code===`visitor_required`)&&!(n instanceof this.host.HistoryClientError&&n.code===`history_disabled`))throw n;return t&&this.host.historyInternals.setStoredResumableHandle?.(null),this.#e(e,!0)}return this.#e(e,!1)}async#e(e,t){let n=this.host.historyInternals.visitorStore;return n&&!await this.host.readVisitorToken()?n.withFirstInitLock(()=>this.#t(e,t)):this.#t(e,t)}async#t(e,t){let n=this.host.config.getStoredSessionId?.()||null,r=await this.createClientSession({storedSessionId:n}),i=await this.#n(r);return this.host.finishInit(i,e,t)}async#n(e){if(!e.visitor?.token||this.host.claimInFlight||!this.host.isHistoryCapable()&&e.durableRecovery?.enabled!==!0)return e;this.host.claimInFlight=!0;try{return await this.createClientSession({storedSessionId:e.sessionId})}catch{return e}finally{this.host.claimInFlight=!1}}async sendWithClientToolsDiff(e,n,r,i){let a=!!(n&&n.length>0),o=a?t(n):void 0,s=this.host.clientToolsFingerprintSessionId===e,c=a&&s&&this.host.lastSentClientToolsFingerprint===o,l=!a&&i?.emptyMeansReplace===!0&&this.host.sentNonEmptyClientToolsSessionId===e,u=!1,d;for(let e=0;d=await r({...a&&(u||!c)&&n?{clientTools:n}:{},...l?{clientTools:[]}:{},...o?{clientToolsFingerprint:o}:{}}),d.status===409&&e===0&&a&&(await d.clone().json().catch(()=>null))?.error===`client_tools_resend_required`;e++)u=!0,this.host.lastSentClientToolsFingerprint=null;return{response:d,commit:()=>{this.host.lastSentClientToolsFingerprint=o??null,this.host.clientToolsFingerprintSessionId=e,a?this.host.sentNonEmptyClientToolsSessionId=e:l&&(this.host.sentNonEmptyClientToolsSessionId=null)}}}async createClientSession(e){let t=this.host.isHistoryCapable()&&!e.omitVisitorFields,n=!e.omitVisitorFields,r=null;(t||n)&&(await this.host.historyInternals.historyBootstrapReady,r=await this.host.readVisitorToken());let i=this.host.routing(),a=i.agentId??i.flowId,o=t||e.durableResume?e.conversationId:void 0,s={token:this.host.config.clientToken,...a&&{flowId:a},...t&&{visitorHistory:!0},...n&&{durableRecovery:!0},...(t||n)&&r?{visitorToken:r}:{},...t&&e.identityProof?{identityProof:e.identityProof}:{},...o?{conversationId:o}:e.storedSessionId?{sessionId:e.storedSessionId}:{}};e.signal?.throwIfAborted();let c=await fetch(this.host.getClientApiUrl(`init`),{method:`POST`,headers:{"Content-Type":`application/json`,"X-Persona-Version":v},body:JSON.stringify(s),signal:e.signal});if(!c.ok){let n=await c.json().catch(()=>({error:`Session initialization failed`}));if(t&&c.status===403&&n.error===`visitor_history_disabled`){if(this.host.markHistoryUnavailable(),o)throw new this.host.HistoryClientError(`history_disabled`,`Visitor history is disabled for this surface`);return this.createClientSession({...e,omitVisitorFields:!0})}throw c.status===403&&n.error===`durable_recovery_disabled`?new this.host.HistoryClientError(`history_disabled`,`Durable recovery is disabled for this surface`):(t||e.durableResume)&&c.status===401&&n.error===`visitor_required`?new this.host.HistoryClientError(`visitor_required`,`Visitor credential no longer resolves`):o&&c.status===404?new this.host.HistoryClientError(`not_found`,`Conversation not found`):c.status===401?Error(`Invalid client token: ${n.hint||n.error}`):c.status===403?Error(`Origin not allowed: ${n.hint||n.error}`):Error(n.error||`Failed to initialize session`)}let l=await c.json();return l.visitor?.token&&await this.host.historyInternals.visitorStore?.set(l.visitor.token),{sessionId:l.sessionId,expiresAt:new Date(l.expiresAt),flow:l.flow,...l.conversationId?{conversationId:l.conversationId}:{},...l.targetId?{targetId:l.targetId}:{},...l.conversationRevision?{conversationRevision:l.conversationRevision}:{},...l.durableRecovery?{durableRecovery:l.durableRecovery}:{},...l.visitor?{visitor:l.visitor}:{},config:{welcomeMessage:l.config.welcomeMessage,placeholder:l.config.placeholder,theme:l.config.theme,...E(l.config)}}}async sendFeedback(e){if([`upvote`,`downvote`,`copy`].includes(e.type)&&!e.messageId)throw Error(`messageId is required for ${e.type} feedback type`);if(e.type===`csat`&&(e.rating===void 0||e.rating<1||e.rating>5))throw Error(`CSAT rating must be between 1 and 5`);if(e.type===`nps`&&(e.rating===void 0||e.rating<0||e.rating>10))throw Error(`NPS rating must be between 0 and 10`);this.host.debug&&console.debug(`[AgentWidgetClient] sending feedback`,e);let t={...e,...this.host.config.clientToken&&{token:this.host.config.clientToken}},n=await fetch(`${this.host.clientApiBase()}/v1/client/feedback`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Persona-Version":v},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:`Feedback submission failed`}));throw n.status===401?(this.host.clientSession=null,this.host.resetSessionWarmLatch(),this.host.config.onSessionExpired?.(),Error(`Session expired. Please refresh to continue.`)):Error(e.error||`Failed to submit feedback`)}}async dispatchClientToken(e,t,n){let{HistoryClientError:r}=this.host,i=()=>this.host.isCurrentTurn(n),a=e=>{i()&&t(e)};try{let t=()=>{if(e.signal?.throwIfAborted(),!i())throw new DOMException(`Turn superseded`,`AbortError`)},o=this.host.clientSession??await this.host.initSession();t();let s=async()=>{t();let n=o,r=n.durableRecovery?.enabled===!0;if(r&&(!n.conversationId||!await this.host.readVisitorToken()))throw Error(`Renewing this conversation requires its visitor credential.`);t();let i=await this.host.createClientSession({...r||this.host.isHistoryCapable()?{conversationId:n.conversationId,durableResume:r}:{storedSessionId:n.sessionId},signal:e.signal});if(t(),n.conversationId&&i.conversationId!==n.conversationId||r&&i.durableRecovery?.enabled!==!0)throw Error(`Session renewal did not preserve this conversation.`);o=this.host.finishInit(i,n.conversationId??null,!1),this.host.clientSession=o,this.host.resetSessionWarmLatch(),this.host.resetClientToolsFingerprint(),this.host.config.onSessionInit?.(o)};Date.now()>=o.expiresAt.getTime()-6e4&&await s();let c=new Map(S(e.messages).map(e=>[e,this.#s(e)])),l=await this.#l(e.messages,void 0,c),u=l.metadata?Object.fromEntries(Object.entries(l.metadata).filter(([e])=>e!==`sessionId`&&e!==`session_id`)):void 0,d=this.host.isHistoryCapable(),f={sessionId:o.sessionId,messages:S(e.messages).flatMap(e=>{let t=c.get(e);if(!t)return[];let n=d?p(e,t.content):void 0;return[{id:e.id,role:t.role,content:t.content,...n!==void 0&&{displayContent:n}}]}),...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},turnId:n,...e.interrupt&&{submitMode:`interrupt`},...e.voiceSpoken&&{voice:{spoken:!0,...e.voicePriorToolResults?.length&&{priorToolResults:e.voicePriorToolResults}}}},m=async()=>{t();let n=o.durableRecovery?.enabled===!0?await this.host.readVisitorToken():null;return t(),this.host.sendWithClientToolsDiff(o.sessionId,l.clientTools,async r=>{t();let i=await this.host.resolveChatIdentityProof(e.signal);t();let a={...f,sessionId:o.sessionId,...r,...i&&{identityProof:i}};return this.host.debug&&console.debug(`[AgentWidgetClient] client token dispatch`,{...a,...i&&{identityProof:{provider:i.provider,token:`[REDACTED]`}}}),fetch(this.host.getClientApiUrl(`chat`),{method:`POST`,headers:{"Content-Type":`application/json`,"X-Persona-Version":v,...n?{"X-Visitor-Token":n}:{}},body:JSON.stringify(a),signal:e.signal})})},h=await m();if(t(),h.response.status===401){let e=await h.response.clone().json().catch(()=>null);t(),e?.error===`Session not found or expired`&&(await s(),h=await m(),t())}let{response:g,commit:_}=h;if(!g.ok){let e=await g.json().catch(()=>({error:`Chat request failed`}));if(g.status===401&&e.error===`invalid_identity_proof`){let e=new r(`invalid_identity_proof`,`The identity proof was rejected`);throw a({type:`error`,error:e}),e}if(g.status===401){this.host.clearClientSession(),this.host.config.onSessionExpired?.();let e=/* @__PURE__ */ Error(`Session expired. Please refresh to continue.`);throw a({type:`error`,error:e}),e}if(g.status===429){let t=Error(e.hint||`Message limit reached for this session.`);throw a({type:`error`,error:t}),t}if(g.status===410&&e.error===`conversation_deleted`){let e=new r(`conversation_deleted`,`This conversation was deleted`);throw a({type:`error`,error:e}),e}let t=Error(e.error||`Failed to send message`);throw a({type:`error`,error:t}),t}if(!g.body){let e=/* @__PURE__ */ Error(`No response body received`);throw a({type:`error`,error:e}),e}_(),a({type:`status`,status:`connected`});try{await this.host.streamResponse(g.body,a,e.assistantMessageId,void 0,e.signal)}finally{a({type:`status`,status:`idle`})}}catch(e){let t=e instanceof Error?e:Error(String(e));throw t instanceof r||t.message.includes(`Session expired`)||t.message.includes(`Message limit`)||a({type:`error`,error:t}),t}}async dispatchProxy(e,t){let n=await this.#l(e.messages,e.composerOptions);this.host.debug&&console.debug(`[AgentWidgetClient] dispatch payload`,n);let r={...this.host.headers};if(this.host.getHeaders)try{let e=await this.host.getHeaders();r={...r,...e}}catch(e){typeof console<`u`&&console.error(`[AgentWidget] getHeaders error:`,e)}let i;if(this.host.customFetch)try{i=await this.host.customFetch(this.host.apiUrl,{method:`POST`,headers:r,body:JSON.stringify(n),signal:e.signal},n)}catch(e){let n=e instanceof Error?e:Error(String(e));throw t({type:`error`,error:n}),n}else i=await fetch(this.host.apiUrl,{method:`POST`,headers:r,body:JSON.stringify(n),signal:e.signal});if(!i.ok||!i.body){let e=/* @__PURE__ */ Error(`Chat backend request failed: ${i.status} ${i.statusText}`);throw t({type:`error`,error:e}),e}t({type:`status`,status:`connected`});try{await this.host.streamResponse(i.body,t,void 0,void 0,e.signal)}finally{t({type:`status`,status:`idle`})}}async dispatchAgent(e,t){let n=await this.#c(e.messages,e.composerOptions);this.host.debug&&console.debug(`[AgentWidgetClient] agent dispatch payload`,n);let r={...this.host.headers};if(this.host.getHeaders)try{let e=await this.host.getHeaders();r={...r,...e}}catch(e){typeof console<`u`&&console.error(`[AgentWidget] getHeaders error:`,e)}let i;if(this.host.customFetch)try{i=await this.host.customFetch(this.host.apiUrl,{method:`POST`,headers:r,body:JSON.stringify(n),signal:e.signal},n)}catch(e){let n=e instanceof Error?e:Error(String(e));throw t({type:`error`,error:n}),n}else i=await fetch(this.host.apiUrl,{method:`POST`,headers:r,body:JSON.stringify(n),signal:e.signal});if(!i.ok||!i.body){let e=/* @__PURE__ */ Error(`Agent execution request failed: ${i.status} ${i.statusText}`);throw t({type:`error`,error:e}),e}t({type:`status`,status:`connected`});try{await this.host.streamResponse(i.body,t,e.assistantMessageId,void 0,e.signal)}finally{t({type:`status`,status:`idle`})}}#r(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role===`user`)return n.mentionContext&&Object.keys(n.mentionContext).length>0?{mentions:n.mentionContext}:null}return null}async#i(e){let t={};this.host.contextProviders.length&&await Promise.all(this.host.contextProviders.map(async n=>{try{let r=await n({messages:e,config:this.host.config});r&&typeof r==`object`&&Object.assign(t,r)}catch(e){typeof console<`u`&&console.warn(`[AgentWidget] Context provider failed:`,e)}}));let n=this.#r(e);return n&&Object.assign(t,n),Object.keys(t).length?t:null}#a(e){if(!e)return;let t={};return e.selectedModelId&&(t.selectedModelId=e.selectedModelId),e.activeModeIds?.length&&(t.activeModeIds=[...e.activeModeIds]),Object.keys(t).length>0?t:void 0}#o(e,t){let n=t?.selectedModelId;return!n||!(`model`in e)?e:this.host.config.composer?.models?.some(e=>e.id===n)?{...e,model:n}:e}#s(e){if(!b(e))return null;let t=e.contentParts??e.llmContent??e.rawContent??e.content,n=e.role===`operator`?null:w(e),r=this.host.config.modelMessageTransform;if(!r)return n;let i=r({message:e,content:t,modelMessage:n});if(i===null)return null;if(!i||typeof i!=`object`||![`user`,`assistant`,`system`].includes(i.role)||!x(i.content)||typeof i.createdAt!=`string`)throw TypeError(`modelMessageTransform must return a supported model message or null`);return{role:i.role,content:i.content,createdAt:i.createdAt,...i.role===`assistant`&&i.phase&&{phase:i.phase}}}async#c(e,t){let n=this.host.routing().agentId;if(!this.host.config.agent&&!n)throw Error(`Agent configuration required for agent mode`);let r=c(S(e),e=>!e.variant||e.variant===`assistant`?this.#s(e):null),i=this.#a(t),a={agent:this.#o(this.host.config.agent??{agentId:n},i),messages:r,options:{streamResponse:!0,recordMode:`virtual`,...this.host.config.agentOptions}};i&&(a.composerOptions=i);let o=[...this.host.builtInClientTools(this.host.config),...await(await this.host.getWebMcpBridge())?.snapshotForDispatch()??[]];o.length>0&&(a.clientTools=o);let s=await this.#i(e);return s&&(a.context=s),a}async#l(e,t,n){let r=c(S(e),e=>n?n.get(e)??null:this.#s(e)),i=this.host.routing(),a={messages:r,...i.agentId?{agent:{agentId:i.agentId}}:i.flowId?{flowId:i.flowId}:{}};if(i.targetPayload)for(let[e,t]of Object.entries(i.targetPayload))e!==`messages`&&(a[e]=t);let o=[...this.host.builtInClientTools(this.host.config),...await(await this.host.getWebMcpBridge())?.snapshotForDispatch()??[]];o.length>0&&(a.clientTools=o);let s=await this.#i(e);s&&(a.context=s);let l=this.#a(t);if(l&&(a.composerOptions=l),this.host.requestMiddleware)try{let e=await this.host.requestMiddleware({payload:{...a},config:this.host.config});if(e&&typeof e==`object`){let t=e;return a.clientTools!==void 0&&!(`clientTools`in t)&&(t.clientTools=a.clientTools),t}}catch(e){typeof console<`u`&&console.error(`[AgentWidget] Request middleware error:`,e)}return a}},E=e=>{let t=e.webmcp?.requireConfirmFor;return Array.isArray(t)&&t.length?{webmcp:{requireConfirmFor:t}}:{}}}))();export{T as ClientDispatch};
|
package/dist/client-history.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},t=`4.
|
|
1
|
+
var e=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},t=`4.35.1`,n,r=e((()=>{n=t}));function i(e,t,n){let r=new URLSearchParams;for(let[e,t]of Object.entries(n))t!==void 0&&t!==``&&r.set(e,String(t));let i=r.toString();return`${e.clientApiBase()}/v1/client/${t}${i?`?${i}`:``}`}function a(e,t){return t||e.config.features?.history?.scope||(e.config.getIdentityProof?`verified-user`:`browser`)}async function o(e,t,n){let r=e.config.getIdentityProof;if(!r)return n&&e.setHistoryIdentityStatus(e.browserOnlyStatus()),null;n&&e.setHistoryIdentityStatus({state:`verifying`});let i;try{i=await r()??null}catch{throw n&&e.setHistoryIdentityStatus({state:`identity_provider_failed`}),new e.HistoryClientError(`identity_provider_failed`,`The identity proof provider failed`)}if(i)return i;if(t.visitor?.endUserId!=null)throw n&&e.setHistoryIdentityStatus({state:`authentication_required`,reason:`proof_unavailable_after_binding`}),new e.HistoryClientError(`authentication_required`,`This browser is bound to a signed-in user and needs a fresh identity proof`);return n&&e.setHistoryIdentityStatus({state:`browser_only`,reason:`proof_unavailable_before_binding`}),null}async function s(e,t,n,r){if(t.visitor?.endUserId!=null)return t;let i=await e.reinitWithProof(n);if(i.visitor?.identityStatus!==`admitted`||i.visitor?.endUserId==null)throw r&&e.setHistoryIdentityStatus({state:`configuration_error`,reason:`proof_not_admitted`}),new e.HistoryClientError(`proof_not_admitted`,C);return i}async function c(e,t){let n=await t.json().catch(()=>({}));return typeof n.error==`string`?n.error:typeof n.message==`string`?n.message:``}async function l(e,t,n,r){let i=t.toLowerCase();if(i.includes(`invalid_identity_proof`))throw r&&e.setHistoryIdentityStatus({state:`authentication_required`,reason:`invalid_identity_proof`}),new e.HistoryClientError(`invalid_identity_proof`,w);if(i.includes(`visitor token required`))throw new e.HistoryClientError(`visitor_token_missing`,T);if(i.includes(`visitor_identity_mismatch`)){if(!n)throw r&&e.setHistoryIdentityStatus({state:`authentication_required`,reason:`proof_unavailable_after_binding`}),new e.HistoryClientError(`visitor_identity_mismatch`,E);return e.reinitWithProof(n)}if(i.includes(`expired`)||i.includes(`not found`))return e.clearClientSession(),e.initSession();throw new e.HistoryClientError(`unauthorized`,t||`History request was not authorized`)}async function u(e,t,n){let r=await c(e,t);if(t.status===404)return new e.HistoryClientError(`not_found`,`Conversation not found`);if(t.status===429){let n=Number.parseInt(t.headers.get(`Retry-After`)??``,10);return new e.HistoryClientError(`rate_limited`,`Too many history requests`,{...Number.isFinite(n)?{retryAfterSeconds:n}:{}})}if(t.status===503&&r.includes(`identity_proof_not_admitted`))return n&&e.setHistoryIdentityStatus({state:`configuration_error`,reason:`proof_not_admitted`}),new e.HistoryClientError(`proof_not_admitted`,C);if(t.status===401){let t=r.toLowerCase();return t.includes(`invalid_identity_proof`)?(n&&e.setHistoryIdentityStatus({state:`authentication_required`,reason:`invalid_identity_proof`}),new e.HistoryClientError(`invalid_identity_proof`,w)):t.includes(`visitor token required`)?new e.HistoryClientError(`visitor_token_missing`,T):t.includes(`visitor_identity_mismatch`)?new e.HistoryClientError(`visitor_identity_mismatch`,E):new e.HistoryClientError(`unauthorized`,r||`History request was not authorized`)}return new e.HistoryClientError(`request_failed`,r||`History request failed (${t.status})`)}function d(e,t,n,r){let i=t?.toLowerCase()??null;if(n){if(i===`admitted`){r&&e.setHistoryIdentityStatus({state:`verified`});return}throw r&&e.setHistoryIdentityStatus({state:`configuration_error`,reason:`proof_not_admitted`}),i===`ignored`?new e.HistoryClientError(`identity_contract_violation`,`Server reported an ignored identity proof on a success response`):new e.HistoryClientError(`proof_not_admitted`,`The response did not acknowledge the identity proof this request sent`)}if(i===`admitted`)throw new e.HistoryClientError(`identity_contract_violation`,`Server admitted an identity proof that was never sent`);r&&e.setHistoryIdentityStatus(e.browserOnlyStatus())}async function f(e,t,r){p(e);let f=r.trackIdentity!==!1,m=await e.initSession(),h=null;a(e,r.scope)===`verified-user`&&(h=await o(e,m,f),h&&(m=await s(e,m,h,f)));let g=e.historyInternals.visitorStore,_=!1;for(;;){let a=g?.revision()??0,o=await e.readVisitorToken();if(!o&&!r.visitorTokenOptional)throw new e.HistoryClientError(`visitor_token_missing`,`No visitor credential is stored for this browser`);let s=await fetch(i(e,t,{...r.query,sessionId:m.sessionId}),{method:r.method,headers:{"X-Persona-Version":n,...o?{"X-Visitor-Token":o}:{},...h?{"X-Identity-Proof":h}:{},...r.body===void 0?{}:{"Content-Type":`application/json`}},...r.body===void 0?{}:{body:JSON.stringify(r.body)},...r.keepalive?{keepalive:!0}:{}});if(s.status===401&&!_){_=!0,m=await l(e,await c(e,s),h,f);continue}if(!s.ok)throw await u(e,s,f);let p=s.headers.get(`X-History-Identity-Status`),v=await s.json().catch(()=>void 0);if(g&&g.revision()!==a)throw new e.HistoryClientError(`credential_changed`,`The visitor credential changed while the request was in flight`);return d(e,p,h!==null,f),v}}function p(e){if(!e.isClientTokenMode())throw Error(`Conversation history is only available in client token mode`);if(!e.isHistoryCapable())throw new e.HistoryClientError(`history_disabled`,`Visitor history is disabled for this surface`)}async function m(e,t){let n=await f(e,`conversations`,{method:`GET`,query:{...t?.cursor?{cursor:t.cursor}:{},...t?.limit===void 0?{}:{limit:t.limit},...t?.targetId?{targetId:t.targetId}:{}},...t?.scope?{scope:t.scope}:{}});return{data:(Array.isArray(n?.data)?n.data:[]).map(S),nextCursor:typeof n?.nextCursor==`string`?n.nextCursor:null}}async function h(e,t,n){let r=await f(e,`conversations/${encodeURIComponent(t)}`,{method:`GET`,query:{...n?.messageCursor?{messageCursor:n.messageCursor}:{}},...n?.scope?{scope:n.scope}:{}});return{summary:S(r),messages:Array.isArray(r?.messages)?r.messages:[],nextMessageCursor:typeof r?.nextMessageCursor==`string`?r.nextMessageCursor:null,conversationRevision:typeof r?.conversationRevision==`string`?r.conversationRevision:null}}async function g(e,t,n){p(e);let r=0;for(let t of n){let n=t.displayContent.length;if(n>b)throw new e.HistoryClientError(`payload_too_large`,`displayContent exceeds the ${b} character limit`);r+=n}if(r>x)throw new e.HistoryClientError(`payload_too_large`,`Display projection batch exceeds the ${x} character limit`);await e.initSession();let i=e.historyInternals.visitorStore,a=i?.revision()??0,o=await f(e,`conversations/${encodeURIComponent(t)}/display-projections`,{method:`PATCH`,body:{messages:n},scope:`browser`,keepalive:r<=x,trackIdentity:!1}),s=typeof o?.conversationRevision==`string`?o.conversationRevision:null;return s&&e.clientSession?.conversationId===t&&(i?.revision()??0)===a&&e.historyInternals.setStoredConversationRevision?.(s),{conversationRevision:s}}async function _(e,t,n){let r=await f(e,`conversations/${encodeURIComponent(t)}`,{method:`DELETE`,...n?.scope?{scope:n.scope}:{}});return{deleted:typeof r?.deleted==`number`?r.deleted:0}}async function v(e,t){let n=await f(e,`conversations`,{method:`DELETE`,query:{...t?.targetId===void 0?{}:{targetId:t.targetId}},...t?.scope?{scope:t.scope}:{}});return{deleted:typeof n?.deleted==`number`?n.deleted:0}}async function y(e){p(e),e.setHistoryIdentityStatus({state:`resetting`});try{await f(e,`visitor/reset`,{method:`POST`,scope:`browser`,visitorTokenOptional:!0})}finally{await e.historyInternals.visitorStore?.clear(),e.setHistoryIdentityStatus(e.derivedBrowserOnly())}return{reset:!0}}var b,x,S,C,w,T,E;e((()=>{r(),b=32768,x=49152,S=e=>{let t=e??{},n=typeof t.targetId==`string`?t.targetId:null;return{id:typeof t.id==`string`?t.id:``,title:typeof t.title==`string`?t.title:``,targetId:n,preview:typeof t.preview==`string`?t.preview:null,messageCount:typeof t.messageCount==`number`?t.messageCount:0,createdAt:typeof t.createdAt==`string`?t.createdAt:``,updatedAt:typeof t.updatedAt==`string`?t.updatedAt:``}},C=`The identity proof was not admitted; account history is unavailable`,w=`The identity proof was rejected`,T=`The request carried no visitor credential`,E=`The stored visitor belongs to a different signed-in user`}))();export{v as deleteAllConversations,_ as deleteConversation,g as finalizeDisplayProjections,h as getConversation,u as historyErrorFor,m as listConversations,c as readErrorCode,l as recoverFromUnauthorized,y as resetVisitor};
|
package/dist/codegen.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){return e?.cdnBase?.trim().replace(/\/+$/,``).replace(/[\\'"<>`]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`)}`)||`https://cdn.jsdelivr.net/npm/@runtypelabs/persona@4.
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){return e?.cdnBase?.trim().replace(/\/+$/,``).replace(/[\\'"<>`]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`)}`)||`https://cdn.jsdelivr.net/npm/@runtypelabs/persona@4.35.1/dist`}function t(e){if(e!==void 0)return typeof e==`string`?e:Array.isArray(e)?`[${e.map(e=>e.toString()).join(`, `)}]`:e.toString()}function n(e){if(e)return{getHeaders:t(e.getHeaders),onFeedback:t(e.onFeedback),onCopy:t(e.onCopy),requestMiddleware:t(e.requestMiddleware),actionHandlers:t(e.actionHandlers),actionParsers:t(e.actionParsers),postprocessMessage:t(e.postprocessMessage),contextProviders:t(e.contextProviders),streamParser:t(e.streamParser)}}const r=`({ text, message }: any) => {
|
|
2
2
|
const jsonSource = (message as any).rawContent || text || message.content;
|
|
3
3
|
if (!jsonSource || typeof jsonSource !== 'string') return null;
|
|
4
4
|
let cleanJson = jsonSource
|
package/dist/codegen.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function e(e){return e?.cdnBase?.trim().replace(/\/+$/,``).replace(/[\\'"<>`]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`)}`)||`https://cdn.jsdelivr.net/npm/@runtypelabs/persona@4.
|
|
1
|
+
function e(e){return e?.cdnBase?.trim().replace(/\/+$/,``).replace(/[\\'"<>`]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`)}`)||`https://cdn.jsdelivr.net/npm/@runtypelabs/persona@4.35.1/dist`}function t(e){if(e!==void 0)return typeof e==`string`?e:Array.isArray(e)?`[${e.map(e=>e.toString()).join(`, `)}]`:e.toString()}function n(e){if(e)return{getHeaders:t(e.getHeaders),onFeedback:t(e.onFeedback),onCopy:t(e.onCopy),requestMiddleware:t(e.requestMiddleware),actionHandlers:t(e.actionHandlers),actionParsers:t(e.actionParsers),postprocessMessage:t(e.postprocessMessage),contextProviders:t(e.contextProviders),streamParser:t(e.streamParser)}}const r=`({ text, message }: any) => {
|
|
2
2
|
const jsonSource = (message as any).rawContent || text || message.content;
|
|
3
3
|
if (!jsonSource || typeof jsonSource !== 'string') return null;
|
|
4
4
|
let cleanJson = jsonSource
|