@commercelayer/app-elements 3.5.1 → 3.5.3

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,6 +1,6 @@
1
1
  "use client";
2
- import { j as se, I as Ee } from "./main-DRHqNsgQ.js";
3
- import V, { memo as ce, useState as U, useRef as y, useCallback as ue, useEffect as $, forwardRef as Ce } from "react";
2
+ import { u as Ee, j as se, I as $e } from "./main-BoeSNofJ.js";
3
+ import V, { memo as ce, useState as U, useRef as w, useCallback as ue, useEffect as I, forwardRef as Ce } from "react";
4
4
  function Ie(e, t, r) {
5
5
  return t in e ? Object.defineProperty(e, t, {
6
6
  value: r,
@@ -30,16 +30,16 @@ function de(e) {
30
30
  }
31
31
  return e;
32
32
  }
33
- function $e(e, t) {
33
+ function Le(e, t) {
34
34
  if (e == null) return {};
35
35
  var r = {}, n = Object.keys(e), i, o;
36
36
  for (o = 0; o < n.length; o++)
37
37
  i = n[o], !(t.indexOf(i) >= 0) && (r[i] = e[i]);
38
38
  return r;
39
39
  }
40
- function Le(e, t) {
40
+ function Ae(e, t) {
41
41
  if (e == null) return {};
42
- var r = $e(e, t), n, i;
42
+ var r = Le(e, t), n, i;
43
43
  if (Object.getOwnPropertySymbols) {
44
44
  var o = Object.getOwnPropertySymbols(e);
45
45
  for (i = 0; i < o.length; i++)
@@ -47,20 +47,20 @@ function Le(e, t) {
47
47
  }
48
48
  return r;
49
49
  }
50
- function Ae(e, t) {
51
- return xe(e) || De(e, t) || Te(e, t) || Re();
50
+ function xe(e, t) {
51
+ return De(e) || Te(e, t) || Re(e, t) || Ne();
52
52
  }
53
- function xe(e) {
53
+ function De(e) {
54
54
  if (Array.isArray(e)) return e;
55
55
  }
56
- function De(e, t) {
56
+ function Te(e, t) {
57
57
  if (!(typeof Symbol > "u" || !(Symbol.iterator in Object(e)))) {
58
58
  var r = [], n = !0, i = !1, o = void 0;
59
59
  try {
60
- for (var a = e[Symbol.iterator](), s; !(n = (s = a.next()).done) && (r.push(s.value), !(t && r.length === t)); n = !0)
60
+ for (var a = e[Symbol.iterator](), d; !(n = (d = a.next()).done) && (r.push(d.value), !(t && r.length === t)); n = !0)
61
61
  ;
62
- } catch (p) {
63
- i = !0, o = p;
62
+ } catch (g) {
63
+ i = !0, o = g;
64
64
  } finally {
65
65
  try {
66
66
  !n && a.return != null && a.return();
@@ -71,7 +71,7 @@ function De(e, t) {
71
71
  return r;
72
72
  }
73
73
  }
74
- function Te(e, t) {
74
+ function Re(e, t) {
75
75
  if (e) {
76
76
  if (typeof e == "string") return pe(e, t);
77
77
  var r = Object.prototype.toString.call(e).slice(8, -1);
@@ -84,11 +84,11 @@ function pe(e, t) {
84
84
  for (var r = 0, n = new Array(t); r < t; r++) n[r] = e[r];
85
85
  return n;
86
86
  }
87
- function Re() {
87
+ function Ne() {
88
88
  throw new TypeError(`Invalid attempt to destructure non-iterable instance.
89
89
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
90
90
  }
91
- function Ne(e, t, r) {
91
+ function _e(e, t, r) {
92
92
  return t in e ? Object.defineProperty(e, t, {
93
93
  value: r,
94
94
  enumerable: !0,
@@ -110,14 +110,14 @@ function he(e) {
110
110
  for (var t = 1; t < arguments.length; t++) {
111
111
  var r = arguments[t] != null ? arguments[t] : {};
112
112
  t % 2 ? ge(Object(r), !0).forEach(function(n) {
113
- Ne(e, n, r[n]);
113
+ _e(e, n, r[n]);
114
114
  }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : ge(Object(r)).forEach(function(n) {
115
115
  Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
116
116
  });
117
117
  }
118
118
  return e;
119
119
  }
120
- function _e() {
120
+ function qe() {
121
121
  for (var e = arguments.length, t = new Array(e), r = 0; r < e; r++)
122
122
  t[r] = arguments[r];
123
123
  return function(n) {
@@ -131,44 +131,44 @@ function H(e) {
131
131
  for (var r = this, n = arguments.length, i = new Array(n), o = 0; o < n; o++)
132
132
  i[o] = arguments[o];
133
133
  return i.length >= e.length ? e.apply(this, i) : function() {
134
- for (var a = arguments.length, s = new Array(a), p = 0; p < a; p++)
135
- s[p] = arguments[p];
136
- return t.apply(r, [].concat(i, s));
134
+ for (var a = arguments.length, d = new Array(a), g = 0; g < a; g++)
135
+ d[g] = arguments[g];
136
+ return t.apply(r, [].concat(i, d));
137
137
  };
138
138
  };
139
139
  }
140
140
  function te(e) {
141
141
  return {}.toString.call(e).includes("Object");
142
142
  }
143
- function qe(e) {
143
+ function ze(e) {
144
144
  return !Object.keys(e).length;
145
145
  }
146
146
  function G(e) {
147
147
  return typeof e == "function";
148
148
  }
149
- function ze(e, t) {
150
- return Object.prototype.hasOwnProperty.call(e, t);
151
- }
152
149
  function Ve(e, t) {
153
- return te(t) || D("changeType"), Object.keys(t).some(function(r) {
154
- return !ze(e, r);
155
- }) && D("changeField"), t;
150
+ return Object.prototype.hasOwnProperty.call(e, t);
156
151
  }
157
- function Ue(e) {
158
- G(e) || D("selectorType");
152
+ function Ue(e, t) {
153
+ return te(t) || T("changeType"), Object.keys(t).some(function(r) {
154
+ return !Ve(e, r);
155
+ }) && T("changeField"), t;
159
156
  }
160
157
  function We(e) {
161
- G(e) || te(e) || D("handlerType"), te(e) && Object.values(e).some(function(t) {
162
- return !G(t);
163
- }) && D("handlersType");
158
+ G(e) || T("selectorType");
164
159
  }
165
160
  function ke(e) {
166
- e || D("initialIsRequired"), te(e) || D("initialType"), qe(e) && D("initialContent");
161
+ G(e) || te(e) || T("handlerType"), te(e) && Object.values(e).some(function(t) {
162
+ return !G(t);
163
+ }) && T("handlersType");
164
+ }
165
+ function Fe(e) {
166
+ e || T("initialIsRequired"), te(e) || T("initialType"), ze(e) && T("initialContent");
167
167
  }
168
- function Fe(e, t) {
168
+ function He(e, t) {
169
169
  throw new Error(e[t] || e.default);
170
170
  }
171
- var He = {
171
+ var Be = {
172
172
  initialIsRequired: "initial state is required",
173
173
  initialType: "initial state should be an object",
174
174
  initialContent: "initial state shouldn't be an empty object",
@@ -178,73 +178,73 @@ var He = {
178
178
  changeType: "provided value of changes should be an object",
179
179
  changeField: 'it seams you want to change a field in the state which is not specified in the "initial" state',
180
180
  default: "an unknown error accured in `state-local` package"
181
- }, D = H(Fe)(He), X = {
182
- changes: Ve,
183
- selector: Ue,
184
- handler: We,
185
- initial: ke
181
+ }, T = H(He)(Be), X = {
182
+ changes: Ue,
183
+ selector: We,
184
+ handler: ke,
185
+ initial: Fe
186
186
  };
187
- function Be(e) {
187
+ function Ke(e) {
188
188
  var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
189
189
  X.initial(e), X.handler(t);
190
190
  var r = {
191
191
  current: e
192
- }, n = H(Je)(r, t), i = H(Ge)(r), o = H(X.changes)(e), a = H(Ke)(r);
193
- function s() {
194
- var g = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(O) {
195
- return O;
192
+ }, n = H(Ye)(r, t), i = H(Je)(r), o = H(X.changes)(e), a = H(Ge)(r);
193
+ function d() {
194
+ var h = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(y) {
195
+ return y;
196
196
  };
197
- return X.selector(g), g(r.current);
197
+ return X.selector(h), h(r.current);
198
198
  }
199
- function p(g) {
200
- _e(n, i, o, a)(g);
199
+ function g(h) {
200
+ qe(n, i, o, a)(h);
201
201
  }
202
- return [s, p];
202
+ return [d, g];
203
203
  }
204
- function Ke(e, t) {
204
+ function Ge(e, t) {
205
205
  return G(t) ? t(e.current) : t;
206
206
  }
207
- function Ge(e, t) {
207
+ function Je(e, t) {
208
208
  return e.current = he(he({}, e.current), t), t;
209
209
  }
210
- function Je(e, t, r) {
210
+ function Ye(e, t, r) {
211
211
  return G(t) ? t(e.current) : Object.keys(r).forEach(function(n) {
212
212
  var i;
213
213
  return (i = t[n]) === null || i === void 0 ? void 0 : i.call(t, e.current[n]);
214
214
  }), r;
215
215
  }
216
- var Ye = {
217
- create: Be
218
- }, Ze = {
216
+ var Ze = {
217
+ create: Ke
218
+ }, Qe = {
219
219
  paths: {
220
220
  vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs"
221
221
  }
222
222
  };
223
- function Qe(e) {
223
+ function Xe(e) {
224
224
  return function t() {
225
225
  for (var r = this, n = arguments.length, i = new Array(n), o = 0; o < n; o++)
226
226
  i[o] = arguments[o];
227
227
  return i.length >= e.length ? e.apply(this, i) : function() {
228
- for (var a = arguments.length, s = new Array(a), p = 0; p < a; p++)
229
- s[p] = arguments[p];
230
- return t.apply(r, [].concat(i, s));
228
+ for (var a = arguments.length, d = new Array(a), g = 0; g < a; g++)
229
+ d[g] = arguments[g];
230
+ return t.apply(r, [].concat(i, d));
231
231
  };
232
232
  };
233
233
  }
234
- function Xe(e) {
234
+ function et(e) {
235
235
  return {}.toString.call(e).includes("Object");
236
236
  }
237
- function et(e) {
238
- return e || me("configIsRequired"), Xe(e) || me("configType"), e.urls ? (tt(), {
237
+ function tt(e) {
238
+ return e || me("configIsRequired"), et(e) || me("configType"), e.urls ? (rt(), {
239
239
  paths: {
240
240
  vs: e.urls.monacoBase
241
241
  }
242
242
  }) : e;
243
243
  }
244
- function tt() {
244
+ function rt() {
245
245
  console.warn(be.deprecation);
246
246
  }
247
- function rt(e, t) {
247
+ function nt(e, t) {
248
248
  throw new Error(e[t] || e.default);
249
249
  }
250
250
  var be = {
@@ -261,9 +261,9 @@ var be = {
261
261
 
262
262
  For more please check the link https://github.com/suren-atoyan/monaco-loader#config
263
263
  `
264
- }, me = Qe(rt)(be), nt = {
265
- config: et
266
- }, it = function() {
264
+ }, me = Xe(nt)(be), it = {
265
+ config: tt
266
+ }, ot = function() {
267
267
  for (var t = arguments.length, r = new Array(t), n = 0; n < t; n++)
268
268
  r[n] = arguments[n];
269
269
  return function(i) {
@@ -277,29 +277,29 @@ function we(e, t) {
277
277
  t[r] instanceof Object && e[r] && Object.assign(t[r], we(e[r], t[r]));
278
278
  }), de(de({}, e), t);
279
279
  }
280
- var ot = {
280
+ var at = {
281
281
  type: "cancelation",
282
282
  msg: "operation is manually canceled"
283
283
  };
284
284
  function ie(e) {
285
285
  var t = !1, r = new Promise(function(n, i) {
286
286
  e.then(function(o) {
287
- return t ? i(ot) : n(o);
287
+ return t ? i(at) : n(o);
288
288
  }), e.catch(i);
289
289
  });
290
290
  return r.cancel = function() {
291
291
  return t = !0;
292
292
  }, r;
293
293
  }
294
- var at = Ye.create({
295
- config: Ze,
294
+ var ut = Ze.create({
295
+ config: Qe,
296
296
  isInitialized: !1,
297
297
  resolve: null,
298
298
  reject: null,
299
299
  monaco: null
300
- }), ye = Ae(at, 2), J = ye[0], ne = ye[1];
301
- function ut(e) {
302
- var t = nt.config(e), r = t.monaco, n = Le(t, ["monaco"]);
300
+ }), ye = xe(ut, 2), J = ye[0], ne = ye[1];
301
+ function ct(e) {
302
+ var t = it.config(e), r = t.monaco, n = Ae(t, ["monaco"]);
303
303
  ne(function(i) {
304
304
  return {
305
305
  config: we(i.config, n),
@@ -307,7 +307,7 @@ function ut(e) {
307
307
  };
308
308
  });
309
309
  }
310
- function ct() {
310
+ function lt() {
311
311
  var e = J(function(t) {
312
312
  var r = t.monaco, n = t.isInitialized, i = t.resolve;
313
313
  return {
@@ -323,30 +323,30 @@ function ct() {
323
323
  return e.resolve(e.monaco), ie(oe);
324
324
  if (window.monaco && window.monaco.editor)
325
325
  return Oe(window.monaco), e.resolve(window.monaco), ie(oe);
326
- it(lt, ft)(dt);
326
+ ot(st, dt)(pt);
327
327
  }
328
328
  return ie(oe);
329
329
  }
330
- function lt(e) {
330
+ function st(e) {
331
331
  return document.body.appendChild(e);
332
332
  }
333
- function st(e) {
333
+ function ft(e) {
334
334
  var t = document.createElement("script");
335
335
  return e && (t.src = e), t;
336
336
  }
337
- function ft(e) {
337
+ function dt(e) {
338
338
  var t = J(function(n) {
339
339
  var i = n.config, o = n.reject;
340
340
  return {
341
341
  config: i,
342
342
  reject: o
343
343
  };
344
- }), r = st("".concat(t.config.paths.vs, "/loader.js"));
344
+ }), r = ft("".concat(t.config.paths.vs, "/loader.js"));
345
345
  return r.onload = function() {
346
346
  return e();
347
347
  }, r.onerror = t.reject, r;
348
348
  }
349
- function dt() {
349
+ function pt() {
350
350
  var e = J(function(r) {
351
351
  var n = r.config, i = r.resolve, o = r.reject;
352
352
  return {
@@ -366,7 +366,7 @@ function Oe(e) {
366
366
  monaco: e
367
367
  });
368
368
  }
369
- function pt() {
369
+ function gt() {
370
370
  return J(function(e) {
371
371
  var t = e.monaco;
372
372
  return t;
@@ -378,97 +378,97 @@ var oe = new Promise(function(e, t) {
378
378
  reject: t
379
379
  });
380
380
  }), re = {
381
- config: ut,
382
- init: ct,
383
- __getMonacoInstance: pt
384
- }, gt = { wrapper: { display: "flex", position: "relative", textAlign: "initial" }, fullWidth: { width: "100%" }, hide: { display: "none" } }, ae = gt, ht = { container: { display: "flex", height: "100%", width: "100%", justifyContent: "center", alignItems: "center" } }, mt = ht;
385
- function vt({ children: e }) {
386
- return V.createElement("div", { style: mt.container }, e);
387
- }
388
- var bt = vt, wt = bt;
389
- function yt({ width: e, height: t, isEditorReady: r, loading: n, _ref: i, className: o, wrapperProps: a }) {
390
- return V.createElement("section", { style: { ...ae.wrapper, width: e, height: t }, ...a }, !r && V.createElement(wt, null, n), V.createElement("div", { ref: i, style: { ...ae.fullWidth, ...!r && ae.hide }, className: o }));
391
- }
392
- var Ot = yt, je = ce(Ot);
393
- function jt(e) {
394
- $(e, []);
395
- }
396
- var le = jt;
397
- function Mt(e, t, r = !0) {
398
- let n = y(!0);
399
- $(n.current || !r ? () => {
381
+ config: ct,
382
+ init: lt,
383
+ __getMonacoInstance: gt
384
+ }, ht = { wrapper: { display: "flex", position: "relative", textAlign: "initial" }, fullWidth: { width: "100%" }, hide: { display: "none" } }, ae = ht, mt = { container: { display: "flex", height: "100%", width: "100%", justifyContent: "center", alignItems: "center" } }, vt = mt;
385
+ function bt({ children: e }) {
386
+ return V.createElement("div", { style: vt.container }, e);
387
+ }
388
+ var wt = bt, yt = wt;
389
+ function Ot({ width: e, height: t, isEditorReady: r, loading: n, _ref: i, className: o, wrapperProps: a }) {
390
+ return V.createElement("section", { style: { ...ae.wrapper, width: e, height: t }, ...a }, !r && V.createElement(yt, null, n), V.createElement("div", { ref: i, style: { ...ae.fullWidth, ...!r && ae.hide }, className: o }));
391
+ }
392
+ var jt = Ot, je = ce(jt);
393
+ function Mt(e) {
394
+ I(e, []);
395
+ }
396
+ var le = Mt;
397
+ function Pt(e, t, r = !0) {
398
+ let n = w(!0);
399
+ I(n.current || !r ? () => {
400
400
  n.current = !1;
401
401
  } : e, t);
402
402
  }
403
- var E = Mt;
403
+ var S = Pt;
404
404
  function B() {
405
405
  }
406
406
  function z(e, t, r, n) {
407
- return Pt(e, n) || St(e, t, r, n);
407
+ return St(e, n) || Et(e, t, r, n);
408
408
  }
409
- function Pt(e, t) {
409
+ function St(e, t) {
410
410
  return e.editor.getModel(Me(e, t));
411
411
  }
412
- function St(e, t, r, n) {
412
+ function Et(e, t, r, n) {
413
413
  return e.editor.createModel(t, r, n ? Me(e, n) : void 0);
414
414
  }
415
415
  function Me(e, t) {
416
416
  return e.Uri.parse(t);
417
417
  }
418
- function Et({ original: e, modified: t, language: r, originalLanguage: n, modifiedLanguage: i, originalModelPath: o, modifiedModelPath: a, keepCurrentOriginalModel: s = !1, keepCurrentModifiedModel: p = !1, theme: g = "light", loading: O = "Loading...", options: j = {}, height: T = "100%", width: L = "100%", className: Y, wrapperProps: I = {}, beforeMount: C = B, onMount: A = B }) {
419
- let [M, R] = U(!1), [h, b] = U(!0), d = y(null), l = y(null), w = y(null), P = y(A), f = y(C), N = y(!1);
418
+ function $t({ original: e, modified: t, language: r, originalLanguage: n, modifiedLanguage: i, originalModelPath: o, modifiedModelPath: a, keepCurrentOriginalModel: d = !1, keepCurrentModifiedModel: g = !1, theme: h = "light", loading: y = "Loading...", options: O = {}, height: R = "100%", width: A = "100%", className: Y, wrapperProps: $ = {}, beforeMount: E = B, onMount: x = B }) {
419
+ let [j, C] = U(!1), [L, c] = U(!0), b = w(null), f = w(null), M = w(null), l = w(x), p = w(E), N = w(!1);
420
420
  le(() => {
421
421
  let u = re.init();
422
- return u.then((m) => (l.current = m) && b(!1)).catch((m) => (m == null ? void 0 : m.type) !== "cancelation" && console.error("Monaco initialization: error:", m)), () => d.current ? W() : u.cancel();
423
- }), E(() => {
424
- if (d.current && l.current) {
425
- let u = d.current.getOriginalEditor(), m = z(l.current, e || "", n || r || "text", o || "");
422
+ return u.then((m) => (f.current = m) && c(!1)).catch((m) => (m == null ? void 0 : m.type) !== "cancelation" && console.error("Monaco initialization: error:", m)), () => b.current ? W() : u.cancel();
423
+ }), S(() => {
424
+ if (b.current && f.current) {
425
+ let u = b.current.getOriginalEditor(), m = z(f.current, e || "", n || r || "text", o || "");
426
426
  m !== u.getModel() && u.setModel(m);
427
427
  }
428
- }, [o], M), E(() => {
429
- if (d.current && l.current) {
430
- let u = d.current.getModifiedEditor(), m = z(l.current, t || "", i || r || "text", a || "");
428
+ }, [o], j), S(() => {
429
+ if (b.current && f.current) {
430
+ let u = b.current.getModifiedEditor(), m = z(f.current, t || "", i || r || "text", a || "");
431
431
  m !== u.getModel() && u.setModel(m);
432
432
  }
433
- }, [a], M), E(() => {
434
- let u = d.current.getModifiedEditor();
435
- u.getOption(l.current.editor.EditorOption.readOnly) ? u.setValue(t || "") : t !== u.getValue() && (u.executeEdits("", [{ range: u.getModel().getFullModelRange(), text: t || "", forceMoveMarkers: !0 }]), u.pushUndoStop());
436
- }, [t], M), E(() => {
433
+ }, [a], j), S(() => {
434
+ let u = b.current.getModifiedEditor();
435
+ u.getOption(f.current.editor.EditorOption.readOnly) ? u.setValue(t || "") : t !== u.getValue() && (u.executeEdits("", [{ range: u.getModel().getFullModelRange(), text: t || "", forceMoveMarkers: !0 }]), u.pushUndoStop());
436
+ }, [t], j), S(() => {
437
437
  var u, m;
438
- (m = (u = d.current) == null ? void 0 : u.getModel()) == null || m.original.setValue(e || "");
439
- }, [e], M), E(() => {
440
- let { original: u, modified: m } = d.current.getModel();
441
- l.current.editor.setModelLanguage(u, n || r || "text"), l.current.editor.setModelLanguage(m, i || r || "text");
442
- }, [r, n, i], M), E(() => {
438
+ (m = (u = b.current) == null ? void 0 : u.getModel()) == null || m.original.setValue(e || "");
439
+ }, [e], j), S(() => {
440
+ let { original: u, modified: m } = b.current.getModel();
441
+ f.current.editor.setModelLanguage(u, n || r || "text"), f.current.editor.setModelLanguage(m, i || r || "text");
442
+ }, [r, n, i], j), S(() => {
443
443
  var u;
444
- (u = l.current) == null || u.editor.setTheme(g);
445
- }, [g], M), E(() => {
444
+ (u = f.current) == null || u.editor.setTheme(h);
445
+ }, [h], j), S(() => {
446
446
  var u;
447
- (u = d.current) == null || u.updateOptions(j);
448
- }, [j], M);
447
+ (u = b.current) == null || u.updateOptions(O);
448
+ }, [O], j);
449
449
  let Z = ue(() => {
450
- var x;
451
- if (!l.current) return;
452
- f.current(l.current);
453
- let u = z(l.current, e || "", n || r || "text", o || ""), m = z(l.current, t || "", i || r || "text", a || "");
454
- (x = d.current) == null || x.setModel({ original: u, modified: m });
450
+ var D;
451
+ if (!f.current) return;
452
+ p.current(f.current);
453
+ let u = z(f.current, e || "", n || r || "text", o || ""), m = z(f.current, t || "", i || r || "text", a || "");
454
+ (D = b.current) == null || D.setModel({ original: u, modified: m });
455
455
  }, [r, t, i, e, n, o, a]), Q = ue(() => {
456
456
  var u;
457
- !N.current && w.current && (d.current = l.current.editor.createDiffEditor(w.current, { automaticLayout: !0, ...j }), Z(), (u = l.current) == null || u.editor.setTheme(g), R(!0), N.current = !0);
458
- }, [j, g, Z]);
459
- $(() => {
460
- M && P.current(d.current, l.current);
461
- }, [M]), $(() => {
462
- !h && !M && Q();
463
- }, [h, M, Q]);
457
+ !N.current && M.current && (b.current = f.current.editor.createDiffEditor(M.current, { automaticLayout: !0, ...O }), Z(), (u = f.current) == null || u.editor.setTheme(h), C(!0), N.current = !0);
458
+ }, [O, h, Z]);
459
+ I(() => {
460
+ j && l.current(b.current, f.current);
461
+ }, [j]), I(() => {
462
+ !L && !j && Q();
463
+ }, [L, j, Q]);
464
464
  function W() {
465
- var m, x, _, k;
466
- let u = (m = d.current) == null ? void 0 : m.getModel();
467
- s || ((x = u == null ? void 0 : u.original) == null || x.dispose()), p || ((_ = u == null ? void 0 : u.modified) == null || _.dispose()), (k = d.current) == null || k.dispose();
465
+ var m, D, _, k;
466
+ let u = (m = b.current) == null ? void 0 : m.getModel();
467
+ d || ((D = u == null ? void 0 : u.original) == null || D.dispose()), g || ((_ = u == null ? void 0 : u.modified) == null || _.dispose()), (k = b.current) == null || k.dispose();
468
468
  }
469
- return V.createElement(je, { width: L, height: T, isEditorReady: M, loading: O, _ref: w, className: Y, wrapperProps: I });
469
+ return V.createElement(je, { width: A, height: R, isEditorReady: j, loading: y, _ref: M, className: Y, wrapperProps: $ });
470
470
  }
471
- var Ct = Et;
471
+ var Ct = $t;
472
472
  ce(Ct);
473
473
  function It() {
474
474
  let [e, t] = U(re.__getMonacoInstance());
@@ -479,81 +479,81 @@ function It() {
479
479
  })), () => r == null ? void 0 : r.cancel();
480
480
  }), e;
481
481
  }
482
- var $t = It;
483
- function Lt(e) {
484
- let t = y();
485
- return $(() => {
482
+ var Lt = It;
483
+ function At(e) {
484
+ let t = w();
485
+ return I(() => {
486
486
  t.current = e;
487
487
  }, [e]), t.current;
488
488
  }
489
- var At = Lt, ee = /* @__PURE__ */ new Map();
490
- function xt({ defaultValue: e, defaultLanguage: t, defaultPath: r, value: n, language: i, path: o, theme: a = "light", line: s, loading: p = "Loading...", options: g = {}, overrideServices: O = {}, saveViewState: j = !0, keepCurrentModel: T = !1, width: L = "100%", height: Y = "100%", className: I, wrapperProps: C = {}, beforeMount: A = B, onMount: M = B, onChange: R, onValidate: h = B }) {
491
- let [b, d] = U(!1), [l, w] = U(!0), P = y(null), f = y(null), N = y(null), Z = y(M), Q = y(A), W = y(), u = y(n), m = At(o), x = y(!1), _ = y(!1);
489
+ var xt = At, ee = /* @__PURE__ */ new Map();
490
+ function Dt({ defaultValue: e, defaultLanguage: t, defaultPath: r, value: n, language: i, path: o, theme: a = "light", line: d, loading: g = "Loading...", options: h = {}, overrideServices: y = {}, saveViewState: O = !0, keepCurrentModel: R = !1, width: A = "100%", height: Y = "100%", className: $, wrapperProps: E = {}, beforeMount: x = B, onMount: j = B, onChange: C, onValidate: L = B }) {
491
+ let [c, b] = U(!1), [f, M] = U(!0), l = w(null), p = w(null), N = w(null), Z = w(j), Q = w(x), W = w(), u = w(n), m = xt(o), D = w(!1), _ = w(!1);
492
492
  le(() => {
493
- let c = re.init();
494
- return c.then((v) => (P.current = v) && w(!1)).catch((v) => (v == null ? void 0 : v.type) !== "cancelation" && console.error("Monaco initialization: error:", v)), () => f.current ? Se() : c.cancel();
495
- }), E(() => {
496
- var v, S, F, q;
497
- let c = z(P.current, e || n || "", t || i || "", o || r || "");
498
- c !== ((v = f.current) == null ? void 0 : v.getModel()) && (j && ee.set(m, (S = f.current) == null ? void 0 : S.saveViewState()), (F = f.current) == null || F.setModel(c), j && ((q = f.current) == null || q.restoreViewState(ee.get(o))));
499
- }, [o], b), E(() => {
500
- var c;
501
- (c = f.current) == null || c.updateOptions(g);
502
- }, [g], b), E(() => {
503
- !f.current || n === void 0 || (f.current.getOption(P.current.editor.EditorOption.readOnly) ? f.current.setValue(n) : n !== f.current.getValue() && (_.current = !0, f.current.executeEdits("", [{ range: f.current.getModel().getFullModelRange(), text: n, forceMoveMarkers: !0 }]), f.current.pushUndoStop(), _.current = !1));
504
- }, [n], b), E(() => {
505
- var v, S;
506
- let c = (v = f.current) == null ? void 0 : v.getModel();
507
- c && i && ((S = P.current) == null || S.editor.setModelLanguage(c, i));
508
- }, [i], b), E(() => {
509
- var c;
510
- s !== void 0 && ((c = f.current) == null || c.revealLine(s));
511
- }, [s], b), E(() => {
512
- var c;
513
- (c = P.current) == null || c.editor.setTheme(a);
514
- }, [a], b);
493
+ let s = re.init();
494
+ return s.then((v) => (l.current = v) && M(!1)).catch((v) => (v == null ? void 0 : v.type) !== "cancelation" && console.error("Monaco initialization: error:", v)), () => p.current ? Se() : s.cancel();
495
+ }), S(() => {
496
+ var v, P, F, q;
497
+ let s = z(l.current, e || n || "", t || i || "", o || r || "");
498
+ s !== ((v = p.current) == null ? void 0 : v.getModel()) && (O && ee.set(m, (P = p.current) == null ? void 0 : P.saveViewState()), (F = p.current) == null || F.setModel(s), O && ((q = p.current) == null || q.restoreViewState(ee.get(o))));
499
+ }, [o], c), S(() => {
500
+ var s;
501
+ (s = p.current) == null || s.updateOptions(h);
502
+ }, [h], c), S(() => {
503
+ !p.current || n === void 0 || (p.current.getOption(l.current.editor.EditorOption.readOnly) ? p.current.setValue(n) : n !== p.current.getValue() && (_.current = !0, p.current.executeEdits("", [{ range: p.current.getModel().getFullModelRange(), text: n, forceMoveMarkers: !0 }]), p.current.pushUndoStop(), _.current = !1));
504
+ }, [n], c), S(() => {
505
+ var v, P;
506
+ let s = (v = p.current) == null ? void 0 : v.getModel();
507
+ s && i && ((P = l.current) == null || P.editor.setModelLanguage(s, i));
508
+ }, [i], c), S(() => {
509
+ var s;
510
+ d !== void 0 && ((s = p.current) == null || s.revealLine(d));
511
+ }, [d], c), S(() => {
512
+ var s;
513
+ (s = l.current) == null || s.editor.setTheme(a);
514
+ }, [a], c);
515
515
  let k = ue(() => {
516
- var c;
517
- if (!(!N.current || !P.current) && !x.current) {
518
- Q.current(P.current);
519
- let v = o || r, S = z(P.current, n || e || "", t || i || "", v || "");
520
- f.current = (c = P.current) == null ? void 0 : c.editor.create(N.current, { model: S, automaticLayout: !0, ...g }, O), j && f.current.restoreViewState(ee.get(v)), P.current.editor.setTheme(a), s !== void 0 && f.current.revealLine(s), d(!0), x.current = !0;
516
+ var s;
517
+ if (!(!N.current || !l.current) && !D.current) {
518
+ Q.current(l.current);
519
+ let v = o || r, P = z(l.current, n || e || "", t || i || "", v || "");
520
+ p.current = (s = l.current) == null ? void 0 : s.editor.create(N.current, { model: P, automaticLayout: !0, ...h }, y), O && p.current.restoreViewState(ee.get(v)), l.current.editor.setTheme(a), d !== void 0 && p.current.revealLine(d), b(!0), D.current = !0;
521
521
  }
522
- }, [e, t, r, n, i, o, g, O, j, a, s]);
523
- $(() => {
524
- b && Z.current(f.current, P.current);
525
- }, [b]), $(() => {
526
- !l && !b && k();
527
- }, [l, b, k]), u.current = n, $(() => {
528
- var c, v;
529
- b && R && ((c = W.current) == null || c.dispose(), W.current = (v = f.current) == null ? void 0 : v.onDidChangeModelContent((S) => {
530
- _.current || R(f.current.getValue(), S);
522
+ }, [e, t, r, n, i, o, h, y, O, a, d]);
523
+ I(() => {
524
+ c && Z.current(p.current, l.current);
525
+ }, [c]), I(() => {
526
+ !f && !c && k();
527
+ }, [f, c, k]), u.current = n, I(() => {
528
+ var s, v;
529
+ c && C && ((s = W.current) == null || s.dispose(), W.current = (v = p.current) == null ? void 0 : v.onDidChangeModelContent((P) => {
530
+ _.current || C(p.current.getValue(), P);
531
531
  }));
532
- }, [b, R]), $(() => {
533
- if (b) {
534
- let c = P.current.editor.onDidChangeMarkers((v) => {
532
+ }, [c, C]), I(() => {
533
+ if (c) {
534
+ let s = l.current.editor.onDidChangeMarkers((v) => {
535
535
  var F;
536
- let S = (F = f.current.getModel()) == null ? void 0 : F.uri;
537
- if (S && v.find((q) => q.path === S.path)) {
538
- let q = P.current.editor.getModelMarkers({ resource: S });
539
- h == null || h(q);
536
+ let P = (F = p.current.getModel()) == null ? void 0 : F.uri;
537
+ if (P && v.find((q) => q.path === P.path)) {
538
+ let q = l.current.editor.getModelMarkers({ resource: P });
539
+ L == null || L(q);
540
540
  }
541
541
  });
542
542
  return () => {
543
- c == null || c.dispose();
543
+ s == null || s.dispose();
544
544
  };
545
545
  }
546
546
  return () => {
547
547
  };
548
- }, [b, h]);
548
+ }, [c, L]);
549
549
  function Se() {
550
- var c, v;
551
- (c = W.current) == null || c.dispose(), T ? j && ee.set(o, f.current.saveViewState()) : (v = f.current.getModel()) == null || v.dispose(), f.current.dispose();
550
+ var s, v;
551
+ (s = W.current) == null || s.dispose(), R ? O && ee.set(o, p.current.saveViewState()) : (v = p.current.getModel()) == null || v.dispose(), p.current.dispose();
552
552
  }
553
- return V.createElement(je, { width: L, height: Y, isEditorReady: b, loading: p, _ref: N, className: I, wrapperProps: C });
553
+ return V.createElement(je, { width: A, height: Y, isEditorReady: c, loading: g, _ref: N, className: $, wrapperProps: E });
554
554
  }
555
- var Dt = xt, Tt = ce(Dt), Rt = Tt;
556
- const Nt = /* @__PURE__ */ (() => {
555
+ var Tt = Dt, Rt = ce(Tt), Nt = Rt;
556
+ const _t = /* @__PURE__ */ (() => {
557
557
  let e;
558
558
  return async () => (e != null || (e = await fetch("https://core.commercelayer.io/api/public/resources").then(async (t) => await t.json()).then(
559
559
  ({ data: t }) => t.reduce((r, n, i, o) => ({
@@ -562,7 +562,7 @@ const Nt = /* @__PURE__ */ (() => {
562
562
  fields: Object.entries(n.attributes.fields).filter(([a]) => !a.startsWith("_")),
563
563
  relationships: Object.entries(n.attributes.relationships).filter(([a]) => !a.startsWith("_")).filter(
564
564
  ([, a]) => t.find(
565
- (s) => s.id === Pe(a.class_name)
565
+ (d) => d.id === Pe(a.class_name)
566
566
  ) != null
567
567
  )
568
568
  }
@@ -571,14 +571,14 @@ const Nt = /* @__PURE__ */ (() => {
571
571
  throw t;
572
572
  })), e);
573
573
  })();
574
- async function _t(e, t) {
574
+ async function qt(e, t) {
575
575
  var i, o;
576
576
  if (!new RegExp(`^(${e.join("|")})(.|$)`).test(t))
577
577
  return e.map((a) => ({
578
578
  value: a,
579
579
  type: "relationship"
580
580
  }));
581
- const r = await qt(t);
581
+ const r = await zt(t);
582
582
  return [].concat(
583
583
  ((i = r.obj) == null ? void 0 : i.fields.map(([a]) => ({
584
584
  value: `${r.path}.${a}`,
@@ -591,20 +591,20 @@ async function _t(e, t) {
591
591
  }))) ?? []
592
592
  );
593
593
  }
594
- async function qt(e, t) {
595
- const r = await Nt(), n = e.replace(/\.$/, "").split("."), i = n.shift();
594
+ async function zt(e, t) {
595
+ const r = await _t(), n = e.replace(/\.$/, "").split("."), i = n.shift();
596
596
  return t ?? (t = r[i ?? ""]), n.reduce(
597
597
  (o, a) => {
598
- var g, O;
599
- const s = (O = (g = o.obj) == null ? void 0 : g.relationships.find(
600
- ([j]) => j === a
601
- )) == null ? void 0 : O[1].class_name;
602
- if (s == null)
598
+ var h, y;
599
+ const d = (y = (h = o.obj) == null ? void 0 : h.relationships.find(
600
+ ([O]) => O === a
601
+ )) == null ? void 0 : y[1].class_name;
602
+ if (d == null)
603
603
  return o;
604
- const p = r[Pe(s)];
605
- return p == null ? o : {
604
+ const g = r[Pe(d)];
605
+ return g == null ? o : {
606
606
  path: `${o.path == null ? "" : `${o.path}.`}${a}`,
607
- obj: p
607
+ obj: g
608
608
  };
609
609
  },
610
610
  { path: t != null ? i ?? "" : "", obj: t }
@@ -613,7 +613,7 @@ async function qt(e, t) {
613
613
  function Pe(e) {
614
614
  return e.replace(/([A-Z])/g, "_$1").replace(/^_/, "").toLowerCase();
615
615
  }
616
- const zt = Ut(500), Vt = Ce(
616
+ const Vt = Wt(500), Ut = Ce(
617
617
  ({
618
618
  feedback: e,
619
619
  hint: t,
@@ -622,97 +622,99 @@ const zt = Ut(500), Vt = Ce(
622
622
  defaultValue: i,
623
623
  readOnly: o,
624
624
  value: a,
625
- language: s = "plaintext",
626
- height: p = "220px",
627
- jsonSchema: g = "none",
628
- onValidate: O,
629
- onValid: j,
630
- onChange: T,
631
- ...L
625
+ language: d = "plaintext",
626
+ height: g = "220px",
627
+ jsonSchema: h = "none",
628
+ onValidate: y,
629
+ onValid: O,
630
+ onChange: R,
631
+ ...A
632
632
  }, Y) => {
633
- const I = $t(), C = y(), [A, M] = U(null), R = (h, b) => {
634
- M(h), h.onDidPaste(() => {
635
- var d;
636
- (d = h.getAction("editor.action.formatDocument")) == null || d.run();
637
- }), h.onDidChangeModelContent(() => {
638
- const d = h.getModel(), l = b.editor.getModelMarkers({
639
- resource: d == null ? void 0 : d.uri
640
- }), w = h.getValue();
641
- zt(() => {
642
- O == null || O(l.length > 0 ? l : null), T == null || T(w), l.length === 0 && (j == null || j(w));
633
+ const $ = Lt(), E = w(), [x, j] = U(null), {
634
+ settings: { domain: C }
635
+ } = Ee(), L = (c, b) => {
636
+ j(c), c.onDidPaste(() => {
637
+ var f;
638
+ (f = c.getAction("editor.action.formatDocument")) == null || f.run();
639
+ }), c.onDidChangeModelContent(() => {
640
+ const f = c.getModel(), M = b.editor.getModelMarkers({
641
+ resource: f == null ? void 0 : f.uri
642
+ }), l = c.getValue();
643
+ Vt(() => {
644
+ y == null || y(M.length > 0 ? M : null), R == null || R(l), M.length === 0 && (O == null || O(l));
643
645
  });
644
646
  });
645
647
  };
646
- return $(() => (async function() {
647
- var b, d;
648
- const h = (b = A == null ? void 0 : A.getModel()) == null ? void 0 : b.uri.toString();
649
- if (I != null && h != null && g != null) {
650
- (d = C.current) == null || d.call(C);
651
- const l = I.languages.json.jsonDefaults.diagnosticsOptions.schemas ?? [];
652
- switch (g) {
648
+ return I(() => (async function() {
649
+ var b, f;
650
+ const c = (b = x == null ? void 0 : x.getModel()) == null ? void 0 : b.uri.toString();
651
+ if ($ != null && c != null && h != null) {
652
+ (f = E.current) == null || f.call(E);
653
+ const M = $.languages.json.jsonDefaults.diagnosticsOptions.schemas ?? [];
654
+ switch (h) {
653
655
  case "none":
654
656
  break;
655
657
  case "organization-config": {
656
- l.push({
658
+ M.push({
657
659
  schema: await fetch(
658
- "https://provisioning.commercelayer.io/api/public/schemas/organization_config"
659
- ).then(async (w) => await w.json()).then((w) => K(w)),
660
- uri: `file:///json-schema--${g}.json`,
661
- fileMatch: [h]
660
+ `https://provisioning.${C}/api/public/schemas/organization_config`
661
+ ).then(async (l) => await l.json()).then((l) => K(l)),
662
+ uri: `file:///json-schema--${h}.json`,
663
+ fileMatch: [c]
662
664
  });
663
665
  break;
664
666
  }
665
667
  case "order-rules": {
666
- l.push({
668
+ M.push({
667
669
  schema: await fetch(
668
- "https://core.commercelayer.io/api/public/schemas/order_rules"
669
- ).then(async (w) => await w.json()).then((w) => K(w)),
670
- uri: `file:///json-schema--${g}.json`,
671
- fileMatch: [h]
672
- }), C.current = ve(I, h, ["order"]);
670
+ `https://core.${C}/api/public/schemas/order_rules`
671
+ ).then(async (l) => await l.json()).then((l) => K(l)),
672
+ uri: `file:///json-schema--${h}.json`,
673
+ fileMatch: [c]
674
+ }), E.current = ve($, c, ["order"]);
673
675
  break;
674
676
  }
675
677
  case "price-rules": {
676
- l.push({
678
+ M.push({
677
679
  schema: await fetch(
678
- "https://core.commercelayer.io/api/public/schemas/price_rules"
679
- ).then(async (w) => await w.json()).then((w) => K(w)),
680
- uri: `file:///json-schema--${g}.json`,
681
- fileMatch: [h]
682
- }), C.current = ve(I, h, ["price"]);
680
+ `https://core.${C}/api/public/schemas/price_rules`
681
+ ).then(async (l) => await l.json()).then((l) => K(l)),
682
+ uri: `file:///json-schema--${h}.json`,
683
+ fileMatch: [c]
684
+ }), E.current = ve($, c, ["price"]);
683
685
  break;
684
686
  }
685
687
  }
686
- I.languages.json.jsonDefaults.setDiagnosticsOptions({
688
+ $.languages.json.jsonDefaults.setDiagnosticsOptions({
687
689
  enableSchemaRequest: !0,
688
690
  schemaRequest: "ignore",
689
691
  schemaValidation: "error",
690
692
  validate: !0,
691
- schemas: l
693
+ schemas: M
692
694
  });
693
695
  }
694
696
  }(), () => {
695
- var h;
696
- (h = C.current) == null || h.call(C);
697
- }), [I, A, g]), /* @__PURE__ */ se.jsx(
698
- Ee,
697
+ var c;
698
+ (c = E.current) == null || c.call(E);
699
+ }), [$, x, h, C]), /* @__PURE__ */ se.jsx(
700
+ $e,
699
701
  {
700
702
  label: n,
701
703
  hint: t,
702
704
  feedback: e,
703
- name: L.id ?? L.name,
705
+ name: A.id ?? A.name,
704
706
  inline: r,
705
707
  children: /* @__PURE__ */ se.jsx(
706
- Rt,
708
+ Nt,
707
709
  {
708
- defaultPath: L.id ?? L.name,
710
+ defaultPath: A.id ?? A.name,
709
711
  className: "[&>.monaco-editor]:rounded [&>.monaco-editor>.overflow-guard]:rounded",
710
712
  theme: "vs-dark",
711
- language: s,
712
- height: p,
713
+ language: d,
714
+ height: g,
713
715
  defaultValue: i,
714
716
  value: a,
715
- onMount: R,
717
+ onMount: L,
716
718
  options: {
717
719
  quickSuggestions: !0,
718
720
  readOnly: o,
@@ -734,8 +736,8 @@ const zt = Ut(500), Vt = Ce(
734
736
  );
735
737
  }
736
738
  );
737
- Vt.displayName = "CodeEditor";
738
- function Ut(e = 100) {
739
+ Ut.displayName = "CodeEditor";
740
+ function Wt(e = 100) {
739
741
  let t = null;
740
742
  return function(n) {
741
743
  t !== null && clearTimeout(t), t = setTimeout(() => {
@@ -759,17 +761,17 @@ function ve(e, t, r) {
759
761
  };
760
762
  const o = n.getWordUntilPosition(i), a = n.getLineContent(i.lineNumber).substring(0, i.column - 1);
761
763
  if (/"(field|selector)"\s*:\s*"[^"]*$/.test(a)) {
762
- const p = o.word;
763
- if (p != null)
764
+ const g = o.word;
765
+ if (g != null)
764
766
  return {
765
767
  incomplete: !1,
766
- suggestions: (await _t(
768
+ suggestions: (await qt(
767
769
  r,
768
- p
769
- )).map((O) => ({
770
- kind: O.type === "relationship" ? e.languages.CompletionItemKind.Module : e.languages.CompletionItemKind.Value,
771
- label: O.value,
772
- insertText: O.value,
770
+ g
771
+ )).map((y) => ({
772
+ kind: y.type === "relationship" ? e.languages.CompletionItemKind.Module : e.languages.CompletionItemKind.Value,
773
+ label: y.value,
774
+ insertText: y.value,
773
775
  // documentation: `Field: ${suggestion}`,
774
776
  range: {
775
777
  startLineNumber: i.lineNumber,
@@ -788,5 +790,5 @@ function ve(e, t, r) {
788
790
  };
789
791
  }
790
792
  export {
791
- Vt as CodeEditor
793
+ Ut as CodeEditor
792
794
  };