@kelet-ai/feedback-ui 1.1.1 → 1.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.
@@ -1,4 +1,4 @@
1
- import Ne, { createContext as xe, useEffect as ce, useContext as le, useCallback as q, isValidElement as Q, cloneElement as ee, useState as G, useRef as Y, useId as de } from "react";
1
+ import Ne, { createContext as Pe, useEffect as ce, useContext as le, useCallback as q, isValidElement as Q, cloneElement as ee, useState as X, useRef as Y, useId as de } from "react";
2
2
  function je(t) {
3
3
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
4
4
  }
@@ -41,24 +41,24 @@ function Ie() {
41
41
  if (pe) return V;
42
42
  pe = 1;
43
43
  var t = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
44
- function n(r, o, u) {
45
- var p = null;
46
- if (u !== void 0 && (p = "" + u), o.key !== void 0 && (p = "" + o.key), "key" in o) {
47
- u = {};
48
- for (var c in o)
49
- c !== "key" && (u[c] = o[c]);
50
- } else u = o;
51
- return o = u.ref, {
44
+ function n(r, o, d) {
45
+ var f = null;
46
+ if (d !== void 0 && (f = "" + d), o.key !== void 0 && (f = "" + o.key), "key" in o) {
47
+ d = {};
48
+ for (var l in o)
49
+ l !== "key" && (d[l] = o[l]);
50
+ } else d = o;
51
+ return o = d.ref, {
52
52
  $$typeof: t,
53
53
  type: r,
54
- key: p,
54
+ key: f,
55
55
  ref: o !== void 0 ? o : null,
56
- props: u
56
+ props: d
57
57
  };
58
58
  }
59
59
  return V.Fragment = e, V.jsx = n, V.jsxs = n, V;
60
60
  }
61
- var X = {};
61
+ var G = {};
62
62
  /**
63
63
  * @license React
64
64
  * react-jsx-runtime.development.js
@@ -77,38 +77,38 @@ function Le() {
77
77
  return a.$$typeof === s ? null : a.displayName || a.name || null;
78
78
  if (typeof a == "string") return a;
79
79
  switch (a) {
80
- case g:
80
+ case k:
81
81
  return "Fragment";
82
82
  case A:
83
83
  return "Profiler";
84
- case C:
84
+ case O:
85
85
  return "StrictMode";
86
- case P:
86
+ case _:
87
87
  return "Suspense";
88
- case j:
88
+ case N:
89
89
  return "SuspenseList";
90
- case l:
90
+ case u:
91
91
  return "Activity";
92
92
  }
93
93
  if (typeof a == "object")
94
94
  switch (typeof a.tag == "number" && console.error(
95
95
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
96
96
  ), a.$$typeof) {
97
- case h:
97
+ case p:
98
98
  return "Portal";
99
- case R:
99
+ case T:
100
100
  return (a.displayName || "Context") + ".Provider";
101
- case b:
101
+ case m:
102
102
  return (a._context.displayName || "Context") + ".Consumer";
103
- case E:
104
- var T = a.render;
105
- return a = a.displayName, a || (a = T.displayName || T.name || "", a = a !== "" ? "ForwardRef(" + a + ")" : "ForwardRef"), a;
106
- case S:
107
- return T = a.displayName || null, T !== null ? T : t(a.type) || "Memo";
103
+ case R:
104
+ var C = a.render;
105
+ return a = a.displayName, a || (a = C.displayName || C.name || "", a = a !== "" ? "ForwardRef(" + a + ")" : "ForwardRef"), a;
106
+ case I:
107
+ return C = a.displayName || null, C !== null ? C : t(a.type) || "Memo";
108
108
  case i:
109
- T = a._payload, a = a._init;
109
+ C = a._payload, a = a._init;
110
110
  try {
111
- return t(a(T));
111
+ return t(a(C));
112
112
  } catch {
113
113
  }
114
114
  }
@@ -120,73 +120,73 @@ function Le() {
120
120
  function n(a) {
121
121
  try {
122
122
  e(a);
123
- var T = !1;
123
+ var C = !1;
124
124
  } catch {
125
- T = !0;
125
+ C = !0;
126
126
  }
127
- if (T) {
128
- T = console;
129
- var _ = T.error, N = typeof Symbol == "function" && Symbol.toStringTag && a[Symbol.toStringTag] || a.constructor.name || "Object";
130
- return _.call(
131
- T,
127
+ if (C) {
128
+ C = console;
129
+ var D = C.error, S = typeof Symbol == "function" && Symbol.toStringTag && a[Symbol.toStringTag] || a.constructor.name || "Object";
130
+ return D.call(
131
+ C,
132
132
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
133
- N
133
+ S
134
134
  ), e(a);
135
135
  }
136
136
  }
137
137
  function r(a) {
138
- if (a === g) return "<>";
138
+ if (a === k) return "<>";
139
139
  if (typeof a == "object" && a !== null && a.$$typeof === i)
140
140
  return "<...>";
141
141
  try {
142
- var T = t(a);
143
- return T ? "<" + T + ">" : "<...>";
142
+ var C = t(a);
143
+ return C ? "<" + C + ">" : "<...>";
144
144
  } catch {
145
145
  return "<...>";
146
146
  }
147
147
  }
148
148
  function o() {
149
- var a = d.A;
149
+ var a = v.A;
150
150
  return a === null ? null : a.getOwner();
151
151
  }
152
- function u() {
152
+ function d() {
153
153
  return Error("react-stack-top-frame");
154
154
  }
155
- function p(a) {
156
- if (v.call(a, "key")) {
157
- var T = Object.getOwnPropertyDescriptor(a, "key").get;
158
- if (T && T.isReactWarning) return !1;
155
+ function f(a) {
156
+ if (y.call(a, "key")) {
157
+ var C = Object.getOwnPropertyDescriptor(a, "key").get;
158
+ if (C && C.isReactWarning) return !1;
159
159
  }
160
160
  return a.key !== void 0;
161
161
  }
162
- function c(a, T) {
163
- function _() {
162
+ function l(a, C) {
163
+ function D() {
164
164
  M || (M = !0, console.error(
165
165
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
166
- T
166
+ C
167
167
  ));
168
168
  }
169
- _.isReactWarning = !0, Object.defineProperty(a, "key", {
170
- get: _,
169
+ D.isReactWarning = !0, Object.defineProperty(a, "key", {
170
+ get: D,
171
171
  configurable: !0
172
172
  });
173
173
  }
174
- function f() {
174
+ function c() {
175
175
  var a = t(this.type);
176
- return L[a] || (L[a] = !0, console.error(
176
+ return j[a] || (j[a] = !0, console.error(
177
177
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
178
178
  )), a = this.props.ref, a !== void 0 ? a : null;
179
179
  }
180
- function y(a, T, _, N, W, $, B, K) {
181
- return _ = $.ref, a = {
182
- $$typeof: k,
180
+ function h(a, C, D, S, W, $, B, U) {
181
+ return D = $.ref, a = {
182
+ $$typeof: x,
183
183
  type: a,
184
- key: T,
184
+ key: C,
185
185
  props: $,
186
186
  _owner: W
187
- }, (_ !== void 0 ? _ : null) !== null ? Object.defineProperty(a, "ref", {
187
+ }, (D !== void 0 ? D : null) !== null ? Object.defineProperty(a, "ref", {
188
188
  enumerable: !1,
189
- get: f
189
+ get: c
190
190
  }) : Object.defineProperty(a, "ref", { enumerable: !1, value: null }), a._store = {}, Object.defineProperty(a._store, "validated", {
191
191
  configurable: !1,
192
192
  enumerable: !1,
@@ -206,100 +206,100 @@ function Le() {
206
206
  configurable: !1,
207
207
  enumerable: !1,
208
208
  writable: !0,
209
- value: K
209
+ value: U
210
210
  }), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
211
211
  }
212
- function m(a, T, _, N, W, $, B, K) {
213
- var I = T.children;
214
- if (I !== void 0)
215
- if (N)
216
- if (D(I)) {
217
- for (N = 0; N < I.length; N++)
218
- O(I[N]);
219
- Object.freeze && Object.freeze(I);
212
+ function b(a, C, D, S, W, $, B, U) {
213
+ var L = C.children;
214
+ if (L !== void 0)
215
+ if (S)
216
+ if (g(L)) {
217
+ for (S = 0; S < L.length; S++)
218
+ P(L[S]);
219
+ Object.freeze && Object.freeze(L);
220
220
  } else
221
221
  console.error(
222
222
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
223
223
  );
224
- else O(I);
225
- if (v.call(T, "key")) {
226
- I = t(a);
227
- var z = Object.keys(T).filter(function(_e) {
228
- return _e !== "key";
224
+ else P(L);
225
+ if (y.call(C, "key")) {
226
+ L = t(a);
227
+ var z = Object.keys(C).filter(function(De) {
228
+ return De !== "key";
229
229
  });
230
- N = 0 < z.length ? "{key: someKey, " + z.join(": ..., ") + ": ...}" : "{key: someKey}", re[I + N] || (z = 0 < z.length ? "{" + z.join(": ..., ") + ": ...}" : "{}", console.error(
230
+ S = 0 < z.length ? "{key: someKey, " + z.join(": ..., ") + ": ...}" : "{key: someKey}", re[L + S] || (z = 0 < z.length ? "{" + z.join(": ..., ") + ": ...}" : "{}", console.error(
231
231
  `A props object containing a "key" prop is being spread into JSX:
232
232
  let props = %s;
233
233
  <%s {...props} />
234
234
  React keys must be passed directly to JSX without using spread:
235
235
  let props = %s;
236
236
  <%s key={someKey} {...props} />`,
237
- N,
238
- I,
237
+ S,
238
+ L,
239
239
  z,
240
- I
241
- ), re[I + N] = !0);
240
+ L
241
+ ), re[L + S] = !0);
242
242
  }
243
- if (I = null, _ !== void 0 && (n(_), I = "" + _), p(T) && (n(T.key), I = "" + T.key), "key" in T) {
244
- _ = {};
245
- for (var ue in T)
246
- ue !== "key" && (_[ue] = T[ue]);
247
- } else _ = T;
248
- return I && c(
249
- _,
243
+ if (L = null, D !== void 0 && (n(D), L = "" + D), f(C) && (n(C.key), L = "" + C.key), "key" in C) {
244
+ D = {};
245
+ for (var ue in C)
246
+ ue !== "key" && (D[ue] = C[ue]);
247
+ } else D = C;
248
+ return L && l(
249
+ D,
250
250
  typeof a == "function" ? a.displayName || a.name || "Unknown" : a
251
- ), y(
251
+ ), h(
252
252
  a,
253
- I,
253
+ L,
254
254
  $,
255
255
  W,
256
256
  o(),
257
- _,
257
+ D,
258
258
  B,
259
- K
259
+ U
260
260
  );
261
261
  }
262
- function O(a) {
263
- typeof a == "object" && a !== null && a.$$typeof === k && a._store && (a._store.validated = 1);
262
+ function P(a) {
263
+ typeof a == "object" && a !== null && a.$$typeof === x && a._store && (a._store.validated = 1);
264
264
  }
265
- var w = Ne, k = Symbol.for("react.transitional.element"), h = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), C = Symbol.for("react.strict_mode"), A = Symbol.for("react.profiler"), b = Symbol.for("react.consumer"), R = Symbol.for("react.context"), E = Symbol.for("react.forward_ref"), P = Symbol.for("react.suspense"), j = Symbol.for("react.suspense_list"), S = Symbol.for("react.memo"), i = Symbol.for("react.lazy"), l = Symbol.for("react.activity"), s = Symbol.for("react.client.reference"), d = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, v = Object.prototype.hasOwnProperty, D = Array.isArray, x = console.createTask ? console.createTask : function() {
265
+ var E = Ne, x = Symbol.for("react.transitional.element"), p = Symbol.for("react.portal"), k = Symbol.for("react.fragment"), O = Symbol.for("react.strict_mode"), A = Symbol.for("react.profiler"), m = Symbol.for("react.consumer"), T = Symbol.for("react.context"), R = Symbol.for("react.forward_ref"), _ = Symbol.for("react.suspense"), N = Symbol.for("react.suspense_list"), I = Symbol.for("react.memo"), i = Symbol.for("react.lazy"), u = Symbol.for("react.activity"), s = Symbol.for("react.client.reference"), v = E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, y = Object.prototype.hasOwnProperty, g = Array.isArray, w = console.createTask ? console.createTask : function() {
266
266
  return null;
267
267
  };
268
- w = {
268
+ E = {
269
269
  react_stack_bottom_frame: function(a) {
270
270
  return a();
271
271
  }
272
272
  };
273
- var M, L = {}, U = w.react_stack_bottom_frame.bind(
274
- w,
275
- u
276
- )(), J = x(r(u)), re = {};
277
- X.Fragment = g, X.jsx = function(a, T, _, N, W) {
278
- var $ = 1e4 > d.recentlyCreatedOwnerStacks++;
279
- return m(
273
+ var M, j = {}, H = E.react_stack_bottom_frame.bind(
274
+ E,
275
+ d
276
+ )(), J = w(r(d)), re = {};
277
+ G.Fragment = k, G.jsx = function(a, C, D, S, W) {
278
+ var $ = 1e4 > v.recentlyCreatedOwnerStacks++;
279
+ return b(
280
280
  a,
281
- T,
282
- _,
281
+ C,
282
+ D,
283
283
  !1,
284
- N,
284
+ S,
285
285
  W,
286
- $ ? Error("react-stack-top-frame") : U,
287
- $ ? x(r(a)) : J
286
+ $ ? Error("react-stack-top-frame") : H,
287
+ $ ? w(r(a)) : J
288
288
  );
289
- }, X.jsxs = function(a, T, _, N, W) {
290
- var $ = 1e4 > d.recentlyCreatedOwnerStacks++;
291
- return m(
289
+ }, G.jsxs = function(a, C, D, S, W) {
290
+ var $ = 1e4 > v.recentlyCreatedOwnerStacks++;
291
+ return b(
292
292
  a,
293
- T,
294
- _,
293
+ C,
294
+ D,
295
295
  !0,
296
- N,
296
+ S,
297
297
  W,
298
- $ ? Error("react-stack-top-frame") : U,
299
- $ ? x(r(a)) : J
298
+ $ ? Error("react-stack-top-frame") : H,
299
+ $ ? w(r(a)) : J
300
300
  );
301
301
  };
302
- }()), X;
302
+ }()), G;
303
303
  }
304
304
  var me;
305
305
  function Fe() {
@@ -314,20 +314,20 @@ function Me(t) {
314
314
  const n = e.getAttribute("data-feedback-id");
315
315
  if (n) return `[data-feedback-id="${n}"]`;
316
316
  const r = [];
317
- let o = e, u = 0;
318
- const p = 5;
319
- for (; o && o !== document.body && u < p; ) {
320
- let c = o.tagName.toLowerCase();
317
+ let o = e, d = 0;
318
+ const f = 5;
319
+ for (; o && o !== document.body && d < f; ) {
320
+ let l = o.tagName.toLowerCase();
321
321
  if (o.classList.length > 0) {
322
- const y = Array.from(o.classList)[0];
323
- c += `.${y}`;
322
+ const h = Array.from(o.classList)[0];
323
+ l += `.${h}`;
324
324
  }
325
- const f = o.parentElement;
326
- if (f) {
327
- const y = Array.from(f.children), m = y.indexOf(o) + 1;
328
- y.length > 1 && (c += `:nth-child(${m})`);
325
+ const c = o.parentElement;
326
+ if (c) {
327
+ const h = Array.from(c.children), b = h.indexOf(o) + 1;
328
+ h.length > 1 && (l += `:nth-child(${b})`);
329
329
  }
330
- r.unshift(c), o = f, u++;
330
+ r.unshift(l), o = c, d++;
331
331
  }
332
332
  return r.join(" > ");
333
333
  }
@@ -365,7 +365,7 @@ function qe() {
365
365
  function ze() {
366
366
  return Z ? Date.now() - Z.timestamp > 1e4 ? (Z = null, null) : { ...Z } : null;
367
367
  }
368
- const ae = xe(null), Ye = "https://api.kelet.ai/api", gt = () => {
368
+ const ae = Pe(null), Ye = "https://api.kelet.ai", gt = () => {
369
369
  const t = le(ae);
370
370
  if (!t)
371
371
  throw new Error("useKelet must be used within a KeletProvider");
@@ -380,53 +380,55 @@ const ae = xe(null), Ye = "https://api.kelet.ai/api", gt = () => {
380
380
  ce(() => {
381
381
  qe();
382
382
  }, []);
383
- const o = le(ae), u = t || o?.api_key;
384
- if (!u)
383
+ const o = le(ae), d = t || o?.api_key;
384
+ if (!d)
385
385
  throw new Error(
386
386
  "apiKey is required either directly or from a parent KeletProvider"
387
387
  );
388
+ let f = n || Ye;
389
+ f.endsWith("/api") && (f = f.slice(0, -4)), f.endsWith("/") && (f = f.slice(0, -1));
388
390
  const c = {
389
- api_key: u,
391
+ api_key: d,
390
392
  project: e,
391
- feedback: async (f) => {
392
- const m = `${n || Ye}/projects/${e}/signal`, O = ze(), w = {
393
- ...f.extra_metadata ?? {},
394
- ...O && { $dom_event: O }
395
- }, k = {
396
- session_id: f.session_id,
397
- source: f.source || "EXPLICIT",
398
- vote: f.vote,
399
- explanation: f.explanation,
400
- correction: f.correction,
401
- selection: f.selection,
402
- trigger_name: f.trigger_name,
403
- metadata: Object.keys(w).length > 0 ? w : void 0
404
- }, h = await fetch(m, {
393
+ feedback: async (h) => {
394
+ const b = `${f}/api/projects/${e}/signal`, P = ze(), E = {
395
+ ...h.metadata ?? {},
396
+ ...P && { $dom_event: P }
397
+ }, x = {
398
+ session_id: h.session_id,
399
+ kind: h.kind,
400
+ source: h.source,
401
+ trigger_name: h.trigger_name,
402
+ score: h.score,
403
+ value: h.value,
404
+ confidence: h.confidence,
405
+ metadata: Object.keys(E).length > 0 ? E : void 0,
406
+ timestamp: h.timestamp || (/* @__PURE__ */ new Date()).toISOString(),
407
+ trace_id: h.trace_id
408
+ }, p = await fetch(b, {
405
409
  method: "POST",
406
410
  headers: {
407
411
  "Content-Type": "application/json",
408
- Authorization: `Bearer ${u}`
412
+ Authorization: `Bearer ${d}`
409
413
  },
410
- body: JSON.stringify(k)
414
+ body: JSON.stringify(x)
411
415
  });
412
- if (!h.ok)
413
- throw new Error(`Failed to submit feedback: ${h.statusText}`);
416
+ if (!p.ok)
417
+ throw new Error(`Failed to submit feedback: ${p.statusText}`);
414
418
  }
415
419
  };
416
420
  return /* @__PURE__ */ F.jsx(ae.Provider, { value: c, children: r });
417
421
  }, te = (t, e) => {
418
422
  const n = { ...e };
419
423
  for (const r in e) {
420
- const o = t[r], u = e[r];
421
- /^on[A-Z]/.test(r) ? o && u ? n[r] = (...c) => {
422
- u(...c), o(...c);
423
- } : o && (n[r] = o) : r === "style" ? n[r] = { ...o, ...u } : r === "className" ? n[r] = [o, u].filter(Boolean).join(" ") : n[r] = u !== void 0 ? u : o;
424
+ const o = t[r], d = e[r];
425
+ /^on[A-Z]/.test(r) ? o && d ? n[r] = (...l) => {
426
+ d(...l), o(...l);
427
+ } : o && (n[r] = o) : r === "style" ? n[r] = { ...o, ...d } : r === "className" ? n[r] = [o, d].filter(Boolean).join(" ") : n[r] = d !== void 0 ? d : o;
424
428
  }
425
429
  return { ...t, ...n };
426
- }, Ce = xe(
427
- null
428
- ), ne = () => {
429
- const t = le(Ce);
430
+ }, _e = Pe(null), ne = () => {
431
+ const t = le(_e);
430
432
  if (!t)
431
433
  throw new Error(
432
434
  "VoteFeedback components must be used within VoteFeedback.Root"
@@ -437,145 +439,157 @@ const ae = xe(null), Ye = "https://api.kelet.ai/api", gt = () => {
437
439
  onFeedback: e,
438
440
  defaultText: n = "",
439
441
  session_id: r,
440
- extra_metadata: o,
441
- trigger_name: u
442
+ metadata: o,
443
+ trigger_name: d,
444
+ trace_id: f
442
445
  }) => {
443
- const p = typeof r == "function" ? r() : r, [c, f] = G(!1), [y, m] = G(n), [O, w] = G(!1), [k, h] = G(null), g = Y(null), C = Y(null), A = de(), b = de(), R = Te(), E = e || R;
446
+ const l = typeof r == "function" ? r() : r, c = d || void 0, [h, b] = X(!1), [P, E] = X(n), [x, p] = X(!1), [k, O] = X(null), A = Y(null), m = Y(null), T = de(), R = de(), _ = Te(), N = e || _;
444
447
  ce(() => {
445
- f(!1), m(n), w(!1), h(null), setTimeout(() => C.current?.focus(), 0);
446
- }, [p, n]);
447
- const P = q(async () => {
448
- h("upvote");
449
- const d = {
450
- session_id: p,
451
- vote: "upvote",
452
- ...o && { extra_metadata: o },
453
- ...u && { trigger_name: u }
448
+ b(!1), E(n), p(!1), O(null), setTimeout(() => m.current?.focus(), 0);
449
+ }, [l, n]);
450
+ const I = q(async () => {
451
+ O("upvote");
452
+ const g = {
453
+ session_id: l,
454
+ kind: "feedback",
455
+ source: "human",
456
+ trigger_name: c,
457
+ score: 1,
458
+ ...o && { metadata: o },
459
+ ...f && { trace_id: f }
454
460
  };
455
461
  try {
456
- w(!0), await E(d);
462
+ p(!0), await N(g);
457
463
  } finally {
458
- w(!1);
464
+ p(!1);
459
465
  }
460
- }, [E, p, o, u]), j = q(async () => {
461
- if (h("downvote"), E) {
462
- const d = {
463
- session_id: p,
464
- vote: "downvote",
465
- ...o && { extra_metadata: o },
466
- ...u && { trigger_name: u }
466
+ }, [N, l, o, c, f]), i = q(async () => {
467
+ if (O("downvote"), N) {
468
+ const g = {
469
+ session_id: l,
470
+ kind: "feedback",
471
+ source: "human",
472
+ trigger_name: c,
473
+ score: 0,
474
+ ...o && { metadata: o },
475
+ ...f && { trace_id: f }
467
476
  };
468
477
  try {
469
- w(!0), await E(d);
478
+ p(!0), await N(g);
470
479
  } finally {
471
- w(!1);
480
+ p(!1);
472
481
  }
473
482
  }
474
- f(!0), setTimeout(() => {
475
- g.current?.focus();
476
- const d = document.createElement("div");
477
- d.setAttribute("aria-live", "polite"), d.setAttribute("aria-atomic", "true"), d.className = "sr-only", d.textContent = "Feedback dialog opened. You can provide additional details about your downvote.", document.body.appendChild(d), setTimeout(() => document.body.removeChild(d), 1e3);
483
+ b(!0), setTimeout(() => {
484
+ A.current?.focus();
485
+ const g = document.createElement("div");
486
+ g.setAttribute("aria-live", "polite"), g.setAttribute("aria-atomic", "true"), g.className = "sr-only", g.textContent = "Feedback dialog opened. You can provide additional details about your downvote.", document.body.appendChild(g), setTimeout(() => document.body.removeChild(g), 1e3);
478
487
  }, 0);
479
- }, [E, p, o, u]), S = q(
480
- (d) => {
481
- m(d.target.value);
488
+ }, [N, l, o, c, f]), u = q(
489
+ (g) => {
490
+ E(g.target.value);
482
491
  },
483
492
  []
484
- ), i = q(async () => {
485
- const d = y.trim().length > 0;
486
- if (d) {
487
- const v = {
488
- session_id: p,
489
- vote: "downvote",
490
- explanation: y,
491
- ...o && { extra_metadata: o },
492
- ...u && { trigger_name: u }
493
+ ), s = q(async () => {
494
+ const g = P.trim().length > 0;
495
+ if (g) {
496
+ const w = {
497
+ session_id: l,
498
+ kind: "feedback",
499
+ source: "human",
500
+ trigger_name: c,
501
+ score: 0,
502
+ value: P,
503
+ ...o && { metadata: o },
504
+ ...f && { trace_id: f }
493
505
  };
494
506
  try {
495
- w(!0), await E(v);
507
+ p(!0), await N(w);
496
508
  } finally {
497
- w(!1);
509
+ p(!1);
498
510
  }
499
511
  }
500
- if (f(!1), m(n), C.current?.focus(), d) {
501
- const v = document.createElement("div");
502
- v.setAttribute("aria-live", "polite"), v.className = "sr-only", v.textContent = "Feedback submitted successfully.", document.body.appendChild(v), setTimeout(() => document.body.removeChild(v), 1e3);
512
+ if (b(!1), E(n), m.current?.focus(), g) {
513
+ const w = document.createElement("div");
514
+ w.setAttribute("aria-live", "polite"), w.className = "sr-only", w.textContent = "Feedback submitted successfully.", document.body.appendChild(w), setTimeout(() => document.body.removeChild(w), 1e3);
503
515
  }
504
516
  }, [
505
- E,
506
- y,
517
+ N,
518
+ P,
507
519
  n,
508
- p,
520
+ l,
509
521
  o,
510
- u
511
- ]), l = q(
512
- (d) => {
513
- if (d.key === "Escape")
514
- f(!1), m(n), C.current?.focus();
515
- else if ((d.metaKey || d.ctrlKey) && d.key === "Enter")
516
- d.preventDefault(), i().then((v) => {
522
+ c,
523
+ f
524
+ ]), v = q(
525
+ (g) => {
526
+ if (g.key === "Escape")
527
+ b(!1), E(n), m.current?.focus();
528
+ else if ((g.metaKey || g.ctrlKey) && g.key === "Enter")
529
+ g.preventDefault(), s().then((w) => {
517
530
  });
518
- else if (d.key === "Tab" && c) {
519
- const v = document.getElementById(A);
520
- if (v) {
521
- const D = v.querySelectorAll(
531
+ else if (g.key === "Tab" && h) {
532
+ const w = document.getElementById(T);
533
+ if (w) {
534
+ const M = w.querySelectorAll(
522
535
  'button, textarea, input, select, a[href], [tabindex]:not([tabindex="-1"])'
523
- ), x = D[0], M = D[D.length - 1];
524
- d.shiftKey && document.activeElement === x ? (d.preventDefault(), M?.focus()) : !d.shiftKey && document.activeElement === M && (d.preventDefault(), x?.focus());
536
+ ), j = M[0], H = M[M.length - 1];
537
+ g.shiftKey && document.activeElement === j ? (g.preventDefault(), H?.focus()) : !g.shiftKey && document.activeElement === H && (g.preventDefault(), j?.focus());
525
538
  }
526
539
  }
527
540
  },
528
- [i, c, A, n]
529
- ), s = {
530
- onFeedback: E,
531
- showPopover: c,
532
- setShowPopover: f,
533
- feedbackText: y,
534
- setFeedbackText: m,
535
- isSubmitting: O,
536
- setIsSubmitting: w,
541
+ [s, h, T, n]
542
+ ), y = {
543
+ onFeedback: N,
544
+ showPopover: h,
545
+ setShowPopover: b,
546
+ feedbackText: P,
547
+ setFeedbackText: E,
548
+ isSubmitting: x,
549
+ setIsSubmitting: p,
537
550
  vote: k,
538
- handleUpvote: P,
539
- handleDownvote: j,
540
- handleTextareaChange: S,
541
- handleSubmit: i,
542
- handleKeyDown: l,
543
- textareaRef: g,
544
- triggerRef: C,
545
- popoverId: A,
546
- triggerId: b,
547
- session_id: p,
548
- extra_metadata: o,
549
- trigger_name: u
551
+ handleUpvote: I,
552
+ handleDownvote: i,
553
+ handleTextareaChange: u,
554
+ handleSubmit: s,
555
+ handleKeyDown: v,
556
+ textareaRef: A,
557
+ triggerRef: m,
558
+ popoverId: T,
559
+ triggerId: R,
560
+ session_id: l,
561
+ metadata: o,
562
+ trigger_name: c,
563
+ trace_id: f
550
564
  };
551
- return /* @__PURE__ */ F.jsx(Ce.Provider, { value: s, children: t });
565
+ return /* @__PURE__ */ F.jsx(_e.Provider, { value: y, children: t });
552
566
  }, Ke = ({
553
567
  asChild: t,
554
568
  children: e,
555
569
  onClick: n,
556
570
  ...r
557
571
  }) => {
558
- const { handleUpvote: o, isSubmitting: u, vote: p } = ne(), c = q(
559
- (m) => {
560
- o(), n?.(m);
572
+ const { handleUpvote: o, isSubmitting: d, vote: f } = ne(), l = q(
573
+ (b) => {
574
+ o(), n?.(b);
561
575
  },
562
576
  [o, n]
563
- ), f = {
577
+ ), c = {
564
578
  ...r,
565
- onClick: c,
566
- disabled: u || r.disabled,
579
+ onClick: l,
580
+ disabled: d || r.disabled,
567
581
  "aria-label": r["aria-label"] || "Upvote feedback",
568
582
  type: "button"
569
- }, y = p === "upvote";
583
+ }, h = f === "upvote";
570
584
  if (t) {
571
- const m = typeof e == "function" ? e({ isSelected: y }) : e;
572
- if (Q(m))
585
+ const b = typeof e == "function" ? e({ isSelected: h }) : e;
586
+ if (Q(b))
573
587
  return ee(
574
- m,
575
- te(f, m.props)
588
+ b,
589
+ te(c, b.props)
576
590
  );
577
591
  }
578
- return /* @__PURE__ */ F.jsx("button", { ...f, children: typeof e == "function" ? e({ isSelected: y }) : e });
592
+ return /* @__PURE__ */ F.jsx("button", { ...c, children: typeof e == "function" ? e({ isSelected: h }) : e });
579
593
  }, Ue = ({
580
594
  asChild: t,
581
595
  children: e,
@@ -584,112 +598,112 @@ const ae = xe(null), Ye = "https://api.kelet.ai/api", gt = () => {
584
598
  }) => {
585
599
  const {
586
600
  handleDownvote: o,
587
- showPopover: u,
588
- isSubmitting: p,
589
- popoverId: c,
590
- triggerId: f,
591
- triggerRef: y,
592
- vote: m
593
- } = ne(), O = q(
594
- (h) => {
595
- o(), n?.(h);
601
+ showPopover: d,
602
+ isSubmitting: f,
603
+ popoverId: l,
604
+ triggerId: c,
605
+ triggerRef: h,
606
+ vote: b
607
+ } = ne(), P = q(
608
+ (p) => {
609
+ o(), n?.(p);
596
610
  },
597
611
  [o, n]
598
- ), w = {
612
+ ), E = {
599
613
  ...r,
600
- ref: y,
601
- onClick: O,
602
- disabled: p || r.disabled,
614
+ ref: h,
615
+ onClick: P,
616
+ disabled: f || r.disabled,
603
617
  "aria-label": r["aria-label"] || "Downvote feedback",
604
- "aria-expanded": u,
605
- "aria-controls": c,
606
- id: f,
618
+ "aria-expanded": d,
619
+ "aria-controls": l,
620
+ id: c,
607
621
  type: "button"
608
- }, k = m === "downvote";
622
+ }, x = b === "downvote";
609
623
  if (t) {
610
- const h = typeof e == "function" ? e({ isSelected: k }) : e;
611
- if (Q(h))
612
- return ee(h, te(w, h.props));
613
- if (h)
614
- return h;
624
+ const p = typeof e == "function" ? e({ isSelected: x }) : e;
625
+ if (Q(p))
626
+ return ee(p, te(E, p.props));
627
+ if (p)
628
+ return p;
615
629
  }
616
- return /* @__PURE__ */ F.jsx("button", { ...w, children: typeof e == "function" ? e({ isSelected: k }) : e });
630
+ return /* @__PURE__ */ F.jsx("button", { ...E, children: typeof e == "function" ? e({ isSelected: x }) : e });
617
631
  }, Je = ({ asChild: t, children: e, ...n }) => {
618
- const { showPopover: r, handleKeyDown: o, popoverId: u, triggerId: p } = ne();
632
+ const { showPopover: r, handleKeyDown: o, popoverId: d, triggerId: f } = ne();
619
633
  if (!r)
620
634
  return null;
621
- const c = {
635
+ const l = {
622
636
  ...n,
623
637
  role: "dialog",
624
- "aria-labelledby": p,
638
+ "aria-labelledby": f,
625
639
  "aria-modal": !0,
626
- "aria-describedby": `${u}-description`,
627
- id: u,
640
+ "aria-describedby": `${d}-description`,
641
+ id: d,
628
642
  onKeyDown: o,
629
643
  tabIndex: -1
630
644
  };
631
645
  return t && Q(e) ? /* @__PURE__ */ F.jsxs(F.Fragment, { children: [
632
646
  ee(
633
647
  e,
634
- te(c, e.props)
648
+ te(l, e.props)
635
649
  ),
636
- /* @__PURE__ */ F.jsx("div", { id: `${u}-description`, className: "sr-only", children: "Provide additional feedback for your downvote" })
637
- ] }) : /* @__PURE__ */ F.jsxs("div", { ...c, children: [
638
- /* @__PURE__ */ F.jsx("div", { id: `${u}-description`, className: "sr-only", children: "Provide additional feedback for your downvote" }),
650
+ /* @__PURE__ */ F.jsx("div", { id: `${d}-description`, className: "sr-only", children: "Provide additional feedback for your downvote" })
651
+ ] }) : /* @__PURE__ */ F.jsxs("div", { ...l, children: [
652
+ /* @__PURE__ */ F.jsx("div", { id: `${d}-description`, className: "sr-only", children: "Provide additional feedback for your downvote" }),
639
653
  e
640
654
  ] });
641
655
  }, Be = ({ asChild: t, value: e, onChange: n, ...r }) => {
642
656
  const {
643
657
  feedbackText: o,
644
- handleTextareaChange: u,
645
- textareaRef: p,
646
- handleKeyDown: c,
647
- popoverId: f
648
- } = ne(), y = {
658
+ handleTextareaChange: d,
659
+ textareaRef: f,
660
+ handleKeyDown: l,
661
+ popoverId: c
662
+ } = ne(), h = {
649
663
  ...r,
650
- ref: p,
664
+ ref: f,
651
665
  value: e !== void 0 ? e : o,
652
- onChange: n || u,
653
- onKeyDown: c,
666
+ onChange: n || d,
667
+ onKeyDown: l,
654
668
  placeholder: r.placeholder || "What did we miss?",
655
669
  "aria-label": r["aria-label"] || "Additional feedback",
656
- "aria-describedby": `${f}-help`,
670
+ "aria-describedby": `${c}-help`,
657
671
  rows: r.rows || 3
658
672
  };
659
673
  return t && Q(r.children) ? ee(
660
674
  r.children,
661
- te(y, r.children.props)
662
- ) : /* @__PURE__ */ F.jsx("textarea", { ...y });
675
+ te(h, r.children.props)
676
+ ) : /* @__PURE__ */ F.jsx("textarea", { ...h });
663
677
  }, Ve = ({
664
678
  asChild: t,
665
679
  children: e,
666
680
  onClick: n,
667
681
  ...r
668
682
  }) => {
669
- const { handleSubmit: o, isSubmitting: u, feedbackText: p } = ne(), c = q(
670
- (O) => {
671
- o(), n?.(O);
683
+ const { handleSubmit: o, isSubmitting: d, feedbackText: f } = ne(), l = q(
684
+ (P) => {
685
+ o(), n?.(P);
672
686
  },
673
687
  [o, n]
674
- ), f = p.trim().length > 0, y = f ? "Submit feedback" : "Close without feedback", m = {
688
+ ), c = f.trim().length > 0, h = c ? "Submit feedback" : "Close without feedback", b = {
675
689
  ...r,
676
- onClick: c,
677
- disabled: u || r.disabled,
690
+ onClick: l,
691
+ disabled: d || r.disabled,
678
692
  type: "button",
679
- "aria-label": r["aria-label"] || y,
680
- "aria-describedby": f ? void 0 : "submit-help"
693
+ "aria-label": r["aria-label"] || h,
694
+ "aria-describedby": c ? void 0 : "submit-help"
681
695
  };
682
696
  return t && Q(e) ? /* @__PURE__ */ F.jsxs(F.Fragment, { children: [
683
697
  ee(
684
698
  e,
685
- te(m, e.props)
699
+ te(b, e.props)
686
700
  ),
687
- !f && /* @__PURE__ */ F.jsx("span", { id: "submit-help", className: "sr-only", children: "This will close the dialog without submitting feedback" })
688
- ] }) : /* @__PURE__ */ F.jsxs("button", { ...m, children: [
701
+ !c && /* @__PURE__ */ F.jsx("span", { id: "submit-help", className: "sr-only", children: "This will close the dialog without submitting feedback" })
702
+ ] }) : /* @__PURE__ */ F.jsxs("button", { ...b, children: [
689
703
  e,
690
- !f && /* @__PURE__ */ F.jsx("span", { id: "submit-help", className: "sr-only", children: "This will close the dialog without submitting feedback" })
704
+ !c && /* @__PURE__ */ F.jsx("span", { id: "submit-help", className: "sr-only", children: "This will close the dialog without submitting feedback" })
691
705
  ] });
692
- }, Et = {
706
+ }, kt = {
693
707
  Root: He,
694
708
  UpvoteButton: Ke,
695
709
  DownvoteButton: Ue,
@@ -697,16 +711,16 @@ const ae = xe(null), Ye = "https://api.kelet.ai/api", gt = () => {
697
711
  Textarea: Be,
698
712
  SubmitButton: Ve
699
713
  };
700
- var se = { exports: {} }, Xe = se.exports, ve;
701
- function Ge() {
714
+ var se = { exports: {} }, Ge = se.exports, ve;
715
+ function Xe() {
702
716
  return ve || (ve = 1, function(t, e) {
703
717
  (function(n, r) {
704
718
  var o = r(n);
705
719
  t.exports = o;
706
- })(Xe, function(n) {
720
+ })(Ge, function(n) {
707
721
  var r = ["N", "E", "A", "D"];
708
- function o(i, l) {
709
- i.super_ = l, i.prototype = Object.create(l.prototype, {
722
+ function o(i, u) {
723
+ i.super_ = u, i.prototype = Object.create(u.prototype, {
710
724
  constructor: {
711
725
  value: i,
712
726
  enumerable: !1,
@@ -715,281 +729,281 @@ function Ge() {
715
729
  }
716
730
  });
717
731
  }
718
- function u(i, l) {
732
+ function d(i, u) {
719
733
  Object.defineProperty(this, "kind", {
720
734
  value: i,
721
735
  enumerable: !0
722
- }), l && l.length && Object.defineProperty(this, "path", {
723
- value: l,
736
+ }), u && u.length && Object.defineProperty(this, "path", {
737
+ value: u,
724
738
  enumerable: !0
725
739
  });
726
740
  }
727
- function p(i, l, s) {
728
- p.super_.call(this, "E", i), Object.defineProperty(this, "lhs", {
729
- value: l,
741
+ function f(i, u, s) {
742
+ f.super_.call(this, "E", i), Object.defineProperty(this, "lhs", {
743
+ value: u,
730
744
  enumerable: !0
731
745
  }), Object.defineProperty(this, "rhs", {
732
746
  value: s,
733
747
  enumerable: !0
734
748
  });
735
749
  }
736
- o(p, u);
737
- function c(i, l) {
738
- c.super_.call(this, "N", i), Object.defineProperty(this, "rhs", {
739
- value: l,
750
+ o(f, d);
751
+ function l(i, u) {
752
+ l.super_.call(this, "N", i), Object.defineProperty(this, "rhs", {
753
+ value: u,
740
754
  enumerable: !0
741
755
  });
742
756
  }
743
- o(c, u);
744
- function f(i, l) {
745
- f.super_.call(this, "D", i), Object.defineProperty(this, "lhs", {
746
- value: l,
757
+ o(l, d);
758
+ function c(i, u) {
759
+ c.super_.call(this, "D", i), Object.defineProperty(this, "lhs", {
760
+ value: u,
747
761
  enumerable: !0
748
762
  });
749
763
  }
750
- o(f, u);
751
- function y(i, l, s) {
752
- y.super_.call(this, "A", i), Object.defineProperty(this, "index", {
753
- value: l,
764
+ o(c, d);
765
+ function h(i, u, s) {
766
+ h.super_.call(this, "A", i), Object.defineProperty(this, "index", {
767
+ value: u,
754
768
  enumerable: !0
755
769
  }), Object.defineProperty(this, "item", {
756
770
  value: s,
757
771
  enumerable: !0
758
772
  });
759
773
  }
760
- o(y, u);
761
- function m(i, l, s) {
762
- var d = i.slice(l + 1 || i.length);
763
- return i.length = l < 0 ? i.length + l : l, i.push.apply(i, d), i;
774
+ o(h, d);
775
+ function b(i, u, s) {
776
+ var v = i.slice(u + 1 || i.length);
777
+ return i.length = u < 0 ? i.length + u : u, i.push.apply(i, v), i;
764
778
  }
765
- function O(i) {
766
- var l = typeof i;
767
- return l !== "object" ? l : i === Math ? "math" : i === null ? "null" : Array.isArray(i) ? "array" : Object.prototype.toString.call(i) === "[object Date]" ? "date" : typeof i.toString == "function" && /^\/.*\//.test(i.toString()) ? "regexp" : "object";
779
+ function P(i) {
780
+ var u = typeof i;
781
+ return u !== "object" ? u : i === Math ? "math" : i === null ? "null" : Array.isArray(i) ? "array" : Object.prototype.toString.call(i) === "[object Date]" ? "date" : typeof i.toString == "function" && /^\/.*\//.test(i.toString()) ? "regexp" : "object";
768
782
  }
769
- function w(i) {
770
- var l = 0;
783
+ function E(i) {
784
+ var u = 0;
771
785
  if (i.length === 0)
772
- return l;
786
+ return u;
773
787
  for (var s = 0; s < i.length; s++) {
774
- var d = i.charCodeAt(s);
775
- l = (l << 5) - l + d, l = l & l;
788
+ var v = i.charCodeAt(s);
789
+ u = (u << 5) - u + v, u = u & u;
776
790
  }
777
- return l;
791
+ return u;
778
792
  }
779
- function k(i) {
780
- var l = 0, s = O(i);
793
+ function x(i) {
794
+ var u = 0, s = P(i);
781
795
  if (s === "array") {
782
796
  i.forEach(function(M) {
783
- l += k(M);
797
+ u += x(M);
784
798
  });
785
- var d = "[type: array, hash: " + l + "]";
786
- return l + w(d);
799
+ var v = "[type: array, hash: " + u + "]";
800
+ return u + E(v);
787
801
  }
788
802
  if (s === "object") {
789
- for (var v in i)
790
- if (i.hasOwnProperty(v)) {
791
- var D = "[ type: object, key: " + v + ", value hash: " + k(i[v]) + "]";
792
- l += w(D);
803
+ for (var y in i)
804
+ if (i.hasOwnProperty(y)) {
805
+ var g = "[ type: object, key: " + y + ", value hash: " + x(i[y]) + "]";
806
+ u += E(g);
793
807
  }
794
- return l;
808
+ return u;
795
809
  }
796
- var x = "[ type: " + s + " ; value: " + i + "]";
797
- return l + w(x);
810
+ var w = "[ type: " + s + " ; value: " + i + "]";
811
+ return u + E(w);
798
812
  }
799
- function h(i, l, s, d, v, D, x, M) {
800
- s = s || [], v = v || [], x = x || [];
801
- var L = v.slice(0);
802
- if (typeof D < "u" && D !== null) {
803
- if (d) {
804
- if (typeof d == "function" && d(L, D))
813
+ function p(i, u, s, v, y, g, w, M) {
814
+ s = s || [], y = y || [], w = w || [];
815
+ var j = y.slice(0);
816
+ if (typeof g < "u" && g !== null) {
817
+ if (v) {
818
+ if (typeof v == "function" && v(j, g))
805
819
  return;
806
- if (typeof d == "object") {
807
- if (d.prefilter && d.prefilter(L, D))
820
+ if (typeof v == "object") {
821
+ if (v.prefilter && v.prefilter(j, g))
808
822
  return;
809
- if (d.normalize) {
810
- var U = d.normalize(L, D, i, l);
811
- U && (i = U[0], l = U[1]);
823
+ if (v.normalize) {
824
+ var H = v.normalize(j, g, i, u);
825
+ H && (i = H[0], u = H[1]);
812
826
  }
813
827
  }
814
828
  }
815
- L.push(D);
829
+ j.push(g);
816
830
  }
817
- O(i) === "regexp" && O(l) === "regexp" && (i = i.toString(), l = l.toString());
818
- var J = typeof i, re = typeof l, a, T, _, N, W = J !== "undefined" || x && x.length > 0 && x[x.length - 1].lhs && Object.getOwnPropertyDescriptor(x[x.length - 1].lhs, D), $ = re !== "undefined" || x && x.length > 0 && x[x.length - 1].rhs && Object.getOwnPropertyDescriptor(x[x.length - 1].rhs, D);
831
+ P(i) === "regexp" && P(u) === "regexp" && (i = i.toString(), u = u.toString());
832
+ var J = typeof i, re = typeof u, a, C, D, S, W = J !== "undefined" || w && w.length > 0 && w[w.length - 1].lhs && Object.getOwnPropertyDescriptor(w[w.length - 1].lhs, g), $ = re !== "undefined" || w && w.length > 0 && w[w.length - 1].rhs && Object.getOwnPropertyDescriptor(w[w.length - 1].rhs, g);
819
833
  if (!W && $)
820
- s.push(new c(L, l));
834
+ s.push(new l(j, u));
821
835
  else if (!$ && W)
822
- s.push(new f(L, i));
823
- else if (O(i) !== O(l))
824
- s.push(new p(L, i, l));
825
- else if (O(i) === "date" && i - l !== 0)
826
- s.push(new p(L, i, l));
827
- else if (J === "object" && i !== null && l !== null) {
828
- for (a = x.length - 1; a > -1; --a)
829
- if (x[a].lhs === i) {
830
- N = !0;
836
+ s.push(new c(j, i));
837
+ else if (P(i) !== P(u))
838
+ s.push(new f(j, i, u));
839
+ else if (P(i) === "date" && i - u !== 0)
840
+ s.push(new f(j, i, u));
841
+ else if (J === "object" && i !== null && u !== null) {
842
+ for (a = w.length - 1; a > -1; --a)
843
+ if (w[a].lhs === i) {
844
+ S = !0;
831
845
  break;
832
846
  }
833
- if (N)
834
- i !== l && s.push(new p(L, i, l));
847
+ if (S)
848
+ i !== u && s.push(new f(j, i, u));
835
849
  else {
836
- if (x.push({ lhs: i, rhs: l }), Array.isArray(i)) {
837
- for (M && (i.sort(function(I, z) {
838
- return k(I) - k(z);
839
- }), l.sort(function(I, z) {
840
- return k(I) - k(z);
841
- })), a = l.length - 1, T = i.length - 1; a > T; )
842
- s.push(new y(L, a, new c(void 0, l[a--])));
843
- for (; T > a; )
844
- s.push(new y(L, T, new f(void 0, i[T--])));
850
+ if (w.push({ lhs: i, rhs: u }), Array.isArray(i)) {
851
+ for (M && (i.sort(function(L, z) {
852
+ return x(L) - x(z);
853
+ }), u.sort(function(L, z) {
854
+ return x(L) - x(z);
855
+ })), a = u.length - 1, C = i.length - 1; a > C; )
856
+ s.push(new h(j, a, new l(void 0, u[a--])));
857
+ for (; C > a; )
858
+ s.push(new h(j, C, new c(void 0, i[C--])));
845
859
  for (; a >= 0; --a)
846
- h(i[a], l[a], s, d, L, a, x, M);
860
+ p(i[a], u[a], s, v, j, a, w, M);
847
861
  } else {
848
- var B = Object.keys(i), K = Object.keys(l);
862
+ var B = Object.keys(i), U = Object.keys(u);
849
863
  for (a = 0; a < B.length; ++a)
850
- _ = B[a], N = K.indexOf(_), N >= 0 ? (h(i[_], l[_], s, d, L, _, x, M), K[N] = null) : h(i[_], void 0, s, d, L, _, x, M);
851
- for (a = 0; a < K.length; ++a)
852
- _ = K[a], _ && h(void 0, l[_], s, d, L, _, x, M);
864
+ D = B[a], S = U.indexOf(D), S >= 0 ? (p(i[D], u[D], s, v, j, D, w, M), U[S] = null) : p(i[D], void 0, s, v, j, D, w, M);
865
+ for (a = 0; a < U.length; ++a)
866
+ D = U[a], D && p(void 0, u[D], s, v, j, D, w, M);
853
867
  }
854
- x.length = x.length - 1;
868
+ w.length = w.length - 1;
855
869
  }
856
- } else i !== l && (J === "number" && isNaN(i) && isNaN(l) || s.push(new p(L, i, l)));
870
+ } else i !== u && (J === "number" && isNaN(i) && isNaN(u) || s.push(new f(j, i, u)));
857
871
  }
858
- function g(i, l, s, d, v) {
859
- var D = [];
860
- if (h(i, l, D, d, null, null, null, v), s)
861
- for (var x = 0; x < D.length; ++x)
862
- s(D[x]);
863
- return D;
872
+ function k(i, u, s, v, y) {
873
+ var g = [];
874
+ if (p(i, u, g, v, null, null, null, y), s)
875
+ for (var w = 0; w < g.length; ++w)
876
+ s(g[w]);
877
+ return g;
864
878
  }
865
- function C(i, l, s, d, v, D, x) {
866
- return h(i, l, s, d, v, D, x, !0);
879
+ function O(i, u, s, v, y, g, w) {
880
+ return p(i, u, s, v, y, g, w, !0);
867
881
  }
868
- function A(i, l, s, d) {
869
- var v = d ? function(x) {
870
- x && d.push(x);
871
- } : void 0, D = g(i, l, v, s);
872
- return d || (D.length ? D : void 0);
882
+ function A(i, u, s, v) {
883
+ var y = v ? function(w) {
884
+ w && v.push(w);
885
+ } : void 0, g = k(i, u, y, s);
886
+ return v || (g.length ? g : void 0);
873
887
  }
874
- function b(i, l, s, d) {
875
- var v = d ? function(x) {
876
- x && d.push(x);
877
- } : void 0, D = g(i, l, v, s, !0);
878
- return d || (D.length ? D : void 0);
888
+ function m(i, u, s, v) {
889
+ var y = v ? function(w) {
890
+ w && v.push(w);
891
+ } : void 0, g = k(i, u, y, s, !0);
892
+ return v || (g.length ? g : void 0);
879
893
  }
880
- function R(i, l, s) {
894
+ function T(i, u, s) {
881
895
  if (s.path && s.path.length) {
882
- var d = i[l], v, D = s.path.length - 1;
883
- for (v = 0; v < D; v++)
884
- d = d[s.path[v]];
896
+ var v = i[u], y, g = s.path.length - 1;
897
+ for (y = 0; y < g; y++)
898
+ v = v[s.path[y]];
885
899
  switch (s.kind) {
886
900
  case "A":
887
- R(d[s.path[v]], s.index, s.item);
901
+ T(v[s.path[y]], s.index, s.item);
888
902
  break;
889
903
  case "D":
890
- delete d[s.path[v]];
904
+ delete v[s.path[y]];
891
905
  break;
892
906
  case "E":
893
907
  case "N":
894
- d[s.path[v]] = s.rhs;
908
+ v[s.path[y]] = s.rhs;
895
909
  break;
896
910
  }
897
911
  } else
898
912
  switch (s.kind) {
899
913
  case "A":
900
- R(i[l], s.index, s.item);
914
+ T(i[u], s.index, s.item);
901
915
  break;
902
916
  case "D":
903
- i = m(i, l);
917
+ i = b(i, u);
904
918
  break;
905
919
  case "E":
906
920
  case "N":
907
- i[l] = s.rhs;
921
+ i[u] = s.rhs;
908
922
  break;
909
923
  }
910
924
  return i;
911
925
  }
912
- function E(i, l, s) {
913
- if (typeof s > "u" && l && ~r.indexOf(l.kind) && (s = l), i && s && s.kind) {
914
- for (var d = i, v = -1, D = s.path ? s.path.length - 1 : 0; ++v < D; )
915
- typeof d[s.path[v]] > "u" && (d[s.path[v]] = typeof s.path[v + 1] < "u" && typeof s.path[v + 1] == "number" ? [] : {}), d = d[s.path[v]];
926
+ function R(i, u, s) {
927
+ if (typeof s > "u" && u && ~r.indexOf(u.kind) && (s = u), i && s && s.kind) {
928
+ for (var v = i, y = -1, g = s.path ? s.path.length - 1 : 0; ++y < g; )
929
+ typeof v[s.path[y]] > "u" && (v[s.path[y]] = typeof s.path[y + 1] < "u" && typeof s.path[y + 1] == "number" ? [] : {}), v = v[s.path[y]];
916
930
  switch (s.kind) {
917
931
  case "A":
918
- s.path && typeof d[s.path[v]] > "u" && (d[s.path[v]] = []), R(s.path ? d[s.path[v]] : d, s.index, s.item);
932
+ s.path && typeof v[s.path[y]] > "u" && (v[s.path[y]] = []), T(s.path ? v[s.path[y]] : v, s.index, s.item);
919
933
  break;
920
934
  case "D":
921
- delete d[s.path[v]];
935
+ delete v[s.path[y]];
922
936
  break;
923
937
  case "E":
924
938
  case "N":
925
- d[s.path[v]] = s.rhs;
939
+ v[s.path[y]] = s.rhs;
926
940
  break;
927
941
  }
928
942
  }
929
943
  }
930
- function P(i, l, s) {
944
+ function _(i, u, s) {
931
945
  if (s.path && s.path.length) {
932
- var d = i[l], v, D = s.path.length - 1;
933
- for (v = 0; v < D; v++)
934
- d = d[s.path[v]];
946
+ var v = i[u], y, g = s.path.length - 1;
947
+ for (y = 0; y < g; y++)
948
+ v = v[s.path[y]];
935
949
  switch (s.kind) {
936
950
  case "A":
937
- P(d[s.path[v]], s.index, s.item);
951
+ _(v[s.path[y]], s.index, s.item);
938
952
  break;
939
953
  case "D":
940
- d[s.path[v]] = s.lhs;
954
+ v[s.path[y]] = s.lhs;
941
955
  break;
942
956
  case "E":
943
- d[s.path[v]] = s.lhs;
957
+ v[s.path[y]] = s.lhs;
944
958
  break;
945
959
  case "N":
946
- delete d[s.path[v]];
960
+ delete v[s.path[y]];
947
961
  break;
948
962
  }
949
963
  } else
950
964
  switch (s.kind) {
951
965
  case "A":
952
- P(i[l], s.index, s.item);
966
+ _(i[u], s.index, s.item);
953
967
  break;
954
968
  case "D":
955
- i[l] = s.lhs;
969
+ i[u] = s.lhs;
956
970
  break;
957
971
  case "E":
958
- i[l] = s.lhs;
972
+ i[u] = s.lhs;
959
973
  break;
960
974
  case "N":
961
- i = m(i, l);
975
+ i = b(i, u);
962
976
  break;
963
977
  }
964
978
  return i;
965
979
  }
966
- function j(i, l, s) {
967
- if (i && l && s && s.kind) {
968
- var d = i, v, D;
969
- for (D = s.path.length - 1, v = 0; v < D; v++)
970
- typeof d[s.path[v]] > "u" && (d[s.path[v]] = {}), d = d[s.path[v]];
980
+ function N(i, u, s) {
981
+ if (i && u && s && s.kind) {
982
+ var v = i, y, g;
983
+ for (g = s.path.length - 1, y = 0; y < g; y++)
984
+ typeof v[s.path[y]] > "u" && (v[s.path[y]] = {}), v = v[s.path[y]];
971
985
  switch (s.kind) {
972
986
  case "A":
973
- P(d[s.path[v]], s.index, s.item);
987
+ _(v[s.path[y]], s.index, s.item);
974
988
  break;
975
989
  case "D":
976
- d[s.path[v]] = s.lhs;
990
+ v[s.path[y]] = s.lhs;
977
991
  break;
978
992
  case "E":
979
- d[s.path[v]] = s.lhs;
993
+ v[s.path[y]] = s.lhs;
980
994
  break;
981
995
  case "N":
982
- delete d[s.path[v]];
996
+ delete v[s.path[y]];
983
997
  break;
984
998
  }
985
999
  }
986
1000
  }
987
- function S(i, l, s) {
988
- if (i && l) {
989
- var d = function(v) {
990
- (!s || s(i, l, v)) && E(i, l, v);
1001
+ function I(i, u, s) {
1002
+ if (i && u) {
1003
+ var v = function(y) {
1004
+ (!s || s(i, u, y)) && R(i, u, y);
991
1005
  };
992
- g(i, l, d);
1006
+ k(i, u, v);
993
1007
  }
994
1008
  }
995
1009
  return Object.defineProperties(A, {
@@ -998,31 +1012,31 @@ function Ge() {
998
1012
  enumerable: !0
999
1013
  },
1000
1014
  orderIndependentDiff: {
1001
- value: b,
1015
+ value: m,
1002
1016
  enumerable: !0
1003
1017
  },
1004
1018
  observableDiff: {
1005
- value: g,
1019
+ value: k,
1006
1020
  enumerable: !0
1007
1021
  },
1008
1022
  orderIndependentObservableDiff: {
1009
- value: C,
1023
+ value: O,
1010
1024
  enumerable: !0
1011
1025
  },
1012
1026
  orderIndepHash: {
1013
- value: k,
1027
+ value: x,
1014
1028
  enumerable: !0
1015
1029
  },
1016
1030
  applyDiff: {
1017
- value: S,
1031
+ value: I,
1018
1032
  enumerable: !0
1019
1033
  },
1020
1034
  applyChange: {
1021
- value: E,
1035
+ value: R,
1022
1036
  enumerable: !0
1023
1037
  },
1024
1038
  revertChange: {
1025
- value: j,
1039
+ value: N,
1026
1040
  enumerable: !0
1027
1041
  },
1028
1042
  isConflict: {
@@ -1035,193 +1049,84 @@ function Ge() {
1035
1049
  });
1036
1050
  }(se)), se.exports;
1037
1051
  }
1038
- var Oe = Ge(), ie = { exports: {} };
1039
- const H = new Uint32Array(65536), Ze = (t, e) => {
1040
- const n = t.length, r = e.length, o = 1 << n - 1;
1041
- let u = -1, p = 0, c = n, f = n;
1042
- for (; f--; )
1043
- H[t.charCodeAt(f)] |= 1 << f;
1044
- for (f = 0; f < r; f++) {
1045
- let y = H[e.charCodeAt(f)];
1046
- const m = y | p;
1047
- y |= (y & u) + u ^ u, p |= ~(y | u), u &= y, p & o && c++, u & o && c--, p = p << 1 | 1, u = u << 1 | ~(m | p), p &= m;
1048
- }
1049
- for (f = n; f--; )
1050
- H[t.charCodeAt(f)] = 0;
1051
- return c;
1052
- }, Qe = (t, e) => {
1053
- const n = e.length, r = t.length, o = [], u = [], p = Math.ceil(n / 32), c = Math.ceil(r / 32);
1054
- for (let h = 0; h < p; h++)
1055
- u[h] = -1, o[h] = 0;
1056
- let f = 0;
1057
- for (; f < c - 1; f++) {
1058
- let h = 0, g = -1;
1059
- const C = f * 32, A = Math.min(32, r) + C;
1060
- for (let b = C; b < A; b++)
1061
- H[t.charCodeAt(b)] |= 1 << b;
1062
- for (let b = 0; b < n; b++) {
1063
- const R = H[e.charCodeAt(b)], E = u[b / 32 | 0] >>> b & 1, P = o[b / 32 | 0] >>> b & 1, j = R | h, S = ((R | P) & g) + g ^ g | R | P;
1064
- let i = h | ~(S | g), l = g & S;
1065
- i >>> 31 ^ E && (u[b / 32 | 0] ^= 1 << b), l >>> 31 ^ P && (o[b / 32 | 0] ^= 1 << b), i = i << 1 | E, l = l << 1 | P, g = l | ~(j | i), h = i & j;
1066
- }
1067
- for (let b = C; b < A; b++)
1068
- H[t.charCodeAt(b)] = 0;
1069
- }
1070
- let y = 0, m = -1;
1071
- const O = f * 32, w = Math.min(32, r - O) + O;
1072
- for (let h = O; h < w; h++)
1073
- H[t.charCodeAt(h)] |= 1 << h;
1074
- let k = r;
1075
- for (let h = 0; h < n; h++) {
1076
- const g = H[e.charCodeAt(h)], C = u[h / 32 | 0] >>> h & 1, A = o[h / 32 | 0] >>> h & 1, b = g | y, R = ((g | A) & m) + m ^ m | g | A;
1077
- let E = y | ~(R | m), P = m & R;
1078
- k += E >>> r - 1 & 1, k -= P >>> r - 1 & 1, E >>> 31 ^ C && (u[h / 32 | 0] ^= 1 << h), P >>> 31 ^ A && (o[h / 32 | 0] ^= 1 << h), E = E << 1 | C, P = P << 1 | A, m = P | ~(b | E), y = E & b;
1079
- }
1080
- for (let h = O; h < w; h++)
1081
- H[t.charCodeAt(h)] = 0;
1082
- return k;
1083
- }, Re = (t, e) => {
1084
- if (t.length < e.length) {
1085
- const n = e;
1086
- e = t, t = n;
1087
- }
1088
- return e.length === 0 ? t.length : t.length <= 32 ? Ze(t, e) : Qe(t, e);
1089
- }, et = (t, e) => {
1090
- let n = 1 / 0, r = 0;
1091
- for (let o = 0; o < e.length; o++) {
1092
- const u = Re(t, e[o]);
1093
- u < n && (n = u, r = o);
1094
- }
1095
- return e[r];
1096
- }, tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1097
- __proto__: null,
1098
- closest: et,
1099
- distance: Re
1100
- }, Symbol.toStringTag, { value: "Module" })), nt = /* @__PURE__ */ Se(tt);
1101
- var ye;
1102
- function rt() {
1103
- return ye || (ye = 1, function(t, e) {
1104
- (function() {
1105
- var n;
1106
- try {
1107
- n = typeof Intl < "u" && typeof Intl.Collator < "u" ? Intl.Collator("generic", { sensitivity: "base" }) : null;
1108
- } catch {
1109
- console.log("Collator could not be initialized and wouldn't be used");
1110
- }
1111
- var r = nt, o = [], u = [], p = {
1112
- /**
1113
- * Calculate levenshtein distance of the two strings.
1114
- *
1115
- * @param str1 String the first string.
1116
- * @param str2 String the second string.
1117
- * @param [options] Additional options.
1118
- * @param [options.useCollator] Use `Intl.Collator` for locale-sensitive string comparison.
1119
- * @return Integer the levenshtein distance (0 and above).
1120
- */
1121
- get: function(c, f, y) {
1122
- var m = y && n && y.useCollator;
1123
- if (m) {
1124
- var O = c.length, w = f.length;
1125
- if (O === 0) return w;
1126
- if (w === 0) return O;
1127
- var k, h, g, C, A;
1128
- for (g = 0; g < w; ++g)
1129
- o[g] = g, u[g] = f.charCodeAt(g);
1130
- o[w] = w;
1131
- var b;
1132
- for (g = 0; g < O; ++g) {
1133
- for (h = g + 1, C = 0; C < w; ++C)
1134
- k = h, b = n.compare(c.charAt(g), String.fromCharCode(u[C])) === 0, h = o[C] + (b ? 0 : 1), A = k + 1, h > A && (h = A), A = o[C + 1] + 1, h > A && (h = A), o[C] = k;
1135
- o[C] = h;
1136
- }
1137
- return h;
1138
- }
1139
- return r.distance(c, f);
1140
- }
1141
- };
1142
- t !== null && t.exports === e ? t.exports = p : typeof self < "u" && typeof self.postMessage == "function" && typeof self.importScripts == "function" ? self.Levenshtein = p : typeof window < "u" && window !== null && (window.Levenshtein = p);
1143
- })();
1144
- }(ie, ie.exports)), ie.exports;
1145
- }
1146
- var ot = rt();
1147
- const it = /* @__PURE__ */ je(ot);
1148
- class st {
1052
+ var Ce = Xe();
1053
+ class Ze {
1149
1054
  diff(e, n, r = {}) {
1150
1055
  let o;
1151
1056
  typeof r == "function" ? (o = r, r = {}) : "callback" in r && (o = r.callback);
1152
- const u = this.castInput(e, r), p = this.castInput(n, r), c = this.removeEmpty(this.tokenize(u, r)), f = this.removeEmpty(this.tokenize(p, r));
1153
- return this.diffWithOptionsObj(c, f, r, o);
1057
+ const d = this.castInput(e, r), f = this.castInput(n, r), l = this.removeEmpty(this.tokenize(d, r)), c = this.removeEmpty(this.tokenize(f, r));
1058
+ return this.diffWithOptionsObj(l, c, r, o);
1154
1059
  }
1155
1060
  diffWithOptionsObj(e, n, r, o) {
1156
- var u;
1157
- const p = (b) => {
1158
- if (b = this.postProcess(b, r), o) {
1061
+ var d;
1062
+ const f = (m) => {
1063
+ if (m = this.postProcess(m, r), o) {
1159
1064
  setTimeout(function() {
1160
- o(b);
1065
+ o(m);
1161
1066
  }, 0);
1162
1067
  return;
1163
1068
  } else
1164
- return b;
1165
- }, c = n.length, f = e.length;
1166
- let y = 1, m = c + f;
1167
- r.maxEditLength != null && (m = Math.min(m, r.maxEditLength));
1168
- const O = (u = r.timeout) !== null && u !== void 0 ? u : 1 / 0, w = Date.now() + O, k = [{ oldPos: -1, lastComponent: void 0 }];
1169
- let h = this.extractCommon(k[0], n, e, 0, r);
1170
- if (k[0].oldPos + 1 >= f && h + 1 >= c)
1171
- return p(this.buildValues(k[0].lastComponent, n, e));
1172
- let g = -1 / 0, C = 1 / 0;
1069
+ return m;
1070
+ }, l = n.length, c = e.length;
1071
+ let h = 1, b = l + c;
1072
+ r.maxEditLength != null && (b = Math.min(b, r.maxEditLength));
1073
+ const P = (d = r.timeout) !== null && d !== void 0 ? d : 1 / 0, E = Date.now() + P, x = [{ oldPos: -1, lastComponent: void 0 }];
1074
+ let p = this.extractCommon(x[0], n, e, 0, r);
1075
+ if (x[0].oldPos + 1 >= c && p + 1 >= l)
1076
+ return f(this.buildValues(x[0].lastComponent, n, e));
1077
+ let k = -1 / 0, O = 1 / 0;
1173
1078
  const A = () => {
1174
- for (let b = Math.max(g, -y); b <= Math.min(C, y); b += 2) {
1175
- let R;
1176
- const E = k[b - 1], P = k[b + 1];
1177
- E && (k[b - 1] = void 0);
1178
- let j = !1;
1179
- if (P) {
1180
- const i = P.oldPos - b;
1181
- j = P && 0 <= i && i < c;
1079
+ for (let m = Math.max(k, -h); m <= Math.min(O, h); m += 2) {
1080
+ let T;
1081
+ const R = x[m - 1], _ = x[m + 1];
1082
+ R && (x[m - 1] = void 0);
1083
+ let N = !1;
1084
+ if (_) {
1085
+ const i = _.oldPos - m;
1086
+ N = _ && 0 <= i && i < l;
1182
1087
  }
1183
- const S = E && E.oldPos + 1 < f;
1184
- if (!j && !S) {
1185
- k[b] = void 0;
1088
+ const I = R && R.oldPos + 1 < c;
1089
+ if (!N && !I) {
1090
+ x[m] = void 0;
1186
1091
  continue;
1187
1092
  }
1188
- if (!S || j && E.oldPos < P.oldPos ? R = this.addToPath(P, !0, !1, 0, r) : R = this.addToPath(E, !1, !0, 1, r), h = this.extractCommon(R, n, e, b, r), R.oldPos + 1 >= f && h + 1 >= c)
1189
- return p(this.buildValues(R.lastComponent, n, e)) || !0;
1190
- k[b] = R, R.oldPos + 1 >= f && (C = Math.min(C, b - 1)), h + 1 >= c && (g = Math.max(g, b + 1));
1093
+ if (!I || N && R.oldPos < _.oldPos ? T = this.addToPath(_, !0, !1, 0, r) : T = this.addToPath(R, !1, !0, 1, r), p = this.extractCommon(T, n, e, m, r), T.oldPos + 1 >= c && p + 1 >= l)
1094
+ return f(this.buildValues(T.lastComponent, n, e)) || !0;
1095
+ x[m] = T, T.oldPos + 1 >= c && (O = Math.min(O, m - 1)), p + 1 >= l && (k = Math.max(k, m + 1));
1191
1096
  }
1192
- y++;
1097
+ h++;
1193
1098
  };
1194
1099
  if (o)
1195
- (function b() {
1100
+ (function m() {
1196
1101
  setTimeout(function() {
1197
- if (y > m || Date.now() > w)
1102
+ if (h > b || Date.now() > E)
1198
1103
  return o(void 0);
1199
- A() || b();
1104
+ A() || m();
1200
1105
  }, 0);
1201
1106
  })();
1202
1107
  else
1203
- for (; y <= m && Date.now() <= w; ) {
1204
- const b = A();
1205
- if (b)
1206
- return b;
1108
+ for (; h <= b && Date.now() <= E; ) {
1109
+ const m = A();
1110
+ if (m)
1111
+ return m;
1207
1112
  }
1208
1113
  }
1209
- addToPath(e, n, r, o, u) {
1210
- const p = e.lastComponent;
1211
- return p && !u.oneChangePerToken && p.added === n && p.removed === r ? {
1114
+ addToPath(e, n, r, o, d) {
1115
+ const f = e.lastComponent;
1116
+ return f && !d.oneChangePerToken && f.added === n && f.removed === r ? {
1212
1117
  oldPos: e.oldPos + o,
1213
- lastComponent: { count: p.count + 1, added: n, removed: r, previousComponent: p.previousComponent }
1118
+ lastComponent: { count: f.count + 1, added: n, removed: r, previousComponent: f.previousComponent }
1214
1119
  } : {
1215
1120
  oldPos: e.oldPos + o,
1216
- lastComponent: { count: 1, added: n, removed: r, previousComponent: p }
1121
+ lastComponent: { count: 1, added: n, removed: r, previousComponent: f }
1217
1122
  };
1218
1123
  }
1219
- extractCommon(e, n, r, o, u) {
1220
- const p = n.length, c = r.length;
1221
- let f = e.oldPos, y = f - o, m = 0;
1222
- for (; y + 1 < p && f + 1 < c && this.equals(r[f + 1], n[y + 1], u); )
1223
- y++, f++, m++, u.oneChangePerToken && (e.lastComponent = { count: 1, previousComponent: e.lastComponent, added: !1, removed: !1 });
1224
- return m && !u.oneChangePerToken && (e.lastComponent = { count: m, previousComponent: e.lastComponent, added: !1, removed: !1 }), e.oldPos = f, y;
1124
+ extractCommon(e, n, r, o, d) {
1125
+ const f = n.length, l = r.length;
1126
+ let c = e.oldPos, h = c - o, b = 0;
1127
+ for (; h + 1 < f && c + 1 < l && this.equals(r[c + 1], n[h + 1], d); )
1128
+ h++, c++, b++, d.oneChangePerToken && (e.lastComponent = { count: 1, previousComponent: e.lastComponent, added: !1, removed: !1 });
1129
+ return b && !d.oneChangePerToken && (e.lastComponent = { count: b, previousComponent: e.lastComponent, added: !1, removed: !1 }), e.oldPos = c, h;
1225
1130
  }
1226
1131
  equals(e, n, r) {
1227
1132
  return r.comparator ? r.comparator(e, n) : e === n || !!r.ignoreCase && e.toLowerCase() === n.toLowerCase();
@@ -1251,34 +1156,34 @@ class st {
1251
1156
  }
1252
1157
  buildValues(e, n, r) {
1253
1158
  const o = [];
1254
- let u;
1159
+ let d;
1255
1160
  for (; e; )
1256
- o.push(e), u = e.previousComponent, delete e.previousComponent, e = u;
1161
+ o.push(e), d = e.previousComponent, delete e.previousComponent, e = d;
1257
1162
  o.reverse();
1258
- const p = o.length;
1259
- let c = 0, f = 0, y = 0;
1260
- for (; c < p; c++) {
1261
- const m = o[c];
1262
- if (m.removed)
1263
- m.value = this.join(r.slice(y, y + m.count)), y += m.count;
1163
+ const f = o.length;
1164
+ let l = 0, c = 0, h = 0;
1165
+ for (; l < f; l++) {
1166
+ const b = o[l];
1167
+ if (b.removed)
1168
+ b.value = this.join(r.slice(h, h + b.count)), h += b.count;
1264
1169
  else {
1265
- if (!m.added && this.useLongestToken) {
1266
- let O = n.slice(f, f + m.count);
1267
- O = O.map(function(w, k) {
1268
- const h = r[y + k];
1269
- return h.length > w.length ? h : w;
1270
- }), m.value = this.join(O);
1170
+ if (!b.added && this.useLongestToken) {
1171
+ let P = n.slice(c, c + b.count);
1172
+ P = P.map(function(E, x) {
1173
+ const p = r[h + x];
1174
+ return p.length > E.length ? p : E;
1175
+ }), b.value = this.join(P);
1271
1176
  } else
1272
- m.value = this.join(n.slice(f, f + m.count));
1273
- f += m.count, m.added || (y += m.count);
1177
+ b.value = this.join(n.slice(c, c + b.count));
1178
+ c += b.count, b.added || (h += b.count);
1274
1179
  }
1275
1180
  }
1276
1181
  return o;
1277
1182
  }
1278
1183
  }
1279
- class at extends st {
1184
+ class Qe extends Ze {
1280
1185
  constructor() {
1281
- super(...arguments), this.tokenize = ut;
1186
+ super(...arguments), this.tokenize = tt;
1282
1187
  }
1283
1188
  equals(e, n, r) {
1284
1189
  return r.ignoreWhitespace ? ((!r.newlineIsToken || !e.includes(`
@@ -1288,87 +1193,87 @@ class at extends st {
1288
1193
  `) && (n = n.slice(0, -1))), super.equals(e, n, r);
1289
1194
  }
1290
1195
  }
1291
- const lt = new at();
1292
- function ge(t, e, n) {
1293
- return lt.diff(t, e, n);
1196
+ const et = new Qe();
1197
+ function ye(t, e, n) {
1198
+ return et.diff(t, e, n);
1294
1199
  }
1295
- function ut(t, e) {
1200
+ function tt(t, e) {
1296
1201
  e.stripTrailingCr && (t = t.replace(/\r\n/g, `
1297
1202
  `));
1298
1203
  const n = [], r = t.split(/(\n|\r\n)/);
1299
1204
  r[r.length - 1] || r.pop();
1300
1205
  for (let o = 0; o < r.length; o++) {
1301
- const u = r[o];
1302
- o % 2 && !e.newlineIsToken ? n[n.length - 1] += u : n.push(u);
1206
+ const d = r[o];
1207
+ o % 2 && !e.newlineIsToken ? n[n.length - 1] += d : n.push(d);
1303
1208
  }
1304
1209
  return n;
1305
1210
  }
1306
- function we(t, e, n, r, o, u, p) {
1307
- let c;
1308
- p ? typeof p == "function" ? c = { callback: p } : c = p : c = {}, typeof c.context > "u" && (c.context = 4);
1309
- const f = c.context;
1310
- if (c.newlineIsToken)
1211
+ function ge(t, e, n, r, o, d, f) {
1212
+ let l;
1213
+ f ? typeof f == "function" ? l = { callback: f } : l = f : l = {}, typeof l.context > "u" && (l.context = 4);
1214
+ const c = l.context;
1215
+ if (l.newlineIsToken)
1311
1216
  throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
1312
- if (c.callback) {
1313
- const { callback: m } = c;
1314
- ge(n, r, Object.assign(Object.assign({}, c), { callback: (O) => {
1315
- const w = y(O);
1316
- m(w);
1217
+ if (l.callback) {
1218
+ const { callback: b } = l;
1219
+ ye(n, r, Object.assign(Object.assign({}, l), { callback: (P) => {
1220
+ const E = h(P);
1221
+ b(E);
1317
1222
  } }));
1318
1223
  } else
1319
- return y(ge(n, r, c));
1320
- function y(m) {
1321
- if (!m)
1224
+ return h(ye(n, r, l));
1225
+ function h(b) {
1226
+ if (!b)
1322
1227
  return;
1323
- m.push({ value: "", lines: [] });
1324
- function O(b) {
1325
- return b.map(function(R) {
1326
- return " " + R;
1228
+ b.push({ value: "", lines: [] });
1229
+ function P(m) {
1230
+ return m.map(function(T) {
1231
+ return " " + T;
1327
1232
  });
1328
1233
  }
1329
- const w = [];
1330
- let k = 0, h = 0, g = [], C = 1, A = 1;
1331
- for (let b = 0; b < m.length; b++) {
1332
- const R = m[b], E = R.lines || ct(R.value);
1333
- if (R.lines = E, R.added || R.removed) {
1334
- if (!k) {
1335
- const P = m[b - 1];
1336
- k = C, h = A, P && (g = f > 0 ? O(P.lines.slice(-f)) : [], k -= g.length, h -= g.length);
1234
+ const E = [];
1235
+ let x = 0, p = 0, k = [], O = 1, A = 1;
1236
+ for (let m = 0; m < b.length; m++) {
1237
+ const T = b[m], R = T.lines || rt(T.value);
1238
+ if (T.lines = R, T.added || T.removed) {
1239
+ if (!x) {
1240
+ const _ = b[m - 1];
1241
+ x = O, p = A, _ && (k = c > 0 ? P(_.lines.slice(-c)) : [], x -= k.length, p -= k.length);
1337
1242
  }
1338
- for (const P of E)
1339
- g.push((R.added ? "+" : "-") + P);
1340
- R.added ? A += E.length : C += E.length;
1243
+ for (const _ of R)
1244
+ k.push((T.added ? "+" : "-") + _);
1245
+ T.added ? A += R.length : O += R.length;
1341
1246
  } else {
1342
- if (k)
1343
- if (E.length <= f * 2 && b < m.length - 2)
1344
- for (const P of O(E))
1345
- g.push(P);
1247
+ if (x)
1248
+ if (R.length <= c * 2 && m < b.length - 2)
1249
+ for (const _ of P(R))
1250
+ k.push(_);
1346
1251
  else {
1347
- const P = Math.min(E.length, f);
1348
- for (const S of O(E.slice(0, P)))
1349
- g.push(S);
1350
- const j = {
1351
- oldStart: k,
1352
- oldLines: C - k + P,
1353
- newStart: h,
1354
- newLines: A - h + P,
1355
- lines: g
1252
+ const _ = Math.min(R.length, c);
1253
+ for (const I of P(R.slice(0, _)))
1254
+ k.push(I);
1255
+ const N = {
1256
+ oldStart: x,
1257
+ oldLines: O - x + _,
1258
+ newStart: p,
1259
+ newLines: A - p + _,
1260
+ lines: k
1356
1261
  };
1357
- w.push(j), k = 0, h = 0, g = [];
1262
+ E.push(N), x = 0, p = 0, k = [];
1358
1263
  }
1359
- C += E.length, A += E.length;
1264
+ O += R.length, A += R.length;
1360
1265
  }
1361
1266
  }
1362
- for (const b of w)
1363
- for (let R = 0; R < b.lines.length; R++)
1364
- b.lines[R].endsWith(`
1365
- `) ? b.lines[R] = b.lines[R].slice(0, -1) : (b.lines.splice(R + 1, 0, "\"), R++);
1267
+ for (const m of E)
1268
+ for (let T = 0; T < m.lines.length; T++)
1269
+ m.lines[T].endsWith(`
1270
+ `) ? m.lines[T] = m.lines[T].slice(0, -1) : (m.lines.splice(T + 1, 0, "\"), T++);
1366
1271
  return {
1367
1272
  oldFileName: t,
1368
1273
  newFileName: e,
1369
1274
  oldHeader: o,
1370
- newHeader: u,
1371
- hunks: w
1275
+ newHeader: d,
1276
+ hunks: E
1372
1277
  };
1373
1278
  }
1374
1279
  }
@@ -1388,38 +1293,148 @@ function fe(t) {
1388
1293
  `) + `
1389
1294
  `;
1390
1295
  }
1391
- function ft(t, e, n, r, o, u, p) {
1392
- if (typeof p == "function" && (p = { callback: p }), p?.callback) {
1393
- const { callback: c } = p;
1394
- we(t, e, n, r, o, u, Object.assign(Object.assign({}, p), { callback: (f) => {
1395
- c(f ? fe(f) : void 0);
1296
+ function nt(t, e, n, r, o, d, f) {
1297
+ if (typeof f == "function" && (f = { callback: f }), f?.callback) {
1298
+ const { callback: l } = f;
1299
+ ge(t, e, n, r, o, d, Object.assign(Object.assign({}, f), { callback: (c) => {
1300
+ l(c ? fe(c) : void 0);
1396
1301
  } }));
1397
1302
  } else {
1398
- const c = we(t, e, n, r, o, u, p);
1399
- return c ? fe(c) : void 0;
1303
+ const l = ge(t, e, n, r, o, d, f);
1304
+ return l ? fe(l) : void 0;
1400
1305
  }
1401
1306
  }
1402
- function ct(t) {
1307
+ function rt(t) {
1403
1308
  const e = t.endsWith(`
1404
1309
  `), n = t.split(`
1405
1310
  `).map((r) => r + `
1406
1311
  `);
1407
1312
  return e ? n.pop() : n.push(n.pop().slice(0, -1)), n;
1408
1313
  }
1314
+ var ie = { exports: {} };
1315
+ const K = new Uint32Array(65536), ot = (t, e) => {
1316
+ const n = t.length, r = e.length, o = 1 << n - 1;
1317
+ let d = -1, f = 0, l = n, c = n;
1318
+ for (; c--; )
1319
+ K[t.charCodeAt(c)] |= 1 << c;
1320
+ for (c = 0; c < r; c++) {
1321
+ let h = K[e.charCodeAt(c)];
1322
+ const b = h | f;
1323
+ h |= (h & d) + d ^ d, f |= ~(h | d), d &= h, f & o && l++, d & o && l--, f = f << 1 | 1, d = d << 1 | ~(b | f), f &= b;
1324
+ }
1325
+ for (c = n; c--; )
1326
+ K[t.charCodeAt(c)] = 0;
1327
+ return l;
1328
+ }, it = (t, e) => {
1329
+ const n = e.length, r = t.length, o = [], d = [], f = Math.ceil(n / 32), l = Math.ceil(r / 32);
1330
+ for (let p = 0; p < f; p++)
1331
+ d[p] = -1, o[p] = 0;
1332
+ let c = 0;
1333
+ for (; c < l - 1; c++) {
1334
+ let p = 0, k = -1;
1335
+ const O = c * 32, A = Math.min(32, r) + O;
1336
+ for (let m = O; m < A; m++)
1337
+ K[t.charCodeAt(m)] |= 1 << m;
1338
+ for (let m = 0; m < n; m++) {
1339
+ const T = K[e.charCodeAt(m)], R = d[m / 32 | 0] >>> m & 1, _ = o[m / 32 | 0] >>> m & 1, N = T | p, I = ((T | _) & k) + k ^ k | T | _;
1340
+ let i = p | ~(I | k), u = k & I;
1341
+ i >>> 31 ^ R && (d[m / 32 | 0] ^= 1 << m), u >>> 31 ^ _ && (o[m / 32 | 0] ^= 1 << m), i = i << 1 | R, u = u << 1 | _, k = u | ~(N | i), p = i & N;
1342
+ }
1343
+ for (let m = O; m < A; m++)
1344
+ K[t.charCodeAt(m)] = 0;
1345
+ }
1346
+ let h = 0, b = -1;
1347
+ const P = c * 32, E = Math.min(32, r - P) + P;
1348
+ for (let p = P; p < E; p++)
1349
+ K[t.charCodeAt(p)] |= 1 << p;
1350
+ let x = r;
1351
+ for (let p = 0; p < n; p++) {
1352
+ const k = K[e.charCodeAt(p)], O = d[p / 32 | 0] >>> p & 1, A = o[p / 32 | 0] >>> p & 1, m = k | h, T = ((k | A) & b) + b ^ b | k | A;
1353
+ let R = h | ~(T | b), _ = b & T;
1354
+ x += R >>> r - 1 & 1, x -= _ >>> r - 1 & 1, R >>> 31 ^ O && (d[p / 32 | 0] ^= 1 << p), _ >>> 31 ^ A && (o[p / 32 | 0] ^= 1 << p), R = R << 1 | O, _ = _ << 1 | A, b = _ | ~(m | R), h = R & m;
1355
+ }
1356
+ for (let p = P; p < E; p++)
1357
+ K[t.charCodeAt(p)] = 0;
1358
+ return x;
1359
+ }, Oe = (t, e) => {
1360
+ if (t.length < e.length) {
1361
+ const n = e;
1362
+ e = t, t = n;
1363
+ }
1364
+ return e.length === 0 ? t.length : t.length <= 32 ? ot(t, e) : it(t, e);
1365
+ }, st = (t, e) => {
1366
+ let n = 1 / 0, r = 0;
1367
+ for (let o = 0; o < e.length; o++) {
1368
+ const d = Oe(t, e[o]);
1369
+ d < n && (n = d, r = o);
1370
+ }
1371
+ return e[r];
1372
+ }, at = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1373
+ __proto__: null,
1374
+ closest: st,
1375
+ distance: Oe
1376
+ }, Symbol.toStringTag, { value: "Module" })), lt = /* @__PURE__ */ Se(at);
1377
+ var we;
1378
+ function ut() {
1379
+ return we || (we = 1, function(t, e) {
1380
+ (function() {
1381
+ var n;
1382
+ try {
1383
+ n = typeof Intl < "u" && typeof Intl.Collator < "u" ? Intl.Collator("generic", { sensitivity: "base" }) : null;
1384
+ } catch {
1385
+ console.log("Collator could not be initialized and wouldn't be used");
1386
+ }
1387
+ var r = lt, o = [], d = [], f = {
1388
+ /**
1389
+ * Calculate levenshtein distance of the two strings.
1390
+ *
1391
+ * @param str1 String the first string.
1392
+ * @param str2 String the second string.
1393
+ * @param [options] Additional options.
1394
+ * @param [options.useCollator] Use `Intl.Collator` for locale-sensitive string comparison.
1395
+ * @return Integer the levenshtein distance (0 and above).
1396
+ */
1397
+ get: function(l, c, h) {
1398
+ var b = h && n && h.useCollator;
1399
+ if (b) {
1400
+ var P = l.length, E = c.length;
1401
+ if (P === 0) return E;
1402
+ if (E === 0) return P;
1403
+ var x, p, k, O, A;
1404
+ for (k = 0; k < E; ++k)
1405
+ o[k] = k, d[k] = c.charCodeAt(k);
1406
+ o[E] = E;
1407
+ var m;
1408
+ for (k = 0; k < P; ++k) {
1409
+ for (p = k + 1, O = 0; O < E; ++O)
1410
+ x = p, m = n.compare(l.charAt(k), String.fromCharCode(d[O])) === 0, p = o[O] + (m ? 0 : 1), A = x + 1, p > A && (p = A), A = o[O + 1] + 1, p > A && (p = A), o[O] = x;
1411
+ o[O] = p;
1412
+ }
1413
+ return p;
1414
+ }
1415
+ return r.distance(l, c);
1416
+ }
1417
+ };
1418
+ t !== null && t.exports === e ? t.exports = f : typeof self < "u" && typeof self.postMessage == "function" && typeof self.importScripts == "function" ? self.Levenshtein = f : typeof window < "u" && window !== null && (window.Levenshtein = f);
1419
+ })();
1420
+ }(ie, ie.exports)), ie.exports;
1421
+ }
1422
+ var ft = ut();
1423
+ const ct = /* @__PURE__ */ je(ft);
1409
1424
  function dt(t, e, n = "git", r = 1) {
1410
1425
  switch (n) {
1411
1426
  case "git":
1412
- return Ee(t, e, r);
1427
+ return ke(t, e, r);
1413
1428
  case "object":
1414
1429
  return pt(t, e);
1415
1430
  case "json":
1416
1431
  return ht(t, e);
1417
1432
  default:
1418
- return Ee(t, e, r);
1433
+ return ke(t, e, r);
1419
1434
  }
1420
1435
  }
1421
- function Ee(t, e, n = 1) {
1422
- const r = Pe(t), o = Pe(e), c = ft(
1436
+ function ke(t, e, n = 1) {
1437
+ const r = xe(t), o = xe(e), l = nt(
1423
1438
  /* oldFilename */
1424
1439
  "",
1425
1440
  /* newFilename */
@@ -1432,15 +1447,15 @@ function Ee(t, e, n = 1) {
1432
1447
  "",
1433
1448
  { context: n }
1434
1449
  ).split(`
1435
- `).filter((f) => !f || f === "\" || f.startsWith("@@") || f.startsWith("---") || f.startsWith("+++") || f.startsWith(" ") ? !1 : !!(f.startsWith("+") || f.startsWith("-")));
1436
- for (; c.length && c[0].trim() === ""; ) c.shift();
1437
- for (; c.length && c[c.length - 1].trim() === ""; )
1438
- c.pop();
1439
- return c.join(`
1450
+ `).filter((c) => !c || c === "\" || c.startsWith("@@") || c.startsWith("---") || c.startsWith("+++") || c.startsWith(" ") ? !1 : !!(c.startsWith("+") || c.startsWith("-")));
1451
+ for (; l.length && l[0].trim() === ""; ) l.shift();
1452
+ for (; l.length && l[l.length - 1].trim() === ""; )
1453
+ l.pop();
1454
+ return l.join(`
1440
1455
  `);
1441
1456
  }
1442
1457
  function pt(t, e) {
1443
- const n = Oe.diff(t, e) || [];
1458
+ const n = Ce.diff(t, e) || [];
1444
1459
  return JSON.stringify(n, null, 2);
1445
1460
  }
1446
1461
  function ht(t, e) {
@@ -1454,15 +1469,15 @@ function ht(t, e) {
1454
1469
  );
1455
1470
  }
1456
1471
  function mt(t, e) {
1457
- return typeof t == "string" && typeof e == "string" ? Ae(t, e) : typeof t == "number" && typeof e == "number" ? De(t, e) : bt(t, e);
1472
+ return typeof t == "string" && typeof e == "string" ? Re(t, e) : typeof t == "number" && typeof e == "number" ? Ae(t, e) : bt(t, e);
1458
1473
  }
1459
- function Ae(t, e) {
1474
+ function Re(t, e) {
1460
1475
  if (t === e) return 0;
1461
1476
  if (t.length === 0 || e.length === 0) return 1;
1462
- const n = it.get(t, e), r = Math.max(t.length, e.length);
1477
+ const n = ct.get(t, e), r = Math.max(t.length, e.length);
1463
1478
  return n / r;
1464
1479
  }
1465
- function De(t, e) {
1480
+ function Ae(t, e) {
1466
1481
  if (t === e) return 0;
1467
1482
  if (t === 0) return 1;
1468
1483
  const n = Math.abs(e - t), r = Math.max(Math.abs(t), Math.abs(e));
@@ -1470,42 +1485,42 @@ function De(t, e) {
1470
1485
  }
1471
1486
  function bt(t, e) {
1472
1487
  if (t === e) return 0;
1473
- const n = Oe.diff(t, e) || [];
1488
+ const n = Ce.diff(t, e) || [];
1474
1489
  if (n.length === 0) return 0;
1475
- const r = ke(t), o = ke(e), u = Math.max(r, o);
1476
- if (u === 0) return 0;
1477
- let p = 0;
1478
- for (const c of n)
1479
- switch (c.kind) {
1490
+ const r = Ee(t), o = Ee(e), d = Math.max(r, o);
1491
+ if (d === 0) return 0;
1492
+ let f = 0;
1493
+ for (const l of n)
1494
+ switch (l.kind) {
1480
1495
  case "N":
1481
- p += 1;
1496
+ f += 1;
1482
1497
  break;
1483
1498
  case "D":
1484
- p += 1;
1499
+ f += 1;
1485
1500
  break;
1486
1501
  case "E":
1487
- if (typeof c.lhs == "string" && typeof c.rhs == "string") {
1488
- const f = Ae(
1489
- c.lhs,
1490
- c.rhs
1502
+ if (typeof l.lhs == "string" && typeof l.rhs == "string") {
1503
+ const c = Re(
1504
+ l.lhs,
1505
+ l.rhs
1491
1506
  );
1492
- p += f;
1493
- } else if (typeof c.lhs == "number" && typeof c.rhs == "number") {
1494
- const f = De(
1495
- c.lhs,
1496
- c.rhs
1507
+ f += c;
1508
+ } else if (typeof l.lhs == "number" && typeof l.rhs == "number") {
1509
+ const c = Ae(
1510
+ l.lhs,
1511
+ l.rhs
1497
1512
  );
1498
- p += f;
1513
+ f += c;
1499
1514
  } else
1500
- p += 1;
1515
+ f += 1;
1501
1516
  break;
1502
1517
  case "A":
1503
- p += 0.5;
1518
+ f += 0.5;
1504
1519
  break;
1505
1520
  }
1506
- return Math.min(p / u, 1);
1521
+ return Math.min(f / d, 1);
1507
1522
  }
1508
- function ke(t) {
1523
+ function Ee(t) {
1509
1524
  if (t == null) return 0;
1510
1525
  if (typeof t != "object") return 1;
1511
1526
  if (Array.isArray(t)) return t.length;
@@ -1514,7 +1529,7 @@ function ke(t) {
1514
1529
  Object.prototype.hasOwnProperty.call(t, n) && (e += 1);
1515
1530
  return e;
1516
1531
  }
1517
- function Pe(t) {
1532
+ function xe(t) {
1518
1533
  try {
1519
1534
  return JSON.stringify(
1520
1535
  t,
@@ -1526,100 +1541,98 @@ function Pe(t) {
1526
1541
  }
1527
1542
  }
1528
1543
  function vt(t, e, n) {
1529
- const r = Te(), o = n?.onFeedback || r, u = n?.debounceMs ?? 3e3, p = n?.diffType ?? "git", c = n?.compareWith, f = n?.default_trigger_name ?? "auto_state_change", y = n?.ignoreInitialNullish ?? !0, m = Y(t), O = Y(!0), w = Y(t), k = Y(t == null), h = Y(
1544
+ const r = Te(), o = n?.onFeedback || r, d = n?.debounceMs ?? 3e3, f = n?.diffType ?? "git", l = n?.compareWith, c = n?.default_trigger_name ?? "auto_state_change", h = n?.ignoreInitialNullish ?? !0, b = Y(t), P = Y(!0), E = Y(t), x = Y(t == null), p = Y(
1530
1545
  t != null
1531
1546
  // != null catches both null and undefined
1532
- ), g = Y(
1533
- !(y && t == null)
1534
- ), C = Y(null), A = Y(void 0), b = q(
1535
- (E, P, j) => {
1536
- const S = mt(E, P), i = dt(E, P, p);
1537
- let l;
1538
- n?.vote ? typeof n.vote == "function" ? l = n.vote(E, P, S) : l = n.vote : l = S > 0.5 ? "downvote" : "upvote";
1539
- const s = typeof e == "function" ? e(P) : e;
1547
+ ), k = Y(
1548
+ !(h && t == null)
1549
+ ), O = Y(null), A = Y(void 0), m = q(
1550
+ (R, _, N) => {
1551
+ const I = mt(R, _), i = dt(R, _, f), u = typeof n?.score == "function" ? n.score(R, _, I) : n?.score ?? (I > 0.5 ? 0 : 1), s = typeof e == "function" ? e(_) : e;
1540
1552
  o({
1541
1553
  session_id: s,
1542
- vote: l,
1543
- explanation: `State change with diff percentage: ${(S * 100).toFixed(1)}%`,
1544
- correction: i,
1545
- source: "IMPLICIT",
1546
- extra_metadata: n?.metadata,
1547
- trigger_name: j
1554
+ kind: "edit",
1555
+ source: "human",
1556
+ trigger_name: N,
1557
+ score: u,
1558
+ value: i,
1559
+ confidence: I,
1560
+ metadata: n?.metadata
1548
1561
  });
1549
1562
  },
1550
- [n, e, p, o]
1551
- ), R = q(
1552
- (E) => {
1553
- const P = E || f;
1554
- if (C.current && A.current && A.current !== P) {
1555
- clearTimeout(C.current);
1556
- const j = w.current;
1557
- b(
1558
- j,
1563
+ [n, e, f, o]
1564
+ ), T = q(
1565
+ (R) => {
1566
+ const _ = R || c;
1567
+ if (O.current && A.current && A.current !== _) {
1568
+ clearTimeout(O.current);
1569
+ const N = E.current;
1570
+ m(
1571
+ N,
1559
1572
  t,
1560
1573
  A.current
1561
- ), C.current = null;
1574
+ ), O.current = null;
1562
1575
  }
1563
- A.current = P;
1576
+ A.current = _;
1564
1577
  },
1565
- [t, f, b]
1578
+ [t, c, m]
1566
1579
  );
1567
1580
  return ce(() => {
1568
- if (O.current) {
1569
- O.current = !1, m.current = t, (!y || t != null) && (w.current = t, g.current = !0);
1581
+ if (P.current) {
1582
+ P.current = !1, b.current = t, (!h || t != null) && (E.current = t, k.current = !0);
1570
1583
  return;
1571
1584
  }
1572
- const E = m.current;
1573
- if (!(c ? c(E, t) : JSON.stringify(E) === JSON.stringify(t))) {
1574
- const j = y && k.current && // True initial state was nullish
1575
- !h.current && // We haven't had non-nullish state before
1585
+ const R = b.current;
1586
+ if (!(l ? l(R, t) : JSON.stringify(R) === JSON.stringify(t))) {
1587
+ const N = h && x.current && // True initial state was nullish
1588
+ !p.current && // We haven't had non-nullish state before
1576
1589
  t != null;
1577
- if (t != null && (h.current = !0), j) {
1578
- w.current = t, g.current = !0, m.current = t;
1590
+ if (t != null && (p.current = !0), N) {
1591
+ E.current = t, k.current = !0, b.current = t;
1579
1592
  return;
1580
1593
  }
1581
- C.current && clearTimeout(C.current), m.current = t, C.current = setTimeout(() => {
1582
- const S = w.current, i = t;
1583
- g.current && b(
1584
- S,
1594
+ O.current && clearTimeout(O.current), b.current = t, O.current = setTimeout(() => {
1595
+ const I = E.current, i = t;
1596
+ k.current && m(
1597
+ I,
1585
1598
  i,
1586
- A.current || f
1587
- ), C.current = null;
1588
- }, u);
1599
+ A.current || c
1600
+ ), O.current = null;
1601
+ }, d);
1589
1602
  }
1590
1603
  return () => {
1591
- C.current && clearTimeout(C.current);
1604
+ O.current && clearTimeout(O.current);
1592
1605
  };
1593
1606
  }, [
1594
1607
  t,
1595
1608
  e,
1596
1609
  n,
1597
1610
  o,
1598
- p,
1599
- u,
1600
- c,
1601
1611
  f,
1602
- y,
1603
- b
1612
+ d,
1613
+ l,
1614
+ c,
1615
+ h,
1616
+ m
1604
1617
  ]), {
1605
- notifyChange: R
1618
+ notifyChange: T
1606
1619
  };
1607
1620
  }
1608
- function kt(t, e, n) {
1609
- const [r, o] = G(t), { notifyChange: u } = vt(r, e, n), p = q(
1610
- (c, f) => {
1611
- u(f), o((y) => typeof c == "function" ? c(y) : c);
1621
+ function Et(t, e, n) {
1622
+ const [r, o] = X(t), { notifyChange: d } = vt(r, e, n), f = q(
1623
+ (l, c) => {
1624
+ d(c), o((h) => typeof l == "function" ? l(h) : l);
1612
1625
  },
1613
- [u]
1626
+ [d]
1614
1627
  );
1615
- return [r, p];
1628
+ return [r, f];
1616
1629
  }
1617
1630
  export {
1618
1631
  ae as KeletContext,
1619
1632
  wt as KeletProvider,
1620
- Et as VoteFeedback,
1633
+ kt as VoteFeedback,
1621
1634
  Te as useDefaultFeedbackHandler,
1622
- kt as useFeedbackState,
1635
+ Et as useFeedbackState,
1623
1636
  gt as useKelet
1624
1637
  };
1625
1638
  //# sourceMappingURL=feedback-ui.es.min.js.map