@opentiny/tiny-robot 0.5.2-alpha.14 → 0.5.2-alpha.15

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.
@@ -1,128 +1,128 @@
1
- import { shallowRef as C, computed as p, watch as j, nextTick as Y, defineComponent as Q, openBlock as g, createElementBlock as w, createElementVNode as I, toDisplayString as K, Fragment as ae, renderList as re, normalizeClass as H, withModifiers as pe, renderSlot as T, createBlock as N, resolveDynamicComponent as se, createCommentVNode as D, unref as P, createSlots as _, withCtx as q, mergeProps as ue, onMounted as de, normalizeProps as F, guardReactiveProps as A, createVNode as U, onScopeDispose as ye, toRaw as be, getCurrentInstance as we, Teleport as ke } from "vue";
2
- import { IconCheck as $e, IconSearch as Ee, IconNoData as Oe, IconArrowDown as Se } from "@opentiny/tiny-robot-svgs";
3
- import { a as xe, c as Pe, o as Ve, f as Me, s as Te, b as Ce } from "../floating-ui.dom.js";
4
- import { u as De } from "../useTeleportTarget.js";
5
- function Ie(e) {
6
- const a = C(""), n = p(() => a.value.trim()), t = p(() => {
7
- const m = e.options(), r = n.value;
8
- if (!e.searchable() || !r)
9
- return m;
10
- const s = e.filterMethod();
11
- if (s)
12
- return m.filter((v) => s(r, v.raw));
13
- const c = r.toLocaleLowerCase();
14
- return m.filter((v) => v.searchText.includes(c));
15
- }), u = p(() => {
16
- const m = /* @__PURE__ */ new Map();
17
- return t.value.forEach((r) => {
18
- var c, v;
19
- const s = m.get(r.groupKey);
20
- if (s) {
21
- s.items.push(r);
1
+ import { shallowRef as V, computed as g, watch as Y, nextTick as Z, defineComponent as J, openBlock as p, createElementBlock as b, createElementVNode as I, toDisplayString as F, Fragment as ae, renderList as re, normalizeClass as W, withModifiers as pe, renderSlot as D, createBlock as _, resolveDynamicComponent as se, createCommentVNode as z, createVNode as N, unref as P, createSlots as te, withCtx as H, mergeProps as ue, onMounted as ce, onBeforeUnmount as ye, normalizeStyle as be, normalizeProps as U, guardReactiveProps as j, onScopeDispose as we, toRaw as ke, getCurrentInstance as $e, Teleport as Ee } from "vue";
2
+ import { IconCheck as Oe, IconSearch as Se, IconNoData as xe, IconArrowDown as Me } from "@opentiny/tiny-robot-svgs";
3
+ import { a as Pe, c as Ve, o as Te, f as Ce, s as De, b as Ie } from "../floating-ui.dom.js";
4
+ import { u as ze } from "../useTeleportTarget.js";
5
+ function Be(e) {
6
+ const a = V(""), n = g(() => a.value.trim()), l = g(() => {
7
+ const d = e.options(), i = n.value;
8
+ if (!e.searchable() || !i)
9
+ return d;
10
+ const r = e.filterMethod();
11
+ if (r)
12
+ return d.filter((m) => r(i, m.raw));
13
+ const u = i.toLocaleLowerCase();
14
+ return d.filter((m) => m.searchText.includes(u));
15
+ }), s = g(() => {
16
+ const d = /* @__PURE__ */ new Map();
17
+ return l.value.forEach((i) => {
18
+ var u, m;
19
+ const r = d.get(i.groupKey);
20
+ if (r) {
21
+ r.items.push(i);
22
22
  return;
23
23
  }
24
- m.set(r.groupKey, {
25
- key: r.groupKey,
26
- index: m.size,
27
- group: ((c = r.raw.group) == null ? void 0 : c.trim()) ?? "",
28
- label: ((v = r.raw.group) == null ? void 0 : v.trim()) ?? "",
29
- items: [r]
24
+ d.set(i.groupKey, {
25
+ key: i.groupKey,
26
+ index: d.size,
27
+ group: ((u = i.raw.group) == null ? void 0 : u.trim()) ?? "",
28
+ label: ((m = i.raw.group) == null ? void 0 : m.trim()) ?? "",
29
+ items: [i]
30
30
  });
31
- }), [...m.values()];
32
- }), f = p(() => t.value.length === 0);
33
- function i(m) {
34
- a.value = m;
31
+ }), [...d.values()];
32
+ }), f = g(() => l.value.length === 0);
33
+ function c(d) {
34
+ a.value = d;
35
35
  }
36
- function d() {
36
+ function h() {
37
37
  a.value = "";
38
38
  }
39
39
  return {
40
40
  query: a,
41
- visibleOptions: t,
42
- groups: u,
41
+ visibleOptions: l,
42
+ groups: s,
43
43
  isEmpty: f,
44
- setQuery: i,
45
- clearQuery: d
44
+ setQuery: c,
45
+ clearQuery: h
46
46
  };
47
47
  }
48
- function ze(e) {
49
- const a = C(null), n = p(() => e.options().find((r) => r.key === a.value) ?? null);
50
- function t() {
51
- return e.options().filter((r) => !r.disabled);
48
+ function Le(e) {
49
+ const a = V(null), n = g(() => e.options().find((i) => i.key === a.value) ?? null);
50
+ function l() {
51
+ return e.options().filter((i) => !i.disabled);
52
52
  }
53
- function u(r) {
54
- if (r === null) {
53
+ function s(i) {
54
+ if (i === null) {
55
55
  a.value = null;
56
56
  return;
57
57
  }
58
- const s = e.options().find((c) => c.key === r);
59
- s && !s.disabled && (a.value = s.key);
58
+ const r = e.options().find((u) => u.key === i);
59
+ r && !r.disabled && (a.value = r.key);
60
60
  }
61
61
  function f() {
62
62
  a.value = null;
63
63
  }
64
- function i(r) {
65
- const s = t(), c = r === "first" ? s[0] : s[s.length - 1];
66
- a.value = (c == null ? void 0 : c.key) ?? null;
64
+ function c(i) {
65
+ const r = l(), u = i === "first" ? r[0] : r[r.length - 1];
66
+ a.value = (u == null ? void 0 : u.key) ?? null;
67
67
  }
68
- function d(r = "first") {
69
- const s = e.selectedValue(), c = e.options().find((v) => v.value === s && !v.disabled);
70
- if (c) {
71
- a.value = c.key;
68
+ function h(i = "first") {
69
+ const r = e.selectedValue(), u = e.options().find((m) => m.value === r && !m.disabled);
70
+ if (u) {
71
+ a.value = u.key;
72
72
  return;
73
73
  }
74
- i(r);
74
+ c(i);
75
75
  }
76
- function m(r) {
77
- var y, E;
78
- const s = t();
79
- if (s.length === 0) {
76
+ function d(i) {
77
+ var y, x;
78
+ const r = l();
79
+ if (r.length === 0) {
80
80
  f();
81
81
  return;
82
82
  }
83
- const c = s.findIndex(($) => $.key === a.value);
84
- if (c < 0) {
85
- const $ = r === 1 ? 0 : s.length - 1;
86
- a.value = ((y = s[$]) == null ? void 0 : y.key) ?? null;
83
+ const u = r.findIndex((k) => k.key === a.value);
84
+ if (u < 0) {
85
+ const k = i === 1 ? 0 : r.length - 1;
86
+ a.value = ((y = r[k]) == null ? void 0 : y.key) ?? null;
87
87
  return;
88
88
  }
89
- const v = (c + r + s.length) % s.length;
90
- a.value = ((E = s[v]) == null ? void 0 : E.key) ?? null;
89
+ const m = (u + i + r.length) % r.length;
90
+ a.value = ((x = r[m]) == null ? void 0 : x.key) ?? null;
91
91
  }
92
- return j(
92
+ return Y(
93
93
  () => [e.enabled(), e.options(), e.selectedValue()],
94
- ([r, s, c], v) => {
95
- if (!r) {
94
+ ([i, r, u], m) => {
95
+ if (!i) {
96
96
  f();
97
97
  return;
98
98
  }
99
- const y = v == null ? void 0 : v[2], E = s.find((O) => O.value === c && !O.disabled);
100
- if (c !== y && E) {
101
- a.value = E.key;
99
+ const y = m == null ? void 0 : m[2], x = r.find(($) => $.value === u && !$.disabled);
100
+ if (u !== y && x) {
101
+ a.value = x.key;
102
102
  return;
103
103
  }
104
- (a.value ? s.some((O) => O.key === a.value && !O.disabled) : !1) || d("first");
104
+ (a.value ? r.some(($) => $.key === a.value && !$.disabled) : !1) || h("first");
105
105
  },
106
106
  { immediate: !0 }
107
- ), j(a, async (r) => {
108
- if (!r || !e.enabled())
107
+ ), Y(a, async (i) => {
108
+ if (!i || !e.enabled())
109
109
  return;
110
- await Y();
111
- const s = e.containerEl.value, c = Array.from(
112
- (s == null ? void 0 : s.querySelectorAll("[data-model-selector-option-key]")) ?? []
113
- ).find((v) => v.dataset.modelSelectorOptionKey === r);
114
- c == null || c.scrollIntoView({ block: "nearest" });
110
+ await Z();
111
+ const r = e.containerEl.value, u = Array.from(
112
+ (r == null ? void 0 : r.querySelectorAll("[data-model-selector-option-key]")) ?? []
113
+ ).find((m) => m.dataset.modelSelectorOptionKey === i);
114
+ u == null || u.scrollIntoView({ block: "nearest" });
115
115
  }), {
116
116
  highlightedKey: a,
117
117
  highlightedOption: n,
118
- setHighlightedKey: u,
118
+ setHighlightedKey: s,
119
119
  resetHighlight: f,
120
- highlightBoundary: i,
121
- highlightSelectedOrBoundary: d,
122
- moveHighlight: m
120
+ highlightBoundary: c,
121
+ highlightSelectedOrBoundary: h,
122
+ moveHighlight: d
123
123
  };
124
124
  }
125
- const Be = { class: "tr-model-selector__effort" }, Le = { class: "tr-model-selector__effort-label" }, Ke = ["aria-label"], Re = ["disabled", "aria-pressed", "data-model-selector-effort-value", "onClick"], qe = /* @__PURE__ */ Q({
125
+ const Re = { class: "tr-model-selector__effort" }, Ke = { class: "tr-model-selector__effort-label" }, qe = ["aria-label"], Fe = ["disabled", "aria-pressed", "data-model-selector-effort-value", "onClick"], Ae = /* @__PURE__ */ J({
126
126
  name: "TrModelSelectorEffort",
127
127
  __name: "ModelSelectorEffort",
128
128
  props: {
@@ -133,26 +133,26 @@ const Be = { class: "tr-model-selector__effort" }, Le = { class: "tr-model-selec
133
133
  },
134
134
  emits: ["select"],
135
135
  setup(e) {
136
- return (a, n) => (g(), w("div", Be, [
137
- I("span", Le, K(e.label), 1),
136
+ return (a, n) => (p(), b("div", Re, [
137
+ I("span", Ke, F(e.label), 1),
138
138
  I("div", {
139
139
  class: "tr-model-selector__effort-options",
140
140
  role: "group",
141
141
  "aria-label": e.label
142
142
  }, [
143
- (g(!0), w(ae, null, re(e.options, (t) => (g(), w("button", {
144
- key: t.value,
143
+ (p(!0), b(ae, null, re(e.options, (l) => (p(), b("button", {
144
+ key: l.value,
145
145
  type: "button",
146
- class: H(["tr-model-selector__effort-option", { "is-active": t.value === e.value }]),
147
- disabled: e.disabled || t.disabled,
148
- "aria-pressed": t.value === e.value,
149
- "data-model-selector-effort-value": t.value,
150
- onClick: (u) => a.$emit("select", t.value)
151
- }, K(t.label), 11, Re))), 128))
152
- ], 8, Ke)
146
+ class: W(["tr-model-selector__effort-option", { "is-active": l.value === e.value }]),
147
+ disabled: e.disabled || l.disabled,
148
+ "aria-pressed": l.value === e.value,
149
+ "data-model-selector-effort-value": l.value,
150
+ onClick: (s) => a.$emit("select", l.value)
151
+ }, F(l.label), 11, Fe))), 128))
152
+ ], 8, qe)
153
153
  ]));
154
154
  }
155
- }), Fe = ["id", "data-model-selector-option-key", "aria-selected", "aria-disabled", "aria-describedby"], Ae = { class: "tr-model-selector__option-main" }, He = ["src"], Ue = { class: "tr-model-selector__option-copy" }, je = ["title"], Ne = ["id", "title"], Qe = /* @__PURE__ */ Q({
155
+ }), He = ["id", "data-model-selector-option-key", "aria-selected", "aria-disabled", "aria-describedby"], Ue = { class: "tr-model-selector__option-main" }, je = ["src"], Ne = { class: "tr-model-selector__option-text" }, We = ["title"], Qe = ["id", "title"], Ge = /* @__PURE__ */ J({
156
156
  name: "TrModelSelectorItem",
157
157
  __name: "ModelSelectorItem",
158
158
  props: {
@@ -164,16 +164,16 @@ const Be = { class: "tr-model-selector__effort" }, Le = { class: "tr-model-selec
164
164
  },
165
165
  emits: ["hover", "select"],
166
166
  setup(e, { emit: a }) {
167
- const n = e, t = a;
168
- function u() {
169
- n.option.disabled || t("hover", n.option.key);
167
+ const n = e, l = a;
168
+ function s() {
169
+ n.option.disabled || l("hover", n.option.key);
170
170
  }
171
171
  function f() {
172
- n.option.disabled || t("select", n.option.raw);
172
+ n.option.disabled || l("select", n.option.raw);
173
173
  }
174
- return (i, d) => (g(), w("div", {
174
+ return (c, h) => (p(), b("div", {
175
175
  id: e.optionId,
176
- class: H(["tr-model-selector__option", {
176
+ class: W(["tr-model-selector__option", {
177
177
  "is-selected": e.selected,
178
178
  "is-highlighted": e.highlighted,
179
179
  "is-disabled": e.option.disabled
@@ -182,53 +182,52 @@ const Be = { class: "tr-model-selector__effort" }, Le = { class: "tr-model-selec
182
182
  role: "option",
183
183
  "aria-selected": e.selected,
184
184
  "aria-disabled": e.option.disabled || void 0,
185
- "aria-describedby": e.option.description && !i.$slots.item ? e.descriptionId : void 0,
186
- onMouseenter: u,
187
- onMousedown: d[0] || (d[0] = pe(() => {
185
+ "aria-describedby": e.option.description && !c.$slots.item ? e.descriptionId : void 0,
186
+ onMouseenter: s,
187
+ onMousedown: h[0] || (h[0] = pe(() => {
188
188
  }, ["prevent"])),
189
189
  onClick: f
190
190
  }, [
191
- T(i.$slots, "item", {
191
+ D(c.$slots, "item", {
192
192
  option: e.option.raw,
193
193
  selected: e.selected,
194
194
  highlighted: e.highlighted
195
195
  }, () => [
196
- I("span", Ae, [
197
- typeof e.option.icon == "string" ? (g(), w("img", {
196
+ I("span", Ue, [
197
+ typeof e.option.icon == "string" ? (p(), b("img", {
198
198
  key: 0,
199
199
  src: e.option.icon,
200
200
  class: "tr-model-selector__option-icon",
201
201
  alt: "",
202
202
  "aria-hidden": "true"
203
- }, null, 8, He)) : e.option.icon ? (g(), N(se(e.option.icon), {
203
+ }, null, 8, je)) : e.option.icon ? (p(), _(se(e.option.icon), {
204
204
  key: 1,
205
205
  class: "tr-model-selector__option-icon",
206
206
  "aria-hidden": "true",
207
207
  focusable: "false"
208
- })) : D("", !0),
209
- I("span", Ue, [
208
+ })) : z("", !0),
209
+ I("span", Ne, [
210
210
  I("span", {
211
211
  class: "tr-model-selector__option-label",
212
212
  title: e.option.label
213
- }, K(e.option.label), 9, je),
214
- e.option.description ? (g(), w("span", {
213
+ }, F(e.option.label), 9, We),
214
+ e.option.description ? (p(), b("span", {
215
215
  key: 0,
216
216
  id: e.descriptionId,
217
217
  class: "tr-model-selector__option-description",
218
218
  title: e.option.description
219
- }, K(e.option.description), 9, Ne)) : D("", !0)
219
+ }, F(e.option.description), 9, Qe)) : z("", !0)
220
220
  ])
221
221
  ]),
222
- e.selected ? (g(), N(P($e), {
223
- key: 0,
222
+ N(P(Oe), {
224
223
  class: "tr-model-selector__option-check",
225
224
  "aria-hidden": "true",
226
225
  focusable: "false"
227
- })) : D("", !0)
226
+ })
228
227
  ])
229
- ], 42, Fe));
228
+ ], 42, He));
230
229
  }
231
- }), We = ["role", "aria-labelledby"], Ge = ["id"], Ye = /* @__PURE__ */ Q({
230
+ }), Ye = ["role", "aria-labelledby"], Je = ["id"], Xe = /* @__PURE__ */ J({
232
231
  name: "TrModelSelectorGroup",
233
232
  __name: "ModelSelectorGroup",
234
233
  props: {
@@ -239,51 +238,51 @@ const Be = { class: "tr-model-selector__effort" }, Le = { class: "tr-model-selec
239
238
  },
240
239
  emits: ["hover", "select"],
241
240
  setup(e) {
242
- return (a, n) => (g(), w("div", {
241
+ return (a, n) => (p(), b("div", {
243
242
  class: "tr-model-selector__group",
244
243
  role: e.group.label ? "group" : "presentation",
245
244
  "aria-labelledby": e.group.label ? `${e.optionIdPrefix}-group-${e.group.index}` : void 0
246
245
  }, [
247
- e.group.label ? (g(), w("div", {
246
+ e.group.label ? (p(), b("div", {
248
247
  key: 0,
249
248
  id: `${e.optionIdPrefix}-group-${e.group.index}`,
250
249
  class: "tr-model-selector__group-title"
251
- }, K(e.group.label), 9, Ge)) : D("", !0),
252
- (g(!0), w(ae, null, re(e.group.items, (t) => (g(), N(Qe, {
253
- key: t.key,
254
- option: t,
255
- selected: e.selectedValue === t.value,
256
- highlighted: e.highlightedKey === t.key,
257
- "option-id": `${e.optionIdPrefix}-option-${t.index}`,
258
- "description-id": `${e.optionIdPrefix}-option-${t.index}-description`,
259
- onHover: n[0] || (n[0] = (u) => a.$emit("hover", u)),
260
- onSelect: n[1] || (n[1] = (u) => a.$emit("select", u))
261
- }, _({ _: 2 }, [
250
+ }, F(e.group.label), 9, Je)) : z("", !0),
251
+ (p(!0), b(ae, null, re(e.group.items, (l) => (p(), _(Ge, {
252
+ key: l.key,
253
+ option: l,
254
+ selected: e.selectedValue === l.value,
255
+ highlighted: e.highlightedKey === l.key,
256
+ "option-id": `${e.optionIdPrefix}-option-${l.index}`,
257
+ "description-id": `${e.optionIdPrefix}-option-${l.index}-description`,
258
+ onHover: n[0] || (n[0] = (s) => a.$emit("hover", s)),
259
+ onSelect: n[1] || (n[1] = (s) => a.$emit("select", s))
260
+ }, te({ _: 2 }, [
262
261
  a.$slots.item ? {
263
262
  name: "item",
264
- fn: q((u) => [
265
- T(a.$slots, "item", ue({ ref_for: !0 }, u))
263
+ fn: H((s) => [
264
+ D(a.$slots, "item", ue({ ref_for: !0 }, s))
266
265
  ]),
267
266
  key: "0"
268
267
  } : void 0
269
268
  ]), 1032, ["option", "selected", "highlighted", "option-id", "description-id"]))), 128))
270
- ], 8, We));
269
+ ], 8, Ye));
271
270
  }
272
- }), Je = {
271
+ }), Ze = {
273
272
  key: 0,
274
273
  class: "tr-model-selector__header"
275
- }, Xe = {
274
+ }, _e = {
276
275
  key: 1,
277
276
  class: "tr-model-selector__search"
278
- }, Ze = ["value", "placeholder", "aria-label", "aria-controls", "aria-activedescendant"], _e = {
277
+ }, et = ["value", "placeholder", "aria-label", "aria-controls", "aria-activedescendant"], tt = {
279
278
  key: 2,
280
279
  class: "tr-model-selector__empty",
281
280
  role: "status",
282
281
  "aria-live": "polite"
283
- }, et = ["id", "aria-label", "aria-activedescendant"], tt = {
282
+ }, lt = ["id", "aria-label", "aria-activedescendant"], ot = {
284
283
  key: 3,
285
284
  class: "tr-model-selector__footer"
286
- }, lt = /* @__PURE__ */ Q({
285
+ }, nt = /* @__PURE__ */ J({
287
286
  name: "TrModelSelectorPanel",
288
287
  __name: "ModelSelectorPanel",
289
288
  props: {
@@ -306,110 +305,127 @@ const Be = { class: "tr-model-selector__effort" }, Le = { class: "tr-model-selec
306
305
  },
307
306
  emits: ["select", "select-effort", "close"],
308
307
  setup(e, { emit: a }) {
309
- const n = e, t = a, u = C(null), f = C(null), i = Ie({
308
+ const n = e, l = a, s = V(null), f = V(null), c = V(null), h = V(null);
309
+ let d;
310
+ const i = g(
311
+ () => h.value === null ? void 0 : { "--tr-model-selector-open-min-width": `${h.value}px` }
312
+ ), r = Be({
310
313
  options: () => n.options,
311
314
  searchable: () => n.searchable,
312
315
  filterMethod: () => n.filterMethod
313
- }), d = ze({
316
+ }), u = Le({
314
317
  enabled: () => !0,
315
- options: () => i.visibleOptions.value,
318
+ options: () => r.visibleOptions.value,
316
319
  selectedValue: () => n.selectedValue,
317
320
  containerEl: f
318
- }), m = p(() => {
319
- const o = d.highlightedOption.value;
320
- return o ? `${n.optionIdPrefix}-option-${o.index}` : void 0;
321
- }), r = p(() => ({
321
+ }), m = g(() => {
322
+ const t = u.highlightedOption.value;
323
+ return t ? `${n.optionIdPrefix}-option-${t.index}` : void 0;
324
+ }), y = g(() => ({
322
325
  ...n.slotContext,
323
- query: i.query.value
324
- })), s = p(() => ({
325
- ...r.value,
326
+ query: r.query.value
327
+ })), x = g(() => ({
328
+ ...y.value,
326
329
  reasoningEfforts: n.effortOptions,
327
- reasoningEffortOption: n.effortOptions.find((o) => o.value === n.effortValue) ?? null,
328
- setReasoningEffort: (o) => t("select-effort", o)
330
+ reasoningEffortOption: n.effortOptions.find((t) => t.value === n.effortValue) ?? null,
331
+ setReasoningEffort: (t) => l("select-effort", t)
329
332
  }));
330
- function c(o) {
331
- i.setQuery(o.target.value);
333
+ function k(t) {
334
+ r.setQuery(t.target.value);
332
335
  }
333
- function v() {
334
- const o = n.searchable ? u.value : f.value;
335
- o == null || o.focus({ preventScroll: !0 });
336
+ function $() {
337
+ const t = n.searchable ? s.value : f.value;
338
+ t == null || t.focus({ preventScroll: !0 });
336
339
  }
337
- async function y() {
338
- var b, S;
339
- await Y();
340
- const o = ((b = u.value) == null ? void 0 : b.ownerDocument.defaultView) ?? ((S = f.value) == null ? void 0 : S.ownerDocument.defaultView);
341
- if (!o || typeof o.requestAnimationFrame != "function") {
342
- v();
340
+ async function E() {
341
+ var S, M;
342
+ await Z();
343
+ const t = ((S = s.value) == null ? void 0 : S.ownerDocument.defaultView) ?? ((M = f.value) == null ? void 0 : M.ownerDocument.defaultView);
344
+ if (!t || typeof t.requestAnimationFrame != "function") {
345
+ $();
343
346
  return;
344
347
  }
345
- o.requestAnimationFrame(() => {
346
- v();
348
+ t.requestAnimationFrame(() => {
349
+ $();
347
350
  });
348
351
  }
349
- function E() {
350
- const o = d.highlightedOption.value;
351
- o && t("select", o.raw);
352
+ function R() {
353
+ const t = u.highlightedOption.value;
354
+ t && l("select", t.raw);
352
355
  }
353
- function $(o) {
354
- return o.isComposing || o.keyCode === 229;
356
+ function T(t) {
357
+ return t.isComposing || t.keyCode === 229;
355
358
  }
356
- function O(o) {
357
- if (!(o.defaultPrevented || $(o))) {
358
- if (o.key === "ArrowDown" || o.key === "ArrowUp") {
359
- o.preventDefault(), d.moveHighlight(o.key === "ArrowDown" ? 1 : -1);
359
+ function O(t) {
360
+ if (!(t.defaultPrevented || T(t))) {
361
+ if (t.key === "ArrowDown" || t.key === "ArrowUp") {
362
+ t.preventDefault(), u.moveHighlight(t.key === "ArrowDown" ? 1 : -1);
360
363
  return;
361
364
  }
362
- if (o.key === "Enter") {
363
- o.preventDefault(), E();
365
+ if (t.key === "Enter") {
366
+ t.preventDefault(), R();
364
367
  return;
365
368
  }
366
- o.key === "Escape" && (o.preventDefault(), t("close", !0));
369
+ t.key === "Escape" && (t.preventDefault(), l("close", !0));
367
370
  }
368
371
  }
369
- function x(o) {
370
- if (!(o.defaultPrevented || $(o))) {
371
- if (o.key === "ArrowDown" || o.key === "ArrowUp") {
372
- o.preventDefault(), d.moveHighlight(o.key === "ArrowDown" ? 1 : -1);
372
+ function K(t) {
373
+ if (!(t.defaultPrevented || T(t))) {
374
+ if (t.key === "ArrowDown" || t.key === "ArrowUp") {
375
+ t.preventDefault(), u.moveHighlight(t.key === "ArrowDown" ? 1 : -1);
373
376
  return;
374
377
  }
375
- if (o.key === "Home" || o.key === "End") {
376
- o.preventDefault(), d.highlightBoundary(o.key === "Home" ? "first" : "last");
378
+ if (t.key === "Home" || t.key === "End") {
379
+ t.preventDefault(), u.highlightBoundary(t.key === "Home" ? "first" : "last");
377
380
  return;
378
381
  }
379
- (o.key === "Enter" || o.key === " " || o.key === "Spacebar") && (o.preventDefault(), E());
382
+ (t.key === "Enter" || t.key === " " || t.key === "Spacebar") && (t.preventDefault(), R());
380
383
  }
381
384
  }
382
- function B(o) {
383
- o.defaultPrevented || o.key === "Escape" && (o.preventDefault(), t("close", !0));
385
+ function Q(t) {
386
+ t.defaultPrevented || t.key === "Escape" && (t.preventDefault(), l("close", !0));
384
387
  }
385
- return de(() => {
386
- y();
387
- }), j(
388
+ return ce(() => {
389
+ var B;
390
+ const t = c.value, S = (B = t == null ? void 0 : t.ownerDocument.defaultView) == null ? void 0 : B.ResizeObserver;
391
+ function M() {
392
+ if (!t)
393
+ return;
394
+ const q = Math.ceil(t.getBoundingClientRect().width);
395
+ q > (h.value ?? 0) && (h.value = q);
396
+ }
397
+ M(), t && S && (d = new S(M), d.observe(t)), E();
398
+ }), ye(() => {
399
+ d == null || d.disconnect();
400
+ }), Y(
388
401
  () => n.searchable,
389
402
  async () => {
390
- i.clearQuery(), await y();
403
+ r.clearQuery(), await E();
391
404
  }
392
- ), (o, b) => (g(), w("div", {
393
- class: H(["tr-model-selector__panel", [`tr-model-selector__panel--${e.size}`, e.panelClass]]),
394
- onKeydown: B
405
+ ), (t, S) => (p(), b("div", {
406
+ ref_key: "panelEl",
407
+ ref: c,
408
+ class: W(["tr-model-selector__panel", [`tr-model-selector__panel--${e.size}`, e.panelClass]]),
409
+ style: be(i.value),
410
+ onKeydown: Q
395
411
  }, [
396
- o.$slots.header ? (g(), w("div", Je, [
397
- T(o.$slots, "header", F(A(r.value)))
398
- ])) : D("", !0),
399
- e.searchable ? (g(), w("div", Xe, [
400
- U(P(Ee), {
412
+ t.$slots.header ? (p(), b("div", Ze, [
413
+ D(t.$slots, "header", U(j(y.value)))
414
+ ])) : z("", !0),
415
+ e.searchable ? (p(), b("div", _e, [
416
+ N(P(Se), {
401
417
  class: "tr-model-selector__search-icon",
402
418
  "aria-hidden": "true",
403
419
  focusable: "false"
404
420
  }),
405
421
  I("input", {
406
422
  ref_key: "searchInputEl",
407
- ref: u,
423
+ ref: s,
408
424
  type: "text",
409
425
  class: "tr-model-selector__search-input",
410
426
  "data-model-selector-search-input": "",
411
427
  role: "combobox",
412
- value: P(i).query.value,
428
+ value: P(r).query.value,
413
429
  placeholder: e.searchPlaceholder,
414
430
  "aria-label": e.searchPlaceholder,
415
431
  "aria-controls": e.listboxId,
@@ -419,68 +435,68 @@ const Be = { class: "tr-model-selector__effort" }, Le = { class: "tr-model-selec
419
435
  "aria-haspopup": "listbox",
420
436
  autocomplete: "off",
421
437
  spellcheck: !1,
422
- onInput: c,
438
+ onInput: k,
423
439
  onKeydown: O
424
- }, null, 40, Ze)
425
- ])) : D("", !0),
426
- P(i).isEmpty.value ? (g(), w("div", _e, [
427
- T(o.$slots, "empty", {
428
- query: P(i).query.value
440
+ }, null, 40, et)
441
+ ])) : z("", !0),
442
+ P(r).isEmpty.value ? (p(), b("div", tt, [
443
+ D(t.$slots, "empty", {
444
+ query: P(r).query.value
429
445
  }, () => [
430
- U(P(Oe), {
446
+ N(P(xe), {
431
447
  class: "tr-model-selector__empty-icon",
432
448
  "aria-hidden": "true",
433
449
  focusable: "false"
434
450
  }),
435
- I("span", null, K(e.emptyText), 1)
451
+ I("span", null, F(e.emptyText), 1)
436
452
  ])
437
- ])) : D("", !0),
453
+ ])) : z("", !0),
438
454
  I("div", {
439
455
  id: e.listboxId,
440
456
  ref_key: "listboxEl",
441
457
  ref: f,
442
- class: H(["tr-model-selector__content", { "is-empty": P(i).isEmpty.value }]),
458
+ class: W(["tr-model-selector__content", { "is-empty": P(r).isEmpty.value }]),
443
459
  role: "listbox",
444
460
  tabindex: "-1",
445
461
  "aria-label": e.placeholder,
446
462
  "aria-activedescendant": e.searchable ? void 0 : m.value,
447
- onKeydown: x
463
+ onKeydown: K
448
464
  }, [
449
- (g(!0), w(ae, null, re(P(i).groups.value, (S) => (g(), N(Ye, {
450
- key: S.key,
451
- group: S,
465
+ (p(!0), b(ae, null, re(P(r).groups.value, (M) => (p(), _(Xe, {
466
+ key: M.key,
467
+ group: M,
452
468
  "selected-value": e.selectedValue,
453
- "highlighted-key": P(d).highlightedKey.value,
469
+ "highlighted-key": P(u).highlightedKey.value,
454
470
  "option-id-prefix": e.optionIdPrefix,
455
- onHover: P(d).setHighlightedKey,
456
- onSelect: b[0] || (b[0] = (L) => o.$emit("select", L))
457
- }, _({ _: 2 }, [
458
- o.$slots.item ? {
471
+ onHover: P(u).setHighlightedKey,
472
+ onSelect: S[0] || (S[0] = (B) => t.$emit("select", B))
473
+ }, te({ _: 2 }, [
474
+ t.$slots.item ? {
459
475
  name: "item",
460
- fn: q((L) => [
461
- T(o.$slots, "item", ue({ ref_for: !0 }, L))
476
+ fn: H((B) => [
477
+ D(t.$slots, "item", ue({ ref_for: !0 }, B))
462
478
  ]),
463
479
  key: "0"
464
480
  } : void 0
465
481
  ]), 1032, ["group", "selected-value", "highlighted-key", "option-id-prefix", "onHover"]))), 128))
466
- ], 42, et),
467
- o.$slots.footer || e.effortOptions.length > 0 ? (g(), w("div", tt, [
468
- T(o.$slots, "footer", F(A(s.value)), () => [
469
- U(qe, {
482
+ ], 42, lt),
483
+ t.$slots.footer || e.effortOptions.length > 0 ? (p(), b("div", ot, [
484
+ D(t.$slots, "footer", U(j(x.value)), () => [
485
+ N(Ae, {
470
486
  options: e.effortOptions,
471
487
  value: e.effortValue,
472
488
  label: e.effortLabel,
473
489
  disabled: e.effortDisabled,
474
- onSelect: b[1] || (b[1] = (S) => o.$emit("select-effort", S))
490
+ onSelect: S[1] || (S[1] = (M) => t.$emit("select-effort", M))
475
491
  }, null, 8, ["options", "value", "label", "disabled"])
476
492
  ])
477
- ])) : D("", !0)
478
- ], 34));
493
+ ])) : z("", !0)
494
+ ], 38));
479
495
  }
480
- }), ot = ["title", "disabled", "aria-label", "aria-expanded", "aria-controls"], nt = { class: "tr-model-selector__trigger-content" }, at = ["src"], rt = { class: "tr-model-selector__trigger-label" }, it = {
496
+ }), at = ["title", "disabled", "aria-label", "aria-expanded", "aria-controls"], rt = { class: "tr-model-selector__trigger-content" }, it = ["src"], st = { class: "tr-model-selector__trigger-label" }, ut = {
481
497
  key: 2,
482
498
  class: "tr-model-selector__trigger-effort"
483
- }, st = /* @__PURE__ */ Q({
499
+ }, ct = /* @__PURE__ */ J({
484
500
  name: "TrModelSelectorTrigger",
485
501
  __name: "ModelSelectorTrigger",
486
502
  props: {
@@ -495,75 +511,75 @@ const Be = { class: "tr-model-selector__effort" }, Le = { class: "tr-model-selec
495
511
  },
496
512
  emits: ["click", "enter"],
497
513
  setup(e, { emit: a }) {
498
- const n = e, t = p(() => n.effortLabel ? `${n.label} · ${n.effortLabel}` : n.label), u = a;
499
- function f(i) {
500
- i.key === "Enter" && !i.defaultPrevented && (i.preventDefault(), u("enter", i));
514
+ const n = e, l = g(() => n.effortLabel ? `${n.label} · ${n.effortLabel}` : n.label), s = a;
515
+ function f(c) {
516
+ c.key === "Enter" && !c.defaultPrevented && (c.preventDefault(), s("enter", c));
501
517
  }
502
- return (i, d) => (g(), w("button", {
518
+ return (c, h) => (p(), b("button", {
503
519
  type: "button",
504
- class: H(["tr-model-selector__trigger", [`tr-model-selector__trigger--${e.variant}`, `tr-model-selector__trigger--${e.size}`, { "is-open": e.open }]]),
505
- title: t.value,
520
+ class: W(["tr-model-selector__trigger", [`tr-model-selector__trigger--${e.variant}`, `tr-model-selector__trigger--${e.size}`, { "is-open": e.open }]]),
521
+ title: l.value,
506
522
  disabled: e.disabled,
507
- "aria-label": t.value,
523
+ "aria-label": l.value,
508
524
  "aria-expanded": e.open,
509
525
  "aria-controls": e.controlsId,
510
526
  "aria-haspopup": "listbox",
511
- onClick: d[0] || (d[0] = (m) => i.$emit("click", m)),
527
+ onClick: h[0] || (h[0] = (d) => c.$emit("click", d)),
512
528
  onKeydown: f
513
529
  }, [
514
- T(i.$slots, "default", {}, () => [
515
- I("span", nt, [
516
- typeof e.icon == "string" ? (g(), w("img", {
530
+ D(c.$slots, "default", {}, () => [
531
+ I("span", rt, [
532
+ typeof e.icon == "string" ? (p(), b("img", {
517
533
  key: 0,
518
534
  src: e.icon,
519
535
  class: "tr-model-selector__trigger-icon",
520
536
  alt: "",
521
537
  "aria-hidden": "true"
522
- }, null, 8, at)) : e.icon ? (g(), N(se(e.icon), {
538
+ }, null, 8, it)) : e.icon ? (p(), _(se(e.icon), {
523
539
  key: 1,
524
540
  class: "tr-model-selector__trigger-icon",
525
541
  "aria-hidden": "true",
526
542
  focusable: "false"
527
- })) : D("", !0),
528
- I("span", rt, K(e.label), 1),
529
- e.effortLabel ? (g(), w("span", it, K(e.effortLabel), 1)) : D("", !0)
543
+ })) : z("", !0),
544
+ I("span", st, F(e.label), 1),
545
+ e.effortLabel ? (p(), b("span", ut, F(e.effortLabel), 1)) : z("", !0)
530
546
  ]),
531
- U(P(Se), {
547
+ N(P(Me), {
532
548
  class: "tr-model-selector__trigger-chevron",
533
549
  "aria-hidden": "true",
534
550
  focusable: "false"
535
551
  })
536
552
  ])
537
- ], 42, ot));
553
+ ], 42, at));
538
554
  }
539
555
  });
540
- function ut(e) {
541
- const a = e.controlled, n = C(e.defaultValue), t = p(() => a ? e.value() ?? null : n.value), u = p(() => e.efforts().find((i) => i.value === t.value) ?? null);
542
- function f(i) {
543
- if (Object.is(t.value, i))
556
+ function dt(e) {
557
+ const a = e.controlled, n = V(e.defaultValue), l = g(() => a ? e.value() ?? null : n.value), s = g(() => e.efforts().find((c) => c.value === l.value) ?? null);
558
+ function f(c) {
559
+ if (Object.is(l.value, c))
544
560
  return !1;
545
- if (i !== null) {
546
- const d = e.efforts().find((m) => m.value === i);
547
- if (!d || d.disabled)
561
+ if (c !== null) {
562
+ const h = e.efforts().find((d) => d.value === c);
563
+ if (!h || h.disabled)
548
564
  return !1;
549
565
  }
550
- return a || (n.value = i), e.onUpdateValue(i), !0;
566
+ return a || (n.value = c), e.onUpdateValue(c), !0;
551
567
  }
552
568
  return {
553
- value: t,
554
- activeOption: u,
569
+ value: l,
570
+ activeOption: s,
555
571
  setValue: f
556
572
  };
557
573
  }
558
574
  function ie(e, a) {
559
- var u, f;
560
- if ((((u = e.composedPath) == null ? void 0 : u.call(e)) ?? []).includes(a))
575
+ var s, f;
576
+ if ((((s = e.composedPath) == null ? void 0 : s.call(e)) ?? []).includes(a))
561
577
  return !0;
562
- const t = (f = a.ownerDocument.defaultView) == null ? void 0 : f.Node;
563
- return !!(t && e.target instanceof t && a.contains(e.target));
578
+ const l = (f = a.ownerDocument.defaultView) == null ? void 0 : f.Node;
579
+ return !!(l && e.target instanceof l && a.contains(e.target));
564
580
  }
565
- function dt(e) {
566
- const a = C(!1), n = j(
581
+ function ft(e) {
582
+ const a = V(!1), n = Y(
567
583
  () => [
568
584
  e.open(),
569
585
  e.referenceEl.value,
@@ -573,137 +589,140 @@ function dt(e) {
573
589
  e.offset(),
574
590
  e.teleportTarget()
575
591
  ],
576
- async ([t, u, f, i, d, m, r], s, c) => {
577
- if (a.value = !1, !t || !u || !f)
592
+ async ([l, s, f, c, h, d, i], r, u) => {
593
+ if (a.value = !1, !l || !s || !f)
578
594
  return;
579
- const v = u, y = f;
580
- let E = !0, $ = 0;
581
- const O = {}, x = v.ownerDocument, B = (b) => {
582
- ie(b, v) || ie(b, y) || e.onOutsidePointerDown(b);
595
+ const m = s, y = f;
596
+ let x = !0, k = 0;
597
+ const $ = {}, E = m.ownerDocument, R = (O) => {
598
+ ie(O, m) || ie(O, y) || e.onOutsidePointerDown(O);
583
599
  };
584
- x.addEventListener("pointerdown", B, !0), c(() => {
585
- var b;
586
- E = !1, $ += 1, (b = O.current) == null || b.call(O), x.removeEventListener("pointerdown", B, !0), a.value = !1;
600
+ E.addEventListener("pointerdown", R, !0), u(() => {
601
+ var O;
602
+ x = !1, k += 1, (O = $.current) == null || O.call($), E.removeEventListener("pointerdown", R, !0), a.value = !1;
587
603
  });
588
- async function o() {
589
- var S;
590
- const b = ++$;
604
+ async function T() {
605
+ var K;
606
+ const O = ++k;
591
607
  try {
592
- const L = await Pe(v, y, {
593
- placement: i,
594
- strategy: d,
608
+ const Q = await Ve(m, y, {
609
+ placement: c,
610
+ strategy: h,
595
611
  middleware: [
596
- Ve(m),
597
- Me({ padding: 8 }),
598
- Te({ padding: 8 }),
599
- Ce({
612
+ Te(d),
613
+ Ce({ padding: 8 }),
614
+ De({ padding: 8 }),
615
+ Ie({
600
616
  padding: 8,
601
- apply({ availableHeight: le, availableWidth: X, rects: oe, elements: W }) {
602
- const Z = Math.min(oe.reference.width, Math.max(0, X));
603
- W.floating.style.minWidth = `${Math.round(Z)}px`, W.floating.style.maxWidth = `${Math.max(0, Math.floor(X))}px`, W.floating.style.setProperty(
617
+ apply({ availableHeight: B, availableWidth: q, rects: oe, elements: G }) {
618
+ const ee = Math.min(oe.reference.width, Math.max(0, q));
619
+ G.floating.style.minWidth = `${Math.round(ee)}px`, G.floating.style.maxWidth = `${Math.max(0, Math.floor(q))}px`, G.floating.style.setProperty(
604
620
  "--tr-model-selector-available-height",
605
- `${Math.max(0, Math.floor(le))}px`
621
+ `${Math.max(0, Math.floor(B))}px`
622
+ ), G.floating.style.setProperty(
623
+ "--tr-model-selector-available-width",
624
+ `${Math.max(0, Math.floor(q))}px`
606
625
  );
607
626
  }
608
627
  })
609
628
  ]
610
629
  });
611
- if (!E || b !== $ || !e.open() || e.referenceEl.value !== v || e.floatingEl.value !== y)
630
+ if (!x || O !== k || !e.open() || e.referenceEl.value !== m || e.floatingEl.value !== y)
612
631
  return;
613
- const V = ((S = x.defaultView) == null ? void 0 : S.devicePixelRatio) || 1, J = Math.round(L.x * V) / V, te = Math.round(L.y * V) / V;
632
+ const t = ((K = E.defaultView) == null ? void 0 : K.devicePixelRatio) || 1, S = Math.round(Q.x * t) / t, M = Math.round(Q.y * t) / t;
614
633
  Object.assign(y.style, {
615
- left: `${J}px`,
616
- top: `${te}px`
634
+ left: `${S}px`,
635
+ top: `${M}px`
617
636
  }), a.value = !0;
618
637
  } catch {
619
- E && b === $ && (a.value = !1);
638
+ x && O === k && (a.value = !1);
620
639
  }
621
640
  }
622
- await Y(), !(!E || !e.open()) && (O.current = xe(v, y, () => {
623
- o();
641
+ await Z(), !(!x || !e.open()) && ($.current = Pe(m, y, () => {
642
+ T();
624
643
  }));
625
644
  },
626
645
  { flush: "post", immediate: !0 }
627
646
  );
628
- return ye(() => {
647
+ return we(() => {
629
648
  n();
630
649
  }), {
631
650
  isPositioned: a
632
651
  };
633
652
  }
634
- function ct(e) {
635
- const a = e.valueControlled, n = e.openControlled, t = C(e.defaultValue), u = C(e.defaultOpen), f = p(() => a ? e.value() ?? null : t.value), i = p(() => n ? !!e.open() : u.value);
636
- function d(r) {
637
- return Object.is(f.value, r) ? !1 : (a || (t.value = r), e.onUpdateValue(r), !0);
653
+ function ht(e) {
654
+ const a = e.valueControlled, n = e.openControlled, l = V(e.defaultValue), s = V(e.defaultOpen), f = g(() => a ? e.value() ?? null : l.value), c = g(() => n ? !!e.open() : s.value);
655
+ function h(i) {
656
+ return Object.is(f.value, i) ? !1 : (a || (l.value = i), e.onUpdateValue(i), !0);
638
657
  }
639
- function m(r) {
640
- return i.value === r ? !1 : (n || (u.value = r), e.onUpdateOpen(r), !0);
658
+ function d(i) {
659
+ return c.value === i ? !1 : (n || (s.value = i), e.onUpdateOpen(i), !0);
641
660
  }
642
661
  return {
643
662
  value: f,
644
- open: i,
645
- setValue: d,
646
- setOpen: m
663
+ open: c,
664
+ setValue: h,
665
+ setOpen: d
647
666
  };
648
667
  }
649
- const ft = Object.freeze([
668
+ const vt = Object.freeze([
650
669
  Object.freeze({ value: "low", label: "Low" }),
651
670
  Object.freeze({ value: "medium", label: "Medium" }),
652
671
  Object.freeze({ value: "high", label: "High" })
653
672
  ]);
654
- function ht(e) {
673
+ function mt(e) {
655
674
  if (!e)
656
675
  return [];
657
676
  if (e === !0)
658
- return ft;
677
+ return vt;
659
678
  const a = /* @__PURE__ */ new Set(), n = [];
660
- for (const t of e)
661
- a.has(t.value) || (a.add(t.value), n.push(t));
679
+ for (const l of e)
680
+ a.has(l.value) || (a.add(l.value), n.push(l));
662
681
  return n;
663
682
  }
664
- function vt(e) {
683
+ function gt(e) {
665
684
  if (!e || e === !0)
666
685
  return [];
667
686
  const a = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
668
- for (const t of e)
669
- a.has(t.value) ? n.add(t.value) : a.add(t.value);
687
+ for (const l of e)
688
+ a.has(l.value) ? n.add(l.value) : a.add(l.value);
670
689
  return Array.from(n);
671
690
  }
672
- const mt = "__tr-model-selector-ungrouped__";
691
+ const pt = "__tr-model-selector-ungrouped__";
673
692
  function ne(e) {
674
693
  return (e == null ? void 0 : e.trim()) ?? "";
675
694
  }
676
- function gt(e) {
695
+ function yt(e) {
677
696
  return e.filter((a) => !!(a && a.trim())).join(" ").toLocaleLowerCase();
678
697
  }
679
- function pt(e) {
698
+ function bt(e) {
680
699
  const a = /* @__PURE__ */ new Set(), n = [];
681
- return e.forEach((t, u) => {
682
- if (a.has(t.value))
700
+ return e.forEach((l, s) => {
701
+ if (a.has(l.value))
683
702
  return;
684
- a.add(t.value);
685
- const f = ne(t.label) || t.value, i = ne(t.description) || void 0, d = ne(t.group), m = d ? `group:${d}` : mt, r = typeof t.icon == "string" ? t.icon : t.icon ? be(t.icon) : void 0;
703
+ a.add(l.value);
704
+ const f = ne(l.label) || l.value, c = ne(l.description) || void 0, h = ne(l.group), d = h ? `group:${h}` : pt, i = typeof l.icon == "string" ? l.icon : l.icon ? ke(l.icon) : void 0;
686
705
  n.push({
687
- key: `value:${t.value}`,
688
- index: u,
689
- value: t.value,
706
+ key: `value:${l.value}`,
707
+ index: s,
708
+ value: l.value,
690
709
  label: f,
691
- description: i,
692
- icon: r,
693
- disabled: !!t.disabled,
694
- groupKey: m,
695
- searchText: gt([f, t.value, i, d]),
696
- raw: t
710
+ description: c,
711
+ icon: i,
712
+ disabled: !!l.disabled,
713
+ groupKey: d,
714
+ searchText: yt([f, l.value, c, h]),
715
+ raw: l
697
716
  });
698
717
  }), n;
699
718
  }
700
- function yt(e) {
719
+ function wt(e) {
701
720
  const a = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
702
- return e.forEach((t) => {
703
- a.has(t.value) ? n.add(t.value) : a.add(t.value);
721
+ return e.forEach((l) => {
722
+ a.has(l.value) ? n.add(l.value) : a.add(l.value);
704
723
  }), [...n];
705
724
  }
706
- const bt = { class: "tr-model-selector__dropdown-surface" }, ee = /* @__PURE__ */ Q({
725
+ const kt = { class: "tr-model-selector__dropdown-surface" }, le = /* @__PURE__ */ J({
707
726
  name: "TrModelSelector",
708
727
  __name: "index",
709
728
  props: {
@@ -714,6 +733,7 @@ const bt = { class: "tr-model-selector__dropdown-surface" }, ee = /* @__PURE__ *
714
733
  defaultReasoningEffort: { default: null },
715
734
  open: { type: Boolean, default: void 0 },
716
735
  defaultOpen: { type: Boolean, default: !1 },
736
+ closeOnSelect: { type: Boolean, default: !0 },
717
737
  disabled: { type: Boolean, default: !1 },
718
738
  searchable: { type: Boolean, default: !1 },
719
739
  placeholder: { default: "选择模型" },
@@ -730,260 +750,260 @@ const bt = { class: "tr-model-selector__dropdown-surface" }, ee = /* @__PURE__ *
730
750
  },
731
751
  emits: ["update:modelValue", "change", "update:reasoningEffort", "reasoning-effort-change", "update:open"],
732
752
  setup(e, { emit: a }) {
733
- const n = e, t = a, u = we(), f = (u == null ? void 0 : u.uid) ?? 0, i = (u == null ? void 0 : u.vnode.props) ?? {}, d = (...l) => l.some((h) => Object.prototype.hasOwnProperty.call(i, h)), m = `tr-model-selector-${f}`, r = `${m}-listbox`, s = C(null), c = C(null), v = C(!1), y = C(null), E = De(s), $ = p(() => {
734
- var M, z;
735
- if (!v.value)
753
+ const n = e, l = a, s = $e(), f = (s == null ? void 0 : s.uid) ?? 0, c = (s == null ? void 0 : s.vnode.props) ?? {}, h = (...o) => o.some((v) => Object.prototype.hasOwnProperty.call(c, v)), d = `tr-model-selector-${f}`, i = `${d}-listbox`, r = V(null), u = V(null), m = V(!1), y = V(null), x = ze(r), k = g(() => {
754
+ var C, L;
755
+ if (!m.value)
736
756
  return null;
737
- const l = E.value, h = n.appendTo;
738
- if (!h)
739
- return l;
740
- if (typeof h != "string")
741
- return h;
742
- if (h === "body" && l === ((M = s.value) == null ? void 0 : M.ownerDocument.body))
743
- return l;
744
- const k = l;
757
+ const o = x.value, v = n.appendTo;
758
+ if (!v)
759
+ return o;
760
+ if (typeof v != "string")
761
+ return v;
762
+ if (v === "body" && o === ((C = r.value) == null ? void 0 : C.ownerDocument.body))
763
+ return o;
764
+ const w = o;
745
765
  try {
746
- return ((z = k.querySelector) == null ? void 0 : z.call(k, h)) ?? l;
766
+ return ((L = w.querySelector) == null ? void 0 : L.call(w, v)) ?? o;
747
767
  } catch {
748
- return l;
768
+ return o;
749
769
  }
750
- }), O = p(() => {
751
- var k;
752
- const l = $.value, h = (k = s.value) == null ? void 0 : k.ownerDocument;
753
- return !!(h && l && l !== h.body && l.nodeType === 1);
754
- }), x = ct({
770
+ }), $ = g(() => {
771
+ var w;
772
+ const o = k.value, v = (w = r.value) == null ? void 0 : w.ownerDocument;
773
+ return !!(v && o && o !== v.body && o.nodeType === 1);
774
+ }), E = ht({
755
775
  value: () => n.modelValue,
756
776
  defaultValue: n.defaultValue,
757
- valueControlled: d("modelValue", "model-value"),
777
+ valueControlled: h("modelValue", "model-value"),
758
778
  open: () => n.open,
759
779
  defaultOpen: n.disabled ? !1 : n.defaultOpen,
760
- openControlled: d("open"),
761
- onUpdateValue: (l) => t("update:modelValue", l),
762
- onUpdateOpen: (l) => t("update:open", l)
763
- }), B = p(() => pt(n.models));
764
- p(() => yt(n.models));
765
- const o = p(() => B.value.find((l) => l.value === x.value.value) ?? null), b = p(() => {
766
- var l;
767
- return ht((l = o.value) == null ? void 0 : l.raw.reasoningEfforts);
780
+ openControlled: h("open"),
781
+ onUpdateValue: (o) => l("update:modelValue", o),
782
+ onUpdateOpen: (o) => l("update:open", o)
783
+ }), R = g(() => bt(n.models));
784
+ g(() => wt(n.models));
785
+ const T = g(() => R.value.find((o) => o.value === E.value.value) ?? null), O = g(() => {
786
+ var o;
787
+ return mt((o = T.value) == null ? void 0 : o.raw.reasoningEfforts);
768
788
  });
769
- p(() => {
770
- var l;
771
- return vt((l = o.value) == null ? void 0 : l.raw.reasoningEfforts);
789
+ g(() => {
790
+ var o;
791
+ return gt((o = T.value) == null ? void 0 : o.raw.reasoningEfforts);
772
792
  });
773
- const S = ut({
793
+ const K = dt({
774
794
  value: () => n.reasoningEffort,
775
795
  defaultValue: n.defaultReasoningEffort,
776
- efforts: () => b.value,
777
- controlled: d("reasoningEffort", "reasoning-effort"),
778
- onUpdateValue: (l) => t("update:reasoningEffort", l)
779
- }), L = p(() => {
780
- var l;
781
- return ((l = S.activeOption.value) == null ? void 0 : l.value) ?? null;
782
- }), V = p(() => x.open.value && !n.disabled), J = p(() => {
783
- var l;
784
- return ((l = o.value) == null ? void 0 : l.label) ?? n.placeholder;
785
- }), te = p(() => {
786
- var l;
796
+ efforts: () => O.value,
797
+ controlled: h("reasoningEffort", "reasoning-effort"),
798
+ onUpdateValue: (o) => l("update:reasoningEffort", o)
799
+ }), Q = g(() => {
800
+ var o;
801
+ return ((o = K.activeOption.value) == null ? void 0 : o.value) ?? null;
802
+ }), t = g(() => E.open.value && !n.disabled), S = g(() => {
803
+ var o;
804
+ return ((o = T.value) == null ? void 0 : o.label) ?? n.placeholder;
805
+ }), M = g(() => {
806
+ var o;
787
807
  return {
788
- option: ((l = o.value) == null ? void 0 : l.raw) ?? null,
789
- label: J.value,
790
- open: V.value,
791
- reasoningEffortOption: S.activeOption.value
808
+ option: ((o = T.value) == null ? void 0 : o.raw) ?? null,
809
+ label: S.value,
810
+ open: t.value,
811
+ reasoningEffortOption: K.activeOption.value
792
812
  };
793
- }), le = p(() => {
794
- var l;
813
+ }), B = g(() => {
814
+ var o;
795
815
  return {
796
- option: ((l = o.value) == null ? void 0 : l.raw) ?? null,
816
+ option: ((o = T.value) == null ? void 0 : o.raw) ?? null,
797
817
  close: me
798
818
  };
799
819
  });
800
- function X() {
801
- var l, h;
802
- (h = (l = s.value) == null ? void 0 : l.querySelector(".tr-model-selector__trigger")) == null || h.focus({ preventScroll: !0 });
820
+ function q() {
821
+ var o, v;
822
+ (v = (o = r.value) == null ? void 0 : o.querySelector(".tr-model-selector__trigger")) == null || v.focus({ preventScroll: !0 });
803
823
  }
804
824
  function oe() {
805
- var h, k;
806
- let l = ((h = s.value) == null ? void 0 : h.ownerDocument.activeElement) ?? null;
807
- for (; (k = l == null ? void 0 : l.shadowRoot) != null && k.activeElement; )
808
- l = l.shadowRoot.activeElement;
809
- return l;
825
+ var v, w;
826
+ let o = ((v = r.value) == null ? void 0 : v.ownerDocument.activeElement) ?? null;
827
+ for (; (w = o == null ? void 0 : o.shadowRoot) != null && w.activeElement; )
828
+ o = o.shadowRoot.activeElement;
829
+ return o;
810
830
  }
811
- function W() {
812
- var h;
813
- const l = oe();
814
- return !!(l && ((h = c.value) != null && h.contains(l)));
831
+ function G() {
832
+ var v;
833
+ const o = oe();
834
+ return !!(o && ((v = u.value) != null && v.contains(o)));
815
835
  }
816
- function Z() {
817
- n.disabled || x.setOpen(!0);
836
+ function ee() {
837
+ n.disabled || E.setOpen(!0);
818
838
  }
819
- function G(l) {
820
- var z;
821
- if (!V.value || y.value !== null)
839
+ function X(o) {
840
+ var L;
841
+ if (!t.value || y.value !== null)
822
842
  return;
823
- if (y.value = l, !x.setOpen(!1)) {
843
+ if (y.value = o, !E.setOpen(!1)) {
824
844
  y.value = null;
825
845
  return;
826
846
  }
827
- const k = () => {
828
- V.value && y.value === l && (y.value = null);
829
- }, M = (z = s.value) == null ? void 0 : z.ownerDocument.defaultView;
830
- M ? M.setTimeout(k, 0) : Y().then(k);
847
+ const w = () => {
848
+ t.value && y.value === o && (y.value = null);
849
+ }, C = (L = r.value) == null ? void 0 : L.ownerDocument.defaultView;
850
+ C ? C.setTimeout(w, 0) : Z().then(w);
831
851
  }
832
- function ce() {
833
- V.value ? G(!1) : Z();
852
+ function de() {
853
+ t.value ? X(!1) : ee();
834
854
  }
835
855
  function fe() {
836
- Z();
856
+ ee();
837
857
  }
838
- function he(l) {
839
- const h = B.value.find((M) => M.value === l.value);
840
- if (!h || h.disabled)
858
+ function he(o) {
859
+ const v = R.value.find((C) => C.value === o.value);
860
+ if (!v || v.disabled)
841
861
  return;
842
- x.setValue(h.value) && t("change", h.raw), G(!0);
862
+ E.setValue(v.value) && l("change", v.raw), n.closeOnSelect && X(!0);
843
863
  }
844
- function ve(l) {
845
- var M;
846
- if (n.disabled || (M = o.value) != null && M.disabled)
864
+ function ve(o) {
865
+ var C;
866
+ if (n.disabled || (C = T.value) != null && C.disabled)
847
867
  return;
848
- const h = l === null ? null : b.value.find((z) => z.value === l) ?? null;
849
- S.setValue(l) && t("reasoning-effort-change", h);
868
+ const v = o === null ? null : O.value.find((L) => L.value === o) ?? null;
869
+ K.setValue(o) && l("reasoning-effort-change", v);
850
870
  }
851
871
  function me() {
852
- G(!0);
872
+ X(!0);
853
873
  }
854
- const { isPositioned: ge } = dt({
855
- referenceEl: s,
856
- floatingEl: c,
857
- open: () => V.value,
874
+ const { isPositioned: ge } = ft({
875
+ referenceEl: r,
876
+ floatingEl: u,
877
+ open: () => t.value,
858
878
  placement: () => n.placement,
859
- strategy: () => O.value ? "absolute" : "fixed",
879
+ strategy: () => $.value ? "absolute" : "fixed",
860
880
  offset: () => n.offset,
861
- teleportTarget: () => $.value,
862
- onOutsidePointerDown: () => G(!1)
881
+ teleportTarget: () => k.value,
882
+ onOutsidePointerDown: () => X(!1)
863
883
  });
864
- return j(
884
+ return Y(
865
885
  () => n.disabled,
866
- (l) => {
867
- l && x.open.value && (y.value = !1, x.setOpen(!1));
886
+ (o) => {
887
+ o && E.open.value && (y.value = !1, E.setOpen(!1));
868
888
  }
869
- ), j(
870
- V,
871
- async (l, h) => {
872
- if (!l) {
873
- if (h) {
874
- const k = y.value ?? W();
875
- y.value = null, k && (await Y(), X());
889
+ ), Y(
890
+ t,
891
+ async (o, v) => {
892
+ if (!o) {
893
+ if (v) {
894
+ const w = y.value ?? G();
895
+ y.value = null, w && (await Z(), q());
876
896
  }
877
897
  return;
878
898
  }
879
899
  },
880
900
  { immediate: !0 }
881
- ), de(() => {
882
- v.value = !0;
883
- }), (l, h) => {
884
- var k, M, z;
885
- return g(), w("div", {
886
- class: H(["tr-model-selector", [`tr-model-selector--${e.variant}`, `tr-model-selector--${e.size}`]])
901
+ ), ce(() => {
902
+ m.value = !0;
903
+ }), (o, v) => {
904
+ var w, C, L;
905
+ return p(), b("div", {
906
+ class: W(["tr-model-selector", [`tr-model-selector--${e.variant}`, `tr-model-selector--${e.size}`]])
887
907
  }, [
888
908
  I("span", {
889
909
  ref_key: "referenceEl",
890
- ref: s,
910
+ ref: r,
891
911
  class: "tr-model-selector__anchor"
892
912
  }, [
893
- U(st, {
894
- open: V.value,
913
+ N(ct, {
914
+ open: t.value,
895
915
  disabled: e.disabled,
896
- label: J.value,
897
- "effort-label": (k = P(S).activeOption.value) == null ? void 0 : k.label,
898
- icon: (M = o.value) == null ? void 0 : M.icon,
899
- "controls-id": r,
916
+ label: S.value,
917
+ "effort-label": (w = P(K).activeOption.value) == null ? void 0 : w.label,
918
+ icon: (C = T.value) == null ? void 0 : C.icon,
919
+ "controls-id": i,
900
920
  variant: e.variant,
901
921
  size: e.size,
902
- onClick: ce,
922
+ onClick: de,
903
923
  onEnter: fe
904
- }, _({ _: 2 }, [
905
- l.$slots.trigger ? {
924
+ }, te({ _: 2 }, [
925
+ o.$slots.trigger ? {
906
926
  name: "default",
907
- fn: q(() => [
908
- T(l.$slots, "trigger", F(A(te.value)))
927
+ fn: H(() => [
928
+ D(o.$slots, "trigger", U(j(M.value)))
909
929
  ]),
910
930
  key: "0"
911
931
  } : void 0
912
932
  ]), 1032, ["open", "disabled", "label", "effort-label", "icon", "variant", "size"])
913
933
  ], 512),
914
- $.value ? (g(), N(ke, {
934
+ k.value ? (p(), _(Ee, {
915
935
  key: 0,
916
- to: $.value
936
+ to: k.value
917
937
  }, [
918
- V.value ? (g(), w("div", {
938
+ t.value ? (p(), b("div", {
919
939
  key: 0,
920
940
  ref_key: "floatingEl",
921
- ref: c,
922
- class: H(["tr-model-selector__dropdown-wrapper", { "is-positioned": P(ge), "is-absolute": O.value }])
941
+ ref: u,
942
+ class: W(["tr-model-selector__dropdown-wrapper", { "is-positioned": P(ge), "is-absolute": $.value }])
923
943
  }, [
924
- I("div", bt, [
925
- U(lt, {
926
- options: B.value,
927
- "selected-value": P(x).value.value,
944
+ I("div", kt, [
945
+ N(nt, {
946
+ options: R.value,
947
+ "selected-value": P(E).value.value,
928
948
  searchable: e.searchable,
929
949
  "filter-method": e.filterMethod,
930
- "listbox-id": r,
931
- "option-id-prefix": m,
950
+ "listbox-id": i,
951
+ "option-id-prefix": d,
932
952
  placeholder: e.placeholder,
933
953
  "search-placeholder": e.searchPlaceholder,
934
954
  "empty-text": e.emptyText,
935
- "effort-options": b.value,
936
- "effort-value": L.value,
955
+ "effort-options": O.value,
956
+ "effort-value": Q.value,
937
957
  "effort-label": e.reasoningEffortLabel,
938
- "effort-disabled": !!((z = o.value) != null && z.disabled),
958
+ "effort-disabled": !!((L = T.value) != null && L.disabled),
939
959
  size: e.size,
940
960
  "panel-class": e.panelClass,
941
- "slot-context": le.value,
961
+ "slot-context": B.value,
942
962
  onSelect: he,
943
963
  onSelectEffort: ve,
944
- onClose: G
945
- }, _({ _: 2 }, [
946
- l.$slots.header ? {
964
+ onClose: X
965
+ }, te({ _: 2 }, [
966
+ o.$slots.header ? {
947
967
  name: "header",
948
- fn: q((R) => [
949
- T(l.$slots, "header", F(A(R)))
968
+ fn: H((A) => [
969
+ D(o.$slots, "header", U(j(A)))
950
970
  ]),
951
971
  key: "0"
952
972
  } : void 0,
953
- l.$slots.item ? {
973
+ o.$slots.item ? {
954
974
  name: "item",
955
- fn: q((R) => [
956
- T(l.$slots, "item", F(A(R)))
975
+ fn: H((A) => [
976
+ D(o.$slots, "item", U(j(A)))
957
977
  ]),
958
978
  key: "1"
959
979
  } : void 0,
960
- l.$slots.empty ? {
980
+ o.$slots.empty ? {
961
981
  name: "empty",
962
- fn: q((R) => [
963
- T(l.$slots, "empty", F(A(R)))
982
+ fn: H((A) => [
983
+ D(o.$slots, "empty", U(j(A)))
964
984
  ]),
965
985
  key: "2"
966
986
  } : void 0,
967
- l.$slots.footer ? {
987
+ o.$slots.footer ? {
968
988
  name: "footer",
969
- fn: q((R) => [
970
- T(l.$slots, "footer", F(A(R)))
989
+ fn: H((A) => [
990
+ D(o.$slots, "footer", U(j(A)))
971
991
  ]),
972
992
  key: "3"
973
993
  } : void 0
974
994
  ]), 1032, ["options", "selected-value", "searchable", "filter-method", "placeholder", "search-placeholder", "empty-text", "effort-options", "effort-value", "effort-label", "effort-disabled", "size", "panel-class", "slot-context"])
975
995
  ])
976
- ], 2)) : D("", !0)
977
- ], 8, ["to"])) : D("", !0)
996
+ ], 2)) : z("", !0)
997
+ ], 8, ["to"])) : z("", !0)
978
998
  ], 2);
979
999
  };
980
1000
  }
981
1001
  });
982
- ee.name = "TrModelSelector";
983
- const wt = function(e) {
984
- e.component(ee.name, ee);
1002
+ le.name = "TrModelSelector";
1003
+ const $t = function(e) {
1004
+ e.component(le.name, le);
985
1005
  };
986
- ee.install = wt;
1006
+ le.install = $t;
987
1007
  export {
988
- ee as default
1008
+ le as default
989
1009
  };