@alwith/module-chat 0.1.26 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/activity-host.js +1 -1
- package/dist/approval/choice-elicitation-form.js +1 -1
- package/dist/approval/permission-options.js +1 -1
- package/dist/approval/permission-view.js +1 -1
- package/dist/approval/schema-elicitation-form.js +1 -1
- package/dist/approval/url-elicitation-card.js +1 -1
- package/dist/chunk-25na55ve.js +2 -0
- package/dist/{chunk-ymka3s33.js → chunk-341yykkp.js} +1 -1
- package/dist/{chunk-10yvvt3h.js → chunk-70sfgw0j.js} +2 -2
- package/dist/{chunk-9npx3fhh.js → chunk-74phx7h8.js} +1 -1
- package/dist/{chunk-xgy0heva.js → chunk-7pr2j1zb.js} +1 -1
- package/dist/{chunk-e05fnqjq.js → chunk-7tj0a2na.js} +2 -2
- package/dist/{chunk-0wtckvss.js → chunk-8zs8vy0q.js} +1 -1
- package/dist/{chunk-vghme4ag.js → chunk-9me7jmzd.js} +2 -2
- package/dist/{chunk-h7vdhe9r.js → chunk-awbgf3hp.js} +2 -2
- package/dist/{chunk-gsn2bext.js → chunk-ax9ganqr.js} +2 -2
- package/dist/{chunk-1cy1j8gj.js → chunk-bhvtt6tv.js} +2 -2
- package/dist/chunk-darkfx1b.js +2 -0
- package/dist/{chunk-3rttyj3m.js → chunk-etvhn65g.js} +2 -2
- package/dist/{chunk-f5syjtnd.js → chunk-f20xh0z9.js} +1 -1
- package/dist/chunk-g20b01rn.js +2 -0
- package/dist/{chunk-c54yh2t2.js → chunk-ghfbzhnb.js} +1 -1
- package/dist/{chunk-mfphmgy1.js → chunk-gycty1x1.js} +2 -2
- package/dist/{chunk-f773g8wv.js → chunk-hnt4tt1n.js} +2 -2
- package/dist/{chunk-6yc96p86.js → chunk-hy1x2td2.js} +1 -1
- package/dist/{chunk-8d3t4bmf.js → chunk-k1c0jrk1.js} +1 -1
- package/dist/{chunk-bgmsrs7h.js → chunk-kj1wrn2j.js} +1 -1
- package/dist/{chunk-ekhe60qa.js → chunk-kzccs8ak.js} +2 -2
- package/dist/{chunk-gj85c3gx.js → chunk-p9wpghey.js} +2 -2
- package/dist/{chunk-n9mnvxs4.js → chunk-qj8r5xvx.js} +2 -2
- package/dist/{chunk-2kb5qj2v.js → chunk-qyhgwc51.js} +2 -2
- package/dist/{chunk-55zxk0m8.js → chunk-rakd7vzb.js} +1 -1
- package/dist/chunk-reqrpvyy.js +2 -0
- package/dist/{chunk-1nr8t8ar.js → chunk-s0nhgptn.js} +1 -1
- package/dist/{chunk-095yr4wk.js → chunk-s28x10qd.js} +1 -1
- package/dist/{chunk-6zj9rdvw.js → chunk-s3z33k7f.js} +1 -1
- package/dist/{chunk-6c610cwg.js → chunk-skx67pc6.js} +1 -1
- package/dist/{chunk-fr3n6fk5.js → chunk-swg5v7sg.js} +2 -2
- package/dist/{chunk-8n7st0js.js → chunk-wc3patey.js} +2 -2
- package/dist/{chunk-7fn3yt0k.js → chunk-wtkv29ba.js} +1 -1
- package/dist/{chunk-6rrnp8ha.js → chunk-y2xbq7rb.js} +3 -3
- package/dist/{chunk-etj5bb5a.js → chunk-ynga7fm4.js} +3 -3
- package/dist/codex/activity-group.js +1 -1
- package/dist/codex/assistant-message.js +2 -2
- package/dist/codex/async-question-card.js +1 -1
- package/dist/codex/edited-files-card.js +1 -1
- package/dist/codex/image-view-activity.js +1 -1
- package/dist/codex/markdown-renderer.js +4 -4
- package/dist/codex/navigation-rail.css +216 -1
- package/dist/codex/navigation-rail.js +1 -1
- package/dist/codex/thread-virtualizer.js +1 -1
- package/dist/codex/user-message.js +1 -1
- package/dist/codex/virtualized-turn-list.js +1 -1
- package/dist/composer/completion-filter.js +1 -1
- package/dist/composer/completion-menu.js +2 -2
- package/dist/composer/completion-trigger.js +1 -1
- package/dist/composer/effort-slider.js +1 -1
- package/dist/composer/menu-radio.js +1 -1
- package/dist/composer/model-select.js +1 -1
- package/dist/composer/permission-mode-select.js +1 -1
- package/dist/composer/prompt-input-attachments.js +1 -1
- package/dist/composer/prompt-input-clipboard.js +1 -1
- package/dist/composer/prompt-input-context.js +1 -1
- package/dist/composer/prompt-input-textarea.js +1 -1
- package/dist/composer/prompt-input.js +1 -1
- package/dist/image-preview-dialog.js +1 -1
- package/dist/lib/code-highlighter.js +1 -1
- package/dist/lib/fuzzy.js +1 -1
- package/dist/lib/group-blocks.js +1 -1
- package/dist/lib/limits.js +1 -1
- package/dist/lib/markdown-parser.js +1 -1
- package/dist/lib/markdown-parser.worker.js +66 -1
- package/dist/lib/markdown-rules.js +1 -1
- package/dist/lib/model-name.js +1 -1
- package/dist/lib/pointer-centered-zoom.js +1 -1
- package/dist/lib/stream-style.js +1 -1
- package/dist/lib/streaming-markdown.js +2 -1
- package/dist/search/chat-search.js +1 -1
- package/dist/search/dom-matches.js +1 -1
- package/dist/search/find-bar.js +1 -1
- package/dist/search/literal-matches.js +1 -1
- package/dist/ui/badge.js +1 -1
- package/dist/ui/button.js +1 -1
- package/dist/ui/card.js +1 -1
- package/dist/ui/dialog.js +1 -1
- package/dist/ui/dropdown-menu.js +1 -1
- package/dist/ui/field.js +1 -1
- package/dist/ui/input-group.js +1 -1
- package/dist/ui/separator.js +1 -1
- package/dist/ui/switch.js +1 -1
- package/dist/ui/tooltip.js +1 -1
- package/package.json +10 -3
- package/dist/chunk-1s523gek.js +0 -2
- package/dist/chunk-am0ge8nt.js +0 -2
- package/dist/chunk-gp69a45h.js +0 -2
- package/dist/chunk-j9hhbm77.js +0 -3
- package/dist/chunk-zb5h5p7y.js +0 -2
|
@@ -1 +1,216 @@
|
|
|
1
|
-
.thread-user-message-navigation
|
|
1
|
+
.thread-user-message-navigation {
|
|
2
|
+
animation: thread-user-message-navigation-enter 150ms cubic-bezier(0.23, 1, 0.32, 1) both;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.thread-user-message-navigation-rail-list {
|
|
6
|
+
--edge-fade-distance: 2.5rem;
|
|
7
|
+
display: flex;
|
|
8
|
+
max-height: min(70vh, 40rem);
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
overflow-y: auto;
|
|
11
|
+
overscroll-behavior: contain;
|
|
12
|
+
scrollbar-width: none;
|
|
13
|
+
mask: linear-gradient(
|
|
14
|
+
to bottom in oklch,
|
|
15
|
+
oklch(60% 0 0 / 0),
|
|
16
|
+
oklch(85% 0 0) var(--top-fade) calc(100% - var(--bottom-fade)),
|
|
17
|
+
oklch(60% 0 0 / 0)
|
|
18
|
+
);
|
|
19
|
+
animation-name: thread-user-message-navigation-edge-fade;
|
|
20
|
+
animation-timing-function: linear;
|
|
21
|
+
animation-fill-mode: both;
|
|
22
|
+
animation-timeline: scroll(self y);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.thread-user-message-navigation-rail-list::-webkit-scrollbar {
|
|
26
|
+
display: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.thread-user-message-navigation-row {
|
|
30
|
+
display: flex;
|
|
31
|
+
width: 36px;
|
|
32
|
+
height: 10px;
|
|
33
|
+
flex-shrink: 0;
|
|
34
|
+
align-items: center;
|
|
35
|
+
cursor: default;
|
|
36
|
+
outline: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.thread-user-message-navigation-marker {
|
|
40
|
+
--marker-progress: 0;
|
|
41
|
+
width: 26px;
|
|
42
|
+
height: 2px;
|
|
43
|
+
background-color: var(--muted-foreground);
|
|
44
|
+
opacity: 0.4;
|
|
45
|
+
transform: scaleX(calc(0.2308 + 0.7692 * var(--marker-progress)));
|
|
46
|
+
transform-origin: left;
|
|
47
|
+
transition: transform 160ms
|
|
48
|
+
linear(0, 0.398 10%, 0.682 20%, 0.843 30%, 0.925 40%, 0.972 50%, 1.004 60%, 1.008 70%, 1.003 80%, 1);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.thread-user-message-navigation-marker:dir(rtl) {
|
|
52
|
+
transform-origin: right;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
:is(
|
|
56
|
+
.thread-user-message-navigation-row:has(+ .thread-user-message-navigation-row[data-scrub-target]),
|
|
57
|
+
.thread-user-message-navigation-row[data-scrub-target] + .thread-user-message-navigation-row
|
|
58
|
+
)
|
|
59
|
+
.thread-user-message-navigation-marker {
|
|
60
|
+
--marker-progress: 0.7;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
:is(
|
|
64
|
+
.thread-user-message-navigation-row:has(
|
|
65
|
+
+ .thread-user-message-navigation-row + .thread-user-message-navigation-row[data-scrub-target]
|
|
66
|
+
),
|
|
67
|
+
.thread-user-message-navigation-row[data-scrub-target]
|
|
68
|
+
+ .thread-user-message-navigation-row
|
|
69
|
+
+ .thread-user-message-navigation-row
|
|
70
|
+
)
|
|
71
|
+
.thread-user-message-navigation-marker {
|
|
72
|
+
--marker-progress: 0.4;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
:is(
|
|
76
|
+
.thread-user-message-navigation-row:has(
|
|
77
|
+
+ .thread-user-message-navigation-row
|
|
78
|
+
+ .thread-user-message-navigation-row
|
|
79
|
+
+ .thread-user-message-navigation-row[data-scrub-target]
|
|
80
|
+
),
|
|
81
|
+
.thread-user-message-navigation-row[data-scrub-target]
|
|
82
|
+
+ .thread-user-message-navigation-row
|
|
83
|
+
+ .thread-user-message-navigation-row
|
|
84
|
+
+ .thread-user-message-navigation-row
|
|
85
|
+
)
|
|
86
|
+
.thread-user-message-navigation-marker {
|
|
87
|
+
--marker-progress: 0.2;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.thread-user-message-navigation-row[aria-current="true"] .thread-user-message-navigation-marker {
|
|
91
|
+
background-color: var(--foreground);
|
|
92
|
+
opacity: 0.6;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
:is(.thread-user-message-navigation-row:focus-visible, .thread-user-message-navigation-row[data-scrub-target])
|
|
96
|
+
.thread-user-message-navigation-marker {
|
|
97
|
+
--marker-progress: 1;
|
|
98
|
+
background-color: var(--foreground);
|
|
99
|
+
opacity: 1;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.thread-user-message-navigation-rail-list[data-scrubbing] .thread-user-message-navigation-marker {
|
|
103
|
+
transition-duration: 0s;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.thread-user-message-navigation-rail-list[data-scrubbing]
|
|
107
|
+
.thread-user-message-navigation-row[aria-current="true"]:not([data-scrub-target])
|
|
108
|
+
.thread-user-message-navigation-marker {
|
|
109
|
+
background-color: var(--muted-foreground);
|
|
110
|
+
opacity: 0.4;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@media (hover: hover) and (pointer: fine) {
|
|
114
|
+
.thread-user-message-navigation-rail-list:not([data-scrubbing]):hover
|
|
115
|
+
.thread-user-message-navigation-row[aria-current="true"]:not(:hover):not(:focus-visible)
|
|
116
|
+
.thread-user-message-navigation-marker {
|
|
117
|
+
background-color: var(--muted-foreground);
|
|
118
|
+
opacity: 0.4;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
:is(
|
|
122
|
+
.thread-user-message-navigation-rail-list:not([data-scrubbing])
|
|
123
|
+
.thread-user-message-navigation-row:has(+ .thread-user-message-navigation-row:hover),
|
|
124
|
+
.thread-user-message-navigation-rail-list:not([data-scrubbing])
|
|
125
|
+
.thread-user-message-navigation-row:hover
|
|
126
|
+
+ .thread-user-message-navigation-row
|
|
127
|
+
)
|
|
128
|
+
.thread-user-message-navigation-marker {
|
|
129
|
+
--marker-progress: 0.7;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
:is(
|
|
133
|
+
.thread-user-message-navigation-rail-list:not([data-scrubbing])
|
|
134
|
+
.thread-user-message-navigation-row:has(
|
|
135
|
+
+ .thread-user-message-navigation-row + .thread-user-message-navigation-row:hover
|
|
136
|
+
),
|
|
137
|
+
.thread-user-message-navigation-rail-list:not([data-scrubbing])
|
|
138
|
+
.thread-user-message-navigation-row:hover
|
|
139
|
+
+ .thread-user-message-navigation-row
|
|
140
|
+
+ .thread-user-message-navigation-row
|
|
141
|
+
)
|
|
142
|
+
.thread-user-message-navigation-marker {
|
|
143
|
+
--marker-progress: 0.4;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
:is(
|
|
147
|
+
.thread-user-message-navigation-rail-list:not([data-scrubbing])
|
|
148
|
+
.thread-user-message-navigation-row:has(
|
|
149
|
+
+ .thread-user-message-navigation-row
|
|
150
|
+
+ .thread-user-message-navigation-row
|
|
151
|
+
+ .thread-user-message-navigation-row:hover
|
|
152
|
+
),
|
|
153
|
+
.thread-user-message-navigation-rail-list:not([data-scrubbing])
|
|
154
|
+
.thread-user-message-navigation-row:hover
|
|
155
|
+
+ .thread-user-message-navigation-row
|
|
156
|
+
+ .thread-user-message-navigation-row
|
|
157
|
+
+ .thread-user-message-navigation-row
|
|
158
|
+
)
|
|
159
|
+
.thread-user-message-navigation-marker {
|
|
160
|
+
--marker-progress: 0.2;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.thread-user-message-navigation-rail-list:not([data-scrubbing])
|
|
164
|
+
.thread-user-message-navigation-row:hover
|
|
165
|
+
.thread-user-message-navigation-marker {
|
|
166
|
+
--marker-progress: 1;
|
|
167
|
+
background-color: var(--foreground);
|
|
168
|
+
opacity: 1;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@media (prefers-reduced-motion: reduce) {
|
|
173
|
+
.thread-user-message-navigation {
|
|
174
|
+
animation-duration: 0s;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.thread-user-message-navigation-marker {
|
|
178
|
+
transition-duration: 0s;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@keyframes thread-user-message-navigation-enter {
|
|
183
|
+
from {
|
|
184
|
+
opacity: 0;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
to {
|
|
188
|
+
opacity: 1;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@keyframes thread-user-message-navigation-edge-fade {
|
|
193
|
+
0%,
|
|
194
|
+
1% {
|
|
195
|
+
--top-fade: 0;
|
|
196
|
+
--bottom-fade: var(--edge-fade-distance);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
99%,
|
|
200
|
+
100% {
|
|
201
|
+
--top-fade: var(--edge-fade-distance);
|
|
202
|
+
--bottom-fade: 0;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
@property --top-fade {
|
|
207
|
+
syntax: "<length>";
|
|
208
|
+
inherits: false;
|
|
209
|
+
initial-value: 0;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
@property --bottom-fade {
|
|
213
|
+
syntax: "<length>";
|
|
214
|
+
inherits: false;
|
|
215
|
+
initial-value: 0;
|
|
216
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{me}from"../chunk-dekjd5sf.js";import{useCallback as
|
|
1
|
+
import{me}from"../chunk-dekjd5sf.js";import{useCallback as xe,useEffect as P,useLayoutEffect as ye,useMemo as Q,useRef as I,useState as E}from"react";import"@alwith/module-chat/navigation-rail.css";import{jsxDEV as h,Fragment as Ne}from"react/jsx-dev-runtime";var we=4,ge=10;function Se(T,x){let v=new Map(x.flatMap((c)=>c.itemIds.map((w)=>[w,c.key]))),p=Array(T.length),C;for(let c=T.length-1;c>=0;c--)C=v.get(T[c])??C,p[c]=C;let O=Math.max(-1,...x.map((c)=>c.key))+1,B=new Set,n=[];for(let[c,w]of T.entries()){let S=v.get(w),g=n.at(-1);if(!g||S!==void 0&&S!==g.key||S===void 0&&g.itemIds.length>=64&&p[c]!==g.key){let y=S!==void 0&&!B.has(S)?S:O++;g={key:y,startIndex:c,itemIds:[]},n.push(g),B.add(y)}g.itemIds.push(w)}return n}function fe(T,x){if(T.size!==x.size)return!1;for(let v of T)if(!x.has(v))return!1;return!0}function Le({audio:T,beforeReveal:x,ensureItemMounted:v,items:p,onPreviewItem:C,renderPreview:O,onRevealError:B,scrollRoot:n,targetTopMarginPx:c=16}){let[w,S]=E(()=>{let e=p.at(-1);return new Set(e===void 0?[]:[e.id])}),[g,y]=E(null),[W,A]=E(null),[X,U]=E(!1),[_,pe]=E(()=>new Set),[ve,be]=E(!0),[Ie,j]=E(null),{installUnlock:Z,preload:ee,playSequence:te}=T,K=I(null),M=I(null),R=I(!1),H=I(null),L=I(0),N=I(null),G=I(new Set),V=Q(()=>p.map((e)=>e.id).join("\x00"),[p]),F=I(p);F.current=p;let ne=I(_),re=I(w),ie=I({itemIdsKey:V,scrollRoot:n});if(ie.current.scrollRoot!==n)L.current+=1,ie.current={itemIdsKey:V,scrollRoot:n};let m=Q(()=>v===void 0?p.filter((e)=>_.has(e.id)):p,[v,p,_]),se=Q(()=>m.map((e)=>({inputTokens:e.inputTokens,outputTokens:e.outputTokens})),[m]),z=I({ids:"",groups:[]}),ae=m.map((e)=>e.id).join("\x00");if(z.current.ids!==ae)z.current={ids:ae,groups:Se(m.map((e)=>e.id),z.current.groups)};P(()=>Z(),[Z]),P(()=>()=>{if(L.current+=1,N.current!==null)clearTimeout(N.current)},[]),P(()=>{y(null),U(!1),A(null),M.current=null,R.current=!1,H.current=null,j(null),G.current.clear()},[n]),P(()=>{ee()},[ee]),P(()=>{if(n===null)return;let e=new Set,t=new Map,r=new Set(F.current.map((o)=>o.id)),i=()=>{let o=new Set(t.values()),l=F.current.filter((f)=>o.has(f.id)).map((f)=>f.id),u=l.findIndex((f)=>e.has(f));if(u===-1)return;let b=u;for(let f=u+1;f<l.length;f++)if(e.has(l[f]))b=f;let k=new Set(l.slice(u,b+1));if(fe(re.current,k))return;re.current=k,S(k)},s=new IntersectionObserver((o)=>{for(let l of o){let u=t.get(l.target);if(l.isIntersecting)e.add(u);else e.delete(u)}i()},{root:n,rootMargin:`-${c}px 0px 0px 0px`}),a=()=>{let o=new Set,l=new Set;for(let u of n.querySelectorAll("[data-content-search-unit-key]")){let b=u.dataset.contentSearchUnitKey;if(b===void 0||!r.has(b)||o.has(b))continue;o.add(b);let k=u.closest("[data-turn-key]"),f=k===null||l.has(k)?u:k;if(l.add(f),t.has(f))continue;t.set(f,b),s.observe(f)}for(let u of t.keys()){if(l.has(u))continue;s.unobserve(u),e.delete(t.get(u)),t.delete(u)}if(i(),fe(ne.current,o))return;ne.current=o,pe(o)};a();let d=new MutationObserver((o)=>{if(o.some((u)=>[...u.addedNodes,...u.removedNodes].some((b)=>b instanceof Element&&(b.matches("[data-turn-key], [data-content-search-unit-key]")||b.querySelector("[data-turn-key], [data-content-search-unit-key]")!==null))))a()});return d.observe(n,{childList:!0,subtree:!0}),()=>{d.disconnect(),s.disconnect()}},[V,n,c]);let J=m.find((e)=>w.has(e.id))?.id??m.at(-1)?.id;ye(()=>{let e=K.current;if(e===null||M.current!==null||J===void 0)return;let t=e.querySelector(`[data-thread-user-message-navigation-item-id="${CSS.escape(J)}"]`);if(t===null)return;let r=e.getBoundingClientRect(),i=t.getBoundingClientRect();if(i.top<r.top)e.scrollTop+=i.top-r.top;else if(i.bottom>r.bottom)e.scrollTop+=i.bottom-r.bottom+1},[J,V]),P(()=>{let e=n?.querySelector("[data-thread-user-message-navigation-content]");if(!n||!e)return;let t=()=>{let i=n.getBoundingClientRect(),s=e.getBoundingClientRect();if(i.width===0||s.width===0)return;let a=n.offsetWidth>0?i.width/n.offsetWidth:1;be((s.left-i.left)/a>=48)},r=new ResizeObserver(t);return r.observe(n),r.observe(e),t(),()=>r.disconnect()},[n]);let he=xe(async(e,t="smooth")=>{if(n===null)throw Error("Thread user-message navigation scroll root is missing");let r=L.current+1;L.current=r,x();let i=()=>n.querySelector(`[data-content-search-unit-key="${CSS.escape(e.id)}"]`),s=i(),a=s!==null&&n.clientHeight>0&&s.closest("[data-turn-key]")!==null&&Math.abs(s.getBoundingClientRect().top-n.getBoundingClientRect().top)>n.clientHeight*2;if((s===null||a)&&v!==void 0){if(t==="instant"&&e.isLoaded===!1)return;s=await v(e,()=>L.current===r)??i(),t="instant"}if(L.current!==r)return;if(s===null)return;let d=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;s.scrollIntoView({behavior:d?"instant":t,block:"start"}),s.querySelector("[data-user-message-bubble], [data-composer-attachment-pill]")?.animate?.([{backgroundColor:"color-mix(in srgb, var(--foreground) 14%, transparent)"},{backgroundColor:"color-mix(in srgb, var(--foreground) 14%, transparent)",offset:0.35},{backgroundColor:"transparent"}],{duration:d?0:1000,easing:"cubic-bezier(0.23, 1, 0.32, 1)"})},[x,v,n]);if(m.length<we||!ve)return null;let Y=()=>{if(N.current!==null)clearTimeout(N.current);N.current=null},oe=(e,t=!1)=>{if(Y(),C===void 0||e.isLoaded!==!1||G.current.has(e.turnKey))return;let r=()=>{N.current=null,G.current.add(e.turnKey),C(e).catch(()=>G.current.delete(e.turnKey))};if(t)r();else N.current=setTimeout(r,150)},q=g===null?null:m.find((e)=>e.id===g.item.id)??m.find((e)=>e.nativeTurnId!==void 0&&e.nativeTurnId===g.item.nativeTurnId)??g.item,ue=(e,t="smooth")=>{he(e,t).catch((r)=>{if(B)B(r);else throw r})},de=m.findIndex((e)=>e.id===(W??Ie)),le=K.current,Te=g===null||!le?.contains(g.button)?0:Me(le,g.button),ce=(e)=>{let t=e?.closest("[data-thread-user-message-navigation-item-id]"),r=K.current;if(t===void 0||t===null||!r.contains(t))return null;let i=t.dataset.threadUserMessageNavigationItemId,s=m.findIndex((a)=>a.id===i);return{button:t,item:m[s],index:s}},D=(e)=>{let t=M.current;if(t?.pointerId!==e.pointerId)return;if(M.current=null,A(null),t.captureTarget.hasPointerCapture(e.pointerId))t.captureTarget.releasePointerCapture(e.pointerId)};return h("nav",{"aria-label":"User messages",className:"thread-user-message-navigation absolute start-4 top-1/2 z-20 -translate-y-1/2",children:h(me,{open:X,onOpenChange:U,side:"inline-end",sideOffset:0,align:"center",alignOffset:Te,trigger:h("div",{ref:K,"data-thread-user-message-navigation-rail-list":!0,"data-scrubbing":W===null?void 0:"",className:"thread-user-message-navigation-rail-list",onPointerEnter:()=>{H.current=null},onPointerDown:(e)=>{if(e.button!==0)return;Y();let t=ce(e.target instanceof Element?e.target:null);if(t===null)return;R.current=!1,M.current={pointerId:e.pointerId,itemId:t.item.id,itemIndex:t.index,captureTarget:t.button},t.button.setPointerCapture(e.pointerId),A(t.item.id),y(t),U(!0)},onPointerMove:(e)=>{let t=M.current;if(t===null){let d=ce(e.target instanceof Element?e.target:null);if(d!==null){j(d.item.id);let o=H.current;if(o!==null&&o!==d.index)te(o,d.index,se);H.current=d.index,y((l)=>l?.item.id===d.item.id?l:d),oe(d.item)}return}if(t.pointerId!==e.pointerId)return;if((e.buttons&1)===0){D(e);return}let r=e.currentTarget.getBoundingClientRect(),i=Math.max(0,Math.min(m.length-1,Math.floor((e.clientY-r.top+e.currentTarget.scrollTop)/ge))),a={button:e.currentTarget.querySelectorAll("[data-thread-user-message-navigation-item-id]")[i],item:m[i],index:i};if(a.item.id===t.itemId)return;te(t.itemIndex,a.index,se),H.current=a.index,M.current={...t,itemId:a.item.id,itemIndex:a.index},R.current=!0,A(a.item.id),y(a),ue(a.item,"instant")},onPointerUp:D,onPointerCancel:D,onLostPointerCapture:D,onPointerLeave:()=>{if(Y(),j(null),H.current=null,M.current===null&&!X)y(null)},children:h("div",{className:"flex flex-col",children:z.current.groups.map((e)=>h("div",{className:"flex w-9 shrink-0 flex-col [content-visibility:auto]",style:{height:e.itemIds.length*ge},children:m.slice(e.startIndex,e.startIndex+e.itemIds.length).map((t,r)=>{let i=e.startIndex+r,s=Math.abs(i-de),a=de===-1||s>3?void 0:[1,0.7,0.4,0.2][s];return h("button",{type:"button","data-thread-user-message-navigation-item-id":t.id,"data-scrub-target":W===t.id?"":void 0,"aria-current":w.has(t.id)?"true":void 0,"aria-label":`Jump to user message ${i+1}`,className:"thread-user-message-navigation-row",onClick:(d)=>{if(R.current){R.current=!1;return}let o={button:d.currentTarget,item:t,index:i};y(o),U(!0),ue(t)},onFocus:(d)=>{oe(t,!0),y({button:d.currentTarget,item:t,index:i}),U(!0)},children:h("span",{className:"flex h-0.5 w-[30px] items-center",children:h("span",{className:"thread-user-message-navigation-marker",style:a===void 0?void 0:{"--marker-progress":a}},void 0,!1,void 0,this)},void 0,!1,void 0,this)},t.id,!1,void 0,this)})},e.key,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),children:q!==null&&h("div",{className:"bg-popover/95 text-popover-foreground ring-border w-80 max-w-[calc(100vw-1rem)] overflow-hidden rounded-xl p-2 text-sm leading-5 shadow-xl ring-[0.5px] backdrop-blur-sm",children:O?O(q):h(Ne,{children:[h("div",{className:"min-w-0 truncate font-medium",children:q.label},void 0,!1,void 0,this),q.response.length>0&&h("div",{className:"text-muted-foreground mt-1 line-clamp-3",children:q.response},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function Me(T,x){let v=T.getBoundingClientRect(),p=x.getBoundingClientRect();return p.top+p.height/2-(v.top+v.height/2)}export{Le as ThreadUserMessageNavigationRail};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{vt,pe,g,K,ge,fe,he}from"../chunk-swg5v7sg.js";export{vt as CODEX_UNKNOWN_TURN_HEIGHT,g as calculateCodexThreadVirtualRange,fe as calculateCodexTurnCenterDistanceFromBottom,he as calculateCodexTurnTargetDistanceFromBottom,pe as createCodexThreadVirtualLayout,ge as preserveCodexThreadDistanceFromBottom,K as preserveCodexThreadRenderedWindow};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{W,bt}from"../chunk-ax9ganqr.js";import"../chunk-8bdd6q4w.js";export{bt as CodexUserMessage,W as CopyAction};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{pe,g,K,ge,fe,he}from"../chunk-swg5v7sg.js";import{forwardRef as Te,useCallback as L,useEffect as xe,useImperativeHandle as be,useLayoutEffect as M,useMemo as ie,useRef as s,useState as N}from"react";import{jsxDEV as m}from"react/jsx-dev-runtime";var Pe=12,J=2,W=800,ye=new Map;function Be({turnKey:_,heightPx:v,placeholder:U=!1,deferUntilReady:n=!1,observe:T,onReady:C,children:k}){let f=s(null),[b,G]=N(!1),X=L((x)=>{f.current=x,T(_,x)},[T,_]);return M(()=>{let x=f.current;if(x===null)throw Error("Codex turn element is missing");let P=()=>{C(x),G(!0)};if(x.querySelector("[data-markdown-pending]")===null){P();return}let d=new MutationObserver(()=>{if(x.querySelector("[data-markdown-pending]")!==null)return;d.disconnect(),P()});return d.observe(x,{childList:!0,subtree:!0}),()=>d.disconnect()},[C]),m("div",{style:b?void 0:{position:"relative",height:v,overflow:"hidden"},children:[m("div",{ref:X,className:"[&_[data-virtualized-turn-content]]:[content-visibility:visible]","data-turn-key":_,"aria-busy":!b||void 0,style:!b&&!U&&n?{visibility:"hidden"}:void 0,"data-turn-ready":b?"":void 0,children:k},void 0,!1,void 0,this),!b&&!U&&n&&m("div",{"aria-hidden":"true",className:"codex-turn-loading",children:m("div",{className:"codex-turn-loading-lines",children:[m("span",{},void 0,!1,void 0,this),m("span",{},void 0,!1,void 0,this),m("span",{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Me=Te(function({entries:v,renderTurn:U,scrollElement:n,sessionKey:T,leadingContent:C,leadingInsetPx:k=0,preserveViewport:f=!1},b){let G=s(null),[X,x]=N(k),P=C!==void 0&&C!==null;M(()=>{let e=G.current;if(e===null)return;let t=()=>x(e.getBoundingClientRect().height);t();let o=new ResizeObserver(t);return o.observe(e),()=>o.disconnect()},[P]);let d=ie(()=>ye.get(T),[T]),[Q,Y]=N(()=>d?.turnHeightsByKey??{}),i=ie(()=>pe({entries:v,gapPx:Pe,measuredHeightsByKey:Q,leadingInsetPx:P?X:k}),[v,Q,P,X,k]),ve=ie(()=>{let e=g({distanceFromBottomPx:d?.distanceFromBottomPx??0,layout:i,overscanCount:J,viewportHeightPx:W}),t=d?.renderedWindow;if(t===void 0||t===null)return e;return K({anchorKey:t.anchorKey,layout:i,previousRange:{startIndex:0,endIndex:Math.min(t.count,e.endIndex-e.startIndex)}})??e},[d,i]),[I,oe]=N(ve),[p,ue]=N(W),[c,ae]=N(null),S=s(d?.distanceFromBottomPx??0),E=s(I),se=s(i.turnKeys),l=s(Q),D=s(i),ce=s(i),B=s(new Map),R=s(null),F=s(null),O=s(null),A=s(new Map),Z=s(!1),de=s(()=>{}),V=s(null),le=L(()=>{if(!f||n===null||R.current!==null||V.current!==null)return;let e=n.getBoundingClientRect();if(e.height<=0)return;let t=[...B.current].filter(([,r])=>r.hasAttribute("data-turn-ready")).map(([r,u])=>{let a=u.getBoundingClientRect(),h=D.current.turnIndexByKey.get(r),w=h===void 0?a.height:D.current.heightsPx[h];return{key:r,element:u,rect:a,bottom:a.top+w}}).filter(({rect:r,bottom:u})=>u>e.top&&r.top<e.bottom).toSorted((r,u)=>r.rect.top-u.rect.top),o=t.flatMap((r)=>[...r.element.querySelectorAll("[data-user-message-bubble], .codex-markdown-root > *")].filter((u)=>!u.closest('[aria-hidden="true"], [inert]')).map((u)=>({key:r.key,element:u,rect:u.getBoundingClientRect()})).filter(({rect:u})=>u.height>0&&u.top>=e.top&&u.top<e.bottom)).toSorted((r,u)=>r.rect.top-u.rect.top)[0]??t[0];if(o)V.current={key:o.key,element:o.element,top:o.rect.top-e.top,scrollTop:n.scrollTop}},[f,n]),ee=s(le);ee.current=le;let H=L((e,t)=>{let o=Math.min(e,i.totalHeightPx),r=g({distanceFromBottomPx:o,layout:i,overscanCount:J,viewportHeightPx:t}),u=E.current,a=u.startIndex<=r.startIndex&&u.endIndex>=r.endIndex?u:r;if(S.current=o,E.current=a,se.current=i.turnKeys,ue(t),a!==u)oe(a)},[i]),q=L((e)=>{let t=Math.max(0,e.scrollHeight-i.totalHeightPx);return Math.max(0,e.scrollHeight-e.clientHeight-e.scrollTop-t)},[i.totalHeightPx]),Re=L((e)=>{let t=e.dataset.turnKey;if(t===void 0)throw Error("Codex measured turn is missing its key");let o=Math.max(1,e.getBoundingClientRect().height);if(l.current[t]===o)return;ee.current();let r={...l.current,[t]:o};l.current=r,Y(r)},[]),te=L(()=>{if(F.current!==null)return F.current;return F.current=new ResizeObserver((e)=>{for(let t of e){let o=t.target;if(!("turnReady"in o.dataset)&&o.querySelector("[data-markdown-pending]")!==null)continue;let r=o.dataset.turnKey;if(r===void 0)throw Error("Codex measured turn is missing its key");let u=Math.max(1,t.borderBoxSize[0]?.blockSize??t.contentRect.height);A.current.set(r,u)}if(O.current!==null||A.current.size===0)return;O.current=requestAnimationFrame(()=>{O.current=null;let t=[...A.current].filter(([r,u])=>l.current[r]!==u);if(A.current.clear(),t.length===0)return;ee.current();let o={...l.current,...Object.fromEntries(t)};l.current=o,Y(o)})}),F.current},[]),He=L((e,t)=>{let o=B.current.get(e);if(o!==void 0)te().unobserve(o),B.current.delete(e);if(t===null)return;if(t.dataset.turnKey!==e)throw Error(`Codex turn key does not match its element: ${e}`);B.current.set(e,t),te().observe(t)},[te]);xe(()=>()=>{if(F.current?.disconnect(),O.current!==null)cancelAnimationFrame(O.current);A.current.clear(),F.current=null,B.current.clear()},[]),M(()=>{de.current=()=>{if(n===null)return;let e=q(n);if(R.current!==null){S.current=e,ue(n.clientHeight||W);return}H(e,n.clientHeight||W)}},[q,n,H]),M(()=>{if(n===null)return;if(!Z.current){Z.current=!0;let o=d?.distanceFromBottomPx??0;n.scrollTo({behavior:"instant",top:Math.max(0,o>0?D.current.totalHeightPx-n.clientHeight-o:n.scrollHeight-n.clientHeight)})}let e=()=>de.current();e(),n.addEventListener("scroll",e,{passive:!0});let t=new ResizeObserver(e);return t.observe(n),()=>{n.removeEventListener("scroll",e),t.disconnect()}},[d,n]),M(()=>{if(n===null||c===null)return;let e=B.current.get(c.turnKey);if(e?.querySelector("[data-markdown-pending]")!==null)return;let t=e.offsetHeight;if(t<=0)return;if(l.current[c.turnKey]!==t){let h={...l.current,[c.turnKey]:t};l.current=h,Y(h);return}let o=c.getTargetElement(e)??e,r=e.getBoundingClientRect(),u=o.getBoundingClientRect(),a=he({align:c.align,layout:i,targetHeightPx:u.height,targetOffsetPx:u.top-r.top,turnKey:c.turnKey,viewportHeightPx:n.clientHeight});if(a===null)throw Error(`Codex virtual turn is missing: ${c.turnKey}`);n.scrollTo({behavior:"instant",top:Math.max(0,i.totalHeightPx-n.clientHeight-a)}),H(a,n.clientHeight||W),queueMicrotask(()=>{if(R.current!==c)return;c.complete(),R.current=null,ae(null)})},[i,c,n,H]),M(()=>{let e=ce.current;if(ce.current=i,D.current=i,n===null||c!==null){V.current=null;return}let t=V.current;V.current=null;let o=t===null?void 0:n.contains(t.element)?t.element:B.current.get(t.key);if(f&&e!==i&&t!==null&&o!==void 0){let u=o.getBoundingClientRect().top-n.getBoundingClientRect().top,a=n.scrollTop-t.scrollTop;n.scrollTop+=u-t.top+a,H(q(n),n.clientHeight);return}let r=S.current;if(f&&e!==i&&Z.current)r=Math.max(0,e.totalHeightPx-n.clientHeight-n.scrollTop);if((r>24||f)&&e!==i){let u=q(n);if(u<=96&&!f){H(u,p);return}let a=g({distanceFromBottomPx:r,layout:e,overscanCount:0,viewportHeightPx:p}),h=e.turnKeys.slice(a.startIndex,a.endIndex).filter((y)=>i.turnIndexByKey.has(y)),w=h.find((y)=>l.current[y]!==void 0)??h[0];if(w!==void 0){let y=ge({anchorKey:w,distanceFromBottomPx:r,nextLayout:i,previousLayout:e});if(y===null)throw Error(`Codex viewport anchor is missing: ${w}`);r=y,n.scrollTo({behavior:"instant",top:Math.max(0,i.totalHeightPx-n.clientHeight-r)})}}H(r,p)},[i,c,q,n,H,p,f]),M(()=>{E.current=I},[I]),xe(()=>()=>{R.current?.complete(),R.current=null;let e=E.current,o=D.current.turnKeys[e.startIndex];ye.set(T,{distanceFromBottomPx:S.current,renderedWindow:o===void 0?null:{anchorKey:o,count:e.endIndex-e.startIndex},turnHeightsByKey:l.current})},[T]),be(b,()=>({scrollToKey(e,t=(r)=>r,o={align:"center"}){R.current?.complete();let r=i.turnIndexByKey.get(e);if(r===void 0)throw Error(`Codex virtual turn is missing: ${e}`);let u=i.turnKeys[r],a=fe({layout:i,turnKey:e,viewportHeightPx:p});if(a===null)throw Error(`Codex virtual turn is missing: ${e}`);let h=g({distanceFromBottomPx:a,layout:i,overscanCount:J,viewportHeightPx:p});return E.current=h,oe(h),new Promise((w)=>{let y={align:o.align,complete:w,getTargetElement:t,turnKey:u};R.current=y,ae(y)})}}),[i,p]);let z=I,j=se.current;if(!(j===i.turnKeys||j.length===i.turnKeys.length&&j.every((e,t)=>e===i.turnKeys[t]))){let e=j[I.startIndex];z=(e===void 0?null:K({anchorKey:e,layout:i,previousRange:I}))??g({distanceFromBottomPx:S.current,layout:i,overscanCount:J,viewportHeightPx:p})}let ne=v.length-1,me=v[ne],re=v.slice(z.startIndex,Math.min(z.endIndex,ne)).map((e,t)=>({entry:e,index:z.startIndex+t}));if(me!==void 0)re.push({entry:me,index:ne});return m("div",{"data-codex-thread":!0,"data-codex-virtualized-pending-key":c?.turnKey,"data-codex-virtualized-range":`${z.startIndex}:${z.endIndex}`,"data-codex-virtualized-total-count":v.length,"data-codex-virtualized-turn-count":re.length,className:"relative shrink-0",style:{height:i.totalHeightPx},children:[P&&m("div",{ref:G,"data-codex-thread-leading":!0,className:"absolute inset-x-0 top-0",children:C},void 0,!1,void 0,this),re.map(({entry:e,index:t})=>m("div",{className:"absolute inset-x-0",style:{top:i.topOffsetsPx[t]??0},children:m(Be,{turnKey:e.turnKey,heightPx:i.heightsPx[t],placeholder:e.placeholder,deferUntilReady:e.deferUntilReady,observe:He,onReady:Re,children:U(e,t)},void 0,!1,void 0,this)},e.turnKey,!1,void 0,this))]},void 0,!0,void 0,this)});export{Me as VirtualizedTurnList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{V,xt}from"../chunk-kzccs8ak.js";import"../chunk-hnt4tt1n.js";export{xt as filterFiles,V as filterSlashCommands};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{e}from"../chunk-
|
|
1
|
+
import{e}from"../chunk-7pr2j1zb.js";import{N}from"../chunk-8zs8vy0q.js";import"../chunk-hnt4tt1n.js";import{V}from"../chunk-kzccs8ak.js";import{ue}from"../chunk-bhvtt6tv.js";import{ce}from"../chunk-awbgf3hp.js";import{autoUpdate as rt}from"@floating-ui/dom";import{cn as X}from"cn";import{BookOpenTextIcon as st,FileIcon as it,StoreIcon as lt}from"lucide-react";import{useCallback as ut,useEffect as v,useLayoutEffect as Y,useMemo as Z,useRef as _,useState as g}from"react";import{createPortal as at}from"react-dom";import{jsxDEV as i,Fragment as ct}from"react/jsx-dev-runtime";function wt({handleRef:c,anchorRef:m,commands:T,searchFiles:a,onMention:R,onSearchError:H,fileSearchDebounceMs:C=0,bashMode:A=!1,forcedOpen:l=!1,onForcedOpenChange:f,emptyLabel:F,fileStatusLabels:E,morePlugins:M}){let j=ce(),u=j.textInput.value,[z,K]=g(0),[y,D]=g(null),[b,h]=g(0),U=_(null);v(()=>{let t=c.current?.getTextarea();if(!t)return;let n=()=>K(t.selectionStart??0),o=()=>{if(document.activeElement===t)n()};return t.addEventListener("keyup",n),t.addEventListener("click",n),t.addEventListener("input",n),t.addEventListener("select",n),t.addEventListener("focus",n),document.addEventListener("selectionchange",o),()=>{t.removeEventListener("keyup",n),t.removeEventListener("click",n),t.removeEventListener("input",n),t.removeEventListener("select",n),t.removeEventListener("focus",n),document.removeEventListener("selectionchange",o)}});let W=Z(()=>A&&u.startsWith("!")?null:ue(u,z),[u,z,A]),r=W?.kind==="at"&&!a?null:W,P=`${r?.kind??"forced"}:${r?.query??""}:${l}`,[O,tt]=g(P);if(O!==P)tt(P),h(0);let L=_(null);v(()=>{if(!l){L.current=null;return}if(L.current===null)L.current=u;else if(u!==L.current)f?.(!1)},[l,u,f]);let x=r?.kind==="at"?r.query:null;v(()=>{if(x===null||!a){D(null);return}let t=!0,n=()=>{a(x).then((s)=>{if(t)D({query:x,search:a,items:s})},(s)=>{if(t)D({query:x,search:a,items:[]}),H(s)})},o=C>0?window.setTimeout(n,C):null;if(o===null)n();return()=>{if(t=!1,o!==null)window.clearTimeout(o)}},[x,a,C,H]);let d=Z(()=>{if(r?.kind==="at")return y?.query===r.query&&y.search===a?y.items:[];if(r)return V(T,r.query);if(l)return V(T,"");return[]},[r,l,T,y,a]),[et,q]=g(!1);v(()=>{let t=c.current?.getTextarea();if(!t)return;let n=()=>q(!0),o=()=>{if(q(!1),l)f?.(!1)};return q(document.activeElement===t),t.addEventListener("focus",n),t.addEventListener("blur",o),()=>{t.removeEventListener("focus",n),t.removeEventListener("blur",o)}},[c,l,f]),v(()=>{if(l)c.current?.getTextarea()?.focus()},[l,c]);let p=et&&(r!==null?r.kind==="slash"||d.length>0||!!E:l);v(()=>{if(!p)return;U.current?.querySelector(`[data-idx="${b}"]`)?.scrollIntoView({block:"nearest"})},[b,p]);function Q(t){let n=c.current?.getTextarea();if(!n)return;let o,s;if(r){let B=r.kind==="slash"?`/${t.payload} `:`@${t.label} `;if(o=u.slice(0,r.start)+B+u.slice(r.end),r.kind==="at")R?.(t.payload);s=r.start+B.length}else if(l)o=`${u.length===0||u.endsWith(`
|
|
2
2
|
`)?u:`${u}
|
|
3
|
-
`}/${t.payload} `,s=o.length,f?.(!1);else return;j.textInput.setInput(o),requestAnimationFrame(()=>{n.focus(),n.setSelectionRange(s,s)})}v(()=>{let t=c.current?.getTextarea();if(!t)return;let n=(o)=>{if(!p)return;if(c.current?.isComposing()||o.isComposing||o.keyCode===229)return;if(o.key==="ArrowDown")o.preventDefault(),o.stopPropagation(),h((s)=>d.length===0?0:Math.min(d.length-1,s+1));else if(o.key==="ArrowUp")o.preventDefault(),o.stopPropagation(),h((s)=>Math.max(0,s-1));else if(o.key==="Enter"||o.key==="Tab"){o.preventDefault(),o.stopPropagation();let s=d[b];if(s)
|
|
3
|
+
`}/${t.payload} `,s=o.length,f?.(!1);else return;j.textInput.setInput(o),requestAnimationFrame(()=>{n.focus(),n.setSelectionRange(s,s)})}v(()=>{let t=c.current?.getTextarea();if(!t)return;let n=(o)=>{if(!p)return;if(c.current?.isComposing()||o.isComposing||o.keyCode===229)return;if(o.key==="ArrowDown")o.preventDefault(),o.stopPropagation(),h((s)=>d.length===0?0:Math.min(d.length-1,s+1));else if(o.key==="ArrowUp")o.preventDefault(),o.stopPropagation(),h((s)=>Math.max(0,s-1));else if(o.key==="Enter"||o.key==="Tab"){o.preventDefault(),o.stopPropagation();let s=d[b];if(s)Q(s)}else if(o.key==="Escape")if(o.preventDefault(),o.stopPropagation(),r)K(Math.max(0,r.start-1)),t.setSelectionRange(r.start,r.start);else f?.(!1)};return t.addEventListener("keydown",n,!0),()=>t.removeEventListener("keydown",n,!0)});let[k,G]=g(null),[S,nt]=g(null),I=ut(()=>{let t=m?.current;if(!t)return;let n=t.getBoundingClientRect();G({left:n.left,width:n.width,bottom:window.innerHeight-n.top+8})},[m]);if(Y(()=>{if(!p){G(null);return}I()},[p,I]),Y(()=>{let t=m?.current;if(!p||!t||!S)return;return rt(t,S,I,{animationFrame:!0})},[p,S,m,I]),!p||m&&!k)return null;let w=r?r.kind==="slash":l,ot=w?st:it,J=i("div",{ref:nt,className:m?"fixed z-50":"absolute inset-x-0 bottom-full z-50 mb-2",style:m&&k?{left:k.left,width:k.width,bottom:k.bottom}:void 0,children:i("div",{ref:U,role:"listbox",onMouseDown:(t)=>t.preventDefault(),className:"bg-popover text-popover-foreground ring-foreground/10 pointer-events-auto w-full overflow-hidden rounded-lg p-1 shadow-md ring-1 outline-hidden",children:[i("div",{className:"max-h-72 overflow-y-auto",children:[d.length===0&&w&&i("div",{className:"text-muted-foreground px-2 py-3 text-xs",children:F},void 0,!1,void 0,this),d.length===0&&!w&&E&&i("div",{role:"status",className:"text-muted-foreground px-2 py-3 text-xs",children:y?.query===x&&y.search===a?E.empty:E.loading},void 0,!1,void 0,this),d.map((t,n)=>i(e,{type:"button",variant:"ghost",role:"option","aria-selected":n===b,"data-idx":n,onMouseDown:(o)=>{o.preventDefault(),Q(t)},onMouseEnter:()=>h(n),className:X("flex h-auto w-full items-center justify-start gap-2.5 rounded-md px-2.5 py-2 text-start",n===b&&"bg-muted"),children:[i(ot,{className:X("size-4 shrink-0",w?"text-blue-500":"text-muted-foreground")},void 0,!1,void 0,this),i("span",{className:"text-foreground shrink-0 text-sm font-medium",children:t.label},void 0,!1,void 0,this),t.description&&i("span",{className:"text-muted-foreground min-w-0 flex-1 truncate text-xs",children:t.description},void 0,!1,void 0,this)]},t.key,!0,void 0,this))]},void 0,!0,void 0,this),w&&M&&i(ct,{children:[i(N,{},void 0,!1,void 0,this),i(e,{type:"button",variant:"ghost",onMouseDown:(t)=>{t.preventDefault(),f?.(!1),M.open()},className:"h-auto w-full justify-start px-2.5 py-2",children:[i(lt,{"data-icon":"inline-start"},void 0,!1,void 0,this),M.label]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);return m?at(J,document.body):J}export{wt as CompletionMenu};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ue}from"../chunk-bhvtt6tv.js";export{ue as detectTrigger};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{U}from"../chunk-etvhn65g.js";export{U as EffortSlider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n}from"../chunk-
|
|
1
|
+
import{n}from"../chunk-skx67pc6.js";import"../chunk-kj1wrn2j.js";export{n as MenuRadioSelect};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e}from"../chunk-xgy0heva.js";import{v,x,m,b,H,y,I,M,N,J,s}from"../chunk-bgmsrs7h.js";import{P}from"../chunk-095yr4wk.js";import{G,j,Q}from"../chunk-7fn3yt0k.js";import{V}from"../chunk-3rttyj3m.js";import{n}from"../chunk-6c610cwg.js";import{cn as p}from"cn";import{ArrowUpRight as pe,ChevronUp as Y,Loader2Icon as E,Zap as ee}from"lucide-react";import{Fragment as ce,useState as ne}from"react";import{jsxDEV as a,Fragment as h}from"react/jsx-dev-runtime";function ye({value:w,onChange:ae,models:f,modelGroups:R,compactCatalog:d,effortPresentation:U="slider",unavailableEffort:C,providerMenu:g,header:D,className:W,condensed:A,stripLabelPrefix:L,showDescription:se,showModelList:oe=!0,loading:ie,switching:Z,isLoading:te,effortConfig:i,booleanOptions:z,onBooleanChange:B,selectOptions:le=[],t:c,...u}){let[de,re]=ne(!1),[me,ue]=ne(!1),r=z?.find((o)=>o.id==="fast_mode"),F=d?z?.filter((o)=>o!==r):z,q=(o)=>L&&o.startsWith(L)?o.slice(L.length):o;if(ie)return a("div",{className:"inline-flex min-w-0 items-center gap-1.5",children:a(e,{variant:"ghost",disabled:!0,className:p("h-7 min-w-0 shrink gap-1.5 rounded-md px-2 text-xs font-normal",W),children:[a(E,{className:"size-3 animate-spin"},void 0,!1,void 0,this),a("span",{className:"text-muted-foreground truncate",children:c("model.loadingModels")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);return a("div",{className:"inline-flex min-w-0 items-center gap-1.5",children:[g&&a(v,{open:de,onOpenChange:re,children:[a(G,{children:[a(j,{render:a(x,{render:a(e,{"data-testid":"provider-trigger",variant:"ghost",disabled:u.disabled,className:p("h-7 shrink-0 gap-1 rounded-md px-1.5","hover:bg-accent"),children:[g.icon,a(Y,{className:"size-2.5 shrink-0 opacity-60"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),a(Q,{children:c("model.switchProvider")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(m,{side:"top",align:"end",sideOffset:4,className:"z-100 min-w-[10rem]",children:[g.groups.map((o,l)=>a(ce,{children:[l>0&&o.length>0&&a(s,{},void 0,!1,void 0,this),a(n,{value:g.value,onValueChange:g.onChange,options:o},void 0,!1,void 0,this)]},l,!0,void 0,this)),g.moreAction&&a(h,{children:[a(s,{},void 0,!1,void 0,this),a(y,{onClick:g.moreAction,className:"whitespace-nowrap",children:[a("span",{className:"min-w-0 flex-1 truncate",children:c("model.moreModels")},void 0,!1,void 0,this),a(pe,{className:"size-4"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),a(v,{open:me,onOpenChange:ue,children:[a(G,{children:[a(j,{render:a(x,{render:a(e,{"data-testid":"model-trigger","aria-busy":Z,variant:"ghost",className:p("h-7 gap-1.5 rounded-md px-2 text-xs font-normal","hover:bg-accent","max-w-full min-w-0 shrink",A&&"h-7 gap-1 px-1.5 text-[11px]",W),...u,children:[w.icon,z?.some((o)=>o.id==="fast_mode"&&o.currentValue&&!o.disabled)&&a(ee,{"aria-hidden":"true",className:"size-3 shrink-0"},void 0,!1,void 0,this),a("span",{className:p("min-w-0 flex-1 truncate text-start",A&&"text-[11px]"),children:q(w.label)||c("model.selectModel")},void 0,!1,void 0,this),i&&a("span",{className:"text-muted-foreground grid shrink-0 justify-items-center",children:[a("span",{className:"invisible col-start-1 row-start-1",children:i.sizer??i.levels.reduce((o,l)=>l.name.length>o.length?l.name:o,"")},void 0,!1,void 0,this),a("span",{className:"col-start-1 row-start-1",children:i.levels.find((o)=>o.value===i.value)?.name??i.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z?a(E,{"data-testid":"model-switch-loading",className:"size-3 shrink-0 animate-spin"},void 0,!1,void 0,this):a(Y,{className:p("size-3 shrink-0",A&&"size-2.5")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),a(Q,{children:c("model.switchModel")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(m,{side:"top",align:"end",sideOffset:4,className:p("z-100 w-auto max-w-[min(24rem,calc(100vw-1rem))] min-w-[14rem]",d&&"flex h-[350px] w-80 min-w-0 flex-col overflow-hidden rounded-xl p-1.5"),children:[d&&a(h,{children:[a(b,{"data-model-menu-header":!0,className:"flex shrink-0 items-center justify-between gap-2 px-1 py-1",children:[i?U==="slider"?a("div",{role:"menuitem","aria-label":i.name,className:"min-w-0 [&>div]:justify-start [&>div]:gap-3 [&>div]:px-2 [&>div]:py-1.5",children:a(V,{...i,disabled:u.disabled},void 0,!1,void 0,this)},void 0,!1,void 0,this):a(I,{children:[a(M,{disabled:u.disabled,className:"h-8 min-w-0 flex-1 gap-2 rounded-md",children:[a("span",{children:i.name},void 0,!1,void 0,this),a("span",{className:"text-muted-foreground min-w-0 truncate text-xs",children:i.levels.find((o)=>o.value===i.value)?.name??i.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(N,{children:a(n,{value:i.value,onValueChange:i.onChange,options:i.levels.map((o)=>({value:o.value,label:o.name}))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):C?a(y,{disabled:!0,className:"h-8 min-w-0 flex-1 gap-2",children:[a("span",{children:C.name},void 0,!1,void 0,this),a("span",{className:"text-muted-foreground truncate text-xs",children:C.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this):a(H,{className:"min-w-0 flex-1 truncate",children:D?.name},void 0,!1,void 0,this),r&&a(J,{"aria-label":r.name,title:r.title??r.name,disabled:u.disabled||r.disabled,checked:r.currentValue,closeOnClick:!1,onCheckedChange:(o)=>B?.(r.id,o),className:p("ml-auto size-8 shrink-0 justify-center rounded-md p-0 focus:bg-transparent hover:bg-accent focus:hover:bg-accent focus-visible:bg-accent [&_[data-slot=dropdown-menu-checkbox-item-indicator]]:hidden",r.currentValue&&!r.disabled?"text-foreground [&_svg]:fill-current":"text-muted-foreground"),children:r.icon??a(ee,{className:"size-4","aria-hidden":"true"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(s,{className:"shrink-0"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D&&!d&&a(h,{children:[a("div",{className:"flex items-center gap-2 px-2 py-2",children:[D.icon,a("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:D.name},void 0,!1,void 0,this),D.action]},void 0,!0,void 0,this),a(s,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(b,{"data-model-menu-list":d?"":void 0,className:d?"min-h-0 flex-1 overflow-y-auto overscroll-contain":void 0,children:[oe&&(te?a(y,{disabled:!0,className:"text-muted-foreground",children:c("model.loadingModels")},void 0,!1,void 0,this):f.length===0?a(y,{disabled:!0,className:"text-muted-foreground",children:c("model.noModelsAvailable")},void 0,!1,void 0,this):(()=>{let o=f.filter((t)=>!t.more),l=f.filter((t)=>t.more),K=o.length>0&&l.length>0,T=(t,k)=>({disabled:u.disabled,icon:t.icon,value:t.api_id,label:q(t.label),description:k?.noDescription?void 0:se?t.description:void 0}),O=(t)=>{let k=f.find((_)=>_.api_id===t);if(k)ae(k)};if(d)return a(n,{value:w.api_id,onValueChange:O,itemClassName:"font-normal whitespace-nowrap",options:f.map((t)=>T(t))},void 0,!1,void 0,this);return a(h,{children:[R?R.map((t)=>{let k=t.models.filter((S)=>!S.more),_=t.models.filter((S)=>S.more),X=k.length>0&&_.length>0;return a(b,{children:[a(H,{className:"text-muted-foreground text-xs font-normal",children:t.name},void 0,!1,void 0,this),a(n,{value:w.api_id,onValueChange:O,itemClassName:"font-medium whitespace-nowrap",options:(X?k:t.models).map((S)=>T(S))},void 0,!1,void 0,this),X&&a(I,{children:[a(M,{className:"font-medium whitespace-nowrap",children:c("model.moreModels")},void 0,!1,void 0,this),a(N,{children:a(n,{value:w.api_id,onValueChange:O,itemClassName:"font-medium whitespace-nowrap",options:_.map((S)=>T(S,{noDescription:!0}))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},t.id,!0,void 0,this)}):a(n,{value:w.api_id,onValueChange:O,itemClassName:"font-medium whitespace-nowrap",options:(K?o:f).map((t)=>T(t))},void 0,!1,void 0,this),!R&&K&&a(I,{children:[a(M,{className:"font-medium whitespace-nowrap",children:c("model.moreModels")},void 0,!1,void 0,this),a(N,{children:a(n,{value:w.api_id,onValueChange:O,itemClassName:"font-medium whitespace-nowrap",options:l.map((t)=>T(t,{noDescription:!0}))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)})()),!d&&i&&a(h,{children:[a(s,{},void 0,!1,void 0,this),U==="menu"?a(I,{children:[a(M,{disabled:u.disabled,children:[a("span",{className:"flex-1",children:i.name},void 0,!1,void 0,this),a("span",{className:"text-muted-foreground",children:i.levels.find((o)=>o.value===i.value)?.name??i.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(N,{children:a(n,{value:i.value,onValueChange:i.onChange,options:i.levels.map((o)=>({value:o.value,label:o.name}))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):a(V,{...i,disabled:u.disabled},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!d&&!i&&C&&a(h,{children:[a(s,{},void 0,!1,void 0,this),a(y,{disabled:!0,children:[a("span",{className:"flex-1",children:C.name},void 0,!1,void 0,this),a("span",{children:C.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),le.map((o)=>a(b,{children:[a(s,{},void 0,!1,void 0,this),a(H,{children:o.name},void 0,!1,void 0,this),a(n,{value:o.value,onValueChange:o.onChange,options:o.options,itemClassName:"whitespace-nowrap"},void 0,!1,void 0,this)]},o.id,!0,void 0,this)),F&&F.length>0&&a(h,{children:[!i&&a(s,{},void 0,!1,void 0,this),F.map((o)=>d?a(J,{"aria-label":o.name,title:o.title,disabled:u.disabled||o.disabled,checked:o.currentValue,closeOnClick:!1,onCheckedChange:(l)=>B?.(o.id,l),className:"justify-between gap-3 py-2.5 pr-2 [&_[data-slot=dropdown-menu-checkbox-item-indicator]]:hidden",children:[a("span",{className:"flex items-center gap-2",children:[o.icon,o.name]},void 0,!0,void 0,this),a("span",{"aria-hidden":"true",className:p("flex h-[18px] w-8 shrink-0 items-center rounded-full p-0.5",o.currentValue?"bg-primary":"bg-input"),children:a("span",{className:p("size-3.5 rounded-full bg-background shadow-xs transition-transform",o.currentValue&&"translate-x-3.5")},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},o.id,!0,void 0,this):a("div",{title:o.title,className:p("flex items-center justify-between gap-3 px-2 py-2.5",o.disabled&&"opacity-50"),children:[a("span",{className:"flex items-center gap-2 text-sm font-medium",children:[o.icon,o.name]},void 0,!0,void 0,this),a(P,{"aria-label":o.name,disabled:u.disabled||o.disabled,checked:o.currentValue,onCheckedChange:(l)=>B?.(o.id,l)},void 0,!1,void 0,this)]},o.id,!0,void 0,this))]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),d&&D?.action&&a(h,{children:[a(s,{className:"shrink-0"},void 0,!1,void 0,this),a(b,{"data-model-menu-footer":!0,className:"shrink-0",children:D.action},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}export{ye as ModelSelect};
|
|
1
|
+
import{e}from"../chunk-7pr2j1zb.js";import{x,v,m,b,H,y,P,I,M,J,s}from"../chunk-kj1wrn2j.js";import{S}from"../chunk-s28x10qd.js";import{G,j,Q}from"../chunk-wtkv29ba.js";import{U}from"../chunk-etvhn65g.js";import{n}from"../chunk-skx67pc6.js";import{cn as p}from"cn";import{ArrowUpRight as pe,ChevronUp as Y,Loader2Icon as E,Zap as ee}from"lucide-react";import{Fragment as ce,useState as ne}from"react";import{jsxDEV as a,Fragment as h}from"react/jsx-dev-runtime";function ye({value:w,onChange:ae,models:f,modelGroups:_,compactCatalog:d,effortPresentation:F="slider",unavailableEffort:C,providerMenu:g,header:N,className:W,condensed:R,stripLabelPrefix:A,showDescription:se,showModelList:oe=!0,loading:ie,switching:Z,isLoading:te,effortConfig:i,booleanOptions:V,onBooleanChange:L,selectOptions:le=[],t:c,...u}){let[de,re]=ne(!1),[me,ue]=ne(!1),r=V?.find((o)=>o.id==="fast_mode"),B=d?V?.filter((o)=>o!==r):V,q=(o)=>A&&o.startsWith(A)?o.slice(A.length):o;if(ie)return a("div",{className:"inline-flex min-w-0 items-center gap-1.5",children:a(e,{variant:"ghost",disabled:!0,className:p("h-7 min-w-0 shrink gap-1.5 rounded-md px-2 text-xs font-normal",W),children:[a(E,{className:"size-3 animate-spin"},void 0,!1,void 0,this),a("span",{className:"text-muted-foreground truncate",children:c("model.loadingModels")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);return a("div",{className:"inline-flex min-w-0 items-center gap-1.5",children:[g&&a(x,{open:de,onOpenChange:re,children:[a(G,{children:[a(j,{render:a(v,{render:a(e,{"data-testid":"provider-trigger",variant:"ghost",disabled:u.disabled,className:p("h-7 shrink-0 gap-1 rounded-md px-1.5","hover:bg-accent"),children:[g.icon,a(Y,{className:"size-2.5 shrink-0 opacity-60"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),a(Q,{children:c("model.switchProvider")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(m,{side:"top",align:"end",sideOffset:4,className:"z-100 min-w-[10rem]",children:[g.groups.map((o,l)=>a(ce,{children:[l>0&&o.length>0&&a(s,{},void 0,!1,void 0,this),a(n,{value:g.value,onValueChange:g.onChange,options:o},void 0,!1,void 0,this)]},l,!0,void 0,this)),g.moreAction&&a(h,{children:[a(s,{},void 0,!1,void 0,this),a(y,{onClick:g.moreAction,className:"whitespace-nowrap",children:[a("span",{className:"min-w-0 flex-1 truncate",children:c("model.moreModels")},void 0,!1,void 0,this),a(pe,{className:"size-4"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),a(x,{open:me,onOpenChange:ue,children:[a(G,{children:[a(j,{render:a(v,{render:a(e,{"data-testid":"model-trigger","aria-busy":Z,variant:"ghost",className:p("h-7 gap-1.5 rounded-md px-2 text-xs font-normal","hover:bg-accent","max-w-full min-w-0 shrink",R&&"h-7 gap-1 px-1.5 text-[11px]",W),...u,children:[w.icon,V?.some((o)=>o.id==="fast_mode"&&o.currentValue&&!o.disabled)&&a(ee,{"aria-hidden":"true",className:"size-3 shrink-0"},void 0,!1,void 0,this),a("span",{className:p("min-w-0 flex-1 truncate text-start",R&&"text-[11px]"),children:q(w.label)||c("model.selectModel")},void 0,!1,void 0,this),i&&a("span",{className:"text-muted-foreground grid shrink-0 justify-items-center",children:[a("span",{className:"invisible col-start-1 row-start-1",children:i.sizer??i.levels.reduce((o,l)=>l.name.length>o.length?l.name:o,"")},void 0,!1,void 0,this),a("span",{className:"col-start-1 row-start-1",children:i.levels.find((o)=>o.value===i.value)?.name??i.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z?a(E,{"data-testid":"model-switch-loading",className:"size-3 shrink-0 animate-spin"},void 0,!1,void 0,this):a(Y,{className:p("size-3 shrink-0",R&&"size-2.5")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),a(Q,{children:c("model.switchModel")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(m,{side:"top",align:"end",sideOffset:4,className:p("z-100 w-auto max-w-[min(24rem,calc(100vw-1rem))] min-w-[14rem]",d&&"flex h-[350px] w-80 min-w-0 flex-col overflow-hidden rounded-xl p-1.5"),children:[d&&a(h,{children:[a(b,{"data-model-menu-header":!0,className:"flex shrink-0 items-center justify-between gap-2 px-1 py-1",children:[i?F==="slider"?a("div",{role:"menuitem","aria-label":i.name,className:"min-w-0 [&>div]:justify-start [&>div]:gap-3 [&>div]:px-2 [&>div]:py-1.5",children:a(U,{...i,disabled:u.disabled},void 0,!1,void 0,this)},void 0,!1,void 0,this):a(P,{children:[a(I,{disabled:u.disabled,className:"h-8 min-w-0 flex-1 gap-2 rounded-md",children:[a("span",{children:i.name},void 0,!1,void 0,this),a("span",{className:"text-muted-foreground min-w-0 truncate text-xs",children:i.levels.find((o)=>o.value===i.value)?.name??i.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(M,{children:a(n,{value:i.value,onValueChange:i.onChange,options:i.levels.map((o)=>({value:o.value,label:o.name}))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):C?a(y,{disabled:!0,className:"h-8 min-w-0 flex-1 gap-2",children:[a("span",{children:C.name},void 0,!1,void 0,this),a("span",{className:"text-muted-foreground truncate text-xs",children:C.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this):a(H,{className:"min-w-0 flex-1 truncate",children:N?.name},void 0,!1,void 0,this),r&&a(J,{"aria-label":r.name,title:r.title??r.name,disabled:u.disabled||r.disabled,checked:r.currentValue,closeOnClick:!1,onCheckedChange:(o)=>L?.(r.id,o),className:p("hover:bg-accent focus:hover:bg-accent focus-visible:bg-accent ml-auto size-8 shrink-0 justify-center rounded-md p-0 focus:bg-transparent [&_[data-slot=dropdown-menu-checkbox-item-indicator]]:hidden",r.currentValue&&!r.disabled?"text-foreground [&_svg]:fill-current":"text-muted-foreground"),children:r.icon??a(ee,{className:"size-4","aria-hidden":"true"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(s,{className:"shrink-0"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),N&&!d&&a(h,{children:[a("div",{className:"flex items-center gap-2 px-2 py-2",children:[N.icon,a("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:N.name},void 0,!1,void 0,this),N.action]},void 0,!0,void 0,this),a(s,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(b,{"data-model-menu-list":d?"":void 0,className:d?"min-h-0 flex-1 overflow-y-auto overscroll-contain":void 0,children:[oe&&(te?a(y,{disabled:!0,className:"text-muted-foreground",children:c("model.loadingModels")},void 0,!1,void 0,this):f.length===0?a(y,{disabled:!0,className:"text-muted-foreground",children:c("model.noModelsAvailable")},void 0,!1,void 0,this):(()=>{let o=f.filter((t)=>!t.more),l=f.filter((t)=>t.more),K=o.length>0&&l.length>0,T=(t,D)=>({disabled:u.disabled,icon:t.icon,value:t.api_id,label:q(t.label),description:D?.noDescription?void 0:se?t.description:void 0}),O=(t)=>{let D=f.find((z)=>z.api_id===t);if(D)ae(D)};if(d)return a(n,{value:w.api_id,onValueChange:O,itemClassName:"font-normal whitespace-nowrap",options:f.map((t)=>T(t))},void 0,!1,void 0,this);return a(h,{children:[_?_.map((t)=>{let D=t.models.filter((k)=>!k.more),z=t.models.filter((k)=>k.more),X=D.length>0&&z.length>0;return a(b,{children:[a(H,{className:"text-muted-foreground text-xs font-normal",children:t.name},void 0,!1,void 0,this),a(n,{value:w.api_id,onValueChange:O,itemClassName:"font-medium whitespace-nowrap",options:(X?D:t.models).map((k)=>T(k))},void 0,!1,void 0,this),X&&a(P,{children:[a(I,{className:"font-medium whitespace-nowrap",children:c("model.moreModels")},void 0,!1,void 0,this),a(M,{children:a(n,{value:w.api_id,onValueChange:O,itemClassName:"font-medium whitespace-nowrap",options:z.map((k)=>T(k,{noDescription:!0}))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},t.id,!0,void 0,this)}):a(n,{value:w.api_id,onValueChange:O,itemClassName:"font-medium whitespace-nowrap",options:(K?o:f).map((t)=>T(t))},void 0,!1,void 0,this),!_&&K&&a(P,{children:[a(I,{className:"font-medium whitespace-nowrap",children:c("model.moreModels")},void 0,!1,void 0,this),a(M,{children:a(n,{value:w.api_id,onValueChange:O,itemClassName:"font-medium whitespace-nowrap",options:l.map((t)=>T(t,{noDescription:!0}))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)})()),!d&&i&&a(h,{children:[a(s,{},void 0,!1,void 0,this),F==="menu"?a(P,{children:[a(I,{disabled:u.disabled,children:[a("span",{className:"flex-1",children:i.name},void 0,!1,void 0,this),a("span",{className:"text-muted-foreground",children:i.levels.find((o)=>o.value===i.value)?.name??i.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(M,{children:a(n,{value:i.value,onValueChange:i.onChange,options:i.levels.map((o)=>({value:o.value,label:o.name}))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):a(U,{...i,disabled:u.disabled},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!d&&!i&&C&&a(h,{children:[a(s,{},void 0,!1,void 0,this),a(y,{disabled:!0,children:[a("span",{className:"flex-1",children:C.name},void 0,!1,void 0,this),a("span",{children:C.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),le.map((o)=>a(b,{children:[a(s,{},void 0,!1,void 0,this),a(H,{children:o.name},void 0,!1,void 0,this),a(n,{value:o.value,onValueChange:o.onChange,options:o.options,itemClassName:"whitespace-nowrap"},void 0,!1,void 0,this)]},o.id,!0,void 0,this)),B&&B.length>0&&a(h,{children:[!i&&a(s,{},void 0,!1,void 0,this),B.map((o)=>d?a(J,{"aria-label":o.name,title:o.title,disabled:u.disabled||o.disabled,checked:o.currentValue,closeOnClick:!1,onCheckedChange:(l)=>L?.(o.id,l),className:"justify-between gap-3 py-2.5 pr-2 [&_[data-slot=dropdown-menu-checkbox-item-indicator]]:hidden",children:[a("span",{className:"flex items-center gap-2",children:[o.icon,o.name]},void 0,!0,void 0,this),a("span",{"aria-hidden":"true",className:p("flex h-[18px] w-8 shrink-0 items-center rounded-full p-0.5",o.currentValue?"bg-primary":"bg-input"),children:a("span",{className:p("bg-background size-3.5 rounded-full shadow-xs transition-transform",o.currentValue&&"translate-x-3.5")},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},o.id,!0,void 0,this):a("div",{title:o.title,className:p("flex items-center justify-between gap-3 px-2 py-2.5",o.disabled&&"opacity-50"),children:[a("span",{className:"flex items-center gap-2 text-sm font-medium",children:[o.icon,o.name]},void 0,!0,void 0,this),a(S,{"aria-label":o.name,disabled:u.disabled||o.disabled,checked:o.currentValue,onCheckedChange:(l)=>L?.(o.id,l)},void 0,!1,void 0,this)]},o.id,!0,void 0,this))]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),d&&N?.action&&a(h,{children:[a(s,{className:"shrink-0"},void 0,!1,void 0,this),a(b,{"data-model-menu-footer":!0,className:"shrink-0",children:N.action},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}export{ye as ModelSelect};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e}from"../chunk-
|
|
1
|
+
import{e}from"../chunk-7pr2j1zb.js";import{x,v,m}from"../chunk-kj1wrn2j.js";import{n}from"../chunk-skx67pc6.js";import{useState as f}from"react";import{jsxDEV as o}from"react/jsx-dev-runtime";function N({value:p,currentName:t,icon:r,options:s,label:i,header:a,onValueChange:l,showLabel:d=!1,disabled:u=!1}){let[c,g]=f(!1);return o(x,{open:c,onOpenChange:g,children:[o(v,{render:o(e,{disabled:u,variant:"ghost","aria-label":`${i}: ${t}`,title:t,className:"text-muted-foreground data-popup-open:hover:bg-muted h-7 gap-1.5 rounded-full bg-transparent px-2 text-xs font-normal whitespace-nowrap data-popup-open:bg-transparent",children:[r,o("span",{className:d?"max-w-40 truncate":"hidden max-w-40 truncate @[40rem]/input-footer:inline-block",children:t},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),o(m,{align:"start",sideOffset:4,className:"permission-mode-menu z-100 w-auto max-w-[calc(100vw-2rem)] min-w-72 rounded-xl p-1.5",children:[a&&o("div",{className:"text-muted-foreground flex items-center px-1.5 pt-0.5 pb-1 text-[11px] leading-4",children:o("span",{children:a},void 0,!1,void 0,this)},void 0,!1,void 0,this),o(n,{value:p,onValueChange:l,itemClassName:"items-center gap-2 py-1 pr-6 pl-2 whitespace-nowrap",options:s},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}export{N as PermissionModeSelect};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunk-
|
|
1
|
+
import"../chunk-qj8r5xvx.js";import{e}from"../chunk-7pr2j1zb.js";import"../chunk-s0nhgptn.js";import{Ke}from"../chunk-74phx7h8.js";import{Re,Le,_e}from"../chunk-6x9vcfpg.js";import{p}from"../chunk-awbgf3hp.js";import{cn as f}from"cn";import{PaperclipIcon as H,XIcon as k}from"lucide-react";import{Fragment as T,useEffect as M,useRef as L,useState as P}from"react";import{jsxDEV as t,Fragment as E}from"react/jsx-dev-runtime";function z(n){return t(_e,{align:"start",...n},void 0,!1,void 0,this)}function W({data:n,t:r,className:u,...m}){let c=p(),[d,h]=P(!1),[N,v]=P(1),I=L(null),a=n.filename||"",o=(n.mediaType?.startsWith("image/")&&n.url?"image":"file")==="image",C=a||(o?r("input.image"):r("input.attachment"));return M(()=>{if(!d)return;let l=0.1,g=(i)=>Math.min(10,Math.max(0.1,i)),y=(i)=>{if(!(i.ctrlKey||i.metaKey))return;let s=i.key,x=s==="+"||s==="=",A=s==="-"||s==="_",w=s==="0";if(!x&&!A&&!w)return;i.preventDefault(),v((b)=>{if(w)return 1;if(x)return g(b+l);return g(b-l)})};return window.addEventListener("keydown",y,{passive:!1}),()=>window.removeEventListener("keydown",y)},[d]),t(E,{children:[t(Re,{children:[t(Le,{render:t("div",{className:f("group border-border hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent relative flex h-8 cursor-pointer items-center gap-1.5 rounded-md border px-1.5 text-sm font-medium transition-all select-none",u),...m,children:[t("div",{className:"relative size-5 shrink-0",children:[o?t(e,{type:"button",variant:"ghost",size:"icon-xs","aria-label":r("input.image"),className:"bg-background absolute inset-0 size-5 overflow-hidden rounded p-0 transition-opacity group-hover:opacity-0",onClick:()=>{v(1),h(!0)},children:t("img",{alt:a||"attachment",className:"size-5 object-cover",height:20,src:n.url,width:20},void 0,!1,void 0,this)},void 0,!1,void 0,this):t("div",{className:"bg-background text-muted-foreground absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded transition-opacity group-hover:opacity-0",children:t(H,{className:"size-3"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t(e,{"aria-label":r("input.removeAttachment"),className:f("absolute -top-1 -right-1 size-4 rounded-full p-0 opacity-0 transition-opacity [&>svg]:size-3","pointer-events-none group-hover:pointer-events-auto group-hover:opacity-100"),onClick:(l)=>{l.stopPropagation(),c.remove(n.id)},type:"button",variant:"ghost",children:[t(k,{},void 0,!1,void 0,this),t("span",{className:"sr-only",children:r("input.removeAttachment")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!o&&t("span",{className:"max-w-40 flex-1 truncate text-xs",children:C},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t(z,{className:"w-auto p-2",children:t("div",{className:"w-auto space-y-3",children:[o&&t("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:t("img",{alt:a||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:n.url,width:448},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("div",{className:"flex items-center gap-2.5",children:t("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[t("h4",{className:"truncate text-sm leading-none font-semibold",children:a||(o?"Image":"Attachment")},void 0,!1,void 0,this),n.mediaType&&t("p",{className:"text-muted-foreground truncate font-mono text-xs",children:n.mediaType},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o&&n.url&&t(Ke,{containerRef:I,filename:a||r("input.image"),onOpenChange:h,onScaleChange:v,open:d,scale:N,url:n.url},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function X({children:n,className:r,...u}){let m=p();if(!m.files.length)return null;return t("div",{className:f("flex w-full flex-wrap items-center gap-1",r),...u,children:m.files.map((c)=>t(T,{children:n(c)},c.id,!1,void 0,this))},void 0,!1,void 0,this)}export{W as PromptInputAttachment,X as PromptInputAttachments};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ot,le,de,it,nt,_}from"../chunk-7tj0a2na.js";export{de as clipboardHasStringItem,nt as countControlCharsBeforeIndex,ot as normalizePastedImageFile,_ as sanitizeTextareaTargetValue,it as sanitizeTextareaValue,le as scanClipboardForImageFiles};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{O,pt,B,gt,k,ce,C,ft,ht,z,p}from"../chunk-awbgf3hp.js";export{z as LocalAttachmentsContext,ht as PromptInputProvider,B as PromptInputSubmissionContext,O as PromptInputSubmitContext,k as ProviderAttachmentsContext,C as useOptionalPromptInputController,p as usePromptInputAttachments,ce as usePromptInputController,gt as usePromptInputSubmission,pt as usePromptInputSubmit,ft as useProviderAttachments};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import"../chunk-r9k7kszp.js";import{ne}from"../chunk-jnx3t913.js";import{le,de,_}from"../chunk-
|
|
1
|
+
import"../chunk-r9k7kszp.js";import{ne}from"../chunk-jnx3t913.js";import{le,de,_}from"../chunk-7tj0a2na.js";import{C,p}from"../chunk-awbgf3hp.js";import{cn as A}from"cn";import{forwardRef as D,useCallback as M,useEffect as K,useImperativeHandle as L,useRef as d}from"react";import{jsxDEV as q}from"react/jsx-dev-runtime";var R=(i)=>!i.shiftKey,F=()=>!1,N=D(({onChange:i,onCompositionStart:v,onCompositionEnd:x,className:T,placeholder:y,bashMode:b=!1,isSendShortcut:E=R,isNewlineShortcut:I=F,...H},P)=>{let n=C(),l=p(),o=d(!1),u=d(!1),r=d(null),s=M(()=>{let e=r.current;if(!e||o.current)return;e.style.height="auto",e.style.height=`${e.scrollHeight}px`},[]);K(()=>{let e=r.current;if(!e)return;let t=new ResizeObserver(()=>{requestAnimationFrame(s)});return t.observe(e),()=>t.disconnect()},[s]);let c=b&&(n?.textInput.value??"").startsWith("!"),S=(e)=>{if(o.current||e.nativeEvent.isComposing||e.nativeEvent.keyCode===229||u.current)return;if(e.key.length===1&&e.key.charCodeAt(0)<32&&e.key!==`
|
|
2
2
|
`&&e.key!=="\r"&&e.key!=="\t"){e.preventDefault();return}if(c&&n){let t=e.currentTarget.selectionStart===0&&e.currentTarget.selectionEnd===0;if(e.key==="Escape"||(e.key==="Backspace"||e.key==="Delete")&&t){e.preventDefault(),n.textInput.setInput(n.textInput.value.slice(1));return}}if(e.key==="Enter"){if(I(e.nativeEvent)){e.preventDefault();let t=e.currentTarget,{selectionStart:a,selectionEnd:f,value:m}=t,h=`${m.slice(0,a)}
|
|
3
3
|
${m.slice(f)}`;if(n)n.textInput.setInput(h);else t.value=h;let g=a+1;t.setSelectionRange(g,g),s();return}if(E(e.nativeEvent)){e.preventDefault();let t=e.currentTarget.form;if(!t)return;let a=t.querySelector('button[type="submit"]');if(!a||a.disabled)return;t.requestSubmit(a)}}if(e.key==="Backspace"&&e.currentTarget.value===""&&l.files.length>0){e.preventDefault();let t=l.files.at(-1);if(t)l.remove(t.id)}},k=(e)=>{let t=e.clipboardData?.items;if(!t)return;let{imageFiles:a,sawNonImageFile:f}=le(t),m=de(t);if(a.length>0)e.preventDefault(),l.add(a);else if(f&&!m)e.preventDefault()},w=n?{value:o.current&&r.current?r.current.value:c?n.textInput.value.slice(1):n.textInput.value,onChange:(e)=>{let t=o.current?e.currentTarget.value:_(e.currentTarget);n.textInput.setInput(c?`!${t}`:t),s(),i?.(e)}}:{onChange:(e)=>{if(!o.current)_(e.currentTarget);s(),i?.(e)}};return L(P,()=>({resetHeight:()=>{if(r.current)r.current.style.height="auto"},focus:()=>{r.current?.focus()},isComposing:()=>o.current||u.current,getTextarea:()=>r.current}),[]),q(ne,{"data-chat-input":!0,ref:r,rows:3,className:A("field-sizing-content max-h-(--chat-input-max-height) min-h-[calc(var(--chat-input-line-height)*3)] min-w-0 flex-1 overflow-x-hidden","leading-(--chat-input-line-height)","placeholder:text-chat-input-placeholder p-0 pe-2.5","bg-chat-input-bg",T),name:"message",onCompositionEnd:(e)=>{o.current=!1;let t=_(e.currentTarget);n?.textInput.setInput(c?`!${t}`:t),s(),x?.(e),u.current=!0,requestAnimationFrame(()=>{u.current=!1})},onCompositionStart:(e)=>{u.current=!1,o.current=!0,v?.(e)},onKeyDown:S,onPaste:k,placeholder:y,...H,...w},void 0,!1,void 0,this)});N.displayName="PromptInputTextarea";export{N as PromptInputTextarea};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Ze,ae}from"../chunk-reqrpvyy.js";import"../chunk-0e1pdbec.js";import{Ve}from"../chunk-src2j5cw.js";import"../chunk-7pr2j1zb.js";import"../chunk-r9k7kszp.js";import"../chunk-jnx3t913.js";import{ze,ee,te}from"../chunk-ghfbzhnb.js";import{O,B,k,C,z}from"../chunk-awbgf3hp.js";import{cn as P}from"cn";import{ArrowUpIcon as Ie,Loader2Icon as ye,SquareIcon as xe,XIcon as Le}from"lucide-react";import{Children as oe,useCallback as h,useEffect as F,useMemo as Te,useRef as M,useState as Fe}from"react";import{flushSync as Me}from"react-dom";import{jsxDEV as o}from"react/jsx-dev-runtime";function se(u){let s=new FormData(u).get("message");return typeof s==="string"?s:""}var De=({className:u,bashMode:s=!1,attachmentPolicy:I,onCommand:d,onSubmitError:y,canSubmit:f,onSubmitAsync:g,accept:E,multiple:ie,globalDrop:A,syncHiddenInput:G,maxFiles:D,maxFileSize:N,onError:b,onSubmit:ue,children:le,...pe})=>{let i=C(),l=!!i,me=s&&l&&i.textInput.value.startsWith("!"),x=M(null),w=M(null),R=M(!1),[ce,U]=Fe([]),c=l?i.attachments.files:ce,j=M(c);j.current=c;let de=h(()=>{x.current?.click()},[]),q=h((e)=>{if(!E||E.trim()==="")return!0;return E.split(",").map((t)=>t.trim()).filter(Boolean).some((t)=>{if(t.endsWith("/*")){let n=t.slice(0,-1);return e.type.startsWith(n)}return e.type===t})},[E]),X=h((e)=>{if(e.type)return e.type;let r=(e.name||"").toLowerCase();if(r.endsWith(".png"))return"image/png";if(r.endsWith(".jpg")||r.endsWith(".jpeg"))return"image/jpeg";if(r.endsWith(".webp"))return"image/webp";if(r.endsWith(".gif"))return"image/gif";if(r.endsWith(".bmp"))return"image/bmp";if(r.endsWith(".svg"))return"image/svg+xml";return""},[]),fe=h((e)=>{let r=[...e],t=r.filter((a)=>q(a));if(r.length&&t.length===0){b?.({code:"accept",message:"No files match the accepted types."});return}let n=(a)=>N?a.size<=N:!0,m=t.filter(n);if(t.length>0&&m.length===0){b?.({code:"max_file_size",message:"All files exceed the maximum size."});return}U((a)=>{let v=I?I.uniqueFiles(m,a):m,p=typeof D==="number"?Math.max(0,D-a.length):void 0,H=typeof p==="number"?v.slice(0,p):v;if(typeof p==="number"&&v.length>p)b?.({code:"max_files",message:"Too many files. Some were not added."});let re=[];for(let T of H){let ne=I?.sourcePath(T);re.push({id:crypto.randomUUID(),type:"file",url:URL.createObjectURL(T),mediaType:X(T),filename:T.name,size:T.size,lastModified:T.lastModified,...ne===void 0?{}:{sourcePath:ne}})}return[...a,...re]})},[I,X,q,D,N,b]),ge=h((e)=>U((r)=>{let t=r.find((n)=>n.id===e);if(t?.url)URL.revokeObjectURL(t.url);return r.filter((n)=>n.id!==e)}),[]),be=h(()=>U((e)=>{for(let r of e)if(r.url)URL.revokeObjectURL(r.url);return[]}),[]),J=l?i.attachments.add:fe,L=h((e)=>{let r=[...e],t=r.filter((m)=>!(m.type??"").toLowerCase().startsWith("image/"));if(t.length>0){b?.({code:"unsupported_type",message:`Only image attachments are supported. ${t.length} non-image file(s) were ignored.`});return}let n=r.reduce((m,a)=>m+a.size,0);if(n>0){let m=c.filter((a)=>(a.mediaType??"").toLowerCase().startsWith("image/")).reduce((a,v)=>a+(v.size??0),0);if(Ze(m,n)){b?.({code:"max_total_size",message:`Total image size must not exceed ${ae}MB.`});return}}J(r)},[c,J,b]),K=l?i.attachments.remove:ge,W=l?i.attachments.clear:be,Q=l?i.attachments.openFileDialog:de;F(()=>{if(!l)return;i.__registerFileInput(x,()=>x.current?.click())},[l,i]),F(()=>{if(G&&x.current&&c.length===0)x.current.value=""},[c,G]),F(()=>{let e=w.current;if(!e)return;if(A)return;let r=(n)=>{if(n.dataTransfer?.types?.includes("Files"))n.preventDefault()},t=(n)=>{if(n.dataTransfer?.types?.includes("Files"))n.preventDefault();if(n.dataTransfer?.files&&n.dataTransfer.files.length>0)L(n.dataTransfer.files)};return e.addEventListener("dragover",r),e.addEventListener("drop",t),()=>{e.removeEventListener("dragover",r),e.removeEventListener("drop",t)}},[L,A]),F(()=>{if(!A)return;let e=(t)=>{if(t.dataTransfer?.types?.includes("Files"))t.preventDefault()},r=(t)=>{if(t.dataTransfer?.types?.includes("Files"))t.preventDefault();if(t.dataTransfer?.files&&t.dataTransfer.files.length>0)L(t.dataTransfer.files)};return document.addEventListener("dragover",e),document.addEventListener("drop",r),()=>{document.removeEventListener("dragover",e),document.removeEventListener("drop",r)}},[L,A]),F(()=>()=>{if(!l){for(let e of j.current)if(e.url)URL.revokeObjectURL(e.url)}},[l]);let ve=(e)=>{if(e.currentTarget.files)L(e.currentTarget.files);e.currentTarget.value=""},V=Te(()=>({files:c.map((e)=>({...e,id:e.id})),add:L,remove:K,clear:W,openFileDialog:Q,fileInputRef:x}),[c,L,K,W,Q]),S=M({controller:i,files:c,canSubmit:f});S.current={controller:i,files:c,canSubmit:f};let _=M(!0);F(()=>(_.current=!0,()=>{_.current=!1}),[]);let Y=async(e)=>{let r=f===void 0?!0:f();if(r!==!0)return{status:"blocked",reason:r};if(R.current)return{status:"blocked",reason:"submission_pending"};if(e===null&&g===void 0)throw Error("Awaitable submission requires onSubmitAsync");let t=w.current;if(t===null)return{status:"blocked",reason:"form_unmounted"};let n=l?i.textInput.value:se(t),m=i?.textInput.getRevision?.(),a=c,v=()=>{if(!_.current)return;let p=S.current;if(p.files!==a)return;if(l){if(m===void 0||p.controller===null||p.controller.textInput.getRevision?.()!==m)return;if(p.controller.textInput.clearSubmitted===void 0)p.controller.textInput.clear();else p.controller.textInput.clearSubmitted()}else if(se(t)===n)t.reset();W()};R.current=!0;try{if(d?.(n.trim()))return v(),{status:"accepted"};let p=await Ve(a),H=S.current.canSubmit===void 0?!0:S.current.canSubmit();if(H!==!0)return{status:"blocked",reason:H};if(!_.current)return{status:"blocked",reason:"form_unmounted"};if(p.rejectedCount>0)b?.({code:"accept",message:"One or more images are corrupted and were removed before sending."});if(g!==void 0)await g({text:n,files:p.files});else if(e!==null)await ue({text:n,files:p.files},e);return v(),{status:"accepted"}}finally{R.current=!1}},he=(e)=>{e.preventDefault(),Y(e).catch(y)},Pe=h((e)=>{if(!e.trim())return;if(l&&i)Me(()=>{i.textInput.setInput(e)});w.current?.requestSubmit()},[i,l]),Z=o(B.Provider,{value:()=>Y(null),children:o(O.Provider,{value:Pe,children:[o("input",{accept:E,"aria-label":"Upload files",className:"hidden",multiple:ie,onChange:ve,ref:x,title:"Upload files",type:"file"},void 0,!1,void 0,this),o("form",{className:P("w-full",u),onSubmit:he,ref:w,"data-tour":"chat-input",...pe,children:o(ze,{className:P("codex-composer-surface overflow-y-auto has-[[data-slot=input-group-control]:focus-visible]:ring-0",me&&"border! border-[rgb(255,0,135)] has-[[data-slot=input-group-control]:focus-visible]:border-[rgb(255,0,135)] dark:border-[rgb(253,93,177)] dark:has-[[data-slot=input-group-control]:focus-visible]:border-[rgb(253,93,177)]"),children:le},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);return l?o(k.Provider,{value:V,children:Z},void 0,!1,void 0,this):o(z.Provider,{value:V,children:Z},void 0,!1,void 0,this)};function Ne({className:u,...s}){return o("div",{className:P("flex w-full min-w-0 flex-row items-end gap-2",u),...s},void 0,!1,void 0,this)}function Re({className:u,...s}){return o(ee,{align:"block-end",className:P("order-first flex-wrap gap-1 p-2 pb-1.5",u),...s},void 0,!1,void 0,this)}function Ue({className:u,...s}){return o(ee,{align:"block-end",className:P("mt-3.5 justify-between gap-1 p-0",u),...s},void 0,!1,void 0,this)}function Be({className:u,...s}){return o("div",{className:P("flex items-center gap-1",u),...s},void 0,!1,void 0,this)}var Oe=({variant:u="ghost",className:s,size:I,collapsed:d=!1,...y})=>{let f=d||oe.count(y.children)<=1?"icon-xs":"xs";return o(te,{className:P("h-7 rounded-full text-xs font-medium hover:bg-transparent dark:hover:bg-transparent",(d||oe.count(y.children)<=1)&&"size-7",s),size:f,type:"button",variant:u,...y},void 0,!1,void 0,this)},We=({className:u,variant:s="ghost",size:I="icon-xs",status:d,children:y,...f})=>{let g=o(Ie,{className:"size-4"},void 0,!1,void 0,this);if(d==="submitted")g=o(ye,{className:"size-4 animate-spin"},void 0,!1,void 0,this);else if(d==="streaming")g=o(xe,{className:"size-3 fill-current"},void 0,!1,void 0,this);else if(d==="error")g=o(Le,{className:"size-4"},void 0,!1,void 0,this);return o(te,{"aria-label":"Submit",className:P("bg-foreground text-background hover:bg-foreground/70 size-7 rounded-full p-0 transition-opacity disabled:opacity-50",u),size:I,type:"submit",variant:s,...f,children:y??g},void 0,!1,void 0,this)};export{ae as MAX_TOTAL_IMAGE_MB,De as PromptInput,Ne as PromptInputBody,Oe as PromptInputButton,Ue as PromptInputFooter,Re as PromptInputHeader,We as PromptInputSubmit,Be as PromptInputTools};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ke}from"./chunk-
|
|
1
|
+
import{Ke}from"./chunk-74phx7h8.js";import"./chunk-s0nhgptn.js";import"./chunk-7pr2j1zb.js";import"./chunk-qj8r5xvx.js";export{Ke as ImagePreviewDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{tt}from"../chunk-25na55ve.js";export{tt as createCodeHighlighter};
|
package/dist/lib/fuzzy.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{se,
|
|
1
|
+
import{se,Je}from"../chunk-hnt4tt1n.js";export{Je as fuzzyFilter,se as fuzzyMatch};
|
package/dist/lib/group-blocks.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ue}from"../chunk-
|
|
1
|
+
import{Ue}from"../chunk-s3z33k7f.js";import"../chunk-y2xbq7rb.js";export{Ue as groupBlocksForStyle};
|