@tombcato/ai-selector-vue 0.1.3 → 0.1.4

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/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { ref as $, computed as A, onMounted as ne, watch as q, defineComponent as V, onUnmounted as ie, createElementBlock as p, openBlock as m, normalizeClass as z, Fragment as R, renderList as ee, normalizeStyle as G, toDisplayString as w, unref as v, createCommentVNode as W, createVNode as j, createElementVNode as n, withDirectives as ve, vModelText as he, createTextVNode as D } from "vue";
1
+ import { ref as $, computed as S, onMounted as ne, watch as q, defineComponent as V, onUnmounted as ie, createElementBlock as p, openBlock as m, normalizeClass as z, Fragment as R, renderList as ee, normalizeStyle as G, toDisplayString as w, unref as v, createCommentVNode as W, createVNode as j, createElementVNode as n, withDirectives as ve, vModelText as he, createTextVNode as D } from "vue";
2
2
  import { resolveProviderConfig as fe, createConfigStorage as pe, fetchModels as me, testConnection as ge, I18N as Q } from "@tombcato/ai-selector-core";
3
3
  function ye(e = {}) {
4
4
  var N, E, H, Y, O;
5
- const r = $(((N = e.initialConfig) == null ? void 0 : N.providerId) || ""), l = $(((E = e.initialConfig) == null ? void 0 : E.apiKey) || ""), a = $(((H = e.initialConfig) == null ? void 0 : H.model) || ""), t = $(((Y = e.initialConfig) == null ? void 0 : Y.modelName) || ""), s = $(((O = e.initialConfig) == null ? void 0 : O.baseUrl) || ""), f = $([]), u = $("idle"), i = $(null), y = $(!1), c = $(null), g = A(() => fe(e.providerConfig)), d = A(() => g.value.providers), h = A(
5
+ const r = $(((N = e.initialConfig) == null ? void 0 : N.providerId) || ""), l = $(((E = e.initialConfig) == null ? void 0 : E.apiKey) || ""), a = $(((H = e.initialConfig) == null ? void 0 : H.model) || ""), t = $(((Y = e.initialConfig) == null ? void 0 : Y.modelName) || ""), s = $(((O = e.initialConfig) == null ? void 0 : O.baseUrl) || ""), f = $([]), u = $("idle"), i = $(null), y = $(!1), c = $(null), g = S(() => fe(e.providerConfig)), d = S(() => g.value.providers), h = S(
6
6
  () => d.value.find((o) => o.id === r.value) || null
7
7
  ), M = pe(void 0, {
8
8
  serialize: e.onSerialize,
@@ -90,7 +90,7 @@ function ye(e = {}) {
90
90
  u.value = "idle";
91
91
  }, 2e3), o;
92
92
  }
93
- function S() {
93
+ function A() {
94
94
  const o = f.value.find((F) => F.id === a.value), b = (o == null ? void 0 : o.name) || t.value || a.value;
95
95
  o != null && o.name && o.name !== t.value && (t.value = o.name), M.save({
96
96
  providerId: r.value,
@@ -111,10 +111,10 @@ function ye(e = {}) {
111
111
  t.value = (F == null ? void 0 : F.name) || o;
112
112
  }
113
113
  }
114
- const T = A(() => {
114
+ const T = S(() => {
115
115
  var o;
116
116
  return !(!r.value || !a.value || (o = h.value) != null && o.needsApiKey && !l.value);
117
- }), C = A(() => {
117
+ }), C = S(() => {
118
118
  var o;
119
119
  return {
120
120
  providerId: r.value,
@@ -143,7 +143,7 @@ function ye(e = {}) {
143
143
  config: C,
144
144
  // Actions
145
145
  runTest: k,
146
- save: S,
146
+ save: A,
147
147
  clear: K,
148
148
  selectModel: L
149
149
  };
@@ -223,9 +223,9 @@ function Ce(e, r, l) {
223
223
  for (let k = 0; k <= d; k++) M[k][0] = k;
224
224
  for (let k = 0; k <= h; k++) M[0][k] = k;
225
225
  for (let k = 1; k <= d; k++)
226
- for (let S = 1; S <= h; S++) {
227
- const K = e[a + k - 1] === r[t + S - 1] ? 0 : 1;
228
- M[k][S] = Math.min(M[k - 1][S] + 1, M[k][S - 1] + 1, M[k - 1][S - 1] + K);
226
+ for (let A = 1; A <= h; A++) {
227
+ const K = e[a + k - 1] === r[t + A - 1] ? 0 : 1;
228
+ M[k][A] = Math.min(M[k - 1][A] + 1, M[k][A - 1] + 1, M[k - 1][A - 1] + K);
229
229
  }
230
230
  const I = [];
231
231
  let x = d, U = h;
@@ -235,8 +235,8 @@ function Ce(e, r, l) {
235
235
  else if (U === 0)
236
236
  I.push(X), x--;
237
237
  else {
238
- const k = M[x][U - 1], S = M[x - 1][U], K = M[x - 1][U - 1];
239
- k < S && k < K ? (I.push(J), U--) : S < K ? (I.push(X), x--) : (I.push(Z), x--, U--);
238
+ const k = M[x][U - 1], A = M[x - 1][U], K = M[x - 1][U - 1];
239
+ k < A && k < K ? (I.push(J), U--) : A < K ? (I.push(X), x--) : (I.push(Z), x--, U--);
240
240
  }
241
241
  for (let k = I.length - 1; k >= 0; k--) s.push(I[k]);
242
242
  }
@@ -297,7 +297,7 @@ const de = {
297
297
  setup(e) {
298
298
  const r = e, l = $([]), a = $(1);
299
299
  let t;
300
- const s = A(() => r.characterLists.map((i) => new ke(i))), f = A(() => {
300
+ const s = S(() => r.characterLists.map((i) => new ke(i))), f = S(() => {
301
301
  const i = /* @__PURE__ */ new Set();
302
302
  return s.value.forEach((y) => y.getSupportedCharacters().forEach((c) => i.add(c))), i;
303
303
  });
@@ -320,10 +320,10 @@ const de = {
320
320
  x.push(se(N, B, s.value, r.direction));
321
321
  }
322
322
  l.value = x, a.value = 0;
323
- const k = performance.now(), S = r.duration, K = de[r.easing] || de.linear;
323
+ const k = performance.now(), A = r.duration, K = de[r.easing] || de.linear;
324
324
  let L = 0;
325
325
  const T = (C) => {
326
- const N = Math.min((C - k) / S, 1), E = K(N);
326
+ const N = Math.min((C - k) / A, 1), E = K(N);
327
327
  if ((C - L >= 16 || N >= 1) && (L = C, a.value = E), N < 1)
328
328
  t = requestAnimationFrame(T);
329
329
  else {
@@ -335,7 +335,7 @@ const de = {
335
335
  }, { immediate: !0 }), ie(() => {
336
336
  t && cancelAnimationFrame(t);
337
337
  });
338
- const u = A(() => l.value.map((i) => {
338
+ const u = S(() => l.value.map((i) => {
339
339
  const { charIdx: y, delta: c } = le(i, a.value), g = i.sourceWidth + (i.targetWidth - i.sourceWidth) * a.value;
340
340
  if (g <= 0) return { width: g, chars: [] };
341
341
  const d = [], h = i.charList || [], M = c * re, I = (C, N, E) => {
@@ -346,7 +346,7 @@ const de = {
346
346
  });
347
347
  };
348
348
  I(y, 0, "c"), I(y + 1, -re, "n"), I(y - 1, re, "p");
349
- const x = (C) => C && C.length > 0 && C.charCodeAt(0) > 255, U = (C) => x(C) ? 1.25 : 0.8, k = h[i.startIndex] || "", S = h[i.endIndex] || "", K = U(k), L = U(S), T = K + (L - K) * a.value;
349
+ const x = (C) => C && C.length > 0 && C.charCodeAt(0) > 255, U = (C) => x(C) ? 1.25 : 0.8, k = h[i.startIndex] || "", A = h[i.endIndex] || "", K = U(k), L = U(A), T = K + (L - K) * a.value;
350
350
  return { width: g, chars: d, baseW: T };
351
351
  }).filter((i) => i.width > 0));
352
352
  return (i, y) => (m(), p("div", {
@@ -392,7 +392,7 @@ const de = {
392
392
  }, null, 8, ["value"])
393
393
  ], 2)) : W("", !0);
394
394
  }
395
- }), $e = { class: "apmsu-label" }, Ue = { class: "relative" }, Se = ["disabled"], Ae = {
395
+ }), $e = { class: "apmsu-label" }, Ue = { class: "relative" }, Ae = ["disabled"], Se = {
396
396
  key: 0,
397
397
  class: "flex items-center gap-2 min-w-0"
398
398
  }, Le = ["src", "alt"], ze = {
@@ -408,7 +408,7 @@ const de = {
408
408
  },
409
409
  emits: ["select"],
410
410
  setup(e, { emit: r }) {
411
- const l = e, a = r, t = $(!1), s = $(null), f = A(() => Q[l.language]), u = A(() => l.providers.find((c) => c.id === l.selectedProviderId));
411
+ const l = e, a = r, t = $(!1), s = $(null), f = S(() => Q[l.language]), u = S(() => l.providers.find((c) => c.id === l.selectedProviderId));
412
412
  function i(c) {
413
413
  s.value && !s.value.contains(c.target) && (t.value = !1);
414
414
  }
@@ -433,7 +433,7 @@ const de = {
433
433
  disabled: e.disabled,
434
434
  class: "apmsu-select-trigger"
435
435
  }, [
436
- u.value ? (m(), p("div", Ae, [
436
+ u.value ? (m(), p("div", Se, [
437
437
  n("img", {
438
438
  src: u.value.icon,
439
439
  alt: u.value.name,
@@ -456,7 +456,7 @@ const de = {
456
456
  d: "M19 9l-7 7-7-7"
457
457
  }, null, -1)
458
458
  ])], 2))
459
- ], 8, Se),
459
+ ], 8, Ae),
460
460
  n("div", {
461
461
  class: z(["apmsu-dropdown max-h-[300px] overflow-auto p-1 origin-top", t.value ? "apmsu-dropdown-open" : ""])
462
462
  }, [
@@ -506,7 +506,7 @@ const de = {
506
506
  },
507
507
  emits: ["update:apiKey"],
508
508
  setup(e, { emit: r }) {
509
- const l = e, a = r, t = $(!1), s = A(() => Q[l.language]), f = A(() => l.testStatus === "success" ? "apmsu-input apmsu-input-success" : "apmsu-input apmsu-input-default");
509
+ const l = e, a = r, t = $(!1), s = S(() => Q[l.language]), f = S(() => "apmsu-input apmsu-input-default");
510
510
  return (u, i) => e.provider && e.provider.needsApiKey ? (m(), p("div", Ee, [
511
511
  n("label", Oe, w(s.value.apiKeyLabel), 1),
512
512
  n("div", We, [
@@ -579,11 +579,11 @@ const de = {
579
579
  },
580
580
  emits: ["select"],
581
581
  setup(e, { emit: r }) {
582
- const l = e, a = r, t = $(!1), s = $(""), f = $(null), u = A(() => Q[l.language]), i = A(
582
+ const l = e, a = r, t = $(!1), s = $(""), f = $(null), u = S(() => Q[l.language]), i = S(
583
583
  () => l.models.filter(
584
584
  (d) => d.name.toLowerCase().includes(s.value.toLowerCase()) || d.id.toLowerCase().includes(s.value.toLowerCase())
585
585
  )
586
- ), y = A(
586
+ ), y = S(
587
587
  () => {
588
588
  var d;
589
589
  return ((d = l.models.find((h) => h.id === l.selectedModelId)) == null ? void 0 : d.name) || l.selectedModelName || l.selectedModelId;
@@ -686,7 +686,7 @@ const de = {
686
686
  },
687
687
  emits: ["update:baseUrl"],
688
688
  setup(e, { emit: r }) {
689
- const l = e, a = r, t = $(!1), s = A(() => Q[l.language]);
689
+ const l = e, a = r, t = $(!1), s = S(() => Q[l.language]);
690
690
  return (f, u) => e.provider ? (m(), p(R, { key: 0 }, [
691
691
  n("button", {
692
692
  type: "button",
@@ -743,7 +743,7 @@ const de = {
743
743
  }, Ct = { class: "overflow-hidden" }, wt = { class: "p-2 rounded-md bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800" }, Mt = { class: "text-xs text-red-600 dark:text-red-400 line-clamp-3 text-left" }, It = {
744
744
  key: 1,
745
745
  class: "mt-6 border border-gray-200/50 dark:border-zinc-800 rounded-lg overflow-hidden"
746
- }, $t = { class: "text-xs font-medium text-gray-500 dark:text-zinc-500 uppercase tracking-wider" }, Ut = { class: "overflow-hidden" }, St = { class: "text-xs text-gray-600 dark:text-zinc-400 font-mono overflow-x-auto leading-relaxed p-4 bg-zinc-50 dark:bg-zinc-900/50" }, zt = /* @__PURE__ */ V({
746
+ }, $t = { class: "text-xs font-medium text-gray-500 dark:text-zinc-500 uppercase tracking-wider" }, Ut = { class: "overflow-hidden" }, At = { class: "text-xs text-gray-600 dark:text-zinc-400 font-mono overflow-x-auto leading-relaxed p-4 bg-zinc-50 dark:bg-zinc-900/50" }, zt = /* @__PURE__ */ V({
747
747
  __name: "AIConfigForm",
748
748
  props: {
749
749
  proxyUrl: {},
@@ -776,7 +776,7 @@ const de = {
776
776
  runTest: x,
777
777
  save: U,
778
778
  selectModel: k,
779
- isFetchingModels: S,
779
+ isFetchingModels: A,
780
780
  fetchModelError: K
781
781
  } = ye({
782
782
  proxyUrl: l.proxyUrl,
@@ -785,7 +785,7 @@ const de = {
785
785
  onSerialize: l.onSerialize,
786
786
  onDeserialize: l.onDeserialize,
787
787
  modelFetcher: l.modelFetcher
788
- }), L = A(() => Q[l.language]), T = $("idle"), C = $(!1);
788
+ }), L = S(() => Q[l.language]), T = $("idle"), C = $(!1);
789
789
  q([t, s, f, i], () => {
790
790
  a("change", {
791
791
  providerId: t.value,
@@ -843,7 +843,7 @@ const de = {
843
843
  testStatus: v(c),
844
844
  disabled: e.disabled,
845
845
  language: e.language,
846
- isFetchingModels: v(S),
846
+ isFetchingModels: v(A),
847
847
  fetchModelError: v(K)
848
848
  }, null, 8, ["provider", "apiKey", "testStatus", "disabled", "language", "isFetchingModels", "fetchModelError"]),
849
849
  j(nt, {
@@ -854,7 +854,7 @@ const de = {
854
854
  hasApiKey: !!v(s),
855
855
  disabled: e.disabled,
856
856
  language: e.language,
857
- isFetchingModels: v(S),
857
+ isFetchingModels: v(A),
858
858
  fetchModelError: v(K),
859
859
  selectedModelName: v(u)
860
860
  }, null, 8, ["provider", "models", "selectedModelId", "hasApiKey", "disabled", "language", "isFetchingModels", "fetchModelError", "selectedModelName"])
@@ -977,7 +977,7 @@ const de = {
977
977
  style: G({ gridTemplateRows: C.value ? "1fr" : "0fr" })
978
978
  }, [
979
979
  n("div", Ut, [
980
- n("pre", St, "" + w(JSON.stringify({
980
+ n("pre", At, "" + w(JSON.stringify({
981
981
  provider: v(d).name,
982
982
  apiFormat: v(d).apiFormat,
983
983
  baseUrl: v(i) || v(d).baseUrl,