@kitn.ai/ui 0.18.2 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/thread.d.ts +54 -0
- package/dist/custom-elements.json +195 -0
- package/dist/elements/agent-card.js +1 -1
- package/dist/elements/artifact.js +1 -1
- package/dist/elements/attachments.js +1 -1
- package/dist/elements/autoloader.js +1 -1
- package/dist/elements/avatar.js +1 -1
- package/dist/elements/badge.js +1 -1
- package/dist/elements/button.js +1 -1
- package/dist/elements/card.js +1 -1
- package/dist/elements/cards.js +1 -1
- package/dist/elements/chain-of-thought.js +1 -1
- package/dist/elements/chat-scope-picker.js +1 -1
- package/dist/elements/chat-workspace.js +1 -1
- package/dist/elements/chat.js +1 -1
- package/dist/elements/checkpoint.js +1 -1
- package/dist/elements/choice.js +1 -1
- package/dist/elements/chunks/{Icon-C2LTALdM.js → Icon-11SRdjJ4.js} +1 -1
- package/dist/elements/chunks/action-icons-CtRg17uX.js +1 -0
- package/dist/elements/chunks/arrow-left-CifsGq8x.js +1 -0
- package/dist/elements/chunks/{attachments-DLJcWCDV.js → attachments-CBqQRh60.js} +1 -1
- package/dist/elements/chunks/{badge-BTNZTODL.js → badge-CxklEXQm.js} +1 -1
- package/dist/elements/chunks/{button-DBDZebGr.js → button-BD7lUvVB.js} +1 -1
- package/dist/elements/chunks/{card-YfCyI4fH.js → card-B-PRGXdj.js} +1 -1
- package/dist/elements/chunks/chat-thread-DIZbRIKG.js +1 -0
- package/dist/elements/chunks/check-CUKS495w.js +1 -0
- package/dist/elements/chunks/chevron-down-AELmYT1j.js +1 -0
- package/dist/elements/chunks/chevron-right-C8g26oKh.js +1 -0
- package/dist/elements/chunks/circle-DGcI8Cft.js +1 -0
- package/dist/elements/chunks/circle-check-DuU0IcBQ.js +1 -0
- package/dist/elements/chunks/{circle-x-pDtzlghQ.js → circle-x-mtjCO_Ok.js} +1 -1
- package/dist/elements/chunks/{code-block-DZ6mz6vs.js → code-block-BeWVttmU.js} +1 -1
- package/dist/elements/chunks/{collapsible-CWUAShMC.js → collapsible-DGjADCN6.js} +1 -1
- package/dist/elements/chunks/{composer-BZyPU6gD.js → composer-CavJww3d.js} +7 -3
- package/dist/elements/chunks/{context-Cx6eQA_G.js → context-CnlsNJSJ.js} +1 -1
- package/dist/elements/chunks/{conversation-list-C4xTQSpT.js → conversation-list-5O_KdI_I.js} +1 -1
- package/dist/elements/chunks/{default-input-BZcwyKcP.js → default-input-CB46cJJ1.js} +1 -1
- package/dist/elements/chunks/{define-CNSKFZCd.js → define-DfTe4zwZ.js} +1 -1
- package/dist/elements/chunks/{disclosure-BcBs--Jf.js → disclosure-BtFK3a-M.js} +1 -1
- package/dist/elements/chunks/{download-BDQwcFav.js → download-qJv1dS3M.js} +1 -1
- package/dist/elements/chunks/{dropdown-wgs8xCJZ.js → dropdown-UhtAueYR.js} +1 -1
- package/dist/elements/chunks/{ellipsis-CUiEJ6R1.js → ellipsis-B1sOOqiJ.js} +1 -1
- package/dist/elements/chunks/{external-link-DJUmC7g2.js → external-link-DToP_VKE.js} +1 -1
- package/dist/elements/chunks/{file-text-DOYfYvrh.js → file-text-BwUs_Pj4.js} +1 -1
- package/dist/elements/chunks/{file-tree-DQzNQrbr.js → file-tree-C6RhmSnX.js} +1 -1
- package/dist/elements/chunks/{folder-DBDUBANz.js → folder-H_Xp0GYP.js} +1 -1
- package/dist/elements/chunks/hover-card-Dn3yrk1l.js +1 -0
- package/dist/elements/chunks/icon-BrxJQXzC.js +1 -0
- package/dist/elements/chunks/{info-DBQl-m6e.js → info-11eT2q5H.js} +1 -1
- package/dist/elements/chunks/{input-DZD67EvW.js → input-B9oZKDfb.js} +1 -1
- package/dist/elements/chunks/{kbd-DbyVrlnU.js → kbd-D2fx3rWh.js} +1 -1
- package/dist/elements/chunks/{link-vko7AttA.js → link-B-RNYWNw.js} +1 -1
- package/dist/elements/chunks/{loader-Cg6rO8tQ.js → loader-BJh_aRlp.js} +1 -1
- package/dist/elements/chunks/{markdown-n3Xbj3PR.js → markdown-BIpjrDFv.js} +1 -1
- package/dist/elements/chunks/{message-CgKytiSB.js → message-CPfqj8Gi.js} +1 -1
- package/dist/elements/chunks/{message-feedback-Ds3-US0e.js → message-feedback-8uj0aVYh.js} +1 -1
- package/dist/elements/chunks/message-square-CCSQ4M9g.js +1 -0
- package/dist/elements/chunks/{minimize-2-3kCdE0q3.js → minimize-2-C9qkiTJg.js} +1 -1
- package/dist/elements/chunks/{model-switcher-BMtXGwLU.js → model-switcher-DRrMcRXH.js} +1 -1
- package/dist/elements/chunks/{overlay-B1-MBI6h.js → overlay-C8_FUL8q.js} +1 -1
- package/dist/elements/chunks/{paperclip-DDEfmkHc.js → paperclip-MA9hxLhW.js} +1 -1
- package/dist/elements/chunks/{progress-bar-Dwbiyv3s.js → progress-bar-y5G6HDjg.js} +1 -1
- package/dist/elements/chunks/{prompt-suggestion-9lvgFcEa.js → prompt-suggestion-LalWvCJy.js} +1 -1
- package/dist/elements/chunks/reasoning-CW3SDdb4.js +1 -0
- package/dist/elements/chunks/resizable-xhYF5lCQ.js +1 -0
- package/dist/elements/chunks/{rotate-cw-jpisOdOV.js → rotate-cw-2ndEXjgS.js} +1 -1
- package/dist/elements/chunks/{scroll-area-g5Ze3K6f.js → scroll-area-BzOPDXrZ.js} +1 -1
- package/dist/elements/chunks/scroll-button-B1x4cYqM.js +1 -0
- package/dist/elements/chunks/{separator-Bmjc5XyX.js → separator-CPvL5Xdl.js} +1 -1
- package/dist/elements/chunks/{settings-group-9imY3kRA.js → settings-group-BiIym17O.js} +1 -1
- package/dist/elements/chunks/{settings-Cz1bMJP9.js → settings-hmzIuNXD.js} +1 -1
- package/dist/elements/chunks/{share-BdenF0wQ.js → share-BbziTAzn.js} +1 -1
- package/dist/elements/chunks/skeleton-Bxhs1thL.js +1 -0
- package/dist/elements/chunks/{slots-DkZ-Cmha.js → slots--V19HwUb.js} +1 -1
- package/dist/elements/chunks/{star-DY6z1UUH.js → star-BHL3Va5p.js} +1 -1
- package/dist/elements/chunks/{store-th4VyJXM.js → store-tpnnWlxY.js} +1 -1
- package/dist/elements/chunks/{text-shimmer-CEi-tlXr.js → text-shimmer-1DCKivKx.js} +1 -1
- package/dist/elements/chunks/textarea-Czaowo9F.js +1 -0
- package/dist/elements/chunks/{thumbs-up-BR33KLfA.js → thumbs-up-CdLqA13R.js} +1 -1
- package/dist/elements/chunks/{toast-store-BEMda0fv.js → toast-store-BvBquUFA.js} +1 -1
- package/dist/elements/chunks/{tool-TMued3WO.js → tool-4P_ne8Go.js} +1 -1
- package/dist/elements/chunks/{tooltip-Cft_Rxiw.js → tooltip-CBeFqJKk.js} +1 -1
- package/dist/elements/chunks/{triangle-alert-B07fX3Q8.js → triangle-alert-BllqxXq8.js} +1 -1
- package/dist/elements/chunks/{use-card-resolution-M36zVciB.js → use-card-resolution-73xiddIW.js} +1 -1
- package/dist/elements/chunks/{video-MKp3LmNT.js → video-O9rA6k7S.js} +1 -1
- package/dist/elements/chunks/x-DeS3rQhx.js +1 -0
- package/dist/elements/coachmark.js +1 -1
- package/dist/elements/code-block.js +1 -1
- package/dist/elements/command.js +1 -1
- package/dist/elements/compare.js +1 -1
- package/dist/elements/composer.js +1 -1
- package/dist/elements/confirm-card.js +1 -1
- package/dist/elements/context-meter.js +1 -1
- package/dist/elements/conversation-list.js +1 -1
- package/dist/elements/dialog.js +1 -1
- package/dist/elements/editable-label.js +1 -1
- package/dist/elements/embed.js +1 -1
- package/dist/elements/empty.js +1 -1
- package/dist/elements/feedback-bar.js +1 -1
- package/dist/elements/file-tree.js +1 -1
- package/dist/elements/file-upload.js +1 -1
- package/dist/elements/form.js +1 -1
- package/dist/elements/hover-card.js +1 -1
- package/dist/elements/icon.js +1 -1
- package/dist/elements/image.js +1 -1
- package/dist/elements/input.js +1 -1
- package/dist/elements/kbd.js +1 -1
- package/dist/elements/link-preview.js +1 -1
- package/dist/elements/loader.js +1 -1
- package/dist/elements/markdown.js +1 -1
- package/dist/elements/menu.js +1 -1
- package/dist/elements/message-skills.js +1 -1
- package/dist/elements/message.js +1 -1
- package/dist/elements/model-switcher.js +1 -1
- package/dist/elements/nav.js +1 -1
- package/dist/elements/notice.js +1 -1
- package/dist/elements/pane-group.js +1 -1
- package/dist/elements/pane.js +1 -1
- package/dist/elements/popover.js +1 -1
- package/dist/elements/progress-bar.js +1 -1
- package/dist/elements/prompt-dock.js +1 -1
- package/dist/elements/prompt-input.js +1 -1
- package/dist/elements/prompt-suggestions.js +1 -1
- package/dist/elements/reasoning.js +1 -1
- package/dist/elements/remote.js +1 -1
- package/dist/elements/resizable.js +1 -1
- package/dist/elements/response-stream.js +1 -1
- package/dist/elements/screen.js +1 -1
- package/dist/elements/scroll-area.js +1 -1
- package/dist/elements/scroll-button.js +1 -1
- package/dist/elements/search.js +1 -1
- package/dist/elements/segmented.js +1 -1
- package/dist/elements/separator.js +1 -1
- package/dist/elements/setting-item.js +1 -1
- package/dist/elements/settings-group.js +1 -1
- package/dist/elements/skeleton.js +1 -1
- package/dist/elements/slots.d.ts +3 -0
- package/dist/elements/source.js +1 -1
- package/dist/elements/status.js +1 -1
- package/dist/elements/switch.js +1 -1
- package/dist/elements/tabs.js +1 -1
- package/dist/elements/tasks.js +1 -1
- package/dist/elements/text-shimmer.js +1 -1
- package/dist/elements/thinking-bar.js +1 -1
- package/dist/elements/thread.d.ts +1 -0
- package/dist/elements/thread.js +1 -0
- package/dist/elements/toast.js +1 -1
- package/dist/elements/tool.js +1 -1
- package/dist/elements/tooltip.js +1 -1
- package/dist/elements/voice-input.js +1 -1
- package/dist/elements/voice-output.js +1 -1
- package/dist/elements.d.ts +24 -0
- package/dist/index.js +3393 -3311
- package/dist/kai.es.js +1 -1
- package/dist/llms/llms-full.txt +34 -4
- package/dist/llms/llms.txt +3 -3
- package/dist/react/index.d.ts +64 -0
- package/dist/react/use-voice-input.d.ts +15 -0
- package/dist/react.js +263 -240
- package/dist/register-impl-CaaHJcea.js +145 -0
- package/dist/ui/resizable.d.ts +9 -3
- package/frameworks/react/index.tsx +32 -1
- package/frameworks/react/use-voice-input.tsx +59 -0
- package/llms-full.txt +34 -4
- package/llms.txt +3 -3
- package/package.json +27 -5
- package/src/components/component-meta.json +30 -28
- package/src/components/composer.tsx +5 -0
- package/src/components/thread.tsx +177 -0
- package/src/elements/chat-workspace.tsx +1 -1
- package/src/elements/compiled.css +1 -1
- package/src/elements/element-manifest.json +4 -0
- package/src/elements/element-meta.json +117 -0
- package/src/elements/element-types.d.ts +24 -0
- package/src/elements/icon-names.json +2 -0
- package/src/elements/menu.tsx +7 -4
- package/src/elements/register-impl.ts +2 -0
- package/src/elements/resizable.tsx +78 -2
- package/src/elements/slots.ts +7 -0
- package/src/elements/thread.tsx +105 -0
- package/src/ui/action-icons.ts +2 -1
- package/src/ui/icon.tsx +4 -0
- package/src/ui/overlay.tsx +8 -1
- package/src/ui/resizable.tsx +47 -9
- package/dist/elements/chunks/action-icons-Dtl8Ox5D.js +0 -1
- package/dist/elements/chunks/arrow-left-GbBceGBE.js +0 -1
- package/dist/elements/chunks/chat-thread-Dz2qbzvI.js +0 -1
- package/dist/elements/chunks/check-fhmRksq_.js +0 -1
- package/dist/elements/chunks/chevron-down-DcRg1aRU.js +0 -1
- package/dist/elements/chunks/chevron-right-ChzBcNJ-.js +0 -1
- package/dist/elements/chunks/circle-B4fTe9v6.js +0 -1
- package/dist/elements/chunks/circle-check-CJV-3Rem.js +0 -1
- package/dist/elements/chunks/hover-card-BQGdGAQ3.js +0 -1
- package/dist/elements/chunks/icon-CAyRqVrg.js +0 -1
- package/dist/elements/chunks/message-square-MmRkvc-M.js +0 -1
- package/dist/elements/chunks/reasoning-DzHWsdAJ.js +0 -1
- package/dist/elements/chunks/resizable-Bq_eHxUm.js +0 -1
- package/dist/elements/chunks/skeleton-Pjc5jiaY.js +0 -1
- package/dist/elements/chunks/textarea-CboigarR.js +0 -1
- package/dist/elements/chunks/x-Ckwicf6g.js +0 -1
- package/dist/register-impl-DcjZDELj.js +0 -141
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,S as i,a as c,d as u,s as g,
|
|
1
|
+
import{c as e,S as i,a as c,d as u,s as g,l as h,m as d,i as l,t as s,f as p,n as v}from"./chunks/define-DfTe4zwZ.js";import{c as o}from"./chunks/cn-CU7UAWzk.js";import{B as m}from"./chunks/button-BD7lUvVB.js";import{T as f}from"./chunks/tooltip-CBeFqJKk.js";import{S as k}from"./chunks/separator-CPvL5Xdl.js";var b=s("<div>"),w=s('<svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2><path d="M19 21l-7-5-7 5V5a2 2 0 012-2h10a2 2 0 012 2z">');function z(t){const[r,a]=g(t,["class","children"]);return(()=>{var n=b();return h(n,d({get class(){return o("flex items-center gap-0.5 overflow-hidden text-muted-foreground",r.class)}},a),!1,!0),l(n,()=>r.children,null),l(n,e(k,{}),null),n})()}function C(t){return e(i,{get when(){return!t.children},get fallback(){return t.children},get children(){var r=w();return c(()=>u(r,"class",o("size-4 shrink-0",t.class))),r}})}function x(t){const r=()=>t.variant??"ghost",a=()=>t.size??"sm",n=()=>e(m,{get variant(){return r()},get size(){return a()},type:"button",get"aria-label"(){return t["aria-label"]},get onClick(){return t.onClick},get class(){return t.class},get children(){return t.children}});return e(i,{get when(){return t.tooltip},get fallback(){return n()},get children(){return e(f,{get content(){return t.tooltip},get children(){return n()}})}})}var B=s("<span class=ml-1.5>");p("kai-checkpoint",{label:void 0,tooltip:void 0,variant:"ghost",size:"sm"},(t,{dispatch:r})=>e(z,{get children(){return e(x,{get tooltip(){return t.tooltip},get"aria-label"(){return v(()=>!!t.label)()?void 0:t.tooltip??"Checkpoint"},get variant(){return t.variant},get size(){return t.size},onClick:()=>r("kai-select"),get children(){return[e(C,{}),e(i,{get when(){return t.label},get children(){var a=B();return l(a,()=>t.label),a}})]}})}}));
|
package/dist/elements/choice.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as ve,s as me,r as fe,j as k,g as U,h as G,l as re,o as he,c as u,E as be,S as b,i as p,d as v,F as ye,a as w,b as L,u as te,t as f,y as ke,n as M,e as xe,f as we}from"./chunks/define-CNSKFZCd.js";import{c as O}from"./chunks/cn-CU7UAWzk.js";import{B as ne}from"./chunks/button-DBDZebGr.js";import{H as Ie}from"./chunks/hover-card-BQGdGAQ3.js";import{C as J}from"./chunks/card-YfCyI4fH.js";import{u as Ae,a as De,D as Ce}from"./chunks/use-card-resolution-M36zVciB.js";import{e as Re}from"./chunks/card-routing-C986KuUA.js";import{x as $e}from"./chunks/x-Ckwicf6g.js";import{c as Se}from"./chunks/check-fhmRksq_.js";var je=f('<p class="text-sm text-foreground">'),Ve=f("<div role=radiogroup>"),Ee=f('<div class="flex flex-col gap-2"><label class=sr-only></label><input type=text class="w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60">'),Te=f('<div class="flex w-full flex-wrap items-center justify-between gap-2">'),Le=f("<div>"),Me=f('<span class="inline-flex items-center rounded-full bg-[var(--color-primary)] px-1.5 py-0.5 text-[0.625rem] font-medium uppercase leading-none tracking-wide text-[var(--color-primary-foreground,white)]">Recommended'),Oe=f("<img>"),_e=f('<span aria-hidden=true class="flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-muted text-sm font-medium text-muted-foreground">'),ze=f('<img class="max-h-80 max-w-80 rounded-md object-contain">'),Fe=f('<span class="h-2 w-2 rounded-full bg-[var(--color-primary)]">'),qe=f('<span class="text-xs font-normal text-muted-foreground">'),Be=f('<span class="ml-auto shrink-0 text-xs font-normal text-muted-foreground">'),He=f('<div role=radio><span aria-hidden=true></span><span class="flex min-w-0 flex-col gap-0.5"><span class="flex items-center gap-2"><span class=truncate>'),Pe=f("<span>"),Ue=f('<span class="ml-auto text-xs font-normal text-muted-foreground">'),Ge=f('<div class="flex items-center gap-3 rounded-lg border border-input bg-accent px-3 py-2.5 text-sm font-medium text-accent-foreground">'),Je=f("<span>Other: ");const Ke="choice",D="__other__",K="Other\u2026";function Ne(r){if(!Array.isArray(r)||r.length===0)return{options:[],error:"This card couldn't be displayed."};const o=new Set,t=[];for(const s of r){if(!s||typeof s!="object")continue;const i=s;if(typeof i.id!="string"||i.id.length===0||typeof i.label!="string"||i.label.length===0)continue;if(o.has(i.id)){console.warn(`[kai-choice] duplicate option id "${i.id}" ignored`);continue}o.add(i.id);const l=i.media&&typeof i.media=="object"?{image:typeof i.media.image=="string"?i.media.image:void 0,imageAlt:typeof i.media.imageAlt=="string"?i.media.imageAlt:void 0,icon:typeof i.media.icon=="string"?i.media.icon:void 0}:void 0;t.push({id:i.id,label:i.label,description:typeof i.description=="string"?i.description:void 0,media:l,meta:typeof i.meta=="string"?i.meta:void 0,recommended:i.recommended===!0,disabled:i.disabled===!0,payload:i.payload})}return t.length===0?{options:[],error:"This card couldn't be displayed."}:{options:t}}function Qe(r){return r?r===!0?{label:K,placeholder:void 0}:typeof r=="object"?{label:typeof r.label=="string"&&r.label.length>0?r.label:K,placeholder:typeof r.placeholder=="string"?r.placeholder:void 0}:null:null}function oe(r,o,t){const s=r.length;if(s===0)return o;for(let i=1;i<=s;i+=1){const l=((o+t*i)%s+s)%s;if(!r[l].disabled)return l}return o}function ie(r){return r.findIndex(o=>!o.disabled)}function We(r){const o=ve({cardId:"kai-choice"},r),[t]=me(o,["data","cardId","heading","host","hostElement","class","resolution","value","defaultValue","disabled","onValueChange","controllerRef"]),s=Ae(),i=fe(),l=e=>{const n=t.host??s;n?n.emit(e):t.hostElement&&Re(t.hostElement,e)},a=k(()=>{var e;return Ne((e=t.data)==null?void 0:e.options)}),h=k(()=>a().error===void 0),I=k(()=>a().error??""),x=k(()=>a().options),V=k(()=>{var e;return Qe((e=t.data)==null?void 0:e.allowOther)}),C=k(()=>{const e=V();return e?[...x(),{id:D,label:e.label}]:x()}),m=De({prop:()=>t.resolution,data:()=>t.data}),_=k(()=>{const e=m.resolution();return e&&e.kind==="action"?e.action:void 0}),[q,R]=U(0),[ae,N]=U(r.defaultValue),T=k(()=>t.value??ae()),de=e=>{var n;T()!==e&&(N(e),(n=t.onValueChange)==null||n.call(t,e))},[B,Q]=U(""),A=()=>t.disabled===!0;let z,E;const W=k(()=>T()===D);G(re(()=>t.data,()=>{N(t.defaultValue),Q(""),R(Math.max(0,ie(C())))}));const le=k(()=>{var e;const n=m.resolution();return!n||n.kind!=="action"?void 0:n.action===D?{other:!0,text:((e=n.payload)==null?void 0:e.text)??""}:{other:!1,opt:x().find(c=>c.id===n.action),id:n.action}});G(re(h,e=>{l(e?{kind:"ready",cardId:t.cardId}:{kind:"error",cardId:t.cardId,message:I()})})),G(()=>{const e=t.hostElement;if(!e)return;const n=_();n!==void 0?e.setAttribute("data-kai-resolved",n):e.removeAttribute("data-kai-resolved")});const se=e=>e.id===D,H=e=>{m.isResolved()||A()||e.disabled||(de(e.id),se(e)&&queueMicrotask(()=>E?.focus()))},ue=k(()=>{if(m.isResolved()||A())return!1;const e=T();return e===void 0?!1:e===D?B().trim().length>0:!0}),ce=()=>{var e;return((e=t.data)==null?void 0:e.submitLabel)??"Submit"},P=()=>{if(m.isResolved()||A())return;const e=T();if(e===void 0)return;if(e===D){const c=B().trim();if(c.length===0)return;l({kind:"action",cardId:t.cardId,action:D,payload:{text:c}}),m.setLocal({kind:"action",action:D,payload:{text:c}});return}const n=x().find(c=>c.id===e);n&&(l({kind:"action",cardId:t.cardId,action:n.id,...n.payload!==void 0?{payload:n.payload}:{}}),m.setLocal({kind:"action",action:n.id,...n.payload!==void 0?{payload:n.payload}:{}}))},X=()=>{m.isResolved()||(l({kind:"dismiss",cardId:t.cardId}),m.setLocal({kind:"dismissed"}))},Y=()=>l({kind:"reopen",cardId:t.cardId}),F=(e,n)=>{var c;const d=z?.querySelectorAll('[role="radio"]');(c=d?.[e])==null||c.focus(n)};he(()=>{var e;(e=t.controllerRef)==null||e.call(t,{focus:n=>{W()&&E?E.focus(n):F(q(),n)},select:n=>{const c=C(),d=c.findIndex(y=>y.id===n);d!==-1&&(R(d),H(c[d]))},send:()=>P(),dismiss:()=>X(),reopen:()=>Y()})});const pe=e=>{if(m.isResolved()||A())return;const n=C(),c=q();if(e.key==="ArrowDown"||e.key==="ArrowRight"){e.preventDefault();const d=oe(n,c,1);R(d),F(d)}else if(e.key==="ArrowUp"||e.key==="ArrowLeft"){e.preventDefault();const d=oe(n,c,-1);R(d),F(d)}else if(e.key==="Home"){e.preventDefault();const d=Math.max(0,ie(n));R(d),F(d)}else if(e.key===" "||e.key==="Enter"){e.preventDefault();const d=n[c];d&&H(d)}},ge=()=>{var e;return t.heading??((e=t.data)==null?void 0:e.prompt)??"Choose an option"},Z=`kai-choice-prompt-${i}`,ee=`kai-choice-other-${i}`;return u(b,{get when(){return h()},get fallback(){return u(J,{get heading(){return t.heading},get errorMessage(){return I()}})},get children(){return u(be,{fallback:()=>(l({kind:"error",cardId:t.cardId,message:"The card failed to render."}),u(J,{get heading(){return t.heading},errorMessage:"The card failed to render."})),get children(){return u(b,{get when(){return!m.isDeferred()},get fallback(){return u(Ce,{type:Ke,get title(){return t.heading},onReopen:Y})},get children(){return u(J,{get heading(){return t.heading},get children(){var e=Le();return p(e,u(b,{get when(){var n;return(n=t.data)==null?void 0:n.prompt},get children(){var n=je();return v(n,"id",Z),p(n,()=>{var c;return(c=t.data)==null?void 0:c.prompt}),n}}),null),p(e,u(b,{get when(){return!m.isResolved()},get fallback(){return u(rr,{get choice(){return le()},get optimistic(){return m.isOptimistic()}})},get children(){return[(()=>{var n=Ve();n.$$keydown=pe;var c=z;return typeof c=="function"?te(c,n):z=n,p(n,u(ye,{get each(){return C()},children:(d,y)=>{const g=()=>T()===d.id,$=()=>!d.disabled&&!A()&&y()===q()&&!m.isResolved(),S=`kai-choice-desc-${i}-${d.id}`,j=()=>!!d.description;return u(er,{opt:d,get checked(){return g()},get tabStop(){return $()},descId:S,get hasDesc(){return j()},onPick:()=>{R(y()),H(d)},onFocus:()=>R(y())})}})),w(d=>{var y,g=ge(),$=(y=t.data)!=null&&y.prompt?Z:void 0,S=A()?"true":void 0,j=O("divide-y divide-border overflow-hidden rounded-lg border border-input",A()&&"cursor-not-allowed opacity-60");return g!==d.e&&v(n,"aria-label",d.e=g),$!==d.t&&v(n,"aria-describedby",d.t=$),S!==d.a&&v(n,"aria-disabled",d.a=S),j!==d.o&&L(n,d.o=j),d},{e:void 0,t:void 0,a:void 0,o:void 0}),n})(),u(b,{get when(){return W()},get children(){var n=Ee(),c=n.firstChild,d=c.nextSibling;v(c,"for",ee),p(c,()=>{var g;return((g=V())==null?void 0:g.label)??K}),d.$$keydown=g=>{g.key==="Enter"&&(g.preventDefault(),P())},d.$$input=g=>Q(g.currentTarget.value);var y=E;return typeof y=="function"?te(y,d):E=d,v(d,"id",ee),w(g=>{var $,S=A(),j=($=V())==null?void 0:$.placeholder;return S!==g.e&&(d.disabled=g.e=S),j!==g.t&&v(d,"placeholder",g.t=j),g},{e:void 0,t:void 0}),w(()=>d.value=B()),n}}),(()=>{var n=Te();return p(n,u(b,{get when(){var c;return((c=t.data)==null?void 0:c.dismissible)===!0},get children(){return u(ne,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Dismiss",onClick:X,get children(){return u($e,{size:16,"aria-hidden":"true"})}})}}),null),p(n,u(ne,{type:"button",class:"ml-auto",get disabled(){return!ue()},onClick:P,get children(){return ce()}}),null),n})()]}}),null),w(()=>L(e,O("flex flex-col gap-3",t.class))),e}})}})}})}})}function Xe(){return Me()}function Ye(r){return(()=>{var o=Oe();return w(t=>{var s=r.media.image,i=r.media.imageAlt??"",l=O("shrink-0 rounded-md object-cover",r.class);return s!==t.e&&v(o,"src",t.e=s),i!==t.t&&v(o,"alt",t.t=i),l!==t.a&&L(o,t.a=l),t},{e:void 0,t:void 0,a:void 0}),o})()}function Ze(r){return(()=>{var o=_e();return p(o,()=>r.name.slice(0,2)),o})()}function er(r){return(()=>{var o=He(),t=o.firstChild,s=t.nextSibling,i=s.firstChild,l=i.firstChild;return ke(o,"focus",r.onFocus),o.$$click=()=>!r.opt.disabled&&r.onPick(),p(o,u(b,{get when(){var a;return(a=r.opt.media)==null?void 0:a.image},get children(){return u(Ie,{openDelay:150,class:"p-1 w-auto",placement:"right-start",get trigger(){return u(Ye,{get media(){return r.opt.media},class:"h-9 w-9"})},get children(){var a=ze();return w(h=>{var I=r.opt.media.image,x=r.opt.media.imageAlt??"";return I!==h.e&&v(a,"src",h.e=I),x!==h.t&&v(a,"alt",h.t=x),h},{e:void 0,t:void 0}),a}})}}),t),p(o,u(b,{get when(){var a;return M(()=>{var h;return!((h=r.opt.media)!=null&&h.image)})()&&((a=r.opt.media)==null?void 0:a.icon)},get children(){return u(Ze,{get name(){return r.opt.media.icon}})}}),t),p(t,u(b,{get when(){return r.checked},get children(){return Fe()}})),p(l,()=>r.opt.label),p(i,u(b,{get when(){return r.opt.recommended},get children(){return u(Xe,{})}}),null),p(s,u(b,{get when(){return r.opt.description},get children(){var a=qe();return p(a,()=>r.opt.description),w(()=>v(a,"id",r.descId)),a}}),null),p(o,u(b,{get when(){return r.opt.meta},get children(){var a=Be();return p(a,()=>r.opt.meta),a}}),null),w(a=>{var h=r.checked,I=r.opt.disabled?"true":void 0,x=r.hasDesc?r.descId:void 0,V=r.opt.id,C=r.opt.disabled?-1:r.tabStop?0:-1,m=O("flex items-center gap-3 px-3 py-2.5 text-sm outline-none transition-colors focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",r.opt.disabled?"cursor-not-allowed opacity-60 text-foreground":"cursor-pointer hover:bg-muted/50",r.checked?"bg-accent font-medium text-accent-foreground":"text-foreground"),_=O("flex h-[1.125rem] w-[1.125rem] shrink-0 items-center justify-center rounded-full border-[1.5px] transition-colors",r.checked?"border-[var(--color-primary)]":"border-input bg-background");return h!==a.e&&v(o,"aria-checked",a.e=h),I!==a.t&&v(o,"aria-disabled",a.t=I),x!==a.a&&v(o,"aria-describedby",a.a=x),V!==a.o&&v(o,"data-option-id",a.o=V),C!==a.i&&v(o,"tabindex",a.i=C),m!==a.n&&L(o,a.n=m),_!==a.s&&L(t,a.s=_),a},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),o})()}function rr(r){const o=r.choice;return(()=>{var t=Ge();return p(t,u(Se,{size:16,"aria-hidden":"true"}),null),p(t,u(b,{get when(){return!o.other},get fallback(){return(()=>{var s=Je();return s.firstChild,p(s,(()=>{var i=M(()=>!!o.other);return()=>i()?o.text:""})(),null),s})()},get children(){return[(()=>{var s=Pe();return p(s,(()=>{var i=M(()=>!o.other);return()=>{var l;return i()?((l=o.opt)==null?void 0:l.label)??o.id:""}})()),s})(),u(b,{get when(){var s;return M(()=>!o.other)()&&((s=o.opt)==null?void 0:s.meta)},get children(){var s=Ue();return p(s,(()=>{var i=M(()=>!o.other);return()=>{var l;return i()?(l=o.opt)==null?void 0:l.meta:""}})()),s}})]}}),null),w(()=>v(t,"role",r.optimistic?"status":void 0)),t})()}xe(["keydown","input","click"]),we("kai-choice",{data:void 0,cardId:void 0,heading:void 0,resolution:void 0,value:void 0,defaultValue:void 0,disabled:void 0},(r,{element:o,dispatch:t,flag:s,expose:i})=>{let l;return i({focus:a=>l?.focus(a),select:a=>l?.select(a),send:()=>l?.send(),dismiss:()=>l?.dismiss(),reopen:()=>l?.reopen()}),u(We,{get data(){return r.data},get cardId(){return r.cardId??(o.id||"kai-choice")},get heading(){return r.heading},get resolution(){return r.resolution},get value(){return r.value},get defaultValue(){return r.defaultValue},get disabled(){return s("disabled")},onValueChange:a=>t("kai-value-change",{value:a}),controllerRef:a=>l=a,hostElement:o})});
|
|
1
|
+
import{m as ve,s as me,r as fe,j as k,g as U,h as G,o as re,k as he,c as u,E as be,S as b,i as p,d as v,F as ye,a as w,b as L,u as te,t as f,w as ke,n as M,e as xe,f as we}from"./chunks/define-DfTe4zwZ.js";import{c as O}from"./chunks/cn-CU7UAWzk.js";import{B as ne}from"./chunks/button-BD7lUvVB.js";import{H as Ie}from"./chunks/hover-card-Dn3yrk1l.js";import{C as J}from"./chunks/card-B-PRGXdj.js";import{u as Ae,a as De,D as Ce}from"./chunks/use-card-resolution-73xiddIW.js";import{e as Re}from"./chunks/card-routing-C986KuUA.js";import{x as $e}from"./chunks/x-DeS3rQhx.js";import{c as Se}from"./chunks/check-CUKS495w.js";var je=f('<p class="text-sm text-foreground">'),Ve=f("<div role=radiogroup>"),Ee=f('<div class="flex flex-col gap-2"><label class=sr-only></label><input type=text class="w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60">'),Te=f('<div class="flex w-full flex-wrap items-center justify-between gap-2">'),Le=f("<div>"),Me=f('<span class="inline-flex items-center rounded-full bg-[var(--color-primary)] px-1.5 py-0.5 text-[0.625rem] font-medium uppercase leading-none tracking-wide text-[var(--color-primary-foreground,white)]">Recommended'),Oe=f("<img>"),_e=f('<span aria-hidden=true class="flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-muted text-sm font-medium text-muted-foreground">'),ze=f('<img class="max-h-80 max-w-80 rounded-md object-contain">'),Fe=f('<span class="h-2 w-2 rounded-full bg-[var(--color-primary)]">'),qe=f('<span class="text-xs font-normal text-muted-foreground">'),Be=f('<span class="ml-auto shrink-0 text-xs font-normal text-muted-foreground">'),He=f('<div role=radio><span aria-hidden=true></span><span class="flex min-w-0 flex-col gap-0.5"><span class="flex items-center gap-2"><span class=truncate>'),Pe=f("<span>"),Ue=f('<span class="ml-auto text-xs font-normal text-muted-foreground">'),Ge=f('<div class="flex items-center gap-3 rounded-lg border border-input bg-accent px-3 py-2.5 text-sm font-medium text-accent-foreground">'),Je=f("<span>Other: ");const Ke="choice",D="__other__",K="Other\u2026";function Ne(r){if(!Array.isArray(r)||r.length===0)return{options:[],error:"This card couldn't be displayed."};const o=new Set,t=[];for(const s of r){if(!s||typeof s!="object")continue;const i=s;if(typeof i.id!="string"||i.id.length===0||typeof i.label!="string"||i.label.length===0)continue;if(o.has(i.id)){console.warn(`[kai-choice] duplicate option id "${i.id}" ignored`);continue}o.add(i.id);const l=i.media&&typeof i.media=="object"?{image:typeof i.media.image=="string"?i.media.image:void 0,imageAlt:typeof i.media.imageAlt=="string"?i.media.imageAlt:void 0,icon:typeof i.media.icon=="string"?i.media.icon:void 0}:void 0;t.push({id:i.id,label:i.label,description:typeof i.description=="string"?i.description:void 0,media:l,meta:typeof i.meta=="string"?i.meta:void 0,recommended:i.recommended===!0,disabled:i.disabled===!0,payload:i.payload})}return t.length===0?{options:[],error:"This card couldn't be displayed."}:{options:t}}function Qe(r){return r?r===!0?{label:K,placeholder:void 0}:typeof r=="object"?{label:typeof r.label=="string"&&r.label.length>0?r.label:K,placeholder:typeof r.placeholder=="string"?r.placeholder:void 0}:null:null}function oe(r,o,t){const s=r.length;if(s===0)return o;for(let i=1;i<=s;i+=1){const l=((o+t*i)%s+s)%s;if(!r[l].disabled)return l}return o}function ie(r){return r.findIndex(o=>!o.disabled)}function We(r){const o=ve({cardId:"kai-choice"},r),[t]=me(o,["data","cardId","heading","host","hostElement","class","resolution","value","defaultValue","disabled","onValueChange","controllerRef"]),s=Ae(),i=fe(),l=e=>{const n=t.host??s;n?n.emit(e):t.hostElement&&Re(t.hostElement,e)},a=k(()=>{var e;return Ne((e=t.data)==null?void 0:e.options)}),h=k(()=>a().error===void 0),I=k(()=>a().error??""),x=k(()=>a().options),V=k(()=>{var e;return Qe((e=t.data)==null?void 0:e.allowOther)}),C=k(()=>{const e=V();return e?[...x(),{id:D,label:e.label}]:x()}),m=De({prop:()=>t.resolution,data:()=>t.data}),_=k(()=>{const e=m.resolution();return e&&e.kind==="action"?e.action:void 0}),[q,R]=U(0),[ae,N]=U(r.defaultValue),T=k(()=>t.value??ae()),de=e=>{var n;T()!==e&&(N(e),(n=t.onValueChange)==null||n.call(t,e))},[B,Q]=U(""),A=()=>t.disabled===!0;let z,E;const W=k(()=>T()===D);G(re(()=>t.data,()=>{N(t.defaultValue),Q(""),R(Math.max(0,ie(C())))}));const le=k(()=>{var e;const n=m.resolution();return!n||n.kind!=="action"?void 0:n.action===D?{other:!0,text:((e=n.payload)==null?void 0:e.text)??""}:{other:!1,opt:x().find(c=>c.id===n.action),id:n.action}});G(re(h,e=>{l(e?{kind:"ready",cardId:t.cardId}:{kind:"error",cardId:t.cardId,message:I()})})),G(()=>{const e=t.hostElement;if(!e)return;const n=_();n!==void 0?e.setAttribute("data-kai-resolved",n):e.removeAttribute("data-kai-resolved")});const se=e=>e.id===D,H=e=>{m.isResolved()||A()||e.disabled||(de(e.id),se(e)&&queueMicrotask(()=>E?.focus()))},ue=k(()=>{if(m.isResolved()||A())return!1;const e=T();return e===void 0?!1:e===D?B().trim().length>0:!0}),ce=()=>{var e;return((e=t.data)==null?void 0:e.submitLabel)??"Submit"},P=()=>{if(m.isResolved()||A())return;const e=T();if(e===void 0)return;if(e===D){const c=B().trim();if(c.length===0)return;l({kind:"action",cardId:t.cardId,action:D,payload:{text:c}}),m.setLocal({kind:"action",action:D,payload:{text:c}});return}const n=x().find(c=>c.id===e);n&&(l({kind:"action",cardId:t.cardId,action:n.id,...n.payload!==void 0?{payload:n.payload}:{}}),m.setLocal({kind:"action",action:n.id,...n.payload!==void 0?{payload:n.payload}:{}}))},X=()=>{m.isResolved()||(l({kind:"dismiss",cardId:t.cardId}),m.setLocal({kind:"dismissed"}))},Y=()=>l({kind:"reopen",cardId:t.cardId}),F=(e,n)=>{var c;const d=z?.querySelectorAll('[role="radio"]');(c=d?.[e])==null||c.focus(n)};he(()=>{var e;(e=t.controllerRef)==null||e.call(t,{focus:n=>{W()&&E?E.focus(n):F(q(),n)},select:n=>{const c=C(),d=c.findIndex(y=>y.id===n);d!==-1&&(R(d),H(c[d]))},send:()=>P(),dismiss:()=>X(),reopen:()=>Y()})});const pe=e=>{if(m.isResolved()||A())return;const n=C(),c=q();if(e.key==="ArrowDown"||e.key==="ArrowRight"){e.preventDefault();const d=oe(n,c,1);R(d),F(d)}else if(e.key==="ArrowUp"||e.key==="ArrowLeft"){e.preventDefault();const d=oe(n,c,-1);R(d),F(d)}else if(e.key==="Home"){e.preventDefault();const d=Math.max(0,ie(n));R(d),F(d)}else if(e.key===" "||e.key==="Enter"){e.preventDefault();const d=n[c];d&&H(d)}},ge=()=>{var e;return t.heading??((e=t.data)==null?void 0:e.prompt)??"Choose an option"},Z=`kai-choice-prompt-${i}`,ee=`kai-choice-other-${i}`;return u(b,{get when(){return h()},get fallback(){return u(J,{get heading(){return t.heading},get errorMessage(){return I()}})},get children(){return u(be,{fallback:()=>(l({kind:"error",cardId:t.cardId,message:"The card failed to render."}),u(J,{get heading(){return t.heading},errorMessage:"The card failed to render."})),get children(){return u(b,{get when(){return!m.isDeferred()},get fallback(){return u(Ce,{type:Ke,get title(){return t.heading},onReopen:Y})},get children(){return u(J,{get heading(){return t.heading},get children(){var e=Le();return p(e,u(b,{get when(){var n;return(n=t.data)==null?void 0:n.prompt},get children(){var n=je();return v(n,"id",Z),p(n,()=>{var c;return(c=t.data)==null?void 0:c.prompt}),n}}),null),p(e,u(b,{get when(){return!m.isResolved()},get fallback(){return u(rr,{get choice(){return le()},get optimistic(){return m.isOptimistic()}})},get children(){return[(()=>{var n=Ve();n.$$keydown=pe;var c=z;return typeof c=="function"?te(c,n):z=n,p(n,u(ye,{get each(){return C()},children:(d,y)=>{const g=()=>T()===d.id,$=()=>!d.disabled&&!A()&&y()===q()&&!m.isResolved(),S=`kai-choice-desc-${i}-${d.id}`,j=()=>!!d.description;return u(er,{opt:d,get checked(){return g()},get tabStop(){return $()},descId:S,get hasDesc(){return j()},onPick:()=>{R(y()),H(d)},onFocus:()=>R(y())})}})),w(d=>{var y,g=ge(),$=(y=t.data)!=null&&y.prompt?Z:void 0,S=A()?"true":void 0,j=O("divide-y divide-border overflow-hidden rounded-lg border border-input",A()&&"cursor-not-allowed opacity-60");return g!==d.e&&v(n,"aria-label",d.e=g),$!==d.t&&v(n,"aria-describedby",d.t=$),S!==d.a&&v(n,"aria-disabled",d.a=S),j!==d.o&&L(n,d.o=j),d},{e:void 0,t:void 0,a:void 0,o:void 0}),n})(),u(b,{get when(){return W()},get children(){var n=Ee(),c=n.firstChild,d=c.nextSibling;v(c,"for",ee),p(c,()=>{var g;return((g=V())==null?void 0:g.label)??K}),d.$$keydown=g=>{g.key==="Enter"&&(g.preventDefault(),P())},d.$$input=g=>Q(g.currentTarget.value);var y=E;return typeof y=="function"?te(y,d):E=d,v(d,"id",ee),w(g=>{var $,S=A(),j=($=V())==null?void 0:$.placeholder;return S!==g.e&&(d.disabled=g.e=S),j!==g.t&&v(d,"placeholder",g.t=j),g},{e:void 0,t:void 0}),w(()=>d.value=B()),n}}),(()=>{var n=Te();return p(n,u(b,{get when(){var c;return((c=t.data)==null?void 0:c.dismissible)===!0},get children(){return u(ne,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Dismiss",onClick:X,get children(){return u($e,{size:16,"aria-hidden":"true"})}})}}),null),p(n,u(ne,{type:"button",class:"ml-auto",get disabled(){return!ue()},onClick:P,get children(){return ce()}}),null),n})()]}}),null),w(()=>L(e,O("flex flex-col gap-3",t.class))),e}})}})}})}})}function Xe(){return Me()}function Ye(r){return(()=>{var o=Oe();return w(t=>{var s=r.media.image,i=r.media.imageAlt??"",l=O("shrink-0 rounded-md object-cover",r.class);return s!==t.e&&v(o,"src",t.e=s),i!==t.t&&v(o,"alt",t.t=i),l!==t.a&&L(o,t.a=l),t},{e:void 0,t:void 0,a:void 0}),o})()}function Ze(r){return(()=>{var o=_e();return p(o,()=>r.name.slice(0,2)),o})()}function er(r){return(()=>{var o=He(),t=o.firstChild,s=t.nextSibling,i=s.firstChild,l=i.firstChild;return ke(o,"focus",r.onFocus),o.$$click=()=>!r.opt.disabled&&r.onPick(),p(o,u(b,{get when(){var a;return(a=r.opt.media)==null?void 0:a.image},get children(){return u(Ie,{openDelay:150,class:"p-1 w-auto",placement:"right-start",get trigger(){return u(Ye,{get media(){return r.opt.media},class:"h-9 w-9"})},get children(){var a=ze();return w(h=>{var I=r.opt.media.image,x=r.opt.media.imageAlt??"";return I!==h.e&&v(a,"src",h.e=I),x!==h.t&&v(a,"alt",h.t=x),h},{e:void 0,t:void 0}),a}})}}),t),p(o,u(b,{get when(){var a;return M(()=>{var h;return!((h=r.opt.media)!=null&&h.image)})()&&((a=r.opt.media)==null?void 0:a.icon)},get children(){return u(Ze,{get name(){return r.opt.media.icon}})}}),t),p(t,u(b,{get when(){return r.checked},get children(){return Fe()}})),p(l,()=>r.opt.label),p(i,u(b,{get when(){return r.opt.recommended},get children(){return u(Xe,{})}}),null),p(s,u(b,{get when(){return r.opt.description},get children(){var a=qe();return p(a,()=>r.opt.description),w(()=>v(a,"id",r.descId)),a}}),null),p(o,u(b,{get when(){return r.opt.meta},get children(){var a=Be();return p(a,()=>r.opt.meta),a}}),null),w(a=>{var h=r.checked,I=r.opt.disabled?"true":void 0,x=r.hasDesc?r.descId:void 0,V=r.opt.id,C=r.opt.disabled?-1:r.tabStop?0:-1,m=O("flex items-center gap-3 px-3 py-2.5 text-sm outline-none transition-colors focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",r.opt.disabled?"cursor-not-allowed opacity-60 text-foreground":"cursor-pointer hover:bg-muted/50",r.checked?"bg-accent font-medium text-accent-foreground":"text-foreground"),_=O("flex h-[1.125rem] w-[1.125rem] shrink-0 items-center justify-center rounded-full border-[1.5px] transition-colors",r.checked?"border-[var(--color-primary)]":"border-input bg-background");return h!==a.e&&v(o,"aria-checked",a.e=h),I!==a.t&&v(o,"aria-disabled",a.t=I),x!==a.a&&v(o,"aria-describedby",a.a=x),V!==a.o&&v(o,"data-option-id",a.o=V),C!==a.i&&v(o,"tabindex",a.i=C),m!==a.n&&L(o,a.n=m),_!==a.s&&L(t,a.s=_),a},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),o})()}function rr(r){const o=r.choice;return(()=>{var t=Ge();return p(t,u(Se,{size:16,"aria-hidden":"true"}),null),p(t,u(b,{get when(){return!o.other},get fallback(){return(()=>{var s=Je();return s.firstChild,p(s,(()=>{var i=M(()=>!!o.other);return()=>i()?o.text:""})(),null),s})()},get children(){return[(()=>{var s=Pe();return p(s,(()=>{var i=M(()=>!o.other);return()=>{var l;return i()?((l=o.opt)==null?void 0:l.label)??o.id:""}})()),s})(),u(b,{get when(){var s;return M(()=>!o.other)()&&((s=o.opt)==null?void 0:s.meta)},get children(){var s=Ue();return p(s,(()=>{var i=M(()=>!o.other);return()=>{var l;return i()?(l=o.opt)==null?void 0:l.meta:""}})()),s}})]}}),null),w(()=>v(t,"role",r.optimistic?"status":void 0)),t})()}xe(["keydown","input","click"]),we("kai-choice",{data:void 0,cardId:void 0,heading:void 0,resolution:void 0,value:void 0,defaultValue:void 0,disabled:void 0},(r,{element:o,dispatch:t,flag:s,expose:i})=>{let l;return i({focus:a=>l?.focus(a),select:a=>l?.select(a),send:()=>l?.send(),dismiss:()=>l?.dismiss(),reopen:()=>l?.reopen()}),u(We,{get data(){return r.data},get cardId(){return r.cardId??(o.id||"kai-choice")},get heading(){return r.heading},get resolution(){return r.resolution},get value(){return r.value},get defaultValue(){return r.defaultValue},get disabled(){return s("disabled")},onValueChange:a=>t("kai-value-change",{value:a}),controllerRef:a=>l=a,hostElement:o})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as d,
|
|
1
|
+
import{s as d,l as h,m as i,n as u,i as c,c as n,D as k,F as g,t as w}from"./define-DfTe4zwZ.js";var m={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"},t=m,v=w("<svg>"),p=r=>r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),b=(...r)=>r.filter((e,s,o)=>!!e&&o.indexOf(e)===s).join(" "),f=r=>{const[e,s]=d(r,["color","size","strokeWidth","children","class","name","iconNode","absoluteStrokeWidth"]);return(()=>{var o=v();return h(o,i(t,{get width(){return e.size??t.width},get height(){return e.size??t.height},get stroke(){return e.color??t.stroke},get"stroke-width"(){return u(()=>!!e.absoluteStrokeWidth)()?Number(e.strokeWidth??t["stroke-width"])*24/Number(e.size):Number(e.strokeWidth??t["stroke-width"])},get class(){return b("lucide","lucide-icon",e.name!=null?`lucide-${p(e?.name)}`:void 0,e.class!=null?e.class:"")}},s),!0,!0),c(o,n(g,{get each(){return e.iconNode},children:([l,a])=>n(k,i({component:l},a))})),o})()},z=f;export{z as I};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{I as a}from"./Icon-11SRdjJ4.js";import{c as o,m as r}from"./define-DfTe4zwZ.js";import{f as t,b as i,s,p,c as m}from"./share-BbziTAzn.js";import{c as k}from"./check-CUKS495w.js";import{d}from"./download-qJv1dS3M.js";import{e as y}from"./ellipsis-B1sOOqiJ.js";import{l as n}from"./link-B-RNYWNw.js";import{s as c}from"./star-BHL3Va5p.js";import{a as l,t as h}from"./thumbs-up-CdLqA13R.js";import{x as f}from"./x-DeS3rQhx.js";var v=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],M=e=>o(a,r(e,{name:"RefreshCw",iconNode:v})),u=M,x=[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]],g=e=>o(a,r(e,{name:"Reply",iconNode:x})),N=g,w=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],L=e=>o(a,r(e,{name:"Trash2",iconNode:w})),R=L,b=[["polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5",key:"16drj5"}],["path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07",key:"ltjumu"}],["path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14",key:"1kegas"}]],j=e=>o(a,r(e,{name:"Volume2",iconNode:b})),C=j;const H={copy:m,like:h,dislike:l,regenerate:u,edit:p,share:s,bookmark:i,download:d,link:n,trash:R,check:k,x:f,star:c,flag:t,reply:N,more:y,"volume-2":C};function V(e){if(e)return H[e]}const D={copy:"Copy",like:"Like",dislike:"Dislike",regenerate:"Regenerate",edit:"Edit"};export{D as B,V as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{I as o}from"./Icon-11SRdjJ4.js";import{c as m,m as r}from"./define-DfTe4zwZ.js";var e=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],t=a=>m(o,r(a,{name:"ArrowLeft",iconNode:e})),p=t;export{p as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as n,m,s as h,
|
|
1
|
+
import{c as n,m,s as h,l as p,i as u,S as w,n as j,t as g,y as C,z as I,a as z,d as y}from"./define-DfTe4zwZ.js";import{c as d}from"./cn-CU7UAWzk.js";import{B as D}from"./button-BD7lUvVB.js";import{a as M,b as P,c as N}from"./hover-card-Dn3yrk1l.js";import{x as S}from"./x-DeS3rQhx.js";import{f as B}from"./file-text-BwUs_Pj4.js";import{p as E,g as V,i as q}from"./paperclip-MA9hxLhW.js";import{I as F}from"./Icon-11SRdjJ4.js";import{v as G}from"./video-O9rA6k7S.js";var H=[["circle",{cx:"8",cy:"18",r:"4",key:"1fc0mg"}],["path",{d:"M12 18V2l7 4",key:"g04rme"}]],J=r=>n(F,m(r,{name:"Music2",iconNode:H})),K=J,b=g("<div>"),L=g('<img class="size-full object-cover"height=96 width=96>'),O=g('<img class="size-full rounded object-cover"height=20 width=20>'),Q=g('<video class="size-full object-cover"muted>'),U=g('<span class="text-muted-foreground text-caption block truncate">'),X=g('<div><span class="block truncate">'),Y=g("<span class=sr-only>");const _={audio:K,document:B,image:q,source:V,unknown:E,video:G},k=r=>{if(r.type==="source-document")return"source";const t=r.mediaType??"";return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.startsWith("application/")||t.startsWith("text/")?"document":"unknown"},T=r=>{if(r.type==="source-document")return r.title||r.filename||"Source";const t=k(r);return r.filename||(t==="image"?"Image":"Attachment")},W=C(),A=C(),$=()=>I(W)??{variant:"grid"},R=()=>{const r=I(A);if(!r)throw new Error("Attachment components must be used within <Attachment>");return r};function Z(r){const[t,s]=h(r,["variant","class","children"]),e=()=>t.variant??"grid";return n(W.Provider,{value:{get variant(){return e()}},get children(){var a=b();return p(a,m({get class(){return d("flex items-start",e()==="list"?"flex-col gap-2":"flex-wrap gap-2",e()==="grid"&&"w-fit",t.class)}},s),!1,!0),u(a,()=>t.children),a}})}function ee(r){const[t,s]=h(r,["data","onRemove","class","children"]),e=$(),a=()=>k(t.data);return n(A.Provider,{value:{get data(){return t.data},get mediaCategory(){return a()},get onRemove(){return t.onRemove},get variant(){return e.variant}},get children(){var o=b();return p(o,m({get class(){return d("group relative",e.variant==="grid"&&"size-24 overflow-hidden rounded-lg",e.variant==="inline"&&["flex h-8 cursor-pointer select-none items-center gap-1.5","rounded-md bg-surface-strong px-1.5 text-foreground","font-medium text-sm transition-all","hover:bg-muted"],e.variant==="list"&&["flex w-full items-center gap-3 rounded-lg bg-surface p-3 text-foreground","hover:bg-muted/50"],t.class)}},s),!1,!0),u(o,()=>t.children),o}})}function re(r){const[t,s]=h(r,["fallbackIcon","class"]),e=R(),a=()=>e.variant==="inline"?"size-3":"size-4",o=c=>n(c,{get class(){return d(a(),"text-muted-foreground")}}),x=()=>{if(e.mediaCategory==="image"&&e.data.type==="file"&&e.data.url)return e.variant==="grid"?(()=>{var l=L();return z(i=>{var v=e.data.filename||"Image",f=e.data.url;return v!==i.e&&y(l,"alt",i.e=v),f!==i.t&&y(l,"src",i.t=f),i},{e:void 0,t:void 0}),l})():(()=>{var l=O();return z(i=>{var v=e.data.filename||"Image",f=e.data.url;return v!==i.e&&y(l,"alt",i.e=v),f!==i.t&&y(l,"src",i.t=f),i},{e:void 0,t:void 0}),l})();if(e.mediaCategory==="video"&&e.data.type==="file"&&e.data.url)return(()=>{var l=Q();return z(()=>y(l,"src",e.data.url)),l})();const c=_[e.mediaCategory];return t.fallbackIcon??o(c)};return(()=>{var c=b();return p(c,m({get class(){return d("flex shrink-0 items-center justify-center overflow-hidden",e.variant==="grid"&&"size-full bg-muted",e.variant==="inline"&&"size-5 rounded bg-background",e.variant==="list"&&"size-12 rounded bg-muted",t.class)}},s),!1,!0),u(c,x),c})()}function te(r){const[t,s]=h(r,["showMediaType","class"]),e=R(),a=()=>T(e.data);return n(w,{get when(){return e.variant!=="grid"},get children(){var o=X(),x=o.firstChild;return p(o,m({get class(){return d("min-w-0 flex-1",t.class)}},s),!1,!0),u(x,a),u(o,n(w,{get when(){return j(()=>!!(t.showMediaType&&e.variant==="list"))()&&e.data.mediaType},get children(){var c=U();return u(c,()=>e.data.mediaType),c}}),null),o}})}function ae(r){const t=R(),s=e=>{var a;e.stopPropagation(),(a=t.onRemove)==null||a.call(t)};return n(w,{get when(){return t.onRemove},get children(){return n(D,{get"aria-label"(){return r.label??"Remove"},get class(){return d(t.variant==="grid"&&["absolute top-2 right-2 size-6 rounded-full p-0","bg-background/80 backdrop-blur-sm","opacity-0 transition-opacity group-hover:opacity-100","hover:bg-background","[&>svg]:size-3"],t.variant==="inline"&&["size-5 rounded p-0","opacity-0 transition-opacity group-hover:opacity-100","[&>svg]:size-2.5"],t.variant==="list"&&["size-8 shrink-0 rounded p-0","[&>svg]:size-4"],r.class)},onClick:s,type:"button",variant:"ghost",get children(){return[j(()=>r.children??n(S,{})),(()=>{var e=Y();return u(e,()=>r.label??"Remove"),e})()]}})}})}function ne(r){return n(M,{get openDelay(){return r.openDelay??0},get closeDelay(){return r.closeDelay??0},get children(){return r.children}})}function se(r){return n(P,{get class(){return r.class},get children(){return r.children}})}function ie(r){return n(N,{get class(){return d("w-auto p-2",r.class)},get children(){return r.children}})}function oe(r){const[t,s]=h(r,["class","children"]);return(()=>{var e=b();return p(e,m({get class(){return d("flex items-center justify-center p-4 text-muted-foreground text-sm",t.class)}},s),!1,!0),u(e,()=>t.children??"No attachments"),e})()}export{Z as A,ee as a,ne as b,se as c,re as d,te as e,ie as f,T as g,k as h,ae as i,oe as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as n,
|
|
1
|
+
import{s as n,l as i,m as s,i as o,t as u}from"./define-DfTe4zwZ.js";import{c as m}from"./index-BCRhi84a.js";import{c}from"./cn-CU7UAWzk.js";var d=u("<span>");const f=m("inline-flex items-center justify-center rounded-full text-xs font-medium min-h-5 min-w-5",{variants:{variant:{default:"bg-muted text-muted-foreground px-2 py-0.5",count:"bg-muted text-muted-foreground h-5 px-1.5",citation:"bg-primary text-primary-foreground px-1.5 py-0.5 cursor-pointer"}},defaultVariants:{variant:"default"}});function l(a){const[t,e]=n(a,["variant","class","children"]);return(()=>{var r=d();return i(r,s({get class(){return c(f({variant:t.variant}),t.class)}},e),!1,!0),o(r,()=>t.children),r})()}export{l as B};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s,
|
|
1
|
+
import{s,l as n,m as o,i as a,t as u}from"./define-DfTe4zwZ.js";import{c as d}from"./index-BCRhi84a.js";import{c as l}from"./cn-CU7UAWzk.js";var c=u("<button>");const f=d("inline-flex items-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",ghost:"hover:bg-muted text-foreground",subtle:"text-muted-foreground hover:bg-accent hover:text-foreground",outline:"bg-muted/50 text-foreground hover:bg-muted",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90"},size:{sm:"h-8 px-3 text-xs rounded-md",md:"h-9 px-4 text-sm",lg:"h-10 px-6 text-sm",icon:"h-9 w-9","icon-sm":"h-7 w-7"},align:{start:"justify-start",center:"justify-center",end:"justify-end"}},defaultVariants:{variant:"default",size:"md",align:"center"}});function g(r){const[e,i]=s(r,["variant","size","align","full","class","children"]);return(()=>{var t=c();return n(t,o({get class(){return l(f({variant:e.variant,size:e.size,align:e.align}),e.full&&"w-full",e.class)}},i),!1,!0),a(t,()=>e.children),t})()}export{g as B};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as u,s as I,r as S,g as j,c as n,i,S as a,a as h,d as E,b as K,D as P,n as l,t as s,e as _}from"./define-
|
|
1
|
+
import{m as u,s as I,r as S,g as j,c as n,i,S as a,a as h,d as E,b as K,D as P,n as l,t as s,e as _}from"./define-DfTe4zwZ.js";import{c as v}from"./cn-CU7UAWzk.js";import{t as q}from"./triangle-alert-BllqxXq8.js";import{x as A}from"./x-DeS3rQhx.js";var B=s('<h3 class="text-[1.0625rem] font-semibold leading-snug tracking-tight text-foreground">'),F=s('<p class="text-[0.8125rem] leading-relaxed text-muted-foreground">'),H=s("<div>"),L=s('<div role=alert class="flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive dark:bg-destructive/15 dark:text-red-400"><span>'),N=s('<div class="text-sm text-foreground">'),O=s('<div class="flex flex-wrap items-center justify-end gap-2 pt-1">'),R=s('<button type=button part=dismiss aria-label=Dismiss class="absolute right-2.5 top-2.5 z-10 shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground">'),U=s('<div class="overflow-hidden rounded-lg">');function V(p){const b=u({dense:!1},p),[r,f]=I(b,["heading","description","media","actions","errorMessage","dense","headingId","dismissible","onDismiss","href","target","rel","clickable","onCardClick","class","children"]),m=S(),x=()=>r.headingId??`kai-card-heading-${m}`,k=()=>r.errorMessage!==void 0&&r.errorMessage!=="",w=()=>!!r.heading||!!r.description,[C,y]=j(!0),D=e=>{var t;e.stopPropagation(),y(!1),(t=r.onDismiss)==null||t.call(r)},d=()=>!!r.href,o=()=>!d()&&!!r.clickable,g=()=>d()||o(),c=e=>{var t;return(t=r.onCardClick)==null?void 0:t.call(r,e)},M=e=>{o()&&(e.key==="Enter"||e.key===" "||e.key==="Spacebar")&&(e.preventDefault(),c(e))},z=()=>r.rel??(r.target==="_blank"?"noopener noreferrer":void 0),$=[n(a,{get when(){return w()},get children(){var e=H();return i(e,n(a,{get when(){return r.heading},get children(){var t=B();return i(t,()=>r.heading),h(()=>E(t,"id",x())),t}}),null),i(e,n(a,{get when(){return r.description},get children(){var t=F();return i(t,()=>r.description),t}}),null),h(()=>K(e,v("flex flex-col border-b border-border",r.dense?"gap-0.5 pb-2.5":"gap-1 pb-4"))),e}}),n(a,{get when(){return k()},get fallback(){return[n(a,{get when(){return r.children},get children(){var e=N();return i(e,()=>r.children),e}}),n(a,{get when(){return r.actions},get children(){var e=O();return i(e,()=>r.actions),e}})]},get children(){var e=L(),t=e.firstChild;return i(e,n(q,{size:16,class:"mt-0.5 shrink-0","aria-hidden":"true"}),t),i(t,()=>r.errorMessage),e}})];return n(a,{get when(){return C()},get children(){return n(P,u({get component(){return d()?"a":"div"},part:"card",get href(){return l(()=>!!d())()?r.href:void 0},get target(){return l(()=>!!d())()?r.target:void 0},get rel(){return l(()=>!!d())()?z():void 0},get role(){return o()?"button":void 0},get tabindex(){return o()?0:void 0},get onClick(){return g()?c:void 0},get onKeyDown(){return o()?M:void 0},get class(){return v("relative flex flex-col rounded-xl border border-border bg-card text-card-foreground kai-elevation-sm",r.dense?"gap-2.5 p-3.5":"gap-4 p-5",g()&&"cursor-pointer no-underline transition-colors hover:border-ring hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",r.class)}},f,{get children(){return[n(a,{get when(){return r.dismissible},get children(){var e=R();return e.$$click=D,i(e,n(A,{class:"size-3.5","aria-hidden":"true"})),e}}),n(a,{get when(){return r.media},get children(){var e=U();return i(e,()=>r.media),e}}),$]}}))}})}_(["click"]);export{V as C};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{v as z,g as M,h as D,k as E,c as r,u as U,i as s,S as i,q as h,n as G,F as J,a as _,b as A,C as K,t as u}from"./define-DfTe4zwZ.js";import{s as L,n as N}from"./composer-CavJww3d.js";import{C as O,a as P,b as Q,S as W}from"./scroll-button-B1x4cYqM.js";import{M as X,a as V,b as Y}from"./message-CPfqj8Gi.js";import{c as Z}from"./message-feedback-8uj0aVYh.js";import{M as ee}from"./model-switcher-DRrMcRXH.js";import{C as te,a as re,b as ne,c as le,d as ae,e as se,f as oe,g as ie}from"./context-CnlsNJSJ.js";import{D as ue}from"./default-input-CB46cJJ1.js";var ce=u('<aside part=sidebar class="flex w-64 shrink-0 flex-col overflow-hidden border-r border-border"><slot name=sidebar>'),de=u("<header part=header class=shrink-0><slot name=header>"),ge=u("<slot name=empty>"),he=u('<div class="absolute bottom-4 left-1/2 flex w-full max-w-3xl -translate-x-1/2 justify-center px-5">'),me=u('<div class="shrink-0 px-4"><div class="mx-auto flex max-w-3xl items-center gap-2 pb-2"><slot name=composer-actions>'),ve=u("<slot name=composer>"),fe=u('<div part=footer class="shrink-0 px-4 pb-3"><div class="mx-auto max-w-3xl text-center text-xs text-muted-foreground"><slot name=footer>'),xe=u('<div><div class="flex h-full min-w-0 flex-1 flex-col"><div class="relative flex-1 overflow-hidden"></div><div class="shrink-0 px-4 pb-4"><div class="mx-auto max-w-3xl">'),pe=u('<div class="text-sm font-semibold text-foreground">'),be=u("<div class=space-y-1.5>"),we=u('<header part=header-bar class="flex h-14 shrink-0 items-center justify-between border-b border-border px-5"><div class="flex items-center gap-2"><slot name=header-start></slot></div><div class="flex items-center gap-2"><slot name=header-end>'),Ce=u("<div>");function ke(e){const F=z(),w=()=>e.actionsReveal==="hover"?"hover":"always";let v;const x=Z({emit:n=>{var l;return(l=e.onMessageAction)==null?void 0:l.call(e,n)},target:()=>v}),[q,f]=M(e.value??""),[p,b]=M([]),C=()=>typeof e.value=="string"?e.value:q();D(()=>{const n=e.value;n!=null&&typeof n!="string"&&f(n)});const k=n=>{var l;f(n),(l=e.onValueChange)==null||l.call(e,n)},S=()=>{b([]),e.value===void 0&&f("")},T=()=>{var n;(n=e.onSubmit)==null||n.call(e,{value:L(N(C())),attachments:p()}),S()},B=n=>{var l,o;(e.suggestionMode??"submit")==="fill"?(k(n),(l=e.onSuggestionClick)==null||l.call(e,n)):((o=e.onSubmit)==null||o.call(e,{value:n,attachments:p()}),S())},H=()=>!!(e.chatTitle||e.models||e.context||e.headerStart||e.headerEnd),I=()=>e.persistSuggestions||e.messages.length===0?e.suggestions:void 0,R=()=>e.scrollButton!==!1;return E(()=>{var n;(n=e.controllerRef)==null||n.call(e,{focus:l=>{var o;return(o=v?.querySelector('[contenteditable]:not([contenteditable="false"]), textarea'))==null?void 0:o.focus(l)},clear:()=>{var l;f(""),b([]),(l=e.onValueChange)==null||l.call(e,"")},send:()=>T(),scrollToBottom:l=>{const o=v?.querySelector(".overflow-y-auto");o?.scrollTo({top:o.scrollHeight,behavior:l??"smooth"})}})}),r(K,{get proseSize(){return e.proseSize},get codeTheme(){return e.codeTheme},get codeHighlight(){return e.codeHighlight!==!1},get portalMount(){return F.portalMount()},get children(){var n=xe(),l=n.firstChild,o=l.firstChild,y=o.nextSibling,j=y.firstChild;return U(t=>v=t,n),s(n,r(i,{get when(){return e.sidebar},get children(){var t=ce(),a=t.firstChild;return a._$owner=h(),t}}),l),s(l,r(i,{get when(){return e.headerFull},get fallback(){return r(i,{get when(){return H()},get children(){var t=we(),a=t.firstChild,g=a.firstChild,d=a.nextSibling,m=d.firstChild;return g._$owner=h(),s(a,r(i,{get when(){return e.chatTitle},get children(){var c=pe();return s(c,()=>e.chatTitle),c}}),null),s(d,r(i,{get when(){return e.models},get children(){return r(ee,{get models(){return e.models},get currentModelId(){var c;return e.currentModel??((c=e.models[0])==null?void 0:c.id)??""},onModelChange:c=>{var $;return($=e.onModelChange)==null?void 0:$.call(e,c)}})}}),m),s(d,r(i,{get when(){return e.context},get children(){return r(te,{get usedTokens(){return e.context.usedTokens},get maxTokens(){return e.context.maxTokens},get inputTokens(){return e.context.inputTokens},get outputTokens(){return e.context.outputTokens},get estimatedCost(){return e.context.estimatedCost},get children(){return[r(re,{}),r(ne,{get children(){return[r(le,{}),r(ae,{get children(){var c=be();return s(c,r(se,{}),null),s(c,r(oe,{}),null),c}}),r(ie,{})]}})]}})}}),m),m._$owner=h(),t}})},get children(){var t=de(),a=t.firstChild;return a._$owner=h(),t}}),o),s(o,r(O,{class:"h-full px-4 py-3",get children(){return[r(P,{class:"mx-auto w-full max-w-3xl space-y-4",get children(){return[r(i,{get when(){return G(()=>!!e.empty)()&&e.messages.length===0},get children(){var t=ge();return t._$owner=h(),t}}),r(J,{get each(){return e.messages},children:t=>{const a=r(X,{get content(){return t.content},get reasoning(){return t.reasoning},get tools(){return t.tools},get attachments(){return t.attachments},get isUser(){return t.role==="user"},get markdown(){return t.role==="assistant"},get actions(){return t.actions},get actionsReveal(){return w()},get activeFeedback(){return x.resolveFeedback(t)},get copied(){return x.isCopied(t.id)},onAction:d=>x.handleAction(t,d)}),g=w()==="hover"?"group ":"";return r(i,{get when(){return t.avatar},get fallback(){return r(V,{get class(){return`${g}${t.role==="user"?"flex-col items-end":"flex-col items-start"}`},children:a})},children:d=>r(V,{class:g,get children(){return[r(Y,{get src(){return d().src??""},get alt(){return d().alt??""},get fallback(){return d().fallback}}),(()=>{var m=Ce();return s(m,a),_(()=>A(m,`flex min-w-0 flex-1 flex-col ${t.role==="user"?"items-end":"items-start"}`)),m})()]}})})}}),r(Q,{})]}}),r(i,{get when(){return R()},get children(){var t=he();return s(t,r(W,{class:"shadow-sm"})),t}})]}})),s(l,r(i,{get when(){return e.composerActions},get children(){var t=me(),a=t.firstChild,g=a.firstChild;return g._$owner=h(),t}}),y),s(j,r(i,{get when(){return e.composer},get fallback(){return r(ue,{get value(){return C()},get placeholder(){return e.placeholder},get loading(){return e.loading===!0},get suggestions(){return I()},get attachments(){return p()},get search(){return e.search===!0},get voice(){return e.voice===!0},get triggers(){return e.triggers},get kindIcons(){return e.kindIcons},onValueChange:k,onSubmit:T,onSuggestionClick:B,onAttachmentsChange:t=>{var a;b(t),(a=e.onAttachmentsChange)==null||a.call(e,t)},onSearch:()=>{var t;return(t=e.onSearch)==null?void 0:t.call(e)},onVoice:()=>{var t;return(t=e.onVoice)==null?void 0:t.call(e)}})},get children(){var t=ve();return t._$owner=h(),t}})),s(l,r(i,{get when(){return e.footer},get children(){var t=fe(),a=t.firstChild,g=a.firstChild;return g._$owner=h(),t}}),null),_(()=>A(n,`flex h-full bg-background ${e.class??""}`)),n}})}export{ke as C};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{I as m}from"./Icon-11SRdjJ4.js";import{c as o,m as r}from"./define-DfTe4zwZ.js";var c=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],e=a=>o(m,r(a,{name:"Check",iconNode:c})),f=e;export{f as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{I as r}from"./Icon-11SRdjJ4.js";import{c as a,m}from"./define-DfTe4zwZ.js";var e=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],n=o=>a(r,m(o,{name:"ChevronDown",iconNode:e})),p=n;export{p as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{I as o}from"./Icon-11SRdjJ4.js";import{c as a,m as r}from"./define-DfTe4zwZ.js";var t=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],e=m=>a(o,r(m,{name:"ChevronRight",iconNode:t})),h=e;export{h as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{I as c}from"./Icon-11SRdjJ4.js";import{c as m,m as o}from"./define-DfTe4zwZ.js";var a=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],e=r=>m(c,o(r,{name:"Circle",iconNode:a})),i=e;export{i as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{I as c}from"./Icon-11SRdjJ4.js";import{c as r,m as a}from"./define-DfTe4zwZ.js";var e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],o=m=>r(c,a(m,{name:"CircleCheck",iconNode:e})),i=o;export{i as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as a}from"./Icon-
|
|
1
|
+
import{I as a}from"./Icon-11SRdjJ4.js";import{c as m,m as c}from"./define-DfTe4zwZ.js";var e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],o=r=>m(a,c(r,{name:"CircleX",iconNode:e})),i=o;export{i as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as m,
|
|
1
|
+
import{s as m,l as c,m as o,i as g,v as C,H as T,c as L,S as z,t as l}from"./define-DfTe4zwZ.js";import{c as h}from"./cn-CU7UAWzk.js";const E={bash:()=>import("./bash-InADTalH.js"),javascript:()=>import("./javascript-C25yR2R2.js"),typescript:()=>import("./typescript-RycA9KXf.js"),tsx:()=>import("./tsx-B8rCNbgL.js"),html:()=>import("./html-CPZ3oZQ7.js"),css:()=>import("./css-M7EaDHN_.js"),json:()=>import("./json-DxJze_jm.js"),vue:()=>import("./vue-BmIZj4XD.js"),svelte:()=>import("./svelte--5p79yCD.js")},M={"github-dark-dimmed":()=>import("./github-dark-dimmed-DUshB20C.js"),"github-light":()=>import("./github-light-JYsPkUQd.js")},P={js:"javascript",ts:"typescript",jsx:"tsx",sh:"bash",shell:"bash"},f="github-dark-dimmed";let R={...E},$={...M},A={...P},u=null;const x=new Set,v=new Set;function B(){return u||(u=(async()=>{const[{createHighlighterCore:t},{createJavaScriptRegexEngine:e}]=await Promise.all([import("./core-AYMC6_lb.js"),import("./engine-javascript-vq0WuIJl.js")]);return t({themes:[],langs:[],engine:e()})})()),u}function b(t){return A[t]??t}async function D(t,e){const a=b(e);if(x.has(a))return!0;const r=R[a];return r?(await t.loadLanguage(r()),x.add(a),!0):!1}async function w(t,e){if(v.has(e))return!0;const a=$[e];return a?(await t.loadTheme(a()),v.add(e),!0):!1}function F(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function i(t){return`<pre><code>${F(t)}</code></pre>`}async function G(t,e,a){if(!t)return i(t);try{const r=await B();if(!await D(r,e))return i(t);const s=await w(r,a)?a:await w(r,f)?f:null;return s?r.codeToHtml(t,{lang:b(e),theme:s}):i(t)}catch{return i(t)}}var J=l("<div>"),K=l("<div tabindex=0>"),N=l("<div tabindex=0><pre><code>");function O(t){const[e,a]=m(t,["children","class"]);return(()=>{var r=J();return c(r,o({get class(){return h("not-prose flex w-full flex-col overflow-clip border","border-border bg-card text-card-foreground","rounded-[var(--kai-code-radius,0.75rem)]",e.class)}},a),!1,!0),g(r,()=>e.children),r})()}function U(t){const[e,a]=m(t,["code","language","theme","class"]),r=C(),s=()=>e.language??"tsx",y=()=>e.theme??r.codeTheme(),j=()=>r.codeHighlight(),[d]=T(()=>j()?{code:e.code,lang:s(),theme:y()}:null,n=>G(n.code,n.lang,n.theme)),H=()=>{switch(r.proseSize()){case"xs":return"text-[11px]";case"sm":return"text-[13px]";case"base":return"text-sm";case"lg":return"text-base"}},p=()=>h("w-full overflow-x-auto [&>pre]:px-4 [&>pre]:py-4",H(),e.class);return L(z,{get when(){return d()},get fallback(){return(()=>{var n=N(),S=n.firstChild,k=S.firstChild;return c(n,o({get class(){return p()}},a),!1,!0),g(k,()=>e.code),n})()},get children(){var n=K();return c(n,o({get class(){return p()},get innerHTML(){return d()}},a),!1,!1),n}})}export{O as C,U as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as c,g as
|
|
1
|
+
import{s as c,g as k,r as y,c as I,l as p,m as u,i as v,n as h,a as R,N as E,b as N,t as g,y as P,z as q}from"./define-DfTe4zwZ.js";import{c as C}from"./cn-CU7UAWzk.js";var z=g("<div>"),B=g("<button>"),S=g("<div><div>");const m=P(),w=()=>{const o=q(m);if(!o)throw new Error("Collapsible parts must be used within <Collapsible>");return o};function T(o){var n;const[e,l]=c(o,["open","defaultOpen","onOpenChange","disabled","controllerRef","children","class"]),[t,a]=k(e.defaultOpen??!1),s=()=>e.open!==void 0,r=()=>s()?!!e.open:t(),i=()=>!!e.disabled,f=d=>{var b;r()!==d&&(s()||a(d),(b=e.onOpenChange)==null||b.call(e,d))},x=()=>{i()||f(!r())};(n=e.controllerRef)==null||n.call(e,{open:r,setOpen:f});const O=y();return I(m.Provider,{value:{open:r,toggle:x,contentId:O,disabled:i},get children(){var d=z();return p(d,u({get class(){return e.class}},l,{get"data-expanded"(){return r()?"":void 0},get"data-closed"(){return r()?void 0:""},get"data-state"(){return r()?"open":"closed"}}),!1,!0),v(d,()=>e.children),d}})}function U(o){const n=w(),[e,l]=c(o,["children","class","as","onClick"]),t=()=>({type:"button","aria-expanded":n.open(),"aria-controls":n.contentId,disabled:n.disabled()||void 0,"data-expanded":n.open()?"":void 0,"data-closed":n.open()?void 0:"","data-state":n.open()?"open":"closed",onClick:a=>{n.disabled()||(typeof e.onClick=="function"&&e.onClick(a),n.toggle())},class:e.class,...l});return h(()=>h(()=>!!e.as)()?e.as(t()):(()=>{var a=B();return p(a,u(t),!1,!0),v(a,()=>e.children),a})())}function _(o){const n=w(),[e,l]=c(o,["children","class"]);return(()=>{var t=S(),a=t.firstChild;return p(t,u(l,{get id(){return n.contentId},get"data-expanded"(){return n.open()?"":void 0},get"data-closed"(){return n.open()?void 0:""},get class(){return C("grid transition-[grid-template-rows] duration-200 ease-out",n.open()?"grid-rows-[1fr]":"grid-rows-[0fr]")}}),!1,!0),v(a,()=>e.children),R(s=>{var r=!n.open(),i=C("overflow-hidden",e.class);return r!==s.e&&E(t,"inert",s.e=r),i!==s.t&&N(a,s.t=i),s},{e:void 0,t:void 0}),t})()}export{T as C,U as a,_ as b};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{g as _,r as Ye,j as J,h as de,
|
|
2
|
-
`})}else i.nodeType===3&&n.push({type:"text",text:(i.textContent??"").split(C).join("")})}),
|
|
1
|
+
import{g as _,r as Ye,j as J,h as de,k as ue,o as Ae,p as Je,i as A,u as De,a as K,d as D,b as V,x as Z,c as O,F as Le,S as P,t as S,e as Ve}from"./define-DfTe4zwZ.js";import{c as Q}from"./cn-CU7UAWzk.js";import{u as Ze,c as Qe,a as et}from"./overlay-C8_FUL8q.js";function B(t){if(t==null)return[];if(typeof t=="string")return t.length?[{type:"text",text:t}]:[];const n=[];for(const l of t)if(l.type==="text"){if(!l.text)continue;const i=n[n.length-1];i&&i.type==="text"?n[n.length-1]={type:"text",text:i.text+l.text}:n.push({type:"text",text:l.text})}else n.push({type:"entity",entity:l.entity});return n}function ee(t,n){let l="";for(const i of t)i.type==="text"?l+=i.text:l+=i.entity.promptText??i.entity.label;return l}function pe(t){return t.filter(n=>n.type==="entity").map(n=>n.entity)}function te(t){return t.every(n=>n.type==="text"&&n.text.length===0)}const C="\u200B",fe="data-kai-entity",he=new WeakMap;function z(t){return!!t&&t.nodeType===1&&t.hasAttribute(fe)}function ne(t){return t.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(n){let l=n.parentElement;for(;l&&l!==t;){if(l.hasAttribute(fe))return NodeFilter.FILTER_REJECT;l=l.parentElement}return NodeFilter.FILTER_ACCEPT}})}function tt(t){switch(t){case"skill":return"/";case"agent":return"@";default:return""}}function $e(t){const n=l=>`<svg viewBox="0 0 24 24" width="1em" height="1em" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${l}</svg>`;switch(t){case"agent":return n('<rect x="4" y="8" width="16" height="12" rx="3"/><path d="M12 4.5V8M9.5 13.5v1.5M14.5 13.5v1.5"/><circle cx="12" cy="3" r="1.2"/>');case"plugin":return n('<path d="M9 2v4M15 2v4M6 6h12v5a6 6 0 0 1-12 0zM12 17v5"/>');default:return""}}function Ie(t,n,l){const i=t.createElement("span");i.setAttribute(fe,""),i.setAttribute("contenteditable","false"),i.dataset.kind=n.kind,i.dataset.id=n.id,i.className="kai-composer-pill";const u=tt(n.kind);if(u){const s=t.createElement("span");s.className="kai-composer-pill-sigil",s.setAttribute("aria-hidden","true"),s.textContent=u,i.appendChild(s)}else{const s=n.icon??l?.[n.kind];if(s){const p=t.createElement("img");p.src=s,p.alt="",p.className="kai-composer-pill-icon",i.appendChild(p)}else{const p=$e(n.kind);if(p){const f=t.createElement("span");f.className="kai-composer-pill-icon kai-composer-pill-glyph",f.setAttribute("aria-hidden","true"),f.innerHTML=p,i.appendChild(f)}}}return i.appendChild(t.createTextNode(n.label)),he.set(i,n),i}function L(t){const n=[],l=t.childNodes;return l.forEach((i,u)=>{if(z(i)){const s=he.get(i),p=i;n.push({type:"entity",entity:s??{kind:p.dataset.kind??"",id:p.dataset.id??"",label:p.textContent??""}})}else if(i.nodeType===1&&i.tagName==="BR"){if(u===l.length-1)return;n.push({type:"text",text:`
|
|
2
|
+
`})}else i.nodeType===3&&n.push({type:"text",text:(i.textContent??"").split(C).join("")})}),B(n)}function re(t,n,l=document,i){t.textContent="";for(const u of n)u.type==="text"?t.appendChild(l.createTextNode(u.text)):(t.appendChild(Ie(l,u.entity,i)),t.appendChild(l.createTextNode(C)))}function nt(t,n,l){if(n<0||n>t.length)return null;for(let i=n-1;i>=0;i--){const u=t[i];if(/\s/.test(u))return null;if(l.includes(u))return i===0||/\s/.test(t[i-1])?{char:u,query:t.slice(i+1,n),start:i}:null}return null}function rt(t,n,l){if(!l.length)return null;const i=l.map(p=>p.char),u=nt(t,n,i);if(!u)return null;const s=l.find(p=>p.char===u.char);return s?{def:s,query:u.query,start:u.start}:null}function ot(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function it(t,n){const l=[];for(const s of n){let p,f;typeof s=="string"?(p=new RegExp(ot(s),"gi"),f=void 0):(p=new RegExp(s.pattern,s.flags??"gi"),f=s.class),p.lastIndex=0;let v;for(;(v=p.exec(t))!==null;){const x=v.index,h=x+v[0].length;if(h===x){p.lastIndex=x+1;continue}l.push({start:x,end:h,class:f})}}l.sort((s,p)=>s.start-p.start);const i=[];let u=-1;for(const s of l)s.start>=u&&(i.push(s),u=s.end);return i}function lt(){try{return typeof CSS<"u"&&typeof CSS.highlights<"u"&&typeof Highlight<"u"}catch{return!1}}const at="kai-composer-highlight";function st(t,n,l,i=at){if(!lt())return;const u=CSS.highlights;if(n.length===0){u.delete(i);return}const s=[];let p=0;const f=t.ownerDocument,v=ne(t);let x=v.nextNode();for(;x;){const w=x.textContent??"",g=[];for(let y=0;y<w.length;y++)w[y]!==l&&g.push(y);if(g.length>0){const y=new Int32Array(g.length);for(let m=0;m<g.length;m++)y[m]=g[m];s.push({node:x,strippedStart:p,strippedToRaw:y}),p+=g.length}x=v.nextNode()}function h(w){let g=0,y=s.length-1;for(;g<=y;){const m=g+y>>1,R=s[m],T=R.strippedStart+R.strippedToRaw.length;if(w<R.strippedStart)y=m-1;else if(w>=T)g=m+1;else{const oe=w-R.strippedStart;return{node:R.node,rawOffset:R.strippedToRaw[oe]}}}if(s.length>0){const m=s[s.length-1];if(w-m.strippedStart===m.strippedToRaw.length)return{node:m.node,rawOffset:m.strippedToRaw[m.strippedToRaw.length-1]+1}}return null}const b=[];for(const w of n){const g=h(w.start),y=h(w.end);if(!g||!y)continue;const m=f.createRange();m.setStart(g.node,g.rawOffset),m.setEnd(y.node,y.rawOffset),b.push(m)}if(b.length===0){u.delete(i);return}const $=new Highlight(...b);u.set(i,$)}function ct(t,n=200){let l=[t],i=0;return{record(u,s){if(s&&i===l.length-1){l[i]=u;return}l=l.slice(0,i+1),l.push(u),l.length>n?l.shift():i++},undo(){return i===0?null:(i--,l[i])},redo(){return i>=l.length-1?null:(i++,l[i])},reset(u){l=[u],i=0},canUndo(){return i>0},canRedo(){return i<l.length-1},size(){return l.length}}}var dt=S("<style>"),ut=S(`<style>
|
|
3
3
|
.kai-composer-pill {
|
|
4
4
|
display: inline-flex; align-items: center; gap: 0.2rem;
|
|
5
5
|
/* middle (not baseline): a flex pill's baseline differs with/without an
|
|
@@ -52,6 +52,10 @@ import{g as _,r as Ye,j as J,h as de,o as ue,l as Ne,i as E,u as De,a as q,d as
|
|
|
52
52
|
.kai-composer-pill-glyph svg { width: 1em; height: 1em; display: block; }
|
|
53
53
|
/* The editable is the containing block for the placeholder pseudo-element. */
|
|
54
54
|
[data-kai-composer-editable] { position: relative; }
|
|
55
|
+
/* While a pill is arrow-selected the pill IS the selection, so hide the text
|
|
56
|
+
caret so a blinking cursor doesn't sit beside the highlight box. Returns
|
|
57
|
+
the moment the pill selection clears (arrow off, type, click, backspace). */
|
|
58
|
+
[data-kai-composer-editable][data-pill-selected] { caret-color: transparent; }
|
|
55
59
|
/* Placeholder via pseudo-element \u2014 exempt from axe color-contrast like a
|
|
56
60
|
native <textarea> placeholder. position:absolute (with auto offsets =
|
|
57
61
|
its static text-origin spot) takes it OUT of flow, so the caret sits at
|
|
@@ -62,4 +66,4 @@ import{g as _,r as Ye,j as J,h as de,o as ue,l as Ne,i as E,u as De,a as q,d as
|
|
|
62
66
|
color: var(--color-muted-foreground, #9ca3af);
|
|
63
67
|
pointer-events: none;
|
|
64
68
|
}
|
|
65
|
-
`),pt=S("<div class=relative><div data-kai-composer-editable role=textbox aria-multiline=true>"),ft=S("<div role=listbox aria-label=Suggestions style=position:fixed>"),ht=S('<div class="px-3 pt-2 pb-1 text-xs font-medium text-muted-foreground select-none">'),gt=S('<span class="text-muted-foreground truncate min-w-0">'),mt=S('<button role=option><span class="font-medium whitespace-nowrap shrink-0">'),yt=S('<span class="kai-composer-pill-glyph w-4 h-4 shrink-0"aria-hidden=true>'),kt=S('<img alt class="w-4 h-4 rounded object-cover shrink-0">'),vt=S("<div>");function A(t){var n;const l=t.getRootNode();return typeof ShadowRoot<"u"&&l instanceof ShadowRoot&&typeof l.getSelection=="function"?l.getSelection():((n=t.ownerDocument)==null?void 0:n.getSelection())??null}function Ie(t){let n="";const l=ne(t);let i=l.nextNode();for(;i;)n+=(i.textContent??"").split(C).join(""),i=l.nextNode();return n}function ge(t){const n=A(t);if(!n||n.rangeCount===0)return 0;const l=n.getRangeAt(0);if(!l.collapsed)return 0;const{startContainer:i,startOffset:u}=l;let s=0;const p=ne(t);let h=p.nextNode();for(;h;){if(h===i){const v=(h.textContent??"").slice(0,u);return s+=v.split(C).join("").length,s}s+=(h.textContent??"").split(C).join("").length,h=p.nextNode()}return s}function xt(t){const n=t.ownerDocument,l=A(t);if(!l||l.rangeCount===0)return null;const i=l.getRangeAt(0).cloneRange();i.collapse(!0);const u=i.getClientRects();if(u.length>0&&(u[0].width>0||u[0].height>0))return u[0];const s=n.createElement("span");s.textContent="\u200B",s.style.position="absolute",s.style.visibility="hidden",i.insertNode(s);const p=s.getBoundingClientRect();return s.remove(),p.width>0||p.height>0?p:null}function bt(t,n){const l=A(t);if(!l)return;const i=t.ownerDocument.createRange(),u=ne(t);let s=n,p=u.nextNode(),h=!1;for(;p;){const v=p.textContent??"",x=v.split(C).join("").length;if(s<=x){let f=0,b=0;for(;f<v.length&&b<s;)v[f]!==C&&b++,f++;for(;f<v.length&&v[f]===C;)f++;i.setStart(p,f),h=!0;break}s-=x,p=u.nextNode()}h?i.collapse(!0):(i.selectNodeContents(t),i.collapse(!1)),l.removeAllRanges(),l.addRange(i)}function wt(t){let n;const[l,i]=_(),u=`kai-composer-highlight-${Ye()}`,[s,p]=_(te(I(t.value))),[h,v]=_(null),x=e=>{const r=h();r&&r!==e&&r.removeAttribute("data-selected"),e.setAttribute("data-selected",""),v(e)},f=()=>{const e=h();e&&(e.removeAttribute("data-selected"),v(null))},b=ct({doc:I(t.value),caret:0});let D=0;const w=500,[g,k]=_(null),[m,R]=_(0),T=J(()=>{const e=g();if(!(e!=null&&e.def.items))return[];const r=new Set(pe(N(n)).map(o=>`${o.kind}:${o.id}`)),a=e.query.toLowerCase();return e.def.items.filter(o=>{var c;const d=o.kind??e.def.kind;return r.has(`${d}:${o.id}`)?!1:a===""?!0:o.label.toLowerCase().includes(a)||(((c=o.description)==null?void 0:c.toLowerCase().includes(a))??!1)})}),oe=J(()=>{const e=[];return T().forEach((r,a)=>{let o=e.find(c=>c.group===r.group);o||(o={group:r.group,items:[]},e.push(o)),o.items.push({item:r,index:a})}),e}),ie=J(()=>T().length>0),me=e=>{var r;return e.kind??((r=g())==null?void 0:r.def.kind)??""},Be=e=>{var r;return e.icon??((r=t.kindIcons)==null?void 0:r[me(e)])};de(()=>{const e=T().length;m()>=e&&R(Math.max(0,e-1))});const Me=J(()=>{const e=g();if(!e)return;const r=e.caretRect;return{getBoundingClientRect:()=>r}}),{pos:ye,hidden:je}=Ze(Me,l,{placement:"bottom-start",gutter:4}),{present:qe,state:Ke,setRef:Fe}=Qe(ie);et({enabled:ie,onDismiss:()=>B(),refs:()=>[n,l()]});function B(){var e;g()&&(k(null),(e=t.onTriggerClose)==null||e.call(t))}const M=()=>{const e=N(n);return{doc:e,text:ee(e),entities:pe(e)}};function X(){const e=t.highlights,r=e!=null&&e.length?it(Ie(n),e):[];st(n,r,C,u)}ue(()=>{re(n,I(t.value),n.ownerDocument,t.kindIcons),p(te(N(n))),X(),b.reset({doc:N(n),caret:0})}),de(Ne(()=>t.value,e=>{ee(I(e))!==ee(N(n))&&(f(),re(n,I(e),n.ownerDocument,t.kindIcons),p(te(N(n))),X(),b.reset({doc:N(n),caret:0}))},{defer:!0})),de(Ne(()=>t.highlights,()=>X(),{defer:!0}));function ke(){var e;const r=t.triggers;if(!(r!=null&&r.length)){g()&&B();return}const a=Ie(n),o=ge(n),c=rt(a,o,r);if(c){const d=xt(n);if(d){const y=g();k({def:c.def,query:c.query,start:c.start,caretRect:d}),(!y||y.def.char!==c.def.char||y.query!==c.query)&&((e=t.onTrigger)==null||e.call(t,{char:c.def.char,query:c.query,rect:d}))}}else g()&&B()}const U=e=>{var r;p(te(e.doc)),(r=t.onChange)==null||r.call(t,e),ke(),X()},He=()=>{f();const e=M();U(e);const r=Date.now();b.record({doc:e.doc,caret:ge(n)},r-D<w),D=r},ve=()=>{const e=M();U(e),b.record({doc:e.doc,caret:ge(n)},!1),D=0},xe=e=>{f(),re(n,e.doc,n.ownerDocument,t.kindIcons),bt(n,e.caret),U(M()),D=0},_e=()=>{const e=b.undo();e&&xe(e)},be=()=>{const e=b.redo();e&&xe(e)};let le=!1;const ze=e=>{var r;le=!0,(r=t.onFocus)==null||r.call(t,e)},Pe=e=>{var r;le=!1,f(),(r=t.onBlur)==null||r.call(t,e)};ue(()=>{const e=()=>{le&&ke()};document.addEventListener("selectionchange",e),Je(()=>document.removeEventListener("selectionchange",e))}),ue(()=>{var e;(e=t.controllerRef)==null||e.call(t,{focus:r=>n.focus(r),blur:()=>n.blur(),clear:()=>{f(),re(n,[],n.ownerDocument,t.kindIcons),U(M()),b.reset({doc:N(n),caret:0}),D=0},send:()=>{var r;return(r=t.onSubmit)==null?void 0:r.call(t,M())},insertEntity:r=>Ce(r)})});function we(e){const r=g();if(!r)return;const a={kind:e.kind??r.def.kind,id:e.id,label:e.label,icon:e.icon,promptText:e.promptText,data:e.data};Ce(a,{deleteBefore:1+r.query.length}),B()}const Ce=(e,r)=>{var a;const o=n.ownerDocument,c=A(n);if(!c||c.rangeCount===0)return;const d=c.getRangeAt(0);if(r!=null&&r.deleteBefore&&d.collapsed){let G=r.deleteBefore,j=d.startContainer,H=d.startOffset;for(;G>0&&j&&j.nodeType===3;){const Ge=j.textContent??"";for(;H>0&&G>0;)H--,Ge[H]!==C&&G--;if(G>0){const Y=j.previousSibling;if(Y&&Y.nodeType===3)j=Y,H=(Y.textContent??"").length;else break}}const ce=o.createRange();ce.setStart(j,H),ce.setEnd(d.startContainer,d.startOffset),ce.deleteContents()}const y=c.getRangeAt(0);y.collapsed||y.deleteContents();const $=Oe(o,e,t.kindIcons),F=o.createTextNode(C);y.insertNode(F),y.insertNode($);const se=o.createRange();se.setStartAfter(F),se.collapse(!0),c.removeAllRanges(),c.addRange(se),(a=t.onEntityAdd)==null||a.call(t,e),ve()},W=e=>(e??"").split("").every(r=>r===C),K=e=>!!e&&e.nodeType===Node.TEXT_NODE&&W(e.textContent),Re=e=>{const{startContainer:r,startOffset:a}=e;if(r===n){let o=a-1;for(;K(n.childNodes[o]);)o--;const c=n.childNodes[o];return P(c)?c:null}if(r.nodeType===Node.TEXT_NODE){if(!W((r.textContent??"").slice(0,a)))return null;let o=r.previousSibling;for(;K(o);)o=o.previousSibling;return P(o)?o:null}return null},Te=e=>{const{startContainer:r,startOffset:a}=e;if(r===n){let o=a;for(;K(n.childNodes[o]);)o++;const c=n.childNodes[o];return P(c)?c:null}if(r.nodeType===Node.TEXT_NODE){if(!W((r.textContent??"").slice(a)))return null;let o=r.nextSibling;for(;K(o);)o=o.nextSibling;return P(o)?o:null}return null},Se=e=>{var r;const a=he.get(e),o=e.nextSibling;o?.nodeType===Node.TEXT_NODE&&W(o.textContent)&&o.remove(),e.remove(),a&&((r=t.onEntityRemove)==null||r.call(t,a)),ve()},Xe=e=>{const r=A(n);if(!r)return;const a=n.ownerDocument.createRange();a.setStartBefore(e),a.collapse(!0),r.removeAllRanges(),r.addRange(a)},Ae=e=>{const r=A(n);if(!r)return;let a=e;for(;K(a.nextSibling);)a=a.nextSibling;const o=n.ownerDocument.createRange();o.setStartAfter(a),o.collapse(!0),r.removeAllRanges(),r.addRange(o)},Ue=e=>{var r;if((e.metaKey||e.ctrlKey)&&(e.key==="z"||e.key==="Z")){e.preventDefault(),e.shiftKey?be():_e();return}if((e.metaKey||e.ctrlKey)&&(e.key==="y"||e.key==="Y")){e.preventDefault(),be();return}if(ie()&&T().length>0){if(e.key==="ArrowDown"){e.preventDefault(),R(o=>(o+1)%T().length);return}if(e.key==="ArrowUp"){e.preventDefault(),R(o=>(o-1+T().length)%T().length);return}if(e.key==="Enter"||e.key==="Tab"){const o=T();if(o.length>0){e.preventDefault(),e.stopPropagation(),we(o[m()]);return}}if(e.key==="Escape"){e.preventDefault(),B();return}}else if(g()&&e.key==="Escape"){e.preventDefault(),B();return}const a=h();if(a&&a.isConnected){if(e.key==="ArrowLeft"){e.preventDefault(),Xe(a),f();return}if(e.key==="ArrowRight"){e.preventDefault(),Ae(a),f();return}if(e.key==="Backspace"||e.key==="Delete"){e.preventDefault();const o=a.previousSibling;f(),Se(a);const c=A(n);if(c){const d=n.ownerDocument.createRange();o&&o.isConnected?d.setStartAfter(o):d.setStart(n,0),d.collapse(!0),c.removeAllRanges(),c.addRange(d)}return}if(e.key==="Escape"){e.preventDefault(),f();return}if(e.key==="Shift"||e.key==="Meta"||e.key==="Control"||e.key==="Alt")return;Ae(a),f()}if(!h()&&(e.key==="ArrowLeft"||e.key==="ArrowRight")&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey){const o=A(n);if(o&&o.rangeCount>0){const c=o.getRangeAt(0);if(c.collapsed){const d=e.key==="ArrowLeft"?Re(c):Te(c);if(d){e.preventDefault(),x(d);return}}}}if(e.key==="Backspace"||e.key==="Delete"){const o=A(n);if(!o||o.rangeCount===0)return;const c=o.getRangeAt(0);if(!c.collapsed)return;const d=e.key==="Backspace"?Re(c):Te(c);if(d){e.preventDefault(),Se(d);return}}if(e.key==="Enter"&&!e.shiftKey&&t.submitOnEnter!==!1){if(e.preventDefault(),t.disabled||t.loading)return;(r=t.onSubmit)==null||r.call(t,M())}},ae=()=>t.maxHeight??240,We=()=>t.editableClass??"text-foreground min-h-[44px] w-full overflow-y-auto outline-none whitespace-pre-wrap break-words",Ee=[(()=>{var e=dt();return E(e,`::highlight(${u}) { background-color: color-mix(in srgb, var(--color-primary, #6366f1) 22%, transparent); }`),e})(),ut(),(()=>{var e=pt(),r=e.firstChild;return r.addEventListener("blur",Pe),r.addEventListener("focus",ze),r.$$mousedown=f,r.$$keydown=Ue,r.$$input=He,De(a=>{var o;n=a,(o=t.editableRef)==null||o.call(t,a)},r),q(a=>{var o=t.placeholder??"",c=t.disabled?!1:"plaintext-only",d=t.ariaLabel||t.placeholder||"Message input",y=Q(We(),s()&&t.placeholder?"kai-composer-empty":""),$=typeof ae()=="number"?`${ae()}px`:String(ae());return o!==a.e&&L(r,"data-placeholder",a.e=o),c!==a.t&&L(r,"contenteditable",a.t=c),d!==a.a&&L(r,"aria-label",a.a=d),y!==a.o&&V(r,a.o=y),$!==a.i&&Z(r,"max-height",a.i=$),a},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e})(),O(z,{get when(){return qe()},get children(){var e=ft();return De(r=>{i(r),Fe(r)},e),E(e,O($e,{get each(){return oe()},children:r=>[O(z,{get when(){return r.group},get children(){var a=ht();return E(a,()=>r.group),a}}),O($e,{get each(){return r.items},children:a=>(()=>{var o=mt(),c=o.firstChild;return o.$$click=d=>{d.preventDefault(),we(a.item)},o.$$mousedown=d=>d.preventDefault(),o.addEventListener("mouseenter",()=>R(a.index)),E(o,O(z,{get when(){return Be(a.item)},get fallback(){return O(z,{get when(){return Le(me(a.item))},children:d=>(()=>{var y=yt();return q(()=>y.innerHTML=d()),y})()})},children:d=>(()=>{var y=kt();return q(()=>L(y,"src",d())),y})()}),c),E(c,()=>a.item.label),E(o,O(z,{get when(){return a.item.description},get children(){var d=gt();return E(d,()=>a.item.description),d}}),null),q(d=>{var y=m()===a.index,$=a.index,F=Q("w-full flex items-center gap-2 px-3 py-1.5 text-left text-sm transition-colors",m()===a.index?"bg-muted text-foreground":"text-foreground hover:bg-muted");return y!==d.e&&L(o,"aria-selected",d.e=y),$!==d.t&&L(o,"data-index",d.t=$),F!==d.a&&V(o,d.a=F),d},{e:void 0,t:void 0,a:void 0}),o})()})]})),q(r=>{var a=Ke(),o=Q("absolute z-50 min-w-[240px] max-w-[420px] max-h-[320px] overflow-y-auto rounded-lg bg-card shadow-lg py-1","border border-border"),c=`${ye().x}px`,d=`${ye().y}px`,y=je()?"hidden":"visible";return a!==r.e&&L(e,"data-state",r.e=a),o!==r.t&&V(e,r.t=o),c!==r.a&&Z(e,"left",r.a=c),d!==r.o&&Z(e,"top",r.o=d),y!==r.i&&Z(e,"visibility",r.i=y),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}})];return t.bare?Ee:(()=>{var e=vt();return E(e,Ee),q(()=>V(e,Q("kai-composer relative rounded-xl bg-surface p-2",t.disabled&&"cursor-not-allowed opacity-60"))),e})()}Ve(["input","keydown","mousedown","click"]);export{wt as C,pe as e,I as n,ee as s};
|
|
69
|
+
`),pt=S("<div class=relative><div data-kai-composer-editable role=textbox aria-multiline=true>"),ft=S("<div role=listbox aria-label=Suggestions style=position:fixed>"),ht=S('<div class="px-3 pt-2 pb-1 text-xs font-medium text-muted-foreground select-none">'),gt=S('<span class="text-muted-foreground truncate min-w-0">'),mt=S('<button role=option><span class="font-medium whitespace-nowrap shrink-0">'),kt=S('<span class="kai-composer-pill-glyph w-4 h-4 shrink-0"aria-hidden=true>'),yt=S('<img alt class="w-4 h-4 rounded object-cover shrink-0">'),vt=S("<div>");function E(t){var n;const l=t.getRootNode();return typeof ShadowRoot<"u"&&l instanceof ShadowRoot&&typeof l.getSelection=="function"?l.getSelection():((n=t.ownerDocument)==null?void 0:n.getSelection())??null}function Oe(t){let n="";const l=ne(t);let i=l.nextNode();for(;i;)n+=(i.textContent??"").split(C).join(""),i=l.nextNode();return n}function ge(t){const n=E(t);if(!n||n.rangeCount===0)return 0;const l=n.getRangeAt(0);if(!l.collapsed)return 0;const{startContainer:i,startOffset:u}=l;let s=0;const p=ne(t);let f=p.nextNode();for(;f;){if(f===i){const v=(f.textContent??"").slice(0,u);return s+=v.split(C).join("").length,s}s+=(f.textContent??"").split(C).join("").length,f=p.nextNode()}return s}function xt(t){const n=t.ownerDocument,l=E(t);if(!l||l.rangeCount===0)return null;const i=l.getRangeAt(0).cloneRange();i.collapse(!0);const u=i.getClientRects();if(u.length>0&&(u[0].width>0||u[0].height>0))return u[0];const s=n.createElement("span");s.textContent="\u200B",s.style.position="absolute",s.style.visibility="hidden",i.insertNode(s);const p=s.getBoundingClientRect();return s.remove(),p.width>0||p.height>0?p:null}function bt(t,n){const l=E(t);if(!l)return;const i=t.ownerDocument.createRange(),u=ne(t);let s=n,p=u.nextNode(),f=!1;for(;p;){const v=p.textContent??"",x=v.split(C).join("").length;if(s<=x){let h=0,b=0;for(;h<v.length&&b<s;)v[h]!==C&&b++,h++;for(;h<v.length&&v[h]===C;)h++;i.setStart(p,h),f=!0;break}s-=x,p=u.nextNode()}f?i.collapse(!0):(i.selectNodeContents(t),i.collapse(!1)),l.removeAllRanges(),l.addRange(i)}function wt(t){let n;const[l,i]=_(),u=`kai-composer-highlight-${Ye()}`,[s,p]=_(te(B(t.value))),[f,v]=_(null),x=e=>{const r=f();r&&r!==e&&r.removeAttribute("data-selected"),e.setAttribute("data-selected",""),v(e)},h=()=>{const e=f();e&&(e.removeAttribute("data-selected"),v(null))},b=ct({doc:B(t.value),caret:0});let $=0;const w=500,[g,y]=_(null),[m,R]=_(0),T=J(()=>{const e=g();if(!(e!=null&&e.def.items))return[];const r=new Set(pe(L(n)).map(o=>`${o.kind}:${o.id}`)),a=e.query.toLowerCase();return e.def.items.filter(o=>{var c;const d=o.kind??e.def.kind;return r.has(`${d}:${o.id}`)?!1:a===""?!0:o.label.toLowerCase().includes(a)||(((c=o.description)==null?void 0:c.toLowerCase().includes(a))??!1)})}),oe=J(()=>{const e=[];return T().forEach((r,a)=>{let o=e.find(c=>c.group===r.group);o||(o={group:r.group,items:[]},e.push(o)),o.items.push({item:r,index:a})}),e}),ie=J(()=>T().length>0),me=e=>{var r;return e.kind??((r=g())==null?void 0:r.def.kind)??""},Be=e=>{var r;return e.icon??((r=t.kindIcons)==null?void 0:r[me(e)])};de(()=>{const e=T().length;m()>=e&&R(Math.max(0,e-1))});const Me=J(()=>{const e=g();if(!e)return;const r=e.caretRect;return{getBoundingClientRect:()=>r}}),{pos:ke,hidden:je}=Ze(Me,l,{placement:"bottom-start",gutter:4}),{present:qe,state:Ke,setRef:Fe}=Qe(ie);et({enabled:ie,onDismiss:()=>M(),refs:()=>[n,l()]});function M(){var e;g()&&(y(null),(e=t.onTriggerClose)==null||e.call(t))}const j=()=>{const e=L(n);return{doc:e,text:ee(e),entities:pe(e)}};function X(){const e=t.highlights,r=e!=null&&e.length?it(Oe(n),e):[];st(n,r,C,u)}ue(()=>{re(n,B(t.value),n.ownerDocument,t.kindIcons),p(te(L(n))),X(),b.reset({doc:L(n),caret:0})}),de(Ae(()=>t.value,e=>{ee(B(e))!==ee(L(n))&&(h(),re(n,B(e),n.ownerDocument,t.kindIcons),p(te(L(n))),X(),b.reset({doc:L(n),caret:0}))},{defer:!0})),de(Ae(()=>t.highlights,()=>X(),{defer:!0}));function ye(){var e;const r=t.triggers;if(!(r!=null&&r.length)){g()&&M();return}const a=Oe(n),o=ge(n),c=rt(a,o,r);if(c){const d=xt(n);if(d){const k=g();y({def:c.def,query:c.query,start:c.start,caretRect:d}),(!k||k.def.char!==c.def.char||k.query!==c.query)&&((e=t.onTrigger)==null||e.call(t,{char:c.def.char,query:c.query,rect:d}))}}else g()&&M()}const U=e=>{var r;p(te(e.doc)),(r=t.onChange)==null||r.call(t,e),ye(),X()},He=()=>{h();const e=j();U(e);const r=Date.now();b.record({doc:e.doc,caret:ge(n)},r-$<w),$=r},ve=()=>{const e=j();U(e),b.record({doc:e.doc,caret:ge(n)},!1),$=0},xe=e=>{h(),re(n,e.doc,n.ownerDocument,t.kindIcons),bt(n,e.caret),U(j()),$=0},_e=()=>{const e=b.undo();e&&xe(e)},be=()=>{const e=b.redo();e&&xe(e)};let le=!1;const Pe=e=>{var r;le=!0,(r=t.onFocus)==null||r.call(t,e)},ze=e=>{var r;le=!1,h(),(r=t.onBlur)==null||r.call(t,e)};ue(()=>{const e=()=>{le&&ye()};document.addEventListener("selectionchange",e),Je(()=>document.removeEventListener("selectionchange",e))}),ue(()=>{var e;(e=t.controllerRef)==null||e.call(t,{focus:r=>n.focus(r),blur:()=>n.blur(),clear:()=>{h(),re(n,[],n.ownerDocument,t.kindIcons),U(j()),b.reset({doc:L(n),caret:0}),$=0},send:()=>{var r;return(r=t.onSubmit)==null?void 0:r.call(t,j())},insertEntity:r=>Ce(r)})});function we(e){const r=g();if(!r)return;const a={kind:e.kind??r.def.kind,id:e.id,label:e.label,icon:e.icon,promptText:e.promptText,data:e.data};Ce(a,{deleteBefore:1+r.query.length}),M()}const Ce=(e,r)=>{var a;const o=n.ownerDocument,c=E(n);if(!c||c.rangeCount===0)return;const d=c.getRangeAt(0);if(r!=null&&r.deleteBefore&&d.collapsed){let G=r.deleteBefore,q=d.startContainer,H=d.startOffset;for(;G>0&&q&&q.nodeType===3;){const Ge=q.textContent??"";for(;H>0&&G>0;)H--,Ge[H]!==C&&G--;if(G>0){const Y=q.previousSibling;if(Y&&Y.nodeType===3)q=Y,H=(Y.textContent??"").length;else break}}const ce=o.createRange();ce.setStart(q,H),ce.setEnd(d.startContainer,d.startOffset),ce.deleteContents()}const k=c.getRangeAt(0);k.collapsed||k.deleteContents();const I=Ie(o,e,t.kindIcons),N=o.createTextNode(C);k.insertNode(N),k.insertNode(I);const se=o.createRange();se.setStartAfter(N),se.collapse(!0),c.removeAllRanges(),c.addRange(se),(a=t.onEntityAdd)==null||a.call(t,e),ve()},W=e=>(e??"").split("").every(r=>r===C),F=e=>!!e&&e.nodeType===Node.TEXT_NODE&&W(e.textContent),Re=e=>{const{startContainer:r,startOffset:a}=e;if(r===n){let o=a-1;for(;F(n.childNodes[o]);)o--;const c=n.childNodes[o];return z(c)?c:null}if(r.nodeType===Node.TEXT_NODE){if(!W((r.textContent??"").slice(0,a)))return null;let o=r.previousSibling;for(;F(o);)o=o.previousSibling;return z(o)?o:null}return null},Te=e=>{const{startContainer:r,startOffset:a}=e;if(r===n){let o=a;for(;F(n.childNodes[o]);)o++;const c=n.childNodes[o];return z(c)?c:null}if(r.nodeType===Node.TEXT_NODE){if(!W((r.textContent??"").slice(a)))return null;let o=r.nextSibling;for(;F(o);)o=o.nextSibling;return z(o)?o:null}return null},Se=e=>{var r;const a=he.get(e),o=e.nextSibling;o?.nodeType===Node.TEXT_NODE&&W(o.textContent)&&o.remove(),e.remove(),a&&((r=t.onEntityRemove)==null||r.call(t,a)),ve()},Xe=e=>{const r=E(n);if(!r)return;const a=n.ownerDocument.createRange();a.setStartBefore(e),a.collapse(!0),r.removeAllRanges(),r.addRange(a)},Ee=e=>{const r=E(n);if(!r)return;let a=e;for(;F(a.nextSibling);)a=a.nextSibling;const o=n.ownerDocument.createRange();o.setStartAfter(a),o.collapse(!0),r.removeAllRanges(),r.addRange(o)},Ue=e=>{var r;if((e.metaKey||e.ctrlKey)&&(e.key==="z"||e.key==="Z")){e.preventDefault(),e.shiftKey?be():_e();return}if((e.metaKey||e.ctrlKey)&&(e.key==="y"||e.key==="Y")){e.preventDefault(),be();return}if(ie()&&T().length>0){if(e.key==="ArrowDown"){e.preventDefault(),R(o=>(o+1)%T().length);return}if(e.key==="ArrowUp"){e.preventDefault(),R(o=>(o-1+T().length)%T().length);return}if(e.key==="Enter"||e.key==="Tab"){const o=T();if(o.length>0){e.preventDefault(),e.stopPropagation(),we(o[m()]);return}}if(e.key==="Escape"){e.preventDefault(),M();return}}else if(g()&&e.key==="Escape"){e.preventDefault(),M();return}const a=f();if(a&&a.isConnected){if(e.key==="ArrowLeft"){e.preventDefault(),Xe(a),h();return}if(e.key==="ArrowRight"){e.preventDefault(),Ee(a),h();return}if(e.key==="Backspace"||e.key==="Delete"){e.preventDefault();const o=a.previousSibling;h(),Se(a);const c=E(n);if(c){const d=n.ownerDocument.createRange();o&&o.isConnected?d.setStartAfter(o):d.setStart(n,0),d.collapse(!0),c.removeAllRanges(),c.addRange(d)}return}if(e.key==="Escape"){e.preventDefault(),h();return}if(e.key==="Shift"||e.key==="Meta"||e.key==="Control"||e.key==="Alt")return;Ee(a),h()}if(!f()&&(e.key==="ArrowLeft"||e.key==="ArrowRight")&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey){const o=E(n);if(o&&o.rangeCount>0){const c=o.getRangeAt(0);if(c.collapsed){const d=e.key==="ArrowLeft"?Re(c):Te(c);if(d){e.preventDefault(),x(d);return}}}}if(e.key==="Backspace"||e.key==="Delete"){const o=E(n);if(!o||o.rangeCount===0)return;const c=o.getRangeAt(0);if(!c.collapsed)return;const d=e.key==="Backspace"?Re(c):Te(c);if(d){e.preventDefault(),Se(d);return}}if(e.key==="Enter"&&!e.shiftKey&&t.submitOnEnter!==!1){if(e.preventDefault(),t.disabled||t.loading)return;(r=t.onSubmit)==null||r.call(t,j())}},ae=()=>t.maxHeight??240,We=()=>t.editableClass??"text-foreground min-h-[44px] w-full overflow-y-auto outline-none whitespace-pre-wrap break-words",Ne=[(()=>{var e=dt();return A(e,`::highlight(${u}) { background-color: color-mix(in srgb, var(--color-primary, #6366f1) 22%, transparent); }`),e})(),ut(),(()=>{var e=pt(),r=e.firstChild;return r.addEventListener("blur",ze),r.addEventListener("focus",Pe),r.$$mousedown=h,r.$$keydown=Ue,r.$$input=He,De(a=>{var o;n=a,(o=t.editableRef)==null||o.call(t,a)},r),K(a=>{var o=f()?"":void 0,c=t.placeholder??"",d=t.disabled?!1:"plaintext-only",k=t.ariaLabel||t.placeholder||"Message input",I=Q(We(),s()&&t.placeholder?"kai-composer-empty":""),N=typeof ae()=="number"?`${ae()}px`:String(ae());return o!==a.e&&D(r,"data-pill-selected",a.e=o),c!==a.t&&D(r,"data-placeholder",a.t=c),d!==a.a&&D(r,"contenteditable",a.a=d),k!==a.o&&D(r,"aria-label",a.o=k),I!==a.i&&V(r,a.i=I),N!==a.n&&Z(r,"max-height",a.n=N),a},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),e})(),O(P,{get when(){return qe()},get children(){var e=ft();return De(r=>{i(r),Fe(r)},e),A(e,O(Le,{get each(){return oe()},children:r=>[O(P,{get when(){return r.group},get children(){var a=ht();return A(a,()=>r.group),a}}),O(Le,{get each(){return r.items},children:a=>(()=>{var o=mt(),c=o.firstChild;return o.$$click=d=>{d.preventDefault(),we(a.item)},o.$$mousedown=d=>d.preventDefault(),o.addEventListener("mouseenter",()=>R(a.index)),A(o,O(P,{get when(){return Be(a.item)},get fallback(){return O(P,{get when(){return $e(me(a.item))},children:d=>(()=>{var k=kt();return K(()=>k.innerHTML=d()),k})()})},children:d=>(()=>{var k=yt();return K(()=>D(k,"src",d())),k})()}),c),A(c,()=>a.item.label),A(o,O(P,{get when(){return a.item.description},get children(){var d=gt();return A(d,()=>a.item.description),d}}),null),K(d=>{var k=m()===a.index,I=a.index,N=Q("w-full flex items-center gap-2 px-3 py-1.5 text-left text-sm transition-colors",m()===a.index?"bg-muted text-foreground":"text-foreground hover:bg-muted");return k!==d.e&&D(o,"aria-selected",d.e=k),I!==d.t&&D(o,"data-index",d.t=I),N!==d.a&&V(o,d.a=N),d},{e:void 0,t:void 0,a:void 0}),o})()})]})),K(r=>{var a=Ke(),o=Q("absolute z-50 min-w-[240px] max-w-[420px] max-h-[320px] overflow-y-auto rounded-lg bg-card shadow-lg py-1","border border-border"),c=`${ke().x}px`,d=`${ke().y}px`,k=je()?"hidden":"visible";return a!==r.e&&D(e,"data-state",r.e=a),o!==r.t&&V(e,r.t=o),c!==r.a&&Z(e,"left",r.a=c),d!==r.o&&Z(e,"top",r.o=d),k!==r.i&&Z(e,"visibility",r.i=k),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}})];return t.bare?Ne:(()=>{var e=vt();return A(e,Ne),K(()=>V(e,Q("kai-composer relative rounded-xl bg-surface p-2",t.disabled&&"cursor-not-allowed opacity-60"))),e})()}Ve(["input","keydown","mousedown","click"]);export{wt as C,pe as e,B as n,ee as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s,c as n,S as a,i as o,a as d,b as f,
|
|
1
|
+
import{j as s,c as n,S as a,i as o,a as d,b as f,x as P,y as z,z as E,t as u,d as D,n as O}from"./define-DfTe4zwZ.js";import{a as R,b as q,c as A}from"./hover-card-Dn3yrk1l.js";import{c as h}from"./cn-CU7UAWzk.js";import{B as G}from"./button-BD7lUvVB.js";var H=u('<svg aria-label="Model context usage"height=20 role=img viewBox="0 0 24 24"width=20 style=color:currentcolor><circle cx=12 cy=12 fill=none opacity=0.25 r=10 stroke=currentColor stroke-width=2></circle><circle cx=12 cy=12 fill=none opacity=0.7 r=10 stroke=currentColor stroke-linecap=round stroke-width=2 style=transform:rotate(-90deg);transform-origin:center>'),J=u('<span class="font-medium text-muted-foreground">'),K=u('<div class="flex items-center justify-between gap-3 text-xs"><p></p><p class="font-mono text-muted-foreground"> / '),L=u('<div class=space-y-2><div class="h-1.5 w-full rounded-full bg-muted overflow-hidden"><div>'),b=u("<div>"),Q=u("<span class=text-muted-foreground>Total cost"),F=u("<span>"),V=u("<div><span class=text-muted-foreground>Input"),W=u("<div><span class=text-muted-foreground>Output"),X=u("<div><span class=text-muted-foreground>Reasoning"),Y=u("<div><span class=text-muted-foreground>Cache");const Z=10,U=100,y=.7,C=.9;function _(e,t=y,r=C){return e>r?"danger":e>t?"warn":"ok"}const M=z();function g(){const e=E(M);if(!e)throw new Error("Context components must be used within Context");return e}const j=new Intl.NumberFormat("en-US",{notation:"compact"}),N=new Intl.NumberFormat("en-US",{maximumFractionDigits:1,style:"percent"}),ee=new Intl.NumberFormat("en-US",{currency:"USD",style:"currency"});function te(e){const t=s(()=>({usedTokens:e.usedTokens,maxTokens:e.maxTokens,inputTokens:e.inputTokens,outputTokens:e.outputTokens,reasoningTokens:e.reasoningTokens,cacheTokens:e.cacheTokens,estimatedCost:e.estimatedCost,warnThreshold:e.warnThreshold??y,dangerThreshold:e.dangerThreshold??C}));return n(M.Provider,{get value(){return t()},get children(){return n(R,{openDelay:0,get children(){return e.children}})}})}function re(){const e=g(),t=2*Math.PI*Z,r=s(()=>e.usedTokens/e.maxTokens),l=s(()=>t*(1-r()));return(()=>{var i=H(),T=i.firstChild,w=T.nextSibling;return D(w,"stroke-dasharray",`${t} ${t}`),d(()=>D(w,"stroke-dashoffset",l())),i})()}function ne(e){const t=g(),r=s(()=>t.usedTokens/t.maxTokens),l=s(()=>N.format(r()));return n(q,{get children(){return n(a,{get when(){return!e.children},get fallback(){return e.children},get children(){return n(G,{type:"button",variant:"ghost",get class(){return e.class},get children(){return[(()=>{var i=J();return o(i,l),i})(),n(re,{})]}})}})}})}function se(e){return n(A,{get class(){return h("min-w-60 divide-y divide-border overflow-hidden",e.class)},get children(){return e.children}})}function oe(e){const t=g(),r=s(()=>t.usedTokens/t.maxTokens),l=s(()=>N.format(r())),i=s(()=>j.format(t.usedTokens)),T=s(()=>j.format(t.maxTokens)),w=s(()=>`${Math.min(r()*U,U)}%`),$=s(()=>{const c=r();return c>t.dangerThreshold?"danger":c>t.warnThreshold?"warn":"ok"}),B=s(()=>{const c=$();return c==="danger"?"bg-red-400":c==="warn"?"bg-yellow-400":"bg-primary"});return(()=>{var c=b();return o(c,n(a,{get when(){return!e.children},get fallback(){return e.children},get children(){return[(()=>{var x=K(),p=x.firstChild,k=p.nextSibling,m=k.firstChild;return o(p,l),o(k,i,m),o(k,T,null),x})(),(()=>{var x=L(),p=x.firstChild,k=p.firstChild;return d(m=>{var S=h("h-full rounded-full transition-all",B()),I=w();return S!==m.e&&f(k,m.e=S),I!==m.t&&P(k,"width",m.t=I),m},{e:void 0,t:void 0}),x})()]}})),d(()=>f(c,h("w-full space-y-2 p-3",e.class))),c})()}function ae(e){return(()=>{var t=b();return o(t,()=>e.children),d(()=>f(t,h("w-full p-3",e.class))),t})()}function ue(e){const t=g(),r=s(()=>ee.format(t.estimatedCost??0));return(()=>{var l=b();return o(l,n(a,{get when(){return!e.children},get fallback(){return e.children},get children(){return[Q(),(()=>{var i=F();return o(i,r),i})()]}})),d(()=>f(l,h("flex w-full items-center justify-between gap-3 bg-muted p-3 text-xs",e.class))),l})()}function v(e){return(()=>{var t=F();return o(t,(()=>{var r=O(()=>e.tokens===void 0);return()=>r()?"\u2014":j.format(e.tokens)})()),t})()}function ie(e){const t=g();return n(a,{get when(){return e.children||t.inputTokens},get children(){return n(a,{get when(){return!e.children},get fallback(){return e.children},get children(){var r=V();return r.firstChild,o(r,n(v,{get tokens(){return t.inputTokens}}),null),d(()=>f(r,h("flex items-center justify-between text-xs",e.class))),r}})}})}function le(e){const t=g();return n(a,{get when(){return e.children||t.outputTokens},get children(){return n(a,{get when(){return!e.children},get fallback(){return e.children},get children(){var r=W();return r.firstChild,o(r,n(v,{get tokens(){return t.outputTokens}}),null),d(()=>f(r,h("flex items-center justify-between text-xs",e.class))),r}})}})}function ce(e){const t=g();return n(a,{get when(){return e.children||t.reasoningTokens},get children(){return n(a,{get when(){return!e.children},get fallback(){return e.children},get children(){var r=X();return r.firstChild,o(r,n(v,{get tokens(){return t.reasoningTokens}}),null),d(()=>f(r,h("flex items-center justify-between text-xs",e.class))),r}})}})}function de(e){const t=g();return n(a,{get when(){return e.children||t.cacheTokens},get children(){return n(a,{get when(){return!e.children},get fallback(){return e.children},get children(){var r=Y();return r.firstChild,o(r,n(v,{get tokens(){return t.cacheTokens}}),null),d(()=>f(r,h("flex items-center justify-between text-xs",e.class))),r}})}})}export{te as C,y as D,ne as a,se as b,oe as c,ae as d,ie as e,le as f,ue as g,_ as h,ce as i,de as j,C as k};
|
package/dist/elements/chunks/{conversation-list-C4xTQSpT.js → conversation-list-5O_KdI_I.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as r,m as L,g as y,s as I,j as m,i as c,S as h,a as v,b as p,d as M,t as l,e as N,
|
|
1
|
+
import{c as r,m as L,g as y,s as I,j as m,i as c,S as h,a as v,b as p,d as M,t as l,e as N,k as O,u as D,F as k}from"./define-DfTe4zwZ.js";import{c as f}from"./cn-CU7UAWzk.js";import{a as R,b as q,C as E}from"./collapsible-DGjADCN6.js";import{B as C}from"./button-BD7lUvVB.js";import{B as F}from"./badge-CxklEXQm.js";import{S as P}from"./scroll-area-BzOPDXrZ.js";import{m as U}from"./message-square-CCSQ4M9g.js";import{I as G}from"./Icon-11SRdjJ4.js";var H=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],J=a=>r(G,L(a,{name:"PanelLeftOpen",iconNode:H})),K=J;function Q(a,e){const[d,o]=y(e);return[()=>a()??d(),t=>o(t)]}var $=l('<span part=trailing class="ml-auto shrink-0 text-xs text-muted-foreground">'),V=l('<div class="flex items-center gap-2.5"><span>'),W=l("<button>"),X=l('<div class="flex items-center gap-2"><div>'),Y=l("<div> messages");function Z(a,e=Date.now()){if(!a)return"";const d=Date.parse(a);if(Number.isNaN(d))return"";const o=Math.max(0,Math.round((e-d)/1e3));if(o<60)return"just now";const t=Math.floor(o/60);if(t<60)return`${t}m ago`;const i=Math.floor(t/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function B(a){const[e]=I(a,["conversation","isActive","onSelect","compact","class"]),d=m(()=>e.conversation.trailing??Z(e.conversation.updatedAt??e.conversation.lastMessageAt));return(()=>{var o=W();return o.$$click=()=>e.onSelect(e.conversation.id),c(o,r(h,{get when(){return e.compact},get fallback(){return[(()=>{var t=X(),i=t.firstChild;return c(i,()=>e.conversation.title),c(t,r(h,{get when(){return d()},get children(){var g=$();return c(g,d),g}}),null),v(()=>p(i,f("min-w-0 flex-1 truncate text-sm",e.isActive?"font-medium text-foreground":"text-foreground/80"))),t})(),(()=>{var t=Y(),i=t.firstChild;return c(t,()=>e.conversation.messageCount,i),v(()=>p(t,f("mt-0.5 truncate text-xs",e.isActive?"text-foreground/70":"text-muted-foreground"))),t})()]},get children(){var t=V(),i=t.firstChild;return c(t,r(U,{get class(){return f("size-3.5 shrink-0",e.isActive?"text-foreground":"text-muted-foreground")}}),i),c(i,()=>e.conversation.title),c(t,r(h,{get when(){return d()},get children(){var g=$();return c(g,d),g}}),null),v(()=>p(i,f("min-w-0 flex-1 truncate text-sm",e.isActive?"font-medium text-foreground":"text-foreground/80"))),t}})),v(t=>{var i=e.conversation.id,g=f("w-full rounded-lg text-left transition-colors",e.compact?"px-2.5 py-1.5":"px-2.5 py-2",e.isActive?"bg-muted":"hover:bg-muted/50",e.class);return i!==t.e&&M(o,"data-conversation-id",t.e=i),g!==t.t&&p(o,t.t=g),t},{e:void 0,t:void 0}),o})()}N(["click"]);var _=l('<div class="px-3 pb-2"><div class="flex items-center gap-2 rounded-md bg-surface-strong px-2.5 py-1.5"><svg width=13 height=13 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 class=text-muted-foreground><circle cx=11 cy=11 r=8></circle><line x1=21 y1=21 x2=16.65 y2=16.65></line></svg><input type=text placeholder="Search chats..."aria-label="Search chats"class="bg-transparent text-[13px] text-foreground placeholder:text-muted-foreground rounded-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring w-full">'),ee=l('<div class="space-y-0.5 py-1">'),te=l('<div class="shrink-0 border-t border-border">'),re=l("<div>"),ne=l('<svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2><line x1=3 y1=12 x2=21 y2=12></line><line x1=3 y1=6 x2=21 y2=6></line><line x1=3 y1=18 x2=21 y2=18>'),oe=l('<svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2><line x1=12 y1=5 x2=12 y2=19></line><line x1=5 y1=12 x2=19 y2=12>'),ae=l('<div class="flex items-center justify-between p-3 pb-2"><div class="flex items-center gap-2"><span class="text-sm font-semibold text-foreground">Chats'),ie=l('<div class="flex flex-1 flex-col items-center justify-center gap-1 p-6 text-center text-sm text-muted-foreground">No conversations yet'),se=l('<svg width=10 height=10 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2><polyline points="6 9 12 15 18 9">'),ce=l("<span>"),le=l('<div class="pl-2 mt-0.5 space-y-0.5">');function ue(a){return r(C,{variant:"ghost",size:"icon-sm","aria-label":"Open sidebar",get class(){return f("rounded-full bg-card/80 shadow-sm backdrop-blur",a.class)},get onClick(){return a.onExpand},get children(){return r(K,{class:"size-4"})}})}function de(a){const[e]=I(a,["groups","conversations","activeId","onSelect","onNewChat","onToggleSidebar","header","footer","empty","compact","onSearchChange","controllerRef","class"]),[d,o]=y(""),t=m(()=>e.conversations.length===0);let i;const g=s=>{var n;o(s),(n=e.onSearchChange)==null||n.call(e,s)};O(()=>{var s;(s=e.controllerRef)==null||s.call(e,{focus:n=>i?.focus(n),clearSearch:()=>g("")})});const z=m(()=>{const s=d().toLowerCase();return s?e.conversations.filter(n=>n.title.toLowerCase().includes(s)):e.conversations}),S=m(()=>{const s=new Map;for(const n of z()){const u=n.groupId;s.has(u)||s.set(u,[]),s.get(u).push(n)}return s}),x=m(()=>S().get(void 0)??[]);return(()=>{var s=re();return c(s,r(h,{get when(){return e.header},get fallback(){return(()=>{var n=ae(),u=n.firstChild,w=u.firstChild;return c(u,r(C,{variant:"ghost",size:"icon-sm","aria-label":"Toggle sidebar",get onClick(){return e.onToggleSidebar},get children(){return ne()}}),w),c(n,r(C,{variant:"ghost",size:"icon-sm","aria-label":"New chat",get onClick(){return e.onNewChat},get children(){return oe()}}),null),n})()},get children(){return e.header}}),null),c(s,r(h,{get when(){return!t()},get children(){var n=_(),u=n.firstChild,w=u.firstChild,b=w.nextSibling;b.$$input=T=>g(T.currentTarget.value);var A=i;return typeof A=="function"?D(A,b):i=b,v(()=>b.value=d()),n}}),null),c(s,r(h,{get when(){return!t()},get fallback(){return r(h,{get when(){return e.empty},get fallback(){return ie()},get children(){return e.empty}})},get children(){return r(P,{class:"flex-1 px-2",get children(){return[r(k,{get each(){return e.groups},children:n=>{const u=m(()=>S().get(n.id)??[]);return r(h,{get when(){return u().length>0},get children(){return r(j,{get name(){return n.name},get count(){return u().length},get conversations(){return u()},get activeId(){return e.activeId},get onSelect(){return e.onSelect},get compact(){return e.compact}})}})}}),r(h,{get when(){return x().length>0},get children(){return r(h,{get when(){return e.compact},get fallback(){return r(j,{name:"Ungrouped",get count(){return x().length},get conversations(){return x()},get activeId(){return e.activeId},get onSelect(){return e.onSelect}})},get children(){var n=ee();return c(n,r(k,{get each(){return x()},children:u=>r(B,{conversation:u,get isActive(){return u.id===e.activeId},get onSelect(){return e.onSelect},compact:!0})})),n}})}})]}})}}),null),c(s,r(h,{get when(){return e.footer},get children(){var n=te();return c(n,()=>e.footer),n}}),null),v(()=>p(s,f("flex flex-col h-full bg-sidebar",e.class))),s})()}function j(a){const[e,d]=y(!0);return r(E,{get open(){return e()},onOpenChange:d,get children(){return[r(R,{class:"flex items-center gap-1.5 w-full px-1.5 py-1 rounded-md text-[13px] text-muted-foreground font-medium hover:bg-muted/30 transition-colors cursor-pointer mt-1.5",get children(){return[(()=>{var o=se();return v(()=>M(o,"class",f("transition-transform",!e()&&"-rotate-90"))),o})(),(()=>{var o=ce();return c(o,()=>a.name),o})(),r(F,{variant:"count",class:"ml-auto text-[11px]",get children(){return a.count}})]}}),r(q,{get children(){var o=le();return c(o,r(k,{get each(){return a.conversations},children:t=>r(B,{conversation:t,get isActive(){return t.id===a.activeId},get onSelect(){return a.onSelect},get compact(){return a.compact}})})),o}})]}})}N(["input"]);export{de as C,ue as a,Q as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as t,m as x,s as y,
|
|
1
|
+
import{c as t,m as x,s as y,v as T,l as A,i as c,g as U,z as H,O as P,t as d,y as D,e as _,F as k,S as g,n as V,q as S,u as j}from"./define-DfTe4zwZ.js";import{c as z}from"./cn-CU7UAWzk.js";import{C as q,s as B,n as E}from"./composer-CavJww3d.js";import{P as M}from"./prompt-suggestion-LalWvCJy.js";import{B as m}from"./button-BD7lUvVB.js";import{T as O}from"./tooltip-CBeFqJKk.js";import{A as F,a as N,d as W,e as G,i as J}from"./attachments-CBqQRh60.js";import{a as K}from"./action-icons-CtRg17uX.js";import{p as Q,g as X}from"./paperclip-MA9hxLhW.js";import{m as Y}from"./icon-BrxJQXzC.js";import{I as Z}from"./Icon-11SRdjJ4.js";var ee=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],te=e=>t(Z,x(e,{name:"Square",iconNode:ee})),re=te,ne=d("<div data-prompt-input>"),ae=d("<div>");const L=D();function le(){const e=H(L);if(!e)throw new Error("PromptInput subcomponents must be used within PromptInput");return e}function ie(e){const[r,l]=y(e,["isLoading","value","onValueChange","maxHeight","onSubmit","children","disabled","class","onClick"]),[u,b]=U(r.value??"");let i;const h=s=>{var v;b(s),(v=r.onValueChange)==null||v.call(r,s)},w=s=>{r.disabled||i==null||i.focus(),typeof r.onClick=="function"&&r.onClick(s)};return t(L.Provider,{get value(){return{isLoading:r.isLoading??!1,value:()=>r.value??u(),setValue:r.onValueChange??h,maxHeight:r.maxHeight??240,onSubmit:r.onSubmit,get disabled(){return r.disabled},get textareaRef(){return i},setTextareaRef:s=>{i=s}}},get children(){var s=ne();return s.$$click=w,A(s,x({get class(){return z("bg-surface cursor-text rounded-xl p-2 shadow-xs","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-0",r.disabled&&"cursor-not-allowed opacity-60",r.class)}},l),!1,!0),c(s,()=>r.children),s}})}function se(e){const[r]=y(e,["class","placeholder","aria-label","triggers","kindIcons","onComposerChange"]),l=le(),u=T(),b=()=>z("text-foreground min-h-[44px] w-full bg-transparent shadow-none outline-none focus-visible:ring-0 focus-visible:ring-offset-0 overflow-y-auto whitespace-pre-wrap break-words",P(u.proseSize()),r.class);return t(q,{bare:!0,get value(){return l.value()},get placeholder(){return r.placeholder},get ariaLabel(){return r["aria-label"]},get disabled(){return l.disabled},get maxHeight(){return l.maxHeight},get editableClass(){return b()},editableRef:i=>l.setTextareaRef(i),get triggers(){return r.triggers},get kindIcons(){return r.kindIcons},onChange:i=>{var h;(h=r.onComposerChange)==null||h.call(r,i),l.setValue(i.text.replace(/^\s+/,""))},onSubmit:()=>{var i;l.disabled||(i=l.onSubmit)==null||i.call(l)}})}function oe(e){const[r,l]=y(e,["children","class"]);return(()=>{var u=ae();return A(u,x({get class(){return z("flex items-center gap-2",r.class)}},l),!1,!0),c(u,()=>r.children),u})()}_(["click"]);var ue=d('<div class="mb-2 flex flex-wrap gap-2">'),ce=d('<div class="px-3 pt-3">'),de=d("<slot name=input-top>"),ge=d("<input type=file multiple class=hidden>"),he=d('<div class="flex items-center gap-2"><slot name=toolbar-start style=display:contents>'),pe=d('<div class="flex items-center gap-2"><slot name=toolbar-end>'),me=d('<span class="px-1 text-xs">'),be=d('<svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2><line x1=12 y1=19 x2=12 y2=5></line><polyline points="5 12 12 5 19 12">');function fe(e){return{id:typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`${e.name}-${e.size}-${e.lastModified}`,type:"file",filename:e.name,mediaType:e.type||void 0,url:e.type.startsWith("image/")?URL.createObjectURL(e):void 0}}function ve(e){let r;const l=()=>e.attachments??[],u=()=>!!e.onAttachmentsChange,b=n=>{!(n!=null&&n.length)||!e.onAttachmentsChange||e.onAttachmentsChange([...l(),...Array.from(n).map(fe)])},i=n=>{var o;return(o=e.onAttachmentsChange)==null?void 0:o.call(e,l().filter(a=>a.id!==n))},h=()=>B(E(e.value)),w=()=>e.disabled||e.loading||!h().trim()&&l().length===0,s=()=>!!e.loading&&!!e.stoppable,v=()=>!!h().trim()||l().length>0,$=()=>{const n=e.submit??"always";return n==="always"||n==="auto"&&v()};return[t(g,{get when(){var n;return(n=e.suggestions)==null?void 0:n.length},get children(){var n=ue();return c(n,t(k,{get each(){return e.suggestions},children:o=>t(M,{onClick:()=>e.onSuggestionClick(o),children:o})})),n}}),t(ie,{get value(){return e.value},get onValueChange(){return e.onValueChange},get onSubmit(){return e.onSubmit},get isLoading(){return e.loading},get disabled(){return e.disabled},class:"relative",get children(){return[t(g,{get when(){return V(()=>!!u())()&&l().length},get children(){var n=ce();return c(n,t(F,{variant:"inline",get children(){return t(k,{get each(){return l()},children:o=>t(N,{data:o,onRemove:()=>i(o.id),get children(){return[t(W,{}),t(G,{}),t(J,{})]}})})}})),n}}),(()=>{var n=de();return n._$owner=S(),n})(),t(se,{get placeholder(){return e.placeholder},get"aria-label"(){return e.placeholder||"Message"},class:"min-h-[44px] pt-3 pl-4",get triggers(){return e.triggers},get kindIcons(){return e.kindIcons},get onComposerChange(){return e.onComposerChange}}),t(oe,{class:"mt-2 flex w-full items-center justify-between gap-2 px-3 pb-0",get children(){return[(()=>{var n=he(),o=n.firstChild;return o._$owner=S(),c(n,t(g,{get when(){return V(()=>!!u())()&&e.attach!==!1},get children(){return[(()=>{var a=ge();a.addEventListener("change",C=>{b(C.currentTarget.files),C.currentTarget.value=""});var f=r;return typeof f=="function"?j(f,a):r=a,a})(),t(m,{type:"button",variant:"outline",size:"icon-sm",class:"rounded-full","aria-label":"Attach files",get disabled(){return e.disabled},onClick:()=>r?.click(),get children(){return t(Q,{class:"size-4"})}})]}}),null),c(n,t(g,{get when(){return e.search},get children(){return t(m,{type:"button",variant:"outline",size:"sm",class:"rounded-full gap-1","aria-label":"Search the web",get disabled(){return e.disabled},onClick:()=>{var a;return(a=e.onSearch)==null?void 0:a.call(e)},get children(){return[t(X,{class:"size-4"}),"Search"]}})}}),null),c(n,t(g,{get when(){return e.voice},get children(){return t(m,{type:"button",variant:"outline",size:"icon-sm",class:"rounded-full","aria-label":"Voice input",get disabled(){return e.disabled},onClick:()=>{var a;return(a=e.onVoice)==null?void 0:a.call(e)},get children(){return t(Y,{class:"size-4"})}})}}),null),c(n,t(k,{get each(){return e.toolbarActions??[]},children:a=>{const f=K(a.icon),C=a.tooltip??a.label,I=t(m,{type:"button",variant:"outline",size:"icon-sm",class:"rounded-full",get"aria-label"(){return a.label},get"data-action"(){return a.id},get disabled(){return e.disabled},onClick:()=>{var p;return(p=e.onAction)==null?void 0:p.call(e,a.id)},get children(){return t(g,{when:f,get fallback(){return(()=>{var p=me();return c(p,()=>a.label),p})()},children:p=>{const R=p();return t(R,{class:"size-4"})}})}});return f?t(O,{content:C,children:I}):I}}),null),n})(),(()=>{var n=pe(),o=n.firstChild;return o._$owner=S(),c(n,t(g,{get when(){return s()},get fallback(){return t(g,{get when(){return $()},get children(){return t(m,{size:"icon-sm",class:"rounded-full",part:"send","data-testid":"send","aria-label":"Send message",get disabled(){return w()},get onClick(){return e.onSubmit},get children(){return be()}})}})},get children(){return t(m,{size:"icon-sm",variant:"outline",class:"rounded-full","data-testid":"stop","aria-label":"Stop",get onClick(){return e.onStop},get children(){return t(re,{class:"size-3"})}})}}),null),n})()]}})]}})]}export{ve as D};
|