@capytale/iframe-react 1.1.17 → 1.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
- import { jsx as Q, jsxs as ft, Fragment as pt } from "react/jsx-runtime";
2
- import L, { useCallback as h, useEffect as w, useMemo as U } from "react";
3
- const et = Symbol("Comlink.proxy"), mt = Symbol("Comlink.endpoint"), yt = Symbol("Comlink.releaseProxy"), q = Symbol("Comlink.finalizer"), I = Symbol("Comlink.thrown"), nt = (t) => typeof t == "object" && t !== null || typeof t == "function", vt = {
1
+ import { jsx as Q, jsxs as ft, Fragment as mt } from "react/jsx-runtime";
2
+ import L, { useCallback as A, useEffect as w, useMemo as U } from "react";
3
+ const et = Symbol("Comlink.proxy"), pt = Symbol("Comlink.endpoint"), yt = Symbol("Comlink.releaseProxy"), q = Symbol("Comlink.finalizer"), I = Symbol("Comlink.thrown"), nt = (t) => typeof t == "object" && t !== null || typeof t == "function", vt = {
4
4
  canHandle: (t) => nt(t) && t[et],
5
5
  serialize(t) {
6
6
  const { port1: e, port2: n } = new MessageChannel();
@@ -43,30 +43,30 @@ function _(t, e = globalThis, n = ["*"]) {
43
43
  console.warn(`Invalid origin '${o.origin}' for comlink proxy`);
44
44
  return;
45
45
  }
46
- const { id: s, type: f, path: c } = Object.assign({ path: [] }, o.data), g = (o.data.argumentList || []).map(x);
46
+ const { id: s, type: f, path: l } = Object.assign({ path: [] }, o.data), g = (o.data.argumentList || []).map(x);
47
47
  let d;
48
48
  try {
49
- const u = c.slice(0, -1).reduce((y, C) => y[C], t), p = c.reduce((y, C) => y[C], t);
49
+ const u = l.slice(0, -1).reduce((y, C) => y[C], t), m = l.reduce((y, C) => y[C], t);
50
50
  switch (f) {
51
51
  case "GET":
52
- d = p;
52
+ d = m;
53
53
  break;
54
54
  case "SET":
55
- u[c.slice(-1)[0]] = x(o.data.value), d = !0;
55
+ u[l.slice(-1)[0]] = x(o.data.value), d = !0;
56
56
  break;
57
57
  case "APPLY":
58
- d = p.apply(u, g);
58
+ d = m.apply(u, g);
59
59
  break;
60
60
  case "CONSTRUCT":
61
61
  {
62
- const y = new p(...g);
63
- d = ct(y);
62
+ const y = new m(...g);
63
+ d = lt(y);
64
64
  }
65
65
  break;
66
66
  case "ENDPOINT":
67
67
  {
68
68
  const { port1: y, port2: C } = new MessageChannel();
69
- _(t, C), d = Rt(y, [y]);
69
+ _(t, C), d = Ft(y, [y]);
70
70
  }
71
71
  break;
72
72
  case "RELEASE":
@@ -79,14 +79,14 @@ function _(t, e = globalThis, n = ["*"]) {
79
79
  d = { value: u, [I]: 0 };
80
80
  }
81
81
  Promise.resolve(d).catch((u) => ({ value: u, [I]: 0 })).then((u) => {
82
- const [p, y] = O(u);
83
- e.postMessage(Object.assign(Object.assign({}, p), { id: s }), y), f === "RELEASE" && (e.removeEventListener("message", r), rt(e), q in t && typeof t[q] == "function" && t[q]());
82
+ const [m, y] = O(u);
83
+ e.postMessage(Object.assign(Object.assign({}, m), { id: s }), y), f === "RELEASE" && (e.removeEventListener("message", r), rt(e), q in t && typeof t[q] == "function" && t[q]());
84
84
  }).catch((u) => {
85
- const [p, y] = O({
85
+ const [m, y] = O({
86
86
  value: new TypeError("Unserializable return value"),
87
87
  [I]: 0
88
88
  });
89
- e.postMessage(Object.assign(Object.assign({}, p), { id: s }), y);
89
+ e.postMessage(Object.assign(Object.assign({}, m), { id: s }), y);
90
90
  });
91
91
  }), e.start && e.start();
92
92
  }
@@ -116,7 +116,7 @@ function G(t) {
116
116
  throw new Error("Proxy has been released and is not useable");
117
117
  }
118
118
  function it(t) {
119
- return M(t, /* @__PURE__ */ new Map(), {
119
+ return T(t, /* @__PURE__ */ new Map(), {
120
120
  type: "RELEASE"
121
121
  }).then(() => {
122
122
  rt(t);
@@ -130,58 +130,58 @@ function bt(t, e) {
130
130
  const n = (j.get(e) || 0) + 1;
131
131
  j.set(e, n), $ && $.register(t, e, t);
132
132
  }
133
- function ht(t) {
133
+ function At(t) {
134
134
  $ && $.unregister(t);
135
135
  }
136
136
  function z(t, e, n = [], r = function() {
137
137
  }) {
138
138
  let o = !1;
139
139
  const s = new Proxy(r, {
140
- get(f, c) {
141
- if (G(o), c === yt)
140
+ get(f, l) {
141
+ if (G(o), l === yt)
142
142
  return () => {
143
- ht(s), it(t), e.clear(), o = !0;
143
+ At(s), it(t), e.clear(), o = !0;
144
144
  };
145
- if (c === "then") {
145
+ if (l === "then") {
146
146
  if (n.length === 0)
147
147
  return { then: () => s };
148
- const g = M(t, e, {
148
+ const g = T(t, e, {
149
149
  type: "GET",
150
150
  path: n.map((d) => d.toString())
151
151
  }).then(x);
152
152
  return g.then.bind(g);
153
153
  }
154
- return z(t, e, [...n, c]);
154
+ return z(t, e, [...n, l]);
155
155
  },
156
- set(f, c, g) {
156
+ set(f, l, g) {
157
157
  G(o);
158
158
  const [d, u] = O(g);
159
- return M(t, e, {
159
+ return T(t, e, {
160
160
  type: "SET",
161
- path: [...n, c].map((p) => p.toString()),
161
+ path: [...n, l].map((m) => m.toString()),
162
162
  value: d
163
163
  }, u).then(x);
164
164
  },
165
- apply(f, c, g) {
165
+ apply(f, l, g) {
166
166
  G(o);
167
167
  const d = n[n.length - 1];
168
- if (d === mt)
169
- return M(t, e, {
168
+ if (d === pt)
169
+ return T(t, e, {
170
170
  type: "ENDPOINT"
171
171
  }).then(x);
172
172
  if (d === "bind")
173
173
  return z(t, e, n.slice(0, -1));
174
- const [u, p] = Y(g);
175
- return M(t, e, {
174
+ const [u, m] = Y(g);
175
+ return T(t, e, {
176
176
  type: "APPLY",
177
177
  path: n.map((y) => y.toString()),
178
178
  argumentList: u
179
- }, p).then(x);
179
+ }, m).then(x);
180
180
  },
181
- construct(f, c) {
181
+ construct(f, l) {
182
182
  G(o);
183
- const [g, d] = Y(c);
184
- return M(t, e, {
183
+ const [g, d] = Y(l);
184
+ return T(t, e, {
185
185
  type: "CONSTRUCT",
186
186
  path: n.map((u) => u.toString()),
187
187
  argumentList: g
@@ -190,21 +190,21 @@ function z(t, e, n = [], r = function() {
190
190
  });
191
191
  return bt(s, t), s;
192
192
  }
193
- function At(t) {
193
+ function ht(t) {
194
194
  return Array.prototype.concat.apply([], t);
195
195
  }
196
196
  function Y(t) {
197
197
  const e = t.map(O);
198
- return [e.map((n) => n[0]), At(e.map((n) => n[1]))];
198
+ return [e.map((n) => n[0]), ht(e.map((n) => n[1]))];
199
199
  }
200
200
  const at = /* @__PURE__ */ new WeakMap();
201
- function Rt(t, e) {
201
+ function Ft(t, e) {
202
202
  return at.set(t, e), t;
203
203
  }
204
- function ct(t) {
204
+ function lt(t) {
205
205
  return Object.assign(t, { [et]: !0 });
206
206
  }
207
- function Et(t, e = globalThis, n = "*") {
207
+ function Rt(t, e = globalThis, n = "*") {
208
208
  return {
209
209
  postMessage: (r, o) => t.postMessage(r, n, o),
210
210
  addEventListener: e.addEventListener.bind(e),
@@ -240,13 +240,13 @@ function x(t) {
240
240
  return t.value;
241
241
  }
242
242
  }
243
- function M(t, e, n, r) {
243
+ function T(t, e, n, r) {
244
244
  return new Promise((o) => {
245
- const s = Ft();
245
+ const s = Et();
246
246
  e.set(s, o), t.start && t.start(), t.postMessage(Object.assign({ id: s }, n), r);
247
247
  });
248
248
  }
249
- function Ft() {
249
+ function Et() {
250
250
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
251
251
  }
252
252
  function xt(t, e) {
@@ -257,9 +257,9 @@ function kt(t, e) {
257
257
  function f(u) {
258
258
  return xt(t, u);
259
259
  }
260
- let c, g = !1;
260
+ let l, g = !1;
261
261
  if (window.parent === window)
262
- console.warn(f("Contract link is not supported in standalone mode")), c = {
262
+ console.warn(f("Contract link is not supported in standalone mode")), l = {
263
263
  ready() {
264
264
  return Promise.resolve();
265
265
  },
@@ -269,37 +269,37 @@ function kt(t, e) {
269
269
  done() {
270
270
  return Promise.resolve();
271
271
  },
272
- provide(u, p, y) {
272
+ provide(u, m, y) {
273
273
  return Promise.resolve();
274
274
  }
275
275
  };
276
276
  else {
277
- const u = Et(window.parent, void 0, e);
277
+ const u = Rt(window.parent, void 0, e);
278
278
  _({
279
- declare(p) {
279
+ declare(m) {
280
280
  if (r == null) throw new Error(f("No handler for declare"));
281
- r(p);
281
+ r(m);
282
282
  },
283
283
  done() {
284
284
  if (o == null) throw new Error(f("No handler for done"));
285
285
  o();
286
286
  },
287
- provide(p, y, C) {
287
+ provide(m, y, C) {
288
288
  if (s == null) throw new Error(f("No handler for provide"));
289
- s(p, y, C);
289
+ s(m, y, C);
290
290
  }
291
- }, u), c = st(u), g = !0;
291
+ }, u), l = st(u), g = !0;
292
292
  }
293
293
  const d = () => {
294
294
  if (!n) {
295
295
  if (r == null || o == null || s == null) return;
296
- n = !0, c.ready();
296
+ n = !0, l.ready();
297
297
  }
298
298
  };
299
299
  return {
300
- declare: (u) => c.declare(u),
301
- done: () => c.done(),
302
- provide: (u, p, y) => c.provide(u, p, ct(y)),
300
+ declare: (u) => l.declare(u),
301
+ done: () => l.done(),
302
+ provide: (u, m, y) => l.provide(u, m, lt(y)),
303
303
  get name() {
304
304
  return t;
305
305
  },
@@ -319,18 +319,18 @@ function kt(t, e) {
319
319
  }
320
320
  function Jt(t) {
321
321
  return function(e) {
322
- let n, r = !1, o = !1, s, f, c = !1, g = !1, d, u, p, y;
322
+ let n, r = !1, o = !1, s, f, l = !1, g = !1, d, u, m, y;
323
323
  function C() {
324
324
  if (s != null && s !== 0 && f != null)
325
325
  return f;
326
326
  }
327
- function E(i) {
328
- if (s != null && f != null && !(i > s))
327
+ function R(a) {
328
+ if (s != null && f != null && !(a > s))
329
329
  return f;
330
330
  }
331
- function A() {
332
- return p ?? (g ? p = Promise.resolve() : p = new Promise((i, l) => {
333
- y = i;
331
+ function h() {
332
+ return m ?? (g ? m = Promise.resolve() : m = new Promise((a, c) => {
333
+ y = a;
334
334
  }));
335
335
  }
336
336
  function k() {
@@ -344,10 +344,10 @@ function Jt(t) {
344
344
  get i() {
345
345
  return C();
346
346
  },
347
- v: (i) => E(i)
347
+ v: (a) => R(a)
348
348
  }), d;
349
349
  }
350
- function T() {
350
+ function M() {
351
351
  return u === void 0 && (u = {
352
352
  get name() {
353
353
  return e;
@@ -358,16 +358,16 @@ function Jt(t) {
358
358
  get i() {
359
359
  return g ? C() : void 0;
360
360
  },
361
- v: (i) => g ? E(i) : void 0,
361
+ v: (a) => g ? R(a) : void 0,
362
362
  get promise() {
363
- return s === 0 ? Promise.reject(t("Remote interface not provided")) : A().then(() => {
363
+ return s === 0 ? Promise.reject(t("Remote interface not provided")) : h().then(() => {
364
364
  if (s === 0) throw new Error(t("Remote interface not provided"));
365
365
  return k();
366
366
  });
367
367
  }
368
368
  }), u;
369
369
  }
370
- function F() {
370
+ function E() {
371
371
  y != null && (y(), y = void 0);
372
372
  }
373
373
  return {
@@ -378,84 +378,84 @@ function Jt(t) {
378
378
  if (n != null)
379
379
  return n;
380
380
  },
381
- set localVersion(i) {
382
- if (n != null && n !== i) throw new Error(t("A different local version is already set"));
383
- n = i;
381
+ set localVersion(a) {
382
+ if (n != null && n !== a) throw new Error(t("A different local version is already set"));
383
+ n = a;
384
384
  },
385
385
  get localVersionSent() {
386
386
  return r;
387
387
  },
388
- set localVersionSent(i) {
389
- if (!i && r) throw new Error(t("Local version already notified"));
390
- r = i, i && n === 0 && (o = !0);
388
+ set localVersionSent(a) {
389
+ if (!a && r) throw new Error(t("Local version already notified"));
390
+ r = a, a && n === 0 && (o = !0);
391
391
  },
392
392
  get localInterfaceSent() {
393
393
  return o;
394
394
  },
395
- set localInterfaceSent(i) {
395
+ set localInterfaceSent(a) {
396
396
  if (n == null) throw new Error(t("Local version not set"));
397
- if (!i && o) throw new Error(t("Local interface already sent."));
398
- o = i;
397
+ if (!a && o) throw new Error(t("Local interface already sent."));
398
+ o = a;
399
399
  },
400
400
  get remoteVersion() {
401
401
  if (s != null)
402
402
  return s;
403
403
  },
404
- set remoteVersion(i) {
405
- if (s != null && s !== i) throw new Error(t("A different remote version is already set for " + e + `(${s} -> ${i})`));
406
- s = i, i === 0 && (c = !0);
404
+ set remoteVersion(a) {
405
+ if (s != null && s !== a) throw new Error(t("A different remote version is already set for " + e + `(${s} -> ${a})`));
406
+ s = a, a === 0 && (l = !0);
407
407
  },
408
408
  get remoteVersionReceived() {
409
409
  return s != null;
410
410
  },
411
- setRemoteInterface: (i) => {
411
+ setRemoteInterface: (a) => {
412
412
  if (s == null) throw new Error(t("Remote version not set"));
413
413
  if (s === 0) {
414
414
  console.warn(t("Remote version is 0, remote interface is ignored."));
415
415
  return;
416
416
  }
417
- if (c) throw new Error(t("Interface already provided."));
418
- f = i, c = !0;
417
+ if (l) throw new Error(t("Interface already provided."));
418
+ f = a, l = !0;
419
419
  },
420
420
  get remoteInterfaceReceived() {
421
- return c;
421
+ return l;
422
422
  },
423
423
  depGroup: void 0,
424
424
  get isActivable() {
425
- return c && o;
425
+ return l && o;
426
426
  },
427
427
  get isActivated() {
428
428
  return g;
429
429
  },
430
430
  activate() {
431
431
  if (!g) {
432
- if (!c) throw new Error(t("Remote interface not provided."));
432
+ if (!l) throw new Error(t("Remote interface not provided."));
433
433
  if (!o) throw new Error(t("Local interface not sent"));
434
- g = !0, F();
434
+ g = !0, E();
435
435
  }
436
436
  },
437
437
  getRemote: () => k(),
438
- getLazyRemote: () => T(),
438
+ getLazyRemote: () => M(),
439
439
  get activationPromise() {
440
- return A();
440
+ return h();
441
441
  }
442
442
  };
443
443
  };
444
444
  }
445
- function Mt(t) {
445
+ function Tt(t) {
446
446
  return function(e, n, r, o) {
447
- let s = r, f = !1, c = !1;
447
+ let s = r, f = !1, l = !1;
448
448
  function g() {
449
449
  return e.every((d) => d.remoteVersionReceived && d.localVersionSent) && n.every((d) => d.remoteVersionReceived);
450
450
  }
451
451
  return {
452
452
  get isDeclared() {
453
- return c;
453
+ return l;
454
454
  },
455
455
  set isDeclared(d) {
456
- if (!d && c)
456
+ if (!d && l)
457
457
  throw new Error(t("Factory already declared"));
458
- c = d;
458
+ l = d;
459
459
  },
460
460
  get isReady() {
461
461
  return g();
@@ -477,9 +477,9 @@ function Mt(t) {
477
477
  let d;
478
478
  o ? d = e.map((y) => y.getRemote()) : d = e[0].getRemote();
479
479
  let u;
480
- const p = n.length > 0 ? n.map((y) => y.getRemote()) : null;
480
+ const m = n.length > 0 ? n.map((y) => y.getRemote()) : null;
481
481
  try {
482
- u = p == null ? s(d) : s(d, p);
482
+ u = m == null ? s(d) : s(d, m);
483
483
  } catch (y) {
484
484
  throw new Error(t("error in factory:"), { cause: y });
485
485
  }
@@ -490,15 +490,15 @@ function Mt(t) {
490
490
  };
491
491
  };
492
492
  }
493
- function Tt(t) {
493
+ function Mt(t) {
494
494
  return function(e, n, r, o) {
495
495
  let s = n, f = !1;
496
- function c() {
496
+ function l() {
497
497
  return e.every((g) => g.isActivated);
498
498
  }
499
499
  return {
500
500
  get isReady() {
501
- return c();
501
+ return l();
502
502
  },
503
503
  get isDone() {
504
504
  return f;
@@ -507,7 +507,7 @@ function Tt(t) {
507
507
  return e;
508
508
  },
509
509
  invoke() {
510
- if (f || !c()) {
510
+ if (f || !l()) {
511
511
  const u = new Error(t(f ? "callback already invoked" : "callback parameters are not ready"));
512
512
  throw o?.[1](u), u;
513
513
  }
@@ -525,141 +525,141 @@ function Tt(t) {
525
525
  };
526
526
  };
527
527
  }
528
- function lt(t, e) {
528
+ function ct(t, e) {
529
529
  return t == null || t.length === 0 ? e : `[${t}] ${e}`;
530
530
  }
531
531
  function Lt(t) {
532
- function e(i) {
533
- return lt(t.name, i);
532
+ function e(a) {
533
+ return ct(t.name, a);
534
534
  }
535
- const n = Tt(e), r = Jt(e), o = Mt(e), s = {}, f = [];
536
- let c = [], g;
535
+ const n = Mt(e), r = Jt(e), o = Tt(e), s = {}, f = [];
536
+ let l = [], g;
537
537
  const d = () => (g == null ? g = 0 : g++, g);
538
- function u(i) {
539
- let l = s[i];
540
- return l == null && (l = r(i), l.localVersion == null && (A && (l.localVersion = 0), k && (l.localVersionSent = !0)), l.remoteVersion == null && T && (l.remoteVersion = 0), s[i] = l), l;
538
+ function u(a) {
539
+ let c = s[a];
540
+ return c == null && (c = r(a), c.localVersion == null && (h && (c.localVersion = 0), k && (c.localVersionSent = !0)), c.remoteVersion == null && M && (c.remoteVersion = 0), s[a] = c), c;
541
541
  }
542
- function p(i) {
543
- return i.map(u);
542
+ function m(a) {
543
+ return a.map(u);
544
544
  }
545
- function y(...i) {
546
- const l = d(), m = Array(l).fill(!1);
547
- i.forEach((v) => {
545
+ function y(...a) {
546
+ const c = d(), p = Array(c).fill(!1);
547
+ a.forEach((v) => {
548
548
  v.forEach((S) => {
549
- S.depGroup != null && (m[S.depGroup] = !0), S.depGroup = l;
549
+ S.depGroup != null && (p[S.depGroup] = !0), S.depGroup = c;
550
550
  });
551
551
  }), Object.values(s).forEach((v) => {
552
- v.depGroup != null && v.depGroup !== l && m[v.depGroup] && (v.depGroup = l);
552
+ v.depGroup != null && v.depGroup !== c && p[v.depGroup] && (v.depGroup = c);
553
553
  });
554
554
  }
555
- t.onDeclare = (i) => {
556
- const l = p(i.map((m) => m.name));
557
- for (let m = 0; m < i.length; m++)
558
- i[m].version != null && (l[m].remoteVersion = i[m].version);
559
- y(l), F();
555
+ t.onDeclare = (a) => {
556
+ const c = m(a.map((p) => p.name));
557
+ for (let p = 0; p < a.length; p++)
558
+ a[p].version != null && (c[p].remoteVersion = a[p].version);
559
+ y(c), E();
560
560
  }, t.onDone = () => {
561
- T || (T = !0, Object.values(s).forEach((i) => {
562
- i.remoteVersion == null && (i.remoteVersion = 0);
563
- }), F());
564
- }, t.onProvide = (i, l, m) => {
565
- let v = s[i];
561
+ M || (M = !0, Object.values(s).forEach((a) => {
562
+ a.remoteVersion == null && (a.remoteVersion = 0);
563
+ }), E());
564
+ }, t.onProvide = (a, c, p) => {
565
+ let v = s[a];
566
566
  if (v == null)
567
- throw new Error(e(`Contract not declared : ${i}`));
568
- if (v.remoteVersion != l)
569
- throw new Error(e(`Remote declared version ${v.remoteVersion} of contract "${i}" but provided version ${l}.`));
567
+ throw new Error(e(`Contract not declared : ${a}`));
568
+ if (v.remoteVersion != c)
569
+ throw new Error(e(`Remote declared version ${v.remoteVersion} of contract "${a}" but provided version ${c}.`));
570
570
  if (v.remoteInterfaceReceived)
571
- throw new Error(e(`Remote contract "${i}" is already provided.`));
572
- v.setRemoteInterface(m), F();
571
+ throw new Error(e(`Remote contract "${a}" is already provided.`));
572
+ v.setRemoteInterface(p), E();
573
573
  };
574
- let C = !1, E = !1, A = !1, k = !1, T = !1;
575
- async function F() {
576
- if (E = !0, !C) {
577
- for (C = !0; E; ) {
578
- if (E = !1, t.isReady) {
579
- const i = f.filter((l) => !l.isDeclared);
580
- if (i.length > 0)
581
- for (const l of i) {
582
- const m = Array(l.args.length + l.deps.length);
583
- l.args.forEach((v, S) => m[S] = v), l.deps.forEach((v, S) => m[S + l.args.length] = v), await t.declare(m.map((v) => ({ name: v.name, version: v.localVersion }))), m.forEach((v) => {
574
+ let C = !1, R = !1, h = !1, k = !1, M = !1;
575
+ async function E() {
576
+ if (R = !0, !C) {
577
+ for (C = !0; R; ) {
578
+ if (R = !1, t.isReady) {
579
+ const a = f.filter((c) => !c.isDeclared);
580
+ if (a.length > 0)
581
+ for (const c of a) {
582
+ const p = Array(c.args.length + c.deps.length);
583
+ c.args.forEach((v, S) => p[S] = v), c.deps.forEach((v, S) => p[S + c.args.length] = v), await t.declare(p.map((v) => ({ name: v.name, version: v.localVersion }))), p.forEach((v) => {
584
584
  v.localVersion != null && (v.localVersionSent = !0);
585
- }), l.isDeclared = !0;
585
+ }), c.isDeclared = !0;
586
586
  }
587
587
  }
588
- if (t.isReady && A && f.every((i) => i.isDeclared)) {
589
- const i = Object.values(s).filter((l) => !l.localVersionSent && l.localVersion != null);
590
- if (i.length > 0)
591
- for (const l of i)
592
- await t.declare([{ name: l.name, version: l.localVersion }]), l.localVersionSent = !0;
588
+ if (t.isReady && h && f.every((a) => a.isDeclared)) {
589
+ const a = Object.values(s).filter((c) => !c.localVersionSent && c.localVersion != null);
590
+ if (a.length > 0)
591
+ for (const c of a)
592
+ await t.declare([{ name: c.name, version: c.localVersion }]), c.localVersionSent = !0;
593
593
  k || (k = !0, await t.done());
594
594
  }
595
595
  if (t.isReady) {
596
- const i = f.filter((l) => !l.isDone && l.isReady);
597
- if (i.length > 0)
598
- for (const l of i) {
599
- const m = l.invoke();
600
- for (let v = 0; v < l.args.length; v++) {
601
- const S = l.args[v];
602
- await t.provide(S.name, S.localVersion, m[v]), S.localInterfaceSent = !0;
596
+ const a = f.filter((c) => !c.isDone && c.isReady);
597
+ if (a.length > 0)
598
+ for (const c of a) {
599
+ const p = c.invoke();
600
+ for (let v = 0; v < c.args.length; v++) {
601
+ const S = c.args[v];
602
+ await t.provide(S.name, S.localVersion, p[v]), S.localInterfaceSent = !0;
603
603
  }
604
604
  }
605
605
  }
606
606
  if (g != null) {
607
- const i = Array(g + 1).fill(null);
608
- for (const l in s) {
609
- const m = s[l];
610
- m.depGroup != null && (m.isActivable ? i[m.depGroup] == null && !m.isActivated && (i[m.depGroup] = !0) : i[m.depGroup] = !1);
607
+ const a = Array(g + 1).fill(null);
608
+ for (const c in s) {
609
+ const p = s[c];
610
+ p.depGroup != null && (p.isActivable ? a[p.depGroup] == null && !p.isActivated && (a[p.depGroup] = !0) : a[p.depGroup] = !1);
611
611
  }
612
- if (i.some((l) => l === !0))
613
- for (const l in s) {
614
- const m = s[l];
615
- m.depGroup != null && i[m.depGroup] && m.activate();
612
+ if (a.some((c) => c === !0))
613
+ for (const c in s) {
614
+ const p = s[c];
615
+ p.depGroup != null && a[p.depGroup] && p.activate();
616
616
  }
617
617
  }
618
618
  if (t.isReady) {
619
- const i = c;
620
- c = [];
621
- const l = [];
622
- for (const m of i)
623
- !m.isDone && m.isReady ? m.invoke() : l.push(m);
624
- l.push(...c), c = l;
619
+ const a = l;
620
+ l = [];
621
+ const c = [];
622
+ for (const p of a)
623
+ !p.isDone && p.isReady ? p.invoke() : c.push(p);
624
+ c.push(...l), l = c;
625
625
  }
626
626
  }
627
627
  C = !1;
628
628
  }
629
629
  }
630
630
  return {
631
- get(i) {
632
- return u(i);
631
+ get(a) {
632
+ return u(a);
633
633
  },
634
- declareFactory: (i, l, m, v) => {
635
- if (A) throw new Error(e("Cannot declare a factory after done has been set to true."));
636
- const S = p(i.map((R) => R.name));
634
+ declareFactory: (a, c, p, v) => {
635
+ if (h) throw new Error(e("Cannot declare a factory after done has been set to true."));
636
+ const S = m(a.map((F) => F.name));
637
637
  {
638
- const R = S.filter((N) => N.localVersion != null);
639
- if (R.length > 0)
640
- throw new Error(e("Cannot declare a factory for already implemented contracts : " + R.map((N) => N.name).join(", ")));
638
+ const F = S.filter((N) => N.localVersion != null);
639
+ if (F.length > 0)
640
+ throw new Error(e("Cannot declare a factory for already implemented contracts : " + F.map((N) => N.name).join(", ")));
641
641
  }
642
- for (let R = 0; R < i.length; R++)
643
- S[R].localVersion = i[R].version;
644
- const J = p(l);
642
+ for (let F = 0; F < a.length; F++)
643
+ S[F].localVersion = a[F].version;
644
+ const J = m(c);
645
645
  y(S, J);
646
- const gt = o(S, J, m, v);
647
- f.push(gt), F();
646
+ const gt = o(S, J, p, v);
647
+ f.push(gt), E();
648
648
  },
649
- declareCallback(i, l, m, v) {
650
- const S = p(i), J = n(S, l, m, v);
651
- !C && c.length === 0 && J.isReady ? J.invoke() : (c.push(J), F());
649
+ declareCallback(a, c, p, v) {
650
+ const S = m(a), J = n(S, c, p, v);
651
+ !C && l.length === 0 && J.isReady ? J.invoke() : (l.push(J), E());
652
652
  },
653
653
  get done() {
654
- return A;
654
+ return h;
655
655
  },
656
- set done(i) {
657
- if (A) {
658
- if (!i) throw new Error(e("Cannot set done to false after it has been set to true."));
656
+ set done(a) {
657
+ if (h) {
658
+ if (!a) throw new Error(e("Cannot set done to false after it has been set to true."));
659
659
  } else
660
- i && (A = !0, Object.values(s).forEach((l) => {
661
- l.localVersion == null && (l.localVersion = 0);
662
- }), F());
660
+ a && (h = !0, Object.values(s).forEach((c) => {
661
+ c.localVersion == null && (c.localVersion = 0);
662
+ }), E());
663
663
  }
664
664
  };
665
665
  }
@@ -673,7 +673,7 @@ function Pt(t) {
673
673
  function Vt(t) {
674
674
  const e = Lt(t);
675
675
  function n(r) {
676
- return lt(t.name, r);
676
+ return ct(t.name, r);
677
677
  }
678
678
  return {
679
679
  plug(r, o, s = void 0) {
@@ -681,13 +681,13 @@ function Vt(t) {
681
681
  s == null && (s = o, o = []);
682
682
  let f = !0;
683
683
  Array.isArray(r) || (r = [r], f = !1);
684
- const c = r.map((g) => {
684
+ const l = r.map((g) => {
685
685
  const d = Pt(g);
686
686
  if (d == null)
687
687
  throw new Error(n("Invalid contract id : " + g));
688
688
  return d;
689
689
  });
690
- e.declareFactory(c, o, s, f);
690
+ e.declareFactory(l, o, s, f);
691
691
  },
692
692
  plugsDone() {
693
693
  e.done = !0;
@@ -716,13 +716,13 @@ console.log(`[${ut}@1.0.12] loaded`);
716
716
  const K = (t) => {
717
717
  let e;
718
718
  const n = /* @__PURE__ */ new Set(), r = (d, u) => {
719
- const p = typeof d == "function" ? d(e) : d;
720
- if (!Object.is(p, e)) {
719
+ const m = typeof d == "function" ? d(e) : d;
720
+ if (!Object.is(m, e)) {
721
721
  const y = e;
722
- e = u ?? (typeof p != "object" || p === null) ? p : Object.assign({}, e, p), n.forEach((C) => C(e, y));
722
+ e = u ?? (typeof m != "object" || m === null) ? m : Object.assign({}, e, m), n.forEach((C) => C(e, y));
723
723
  }
724
- }, o = () => e, c = { setState: r, getState: o, getInitialState: () => g, subscribe: (d) => (n.add(d), () => n.delete(d)) }, g = e = t(r, o, c);
725
- return c;
724
+ }, o = () => e, l = { setState: r, getState: o, getInitialState: () => g, subscribe: (d) => (n.add(d), () => n.delete(d)) }, g = e = t(r, o, l);
725
+ return l;
726
726
  }, It = (t) => t ? K(t) : K, jt = (t) => t;
727
727
  function $t(t, e = jt) {
728
728
  const n = L.useSyncExternalStore(
@@ -737,22 +737,22 @@ const X = (t) => {
737
737
  return Object.assign(n, e), n;
738
738
  }, dt = (t) => t ? X(t) : X, Ot = (t) => (e, n, r) => {
739
739
  const o = r.subscribe;
740
- return r.subscribe = (f, c, g) => {
740
+ return r.subscribe = (f, l, g) => {
741
741
  let d = f;
742
- if (c) {
742
+ if (l) {
743
743
  const u = g?.equalityFn || Object.is;
744
- let p = f(r.getState());
744
+ let m = f(r.getState());
745
745
  d = (y) => {
746
746
  const C = f(y);
747
- if (!u(p, C)) {
748
- const E = p;
749
- c(p = C, E);
747
+ if (!u(m, C)) {
748
+ const R = m;
749
+ l(m = C, R);
750
750
  }
751
- }, g?.fireImmediately && c(p, p);
751
+ }, g?.fireImmediately && l(m, m);
752
752
  }
753
753
  return o(d);
754
754
  }, t(e, n, r);
755
- }, Nt = Ot, a = dt()(
755
+ }, Nt = Ot, i = dt()(
756
756
  Nt((t) => ({
757
757
  ready: !1,
758
758
  workflow: "current",
@@ -775,16 +775,32 @@ const X = (t) => {
775
775
  throw console.error("[React bindings] getJsonContentFunction is not set"), new Error("[React bindings] getJsonContentFunction is not set");
776
776
  },
777
777
  getJsonActivityContentFunction: () => {
778
- throw console.error("[React bindings] getJsonActivityContentFunction is not set"), new Error("[React bindings] getJsonActivityContentFunction is not set");
778
+ throw console.error(
779
+ "[React bindings] getJsonActivityContentFunction is not set"
780
+ ), new Error(
781
+ "[React bindings] getJsonActivityContentFunction is not set"
782
+ );
779
783
  },
780
784
  getJsonAssignmentContentFunction: () => {
781
- throw console.error("[React bindings] getJsonAssignmentContentFunction is not set"), new Error("[React bindings] getJsonAssignmentContentFunction is not set");
785
+ throw console.error(
786
+ "[React bindings] getJsonAssignmentContentFunction is not set"
787
+ ), new Error(
788
+ "[React bindings] getJsonAssignmentContentFunction is not set"
789
+ );
782
790
  },
783
791
  getJsonActivitySplitContentFunction: () => {
784
- throw console.error("[React bindings] getJsonActivitySplitContentFunction is not set"), new Error("[React bindings] getJsonActivitySplitContentFunction is not set");
792
+ throw console.error(
793
+ "[React bindings] getJsonActivitySplitContentFunction is not set"
794
+ ), new Error(
795
+ "[React bindings] getJsonActivitySplitContentFunction is not set"
796
+ );
785
797
  },
786
798
  getJsonAssignmentSplitContentFunction: () => {
787
- throw console.error("[React bindings] getJsonAssignmentSplitContentFunction is not set"), new Error("[React bindings] getJsonAssignmentSplitContentFunction is not set");
799
+ throw console.error(
800
+ "[React bindings] getJsonAssignmentSplitContentFunction is not set"
801
+ ), new Error(
802
+ "[React bindings] getJsonAssignmentSplitContentFunction is not set"
803
+ );
788
804
  },
789
805
  sidebarActions: {},
790
806
  quickActions: {},
@@ -797,6 +813,14 @@ const X = (t) => {
797
813
  setLlmGetAllMessagesContextFunction: (e) => {
798
814
  t({ llmGetAllMessagesContextFunction: e });
799
815
  },
816
+ llmGetAvailableToolsFunction: null,
817
+ setLlmGetAvailableToolsFunction: (e) => {
818
+ t({ llmGetAvailableToolsFunction: e });
819
+ },
820
+ llmCallToolFunction: null,
821
+ setLlmCallToolFunction: (e) => {
822
+ t({ llmCallToolFunction: e });
823
+ },
800
824
  setGetTextContentFunction: (e) => {
801
825
  t({ getTextContentFunction: e });
802
826
  },
@@ -850,7 +874,7 @@ const qt = [
850
874
  ], tt = {
851
875
  "mode:1": {
852
876
  setMode: (t) => {
853
- a.setState({ mode: t });
877
+ i.setState({ mode: t });
854
878
  }
855
879
  },
856
880
  "reload:1": {
@@ -861,68 +885,70 @@ const qt = [
861
885
  "theme:1": {
862
886
  setTheme: (t) => {
863
887
  if (t === null) {
864
- a.setState({ theme: null });
888
+ i.setState({ theme: null });
865
889
  return;
866
890
  }
867
891
  if (t !== "light" && t !== "dark") {
868
- console.warn(`[React bindings] Invalid theme: ${t}. Expected 'light' or 'dark'.`), a.setState({ theme: null });
892
+ console.warn(
893
+ `[React bindings] Invalid theme: ${t}. Expected 'light' or 'dark'.`
894
+ ), i.setState({ theme: null });
869
895
  return;
870
896
  }
871
- a.setState({ theme: t });
897
+ i.setState({ theme: t });
872
898
  }
873
899
  },
874
900
  "workflow:1": {
875
901
  setWorkflow: (t) => {
876
- a.setState({ workflow: t });
902
+ i.setState({ workflow: t });
877
903
  }
878
904
  },
879
905
  "trigger-save:1": {
880
906
  setCanSave(t) {
881
- a.setState({ canSave: t });
907
+ i.setState({ canSave: t });
882
908
  }
883
909
  },
884
910
  "simple-content(text):1": {
885
911
  contentSaved: () => {
886
- a.setState((t) => ({
912
+ i.setState((t) => ({
887
913
  afterSaveCount: t.afterSaveCount + 1
888
914
  }));
889
915
  },
890
- getContent: () => a.getState().getTextContentFunction(),
916
+ getContent: () => i.getState().getTextContentFunction(),
891
917
  loadContent: (t) => {
892
- a.setState({ loadedTextContent: t });
918
+ i.setState({ loadedTextContent: t });
893
919
  }
894
920
  },
895
921
  "simple-content(json):1": {
896
922
  contentSaved: () => {
897
- a.setState((t) => ({
923
+ i.setState((t) => ({
898
924
  afterSaveCount: t.afterSaveCount + 1
899
925
  }));
900
926
  },
901
- getContent: () => a.getState().getJsonContentFunction(),
927
+ getContent: () => i.getState().getJsonContentFunction(),
902
928
  loadContent: (t) => {
903
- a.setState({ loadedJsonContent: t });
929
+ i.setState({ loadedJsonContent: t });
904
930
  }
905
931
  },
906
932
  "simple-binary-data(text):1": {
907
933
  contentSaved: () => {
908
- a.setState((t) => ({
934
+ i.setState((t) => ({
909
935
  afterSaveCount: t.afterSaveCount + 1
910
936
  }));
911
937
  },
912
- getContent: () => a.getState().getTextContentFunction(),
938
+ getContent: () => i.getState().getTextContentFunction(),
913
939
  loadContent: (t) => {
914
- a.setState({ loadedTextContent: t });
940
+ i.setState({ loadedTextContent: t });
915
941
  }
916
942
  },
917
943
  "simple-content-eval(text):1": {
918
944
  contentSaved: () => {
919
- a.setState((t) => ({
945
+ i.setState((t) => ({
920
946
  afterSaveCount: t.afterSaveCount + 1
921
947
  }));
922
948
  },
923
- getContent: () => a.getState().getTextContentFunction(),
949
+ getContent: () => i.getState().getTextContentFunction(),
924
950
  loadContent: (t) => {
925
- a.setState({ loadedTextContent: t });
951
+ i.setState({ loadedTextContent: t });
926
952
  },
927
953
  getAssignmentContent: () => {
928
954
  throw new Error(
@@ -932,13 +958,13 @@ const qt = [
932
958
  },
933
959
  "simple-content-eval(json):1": {
934
960
  contentSaved: () => {
935
- a.setState((t) => ({
961
+ i.setState((t) => ({
936
962
  afterSaveCount: t.afterSaveCount + 1
937
963
  }));
938
964
  },
939
- getContent: () => a.getState().getJsonContentFunction(),
965
+ getContent: () => i.getState().getJsonContentFunction(),
940
966
  loadContent: (t) => {
941
- a.setState({ loadedJsonContent: t });
967
+ i.setState({ loadedJsonContent: t });
942
968
  },
943
969
  getAssignmentContent: () => {
944
970
  throw new Error(
@@ -948,13 +974,13 @@ const qt = [
948
974
  },
949
975
  "simple-content-eval(json):2": {
950
976
  contentSaved: () => {
951
- a.setState((t) => ({
977
+ i.setState((t) => ({
952
978
  afterSaveCount: t.afterSaveCount + 1
953
979
  }));
954
980
  },
955
- getContent: () => a.getState().getJsonContentFunction(),
981
+ getContent: () => i.getState().getJsonContentFunction(),
956
982
  loadContent: (t) => {
957
- a.setState({ loadedJsonContent: t });
983
+ i.setState({ loadedJsonContent: t });
958
984
  },
959
985
  getAssignmentContent: () => {
960
986
  throw new Error(
@@ -964,13 +990,13 @@ const qt = [
964
990
  },
965
991
  "simple-content-eval(text):2": {
966
992
  contentSaved: () => {
967
- a.setState((t) => ({
993
+ i.setState((t) => ({
968
994
  afterSaveCount: t.afterSaveCount + 1
969
995
  }));
970
996
  },
971
- getContent: () => a.getState().getTextContentFunction(),
997
+ getContent: () => i.getState().getTextContentFunction(),
972
998
  loadContent: (t) => {
973
- a.setState({ loadedTextContent: t });
999
+ i.setState({ loadedTextContent: t });
974
1000
  },
975
1001
  getAssignmentContent: () => {
976
1002
  throw new Error(
@@ -980,22 +1006,22 @@ const qt = [
980
1006
  },
981
1007
  "separate-contents(json):1": {
982
1008
  contentSaved: () => {
983
- a.setState((t) => ({
1009
+ i.setState((t) => ({
984
1010
  afterSaveCount: t.afterSaveCount + 1
985
1011
  }));
986
1012
  },
987
1013
  loadContent: (t, e) => {
988
- a.setState({
1014
+ i.setState({
989
1015
  loadedJsonActivityContent: t,
990
1016
  loadedJsonAssignmentContent: e
991
1017
  });
992
1018
  },
993
- getActivityContent: () => a.getState().getJsonActivityContentFunction(),
994
- getAssignmentContent: () => a.getState().getJsonAssignmentContentFunction()
1019
+ getActivityContent: () => i.getState().getJsonActivityContentFunction(),
1020
+ getAssignmentContent: () => i.getState().getJsonAssignmentContentFunction()
995
1021
  },
996
1022
  "separate-dual-contents(json):1": {
997
1023
  contentSaved: () => {
998
- a.setState((t) => ({
1024
+ i.setState((t) => ({
999
1025
  afterSaveCount: t.afterSaveCount + 1
1000
1026
  }));
1001
1027
  },
@@ -1005,15 +1031,15 @@ const qt = [
1005
1031
  activityBinaryData: n,
1006
1032
  assignmentBinaryData: r
1007
1033
  }) => {
1008
- a.setState({
1034
+ i.setState({
1009
1035
  loadedJsonActivityContent: t,
1010
1036
  loadedJsonAssignmentContent: e,
1011
1037
  loadedJsonActivityBinaryData: n,
1012
1038
  loadedJsonAssignmentBinaryData: r
1013
1039
  });
1014
1040
  },
1015
- getActivityContentAndData: () => (console.log("[React bindings] Getting activity content and data"), a.getState().getJsonActivitySplitContentFunction()),
1016
- getAssignmentContentAndData: () => (console.log("[React bindings] Getting assignment content and data"), a.getState().getJsonAssignmentSplitContentFunction())
1041
+ getActivityContentAndData: () => (console.log("[React bindings] Getting activity content and data"), i.getState().getJsonActivitySplitContentFunction()),
1042
+ getAssignmentContentAndData: () => (console.log("[React bindings] Getting assignment content and data"), i.getState().getJsonAssignmentSplitContentFunction())
1017
1043
  },
1018
1044
  "meta-player-anti-cheat:1": {
1019
1045
  lock: () => {
@@ -1024,24 +1050,24 @@ const qt = [
1024
1050
  "meta-player-ui:1": {
1025
1051
  executeAction(t) {
1026
1052
  if (console.log("[React bindings] Executing action:", t), t.startsWith("qa")) {
1027
- const n = a.getState().quickActions[t];
1053
+ const n = i.getState().quickActions[t];
1028
1054
  n ? n() : console.error(`[React bindings] Quick action not found: ${t}`);
1029
1055
  } else {
1030
- const n = a.getState().sidebarActions[t];
1056
+ const n = i.getState().sidebarActions[t];
1031
1057
  n ? n() : console.error(`[React bindings] Sidebar action not found: ${t}`);
1032
1058
  }
1033
1059
  },
1034
1060
  executeFileUpload(t, e) {
1035
1061
  if (t.startsWith("qa")) {
1036
- const r = a.getState().quickActions[t];
1062
+ const r = i.getState().quickActions[t];
1037
1063
  r ? r(e) : console.error(`[React bindings] Quick action not found: ${t}`);
1038
1064
  } else {
1039
- const r = a.getState().sidebarActions[t];
1065
+ const r = i.getState().sidebarActions[t];
1040
1066
  r ? r(e) : console.error(`[React bindings] Sidebar action not found: ${t}`);
1041
1067
  }
1042
1068
  },
1043
1069
  updateSettings(t) {
1044
- const e = a.getState().activitySettingsCallback;
1070
+ const e = i.getState().activitySettingsCallback;
1045
1071
  e ? e(t) : console.warn(
1046
1072
  "activitySettingsCallback is not set. Changes:",
1047
1073
  t
@@ -1050,27 +1076,35 @@ const qt = [
1050
1076
  },
1051
1077
  "meta-player-events:1": {
1052
1078
  handleEvent(t) {
1053
- t === "all-loaded" && a.setState({ ready: !0 });
1079
+ t === "all-loaded" && i.setState({ ready: !0 });
1054
1080
  }
1055
1081
  },
1056
1082
  "llm:1": {
1057
1083
  getFirstMessageContext: (t) => {
1058
- const e = a.getState().llmGetFirstMessageContextFunction;
1059
- if (!e)
1060
- throw new Error("LLM first message context function is not set");
1061
- return e(t);
1084
+ const e = i.getState().llmGetFirstMessageContextFunction;
1085
+ return e ? e(t) : "";
1062
1086
  },
1063
1087
  getAllMessagesContext: (t) => {
1064
- const e = a.getState().llmGetAllMessagesContextFunction;
1065
- if (!e)
1066
- throw new Error("LLM all messages context function is not set");
1067
- return e(t);
1088
+ const e = i.getState().llmGetAllMessagesContextFunction;
1089
+ return e ? e(t) : "";
1090
+ },
1091
+ getAvailableTools: (t) => {
1092
+ const e = i.getState().llmGetAvailableToolsFunction;
1093
+ return e ? e(t) : [];
1094
+ },
1095
+ callTool: (t, e) => {
1096
+ const n = i.getState().llmCallToolFunction;
1097
+ if (!n)
1098
+ throw new Error("LLM call tool function is not set");
1099
+ return n(t, e);
1068
1100
  }
1069
1101
  }
1070
1102
  }, b = Dt();
1071
1103
  function Bt(t) {
1072
1104
  if (console.log("[React bindings] Contracts to plug:", t), Z) {
1073
- console.warn("[React bindings] Contracts have already been plugged. Skipping.");
1105
+ console.warn(
1106
+ "[React bindings] Contracts have already been plugged. Skipping."
1107
+ );
1074
1108
  return;
1075
1109
  }
1076
1110
  Z = !0;
@@ -1102,11 +1136,15 @@ function Bt(t) {
1102
1136
  "separate-contents(json):1",
1103
1137
  "separate-dual-contents(json):1"
1104
1138
  ])
1105
- if (console.log(`[React bindings] Contract ${e} is being subscribed to content changes.`), t.includes(e)) {
1106
- console.log(`[React bindings] Subscribing to content changes for contract ${e}`);
1139
+ if (console.log(
1140
+ `[React bindings] Contract ${e} is being subscribed to content changes.`
1141
+ ), t.includes(e)) {
1142
+ console.log(
1143
+ `[React bindings] Subscribing to content changes for contract ${e}`
1144
+ );
1107
1145
  const n = e.split(":")[0];
1108
1146
  b.use([n], ([r]) => {
1109
- a.subscribe(
1147
+ i.subscribe(
1110
1148
  (o) => o.isDirtyCount,
1111
1149
  () => {
1112
1150
  r.i?.contentChanged(), console.log(
@@ -1117,76 +1155,76 @@ function Bt(t) {
1117
1155
  });
1118
1156
  }
1119
1157
  }
1120
- const re = () => a((t) => {
1158
+ const re = () => i((t) => {
1121
1159
  if (t.mode === null)
1122
1160
  throw new Error("Mode is not set. Have you used contract 'mode'?");
1123
1161
  return t.mode;
1124
- }), se = () => a((t) => {
1162
+ }), se = () => i((t) => {
1125
1163
  if (t.workflow === null)
1126
1164
  throw new Error(
1127
1165
  "Workflow is not set. Have you used contract 'workflow'?"
1128
1166
  );
1129
1167
  return t.workflow;
1130
- }), ie = () => a((t) => {
1168
+ }), ie = () => i((t) => {
1131
1169
  if (t.theme === null)
1132
1170
  throw new Error("Theme is not set. Have you used contract 'theme'?");
1133
1171
  return t.theme;
1134
- }), ae = () => a((t) => t.incSaveCount), ce = () => a((t) => t.incDirtyCount), le = () => a((t) => t.loadedTextContent), ue = () => a((t) => t.loadedJsonContent), de = () => a((t) => t.loadedJsonActivityContent), ge = () => a((t) => t.loadedJsonAssignmentContent), fe = () => a((t) => t.loadedJsonActivityBinaryData), pe = () => a((t) => t.loadedJsonAssignmentBinaryData), me = () => h(() => a.getState().loadedTextContent, []), ye = () => h(() => a.getState().loadedJsonContent, []), ve = () => h(() => a.getState().loadedJsonActivityContent, []), Ce = () => h(() => a.getState().loadedJsonAssignmentContent, []), Se = () => h(
1172
+ }), ae = () => i((t) => t.incSaveCount), le = () => i((t) => t.incDirtyCount), ce = () => i((t) => t.loadedTextContent), ue = () => i((t) => t.loadedJsonContent), de = () => i((t) => t.loadedJsonActivityContent), ge = () => i((t) => t.loadedJsonAssignmentContent), fe = () => i((t) => t.loadedJsonActivityBinaryData), me = () => i((t) => t.loadedJsonAssignmentBinaryData), pe = () => A(() => i.getState().loadedTextContent, []), ye = () => A(() => i.getState().loadedJsonContent, []), ve = () => A(() => i.getState().loadedJsonActivityContent, []), Ce = () => A(() => i.getState().loadedJsonAssignmentContent, []), Se = () => A(
1135
1173
  () => ({
1136
- content: a.getState().loadedJsonActivityContent,
1137
- binaryData: a.getState().loadedJsonActivityBinaryData
1174
+ content: i.getState().loadedJsonActivityContent,
1175
+ binaryData: i.getState().loadedJsonActivityBinaryData
1138
1176
  }),
1139
1177
  []
1140
- ), we = () => h(
1178
+ ), we = () => A(
1141
1179
  () => ({
1142
- content: a.getState().loadedJsonAssignmentContent,
1143
- binaryData: a.getState().loadedJsonAssignmentBinaryData
1180
+ content: i.getState().loadedJsonAssignmentContent,
1181
+ binaryData: i.getState().loadedJsonAssignmentBinaryData
1144
1182
  }),
1145
1183
  []
1146
1184
  ), be = (t) => {
1147
- const e = a(
1185
+ const e = i(
1148
1186
  (n) => n.setGetTextContentFunction
1149
1187
  );
1150
1188
  w(() => {
1151
1189
  e(t);
1152
1190
  }, [t, e]);
1153
- }, he = (t) => {
1154
- const e = a(
1191
+ }, Ae = (t) => {
1192
+ const e = i(
1155
1193
  (n) => n.setGetJsonContentFunction
1156
1194
  );
1157
1195
  w(() => {
1158
1196
  e(t);
1159
1197
  }, [t, e]);
1160
- }, Ae = (t) => {
1161
- const e = a(
1198
+ }, he = (t) => {
1199
+ const e = i(
1162
1200
  (n) => n.setGetJsonActivityContentFunction
1163
1201
  );
1164
1202
  w(() => {
1165
1203
  e(t);
1166
1204
  }, [t, e]);
1167
- }, Re = (t) => {
1168
- const e = a(
1205
+ }, Fe = (t) => {
1206
+ const e = i(
1169
1207
  (n) => n.setGetJsonAssignmentContentFunction
1170
1208
  );
1171
1209
  w(() => {
1172
1210
  e(t);
1173
1211
  }, [t, e]);
1174
- }, Ee = (t) => {
1175
- const e = a(
1212
+ }, Re = (t) => {
1213
+ const e = i(
1176
1214
  (n) => n.setGetJsonActivitySplitContentFunction
1177
1215
  );
1178
1216
  w(() => {
1179
1217
  e(t);
1180
1218
  }, [t, e]);
1181
- }, Fe = (t) => {
1182
- const e = a(
1219
+ }, Ee = (t) => {
1220
+ const e = i(
1183
1221
  (n) => n.setGetJsonAssignmentSplitContentFunction
1184
1222
  );
1185
1223
  w(() => {
1186
1224
  e(t);
1187
1225
  }, [t, e]);
1188
1226
  }, xe = (t) => {
1189
- const e = a((n) => n.afterSaveCount);
1227
+ const e = i((n) => n.afterSaveCount);
1190
1228
  w(() => {
1191
1229
  e > 0 && t();
1192
1230
  }, [e]);
@@ -1212,8 +1250,8 @@ const re = () => a((t) => {
1212
1250
  });
1213
1251
  };
1214
1252
  let P = 0, W = 0;
1215
- const Me = (t, e) => {
1216
- const n = U(t, e), r = a((o) => o.setSidebarActions);
1253
+ const Te = (t, e) => {
1254
+ const n = U(t, e), r = i((o) => o.setSidebarActions);
1217
1255
  w(() => (P++, P > 1 && console.error(
1218
1256
  "[React bindings] Capytale iframe React: Multiple sidebar actions registered: ",
1219
1257
  P
@@ -1227,15 +1265,15 @@ const Me = (t, e) => {
1227
1265
  return;
1228
1266
  }
1229
1267
  W++;
1230
- const s = n.map((c, g) => ({
1231
- type: c.type,
1232
- title: c.title,
1233
- icon: c.icon,
1268
+ const s = n.map((l, g) => ({
1269
+ type: l.type,
1270
+ title: l.title,
1271
+ icon: l.icon,
1234
1272
  id: `sa-${W}-${g}`,
1235
- ...c.type === "file-upload" ? { accept: c.accept } : {}
1273
+ ...l.type === "file-upload" ? { accept: l.accept } : {}
1236
1274
  })), f = {};
1237
- n.forEach((c, g) => {
1238
- f[`sa-${W}-${g}`] = c.action;
1275
+ n.forEach((l, g) => {
1276
+ f[`sa-${W}-${g}`] = l.action;
1239
1277
  }), o.i?.setSidebarActionButtons(s), r(f);
1240
1278
  }), () => {
1241
1279
  r({}), b.use(["meta-player-ui"], ([o]) => {
@@ -1250,8 +1288,8 @@ const Me = (t, e) => {
1250
1288
  }), [n]);
1251
1289
  };
1252
1290
  let V = 0, H = 0;
1253
- const Te = (t, e) => {
1254
- const n = U(t, e), r = a((o) => o.setQuickActions);
1291
+ const Me = (t, e) => {
1292
+ const n = U(t, e), r = i((o) => o.setQuickActions);
1255
1293
  w(() => (V++, V > 1 && console.error(
1256
1294
  "[React bindings] Capytale iframe React: Multiple quick actions registered: ",
1257
1295
  V
@@ -1265,15 +1303,15 @@ const Te = (t, e) => {
1265
1303
  return;
1266
1304
  }
1267
1305
  H++;
1268
- const s = n.map((c, g) => ({
1269
- type: c.type,
1270
- title: c.title,
1271
- icon: c.icon,
1306
+ const s = n.map((l, g) => ({
1307
+ type: l.type,
1308
+ title: l.title,
1309
+ icon: l.icon,
1272
1310
  id: `qa-${H}-${g}`,
1273
- ...c.type === "file-upload" ? { accept: c.accept } : {}
1311
+ ...l.type === "file-upload" ? { accept: l.accept } : {}
1274
1312
  })), f = {};
1275
- n.forEach((c, g) => {
1276
- f[`qa-${H}-${g}`] = c.action;
1313
+ n.forEach((l, g) => {
1314
+ f[`qa-${H}-${g}`] = l.action;
1277
1315
  }), o.i?.setQuickActionButtons(s), r(f);
1278
1316
  }), () => {
1279
1317
  r({}), b.use(["meta-player-ui"], ([o]) => {
@@ -1289,7 +1327,7 @@ const Te = (t, e) => {
1289
1327
  };
1290
1328
  let D = 0;
1291
1329
  const Wt = (t, e, n) => {
1292
- const r = U(t, n), o = a(
1330
+ const r = U(t, n), o = i(
1293
1331
  (s) => s.setActivitySettingsCallback
1294
1332
  );
1295
1333
  w(() => (console.log("[React bindings] Mounting useSettings"), D++, D > 1 && console.error(
@@ -1304,31 +1342,46 @@ const Wt = (t, e, n) => {
1304
1342
  );
1305
1343
  return;
1306
1344
  }
1307
- console.log("[React bindings] Updating settings UI in MetaPlayer", r), s.i?.setSettingsUI(r);
1345
+ console.log(
1346
+ "[React bindings] Updating settings UI in MetaPlayer",
1347
+ r
1348
+ ), s.i?.setSettingsUI(r);
1308
1349
  }), o(
1309
1350
  e
1310
1351
  ), () => {
1311
1352
  o(null);
1312
1353
  }), [r]);
1313
- }, Ht = () => h((e) => b.exec(["meta-player-ui"], ([n]) => {
1354
+ }, Ht = () => A((e) => b.exec(["meta-player-ui"], ([n]) => {
1314
1355
  if (n.version === 0)
1315
1356
  throw console.error(
1316
1357
  "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1317
- ), new Error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
1358
+ ), new Error(
1359
+ "Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1360
+ );
1318
1361
  return n.i?.showToast(e);
1319
- }), []), zt = () => h((e) => b.exec(["meta-player-ui"], ([n]) => {
1320
- if (n.version === 0)
1321
- throw console.error(
1322
- "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1323
- ), new Error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
1324
- return n.i?.clearToast(e);
1325
- }), []), Le = () => h(() => b.exec(["meta-player-ui"], ([e]) => {
1326
- if (e.version === 0)
1327
- throw console.error(
1328
- "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1329
- ), new Error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
1330
- return e.i?.clearToasts();
1331
- }), []), Ut = (t, e) => {
1362
+ }), []), zt = () => A(
1363
+ (e) => b.exec(["meta-player-ui"], ([n]) => {
1364
+ if (n.version === 0)
1365
+ throw console.error(
1366
+ "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1367
+ ), new Error(
1368
+ "Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1369
+ );
1370
+ return n.i?.clearToast(e);
1371
+ }),
1372
+ []
1373
+ ), Le = () => A(
1374
+ () => b.exec(["meta-player-ui"], ([e]) => {
1375
+ if (e.version === 0)
1376
+ throw console.error(
1377
+ "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1378
+ ), new Error(
1379
+ "Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1380
+ );
1381
+ return e.i?.clearToasts();
1382
+ }),
1383
+ []
1384
+ ), Ut = (t, e) => {
1332
1385
  const n = Ht(), r = zt();
1333
1386
  return w(() => {
1334
1387
  if (t == null)
@@ -1340,26 +1393,37 @@ const Wt = (t, e, n) => {
1340
1393
  });
1341
1394
  };
1342
1395
  }, [n, r, ...e]), null;
1343
- }, Ge = () => h(() => b.exec(["trigger-save"], ([e]) => {
1396
+ }, Ge = () => A(() => b.exec(["trigger-save"], ([e]) => {
1344
1397
  if (e.version === 0)
1345
1398
  throw console.error(
1346
1399
  "[React bindings] Le MétaPlayer ne supporte pas le contrat trigger-save"
1347
- ), new Error("Le MétaPlayer ne supporte pas le contrat trigger-save");
1400
+ ), new Error(
1401
+ "Le MétaPlayer ne supporte pas le contrat trigger-save"
1402
+ );
1348
1403
  return e.i?.triggerSave();
1349
- }), []), Pe = () => a((t) => t.canSave), Ve = (t, e) => {
1350
- const n = a(
1404
+ }), []), Pe = () => i((t) => t.canSave), Ve = (t, e) => {
1405
+ const n = i(
1351
1406
  (r) => r.setLlmGetFirstMessageContextFunction
1352
1407
  );
1353
1408
  w(() => (n(t), () => {
1354
1409
  n(null);
1355
1410
  }), [e, n]);
1356
1411
  }, De = (t, e) => {
1357
- const n = a(
1412
+ const n = i(
1358
1413
  (r) => r.setLlmGetAllMessagesContextFunction
1359
1414
  );
1360
1415
  w(() => (n(t), () => {
1361
1416
  n(null);
1362
1417
  }), [e, n]);
1418
+ }, Ie = (t, e, n) => {
1419
+ const r = i(
1420
+ (s) => s.setLlmGetAvailableToolsFunction
1421
+ ), o = i(
1422
+ (s) => s.setLlmCallToolFunction
1423
+ );
1424
+ w(() => (r(t), o(e), () => {
1425
+ r(null), o(null);
1426
+ }), [n, r, o]);
1363
1427
  };
1364
1428
  function _t(t) {
1365
1429
  const e = {};
@@ -1392,7 +1456,7 @@ function Xt(t) {
1392
1456
  Object.assign(e, Kt(n));
1393
1457
  return e;
1394
1458
  }
1395
- function Ie(t) {
1459
+ function je(t) {
1396
1460
  const n = dt()((r) => ({
1397
1461
  ...Xt(t)
1398
1462
  }));
@@ -1418,30 +1482,30 @@ const ee = [
1418
1482
  "mode:1",
1419
1483
  "workflow:1"
1420
1484
  ];
1421
- function je({
1485
+ function $e({
1422
1486
  children: t,
1423
1487
  contracts: e,
1424
1488
  loadOnlyWhenReady: n = !0,
1425
1489
  activitySettingsStore: r
1426
1490
  }) {
1427
- const o = a((s) => s.ready);
1491
+ const o = i((s) => s.ready);
1428
1492
  return w(() => {
1429
1493
  const s = [...e];
1430
1494
  for (const f of ee)
1431
1495
  s.includes(f) || s.push(f);
1432
1496
  Bt(s);
1433
- }, []), n && !o ? /* @__PURE__ */ Q("div", { className: "capy-loading-container", children: "Chargement en cours..." }) : /* @__PURE__ */ ft(pt, { children: [
1497
+ }, []), n && !o ? /* @__PURE__ */ Q("div", { className: "capy-loading-container", children: "Chargement en cours..." }) : /* @__PURE__ */ ft(mt, { children: [
1434
1498
  r && /* @__PURE__ */ Q(te, { store: r }),
1435
1499
  t
1436
1500
  ] });
1437
1501
  }
1438
- function $e({ message: t }) {
1502
+ function Oe({ message: t }) {
1439
1503
  return Ut(t, [t]), null;
1440
1504
  }
1441
1505
  export {
1442
- je as Capytale,
1443
- $e as TemporaryToast,
1444
- Ie as createActivitySettingsStore,
1506
+ $e as Capytale,
1507
+ Oe as TemporaryToast,
1508
+ je as createActivitySettingsStore,
1445
1509
  xe as useAfterSaveAction,
1446
1510
  Pe as useCanSave,
1447
1511
  zt as useClearToast,
@@ -1451,29 +1515,30 @@ export {
1451
1515
  Ce as useGetLoadedJsonAssignmentContent,
1452
1516
  we as useGetLoadedJsonAssignmentSplitContent,
1453
1517
  ye as useGetLoadedJsonContent,
1454
- me as useGetLoadedTextContent,
1455
- Ae as useJsonActivityContentSaveFunction,
1456
- Ee as useJsonActivitySplitContentSaveFunction,
1457
- Re as useJsonAssignmentContentSaveFunction,
1458
- Fe as useJsonAssignmentSplitContentSaveFunction,
1459
- he as useJsonContentSaveFunction,
1518
+ pe as useGetLoadedTextContent,
1519
+ he as useJsonActivityContentSaveFunction,
1520
+ Re as useJsonActivitySplitContentSaveFunction,
1521
+ Fe as useJsonAssignmentContentSaveFunction,
1522
+ Ee as useJsonAssignmentSplitContentSaveFunction,
1523
+ Ae as useJsonContentSaveFunction,
1460
1524
  De as useLLMAllMessagesContext,
1461
1525
  Ve as useLLMFirstMessageContext,
1526
+ Ie as useLLMTools,
1462
1527
  fe as useLoadedJsonActivityBinaryData,
1463
1528
  de as useLoadedJsonActivityContent,
1464
- pe as useLoadedJsonAssignmentBinaryData,
1529
+ me as useLoadedJsonAssignmentBinaryData,
1465
1530
  ge as useLoadedJsonAssignmentContent,
1466
1531
  ue as useLoadedJsonContent,
1467
- le as useLoadedTextContent,
1532
+ ce as useLoadedTextContent,
1468
1533
  re as useMode,
1469
- ce as useNotifyIsDirty,
1534
+ le as useNotifyIsDirty,
1470
1535
  Je as usePreviewImageFile,
1471
1536
  ke as usePreviewTextFile,
1472
- Te as useQuickActions,
1537
+ Me as useQuickActions,
1473
1538
  ae as useRequestSave,
1474
1539
  Wt as useSettings,
1475
1540
  Ht as useShowToast,
1476
- Me as useSidebarActions,
1541
+ Te as useSidebarActions,
1477
1542
  be as useTextContentSaveFunction,
1478
1543
  ie as useTheme,
1479
1544
  Ut as useToast,