llm-testrunner-components 1.0.3 → 1.0.5

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.
Files changed (63) hide show
  1. package/README.md +113 -10
  2. package/dist/cjs/app-globals-CbbEbofA.js +14 -0
  3. package/dist/cjs/app-globals-CbbEbofA.js.map +1 -0
  4. package/dist/cjs/{index-CY2lQip_.js → index-D-FySkoV.js} +25 -5
  5. package/dist/cjs/index-D-FySkoV.js.map +1 -0
  6. package/dist/cjs/index.cjs.js +159 -66
  7. package/dist/cjs/index.cjs.js.map +1 -1
  8. package/dist/cjs/llm-test-runner.cjs.entry.js +1 -1
  9. package/dist/cjs/llm-testrunner.cjs.js +4 -4
  10. package/dist/cjs/llm-testrunner.cjs.js.map +1 -1
  11. package/dist/cjs/loader.cjs.js +3 -3
  12. package/dist/collection/collection-manifest.json +3 -2
  13. package/dist/collection/components/llm-test-runner/llm-test-runner.js +152 -72
  14. package/dist/collection/components/llm-test-runner/llm-test-runner.js.map +1 -1
  15. package/dist/collection/global/env.js +6 -0
  16. package/dist/collection/global/env.js.map +1 -0
  17. package/dist/collection/lib/rate-limited-fetcher/rate-limited-fetcher.js +39 -0
  18. package/dist/collection/lib/rate-limited-fetcher/rate-limited-fetcher.js.map +1 -0
  19. package/dist/components/index.js +6 -1650
  20. package/dist/components/index.js.map +1 -1
  21. package/dist/components/llm-test-runner.js +1 -1
  22. package/dist/components/p-CYUbsbxt.js +1770 -0
  23. package/dist/components/p-CYUbsbxt.js.map +1 -0
  24. package/dist/esm/app-globals-BOQOUavG.js +12 -0
  25. package/dist/esm/app-globals-BOQOUavG.js.map +1 -0
  26. package/dist/esm/{index-DBp-rMPb.js → index-cncubhtM.js} +25 -6
  27. package/dist/esm/index-cncubhtM.js.map +1 -0
  28. package/dist/esm/index.js +159 -66
  29. package/dist/esm/index.js.map +1 -1
  30. package/dist/esm/llm-test-runner.entry.js +1 -1
  31. package/dist/esm/llm-testrunner.js +5 -5
  32. package/dist/esm/llm-testrunner.js.map +1 -1
  33. package/dist/esm/loader.js +4 -4
  34. package/dist/llm-testrunner/index.esm.js +1 -1
  35. package/dist/llm-testrunner/index.esm.js.map +1 -1
  36. package/dist/llm-testrunner/llm-testrunner.esm.js +1 -1
  37. package/dist/llm-testrunner/llm-testrunner.esm.js.map +1 -1
  38. package/dist/llm-testrunner/p-BOQOUavG.js +2 -0
  39. package/dist/llm-testrunner/p-BOQOUavG.js.map +1 -0
  40. package/dist/llm-testrunner/p-cncubhtM.js +3 -0
  41. package/dist/llm-testrunner/p-cncubhtM.js.map +1 -0
  42. package/dist/llm-testrunner/p-f68fd660.entry.js +2 -0
  43. package/dist/react/components.d.ts +6 -3
  44. package/dist/react/components.d.ts.map +1 -1
  45. package/dist/react/components.js +2 -2
  46. package/dist/types/components/llm-test-runner/llm-test-runner.d.ts +13 -4
  47. package/dist/types/components.d.ts +26 -2
  48. package/dist/types/global/env.d.ts +8 -0
  49. package/dist/types/lib/rate-limited-fetcher/rate-limited-fetcher.d.ts +10 -0
  50. package/dist/types/stencil-public-runtime.d.ts +19 -10
  51. package/package.json +3 -1
  52. package/dist/cjs/app-globals-V2Kpy_OQ.js +0 -8
  53. package/dist/cjs/app-globals-V2Kpy_OQ.js.map +0 -1
  54. package/dist/cjs/index-CY2lQip_.js.map +0 -1
  55. package/dist/esm/app-globals-DQuL1Twl.js +0 -6
  56. package/dist/esm/app-globals-DQuL1Twl.js.map +0 -1
  57. package/dist/esm/index-DBp-rMPb.js.map +0 -1
  58. package/dist/llm-testrunner/p-DBp-rMPb.js +0 -3
  59. package/dist/llm-testrunner/p-DBp-rMPb.js.map +0 -1
  60. package/dist/llm-testrunner/p-DQuL1Twl.js +0 -2
  61. package/dist/llm-testrunner/p-DQuL1Twl.js.map +0 -1
  62. package/dist/llm-testrunner/p-ed2ea423.entry.js +0 -2
  63. /package/dist/llm-testrunner/{p-ed2ea423.entry.js.map → p-f68fd660.entry.js.map} +0 -0
@@ -1,1658 +1,14 @@
1
- const NAMESPACE = 'llm-testrunner';
2
- const BUILD = /* llm-testrunner */ { hydratedSelectorName: "hydrated", lazyLoad: false, propChangeCallback: false, updatable: true};
1
+ export { L as LLMTestRunner, g as getAssetPath, r as render, s as setAssetPath, a as setNonce, b as setPlatformOptions } from './p-CYUbsbxt.js';
3
2
 
4
- /*
5
- Stencil Client Platform v4.38.1 | MIT Licensed | https://stenciljs.com
6
- */
7
- var __defProp = Object.defineProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
-
13
- // src/utils/es2022-rewire-class-members.ts
14
- var reWireGetterSetter = (instance, hostRef) => {
15
- var _a;
16
- const cmpMeta = hostRef.$cmpMeta$;
17
- const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
18
- members.map(([memberName, [memberFlags]]) => {
19
- if ((memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) {
20
- const ogValue = instance[memberName];
21
- const ogDescriptor = getPropertyDescriptor(Object.getPrototypeOf(instance), memberName) || Object.getOwnPropertyDescriptor(instance, memberName);
22
- if (ogDescriptor) {
23
- Object.defineProperty(instance, memberName, {
24
- get() {
25
- return ogDescriptor.get.call(this);
26
- },
27
- set(newValue) {
28
- ogDescriptor.set.call(this, newValue);
29
- },
30
- configurable: true,
31
- enumerable: true
32
- });
33
- }
34
- instance[memberName] = hostRef.$instanceValues$.has(memberName) ? hostRef.$instanceValues$.get(memberName) : ogValue;
35
- }
36
- });
37
- };
38
- function getPropertyDescriptor(obj, memberName) {
39
- while (obj) {
40
- const desc = Object.getOwnPropertyDescriptor(obj, memberName);
41
- if (desc == null ? void 0 : desc.get) return desc;
42
- obj = Object.getPrototypeOf(obj);
43
- }
44
- return void 0;
45
- }
46
-
47
- // src/client/client-host-ref.ts
48
- var getHostRef = (ref) => {
49
- if (ref.__stencil__getHostRef) {
50
- return ref.__stencil__getHostRef();
51
- }
52
- return void 0;
53
- };
54
- var registerHost = (hostElement, cmpMeta) => {
55
- const hostRef = {
56
- $flags$: 0,
57
- $hostElement$: hostElement,
58
- $cmpMeta$: cmpMeta,
59
- $instanceValues$: /* @__PURE__ */ new Map(),
60
- $serializerValues$: /* @__PURE__ */ new Map()
61
- };
62
- {
63
- hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
64
- hostElement["s-p"] = [];
65
- hostElement["s-rc"] = [];
66
- }
67
- const ref = hostRef;
68
- hostElement.__stencil__getHostRef = () => ref;
69
- {
70
- reWireGetterSetter(hostElement, hostRef);
71
- }
72
- return ref;
73
- };
74
- var isMemberInElement = (elm, memberName) => memberName in elm;
75
- var consoleError = (e, el) => (0, console.error)(e, el);
76
-
77
- // src/client/client-style.ts
78
- var styles = /* @__PURE__ */ new Map();
79
- var SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
80
- var win = typeof window !== "undefined" ? window : {};
81
- var H = win.HTMLElement || class {
82
- };
83
- var plt = {
84
- $flags$: 0,
85
- $resourcesUrl$: "",
86
- jmp: (h2) => h2(),
87
- raf: (h2) => requestAnimationFrame(h2),
88
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
89
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
90
- ce: (eventName, opts) => new CustomEvent(eventName, opts)
91
- };
92
- var promiseResolve = (v) => Promise.resolve(v);
93
- var supportsConstructableStylesheets = /* @__PURE__ */ (() => {
94
- try {
95
- new CSSStyleSheet();
96
- return typeof new CSSStyleSheet().replaceSync === "function";
97
- } catch (e) {
98
- }
99
- return false;
100
- })() ;
101
- var supportsMutableAdoptedStyleSheets = supportsConstructableStylesheets ? /* @__PURE__ */ (() => !!win.document && Object.getOwnPropertyDescriptor(win.document.adoptedStyleSheets, "length").writable)() : false;
102
- var queuePending = false;
103
- var queueDomReads = [];
104
- var queueDomWrites = [];
105
- var queueTask = (queue, write) => (cb) => {
106
- queue.push(cb);
107
- if (!queuePending) {
108
- queuePending = true;
109
- if (write && plt.$flags$ & 4 /* queueSync */) {
110
- nextTick(flush);
111
- } else {
112
- plt.raf(flush);
113
- }
114
- }
115
- };
116
- var consume = (queue) => {
117
- for (let i2 = 0; i2 < queue.length; i2++) {
118
- try {
119
- queue[i2](performance.now());
120
- } catch (e) {
121
- consoleError(e);
122
- }
123
- }
124
- queue.length = 0;
125
- };
126
- var flush = () => {
127
- consume(queueDomReads);
128
- {
129
- consume(queueDomWrites);
130
- if (queuePending = queueDomReads.length > 0) {
131
- plt.raf(flush);
132
- }
133
- }
134
- };
135
- var nextTick = (cb) => promiseResolve().then(cb);
136
- var writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true);
137
-
138
- // src/runtime/asset-path.ts
139
- var getAssetPath = (path) => {
140
- const assetUrl = new URL(path, plt.$resourcesUrl$);
141
- return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
142
- };
143
- var setAssetPath = (path) => plt.$resourcesUrl$ = path;
144
- var isComplexType = (o) => {
145
- o = typeof o;
146
- return o === "object" || o === "function";
147
- };
148
-
149
- // src/utils/query-nonce-meta-tag-content.ts
150
- function queryNonceMetaTagContent(doc) {
151
- var _a, _b, _c;
152
- return (_c = (_b = (_a = doc.head) == null ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) == null ? void 0 : _b.getAttribute("content")) != null ? _c : void 0;
153
- }
154
-
155
- // src/utils/regular-expression.ts
156
- var escapeRegExpSpecialCharacters = (text) => {
157
- return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
158
- };
159
-
160
- // src/utils/result.ts
161
- var result_exports = {};
162
- __export(result_exports, {
163
- err: () => err,
164
- map: () => map,
165
- ok: () => ok,
166
- unwrap: () => unwrap,
167
- unwrapErr: () => unwrapErr
168
- });
169
- var ok = (value) => ({
170
- isOk: true,
171
- isErr: false,
172
- value
173
- });
174
- var err = (value) => ({
175
- isOk: false,
176
- isErr: true,
177
- value
178
- });
179
- function map(result, fn) {
180
- if (result.isOk) {
181
- const val = fn(result.value);
182
- if (val instanceof Promise) {
183
- return val.then((newVal) => ok(newVal));
184
- } else {
185
- return ok(val);
186
- }
187
- }
188
- if (result.isErr) {
189
- const value = result.value;
190
- return err(value);
191
- }
192
- throw "should never get here";
193
- }
194
- var unwrap = (result) => {
195
- if (result.isOk) {
196
- return result.value;
197
- } else {
198
- throw result.value;
199
- }
200
- };
201
- var unwrapErr = (result) => {
202
- if (result.isErr) {
203
- return result.value;
204
- } else {
205
- throw result.value;
206
- }
207
- };
208
-
209
- // src/utils/style.ts
210
- function createStyleSheetIfNeededAndSupported(styles2) {
211
- return void 0;
212
- }
213
-
214
- // src/utils/shadow-root.ts
215
- var globalStyleSheet;
216
- function createShadowRoot(cmpMeta) {
217
- var _a;
218
- const shadowRoot = this.attachShadow({ mode: "open" });
219
- if (globalStyleSheet === void 0) globalStyleSheet = (_a = createStyleSheetIfNeededAndSupported()) != null ? _a : null;
220
- if (globalStyleSheet) {
221
- if (supportsMutableAdoptedStyleSheets) {
222
- shadowRoot.adoptedStyleSheets.push(globalStyleSheet);
223
- } else {
224
- shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, globalStyleSheet];
225
- }
226
- }
227
- }
228
- var createTime = (fnName, tagName = "") => {
229
- {
230
- return () => {
231
- return;
3
+ function appGlobalScript () {
4
+ window.env = {
5
+ API_KEY: ''
232
6
  };
233
- }
234
- };
235
- var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
236
- var registerStyle = (scopeId2, cssText, allowCS) => {
237
- let style = styles.get(scopeId2);
238
- if (supportsConstructableStylesheets && allowCS) {
239
- style = style || new CSSStyleSheet();
240
- if (typeof style === "string") {
241
- style = cssText;
242
- } else {
243
- style.replaceSync(cssText);
244
- }
245
- } else {
246
- style = cssText;
247
- }
248
- styles.set(scopeId2, style);
249
- };
250
- var addStyle = (styleContainerNode, cmpMeta, mode) => {
251
- var _a;
252
- const scopeId2 = getScopeId(cmpMeta);
253
- const style = styles.get(scopeId2);
254
- if (!win.document) {
255
- return scopeId2;
256
- }
257
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : win.document;
258
- if (style) {
259
- if (typeof style === "string") {
260
- styleContainerNode = styleContainerNode.head || styleContainerNode;
261
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
262
- let styleElm;
263
- if (!appliedStyles) {
264
- rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
265
- }
266
- if (!appliedStyles.has(scopeId2)) {
267
- {
268
- styleElm = win.document.createElement("style");
269
- styleElm.innerHTML = style;
270
- const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(win.document);
271
- if (nonce != null) {
272
- styleElm.setAttribute("nonce", nonce);
273
- }
274
- if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
275
- if (styleContainerNode.nodeName === "HEAD") {
276
- const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
277
- const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
278
- styleContainerNode.insertBefore(
279
- styleElm,
280
- (referenceNode2 == null ? void 0 : referenceNode2.parentNode) === styleContainerNode ? referenceNode2 : null
281
- );
282
- } else if ("host" in styleContainerNode) {
283
- if (supportsConstructableStylesheets) {
284
- const stylesheet = new CSSStyleSheet();
285
- stylesheet.replaceSync(style);
286
- if (supportsMutableAdoptedStyleSheets) {
287
- styleContainerNode.adoptedStyleSheets.unshift(stylesheet);
288
- } else {
289
- styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
290
- }
291
- } else {
292
- const existingStyleContainer = styleContainerNode.querySelector("style");
293
- if (existingStyleContainer) {
294
- existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
295
- } else {
296
- styleContainerNode.prepend(styleElm);
297
- }
298
- }
299
- } else {
300
- styleContainerNode.append(styleElm);
301
- }
302
- }
303
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
304
- styleContainerNode.insertBefore(styleElm, null);
305
- }
306
- }
307
- if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
308
- styleElm.innerHTML += SLOT_FB_CSS;
309
- }
310
- if (appliedStyles) {
311
- appliedStyles.add(scopeId2);
312
- }
313
- }
314
- } else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
315
- if (supportsMutableAdoptedStyleSheets) {
316
- styleContainerNode.adoptedStyleSheets.push(style);
317
- } else {
318
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
319
- }
320
- }
321
- }
322
- return scopeId2;
323
- };
324
- var attachStyles = (hostRef) => {
325
- const cmpMeta = hostRef.$cmpMeta$;
326
- const elm = hostRef.$hostElement$;
327
- const flags = cmpMeta.$flags$;
328
- const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
329
- const scopeId2 = addStyle(
330
- elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
331
- cmpMeta);
332
- if (flags & 10 /* needsScopedEncapsulation */) {
333
- elm["s-sc"] = scopeId2;
334
- elm.classList.add(scopeId2 + "-h");
335
- }
336
- endAttachStyles();
337
- };
338
- var getScopeId = (cmp, mode) => "sc-" + (cmp.$tagName$);
339
- var h = (nodeName, vnodeData, ...children) => {
340
- let child = null;
341
- let key = null;
342
- let simple = false;
343
- let lastSimple = false;
344
- const vNodeChildren = [];
345
- const walk = (c) => {
346
- for (let i2 = 0; i2 < c.length; i2++) {
347
- child = c[i2];
348
- if (Array.isArray(child)) {
349
- walk(child);
350
- } else if (child != null && typeof child !== "boolean") {
351
- if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
352
- child = String(child);
353
- }
354
- if (simple && lastSimple) {
355
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
356
- } else {
357
- vNodeChildren.push(simple ? newVNode(null, child) : child);
358
- }
359
- lastSimple = simple;
360
- }
361
- }
362
- };
363
- walk(children);
364
- if (vnodeData) {
365
- if (vnodeData.key) {
366
- key = vnodeData.key;
367
- }
368
- {
369
- const classData = vnodeData.className || vnodeData.class;
370
- if (classData) {
371
- vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
372
- }
373
- }
374
- }
375
- if (typeof nodeName === "function") {
376
- return nodeName(
377
- vnodeData === null ? {} : vnodeData,
378
- vNodeChildren,
379
- vdomFnUtils
380
- );
381
- }
382
- const vnode = newVNode(nodeName, null);
383
- vnode.$attrs$ = vnodeData;
384
- if (vNodeChildren.length > 0) {
385
- vnode.$children$ = vNodeChildren;
386
- }
387
- {
388
- vnode.$key$ = key;
389
- }
390
- return vnode;
391
- };
392
- var newVNode = (tag, text) => {
393
- const vnode = {
394
- $flags$: 0,
395
- $tag$: tag,
396
- $text$: text,
397
- $elm$: null,
398
- $children$: null
399
- };
400
- {
401
- vnode.$attrs$ = null;
402
- }
403
- {
404
- vnode.$key$ = null;
405
- }
406
- return vnode;
407
- };
408
- var Host = {};
409
- var isHost = (node) => node && node.$tag$ === Host;
410
- var vdomFnUtils = {
411
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
412
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
413
- };
414
- var convertToPublic = (node) => ({
415
- vattrs: node.$attrs$,
416
- vchildren: node.$children$,
417
- vkey: node.$key$,
418
- vname: node.$name$,
419
- vtag: node.$tag$,
420
- vtext: node.$text$
421
- });
422
- var convertToPrivate = (node) => {
423
- if (typeof node.vtag === "function") {
424
- const vnodeData = { ...node.vattrs };
425
- if (node.vkey) {
426
- vnodeData.key = node.vkey;
427
- }
428
- if (node.vname) {
429
- vnodeData.name = node.vname;
430
- }
431
- return h(node.vtag, vnodeData, ...node.vchildren || []);
432
- }
433
- const vnode = newVNode(node.vtag, node.vtext);
434
- vnode.$attrs$ = node.vattrs;
435
- vnode.$children$ = node.vchildren;
436
- vnode.$key$ = node.vkey;
437
- vnode.$name$ = node.vname;
438
- return vnode;
439
- };
440
- var createSupportsRuleRe = (selector) => {
441
- const safeSelector2 = escapeRegExpSpecialCharacters(selector);
442
- return new RegExp(
443
- // First capture group: match any context before the selector that's not inside @supports selector()
444
- // Using negative lookahead to avoid matching inside @supports selector(...) condition
445
- `(^|[^@]|@(?!supports\\s+selector\\s*\\([^{]*?${safeSelector2}))(${safeSelector2}\\b)`,
446
- "g"
447
- );
448
- };
449
- createSupportsRuleRe("::slotted");
450
- createSupportsRuleRe(":host");
451
- createSupportsRuleRe(":host-context");
452
- var parsePropertyValue = (propValue, propType, isFormAssociated) => {
453
- if (propValue != null && !isComplexType(propValue)) {
454
- if (propType & 1 /* String */) {
455
- return String(propValue);
456
- }
457
- return propValue;
458
- }
459
- return propValue;
460
- };
461
- var emitEvent = (elm, name, opts) => {
462
- const ev = plt.ce(name, opts);
463
- elm.dispatchEvent(ev);
464
- return ev;
465
- };
466
- var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRender) => {
467
- if (oldValue === newValue) {
468
- return;
469
- }
470
- let isProp = isMemberInElement(elm, memberName);
471
- let ln = memberName.toLowerCase();
472
- if (memberName === "class") {
473
- const classList = elm.classList;
474
- const oldClasses = parseClassList(oldValue);
475
- let newClasses = parseClassList(newValue);
476
- {
477
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
478
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
479
- }
480
- } else if (memberName === "key") ; else if (memberName === "ref") {
481
- if (newValue) {
482
- newValue(elm);
483
- }
484
- } else if ((!elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
485
- if (memberName[2] === "-") {
486
- memberName = memberName.slice(3);
487
- } else if (isMemberInElement(win, ln)) {
488
- memberName = ln.slice(2);
489
- } else {
490
- memberName = ln[2] + memberName.slice(3);
491
- }
492
- if (oldValue || newValue) {
493
- const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
494
- memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
495
- if (oldValue) {
496
- plt.rel(elm, memberName, oldValue, capture);
497
- }
498
- if (newValue) {
499
- plt.ael(elm, memberName, newValue, capture);
500
- }
501
- }
502
- } else {
503
- const isComplex = isComplexType(newValue);
504
- if ((isProp || isComplex && newValue !== null) && true) {
505
- try {
506
- if (!elm.tagName.includes("-")) {
507
- const n = newValue == null ? "" : newValue;
508
- if (memberName === "list") {
509
- isProp = false;
510
- } else if (oldValue == null || elm[memberName] != n) {
511
- if (typeof elm.__lookupSetter__(memberName) === "function") {
512
- elm[memberName] = n;
513
- } else {
514
- elm.setAttribute(memberName, n);
515
- }
516
- }
517
- } else if (elm[memberName] !== newValue) {
518
- elm[memberName] = newValue;
519
- }
520
- } catch (e) {
521
- }
522
- }
523
- if (newValue == null || newValue === false) {
524
- if (newValue !== false || elm.getAttribute(memberName) === "") {
525
- {
526
- elm.removeAttribute(memberName);
527
- }
528
- }
529
- } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex && elm.nodeType === 1 /* ElementNode */) {
530
- newValue = newValue === true ? "" : newValue;
531
- {
532
- elm.setAttribute(memberName, newValue);
533
- }
534
- }
535
- }
536
- };
537
- var parseClassListRegex = /\s/;
538
- var parseClassList = (value) => {
539
- if (typeof value === "object" && value && "baseVal" in value) {
540
- value = value.baseVal;
541
- }
542
- if (!value || typeof value !== "string") {
543
- return [];
544
- }
545
- return value.split(parseClassListRegex);
546
- };
547
- var CAPTURE_EVENT_SUFFIX = "Capture";
548
- var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
549
-
550
- // src/runtime/vdom/update-element.ts
551
- var updateElement = (oldVnode, newVnode, isSvgMode2, isInitialRender) => {
552
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
553
- const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
554
- const newVnodeAttrs = newVnode.$attrs$ || {};
555
- {
556
- for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
557
- if (!(memberName in newVnodeAttrs)) {
558
- setAccessor(
559
- elm,
560
- memberName,
561
- oldVnodeAttrs[memberName],
562
- void 0,
563
- isSvgMode2,
564
- newVnode.$flags$);
565
- }
566
- }
567
- }
568
- for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
569
- setAccessor(
570
- elm,
571
- memberName,
572
- oldVnodeAttrs[memberName],
573
- newVnodeAttrs[memberName],
574
- isSvgMode2,
575
- newVnode.$flags$);
576
- }
577
- };
578
- function sortedAttrNames(attrNames) {
579
- return attrNames.includes("ref") ? (
580
- // we need to sort these to ensure that `'ref'` is the last attr
581
- [...attrNames.filter((attr) => attr !== "ref"), "ref"]
582
- ) : (
583
- // no need to sort, return the original array
584
- attrNames
585
- );
586
7
  }
587
- var hostTagName;
588
- var isSvgMode = false;
589
- var createElm = (oldParentVNode, newParentVNode, childIndex) => {
590
- const newVNode2 = newParentVNode.$children$[childIndex];
591
- let i2 = 0;
592
- let elm;
593
- let childNode;
594
- if (newVNode2.$text$ !== null) {
595
- elm = newVNode2.$elm$ = win.document.createTextNode(newVNode2.$text$);
596
- } else {
597
- if (!win.document) {
598
- throw new Error(
599
- "You are trying to render a Stencil component in an environment that doesn't support the DOM. Make sure to populate the [`window`](https://developer.mozilla.org/en-US/docs/Web/API/Window/window) object before rendering a component."
600
- );
601
- }
602
- elm = newVNode2.$elm$ = win.document.createElement(
603
- newVNode2.$tag$
604
- );
605
- {
606
- updateElement(null, newVNode2, isSvgMode);
607
- }
608
- if (newVNode2.$children$) {
609
- for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
610
- childNode = createElm(oldParentVNode, newVNode2, i2);
611
- if (childNode) {
612
- elm.appendChild(childNode);
613
- }
614
- }
615
- }
616
- }
617
- elm["s-hn"] = hostTagName;
618
- return elm;
619
- };
620
- var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
621
- let containerElm = parentElm;
622
- let childNode;
623
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
624
- containerElm = containerElm.shadowRoot;
625
- }
626
- for (; startIdx <= endIdx; ++startIdx) {
627
- if (vnodes[startIdx]) {
628
- childNode = createElm(null, parentVNode, startIdx);
629
- if (childNode) {
630
- vnodes[startIdx].$elm$ = childNode;
631
- insertBefore(containerElm, childNode, before);
632
- }
633
- }
634
- }
635
- };
636
- var removeVnodes = (vnodes, startIdx, endIdx) => {
637
- for (let index = startIdx; index <= endIdx; ++index) {
638
- const vnode = vnodes[index];
639
- if (vnode) {
640
- const elm = vnode.$elm$;
641
- nullifyVNodeRefs(vnode);
642
- if (elm) {
643
- elm.remove();
644
- }
645
- }
646
- }
647
- };
648
- var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
649
- let oldStartIdx = 0;
650
- let newStartIdx = 0;
651
- let idxInOld = 0;
652
- let i2 = 0;
653
- let oldEndIdx = oldCh.length - 1;
654
- let oldStartVnode = oldCh[0];
655
- let oldEndVnode = oldCh[oldEndIdx];
656
- let newEndIdx = newCh.length - 1;
657
- let newStartVnode = newCh[0];
658
- let newEndVnode = newCh[newEndIdx];
659
- let node;
660
- let elmToMove;
661
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
662
- if (oldStartVnode == null) {
663
- oldStartVnode = oldCh[++oldStartIdx];
664
- } else if (oldEndVnode == null) {
665
- oldEndVnode = oldCh[--oldEndIdx];
666
- } else if (newStartVnode == null) {
667
- newStartVnode = newCh[++newStartIdx];
668
- } else if (newEndVnode == null) {
669
- newEndVnode = newCh[--newEndIdx];
670
- } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
671
- patch(oldStartVnode, newStartVnode, isInitialRender);
672
- oldStartVnode = oldCh[++oldStartIdx];
673
- newStartVnode = newCh[++newStartIdx];
674
- } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
675
- patch(oldEndVnode, newEndVnode, isInitialRender);
676
- oldEndVnode = oldCh[--oldEndIdx];
677
- newEndVnode = newCh[--newEndIdx];
678
- } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
679
- patch(oldStartVnode, newEndVnode, isInitialRender);
680
- insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
681
- oldStartVnode = oldCh[++oldStartIdx];
682
- newEndVnode = newCh[--newEndIdx];
683
- } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
684
- patch(oldEndVnode, newStartVnode, isInitialRender);
685
- insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
686
- oldEndVnode = oldCh[--oldEndIdx];
687
- newStartVnode = newCh[++newStartIdx];
688
- } else {
689
- idxInOld = -1;
690
- {
691
- for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
692
- if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
693
- idxInOld = i2;
694
- break;
695
- }
696
- }
697
- }
698
- if (idxInOld >= 0) {
699
- elmToMove = oldCh[idxInOld];
700
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
701
- node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
702
- } else {
703
- patch(elmToMove, newStartVnode, isInitialRender);
704
- oldCh[idxInOld] = void 0;
705
- node = elmToMove.$elm$;
706
- }
707
- newStartVnode = newCh[++newStartIdx];
708
- } else {
709
- node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
710
- newStartVnode = newCh[++newStartIdx];
711
- }
712
- if (node) {
713
- {
714
- insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
715
- }
716
- }
717
- }
718
- }
719
- if (oldStartIdx > oldEndIdx) {
720
- addVnodes(
721
- parentElm,
722
- newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
723
- newVNode2,
724
- newCh,
725
- newStartIdx,
726
- newEndIdx
727
- );
728
- } else if (newStartIdx > newEndIdx) {
729
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
730
- }
731
- };
732
- var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
733
- if (leftVNode.$tag$ === rightVNode.$tag$) {
734
- if (!isInitialRender) {
735
- return leftVNode.$key$ === rightVNode.$key$;
736
- }
737
- if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) {
738
- leftVNode.$key$ = rightVNode.$key$;
739
- }
740
- return true;
741
- }
742
- return false;
743
- };
744
- var patch = (oldVNode, newVNode2, isInitialRender = false) => {
745
- const elm = newVNode2.$elm$ = oldVNode.$elm$;
746
- const oldChildren = oldVNode.$children$;
747
- const newChildren = newVNode2.$children$;
748
- const text = newVNode2.$text$;
749
- if (text === null) {
750
- {
751
- updateElement(oldVNode, newVNode2, isSvgMode);
752
- }
753
- if (oldChildren !== null && newChildren !== null) {
754
- updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
755
- } else if (newChildren !== null) {
756
- if (oldVNode.$text$ !== null) {
757
- elm.textContent = "";
758
- }
759
- addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
760
- } else if (
761
- // don't do this on initial render as it can cause non-hydrated content to be removed
762
- !isInitialRender && BUILD.updatable && oldChildren !== null
763
- ) {
764
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
765
- } else ;
766
- } else if (oldVNode.$text$ !== text) {
767
- elm.data = text;
768
- }
769
- };
770
- var nullifyVNodeRefs = (vNode) => {
771
- {
772
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
773
- vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
774
- }
775
- };
776
- var insertBefore = (parent, newNode, reference) => {
777
- {
778
- return parent == null ? void 0 : parent.insertBefore(newNode, reference);
779
- }
780
- };
781
- var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
782
- const hostElm = hostRef.$hostElement$;
783
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
784
- const isHostElement = isHost(renderFnResults);
785
- const rootVnode = isHostElement ? renderFnResults : h(null, null, renderFnResults);
786
- hostTagName = hostElm.tagName;
787
- if (isInitialLoad && rootVnode.$attrs$) {
788
- for (const key of Object.keys(rootVnode.$attrs$)) {
789
- if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
790
- rootVnode.$attrs$[key] = hostElm[key];
791
- }
792
- }
793
- }
794
- rootVnode.$tag$ = null;
795
- rootVnode.$flags$ |= 4 /* isHost */;
796
- hostRef.$vnode$ = rootVnode;
797
- rootVnode.$elm$ = oldVNode.$elm$ = hostElm.shadowRoot || hostElm ;
798
- patch(oldVNode, rootVnode, isInitialLoad);
799
- };
800
-
801
- // src/runtime/update-component.ts
802
- var attachToAncestor = (hostRef, ancestorComponent) => {
803
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
804
- const index = ancestorComponent["s-p"].push(
805
- new Promise(
806
- (r) => hostRef.$onRenderResolve$ = () => {
807
- ancestorComponent["s-p"].splice(index - 1, 1);
808
- r();
809
- }
810
- )
811
- );
812
- }
813
- };
814
- var scheduleUpdate = (hostRef, isInitialLoad) => {
815
- {
816
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
817
- }
818
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
819
- hostRef.$flags$ |= 512 /* needsRerender */;
820
- return;
821
- }
822
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
823
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
824
- if (isInitialLoad) {
825
- queueMicrotask(() => {
826
- dispatch();
827
- });
828
- return;
829
- }
830
- return writeTask(dispatch) ;
831
- };
832
- var dispatchHooks = (hostRef, isInitialLoad) => {
833
- const elm = hostRef.$hostElement$;
834
- const endSchedule = createTime("scheduleUpdate", hostRef.$cmpMeta$.$tagName$);
835
- const instance = elm;
836
- if (!instance) {
837
- throw new Error(
838
- `Can't render component <${elm.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`
839
- );
840
- }
841
- let maybePromise;
842
- if (isInitialLoad) {
843
- maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
844
- } else {
845
- maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
846
- }
847
- maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender", void 0, elm));
848
- endSchedule();
849
- return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
850
- };
851
- var enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn).catch((err2) => {
852
- console.error(err2);
853
- fn();
854
- }) : fn();
855
- var isPromisey = (maybePromise) => maybePromise instanceof Promise || maybePromise && maybePromise.then && typeof maybePromise.then === "function";
856
- var updateComponent = async (hostRef, instance, isInitialLoad) => {
857
- var _a;
858
- const elm = hostRef.$hostElement$;
859
- const endUpdate = createTime("update", hostRef.$cmpMeta$.$tagName$);
860
- const rc = elm["s-rc"];
861
- if (isInitialLoad) {
862
- attachStyles(hostRef);
863
- }
864
- const endRender = createTime("render", hostRef.$cmpMeta$.$tagName$);
865
- {
866
- callRender(hostRef, instance, elm, isInitialLoad);
867
- }
868
- if (rc) {
869
- rc.map((cb) => cb());
870
- elm["s-rc"] = void 0;
871
- }
872
- endRender();
873
- endUpdate();
874
- {
875
- const childrenPromises = (_a = elm["s-p"]) != null ? _a : [];
876
- const postUpdate = () => postUpdateComponent(hostRef);
877
- if (childrenPromises.length === 0) {
878
- postUpdate();
879
- } else {
880
- Promise.all(childrenPromises).then(postUpdate);
881
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
882
- childrenPromises.length = 0;
883
- }
884
- }
885
- };
886
- var callRender = (hostRef, instance, elm, isInitialLoad) => {
887
- try {
888
- instance = instance.render() ;
889
- {
890
- hostRef.$flags$ &= -17 /* isQueuedForUpdate */;
891
- }
892
- {
893
- hostRef.$flags$ |= 2 /* hasRendered */;
894
- }
895
- {
896
- {
897
- {
898
- renderVdom(hostRef, instance, isInitialLoad);
899
- }
900
- }
901
- }
902
- } catch (e) {
903
- consoleError(e, hostRef.$hostElement$);
904
- }
905
- return null;
906
- };
907
- var postUpdateComponent = (hostRef) => {
908
- const tagName = hostRef.$cmpMeta$.$tagName$;
909
- const elm = hostRef.$hostElement$;
910
- const endPostUpdate = createTime("postUpdate", tagName);
911
- const instance = elm;
912
- const ancestorComponent = hostRef.$ancestorComponent$;
913
- safeCall(instance, "componentDidRender", void 0, elm);
914
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
915
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
916
- {
917
- addHydratedFlag(elm);
918
- }
919
- safeCall(instance, "componentDidLoad", void 0, elm);
920
- endPostUpdate();
921
- {
922
- hostRef.$onReadyResolve$(elm);
923
- if (!ancestorComponent) {
924
- appDidLoad();
925
- }
926
- }
927
- } else {
928
- safeCall(instance, "componentDidUpdate", void 0, elm);
929
- endPostUpdate();
930
- }
931
- {
932
- if (hostRef.$onRenderResolve$) {
933
- hostRef.$onRenderResolve$();
934
- hostRef.$onRenderResolve$ = void 0;
935
- }
936
- if (hostRef.$flags$ & 512 /* needsRerender */) {
937
- nextTick(() => scheduleUpdate(hostRef, false));
938
- }
939
- hostRef.$flags$ &= -517;
940
- }
941
- };
942
- var appDidLoad = (who) => {
943
- nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } }));
944
- };
945
- var safeCall = (instance, method, arg, elm) => {
946
- if (instance && instance[method]) {
947
- try {
948
- return instance[method](arg);
949
- } catch (e) {
950
- consoleError(e, elm);
951
- }
952
- }
953
- return void 0;
954
- };
955
- var addHydratedFlag = (elm) => {
956
- var _a;
957
- return elm.classList.add((_a = BUILD.hydratedSelectorName) != null ? _a : "hydrated") ;
958
- };
959
-
960
- // src/runtime/set-value.ts
961
- var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
962
- var setValue = (ref, propName, newVal, cmpMeta) => {
963
- const hostRef = getHostRef(ref);
964
- if (!hostRef) {
965
- return;
966
- }
967
- const elm = ref;
968
- const oldVal = hostRef.$instanceValues$.get(propName);
969
- const flags = hostRef.$flags$;
970
- const instance = elm;
971
- newVal = parsePropertyValue(
972
- newVal,
973
- cmpMeta.$members$[propName][0]);
974
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
975
- const didValueChange = newVal !== oldVal && !areBothNaN;
976
- if (didValueChange) {
977
- hostRef.$instanceValues$.set(propName, newVal);
978
- {
979
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
980
- if (instance.componentShouldUpdate) {
981
- if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
982
- return;
983
- }
984
- }
985
- scheduleUpdate(hostRef, false);
986
- }
987
- }
988
- }
989
- };
990
-
991
- // src/runtime/proxy-component.ts
992
- var proxyComponent = (Cstr, cmpMeta, flags) => {
993
- var _a, _b;
994
- const prototype = Cstr.prototype;
995
- if (cmpMeta.$members$ || BUILD.propChangeCallback) {
996
- const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
997
- members.map(([memberName, [memberFlags]]) => {
998
- if ((memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) {
999
- const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(prototype, memberName) || {};
1000
- if (origGetter) cmpMeta.$members$[memberName][0] |= 2048 /* Getter */;
1001
- if (origSetter) cmpMeta.$members$[memberName][0] |= 4096 /* Setter */;
1002
- {
1003
- Object.defineProperty(prototype, memberName, {
1004
- get() {
1005
- {
1006
- return origGetter ? origGetter.apply(this) : getValue(this, memberName);
1007
- }
1008
- },
1009
- configurable: true,
1010
- enumerable: true
1011
- });
1012
- }
1013
- Object.defineProperty(prototype, memberName, {
1014
- set(newValue) {
1015
- const ref = getHostRef(this);
1016
- if (!ref) {
1017
- return;
1018
- }
1019
- if (origSetter) {
1020
- const currentValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
1021
- if (typeof currentValue === "undefined" && ref.$instanceValues$.get(memberName)) {
1022
- newValue = ref.$instanceValues$.get(memberName);
1023
- }
1024
- origSetter.apply(this, [
1025
- parsePropertyValue(
1026
- newValue,
1027
- memberFlags)
1028
- ]);
1029
- newValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
1030
- setValue(this, memberName, newValue, cmpMeta);
1031
- return;
1032
- }
1033
- {
1034
- setValue(this, memberName, newValue, cmpMeta);
1035
- return;
1036
- }
1037
- }
1038
- });
1039
- }
1040
- });
1041
- {
1042
- const attrNameToPropName = /* @__PURE__ */ new Map();
1043
- prototype.attributeChangedCallback = function(attrName, oldValue, newValue) {
1044
- plt.jmp(() => {
1045
- var _a2;
1046
- const propName = attrNameToPropName.get(attrName);
1047
- const hostRef = getHostRef(this);
1048
- if (this.hasOwnProperty(propName) && BUILD.lazyLoad) ;
1049
- if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && // cast type to number to avoid TS compiler issues
1050
- this[propName] == newValue) {
1051
- return;
1052
- } else if (propName == null) {
1053
- const flags2 = hostRef == null ? void 0 : hostRef.$flags$;
1054
- if (hostRef && flags2 && !(flags2 & 8 /* isConstructingInstance */) && flags2 & 128 /* isWatchReady */ && newValue !== oldValue) {
1055
- const elm = this;
1056
- const instance = elm;
1057
- const entry = (_a2 = cmpMeta.$watchers$) == null ? void 0 : _a2[attrName];
1058
- entry == null ? void 0 : entry.forEach((callbackName) => {
1059
- if (instance[callbackName] != null) {
1060
- instance[callbackName].call(instance, newValue, oldValue, attrName);
1061
- }
1062
- });
1063
- }
1064
- return;
1065
- }
1066
- const propFlags = members.find(([m]) => m === propName);
1067
- if (propFlags && propFlags[1][0] & 4 /* Boolean */) {
1068
- newValue = newValue === null || newValue === "false" ? false : true;
1069
- }
1070
- const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
1071
- if (newValue != this[propName] && (!propDesc.get || !!propDesc.set)) {
1072
- this[propName] = newValue;
1073
- }
1074
- });
1075
- };
1076
- Cstr.observedAttributes = Array.from(
1077
- /* @__PURE__ */ new Set([
1078
- ...Object.keys((_b = cmpMeta.$watchers$) != null ? _b : {}),
1079
- ...members.filter(([_, m]) => m[0] & 31 /* HasAttribute */).map(([propName, m]) => {
1080
- const attrName = m[1] || propName;
1081
- attrNameToPropName.set(attrName, propName);
1082
- return attrName;
1083
- })
1084
- ])
1085
- );
1086
- }
1087
- }
1088
- return Cstr;
1089
- };
1090
-
1091
- // src/runtime/initialize-component.ts
1092
- var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1093
- let Cstr;
1094
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1095
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1096
- {
1097
- Cstr = elm.constructor;
1098
- const cmpTag = elm.localName;
1099
- customElements.whenDefined(cmpTag).then(() => hostRef.$flags$ |= 128 /* isWatchReady */);
1100
- }
1101
- if (Cstr && Cstr.style) {
1102
- let style;
1103
- if (typeof Cstr.style === "string") {
1104
- style = Cstr.style;
1105
- }
1106
- const scopeId2 = getScopeId(cmpMeta);
1107
- if (!styles.has(scopeId2)) {
1108
- const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$);
1109
- registerStyle(scopeId2, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1110
- endRegisterStyles();
1111
- }
1112
- }
1113
- }
1114
- const ancestorComponent = hostRef.$ancestorComponent$;
1115
- const schedule = () => scheduleUpdate(hostRef, true);
1116
- if (ancestorComponent && ancestorComponent["s-rc"]) {
1117
- ancestorComponent["s-rc"].push(schedule);
1118
- } else {
1119
- schedule();
1120
- }
1121
- };
1122
- var fireConnectedCallback = (instance, elm) => {
1123
- };
1124
-
1125
- // src/runtime/connected-callback.ts
1126
- var connectedCallback = (elm) => {
1127
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1128
- const hostRef = getHostRef(elm);
1129
- if (!hostRef) {
1130
- return;
1131
- }
1132
- const cmpMeta = hostRef.$cmpMeta$;
1133
- const endConnected = createTime("connectedCallback", cmpMeta.$tagName$);
1134
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1135
- hostRef.$flags$ |= 1 /* hasConnected */;
1136
- {
1137
- let ancestorComponent = elm;
1138
- while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
1139
- if (ancestorComponent["s-p"]) {
1140
- attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
1141
- break;
1142
- }
1143
- }
1144
- }
1145
- if (cmpMeta.$members$) {
1146
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1147
- if (memberFlags & 31 /* Prop */ && memberName in elm && elm[memberName] !== Object.prototype[memberName]) {
1148
- const value = elm[memberName];
1149
- delete elm[memberName];
1150
- elm[memberName] = value;
1151
- }
1152
- });
1153
- }
1154
- {
1155
- initializeComponent(elm, hostRef, cmpMeta);
1156
- }
1157
- } else {
1158
- if (hostRef == null ? void 0 : hostRef.$lazyInstance$) ; else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
1159
- hostRef.$onReadyPromise$.then(() => fireConnectedCallback());
1160
- }
1161
- }
1162
- endConnected();
1163
- }
1164
- };
1165
- var disconnectedCallback = async (elm) => {
1166
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1167
- getHostRef(elm);
1168
- }
1169
- if (rootAppliedStyles.has(elm)) {
1170
- rootAppliedStyles.delete(elm);
1171
- }
1172
- if (elm.shadowRoot && rootAppliedStyles.has(elm.shadowRoot)) {
1173
- rootAppliedStyles.delete(elm.shadowRoot);
1174
- }
1175
- };
1176
- var proxyCustomElement = (Cstr, compactMeta) => {
1177
- const cmpMeta = {
1178
- $flags$: compactMeta[0],
1179
- $tagName$: compactMeta[1]
1180
- };
1181
- {
1182
- cmpMeta.$members$ = compactMeta[2];
1183
- }
1184
- const originalConnectedCallback = Cstr.prototype.connectedCallback;
1185
- const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
1186
- Object.assign(Cstr.prototype, {
1187
- __hasHostListenerAttached: false,
1188
- __registerHost() {
1189
- registerHost(this, cmpMeta);
1190
- },
1191
- connectedCallback() {
1192
- if (!this.__hasHostListenerAttached) {
1193
- const hostRef = getHostRef(this);
1194
- if (!hostRef) {
1195
- return;
1196
- }
1197
- this.__hasHostListenerAttached = true;
1198
- }
1199
- connectedCallback(this);
1200
- if (originalConnectedCallback) {
1201
- originalConnectedCallback.call(this);
1202
- }
1203
- },
1204
- disconnectedCallback() {
1205
- disconnectedCallback(this);
1206
- if (originalDisconnectedCallback) {
1207
- originalDisconnectedCallback.call(this);
1208
- }
1209
- },
1210
- __attachShadow() {
1211
- {
1212
- if (!this.shadowRoot) {
1213
- createShadowRoot.call(this, cmpMeta);
1214
- } else {
1215
- if (this.shadowRoot.mode !== "open") {
1216
- throw new Error(
1217
- `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`
1218
- );
1219
- }
1220
- }
1221
- }
1222
- }
1223
- });
1224
- Cstr.is = cmpMeta.$tagName$;
1225
- return proxyComponent(Cstr, cmpMeta);
1226
- };
1227
8
 
1228
- // src/runtime/nonce.ts
1229
- var setNonce = (nonce) => plt.$nonce$ = nonce;
1230
-
1231
- // src/runtime/platform-options.ts
1232
- var setPlatformOptions = (opts) => Object.assign(plt, opts);
1233
-
1234
- // src/runtime/render.ts
1235
- function render(vnode, container) {
1236
- const ref = {
1237
- $hostElement$: container
1238
- };
1239
- renderVdom(ref, vnode);
1240
- }
1241
-
1242
- class LLMEvaluationEngine {
1243
- constructor() { }
1244
- async evaluateResponse(request, callback) {
1245
- try {
1246
- console.log('🔍 Starting evaluation for test case:', request.testCaseId);
1247
- const result = await this.performEvaluation(request);
1248
- console.log('Evaluation completed for test case:', request.testCaseId);
1249
- console.log('Result:', result);
1250
- callback(result);
1251
- }
1252
- catch (error) {
1253
- console.error('Evaluation failed:', error);
1254
- const errorResult = {
1255
- testCaseId: request.testCaseId,
1256
- passed: false,
1257
- keywordMatches: [],
1258
- sourceLinkMatches: [],
1259
- timestamp: new Date().toISOString()
1260
- };
1261
- callback(errorResult);
1262
- }
1263
- }
1264
- async performEvaluation(request) {
1265
- const { testCaseId, expectedKeywords, expectedSourceLinks, actualResponse } = request;
1266
- const keywordMatches = this.evaluateKeywords(expectedKeywords, actualResponse);
1267
- const sourceLinkMatches = this.evaluateSourceLinks(expectedSourceLinks, actualResponse);
1268
- // Test passes only if ALL expected keywords and source links are found
1269
- const totalItems = keywordMatches.length + sourceLinkMatches.length;
1270
- const foundItems = keywordMatches.filter(m => m.found).length + sourceLinkMatches.filter(m => m.found).length;
1271
- const passed = foundItems === totalItems;
1272
- return {
1273
- testCaseId,
1274
- passed,
1275
- keywordMatches,
1276
- sourceLinkMatches,
1277
- timestamp: new Date().toISOString()
1278
- };
1279
- }
1280
- evaluateKeywords(expectedKeywords, actualResponse) {
1281
- // Case-insensitive keyword matching
1282
- const response = actualResponse.toLowerCase();
1283
- return expectedKeywords.map(keyword => {
1284
- const keywordToMatch = keyword.toLowerCase();
1285
- const found = response.includes(keywordToMatch);
1286
- return {
1287
- keyword,
1288
- found
1289
- };
1290
- });
1291
- }
1292
- evaluateSourceLinks(expectedSourceLinks, actualResponse) {
1293
- return expectedSourceLinks.map(link => {
1294
- const found = actualResponse.includes(link);
1295
- return {
1296
- link,
1297
- found
1298
- };
1299
- });
1300
- }
1301
- }
1302
-
1303
- /**
1304
- * Convert array of 16 byte values to UUID string format of the form:
1305
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
1306
- */
1307
- var byteToHex = [];
1308
- for (var i = 0; i < 256; ++i) {
1309
- byteToHex.push((i + 0x100).toString(16).slice(1));
1310
- }
1311
- function unsafeStringify(arr, offset = 0) {
1312
- // Note: Be careful editing this code! It's been tuned for performance
1313
- // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
1314
- //
1315
- // Note to future-self: No, you can't remove the `toLowerCase()` call.
1316
- // REF: https://github.com/uuidjs/uuid/pull/677#issuecomment-1757351351
1317
- return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
1318
- }
1319
-
1320
- // Unique ID creation requires a high quality random # generator. In the browser we therefore
1321
- // require the crypto API and do not support built-in fallback to lower quality random number
1322
- // generators (like Math.random()).
1323
-
1324
- var getRandomValues;
1325
- var rnds8 = new Uint8Array(16);
1326
- function rng() {
1327
- // lazy load so that environments that need to polyfill have a chance to do so
1328
- if (!getRandomValues) {
1329
- // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
1330
- getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
1331
- if (!getRandomValues) {
1332
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
1333
- }
1334
- }
1335
- return getRandomValues(rnds8);
1336
- }
1337
-
1338
- var randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
1339
- var native = {
1340
- randomUUID
1341
- };
1342
-
1343
- function v4(options, buf, offset) {
1344
- if (native.randomUUID && true && !options) {
1345
- return native.randomUUID();
1346
- }
1347
- options = options || {};
1348
- var rnds = options.random || (options.rng || rng)();
1349
-
1350
- // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
1351
- rnds[6] = rnds[6] & 0x0f | 0x40;
1352
- rnds[8] = rnds[8] & 0x3f | 0x80;
1353
- return unsafeStringify(rnds);
1354
- }
1355
-
1356
- const ErrorMessage = ({ message, onClear }) => {
1357
- if (!message) {
1358
- return null;
1359
- }
1360
- return (h("div", { class: "error-message" }, h("span", null, message), onClear && (h("button", { class: "error-close", title: "Close", onClick: onClear }, "\u00D7"))));
1361
- };
1362
-
1363
- const llmTestRunnerCss = ":host {\n display: block;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;\n background-color: #f8fafc;\n min-height: 100vh;\n}\n\n.test-runner-container {\n padding: 20px;\n background: white;\n border-radius: 8px;\n box-shadow: 0 2px 4px rgba(0,0,0,0.1);\n margin: 20px 0;\n}\n\n.simple-test {\n margin: 20px 0;\n padding: 20px;\n border: 1px solid #ddd;\n border-radius: 4px;\n}\n\n.test-cases {\n margin: 20px 0;\n}\n\n.test-case {\n margin: 20px 0;\n padding: 20px;\n border: 1px solid #eee;\n border-radius: 4px;\n background: #f9f9f9;\n}\n\n.test-case h3 {\n margin-top: 0;\n color: #333;\n}\n\n.test-case textarea {\n width: 100%;\n padding: 10px;\n border: 1px solid #ddd;\n border-radius: 4px;\n font-family: inherit;\n margin: 10px 0;\n}\n\n.test-case button {\n background: #007bff;\n color: white;\n border: none;\n padding: 10px 20px;\n border-radius: 4px;\n cursor: pointer;\n margin: 10px 5px 10px 0;\n}\n\n.test-case button:disabled {\n background: #ccc;\n cursor: not-allowed;\n}\n\n.output, .error {\n margin: 10px 0;\n padding: 10px;\n border-radius: 4px;\n}\n\n.output {\n background: #d4edda;\n border: 1px solid #c3e6cb;\n color: #155724;\n}\n\n.error {\n background: #f8d7da;\n border: 1px solid #f5c6cb;\n color: #721c24;\n}\n\n.test-runner-container {\n max-width: 1400px;\n margin: 0 auto;\n background: white;\n box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);\n}\n\n/* Header Styles */\n.test-runner-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 20px 24px;\n background: /*linear-gradient(135deg, #667eea 0%, #764ba2 100%);*/ white;\n color: white;\n box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);\n}\n\n.header-left, .header-right {\n display: flex;\n gap: 12px;\n align-items: center;\n}\n\n.header-center {\n flex: 1;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.api-status {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n}\n\n.api-status-text {\n color: #28a745;\n font-weight: 500;\n font-size: 0.9rem;\n}\n\n/* Button Styles */\n.btn {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n padding: 10px 16px;\n border: none;\n border-radius: 8px;\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.2s ease;\n text-decoration: none;\n position: relative;\n}\n\n.btn:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n transform: none !important;\n}\n\n.btn-primary {\n color: black;\n box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);\n}\n\n.btn-primary:hover:not(:disabled) {\n transform: translateY(-1px);\n box-shadow: 0 4px 8px rgba(59, 130, 246, 0.4);\n}\n\n.btn-secondary {\n background: rgba(255, 255, 255, 0.2);\n color: blue;\n border: 1px solid rgba(255, 255, 255, 0.3);\n}\n\n.btn-secondary:hover:not(:disabled) {\n background: rgba(255, 255, 255, 0.3);\n transform: translateY(-1px);\n}\n\n.btn-outline {\n background: transparent;\n color: #6b7280;\n border: 2px solid #e5e7eb;\n}\n\n.btn-outline:hover {\n background: #f9fafb;\n border-color: #d1d5db;\n transform: translateY(-1px);\n}\n\n.btn-icon {\n padding: 8px;\n min-width: 40px;\n height: 40px;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 16px;\n}\n\n.btn-run {\n color: white;\n}\n\n.btn-run:hover:not(:disabled) {\n transform: translateY(-1px);\n}\n\n.btn-delete {\n color: white;\n}\n\n.btn-delete:hover:not(:disabled) {\n transform: translateY(-1px);\n}\n\n.icon {\n font-size: 16px;\n}\n\n/* Main Content */\n.test-runner-content {\n padding: 0;\n}\n\n/* Column Headers */\n.column-headers {\n display: grid;\n grid-template-columns: 1fr 1.5fr 0.5fr 120px;\n gap: 1px;\n background: #e5e7eb;\n border-bottom: 2px solid #d1d5db;\n}\n\n.column-header {\n background: #f8fafc;\n padding: 16px 20px;\n font-weight: 600;\n color: #374151;\n font-size: 14px;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n}\n\n/* Test Cases */\n.test-cases {\n background: white;\n}\n\n.test-case-row {\n display: grid;\n grid-template-columns: 1fr 1.5fr 0.5fr 120px;\n gap: 1px;\n border-bottom: 1px solid #e5e7eb;\n min-height: 200px;\n}\n\n.test-case-row:hover {\n background: #f9fafb;\n}\n\n/* Input Column */\n.input-column {\n padding: 20px;\n background: white;\n border-right: 1px solid #e5e7eb;\n}\n\n.input-group {\n margin-bottom: 16px;\n}\n\n.input-group label {\n display: block;\n margin-bottom: 8px;\n font-weight: 500;\n color: #374151;\n font-size: 14px;\n}\n\n.input-group textarea {\n width: 95%;\n padding: 12px;\n border: 2px solid #e5e7eb;\n border-radius: 8px;\n font-size: 14px;\n resize: vertical;\n outline: none;\n transition: border-color 0.2s ease;\n font-family: inherit;\n}\n\n.input-group textarea:focus {\n border-color: #3b82f6;\n box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);\n}\n\n/* Keywords and Links */\n.keywords-group, .links-group {\n margin-bottom: 16px;\n}\n\n.keywords-group label, .links-group label {\n display: block;\n margin-bottom: 8px;\n font-weight: 500;\n color: #374151;\n font-size: 14px;\n}\n\n.tags-container, .links-container {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n align-items: center;\n}\n\n.tag {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n background: #dbeafe;\n color: #1e40af;\n padding: 4px 8px;\n border-radius: 16px;\n font-size: 12px;\n font-weight: 500;\n}\n\n.tag-remove {\n background: none;\n border: none;\n color: #1e40af;\n cursor: pointer;\n font-size: 14px;\n padding: 0;\n width: 16px;\n height: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n}\n\n.tag-remove:hover {\n background: rgba(30, 64, 175, 0.1);\n}\n\n.link-item {\n display: flex;\n align-items: center;\n gap: 6px;\n background: #f0f9ff;\n padding: 4px 8px;\n border-radius: 6px;\n font-size: 12px;\n}\n\n.link-item a {\n color: #0369a1;\n text-decoration: none;\n max-width: 200px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.link-item a:hover {\n text-decoration: underline;\n}\n\n.link-remove {\n background: none;\n border: none;\n color: #0369a1;\n cursor: pointer;\n font-size: 12px;\n padding: 0;\n width: 16px;\n height: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n}\n\n.link-remove:hover {\n background: rgba(3, 105, 161, 0.1);\n}\n\n.tags-container input, .links-container input {\n border: 1px solid #d1d5db;\n border-radius: 6px;\n padding: 6px 8px;\n font-size: 12px;\n outline: none;\n min-width: 120px;\n}\n\n.tags-container input:focus, .links-container input:focus {\n border-color: #3b82f6;\n box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);\n}\n\n/* Output Column */\n.output-column {\n padding: 20px;\n background: white;\n border-right: 1px solid #e5e7eb;\n display: flex;\n flex-direction: column;\n}\n\n.output-content {\n background: #f8fafc;\n border: 1px solid #e5e7eb;\n border-radius: 8px;\n padding: 16px;\n font-size: 14px;\n line-height: 1.6;\n color: #374151;\n white-space: pre-wrap;\n word-wrap: break-word;\n flex: 1;\n overflow-y: auto;\n max-height: 250px;\n overflow-x: scroll;\n}\n\n.output-placeholder {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #9ca3af;\n font-style: italic;\n flex: 1;\n background: #f9fafb;\n border: 2px dashed #d1d5db;\n border-radius: 8px;\n}\n\n/* Evaluation Column */\n.evaluation-column {\n padding: 20px;\n background: white;\n border-right: 1px solid #e5e7eb;\n display: flex;\n flex-direction: column;\n}\n\n.evaluation-content {\n display: flex;\n flex-direction: column;\n gap: 12px;\n flex: 1;\n}\n\n.score-display {\n text-align: center;\n}\n\n.score-number {\n font-size: 24px;\n font-weight: 700;\n color: #111827;\n display: block;\n margin-bottom: 8px;\n}\n\n.score-bar {\n width: 100%;\n height: 8px;\n background: #e5e7eb;\n border-radius: 4px;\n overflow: hidden;\n}\n\n.score-fill {\n height: 100%;\n background: linear-gradient(90deg, #ef4444 0%, #f59e0b 50%, #10b981 100%);\n transition: width 0.3s ease;\n}\n\n.evaluation-details {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.detail-item {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: 14px;\n}\n\n.status {\n width: 20px;\n height: 20px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 12px;\n font-weight: bold;\n}\n\n.status.pass {\n background: #dcfce7;\n color: #166534;\n}\n\n.status.fail {\n background: #fef2f2;\n color: #dc2626;\n}\n\n.evaluation-text {\n font-size: 12px;\n color: #6b7280;\n line-height: 1.4;\n background: #f9fafb;\n padding: 8px;\n border-radius: 6px;\n border: 1px solid #e5e7eb;\n}\n\n.evaluation-placeholder {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #9ca3af;\n font-style: italic;\n flex: 1;\n background: #f9fafb;\n border: 2px dashed #d1d5db;\n border-radius: 8px;\n}\n\n/* New evaluation result styles */\n.evaluation-result {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.evaluation-status {\n font-weight: 600;\n font-size: 14px;\n padding: 8px 12px;\n border-radius: 4px;\n text-align: center;\n}\n\n.evaluation-status.passed {\n background: #d4edda;\n color: #155724;\n border: 1px solid #c3e6cb;\n}\n\n.evaluation-status.failed {\n background: #f8d7da;\n color: #721c24;\n border: 1px solid #f5c6cb;\n}\n\n.evaluation-score {\n font-size: 12px;\n color: #495057;\n text-align: center;\n font-weight: 500;\n}\n\n.evaluation-feedback {\n font-size: 12px;\n color: #6c757d;\n background: #f8f9fa;\n padding: 8px;\n border-radius: 4px;\n border: 1px solid #dee2e6;\n}\n\n/* Actions Column */\n.actions-column {\n padding: 20px;\n background: white;\n display: flex;\n flex-direction: column;\n gap: 12px;\n align-items: center;\n justify-content: flex-start;\n align-self: flex-start;\n}\n\n/* Add Test Case */\n.add-test-case {\n padding: 24px;\n text-align: center;\n background: #f9fafb;\n border-top: 1px solid #e5e7eb;\n}\n\n.hidden {\n display: none;\n}\n\n.error-message {\n background: #ffeaea;\n color: #b71c1c;\n border: 1px solid #f44336;\n padding: 0.75em 2.5em 0.75em 1em;\n border-radius: 4px;\n margin: 1em 0;\n position: relative;\n font-size: 1em;\n display: flex;\n align-items: center;\n gap: 1em;\n}\n\n.error-close {\n background: none;\n border: none;\n color: #b71c1c;\n font-size: 1.25em;\n font-weight: bold;\n cursor: pointer;\n position: absolute;\n right: 0.75em;\n top: 50%;\n transform: translateY(-50%);\n line-height: 1;\n padding: 0;\n}\n\n/* Responsive Design */\n@media (max-width: 1200px) {\n .test-case-row {\n grid-template-columns: 1fr;\n gap: 0;\n }\n \n .column-headers {\n display: none;\n }\n \n .input-column, .output-column, .evaluation-column, .actions-column {\n border-right: none;\n border-bottom: 1px solid #e5e7eb;\n }\n \n .actions-column {\n flex-direction: row;\n justify-content: center;\n }\n}\n\n@media (max-width: 768px) {\n .test-runner-header {\n flex-direction: column;\n gap: 16px;\n padding: 16px;\n }\n \n .header-left, .header-right {\n flex-wrap: wrap;\n justify-content: center;\n }\n \n .btn {\n font-size: 12px;\n padding: 8px 12px;\n }\n \n .input-column, .output-column, .evaluation-column, .actions-column {\n padding: 16px;\n }\n \n .test-case-row {\n min-height: auto;\n }\n}";
1364
-
1365
- const LLMTestRunner = /*@__PURE__*/ proxyCustomElement(class LLMTestRunner extends H {
1366
- constructor(registerHost) {
1367
- super();
1368
- if (registerHost !== false) {
1369
- this.__registerHost();
1370
- }
1371
- this.__attachShadow();
1372
- }
1373
- apiKey;
1374
- testCases = [
1375
- {
1376
- id: '1',
1377
- question: '',
1378
- expectedKeywords: [],
1379
- expectedSourceLinks: [],
1380
- isRunning: false
1381
- }
1382
- ];
1383
- isRunningAll = false;
1384
- error = '';
1385
- fileInput;
1386
- isExportingTestSuite = false;
1387
- evaluationEngine;
1388
- apiUrl = 'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent';
1389
- async componentWillLoad() {
1390
- this.evaluationEngine = new LLMEvaluationEngine();
1391
- console.log('🔍 componentWillLoad - apiKey:', this.apiKey ? 'SET' : 'NOT SET');
1392
- console.log('🔍 componentWillLoad - apiKey value:', this.apiKey);
1393
- if (!this.apiKey) {
1394
- throw new Error('API key is required. Please provide the apiKey prop: <llm-test-runner apiKey="your-api-key" />');
1395
- }
1396
- }
1397
- componentDidLoad() {
1398
- }
1399
- disconnectedCallback() {
1400
- }
1401
- addNewTestCase() {
1402
- const newTestCase = {
1403
- id: this.generateId(),
1404
- question: '',
1405
- expectedKeywords: [],
1406
- expectedSourceLinks: [],
1407
- isRunning: false
1408
- };
1409
- this.testCases = [...this.testCases, newTestCase];
1410
- }
1411
- updateTestCase(id, updates) {
1412
- this.testCases = this.testCases.map(tc => tc.id === id ? { ...tc, ...updates } : tc);
1413
- }
1414
- async runSingleTest(testCase) {
1415
- console.log('🚀 Starting test for question:', testCase.question);
1416
- this.updateTestCase(testCase.id, { isRunning: true });
1417
- try {
1418
- const aiResponse = await this.callGeminiAPI(testCase.question);
1419
- console.log('✅ AI call completed for test case:', testCase.id);
1420
- this.updateTestCase(testCase.id, {
1421
- isRunning: false,
1422
- output: aiResponse,
1423
- error: null
1424
- });
1425
- await this.evaluateResponse({
1426
- ...testCase,
1427
- output: aiResponse
1428
- });
1429
- }
1430
- catch (error) {
1431
- console.error('❌ Error in runSingleTest:', error);
1432
- this.updateTestCase(testCase.id, {
1433
- isRunning: false,
1434
- output: null,
1435
- error: error instanceof Error ? error.message : 'Unknown error'
1436
- });
1437
- }
1438
- }
1439
- deleteTestCase(id) {
1440
- this.testCases = this.testCases.filter(tc => tc.id !== id);
1441
- }
1442
- addKeyword(testCaseId, keyword) {
1443
- if (keyword.trim()) {
1444
- const testCase = this.testCases.find(tc => tc.id === testCaseId);
1445
- if (testCase) {
1446
- this.updateTestCase(testCaseId, {
1447
- expectedKeywords: [...testCase.expectedKeywords, keyword.trim()]
1448
- });
1449
- }
1450
- }
1451
- }
1452
- removeKeyword(testCaseId, index) {
1453
- const testCase = this.testCases.find(tc => tc.id === testCaseId);
1454
- if (testCase) {
1455
- const newKeywords = testCase.expectedKeywords.filter((_, i) => i !== index);
1456
- this.updateTestCase(testCaseId, { expectedKeywords: newKeywords });
1457
- }
1458
- }
1459
- addSourceLink(testCaseId, link) {
1460
- if (link.trim()) {
1461
- const testCase = this.testCases.find(tc => tc.id === testCaseId);
1462
- if (testCase) {
1463
- this.updateTestCase(testCaseId, {
1464
- expectedSourceLinks: [...testCase.expectedSourceLinks, link.trim()]
1465
- });
1466
- }
1467
- }
1468
- }
1469
- removeSourceLink(testCaseId, index) {
1470
- const testCase = this.testCases.find(tc => tc.id === testCaseId);
1471
- if (testCase) {
1472
- const newLinks = testCase.expectedSourceLinks.filter((_, i) => i !== index);
1473
- this.updateTestCase(testCaseId, { expectedSourceLinks: newLinks });
1474
- }
1475
- }
1476
- async callGeminiAPI(prompt) {
1477
- console.log('🔍 callGeminiAPI - apiKey:', this.apiKey ? 'SET' : 'NOT SET');
1478
- console.log('🔍 callGeminiAPI - apiKey value:', this.apiKey ? `${this.apiKey.substring(0, 10)}...` : 'undefined');
1479
- if (!this.apiKey) {
1480
- throw new Error('API key is required. Please provide the apiKey prop.');
1481
- }
1482
- const requestBody = {
1483
- contents: [{
1484
- parts: [{
1485
- text: prompt
1486
- }]
1487
- }]
1488
- };
1489
- const response = await fetch(`${this.apiUrl}?key=${this.apiKey}`, {
1490
- method: 'POST',
1491
- headers: {
1492
- 'Content-Type': 'application/json',
1493
- },
1494
- body: JSON.stringify(requestBody)
1495
- });
1496
- if (!response.ok) {
1497
- const errorData = await response.json().catch(() => ({}));
1498
- throw new Error(errorData.error?.message || `HTTP error! status: ${response.status}`);
1499
- }
1500
- const data = await response.json();
1501
- if (data.candidates && data.candidates[0] && data.candidates[0].content) {
1502
- return data.candidates[0].content.parts[0].text;
1503
- }
1504
- else {
1505
- throw new Error('Unexpected response format from Gemini API');
1506
- }
1507
- }
1508
- async evaluateResponse(testCase) {
1509
- if (!testCase.output) {
1510
- console.warn('⚠️ No output to evaluate for test case:', testCase.id);
1511
- return;
1512
- }
1513
- const evaluationRequest = {
1514
- testCaseId: testCase.id,
1515
- question: testCase.question,
1516
- expectedKeywords: testCase.expectedKeywords,
1517
- expectedSourceLinks: testCase.expectedSourceLinks,
1518
- actualResponse: testCase.output
1519
- };
1520
- await this.evaluationEngine.evaluateResponse(evaluationRequest, (result) => {
1521
- console.log('📊 Evaluation result received:', result);
1522
- this.updateTestCase(testCase.id, {
1523
- evaluationResult: result
1524
- });
1525
- });
1526
- }
1527
- async runAllTests() {
1528
- this.isRunningAll = true;
1529
- for (const testCase of this.testCases) {
1530
- if (!testCase.isRunning && testCase.question.trim()) {
1531
- await this.runSingleTest(testCase);
1532
- // Delay between tests to avoid rate limiting
1533
- await new Promise(resolve => setTimeout(resolve, 1000));
1534
- }
1535
- }
1536
- this.isRunningAll = false;
1537
- }
1538
- generateId() {
1539
- return v4();
1540
- }
1541
- handleFileSelect() {
1542
- this.fileInput.click();
1543
- }
1544
- async handleFileChange(event) {
1545
- const target = event.target;
1546
- const file = target.files?.[0];
1547
- // Immediately clear the input value to allow for a new upload.
1548
- target.value = '';
1549
- if (!file) {
1550
- this.error = 'No file selected.';
1551
- return;
1552
- }
1553
- const isJsonType = file.type === 'application/json';
1554
- const isJsonExtension = file.name.toLowerCase().endsWith('.json');
1555
- if (!isJsonType && !isJsonExtension) {
1556
- this.error = 'Invalid file type. Please select a JSON file.';
1557
- return;
1558
- }
1559
- this.error = '';
1560
- try {
1561
- const content = await this.readFileAsync(file);
1562
- const fileContent = JSON.parse(content);
1563
- if (!Array.isArray(fileContent)) {
1564
- throw new Error("Invalid JSON structure. Expected a JSON array.");
1565
- }
1566
- const importedTestCases = fileContent.map((item) => ({
1567
- id: this.generateId(),
1568
- question: item.question || '',
1569
- expectedKeywords: Array.isArray(item.expectedKeywords) ? item.expectedKeywords : [],
1570
- expectedSourceLinks: Array.isArray(item.expectedSourceLinks) ? item.expectedSourceLinks : [],
1571
- isRunning: false
1572
- }));
1573
- this.testCases = importedTestCases;
1574
- }
1575
- catch (err) {
1576
- this.error = err?.message || 'Error processing file. Please ensure it is a valid JSON array.';
1577
- console.error('File Processing Error:', err);
1578
- }
1579
- }
1580
- readFileAsync(file) {
1581
- return new Promise((resolve, reject) => {
1582
- const reader = new FileReader();
1583
- reader.onload = () => resolve(reader.result);
1584
- reader.onerror = () => reject(reader.error);
1585
- reader.readAsText(file);
1586
- });
1587
- }
1588
- downloadFile(content, filename, mimeType) {
1589
- const blob = new Blob([content], { type: mimeType });
1590
- const url = URL.createObjectURL(blob);
1591
- const link = document.createElement('a');
1592
- link.href = url;
1593
- link.download = filename;
1594
- document.body.appendChild(link);
1595
- link.click();
1596
- document.body.removeChild(link);
1597
- URL.revokeObjectURL(url);
1598
- }
1599
- async handleExportTestSuite() {
1600
- this.isExportingTestSuite = true;
1601
- try {
1602
- // Exporting only input data (question, expected keywords, expected source links)
1603
- const exportData = this.testCases.map(testCase => ({
1604
- id: testCase.id,
1605
- question: testCase.question,
1606
- expectedKeywords: testCase.expectedKeywords,
1607
- expectedSourceLinks: testCase.expectedSourceLinks
1608
- }));
1609
- const jsonContent = JSON.stringify(exportData, null, 2);
1610
- // Added a small delay to show the loading state
1611
- await new Promise(resolve => setTimeout(resolve, 500));
1612
- this.downloadFile(jsonContent, 'test-suite.json', 'application/json');
1613
- }
1614
- finally {
1615
- this.isExportingTestSuite = false;
1616
- }
1617
- }
1618
- render() {
1619
- return (h("div", { key: 'dc5b661334cb4d4bb9bf51fb25363fe08ad938e3', class: "test-runner-container" }, h("header", { key: 'eede0d7f00c0bf5ff794fe2e53bad7a239f2d4d4', class: "test-runner-header" }, h("div", { key: '19327ae6f7408843110a10f791e00ffdf3da6d64', class: "header-left" }, h("input", { key: 'b24227b27dc0f562318a67ca9c38b8793b55c644', class: "hidden", type: "file", ref: (el) => (this.fileInput = el), onChange: (e) => this.handleFileChange(e), accept: ".json,application/json" }), h("button", { key: '65adec40d3787115546c9b59e8691bc89c55c688', class: "btn btn-secondary", onClick: () => this.handleFileSelect() }, h("span", { key: '6fd40e85b4c99232330242b41199df1c4f947351', class: "icon" }, "\u2191"), "Import Test Suite"), h("button", { key: 'd7c4d6b7e3e9bb6951395a3c2c10b964ef2d2fca', class: "btn btn-secondary", onClick: () => this.handleExportTestSuite(), disabled: this.isExportingTestSuite }, h("span", { key: 'bab67984c37b2744f35b4b2c34bfa3a500d196fb', class: "icon" }, this.isExportingTestSuite ? '⏳' : '↓'), this.isExportingTestSuite ? 'Exporting...' : 'Export Test Suite')), h("div", { key: '74a7d6e148311151de86a66d7b146bd0d01c215c', class: "header-right" }, h("button", { key: '3e9c33ef795755ebdf11fafa68801294b61a03d1', class: "btn btn-secondary" }, h("span", { key: '89b3582178782392cbea1309ba32b5edc57f9392', class: "icon" }, "\u2699\uFE0F"), "Prompt Editor"), h("button", { key: 'e68e8edd5f532c7a8ec87746fa6d393c4297bc36', class: "btn btn-secondary" }, h("span", { key: '7298d968bbc108cf060a0c309c9a8b2bce88aa90', class: "icon" }, "\u2193"), "Export Test Results"), h("button", { key: 'fb7d10cf9abda9968a2502bd8b4bf8e4cade11e8', class: "btn btn-primary", onClick: () => this.runAllTests(), disabled: this.isRunningAll }, this.isRunningAll ? 'Running...' : 'Run All'))), h(ErrorMessage, { key: '71eb4e561018a176a8c944107d734c32cd74334b', message: this.error, onClear: () => (this.error = '') }), h("div", { key: 'c120a8e40c6c6721dacd400266d4cd6270057c66', class: "test-runner-content" }, h("div", { key: '7b864c6e0671d8be117b001fd87047fabdc851c0', class: "column-headers" }, h("div", { key: 'fcd6ae26d7b98422d800c4e3a4bcec587187be2b', class: "column-header" }, "Input"), h("div", { key: '2855a067b11f8f9ddaf489daffb8a9fd2a317a44', class: "column-header" }, "Output"), h("div", { key: '8b6d75b16005d19bacd8fa6d2008fa64c268e1ef', class: "column-header" }, "Evaluation"), h("div", { key: 'd14ea8cecb426c9692b16044124f3d23ddae671d', class: "column-header" }, "Actions")), h("div", { key: '958aaba85391f7aadabd86c0395d0fe18b942ed4', class: "test-cases" }, this.testCases.map((testCase) => (h("div", { class: "test-case-row", key: testCase.id }, h("div", { class: "input-column" }, h("div", { class: "input-group" }, h("label", null, "Question"), h("textarea", { value: testCase.question, onInput: (e) => this.updateTestCase(testCase.id, {
1620
- question: e.target.value
1621
- }), placeholder: "Enter your question here...", rows: 3 })), h("div", { class: "keywords-group" }, h("label", null, "Expected keywords"), h("div", { class: "tags-container" }, testCase.expectedKeywords.map((keyword, index) => (h("span", { class: "tag", key: index }, keyword, h("button", { class: "tag-remove", onClick: () => this.removeKeyword(testCase.id, index) }, "\u00D7")))), h("input", { type: "text", placeholder: "New item...", onKeyDown: (e) => {
1622
- if (e.key === 'Enter') {
1623
- this.addKeyword(testCase.id, e.target.value);
1624
- e.target.value = '';
1625
- }
1626
- } }))), h("div", { class: "links-group" }, h("label", null, "Expected source links"), h("div", { class: "links-container" }, testCase.expectedSourceLinks.map((link, index) => (h("div", { class: "link-item", key: index }, h("a", { href: link, target: "_blank", rel: "noopener noreferrer" }, link), h("button", { class: "link-remove", onClick: () => this.removeSourceLink(testCase.id, index) }, "\u00D7")))), h("input", { type: "url", placeholder: "New item...", onKeyDown: (e) => {
1627
- if (e.key === 'Enter') {
1628
- this.addSourceLink(testCase.id, e.target.value);
1629
- e.target.value = '';
1630
- }
1631
- } })))), h("div", { class: "output-column" }, testCase.output ? (h("div", { class: "output-content" }, testCase.output)) : (h("div", { class: "output-placeholder" }, testCase.isRunning ? 'Running...' : ''))), h("div", { class: "evaluation-column" }, testCase.evaluationResult ? (h("div", { class: "evaluation-result" }, h("div", { class: `evaluation-status ${testCase.evaluationResult.passed ? 'passed' : 'failed'}` }, testCase.evaluationResult.passed ? '✅ PASSED' : '❌ FAILED'), h("div", { class: "evaluation-details" }, "Keywords: ", testCase.evaluationResult.keywordMatches.filter(m => m.found).length, "/", testCase.evaluationResult.keywordMatches.length, " found"))) : (h("div", { class: "evaluation-placeholder" }, testCase.isRunning ? 'Evaluating...' : ''))), h("div", { class: "actions-column" }, h("button", { class: "btn btn-icon btn-run", onClick: () => this.runSingleTest(testCase), disabled: testCase.isRunning || !testCase.question.trim(), title: !testCase.question.trim() ? "Enter a question first" : "Run this test" }, testCase.isRunning ? '⏳' : '▶️'), h("button", { class: "btn btn-icon btn-delete", onClick: () => this.deleteTestCase(testCase.id), title: "Delete this test" }, "\uD83D\uDDD1\uFE0F")))))), h("div", { key: '678932d3554c7ef2c86373bc4c972eb0f9894916', class: "add-test-case" }, h("button", { key: '7f8447a4681214320647c55e06d1cfc0fc87b3fb', class: "btn btn-outline", onClick: () => this.addNewTestCase() }, "+ Add Question")))));
1632
- }
1633
- static get style() { return llmTestRunnerCss; }
1634
- }, [257, "llm-test-runner", {
1635
- "apiKey": [1, "api-key"],
1636
- "testCases": [32],
1637
- "isRunningAll": [32],
1638
- "error": [32],
1639
- "isExportingTestSuite": [32]
1640
- }]);
1641
- function defineCustomElement() {
1642
- if (typeof customElements === "undefined") {
1643
- return;
1644
- }
1645
- const components = ["llm-test-runner"];
1646
- components.forEach(tagName => { switch (tagName) {
1647
- case "llm-test-runner":
1648
- if (!customElements.get(tagName)) {
1649
- customElements.define(tagName, LLMTestRunner);
1650
- }
1651
- break;
1652
- } });
1653
- }
9
+ const globalScripts = appGlobalScript;
1654
10
 
1655
- export { LLMTestRunner, defineCustomElement as d, getAssetPath, render, setAssetPath, setNonce, setPlatformOptions };
11
+ globalScripts();
1656
12
  //# sourceMappingURL=index.js.map
1657
13
 
1658
14
  //# sourceMappingURL=index.js.map