PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.2
Elementor Website Builder – more than just a page builder v4.3.2
4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 All 455 releases
elementor / assets / js / ai-unify-product-images.js

ai-unify-product-images.js in Elementor Website Builder – more than just a page builder 4.3.2, at assets/js/ai-unify-product-images.js

30,781 lines 1.0 MB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function(react, _elementor_ui, _wordpress_i18n, _elementor_icons, _elementor_ui_TextField) {
2
3 //#region \0rolldown/runtime.js
4 var __create = Object.create;
5 var __defProp = Object.defineProperty;
6 var __name = (target, value) => __defProp(target, "name", {
7 value,
8 configurable: true
9 });
10 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11 var __getOwnPropNames = Object.getOwnPropertyNames;
12 var __getProtoOf = Object.getPrototypeOf;
13 var __hasOwnProp = Object.prototype.hasOwnProperty;
14 var __esmMin = (fn, res, err) => () => {
15 if (err) throw err[0];
16 try {
17 return fn && (res = fn(fn = 0)), res;
18 } catch (e) {
19 throw err = [e], e;
20 }
21 };
22 var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
23 var __exportAll = (all, no_symbols) => {
24 let target = {};
25 for (var name in all) {
26 __defProp(target, name, {
27 get: all[name],
28 enumerable: true
29 });
30 }
31 if (!no_symbols) {
32 __defProp(target, Symbol.toStringTag, { value: "Module" });
33 }
34 return target;
35 };
36 var __copyProps = (to, from, except, desc) => {
37 if (from && typeof from === "object" || typeof from === "function") {
38 for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
39 key = keys[i];
40 if (!__hasOwnProp.call(to, key) && key !== except) {
41 __defProp(to, key, {
42 get: ((k) => from[k]).bind(null, key),
43 enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
44 });
45 }
46 }
47 }
48 return to;
49 };
50 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
51 value: mod,
52 enumerable: true
53 }) : target, mod));
54
55 //#endregion
56 let react$1 = __toESM(react, 1);
57 react = __toESM(react);
58 _elementor_ui_TextField = __toESM(_elementor_ui_TextField);
59
60 //#region node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
61 function asyncGeneratorStep$1(n, t, e, r, o, a, c) {
62 try {
63 var i = n[a](c);
64 var u = i.value;
65 } catch (n) {
66 e(n);
67 return;
68 }
69 i.done ? t(u) : Promise.resolve(u).then(r, o);
70 }
71 function _asyncToGenerator$1(n) {
72 return function() {
73 var t = this;
74 var e = arguments;
75 return new Promise(function(r, o) {
76 var a = n.apply(t, e);
77 function _next(n) {
78 asyncGeneratorStep$1(a, r, o, _next, _throw, "next", n);
79 }
80 function _throw(n) {
81 asyncGeneratorStep$1(a, r, o, _next, _throw, "throw", n);
82 }
83 _next(void 0);
84 });
85 };
86 }
87 var init_asyncToGenerator = __esmMin((() => {
88 __name(asyncGeneratorStep$1, "asyncGeneratorStep");
89 __name(_asyncToGenerator$1, "_asyncToGenerator");
90 }));
91
92 //#endregion
93 //#region node_modules/@babel/runtime/helpers/OverloadYield.js
94 var require_OverloadYield = /* @__PURE__ */ __commonJSMin(((exports, module) => {
95 function _OverloadYield(e, d) {
96 this.v = e, this.k = d;
97 }
98 module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
99 }));
100
101 //#endregion
102 //#region node_modules/@babel/runtime/helpers/regeneratorDefine.js
103 var require_regeneratorDefine = /* @__PURE__ */ __commonJSMin(((exports, module) => {
104 function _regeneratorDefine(e, r, n, t) {
105 var i = Object.defineProperty;
106 try {
107 i({}, "", {});
108 } catch (e) {
109 i = 0;
110 }
111 module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
112 function o(r, n) {
113 _regeneratorDefine(e, r, function(e) {
114 return this._invoke(r, n, e);
115 });
116 }
117 r ? i ? i(e, r, {
118 value: n,
119 enumerable: !t,
120 configurable: !t,
121 writable: !t
122 }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
123 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
124 }
125 module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
126 }));
127
128 //#endregion
129 //#region node_modules/@babel/runtime/helpers/regenerator.js
130 var require_regenerator$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
131 var regeneratorDefine = require_regeneratorDefine();
132 function _regenerator() {
133 /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
134 var e;
135 var t;
136 var r = "function" == typeof Symbol ? Symbol : {};
137 var n = r.iterator || "@@iterator";
138 var o = r.toStringTag || "@@toStringTag";
139 function i(r, n, o, i) {
140 var c = n && n.prototype instanceof Generator ? n : Generator;
141 var u = Object.create(c.prototype);
142 return regeneratorDefine(u, "_invoke", function(r, n, o) {
143 var i;
144 var c;
145 var u;
146 var f = 0;
147 var p = o || [];
148 var y = !1;
149 var G = {
150 p: 0,
151 n: 0,
152 v: e,
153 a: d,
154 f: d.bind(e, 4),
155 d: function d(t, r) {
156 return i = t, c = 0, u = e, G.n = r, a;
157 }
158 };
159 function d(r, n) {
160 for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
161 var o;
162 var i = p[t];
163 var d = G.p;
164 var l = i[2];
165 r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
166 }
167 if (o || r > 1) return a;
168 throw y = !0, n;
169 }
170 return function(o, p, l) {
171 if (f > 1) throw TypeError("Generator is already running");
172 for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
173 i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
174 try {
175 if (f = 2, i) {
176 if (c || (o = "next"), t = i[o]) {
177 if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
178 if (!t.done) return t;
179 u = t.value, c < 2 && (c = 0);
180 } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
181 i = e;
182 } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
183 } catch (t) {
184 i = e, c = 1, u = t;
185 } finally {
186 f = 1;
187 }
188 }
189 return {
190 value: t,
191 done: y
192 };
193 };
194 }(r, o, i), !0), u;
195 }
196 var a = {};
197 function Generator() {}
198 function GeneratorFunction() {}
199 function GeneratorFunctionPrototype() {}
200 t = Object.getPrototypeOf;
201 var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function() {
202 return this;
203 }), t);
204 var u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
205 function f(e) {
206 return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
207 }
208 return GeneratorFunction.prototype = GeneratorFunctionPrototype, regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), regeneratorDefine(u), regeneratorDefine(u, o, "Generator"), regeneratorDefine(u, n, function() {
209 return this;
210 }), regeneratorDefine(u, "toString", function() {
211 return "[object Generator]";
212 }), (module.exports = _regenerator = function _regenerator() {
213 return {
214 w: i,
215 m: f
216 };
217 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
218 }
219 module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
220 }));
221
222 //#endregion
223 //#region node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js
224 var require_regeneratorAsyncIterator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
225 var OverloadYield = require_OverloadYield();
226 var regeneratorDefine = require_regeneratorDefine();
227 function AsyncIterator(t, e) {
228 function n(r, o, i, f) {
229 try {
230 var c = t[r](o);
231 var u = c.value;
232 return u instanceof OverloadYield ? e.resolve(u.v).then(function(t) {
233 n("next", t, i, f);
234 }, function(t) {
235 n("throw", t, i, f);
236 }) : e.resolve(u).then(function(t) {
237 c.value = t, i(c);
238 }, function(t) {
239 return n("throw", t, i, f);
240 });
241 } catch (t) {
242 f(t);
243 }
244 }
245 var r;
246 this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function() {
247 return this;
248 })), regeneratorDefine(this, "_invoke", function(t, o, i) {
249 function f() {
250 return new e(function(e, r) {
251 n(t, i, e, r);
252 });
253 }
254 return r = r ? r.then(f, f) : f();
255 }, !0);
256 }
257 module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
258 }));
259
260 //#endregion
261 //#region node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js
262 var require_regeneratorAsyncGen = /* @__PURE__ */ __commonJSMin(((exports, module) => {
263 var regenerator = require_regenerator$1();
264 var regeneratorAsyncIterator = require_regeneratorAsyncIterator();
265 function _regeneratorAsyncGen(r, e, t, o, n) {
266 return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
267 }
268 module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
269 }));
270
271 //#endregion
272 //#region node_modules/@babel/runtime/helpers/regeneratorAsync.js
273 var require_regeneratorAsync = /* @__PURE__ */ __commonJSMin(((exports, module) => {
274 var regeneratorAsyncGen = require_regeneratorAsyncGen();
275 function _regeneratorAsync(n, e, r, t, o) {
276 var a = regeneratorAsyncGen(n, e, r, t, o);
277 return a.next().then(function(n) {
278 return n.done ? n.value : a.next();
279 });
280 }
281 module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
282 }));
283
284 //#endregion
285 //#region node_modules/@babel/runtime/helpers/regeneratorKeys.js
286 var require_regeneratorKeys = /* @__PURE__ */ __commonJSMin(((exports, module) => {
287 function _regeneratorKeys(e) {
288 var n = Object(e);
289 var r = [];
290 for (var t in n) r.unshift(t);
291 return function e() {
292 for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
293 return e.done = !0, e;
294 };
295 }
296 module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
297 }));
298
299 //#endregion
300 //#region node_modules/@babel/runtime/helpers/typeof.js
301 var require_typeof = /* @__PURE__ */ __commonJSMin(((exports, module) => {
302 function _typeof(o) {
303 "@babel/helpers - typeof";
304 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
305 return typeof o;
306 } : function(o) {
307 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
308 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
309 }
310 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
311 }));
312
313 //#endregion
314 //#region node_modules/@babel/runtime/helpers/regeneratorValues.js
315 var require_regeneratorValues = /* @__PURE__ */ __commonJSMin(((exports, module) => {
316 var _typeof = require_typeof()["default"];
317 function _regeneratorValues(e) {
318 if (null != e) {
319 var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"];
320 var r = 0;
321 if (t) return t.call(e);
322 if ("function" == typeof e.next) return e;
323 if (!isNaN(e.length)) return { next: function next() {
324 return e && r >= e.length && (e = void 0), {
325 value: e && e[r++],
326 done: !e
327 };
328 } };
329 }
330 throw new TypeError(_typeof(e) + " is not iterable");
331 }
332 module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
333 }));
334
335 //#endregion
336 //#region node_modules/@babel/runtime/helpers/regeneratorRuntime.js
337 var require_regeneratorRuntime = /* @__PURE__ */ __commonJSMin(((exports, module) => {
338 var OverloadYield = require_OverloadYield();
339 var regenerator = require_regenerator$1();
340 var regeneratorAsync = require_regeneratorAsync();
341 var regeneratorAsyncGen = require_regeneratorAsyncGen();
342 var regeneratorAsyncIterator = require_regeneratorAsyncIterator();
343 var regeneratorKeys = require_regeneratorKeys();
344 var regeneratorValues = require_regeneratorValues();
345 function _regeneratorRuntime() {
346 "use strict";
347 var r = regenerator();
348 var e = r.m(_regeneratorRuntime);
349 var t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
350 function n(r) {
351 var e = "function" == typeof r && r.constructor;
352 return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
353 }
354 var o = {
355 "throw": 1,
356 "return": 2,
357 "break": 3,
358 "continue": 3
359 };
360 function a(r) {
361 var e;
362 var t;
363 return function(n) {
364 e || (e = {
365 stop: function stop() {
366 return t(n.a, 2);
367 },
368 "catch": function _catch() {
369 return n.v;
370 },
371 abrupt: function abrupt(r, e) {
372 return t(n.a, o[r], e);
373 },
374 delegateYield: function delegateYield(r, o, a) {
375 return e.resultName = o, t(n.d, regeneratorValues(r), a);
376 },
377 finish: function finish(r) {
378 return t(n.f, r);
379 }
380 }, t = function t(r, _t, o) {
381 n.p = e.prev, n.n = e.next;
382 try {
383 return r(_t, o);
384 } finally {
385 e.next = n.n;
386 }
387 }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
388 try {
389 return r.call(this, e);
390 } finally {
391 n.p = e.prev, n.n = e.next;
392 }
393 };
394 }
395 return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
396 return {
397 wrap: function wrap(e, t, n, o) {
398 return r.w(a(e), t, n, o && o.reverse());
399 },
400 isGeneratorFunction: n,
401 mark: r.m,
402 awrap: function awrap(r, e) {
403 return new OverloadYield(r, e);
404 },
405 AsyncIterator: regeneratorAsyncIterator,
406 async: function async(r, e, t, o, u) {
407 return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
408 },
409 keys: regeneratorKeys,
410 values: regeneratorValues
411 };
412 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
413 }
414 module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
415 }));
416
417 //#endregion
418 //#region node_modules/@babel/runtime/regenerator/index.js
419 var require_regenerator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
420 var runtime = require_regeneratorRuntime()();
421 module.exports = runtime;
422 try {
423 regeneratorRuntime = runtime;
424 } catch (accidentalStrictMode) {
425 if (typeof globalThis === "object") globalThis.regeneratorRuntime = runtime;
426 else Function("r", "regeneratorRuntime = r")(runtime);
427 }
428 }));
429
430 //#endregion
431 //#region \0@[email protected]/helpers/esm/objectWithoutPropertiesLoose.js
432 function _objectWithoutPropertiesLoose$1(r, e) {
433 if (null == r) return {};
434 var t = {};
435 for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
436 if (e.includes(n)) continue;
437 t[n] = r[n];
438 }
439 return t;
440 }
441 var init_objectWithoutPropertiesLoose$1 = __esmMin((() => {
442 __name(_objectWithoutPropertiesLoose$1, "_objectWithoutPropertiesLoose");
443 }));
444
445 //#endregion
446 //#region \0@[email protected]/helpers/esm/objectWithoutProperties.js
447 function _objectWithoutProperties$1(e, t) {
448 if (null == e) return {};
449 var o;
450 var r;
451 var i = _objectWithoutPropertiesLoose$1(e, t);
452 if (Object.getOwnPropertySymbols) {
453 var s = Object.getOwnPropertySymbols(e);
454 for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
455 }
456 return i;
457 }
458 var init_objectWithoutProperties$1 = __esmMin((() => {
459 init_objectWithoutPropertiesLoose$1();
460 __name(_objectWithoutProperties$1, "_objectWithoutProperties");
461 }));
462
463 //#endregion
464 //#region \0@[email protected]/helpers/esm/typeof.js
465 function _typeof$1(o) {
466 "@babel/helpers - typeof";
467 return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
468 return typeof o;
469 } : function(o) {
470 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
471 }, _typeof$1(o);
472 }
473 var init_typeof$1 = __esmMin((() => {
474 __name(_typeof$1, "_typeof");
475 }));
476
477 //#endregion
478 //#region \0@[email protected]/helpers/esm/toPrimitive.js
479 function toPrimitive$1(t, r) {
480 if ("object" != _typeof$1(t) || !t) return t;
481 var e = t[Symbol.toPrimitive];
482 if (void 0 !== e) {
483 var i = e.call(t, r || "default");
484 if ("object" != _typeof$1(i)) return i;
485 throw new TypeError("@@toPrimitive must return a primitive value.");
486 }
487 return ("string" === r ? String : Number)(t);
488 }
489 var init_toPrimitive$1 = __esmMin((() => {
490 init_typeof$1();
491 __name(toPrimitive$1, "toPrimitive");
492 }));
493
494 //#endregion
495 //#region \0@[email protected]/helpers/esm/toPropertyKey.js
496 function toPropertyKey$1(t) {
497 var i = toPrimitive$1(t, "string");
498 return "symbol" == _typeof$1(i) ? i : i + "";
499 }
500 var init_toPropertyKey$1 = __esmMin((() => {
501 init_typeof$1();
502 init_toPrimitive$1();
503 __name(toPropertyKey$1, "toPropertyKey");
504 }));
505
506 //#endregion
507 //#region \0@[email protected]/helpers/esm/defineProperty.js
508 function _defineProperty$1(e, r, t) {
509 return (r = toPropertyKey$1(r)) in e ? Object.defineProperty(e, r, {
510 value: t,
511 enumerable: !0,
512 configurable: !0,
513 writable: !0
514 }) : e[r] = t, e;
515 }
516 var init_defineProperty$1 = __esmMin((() => {
517 init_toPropertyKey$1();
518 __name(_defineProperty$1, "_defineProperty");
519 }));
520
521 //#endregion
522 //#region \0@[email protected]/helpers/esm/objectSpread2.js
523 function ownKeys$33(e, r) {
524 var t = Object.keys(e);
525 if (Object.getOwnPropertySymbols) {
526 var o = Object.getOwnPropertySymbols(e);
527 r && (o = o.filter(function(r) {
528 return Object.getOwnPropertyDescriptor(e, r).enumerable;
529 })), t.push.apply(t, o);
530 }
531 return t;
532 }
533 function _objectSpread2(e) {
534 for (var r = 1; r < arguments.length; r++) {
535 var t = null != arguments[r] ? arguments[r] : {};
536 r % 2 ? ownKeys$33(Object(t), !0).forEach(function(r) {
537 _defineProperty$1(e, r, t[r]);
538 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$33(Object(t)).forEach(function(r) {
539 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
540 });
541 }
542 return e;
543 }
544 var init_objectSpread2 = __esmMin((() => {
545 init_defineProperty$1();
546 __name(ownKeys$33, "ownKeys");
547 }));
548
549 //#endregion
550 //#region node_modules/react-dom/client.js
551 var require_client = /* @__PURE__ */ __commonJSMin(((exports) => {
552 var m$1 = (globalThis.ReactDOM);
553 var i = m$1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
554 exports.createRoot = function(c, o) {
555 i.usingClientEntryPoint = true;
556 try {
557 return m$1.createRoot(c, o);
558 } finally {
559 i.usingClientEntryPoint = false;
560 }
561 };
562 }));
563
564 //#endregion
565 //#region node_modules/@wordpress/element/build-module/react-platform.js
566 /**
567 * External dependencies
568 */
569 var import_client = require_client();
570
571 //#endregion
572 //#region node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
573 function _arrayWithHoles(r) {
574 if (Array.isArray(r)) return r;
575 }
576 var init_arrayWithHoles = __esmMin((() => {}));
577
578 //#endregion
579 //#region node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
580 function _iterableToArrayLimit(r, l) {
581 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
582 if (null != t) {
583 var e;
584 var n;
585 var i;
586 var u;
587 var a = [];
588 var f = !0;
589 var o = !1;
590 try {
591 if (i = (t = t.call(r)).next, 0 === l) {
592 if (Object(t) !== t) return;
593 f = !1;
594 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
595 } catch (r) {
596 o = !0, n = r;
597 } finally {
598 try {
599 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
600 } finally {
601 if (o) throw n;
602 }
603 }
604 return a;
605 }
606 }
607 var init_iterableToArrayLimit = __esmMin((() => {}));
608
609 //#endregion
610 //#region node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
611 function _arrayLikeToArray$2(r, a) {
612 (null == a || a > r.length) && (a = r.length);
613 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
614 return n;
615 }
616 var init_arrayLikeToArray = __esmMin((() => {
617 __name(_arrayLikeToArray$2, "_arrayLikeToArray");
618 }));
619
620 //#endregion
621 //#region node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
622 function _unsupportedIterableToArray$2(r, a) {
623 if (r) {
624 if ("string" == typeof r) return _arrayLikeToArray$2(r, a);
625 var t = {}.toString.call(r).slice(8, -1);
626 return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$2(r, a) : void 0;
627 }
628 }
629 var init_unsupportedIterableToArray = __esmMin((() => {
630 init_arrayLikeToArray();
631 __name(_unsupportedIterableToArray$2, "_unsupportedIterableToArray");
632 }));
633
634 //#endregion
635 //#region node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
636 function _nonIterableRest() {
637 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
638 }
639 var init_nonIterableRest = __esmMin((() => {}));
640
641 //#endregion
642 //#region node_modules/@babel/runtime/helpers/esm/slicedToArray.js
643 function _slicedToArray(r, e) {
644 return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$2(r, e) || _nonIterableRest();
645 }
646 var init_slicedToArray = __esmMin((() => {
647 init_arrayWithHoles();
648 init_iterableToArrayLimit();
649 init_unsupportedIterableToArray();
650 init_nonIterableRest();
651 }));
652
653 //#endregion
654 //#region node_modules/prop-types/node_modules/react-is/cjs/react-is.development.js
655 /** @license React v16.13.1
656 * react-is.development.js
657 *
658 * Copyright (c) Facebook, Inc. and its affiliates.
659 *
660 * This source code is licensed under the MIT license found in the
661 * LICENSE file in the root directory of this source tree.
662 */
663 var require_react_is_development$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
664 (function() {
665 "use strict";
666 var hasSymbol = typeof Symbol === "function" && Symbol.for;
667 var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103;
668 var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106;
669 var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107;
670 var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108;
671 var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114;
672 var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109;
673 var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110;
674 var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for("react.async_mode") : 60111;
675 var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for("react.concurrent_mode") : 60111;
676 var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112;
677 var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113;
678 var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for("react.suspense_list") : 60120;
679 var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115;
680 var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116;
681 var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121;
682 var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for("react.fundamental") : 60117;
683 var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for("react.responder") : 60118;
684 var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for("react.scope") : 60119;
685 function isValidElementType(type) {
686 return typeof type === "string" || typeof type === "function" || type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === "object" && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
687 }
688 function typeOf(object) {
689 if (typeof object === "object" && object !== null) {
690 var $$typeof = object.$$typeof;
691 switch ($$typeof) {
692 case REACT_ELEMENT_TYPE:
693 var type = object.type;
694 switch (type) {
695 case REACT_ASYNC_MODE_TYPE:
696 case REACT_CONCURRENT_MODE_TYPE:
697 case REACT_FRAGMENT_TYPE:
698 case REACT_PROFILER_TYPE:
699 case REACT_STRICT_MODE_TYPE:
700 case REACT_SUSPENSE_TYPE: return type;
701 default:
702 var $$typeofType = type && type.$$typeof;
703 switch ($$typeofType) {
704 case REACT_CONTEXT_TYPE:
705 case REACT_FORWARD_REF_TYPE:
706 case REACT_LAZY_TYPE:
707 case REACT_MEMO_TYPE:
708 case REACT_PROVIDER_TYPE: return $$typeofType;
709 default: return $$typeof;
710 }
711 }
712 case REACT_PORTAL_TYPE: return $$typeof;
713 }
714 }
715 }
716 var AsyncMode = REACT_ASYNC_MODE_TYPE;
717 var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
718 var ContextConsumer = REACT_CONTEXT_TYPE;
719 var ContextProvider = REACT_PROVIDER_TYPE;
720 var Element = REACT_ELEMENT_TYPE;
721 var ForwardRef = REACT_FORWARD_REF_TYPE;
722 var Fragment = REACT_FRAGMENT_TYPE;
723 var Lazy = REACT_LAZY_TYPE;
724 var Memo = REACT_MEMO_TYPE;
725 var Portal = REACT_PORTAL_TYPE;
726 var Profiler = REACT_PROFILER_TYPE;
727 var StrictMode = REACT_STRICT_MODE_TYPE;
728 var Suspense = REACT_SUSPENSE_TYPE;
729 var hasWarnedAboutDeprecatedIsAsyncMode = false;
730 function isAsyncMode(object) {
731 if (!hasWarnedAboutDeprecatedIsAsyncMode) {
732 hasWarnedAboutDeprecatedIsAsyncMode = true;
733 console["warn"]("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.");
734 }
735 return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
736 }
737 function isConcurrentMode(object) {
738 return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
739 }
740 function isContextConsumer(object) {
741 return typeOf(object) === REACT_CONTEXT_TYPE;
742 }
743 function isContextProvider(object) {
744 return typeOf(object) === REACT_PROVIDER_TYPE;
745 }
746 function isElement(object) {
747 return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
748 }
749 function isForwardRef(object) {
750 return typeOf(object) === REACT_FORWARD_REF_TYPE;
751 }
752 function isFragment(object) {
753 return typeOf(object) === REACT_FRAGMENT_TYPE;
754 }
755 function isLazy(object) {
756 return typeOf(object) === REACT_LAZY_TYPE;
757 }
758 function isMemo(object) {
759 return typeOf(object) === REACT_MEMO_TYPE;
760 }
761 function isPortal(object) {
762 return typeOf(object) === REACT_PORTAL_TYPE;
763 }
764 function isProfiler(object) {
765 return typeOf(object) === REACT_PROFILER_TYPE;
766 }
767 function isStrictMode(object) {
768 return typeOf(object) === REACT_STRICT_MODE_TYPE;
769 }
770 function isSuspense(object) {
771 return typeOf(object) === REACT_SUSPENSE_TYPE;
772 }
773 exports.AsyncMode = AsyncMode;
774 exports.ConcurrentMode = ConcurrentMode;
775 exports.ContextConsumer = ContextConsumer;
776 exports.ContextProvider = ContextProvider;
777 exports.Element = Element;
778 exports.ForwardRef = ForwardRef;
779 exports.Fragment = Fragment;
780 exports.Lazy = Lazy;
781 exports.Memo = Memo;
782 exports.Portal = Portal;
783 exports.Profiler = Profiler;
784 exports.StrictMode = StrictMode;
785 exports.Suspense = Suspense;
786 exports.isAsyncMode = isAsyncMode;
787 exports.isConcurrentMode = isConcurrentMode;
788 exports.isContextConsumer = isContextConsumer;
789 exports.isContextProvider = isContextProvider;
790 exports.isElement = isElement;
791 exports.isForwardRef = isForwardRef;
792 exports.isFragment = isFragment;
793 exports.isLazy = isLazy;
794 exports.isMemo = isMemo;
795 exports.isPortal = isPortal;
796 exports.isProfiler = isProfiler;
797 exports.isStrictMode = isStrictMode;
798 exports.isSuspense = isSuspense;
799 exports.isValidElementType = isValidElementType;
800 exports.typeOf = typeOf;
801 })();
802 }));
803
804 //#endregion
805 //#region node_modules/prop-types/node_modules/react-is/index.js
806 var require_react_is$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
807 module.exports = require_react_is_development$1();
808 }));
809
810 //#endregion
811 //#region node_modules/object-assign/index.js
812 /*
813 object-assign
814 (c) Sindre Sorhus
815 @license MIT
816 */
817 var require_object_assign = /* @__PURE__ */ __commonJSMin(((exports, module) => {
818 var getOwnPropertySymbols = Object.getOwnPropertySymbols;
819 var hasOwnProperty = Object.prototype.hasOwnProperty;
820 var propIsEnumerable = Object.prototype.propertyIsEnumerable;
821 function toObject(val) {
822 if (val === null || val === void 0) throw new TypeError("Object.assign cannot be called with null or undefined");
823 return Object(val);
824 }
825 function shouldUseNative() {
826 try {
827 if (!Object.assign) return false;
828 var test1 = /* @__PURE__ */ new String("abc");
829 test1[5] = "de";
830 if (Object.getOwnPropertyNames(test1)[0] === "5") return false;
831 var test2 = {};
832 for (var i = 0; i < 10; i++) test2["_" + String.fromCharCode(i)] = i;
833 if (Object.getOwnPropertyNames(test2).map(function(n) {
834 return test2[n];
835 }).join("") !== "0123456789") return false;
836 var test3 = {};
837 "abcdefghijklmnopqrst".split("").forEach(function(letter) {
838 test3[letter] = letter;
839 });
840 if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") return false;
841 return true;
842 } catch (err) {
843 return false;
844 }
845 }
846 module.exports = shouldUseNative() ? Object.assign : function(target, source) {
847 var from;
848 var to = toObject(target);
849 var symbols;
850 for (var s = 1; s < arguments.length; s++) {
851 from = Object(arguments[s]);
852 for (var key in from) if (hasOwnProperty.call(from, key)) to[key] = from[key];
853 if (getOwnPropertySymbols) {
854 symbols = getOwnPropertySymbols(from);
855 for (var i = 0; i < symbols.length; i++) if (propIsEnumerable.call(from, symbols[i])) to[symbols[i]] = from[symbols[i]];
856 }
857 }
858 return to;
859 };
860 }));
861
862 //#endregion
863 //#region node_modules/prop-types/lib/ReactPropTypesSecret.js
864 /**
865 * Copyright (c) 2013-present, Facebook, Inc.
866 *
867 * This source code is licensed under the MIT license found in the
868 * LICENSE file in the root directory of this source tree.
869 */
870 var require_ReactPropTypesSecret = /* @__PURE__ */ __commonJSMin(((exports, module) => {
871 var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
872 module.exports = ReactPropTypesSecret;
873 }));
874
875 //#endregion
876 //#region node_modules/prop-types/lib/has.js
877 var require_has = /* @__PURE__ */ __commonJSMin(((exports, module) => {
878 module.exports = Function.call.bind(Object.prototype.hasOwnProperty);
879 }));
880
881 //#endregion
882 //#region node_modules/prop-types/checkPropTypes.js
883 /**
884 * Copyright (c) 2013-present, Facebook, Inc.
885 *
886 * This source code is licensed under the MIT license found in the
887 * LICENSE file in the root directory of this source tree.
888 */
889 var require_checkPropTypes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
890 var printWarning = function() {};
891 var ReactPropTypesSecret = require_ReactPropTypesSecret();
892 var loggedTypeFailures = {};
893 var has = require_has();
894 printWarning = function(text) {
895 var message = "Warning: " + text;
896 if (typeof console !== "undefined") console.error(message);
897 try {
898 throw new Error(message);
899 } catch (x) {}
900 };
901 /**
902 * Assert that the values match with the type specs.
903 * Error messages are memorized and will only be shown once.
904 *
905 * @param {object} typeSpecs Map of name to a ReactPropType
906 * @param {object} values Runtime values that need to be type-checked
907 * @param {string} location e.g. "prop", "context", "child context"
908 * @param {string} componentName Name of the component for error messages.
909 * @param {?Function} getStack Returns the component stack.
910 * @private
911 */
912 function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
913 for (var typeSpecName in typeSpecs) if (has(typeSpecs, typeSpecName)) {
914 var error;
915 try {
916 if (typeof typeSpecs[typeSpecName] !== "function") {
917 var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
918 err.name = "Invariant Violation";
919 throw err;
920 }
921 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
922 } catch (ex) {
923 error = ex;
924 }
925 if (error && !(error instanceof Error)) printWarning((componentName || "React class") + ": type specification of " + location + " `" + typeSpecName + "` is invalid; the type checker function must return `null` or an `Error` but returned a " + typeof error + ". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).");
926 if (error instanceof Error && !(error.message in loggedTypeFailures)) {
927 loggedTypeFailures[error.message] = true;
928 var stack = getStack ? getStack() : "";
929 printWarning("Failed " + location + " type: " + error.message + (stack != null ? stack : ""));
930 }
931 }
932 }
933 /**
934 * Resets warning cache when testing.
935 *
936 * @private
937 */
938 checkPropTypes.resetWarningCache = function() {
939 loggedTypeFailures = {};
940 };
941 module.exports = checkPropTypes;
942 }));
943
944 //#endregion
945 //#region node_modules/prop-types/factoryWithTypeCheckers.js
946 /**
947 * Copyright (c) 2013-present, Facebook, Inc.
948 *
949 * This source code is licensed under the MIT license found in the
950 * LICENSE file in the root directory of this source tree.
951 */
952 var require_factoryWithTypeCheckers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
953 var ReactIs = require_react_is$1();
954 var assign = require_object_assign();
955 var ReactPropTypesSecret = require_ReactPropTypesSecret();
956 var has = require_has();
957 var checkPropTypes = require_checkPropTypes();
958 var printWarning = function() {};
959 printWarning = function(text) {
960 var message = "Warning: " + text;
961 if (typeof console !== "undefined") console.error(message);
962 try {
963 throw new Error(message);
964 } catch (x) {}
965 };
966 function emptyFunctionThatReturnsNull() {
967 return null;
968 }
969 module.exports = function(isValidElement, throwOnDirectAccess) {
970 var ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
971 var FAUX_ITERATOR_SYMBOL = "@@iterator";
972 /**
973 * Returns the iterator method function contained on the iterable object.
974 *
975 * Be sure to invoke the function with the iterable as context:
976 *
977 * var iteratorFn = getIteratorFn(myIterable);
978 * if (iteratorFn) {
979 * var iterator = iteratorFn.call(myIterable);
980 * ...
981 * }
982 *
983 * @param {?object} maybeIterable
984 * @return {?function}
985 */
986 function getIteratorFn(maybeIterable) {
987 var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
988 if (typeof iteratorFn === "function") return iteratorFn;
989 }
990 /**
991 * Collection of methods that allow declaration and validation of props that are
992 * supplied to React components. Example usage:
993 *
994 * var Props = require('ReactPropTypes');
995 * var MyArticle = React.createClass({
996 * propTypes: {
997 * // An optional string prop named "description".
998 * description: Props.string,
999 *
1000 * // A required enum prop named "category".
1001 * category: Props.oneOf(['News','Photos']).isRequired,
1002 *
1003 * // A prop named "dialog" that requires an instance of Dialog.
1004 * dialog: Props.instanceOf(Dialog).isRequired
1005 * },
1006 * render: function() { ... }
1007 * });
1008 *
1009 * A more formal specification of how these methods are used:
1010 *
1011 * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
1012 * decl := ReactPropTypes.{type}(.isRequired)?
1013 *
1014 * Each and every declaration produces a function with the same signature. This
1015 * allows the creation of custom validation functions. For example:
1016 *
1017 * var MyLink = React.createClass({
1018 * propTypes: {
1019 * // An optional string or URI prop named "href".
1020 * href: function(props, propName, componentName) {
1021 * var propValue = props[propName];
1022 * if (propValue != null && typeof propValue !== 'string' &&
1023 * !(propValue instanceof URI)) {
1024 * return new Error(
1025 * 'Expected a string or an URI for ' + propName + ' in ' +
1026 * componentName
1027 * );
1028 * }
1029 * }
1030 * },
1031 * render: function() {...}
1032 * });
1033 *
1034 * @internal
1035 */
1036 var ANONYMOUS = "<<anonymous>>";
1037 var ReactPropTypes = {
1038 array: createPrimitiveTypeChecker("array"),
1039 bigint: createPrimitiveTypeChecker("bigint"),
1040 bool: createPrimitiveTypeChecker("boolean"),
1041 func: createPrimitiveTypeChecker("function"),
1042 number: createPrimitiveTypeChecker("number"),
1043 object: createPrimitiveTypeChecker("object"),
1044 string: createPrimitiveTypeChecker("string"),
1045 symbol: createPrimitiveTypeChecker("symbol"),
1046 any: createAnyTypeChecker(),
1047 arrayOf: createArrayOfTypeChecker,
1048 element: createElementTypeChecker(),
1049 elementType: createElementTypeTypeChecker(),
1050 instanceOf: createInstanceTypeChecker,
1051 node: createNodeChecker(),
1052 objectOf: createObjectOfTypeChecker,
1053 oneOf: createEnumTypeChecker,
1054 oneOfType: createUnionTypeChecker,
1055 shape: createShapeTypeChecker,
1056 exact: createStrictShapeTypeChecker
1057 };
1058 /**
1059 * inlined Object.is polyfill to avoid requiring consumers ship their own
1060 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
1061 */
1062 function is(x, y) {
1063 if (x === y) return x !== 0 || 1 / x === 1 / y;
1064 else return x !== x && y !== y;
1065 }
1066 /**
1067 * We use an Error-like object for backward compatibility as people may call
1068 * PropTypes directly and inspect their output. However, we don't use real
1069 * Errors anymore. We don't inspect their stack anyway, and creating them
1070 * is prohibitively expensive if they are created too often, such as what
1071 * happens in oneOfType() for any type before the one that matched.
1072 */
1073 function PropTypeError(message, data) {
1074 this.message = message;
1075 this.data = data && typeof data === "object" ? data : {};
1076 this.stack = "";
1077 }
1078 PropTypeError.prototype = Error.prototype;
1079 function createChainableTypeChecker(validate) {
1080 var manualPropTypeCallCache = {};
1081 var manualPropTypeWarningCount = 0;
1082 function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
1083 componentName = componentName || ANONYMOUS;
1084 propFullName = propFullName || propName;
1085 if (secret !== ReactPropTypesSecret) {
1086 if (throwOnDirectAccess) {
1087 var err = /* @__PURE__ */ new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");
1088 err.name = "Invariant Violation";
1089 throw err;
1090 } else if (typeof console !== "undefined") {
1091 var cacheKey = componentName + ":" + propName;
1092 if (!manualPropTypeCallCache[cacheKey] && manualPropTypeWarningCount < 3) {
1093 printWarning("You are manually calling a React.PropTypes validation function for the `" + propFullName + "` prop on `" + componentName + "`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.");
1094 manualPropTypeCallCache[cacheKey] = true;
1095 manualPropTypeWarningCount++;
1096 }
1097 }
1098 }
1099 if (props[propName] == null) {
1100 if (isRequired) {
1101 if (props[propName] === null) return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required " + ("in `" + componentName + "`, but its value is `null`."));
1102 return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required in " + ("`" + componentName + "`, but its value is `undefined`."));
1103 }
1104 return null;
1105 } else return validate(props, propName, componentName, location, propFullName);
1106 }
1107 var chainedCheckType = checkType.bind(null, false);
1108 chainedCheckType.isRequired = checkType.bind(null, true);
1109 return chainedCheckType;
1110 }
1111 function createPrimitiveTypeChecker(expectedType) {
1112 function validate(props, propName, componentName, location, propFullName, secret) {
1113 var propValue = props[propName];
1114 if (getPropType(propValue) !== expectedType) {
1115 var preciseType = getPreciseType(propValue);
1116 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + preciseType + "` supplied to `" + componentName + "`, expected ") + ("`" + expectedType + "`."), { expectedType });
1117 }
1118 return null;
1119 }
1120 return createChainableTypeChecker(validate);
1121 }
1122 function createAnyTypeChecker() {
1123 return createChainableTypeChecker(emptyFunctionThatReturnsNull);
1124 }
1125 function createArrayOfTypeChecker(typeChecker) {
1126 function validate(props, propName, componentName, location, propFullName) {
1127 if (typeof typeChecker !== "function") return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside arrayOf.");
1128 var propValue = props[propName];
1129 if (!Array.isArray(propValue)) {
1130 var propType = getPropType(propValue);
1131 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an array."));
1132 }
1133 for (var i = 0; i < propValue.length; i++) {
1134 var error = typeChecker(propValue, i, componentName, location, propFullName + "[" + i + "]", ReactPropTypesSecret);
1135 if (error instanceof Error) return error;
1136 }
1137 return null;
1138 }
1139 return createChainableTypeChecker(validate);
1140 }
1141 function createElementTypeChecker() {
1142 function validate(props, propName, componentName, location, propFullName) {
1143 var propValue = props[propName];
1144 if (!isValidElement(propValue)) {
1145 var propType = getPropType(propValue);
1146 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement."));
1147 }
1148 return null;
1149 }
1150 return createChainableTypeChecker(validate);
1151 }
1152 function createElementTypeTypeChecker() {
1153 function validate(props, propName, componentName, location, propFullName) {
1154 var propValue = props[propName];
1155 if (!ReactIs.isValidElementType(propValue)) {
1156 var propType = getPropType(propValue);
1157 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement type."));
1158 }
1159 return null;
1160 }
1161 return createChainableTypeChecker(validate);
1162 }
1163 function createInstanceTypeChecker(expectedClass) {
1164 function validate(props, propName, componentName, location, propFullName) {
1165 if (!(props[propName] instanceof expectedClass)) {
1166 var expectedClassName = expectedClass.name || ANONYMOUS;
1167 var actualClassName = getClassName(props[propName]);
1168 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + actualClassName + "` supplied to `" + componentName + "`, expected ") + ("instance of `" + expectedClassName + "`."));
1169 }
1170 return null;
1171 }
1172 return createChainableTypeChecker(validate);
1173 }
1174 function createEnumTypeChecker(expectedValues) {
1175 if (!Array.isArray(expectedValues)) {
1176 if (arguments.length > 1) printWarning("Invalid arguments supplied to oneOf, expected an array, got " + arguments.length + " arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).");
1177 else printWarning("Invalid argument supplied to oneOf, expected an array.");
1178 return emptyFunctionThatReturnsNull;
1179 }
1180 function validate(props, propName, componentName, location, propFullName) {
1181 var propValue = props[propName];
1182 for (var i = 0; i < expectedValues.length; i++) if (is(propValue, expectedValues[i])) return null;
1183 var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
1184 if (getPreciseType(value) === "symbol") return String(value);
1185 return value;
1186 });
1187 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of value `" + String(propValue) + "` " + ("supplied to `" + componentName + "`, expected one of " + valuesString + "."));
1188 }
1189 return createChainableTypeChecker(validate);
1190 }
1191 function createObjectOfTypeChecker(typeChecker) {
1192 function validate(props, propName, componentName, location, propFullName) {
1193 if (typeof typeChecker !== "function") return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside objectOf.");
1194 var propValue = props[propName];
1195 var propType = getPropType(propValue);
1196 if (propType !== "object") return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an object."));
1197 for (var key in propValue) if (has(propValue, key)) {
1198 var error = typeChecker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
1199 if (error instanceof Error) return error;
1200 }
1201 return null;
1202 }
1203 return createChainableTypeChecker(validate);
1204 }
1205 function createUnionTypeChecker(arrayOfTypeCheckers) {
1206 if (!Array.isArray(arrayOfTypeCheckers)) {
1207 printWarning("Invalid argument supplied to oneOfType, expected an instance of array.");
1208 return emptyFunctionThatReturnsNull;
1209 }
1210 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
1211 var checker = arrayOfTypeCheckers[i];
1212 if (typeof checker !== "function") {
1213 printWarning("Invalid argument supplied to oneOfType. Expected an array of check functions, but received " + getPostfixForTypeWarning(checker) + " at index " + i + ".");
1214 return emptyFunctionThatReturnsNull;
1215 }
1216 }
1217 function validate(props, propName, componentName, location, propFullName) {
1218 var expectedTypes = [];
1219 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
1220 var checker = arrayOfTypeCheckers[i];
1221 var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
1222 if (checkerResult == null) return null;
1223 if (checkerResult.data && has(checkerResult.data, "expectedType")) expectedTypes.push(checkerResult.data.expectedType);
1224 }
1225 var expectedTypesMessage = expectedTypes.length > 0 ? ", expected one of type [" + expectedTypes.join(", ") + "]" : "";
1226 return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`" + expectedTypesMessage + "."));
1227 }
1228 return createChainableTypeChecker(validate);
1229 }
1230 function createNodeChecker() {
1231 function validate(props, propName, componentName, location, propFullName) {
1232 if (!isNode(props[propName])) return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`, expected a ReactNode."));
1233 return null;
1234 }
1235 return createChainableTypeChecker(validate);
1236 }
1237 function invalidValidatorError(componentName, location, propFullName, key, type) {
1238 return new PropTypeError((componentName || "React class") + ": " + location + " type `" + propFullName + "." + key + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + type + "`.");
1239 }
1240 function createShapeTypeChecker(shapeTypes) {
1241 function validate(props, propName, componentName, location, propFullName) {
1242 var propValue = props[propName];
1243 var propType = getPropType(propValue);
1244 if (propType !== "object") return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
1245 for (var key in shapeTypes) {
1246 var checker = shapeTypes[key];
1247 if (typeof checker !== "function") return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
1248 var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
1249 if (error) return error;
1250 }
1251 return null;
1252 }
1253 return createChainableTypeChecker(validate);
1254 }
1255 function createStrictShapeTypeChecker(shapeTypes) {
1256 function validate(props, propName, componentName, location, propFullName) {
1257 var propValue = props[propName];
1258 var propType = getPropType(propValue);
1259 if (propType !== "object") return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
1260 for (var key in assign({}, props[propName], shapeTypes)) {
1261 var checker = shapeTypes[key];
1262 if (has(shapeTypes, key) && typeof checker !== "function") return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
1263 if (!checker) return new PropTypeError("Invalid " + location + " `" + propFullName + "` key `" + key + "` supplied to `" + componentName + "`.\nBad object: " + JSON.stringify(props[propName], null, " ") + "\nValid keys: " + JSON.stringify(Object.keys(shapeTypes), null, " "));
1264 var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
1265 if (error) return error;
1266 }
1267 return null;
1268 }
1269 return createChainableTypeChecker(validate);
1270 }
1271 function isNode(propValue) {
1272 switch (typeof propValue) {
1273 case "number":
1274 case "string":
1275 case "undefined": return true;
1276 case "boolean": return !propValue;
1277 case "object":
1278 if (Array.isArray(propValue)) return propValue.every(isNode);
1279 if (propValue === null || isValidElement(propValue)) return true;
1280 var iteratorFn = getIteratorFn(propValue);
1281 if (iteratorFn) {
1282 var iterator = iteratorFn.call(propValue);
1283 var step;
1284 if (iteratorFn !== propValue.entries) {
1285 while (!(step = iterator.next()).done) if (!isNode(step.value)) return false;
1286 } else while (!(step = iterator.next()).done) {
1287 var entry = step.value;
1288 if (entry) {
1289 if (!isNode(entry[1])) return false;
1290 }
1291 }
1292 } else return false;
1293 return true;
1294 default: return false;
1295 }
1296 }
1297 function isSymbol(propType, propValue) {
1298 if (propType === "symbol") return true;
1299 if (!propValue) return false;
1300 if (propValue["@@toStringTag"] === "Symbol") return true;
1301 if (typeof Symbol === "function" && propValue instanceof Symbol) return true;
1302 return false;
1303 }
1304 function getPropType(propValue) {
1305 var propType = typeof propValue;
1306 if (Array.isArray(propValue)) return "array";
1307 if (propValue instanceof RegExp) return "object";
1308 if (isSymbol(propType, propValue)) return "symbol";
1309 return propType;
1310 }
1311 function getPreciseType(propValue) {
1312 if (typeof propValue === "undefined" || propValue === null) return "" + propValue;
1313 var propType = getPropType(propValue);
1314 if (propType === "object") {
1315 if (propValue instanceof Date) return "date";
1316 else if (propValue instanceof RegExp) return "regexp";
1317 }
1318 return propType;
1319 }
1320 function getPostfixForTypeWarning(value) {
1321 var type = getPreciseType(value);
1322 switch (type) {
1323 case "array":
1324 case "object": return "an " + type;
1325 case "boolean":
1326 case "date":
1327 case "regexp": return "a " + type;
1328 default: return type;
1329 }
1330 }
1331 function getClassName(propValue) {
1332 if (!propValue.constructor || !propValue.constructor.name) return ANONYMOUS;
1333 return propValue.constructor.name;
1334 }
1335 ReactPropTypes.checkPropTypes = checkPropTypes;
1336 ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
1337 ReactPropTypes.PropTypes = ReactPropTypes;
1338 return ReactPropTypes;
1339 };
1340 }));
1341
1342 //#endregion
1343 //#region node_modules/prop-types/index.js
1344 var require_prop_types = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1345 var ReactIs = require_react_is$1();
1346 var throwOnDirectAccess = true;
1347 module.exports = require_factoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
1348 }));
1349
1350 //#endregion
1351 //#region modules/ai/assets/js/editor/context/requests-ids.js
1352 var import_prop_types$13, Context, useRequestIds, getUniqueId, RequestIdsProvider;
1353 var init_requests_ids = __esmMin((() => {
1354 init_slicedToArray();
1355 import_prop_types$13 = /* @__PURE__ */ __toESM(require_prop_types());
1356 Context = (0, react.createContext)({});
1357 useRequestIds = function useRequestIds() {
1358 var context = (0, react.useContext)(Context);
1359 if (!context) throw new Error("useRequestIds must be used within a RequestIdsProvider");
1360 return context;
1361 };
1362 getUniqueId = function getUniqueId(prefix) {
1363 return prefix + "-" + Math.random().toString(16).substr(2, 7);
1364 };
1365 window.EDITOR_SESSION_ID = window.EDITOR_SESSION_ID || getUniqueId("editor-session");
1366 RequestIdsProvider = function RequestIdsProvider(props) {
1367 var editorSessionId = (0, react.useRef)(window.EDITOR_SESSION_ID);
1368 var sessionId = (0, react.useRef)("");
1369 var generateId = (0, react.useRef)("");
1370 var batchId = (0, react.useRef)("");
1371 var requestId = (0, react.useRef)("");
1372 sessionId.current = getUniqueId("session");
1373 var setGenerate = function setGenerate() {
1374 generateId.current = getUniqueId("generate");
1375 return generateId;
1376 };
1377 var setBatch = function setBatch() {
1378 batchId.current = getUniqueId("batch");
1379 return batchId;
1380 };
1381 var setRequest = function setRequest() {
1382 requestId.current = getUniqueId("request");
1383 return requestId;
1384 };
1385 var _useState2 = _slicedToArray((0, react.useState)(0), 2);
1386 var usagePercentage = _useState2[0];
1387 var setUsagePercentage = _useState2[1];
1388 return /*#__PURE__*/ react.default.createElement(Context.Provider, { value: {
1389 editorSessionId,
1390 sessionId,
1391 generateId,
1392 batchId,
1393 requestId,
1394 setGenerate,
1395 setBatch,
1396 setRequest,
1397 usagePercentage,
1398 updateUsagePercentage: function updateUsagePercentage(newPercentage) {
1399 setUsagePercentage(newPercentage);
1400 }
1401 } }, props.children);
1402 };
1403 RequestIdsProvider.propTypes = { children: import_prop_types$13.default.node.isRequired };
1404 }));
1405
1406 //#endregion
1407 //#region node_modules/@babel/runtime/helpers/esm/extends.js
1408 function _extends$1() {
1409 return _extends$1 = Object.assign ? Object.assign.bind() : function(n) {
1410 for (var e = 1; e < arguments.length; e++) {
1411 var t = arguments[e];
1412 for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
1413 }
1414 return n;
1415 }, _extends$1.apply(null, arguments);
1416 }
1417 var init_extends = __esmMin((() => {
1418 __name(_extends$1, "_extends");
1419 }));
1420
1421 //#endregion
1422 //#region node_modules/@babel/runtime/helpers/esm/typeof.js
1423 function _typeof(o) {
1424 "@babel/helpers - typeof";
1425 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
1426 return typeof o;
1427 } : function(o) {
1428 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
1429 }, _typeof(o);
1430 }
1431 var init_typeof = __esmMin((() => {}));
1432
1433 //#endregion
1434 //#region node_modules/@babel/runtime/helpers/esm/toPrimitive.js
1435 function toPrimitive(t, r) {
1436 if ("object" != _typeof(t) || !t) return t;
1437 var e = t[Symbol.toPrimitive];
1438 if (void 0 !== e) {
1439 var i = e.call(t, r || "default");
1440 if ("object" != _typeof(i)) return i;
1441 throw new TypeError("@@toPrimitive must return a primitive value.");
1442 }
1443 return ("string" === r ? String : Number)(t);
1444 }
1445 var init_toPrimitive = __esmMin((() => {
1446 init_typeof();
1447 }));
1448
1449 //#endregion
1450 //#region node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
1451 function toPropertyKey(t) {
1452 var i = toPrimitive(t, "string");
1453 return "symbol" == _typeof(i) ? i : i + "";
1454 }
1455 var init_toPropertyKey = __esmMin((() => {
1456 init_typeof();
1457 init_toPrimitive();
1458 }));
1459
1460 //#endregion
1461 //#region node_modules/@babel/runtime/helpers/esm/defineProperty.js
1462 function _defineProperty(e, r, t) {
1463 return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
1464 value: t,
1465 enumerable: !0,
1466 configurable: !0,
1467 writable: !0
1468 }) : e[r] = t, e;
1469 }
1470 var init_defineProperty = __esmMin((() => {
1471 init_toPropertyKey();
1472 }));
1473
1474 //#endregion
1475 //#region node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js
1476 function _objectWithoutPropertiesLoose(r, e) {
1477 if (null == r) return {};
1478 var t = {};
1479 for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
1480 if (-1 !== e.indexOf(n)) continue;
1481 t[n] = r[n];
1482 }
1483 return t;
1484 }
1485 var init_objectWithoutPropertiesLoose = __esmMin((() => {}));
1486
1487 //#endregion
1488 //#region node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js
1489 function _objectWithoutProperties(e, t) {
1490 if (null == e) return {};
1491 var o;
1492 var r;
1493 var i = _objectWithoutPropertiesLoose(e, t);
1494 if (Object.getOwnPropertySymbols) {
1495 var n = Object.getOwnPropertySymbols(e);
1496 for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
1497 }
1498 return i;
1499 }
1500 var init_objectWithoutProperties = __esmMin((() => {
1501 init_objectWithoutPropertiesLoose();
1502 }));
1503
1504 //#endregion
1505 //#region modules/ai/assets/js/editor/components/loader.js
1506 function ownKeys$32(e, r) {
1507 var t = Object.keys(e);
1508 if (Object.getOwnPropertySymbols) {
1509 var o = Object.getOwnPropertySymbols(e);
1510 r && (o = o.filter(function(r) {
1511 return Object.getOwnPropertyDescriptor(e, r).enumerable;
1512 })), t.push.apply(t, o);
1513 }
1514 return t;
1515 }
1516 function _objectSpread$32(e) {
1517 for (var r = 1; r < arguments.length; r++) {
1518 var t = null != arguments[r] ? arguments[r] : {};
1519 r % 2 ? ownKeys$32(Object(t), !0).forEach(function(r) {
1520 _defineProperty(e, r, t[r]);
1521 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$32(Object(t)).forEach(function(r) {
1522 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
1523 });
1524 }
1525 return e;
1526 }
1527 var import_prop_types$12, _excluded$33, Loader;
1528 var init_loader = __esmMin((() => {
1529 init_extends();
1530 init_defineProperty();
1531 init_objectWithoutProperties();
1532 import_prop_types$12 = /* @__PURE__ */ __toESM(require_prop_types());
1533 _excluded$33 = ["sx", "BoxProps"];
1534 __name(ownKeys$32, "ownKeys");
1535 __name(_objectSpread$32, "_objectSpread");
1536 Loader = function Loader(_ref) {
1537 var _ref$sx = _ref.sx;
1538 var sx = _ref$sx === void 0 ? {} : _ref$sx;
1539 var _ref$BoxProps = _ref.BoxProps;
1540 var BoxProps = _ref$BoxProps === void 0 ? {} : _ref$BoxProps;
1541 var props = _objectWithoutProperties(_ref, _excluded$33);
1542 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
1543 width: "100%",
1544 display: "flex",
1545 alignItems: "center"
1546 }, BoxProps, { sx: _objectSpread$32({
1547 px: 1.5,
1548 minHeight: function minHeight(theme) {
1549 return theme.spacing(5);
1550 }
1551 }, BoxProps.sx || {}) }), /*#__PURE__*/ react.default.createElement(_elementor_ui.LinearProgress, _extends$1({ color: "secondary" }, props, { sx: _objectSpread$32({ width: "100%" }, sx) })));
1552 };
1553 Loader.propTypes = {
1554 sx: import_prop_types$12.default.object,
1555 BoxProps: import_prop_types$12.default.object
1556 };
1557 }));
1558
1559 //#endregion
1560 //#region modules/ai/assets/js/editor/components/ui/search-field.js
1561 var import_prop_types$11, StyledTextField$1, SearchField;
1562 var init_search_field = __esmMin((() => {
1563 init_extends();
1564 import_prop_types$11 = /* @__PURE__ */ __toESM(require_prop_types());
1565 StyledTextField$1 = (0, _elementor_ui.styled)(_elementor_ui.TextField)(function() {
1566 return { ".wp-admin & .MuiInputBase-input, & .MuiInputBase-input:focus": {
1567 backgroundColor: "initial",
1568 boxShadow: "none",
1569 border: 0,
1570 color: "inherit",
1571 outline: 0,
1572 /**
1573 * TODO:
1574 * Find a better solution to get the component padding value dynamically or fix the global CSS override.
1575 * These values are taken from Material UI's source code (the left padding reset was added to match the component style).
1576 */
1577 padding: "16.5px 14px 16.5px 0",
1578 "&.MuiInputBase-inputSizeSmall": { padding: "8.5px 14px 8.5px 0" }
1579 } };
1580 });
1581 SearchField = (0, react.forwardRef)(function(props, ref) {
1582 return /*#__PURE__*/ react.default.createElement(StyledTextField$1, _extends$1({
1583 autoFocus: true,
1584 fullWidth: true,
1585 required: true,
1586 size: "small",
1587 color: "secondary",
1588 InputProps: {
1589 autoComplete: "off",
1590 startAdornment: /*#__PURE__*/ react.default.createElement(_elementor_ui.InputAdornment, { position: "start" }, /*#__PURE__*/ react.default.createElement(_elementor_icons.SearchIcon, null))
1591 },
1592 placeholder: props.placeholder,
1593 name: props.name,
1594 value: props.value,
1595 onChange: props.onChange
1596 }, props, { inputRef: ref }));
1597 });
1598 SearchField.propTypes = {
1599 placeholder: import_prop_types$11.default.string,
1600 name: import_prop_types$11.default.string,
1601 value: import_prop_types$11.default.string,
1602 onChange: import_prop_types$11.default.func
1603 };
1604 }));
1605
1606 //#endregion
1607 //#region modules/ai/assets/js/editor/components/prompt-search.js
1608 var PromptSearch;
1609 var init_prompt_search = __esmMin((() => {
1610 init_extends();
1611 init_search_field();
1612 PromptSearch = (0, react.forwardRef)(function(props, ref) {
1613 return /*#__PURE__*/ react.default.createElement(SearchField, _extends$1({
1614 name: "prompt",
1615 placeholder: (0, _wordpress_i18n.__)("Describe the text and tone you want to use", "elementor") + "..."
1616 }, props, { ref }));
1617 });
1618 }));
1619
1620 //#endregion
1621 //#region modules/ai/assets/js/editor/components/textarea.js
1622 var import_prop_types$10, Textarea;
1623 var init_textarea = __esmMin((() => {
1624 init_extends();
1625 import_prop_types$10 = /* @__PURE__ */ __toESM(require_prop_types());
1626 Textarea = (0, react.forwardRef)(function(props, ref) {
1627 return /*#__PURE__*/ react.default.createElement(_elementor_ui.TextField, _extends$1({
1628 inputRef: ref,
1629 multiline: true,
1630 minRows: 4,
1631 maxRows: 20,
1632 color: "secondary"
1633 }, props));
1634 });
1635 Textarea.propTypes = {
1636 value: import_prop_types$10.default.string,
1637 onChange: import_prop_types$10.default.func,
1638 helperText: import_prop_types$10.default.string
1639 };
1640 }));
1641
1642 //#endregion
1643 //#region modules/ai/assets/js/editor/components/prompt-suggestions.js
1644 var import_prop_types$9, PromptSuggestions;
1645 var init_prompt_suggestions = __esmMin((() => {
1646 import_prop_types$9 = /* @__PURE__ */ __toESM(require_prop_types());
1647 PromptSuggestions = function PromptSuggestions(props) {
1648 var _props$suggestions;
1649 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
1650 variant: "subtitle1",
1651 color: "text.secondary"
1652 }, (0, _wordpress_i18n.__)("Suggested prompts", "elementor") + ":"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
1653 direction: "column",
1654 alignItems: "flex-start",
1655 gap: 1,
1656 sx: { my: 1 }
1657 }, (_props$suggestions = props.suggestions) === null || _props$suggestions === void 0 ? void 0 : _props$suggestions.map(function(option, index) {
1658 var _props$suggestionFilt;
1659 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Chip, {
1660 key: index,
1661 variant: "outlined",
1662 size: "large",
1663 color: "secondary",
1664 label: ((_props$suggestionFilt = props.suggestionFilter) === null || _props$suggestionFilt === void 0 ? void 0 : _props$suggestionFilt.call(props, option)) || option,
1665 onClick: function onClick() {
1666 return props.onSelect(option);
1667 }
1668 });
1669 })), props.children);
1670 };
1671 PromptSuggestions.propTypes = {
1672 suggestions: import_prop_types$9.default.arrayOf(import_prop_types$9.default.string),
1673 onSelect: import_prop_types$9.default.func.isRequired,
1674 suggestionFilter: import_prop_types$9.default.func,
1675 children: import_prop_types$9.default.node
1676 };
1677 }));
1678
1679 //#endregion
1680 //#region modules/ai/assets/js/editor/components/prompt-library-link.js
1681 var import_prop_types$8, PromptLibraryLink;
1682 var init_prompt_library_link = __esmMin((() => {
1683 import_prop_types$8 = /* @__PURE__ */ __toESM(require_prop_types());
1684 PromptLibraryLink = function PromptLibraryLink(props) {
1685 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
1686 variant: "body2",
1687 color: "text.secondary"
1688 }, (0, _wordpress_i18n.__)("For more suggestions, explore our"), " ", /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
1689 href: props.libraryLink,
1690 className: "elementor-clickable",
1691 target: "_blank"
1692 }, (0, _wordpress_i18n.__)("prompt library")));
1693 };
1694 PromptLibraryLink.propTypes = { libraryLink: import_prop_types$8.default.string };
1695 }));
1696
1697 //#endregion
1698 //#region modules/ai/assets/js/editor/components/prompt-action-selection.js
1699 init_asyncToGenerator();
1700 var import_regenerator$3 = /* @__PURE__ */ __toESM(require_regenerator());
1701 init_requests_ids();
1702 init_loader();
1703 init_prompt_search();
1704 init_textarea();
1705 init_prompt_suggestions();
1706 init_prompt_library_link();
1707 var import_prop_types$7 = /* @__PURE__ */ __toESM(require_prop_types());
1708 var labelToDashCash = function labelToDashCash(str) {
1709 return str.toLowerCase().replace(/ /g, "-");
1710 };
1711 var PromptActionSelection = function PromptActionSelection(props) {
1712 var actionId = labelToDashCash(props.label);
1713 var _props$wrapperStyle = props.wrapperStyle;
1714 var wrapperStyle = _props$wrapperStyle === void 0 ? { maxWidth: 138 } : _props$wrapperStyle;
1715 return /*#__PURE__*/ react.default.createElement(_elementor_ui.FormControl, {
1716 size: "small",
1717 color: "secondary",
1718 fullWidth: true,
1719 sx: wrapperStyle
1720 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.InputLabel, { id: actionId }, props.label), /*#__PURE__*/ react.default.createElement(_elementor_ui.Select, {
1721 id: actionId,
1722 labelId: actionId,
1723 label: props.label,
1724 value: props.value || "",
1725 onChange: props.onChange,
1726 disabled: props.disabled,
1727 sx: { "&.Mui-disabled .MuiSelect-nativeInput": {
1728 backgroundColor: "initial",
1729 opacity: 0
1730 } }
1731 }, props.options.map(function(option) {
1732 var _option$value;
1733 return /*#__PURE__*/ react.default.createElement(_elementor_ui.MenuItem, {
1734 dense: true,
1735 key: option.label,
1736 value: (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option.label
1737 }, option.label);
1738 })));
1739 };
1740 PromptActionSelection.propTypes = {
1741 label: import_prop_types$7.default.string.isRequired,
1742 options: import_prop_types$7.default.arrayOf(import_prop_types$7.default.shape({
1743 label: import_prop_types$7.default.string.isRequired,
1744 value: import_prop_types$7.default.string
1745 })).isRequired,
1746 onChange: import_prop_types$7.default.func.isRequired,
1747 value: import_prop_types$7.default.string,
1748 wrapperStyle: import_prop_types$7.default.object,
1749 disabled: import_prop_types$7.default.bool
1750 };
1751
1752 //#endregion
1753 //#region modules/ai/assets/js/editor/components/generate-button.js
1754 var GenerateButton$1;
1755 var init_generate_button = __esmMin((() => {
1756 init_extends();
1757 GenerateButton$1 = function GenerateButton(props) {
1758 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
1759 variant: "contained",
1760 endIcon: /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { fontSize: "small" }),
1761 disabled: !prompt,
1762 "aria-label": (0, _wordpress_i18n.__)("search", "elementor"),
1763 type: "submit",
1764 size: "small"
1765 }, props));
1766 };
1767 }));
1768
1769 //#endregion
1770 //#region modules/ai/assets/js/editor/components/prompt-action.js
1771 init_generate_button();
1772 init_extends();
1773 var PromptAction = function PromptAction(props) {
1774 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Chip, _extends$1({
1775 size: "large",
1776 color: "secondary",
1777 variant: "outlined"
1778 }, props));
1779 };
1780
1781 //#endregion
1782 //#region modules/ai/assets/js/editor/components/prompt-error-message.js
1783 var import_prop_types$6, _excluded$32, PromptErrorMessage;
1784 var init_prompt_error_message = __esmMin((() => {
1785 init_extends();
1786 init_objectWithoutProperties();
1787 import_prop_types$6 = /* @__PURE__ */ __toESM(require_prop_types());
1788 _excluded$32 = [
1789 "error",
1790 "onRetry",
1791 "actionPosition"
1792 ];
1793 PromptErrorMessage = function PromptErrorMessage(_ref) {
1794 var error = _ref.error;
1795 var _ref$onRetry = _ref.onRetry;
1796 var onRetry = _ref$onRetry === void 0 ? function() {} : _ref$onRetry;
1797 var _ref$actionPosition = _ref.actionPosition;
1798 var actionPosition = _ref$actionPosition === void 0 ? "default" : _ref$actionPosition;
1799 var props = _objectWithoutProperties(_ref, _excluded$32);
1800 function getQuotaReachedTrailMessage(featureName) {
1801 if (!featureName) return {
1802 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("It's time to upgrade.", "elementor")),
1803 description: (0, _wordpress_i18n.__)("Enjoy the free trial? Upgrade now for unlimited access to built-in image, text and custom code generators.", "elementor"),
1804 buttonText: (0, _wordpress_i18n.__)("Upgrade", "elementor"),
1805 buttonAction: function buttonAction() {
1806 return window.open("https://go.elementor.com/ai-popup-purchase-limit-reached/", "_blank");
1807 }
1808 };
1809 return {
1810 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("You've used all AI credits for %s.", "elementor"), featureName.toLowerCase())),
1811 description: (0, _wordpress_i18n.__)("Upgrade now to keep using this feature. You still have credits for other AI features (Text, Code, Images, Containers, etc.)", "elementor"),
1812 buttonText: (0, _wordpress_i18n.__)("Upgrade now", "elementor"),
1813 buttonAction: function buttonAction() {
1814 return window.open("https://go.elementor.com/ai-popup-purchase-limit-reached/", "_blank");
1815 }
1816 };
1817 }
1818 function getErrorMessage() {
1819 var _error$extra_data;
1820 var errMsg = error.message || error;
1821 var featureName = (_error$extra_data = error.extra_data) === null || _error$extra_data === void 0 ? void 0 : _error$extra_data.featureName;
1822 var messages = {
1823 default: {
1824 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("There was a glitch.", "elementor")),
1825 description: (0, _wordpress_i18n.__)("Wait a moment and give it another go, or try tweaking the prompt.", "elementor"),
1826 buttonText: (0, _wordpress_i18n.__)("Try again", "elementor"),
1827 buttonAction: onRetry
1828 },
1829 service_outage_internal: {
1830 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("There was a glitch.", "elementor")),
1831 description: (0, _wordpress_i18n.__)("Wait a moment and give it another go.", "elementor"),
1832 buttonText: (0, _wordpress_i18n.__)("Try again", "elementor"),
1833 buttonAction: onRetry
1834 },
1835 invalid_connect_data: {
1836 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("There was a glitch.", "elementor")),
1837 description: /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, (0, _wordpress_i18n.__)("Try exiting Elementor and sign in again.", "elementor"), " ", /*#__PURE__*/ react.default.createElement("a", {
1838 href: "https://elementor.com/help/disconnecting-reconnecting-your-elementor-account/",
1839 target: "_blank",
1840 rel: "noreferrer"
1841 }, (0, _wordpress_i18n.__)("Show me how", "elementor"))),
1842 buttonText: (0, _wordpress_i18n.__)("Reconnect", "elementor"),
1843 buttonAction: function buttonAction() {
1844 return window.open(window.ElementorAiConfig.connect_url);
1845 }
1846 },
1847 not_connected: {
1848 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("You aren't connected to Elementor AI.", "elementor")),
1849 description: (0, _wordpress_i18n.__)("Elementor AI is just a few clicks away. Connect your account to instantly create texts and custom code.", "elementor"),
1850 buttonText: (0, _wordpress_i18n.__)("Connect", "elementor"),
1851 buttonAction: function buttonAction() {
1852 return window.open(window.ElementorAiConfig.connect_url);
1853 }
1854 },
1855 quota_reached_trail: getQuotaReachedTrailMessage(featureName),
1856 quota_reached_subscription: {
1857 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("Looks like you're out of credits.", "elementor")),
1858 description: (0, _wordpress_i18n.__)("Ready to take it to the next level?", "elementor"),
1859 buttonText: (0, _wordpress_i18n.__)("Upgrade now", "elementor"),
1860 buttonAction: function buttonAction() {
1861 return window.open("https://go.elementor.com/ai-popup-purchase-limit-reached/", "_blank");
1862 }
1863 },
1864 rate_limit_network: {
1865 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("Whoa! Slow down there.", "elementor")),
1866 description: (0, _wordpress_i18n.__)("We can’t process that many requests so fast. Try again in 15 minutes.", "elementor")
1867 },
1868 invalid_prompts: {
1869 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("We were unable to generate that prompt.", "elementor")),
1870 description: (0, _wordpress_i18n.__)("Seems like the prompt contains words that could generate harmful content. Write a different prompt to continue.", "elementor")
1871 },
1872 service_unavailable: {
1873 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("There was a glitch.", "elementor")),
1874 description: (0, _wordpress_i18n.__)("Wait a moment and give it another go, or try tweaking the prompt.", "elementor"),
1875 buttonText: (0, _wordpress_i18n.__)("Try again", "elementor"),
1876 buttonAction: onRetry
1877 },
1878 request_timeout_error: {
1879 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("There was a glitch.", "elementor")),
1880 description: (0, _wordpress_i18n.__)("Wait a moment and give it another go, or try tweaking the prompt.", "elementor"),
1881 buttonText: (0, _wordpress_i18n.__)("Try again", "elementor"),
1882 buttonAction: onRetry
1883 },
1884 invalid_token: {
1885 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("Try again", "elementor")),
1886 description: (0, _wordpress_i18n.__)("Try exiting Elementor and sign in again.", "elementor"),
1887 buttonText: (0, _wordpress_i18n.__)("Reconnect", "elementor"),
1888 buttonAction: onRetry
1889 },
1890 file_too_large: {
1891 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("The file is too large.", "elementor")),
1892 description: (0, _wordpress_i18n.__)("Please upload a file that is less than 4MB.", "elementor")
1893 },
1894 image_resolution_maximum_exceeded: {
1895 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("The image resolution exceeds the maximum allowed size.", "elementor")),
1896 description: (0, _wordpress_i18n.__)("Please upload a file with dimensions less than 2048x2048 pixels.", "elementor")
1897 },
1898 external_service_unavailable: {
1899 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("Temporary external service issue", "elementor")),
1900 description: (0, _wordpress_i18n.__)("It seems that one of our partner services is temporarily unavailable. Please try again in a few minutes.", "elementor"),
1901 buttonText: (0, _wordpress_i18n.__)("Try Again", "elementor"),
1902 buttonAction: onRetry
1903 }
1904 };
1905 return messages[errMsg] || messages.default;
1906 }
1907 var message = getErrorMessage();
1908 var action = (message === null || message === void 0 ? void 0 : message.buttonText) && /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
1909 color: "inherit",
1910 size: "small",
1911 variant: "outlined",
1912 onClick: message.buttonAction
1913 }, message.buttonText);
1914 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Alert, _extends$1({
1915 severity: message.severity || "error",
1916 action: "default" === actionPosition && action
1917 }, props), message.text, message.description, "bottom" === actionPosition && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: { mt: 1 } }, action));
1918 };
1919 PromptErrorMessage.propTypes = {
1920 error: import_prop_types$6.default.oneOfType([import_prop_types$6.default.object, import_prop_types$6.default.string]),
1921 onRetry: import_prop_types$6.default.func,
1922 actionPosition: import_prop_types$6.default.oneOf(["default", "bottom"])
1923 };
1924 }));
1925
1926 //#endregion
1927 //#region modules/ai/assets/js/editor/api/index.js
1928 function ownKeys$31(e, r) {
1929 var t = Object.keys(e);
1930 if (Object.getOwnPropertySymbols) {
1931 var o = Object.getOwnPropertySymbols(e);
1932 r && (o = o.filter(function(r) {
1933 return Object.getOwnPropertyDescriptor(e, r).enumerable;
1934 })), t.push.apply(t, o);
1935 }
1936 return t;
1937 }
1938 function _objectSpread$31(e) {
1939 for (var r = 1; r < arguments.length; r++) {
1940 var t = null != arguments[r] ? arguments[r] : {};
1941 r % 2 ? ownKeys$31(Object(t), !0).forEach(function(r) {
1942 _defineProperty(e, r, t[r]);
1943 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$31(Object(t)).forEach(function(r) {
1944 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
1945 });
1946 }
1947 return e;
1948 }
1949 var request, getUserInformation, getRemoteConfig, getCompletionText, getEditText, getCustomCode, getCustomCSS, setGetStarted, setStatusFeedback, getTextToImageGeneration, getImageToImageGeneration, getImageToImageMaskCleanup, getImageToImageMaskGeneration, getImageToImageOutPainting, getImageToImageUpscale, getImageToImageRemoveBackground, getImageToImageIsolateObjects, getImageToImageReplaceBackground, getImagePromptEnhanced, getProductImageUnification, getAnimation, uploadImage, generateLayout, getLayoutPromptEnhanced, getHistory, deleteHistoryItem;
1950 var init_api = __esmMin((() => {
1951 init_defineProperty();
1952 __name(ownKeys$31, "ownKeys");
1953 __name(_objectSpread$31, "_objectSpread");
1954 request = function request(endpoint) {
1955 var data = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1956 var immediately = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
1957 var signal = arguments.length > 3 ? arguments[3] : void 0;
1958 if (Object.keys(data).length) if (window.elementorAiCurrentContext) data.context = window.elementorAiCurrentContext;
1959 else data.context = window.elementorWpAiCurrentContext;
1960 return new Promise(function(resolve, reject) {
1961 var ajaxData = elementorCommon.ajax.addRequest(endpoint, {
1962 success: resolve,
1963 error: reject,
1964 data,
1965 unique_id: data.unique_id
1966 }, immediately);
1967 if (signal && ajaxData.jqXhr) signal.addEventListener("abort", ajaxData.jqXhr.abort);
1968 });
1969 };
1970 getUserInformation = function getUserInformation(immediately) {
1971 return request("ai_get_user_information", void 0, immediately);
1972 };
1973 getRemoteConfig = function getRemoteConfig() {
1974 return request("ai_get_remote_config");
1975 };
1976 getCompletionText = function getCompletionText(payload) {
1977 return request("ai_get_completion_text", { payload });
1978 };
1979 getEditText = function getEditText(payload) {
1980 return request("ai_get_edit_text", { payload });
1981 };
1982 getCustomCode = function getCustomCode(payload) {
1983 return request("ai_get_custom_code", { payload });
1984 };
1985 getCustomCSS = function getCustomCSS(payload) {
1986 return request("ai_get_custom_css", { payload });
1987 };
1988 setGetStarted = function setGetStarted() {
1989 return request("ai_set_get_started");
1990 };
1991 setStatusFeedback = function setStatusFeedback(responseId) {
1992 return request("ai_set_status_feedback", { response_id: responseId }, true);
1993 };
1994 getTextToImageGeneration = function getTextToImageGeneration(payload) {
1995 return request("ai_get_text_to_image", { payload });
1996 };
1997 getImageToImageGeneration = function getImageToImageGeneration(payload) {
1998 return request("ai_get_image_to_image", { payload });
1999 };
2000 getImageToImageMaskCleanup = function getImageToImageMaskCleanup(payload) {
2001 return request("ai_get_image_to_image_mask_cleanup", { payload });
2002 };
2003 getImageToImageMaskGeneration = function getImageToImageMaskGeneration(payload) {
2004 return request("ai_get_image_to_image_mask", { payload });
2005 };
2006 getImageToImageOutPainting = function getImageToImageOutPainting(payload) {
2007 return request("ai_get_image_to_image_outpainting", { payload });
2008 };
2009 getImageToImageUpscale = function getImageToImageUpscale(payload) {
2010 return request("ai_get_image_to_image_upscale", { payload });
2011 };
2012 getImageToImageRemoveBackground = function getImageToImageRemoveBackground(payload) {
2013 return request("ai_get_image_to_image_remove_background", { payload });
2014 };
2015 getImageToImageIsolateObjects = function getImageToImageIsolateObjects(payload) {
2016 return request("ai_get_image_to_image_isolate_objects", { payload });
2017 };
2018 getImageToImageReplaceBackground = function getImageToImageReplaceBackground(payload) {
2019 return request("ai_get_image_to_image_replace_background", { payload });
2020 };
2021 getImagePromptEnhanced = function getImagePromptEnhanced(prompt) {
2022 return request("ai_get_image_prompt_enhancer", { prompt });
2023 };
2024 getProductImageUnification = function getProductImageUnification(payload, immediately) {
2025 return request("ai_get_product_image_unification", { payload }, immediately);
2026 };
2027 getAnimation = function getAnimation(payload) {
2028 return request("ai_get_animation", { payload });
2029 };
2030 uploadImage = function uploadImage(image) {
2031 return request("ai_upload_image", _objectSpread$31(_objectSpread$31({}, image), {}, {
2032 editor_post_id: image.image.editor_post_id,
2033 unique_id: image.image.unique_id
2034 }));
2035 };
2036 generateLayout = function generateLayout(requestBody, signal) {
2037 return request("ai_generate_layout", requestBody, true, signal);
2038 };
2039 getLayoutPromptEnhanced = function getLayoutPromptEnhanced(prompt, enhanceType) {
2040 return request("ai_get_layout_prompt_enhancer", {
2041 prompt,
2042 enhance_type: enhanceType
2043 });
2044 };
2045 getHistory = function getHistory(type, page, limit) {
2046 return request("ai_get_history", {
2047 type,
2048 page,
2049 limit
2050 });
2051 };
2052 deleteHistoryItem = function deleteHistoryItem(id) {
2053 return request("ai_delete_history_item", { id });
2054 };
2055 }));
2056
2057 //#endregion
2058 //#region modules/ai/assets/js/editor/hooks/use-prompt.js
2059 function ownKeys$30(e, r) {
2060 var t = Object.keys(e);
2061 if (Object.getOwnPropertySymbols) {
2062 var o = Object.getOwnPropertySymbols(e);
2063 r && (o = o.filter(function(r) {
2064 return Object.getOwnPropertyDescriptor(e, r).enumerable;
2065 })), t.push.apply(t, o);
2066 }
2067 return t;
2068 }
2069 function _objectSpread$30(e) {
2070 for (var r = 1; r < arguments.length; r++) {
2071 var t = null != arguments[r] ? arguments[r] : {};
2072 r % 2 ? ownKeys$30(Object(t), !0).forEach(function(r) {
2073 _defineProperty(e, r, t[r]);
2074 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$30(Object(t)).forEach(function(r) {
2075 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
2076 });
2077 }
2078 return e;
2079 }
2080 var _excluded$31, normalizeResponse, usePrompt;
2081 var init_use_prompt = __esmMin((() => {
2082 init_defineProperty();
2083 init_slicedToArray();
2084 init_objectWithoutProperties();
2085 init_api();
2086 _excluded$31 = [
2087 "text",
2088 "response_id",
2089 "usage",
2090 "images"
2091 ];
2092 __name(ownKeys$30, "ownKeys");
2093 __name(_objectSpread$30, "_objectSpread");
2094 normalizeResponse = function normalizeResponse(_ref) {
2095 var text = _ref.text;
2096 var responseId = _ref.response_id;
2097 var usage = _ref.usage;
2098 var images = _ref.images;
2099 var optional = _objectWithoutProperties(_ref, _excluded$31);
2100 var creditsData = usage ? usage.quota - usage.usedQuota : 0;
2101 var normalized = {
2102 result: text || images,
2103 responseId,
2104 credits: Math.max(creditsData, 0),
2105 usagePercentage: usage === null || usage === void 0 ? void 0 : usage.usagePercentage
2106 };
2107 if (optional.base_template_id) normalized.baseTemplateId = optional.base_template_id;
2108 normalized.type = optional.template_type;
2109 return normalized;
2110 };
2111 usePrompt = function usePrompt(fetchData, initialState) {
2112 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
2113 var isLoading = _useState2[0];
2114 var setIsLoading = _useState2[1];
2115 var _useState4 = _slicedToArray((0, react.useState)(""), 2);
2116 var error = _useState4[0];
2117 var setError = _useState4[1];
2118 var _useState6 = _slicedToArray((0, react.useState)(initialState), 2);
2119 var data = _useState6[0];
2120 var setData = _useState6[1];
2121 var _useRequestIds = useRequestIds();
2122 var updateUsagePercentage = _useRequestIds.updateUsagePercentage;
2123 var usagePercentage = _useRequestIds.usagePercentage;
2124 var send = (0, react.useRef)(/*#__PURE__*/ function() {
2125 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee(payload) {
2126 return import_regenerator$3.default.wrap(function(_context) {
2127 while (1) switch (_context.prev = _context.next) {
2128 case 0: return _context.abrupt("return", payload);
2129 case 1:
2130 case "end": return _context.stop();
2131 }
2132 }, _callee);
2133 }));
2134 return function(_x) {
2135 return _ref2.apply(this, arguments);
2136 };
2137 }());
2138 var sendUsageData = (0, react.useRef)(function() {});
2139 (0, react.useEffect)(function() {
2140 var newUsageValue = data === null || data === void 0 ? void 0 : data.usagePercentage;
2141 if (newUsageValue && newUsageValue !== usagePercentage) updateUsagePercentage(newUsageValue);
2142 }, [
2143 data,
2144 usagePercentage,
2145 updateUsagePercentage
2146 ]);
2147 var _useRequestIds2 = useRequestIds();
2148 var setRequest = _useRequestIds2.setRequest;
2149 var editorSessionId = _useRequestIds2.editorSessionId;
2150 var sessionId = _useRequestIds2.sessionId;
2151 var generateId = _useRequestIds2.generateId;
2152 var batchId = _useRequestIds2.batchId;
2153 send.current = (0, react.useCallback)(/*#__PURE__*/ function() {
2154 var _ref3 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee2(payload) {
2155 return import_regenerator$3.default.wrap(function(_context2) {
2156 while (1) switch (_context2.prev = _context2.next) {
2157 case 0: return _context2.abrupt("return", new Promise(function(resolve, reject) {
2158 setError("");
2159 setIsLoading(true);
2160 var requestId = setRequest();
2161 var requestIds = {
2162 editorSessionId: editorSessionId.current,
2163 sessionId: sessionId.current,
2164 generateId: generateId.current,
2165 batchId: batchId.current,
2166 requestId: requestId.current
2167 };
2168 payload = _objectSpread$30(_objectSpread$30({}, payload), {}, { requestIds });
2169 fetchData(payload).then(function(result) {
2170 var normalizedData = normalizeResponse(result);
2171 setData(normalizedData);
2172 resolve(normalizedData);
2173 }).catch(function(err) {
2174 var finalError = (err === null || err === void 0 ? void 0 : err.responseText) || err;
2175 setError(finalError);
2176 reject(finalError);
2177 }).finally(function() {
2178 return setIsLoading(false);
2179 });
2180 }));
2181 case 1:
2182 case "end": return _context2.stop();
2183 }
2184 }, _callee2);
2185 }));
2186 return function(_x2) {
2187 return _ref3.apply(this, arguments);
2188 };
2189 }(), [
2190 batchId,
2191 editorSessionId,
2192 fetchData,
2193 generateId,
2194 sessionId,
2195 setRequest
2196 ]);
2197 sendUsageData.current = (0, react.useCallback)(function() {
2198 var usageData = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : data;
2199 return usageData.responseId && setStatusFeedback(usageData.responseId);
2200 }, [data]);
2201 return {
2202 isLoading,
2203 error,
2204 data,
2205 setResult: function setResult(result) {
2206 var responseId = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
2207 var updatedResult = _objectSpread$30({}, data);
2208 updatedResult.result = result;
2209 if (responseId) updatedResult.responseId = responseId;
2210 setData(updatedResult);
2211 },
2212 reset: function reset() {
2213 setData(function(_ref4) {
2214 return {
2215 credits: _ref4.credits,
2216 result: "",
2217 responseId: ""
2218 };
2219 });
2220 setError("");
2221 setIsLoading(false);
2222 },
2223 send: send.current,
2224 sendUsageData: sendUsageData.current
2225 };
2226 };
2227 }));
2228
2229 //#endregion
2230 //#region modules/ai/assets/js/editor/hooks/use-text-prompt.js
2231 init_prompt_error_message();
2232 init_asyncToGenerator();
2233 var import_regenerator$2 = /* @__PURE__ */ __toESM(require_regenerator());
2234 init_api();
2235 init_use_prompt();
2236 var getTextResult = /*#__PURE__*/ function() {
2237 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(payload) {
2238 return import_regenerator$2.default.wrap(function(_context) {
2239 while (1) switch (_context.prev = _context.next) {
2240 case 0:
2241 if (!(payload !== null && payload !== void 0 && payload.instruction)) {
2242 _context.next = 1;
2243 break;
2244 }
2245 return _context.abrupt("return", getEditText(payload));
2246 case 1: return _context.abrupt("return", getCompletionText(payload));
2247 case 2:
2248 case "end": return _context.stop();
2249 }
2250 }, _callee);
2251 }));
2252 return function getTextResult(_x) {
2253 return _ref.apply(this, arguments);
2254 };
2255 }();
2256 var useTextPrompt = function useTextPrompt(initialValue) {
2257 return usePrompt(getTextResult, initialValue);
2258 };
2259
2260 //#endregion
2261 //#region modules/ai/assets/js/editor/actions-data.js
2262 var textAutocomplete, textareaAutocomplete, codeHtmlAutocomplete, codeCssAutocomplete, vocalTones, translateLanguages, motionEffectAutocomplete, hoverEffectAutocomplete;
2263 var init_actions_data = __esmMin((() => {
2264 textAutocomplete = [
2265 (0, _wordpress_i18n.__)("Craft a catchy slogan for", "elementor"),
2266 (0, _wordpress_i18n.__)("Write a strong section header for", "elementor"),
2267 (0, _wordpress_i18n.__)("Create a blog title for", "elementor"),
2268 (0, _wordpress_i18n.__)("Suggest a 4 word headline for", "elementor"),
2269 (0, _wordpress_i18n.__)("Write an attention grabbing title for", "elementor")
2270 ];
2271 textareaAutocomplete = [
2272 (0, _wordpress_i18n.__)("Write a product description for", "elementor"),
2273 (0, _wordpress_i18n.__)("Create a blog post for", "elementor"),
2274 (0, _wordpress_i18n.__)("Craft an about us section for", "elementor"),
2275 (0, _wordpress_i18n.__)("Offer a few sentences to invite visitors to", "elementor"),
2276 (0, _wordpress_i18n.__)("Write microcopy for a submission form that includes", "elementor")
2277 ];
2278 codeHtmlAutocomplete = [
2279 (0, _wordpress_i18n.__)("GA event fired on every button element click (assume GA was loaded)", "elementor"),
2280 (0, _wordpress_i18n.__)("Iframe code to embed a Spotify widget on my web page. My ID is 1234567890", "elementor"),
2281 (0, _wordpress_i18n.__)("Write an embed code of Google Analytics", "elementor"),
2282 (0, _wordpress_i18n.__)("Write an embed code of Facebook Pixel", "elementor"),
2283 (0, _wordpress_i18n.__)("HTML code that embeds the following PDF into a webpage: link to PDF", "elementor")
2284 ];
2285 codeCssAutocomplete = [
2286 (0, _wordpress_i18n.__)("On hover, animate 20% bigger, rotate 10 deg CCW", "elementor"),
2287 (0, _wordpress_i18n.__)("Add a circle-shaped clip mask, semi transparent on hover", "elementor"),
2288 (0, _wordpress_i18n.__)("Rainbow colored animated text gradient", "elementor"),
2289 (0, _wordpress_i18n.__)("Add a 3D shadow to the text", "elementor")
2290 ];
2291 vocalTones = [
2292 { label: (0, _wordpress_i18n.__)("Casual", "elementor") },
2293 { label: (0, _wordpress_i18n.__)("Confidence", "elementor") },
2294 { label: (0, _wordpress_i18n.__)("Formal", "elementor") },
2295 { label: (0, _wordpress_i18n.__)("Friendly", "elementor") },
2296 { label: (0, _wordpress_i18n.__)("Inspirational", "elementor") },
2297 { label: (0, _wordpress_i18n.__)("Motivational", "elementor") },
2298 { label: (0, _wordpress_i18n.__)("Nostalgic", "elementor") },
2299 { label: (0, _wordpress_i18n.__)("Playful", "elementor") },
2300 { label: (0, _wordpress_i18n.__)("Professional", "elementor") },
2301 { label: (0, _wordpress_i18n.__)("Scientific", "elementor") },
2302 { label: (0, _wordpress_i18n.__)("Straightforward", "elementor") },
2303 { label: (0, _wordpress_i18n.__)("Witty", "elementor") }
2304 ];
2305 translateLanguages = [
2306 {
2307 label: (0, _wordpress_i18n.__)("Arabic", "elementor"),
2308 value: "ar-SA"
2309 },
2310 {
2311 label: (0, _wordpress_i18n.__)("Chinese", "elementor"),
2312 value: "zh-CN"
2313 },
2314 {
2315 label: (0, _wordpress_i18n.__)("Czech", "elementor"),
2316 value: "cs-CZ"
2317 },
2318 {
2319 label: (0, _wordpress_i18n.__)("Danish", "elementor"),
2320 value: "da-DK"
2321 },
2322 {
2323 label: (0, _wordpress_i18n.__)("Dutch", "elementor"),
2324 value: "nl-NL"
2325 },
2326 {
2327 label: (0, _wordpress_i18n.__)("English", "elementor"),
2328 value: "en-US"
2329 },
2330 {
2331 label: (0, _wordpress_i18n.__)("Finnish", "elementor"),
2332 value: "fi-FI"
2333 },
2334 {
2335 label: (0, _wordpress_i18n.__)("French", "elementor"),
2336 value: "fr-FR"
2337 },
2338 {
2339 label: (0, _wordpress_i18n.__)("German", "elementor"),
2340 value: "de-DE"
2341 },
2342 {
2343 label: (0, _wordpress_i18n.__)("Greek", "elementor"),
2344 value: "el-GR"
2345 },
2346 {
2347 label: (0, _wordpress_i18n.__)("Hebrew", "elementor"),
2348 value: "he-IL"
2349 },
2350 {
2351 label: (0, _wordpress_i18n.__)("Hungarian", "elementor"),
2352 value: "hu-HU"
2353 },
2354 {
2355 label: (0, _wordpress_i18n.__)("Indonesian", "elementor"),
2356 value: "id-ID"
2357 },
2358 {
2359 label: (0, _wordpress_i18n.__)("Italian", "elementor"),
2360 value: "it-IT"
2361 },
2362 {
2363 label: (0, _wordpress_i18n.__)("Japanese", "elementor"),
2364 value: "ja-JP"
2365 },
2366 {
2367 label: (0, _wordpress_i18n.__)("Korean", "elementor"),
2368 value: "ko-KR"
2369 },
2370 {
2371 label: (0, _wordpress_i18n.__)("Persian", "elementor"),
2372 value: "fa-IR"
2373 },
2374 {
2375 label: (0, _wordpress_i18n.__)("Polish", "elementor"),
2376 value: "pl-PL"
2377 },
2378 {
2379 label: (0, _wordpress_i18n.__)("Portuguese", "elementor"),
2380 value: "pt-PT"
2381 },
2382 {
2383 label: (0, _wordpress_i18n.__)("Russian", "elementor"),
2384 value: "ru-RU"
2385 },
2386 {
2387 label: (0, _wordpress_i18n.__)("Spanish", "elementor"),
2388 value: "es-ES"
2389 },
2390 {
2391 label: (0, _wordpress_i18n.__)("Swedish", "elementor"),
2392 value: "sv-SE"
2393 },
2394 {
2395 label: (0, _wordpress_i18n.__)("Thai", "elementor"),
2396 value: "th-TH"
2397 },
2398 {
2399 label: (0, _wordpress_i18n.__)("Turkish", "elementor"),
2400 value: "tr-TR"
2401 },
2402 {
2403 label: (0, _wordpress_i18n.__)("Vietnamese", "elementor"),
2404 value: "vi-VN"
2405 }
2406 ];
2407 motionEffectAutocomplete = [
2408 (0, _wordpress_i18n.__)("Create Fade out animation on scroll", "elementor"),
2409 (0, _wordpress_i18n.__)("Create a Parallax effect on scroll", "elementor"),
2410 (0, _wordpress_i18n.__)("On scroll, fade in with slight scaling up", "elementor"),
2411 (0, _wordpress_i18n.__)("Move and tilt opposite to mouse position", "elementor"),
2412 (0, _wordpress_i18n.__)("Slide in from the left on load", "elementor")
2413 ];
2414 hoverEffectAutocomplete = [
2415 (0, _wordpress_i18n.__)("Move down on hover", "elementor"),
2416 (0, _wordpress_i18n.__)("Slightly shift right on hover", "elementor"),
2417 (0, _wordpress_i18n.__)("Apply a subtle 3D tilt", "elementor"),
2418 (0, _wordpress_i18n.__)("Rotate gently clockwise on hover", "elementor"),
2419 (0, _wordpress_i18n.__)("Scale down and move up on hover", "elementor")
2420 ];
2421 }));
2422
2423 //#endregion
2424 //#region modules/ai/assets/js/editor/components/prompt-history/history-types.js
2425 var HISTORY_TYPES, TRANSLATED_HISTORY_TYPES_FALLBACK, TRANSLATED_HISTORY_TYPES, getTranslatedPromptHistoryType;
2426 var init_history_types = __esmMin((() => {
2427 init_defineProperty();
2428 HISTORY_TYPES = Object.freeze({
2429 ALL: "all",
2430 TEXT: "text",
2431 CODE: "code",
2432 IMAGE: "images",
2433 BLOCK: "blocks"
2434 });
2435 TRANSLATED_HISTORY_TYPES_FALLBACK = (0, _wordpress_i18n.__)("things", "elementor");
2436 TRANSLATED_HISTORY_TYPES = Object.freeze(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, HISTORY_TYPES.TEXT, (0, _wordpress_i18n.__)("texts", "elementor")), HISTORY_TYPES.CODE, (0, _wordpress_i18n.__)("code", "elementor")), HISTORY_TYPES.IMAGE, (0, _wordpress_i18n.__)("images", "elementor")), HISTORY_TYPES.BLOCK, (0, _wordpress_i18n.__)("blocks", "elementor")));
2437 getTranslatedPromptHistoryType = function getTranslatedPromptHistoryType(historyType) {
2438 if (TRANSLATED_HISTORY_TYPES[historyType]) return TRANSLATED_HISTORY_TYPES[historyType];
2439 return TRANSLATED_HISTORY_TYPES_FALLBACK;
2440 };
2441 }));
2442
2443 //#endregion
2444 //#region modules/ai/assets/js/editor/helpers/index.js
2445 var vh;
2446 var init_helpers = __esmMin((() => {
2447 vh = function vh(value) {
2448 return value * Math.max(document.documentElement.clientHeight, window.innerHeight || 0) / 100;
2449 };
2450 }));
2451
2452 //#endregion
2453 //#region modules/ai/assets/js/editor/components/prompt-history/context/prompt-history-context.js
2454 var import_prop_types$5, PromptHistoryContext, DIALOG_CONTAINER_SELECTOR, getContainer, getContainerHeight, getContentHeight, setContentHeight, PromptHistoryProvider, usePromptHistoryContext;
2455 var init_prompt_history_context = __esmMin((() => {
2456 init_slicedToArray();
2457 import_prop_types$5 = /* @__PURE__ */ __toESM(require_prop_types());
2458 init_history_types();
2459 init_helpers();
2460 PromptHistoryContext = (0, react.createContext)({});
2461 DIALOG_CONTAINER_SELECTOR = ".e-ai-dialog-content";
2462 getContainer = function getContainer() {
2463 return document.querySelector(DIALOG_CONTAINER_SELECTOR);
2464 };
2465 getContainerHeight = function getContainerHeight() {
2466 var contentContainer = document.querySelector(DIALOG_CONTAINER_SELECTOR);
2467 return contentContainer === null || contentContainer === void 0 ? void 0 : contentContainer.clientHeight;
2468 };
2469 getContentHeight = function getContentHeight() {
2470 return document.querySelector(DIALOG_CONTAINER_SELECTOR).children[0].clientHeight + 50;
2471 };
2472 setContentHeight = function setContentHeight(height) {
2473 var contentContainer = document.querySelector(DIALOG_CONTAINER_SELECTOR);
2474 if ("auto" === height) {
2475 contentContainer.style.height = "auto";
2476 return;
2477 }
2478 contentContainer.style.height = "".concat(height, "px");
2479 };
2480 PromptHistoryProvider = function PromptHistoryProvider(_ref) {
2481 var historyType = _ref.historyType;
2482 var children = _ref.children;
2483 var showHistoryState = (0, react.useState)(false);
2484 return /*#__PURE__*/ react.default.createElement(PromptHistoryContext.Provider, { value: {
2485 historyType,
2486 showHistoryState
2487 } }, children);
2488 };
2489 PromptHistoryProvider.propTypes = {
2490 historyType: import_prop_types$5.default.oneOf(Object.values(HISTORY_TYPES)).isRequired,
2491 children: import_prop_types$5.default.node
2492 };
2493 usePromptHistoryContext = function usePromptHistoryContext() {
2494 var _useContext = (0, react.useContext)(PromptHistoryContext);
2495 var historyType = _useContext.historyType;
2496 var showHistoryState = _useContext.showHistoryState;
2497 var _showHistoryState = _slicedToArray(showHistoryState, 2);
2498 var showHistory = _showHistoryState[0];
2499 var setShowHistory = _showHistoryState[1];
2500 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
2501 var showModalWrapper = _useState2[0];
2502 var setShowModalWrapper = _useState2[1];
2503 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
2504 var showPromptHistory = _useState4[0];
2505 var setShowPromptHistory = _useState4[1];
2506 var handleFullScreenHistoryState = function handleFullScreenHistoryState() {
2507 if (showHistory) {
2508 setShowModalWrapper(true);
2509 setTimeout(function() {
2510 return setShowPromptHistory(true);
2511 }, 200);
2512 return;
2513 }
2514 setShowPromptHistory(false);
2515 setTimeout(function() {
2516 return setShowModalWrapper(false);
2517 }, 500);
2518 };
2519 var handleDefaultHistoryState = function handleDefaultHistoryState() {
2520 if (showHistory) {
2521 var currentHeight = getContentHeight();
2522 setContentHeight(currentHeight);
2523 setTimeout(function() {
2524 if (currentHeight < vh(61)) {
2525 setContentHeight(vh(61));
2526 setTimeout(function() {
2527 return setShowModalWrapper(true);
2528 }, 200);
2529 setTimeout(function() {
2530 return setShowPromptHistory(true);
2531 }, 300);
2532 return;
2533 }
2534 setShowModalWrapper(true);
2535 setShowPromptHistory(true);
2536 }, 20);
2537 return;
2538 }
2539 setShowPromptHistory(false);
2540 setTimeout(function() {
2541 setShowModalWrapper(false);
2542 setContentHeight(getContentHeight());
2543 setTimeout(function() {
2544 return setContentHeight("auto");
2545 }, 300);
2546 }, 500);
2547 };
2548 (0, react.useEffect)(function() {
2549 if (showHistory === showModalWrapper && showHistory === showPromptHistory) return;
2550 if (historyType === HISTORY_TYPES.IMAGE) return handleFullScreenHistoryState();
2551 handleDefaultHistoryState();
2552 }, [showHistory]);
2553 return {
2554 historyType,
2555 isOpen: showPromptHistory,
2556 isModalOpen: showModalWrapper,
2557 showHistory,
2558 onOpen: function onOpen() {
2559 setShowHistory(true);
2560 },
2561 onClose: function onClose() {
2562 setShowHistory(false);
2563 },
2564 getContainer,
2565 getContainerHeight
2566 };
2567 };
2568 }));
2569
2570 //#endregion
2571 //#region modules/ai/assets/js/editor/components/prompt-history/context/prompt-history-action-context.js
2572 function _createForOfIteratorHelper$1(r, e) {
2573 var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
2574 if (!t) {
2575 if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e && r && "number" == typeof r.length) {
2576 t && (r = t);
2577 var _n = 0;
2578 var F = function F() {};
2579 return {
2580 s: F,
2581 n: function n() {
2582 return _n >= r.length ? { done: !0 } : {
2583 done: !1,
2584 value: r[_n++]
2585 };
2586 },
2587 e: function e(r) {
2588 throw r;
2589 },
2590 f: F
2591 };
2592 }
2593 throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2594 }
2595 var o;
2596 var a = !0;
2597 var u = !1;
2598 return {
2599 s: function s() {
2600 t = t.call(r);
2601 },
2602 n: function n() {
2603 var r = t.next();
2604 return a = r.done, r;
2605 },
2606 e: function e(r) {
2607 u = !0, o = r;
2608 },
2609 f: function f() {
2610 try {
2611 a || null == t.return || t.return();
2612 } finally {
2613 if (u) throw o;
2614 }
2615 }
2616 };
2617 }
2618 function _unsupportedIterableToArray$1(r, a) {
2619 if (r) {
2620 if ("string" == typeof r) return _arrayLikeToArray$1(r, a);
2621 var t = {}.toString.call(r).slice(8, -1);
2622 return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0;
2623 }
2624 }
2625 function _arrayLikeToArray$1(r, a) {
2626 (null == a || a > r.length) && (a = r.length);
2627 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
2628 return n;
2629 }
2630 var import_prop_types$4, PromptHistoryActionContext, initialActionValue, ACTION_TYPES, ENABLED_ACTIONS_BY_TYPE, PromptHistoryActionProvider, usePromptHistoryAction, useSubscribeOnPromptHistoryAction;
2631 var init_prompt_history_action_context = __esmMin((() => {
2632 init_slicedToArray();
2633 init_defineProperty();
2634 import_prop_types$4 = /* @__PURE__ */ __toESM(require_prop_types());
2635 init_history_types();
2636 init_prompt_history_context();
2637 __name(_createForOfIteratorHelper$1, "_createForOfIteratorHelper");
2638 __name(_unsupportedIterableToArray$1, "_unsupportedIterableToArray");
2639 __name(_arrayLikeToArray$1, "_arrayLikeToArray");
2640 PromptHistoryActionContext = (0, react.createContext)({});
2641 initialActionValue = {
2642 type: "",
2643 id: "",
2644 data: null
2645 };
2646 ACTION_TYPES = Object.freeze({
2647 REUSE: "reuse",
2648 EDIT: "edit",
2649 RESTORE: "restore",
2650 REMOVE: "remove"
2651 });
2652 ENABLED_ACTIONS_BY_TYPE = _defineProperty(_defineProperty(_defineProperty({}, HISTORY_TYPES.TEXT, _defineProperty(_defineProperty(_defineProperty({}, ACTION_TYPES.REUSE, true), ACTION_TYPES.EDIT, true), ACTION_TYPES.REMOVE, true)), HISTORY_TYPES.CODE, _defineProperty(_defineProperty({}, ACTION_TYPES.REUSE, true), ACTION_TYPES.REMOVE, true)), HISTORY_TYPES.IMAGE, _defineProperty(_defineProperty({}, ACTION_TYPES.RESTORE, true), ACTION_TYPES.REMOVE, true));
2653 PromptHistoryActionProvider = function PromptHistoryActionProvider(_ref) {
2654 var children = _ref.children;
2655 var _useState2 = _slicedToArray((0, react.useState)(initialActionValue), 2);
2656 var state = _useState2[0];
2657 var dispatch = _useState2[1];
2658 return /*#__PURE__*/ react.default.createElement(PromptHistoryActionContext.Provider, { value: {
2659 state,
2660 dispatch
2661 } }, children);
2662 };
2663 PromptHistoryActionProvider.propTypes = { children: import_prop_types$4.default.node };
2664 usePromptHistoryAction = function usePromptHistoryAction() {
2665 var _useContext = (0, react.useContext)(PromptHistoryActionContext);
2666 var state = _useContext.state;
2667 var dispatch = _useContext.dispatch;
2668 var _usePromptHistoryCont = usePromptHistoryContext();
2669 var historyType = _usePromptHistoryCont.historyType;
2670 var onClose = _usePromptHistoryCont.onClose;
2671 var closeModalAfterAction = function closeModalAfterAction(action) {
2672 return function() {
2673 action.apply(void 0, arguments);
2674 onClose();
2675 };
2676 };
2677 return {
2678 promptHistoryAction: state,
2679 onPromptReuse: closeModalAfterAction(function onPromptReuse(id, data) {
2680 return dispatch({
2681 type: ACTION_TYPES.REUSE,
2682 id,
2683 data
2684 });
2685 }),
2686 onResultEdit: closeModalAfterAction(function onResultEdit(id, data) {
2687 return dispatch({
2688 type: ACTION_TYPES.EDIT,
2689 id,
2690 data
2691 });
2692 }),
2693 onImagesRestore: closeModalAfterAction(function onImagesRestore(id, data) {
2694 return dispatch({
2695 type: ACTION_TYPES.RESTORE,
2696 id,
2697 data
2698 });
2699 }),
2700 getAllowedActions: function getAllowedActions() {
2701 return ENABLED_ACTIONS_BY_TYPE[historyType] || {};
2702 }
2703 };
2704 };
2705 useSubscribeOnPromptHistoryAction = function useSubscribeOnPromptHistoryAction(actions) {
2706 var state = (0, react.useContext)(PromptHistoryActionContext).state;
2707 (0, react.useEffect)(function() {
2708 if (!state.type) return;
2709 var _iterator = _createForOfIteratorHelper$1(actions);
2710 var _step;
2711 try {
2712 for (_iterator.s(); !(_step = _iterator.n()).done;) {
2713 var action = _step.value;
2714 if (state.type === (action === null || action === void 0 ? void 0 : action.type)) action === null || action === void 0 || action.handler(state);
2715 }
2716 } catch (err) {
2717 _iterator.e(err);
2718 } finally {
2719 _iterator.f();
2720 }
2721 }, [state]);
2722 };
2723 }));
2724
2725 //#endregion
2726 //#region modules/ai/assets/js/editor/icons/bulb-icon.js
2727 var BulbIcon;
2728 var init_bulb_icon = __esmMin((() => {
2729 init_extends();
2730 BulbIcon = react.default.forwardRef(function(props, ref) {
2731 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({}, props, { ref }), /*#__PURE__*/ react.default.createElement("svg", {
2732 width: "22",
2733 height: "22",
2734 viewBox: "0 0 22 22",
2735 fill: "none",
2736 xmlns: "http://www.w3.org/2000/svg"
2737 }, /*#__PURE__*/ react.default.createElement("g", { clipPath: "url(#clip0_10743_8902)" }, /*#__PURE__*/ react.default.createElement("path", {
2738 d: "M2.75 10.0833H3.66667M11 2.75V3.66667M18.3333 10.0833H19.25M5.13333 5.13333L5.775 5.775M16.8667 5.13333L16.225 5.775",
2739 stroke: "#2563EB",
2740 strokeWidth: "1.5",
2741 strokeLinecap: "round",
2742 strokeLinejoin: "round"
2743 }), /*#__PURE__*/ react.default.createElement("path", {
2744 d: "M9.16675 16.041C8.70841 15.1243 6.91205 13.2842 6.62523 12.366C6.3384 11.4477 6.34775 10.4626 6.65195 9.54997C6.95615 8.63738 7.53978 7.84362 8.32016 7.28116C9.10054 6.71869 10.0381 6.41602 11.0001 6.41602C11.962 6.41602 12.8996 6.71869 13.68 7.28116C14.4604 7.84362 15.044 8.63738 15.3482 9.54997C15.6524 10.4626 15.6618 11.4477 15.3749 12.366C15.0881 13.2842 13.2917 15.1243 12.8334 16.041C12.8334 16.041 12.7597 17.3762 12.8334 17.8743C12.8334 18.3606 12.6403 18.8269 12.2964 19.1707C11.9526 19.5145 11.4863 19.7077 11.0001 19.7077C10.5139 19.7077 10.0475 19.5145 9.70372 19.1707C9.3599 18.8269 9.16675 18.3606 9.16675 17.8743C9.2405 17.3762 9.16675 16.041 9.16675 16.041Z",
2745 stroke: "#2563EB",
2746 strokeWidth: "1.5",
2747 strokeLinecap: "round",
2748 strokeLinejoin: "round"
2749 }), /*#__PURE__*/ react.default.createElement("path", {
2750 d: "M10.0833 16.5H11.9166",
2751 stroke: "#2563EB",
2752 strokeWidth: "1.5",
2753 strokeLinecap: "round",
2754 strokeLinejoin: "round"
2755 })), /*#__PURE__*/ react.default.createElement("defs", null, /*#__PURE__*/ react.default.createElement("clipPath", { id: "clip0_10743_8902" }, /*#__PURE__*/ react.default.createElement("rect", {
2756 width: "22",
2757 height: "22",
2758 fill: "white"
2759 })))));
2760 });
2761 }));
2762
2763 //#endregion
2764 //#region modules/ai/assets/js/editor/hooks/use-introduction.js
2765 function useIntroduction(key) {
2766 var _window$elementor$con;
2767 var _window$elementorAdmi;
2768 var _globalConfig$introdu;
2769 var globalConfig = window.elementor ? (_window$elementor$con = window.elementor.config) === null || _window$elementor$con === void 0 ? void 0 : _window$elementor$con.user : (_window$elementorAdmi = window.elementorAdmin) === null || _window$elementorAdmi === void 0 || (_window$elementorAdmi = _window$elementorAdmi.config) === null || _window$elementorAdmi === void 0 ? void 0 : _window$elementorAdmi.user;
2770 var _useState2 = _slicedToArray((0, react.useState)(!!(globalConfig !== null && globalConfig !== void 0 && (_globalConfig$introdu = globalConfig.introduction) !== null && _globalConfig$introdu !== void 0 && _globalConfig$introdu[key])), 2);
2771 var isViewed = _useState2[0];
2772 var setIsViewed = _useState2[1];
2773 function markAsViewed() {
2774 if (!key) return Promise.reject();
2775 return new Promise(function(resolve, reject) {
2776 if (isViewed) reject();
2777 setIsViewed(true);
2778 elementorCommon.ajax.addRequest("introduction_viewed", {
2779 data: { introductionKey: key },
2780 error: function error() {
2781 setIsViewed(false);
2782 reject();
2783 },
2784 success: function success() {
2785 setIsViewed(true);
2786 if (globalConfig !== null && globalConfig !== void 0 && globalConfig.introduction) globalConfig.introduction[key] = true;
2787 resolve();
2788 }
2789 });
2790 });
2791 }
2792 return {
2793 isViewed,
2794 markAsViewed
2795 };
2796 }
2797 var init_use_introduction = __esmMin((() => {
2798 init_slicedToArray();
2799 }));
2800
2801 //#endregion
2802 //#region modules/ai/assets/js/editor/components/voice-promotion-alert.js
2803 function ownKeys$29(e, r) {
2804 var t = Object.keys(e);
2805 if (Object.getOwnPropertySymbols) {
2806 var o = Object.getOwnPropertySymbols(e);
2807 r && (o = o.filter(function(r) {
2808 return Object.getOwnPropertyDescriptor(e, r).enumerable;
2809 })), t.push.apply(t, o);
2810 }
2811 return t;
2812 }
2813 function _objectSpread$29(e) {
2814 for (var r = 1; r < arguments.length; r++) {
2815 var t = null != arguments[r] ? arguments[r] : {};
2816 r % 2 ? ownKeys$29(Object(t), !0).forEach(function(r) {
2817 _defineProperty(e, r, t[r]);
2818 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$29(Object(t)).forEach(function(r) {
2819 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
2820 });
2821 }
2822 return e;
2823 }
2824 var import_prop_types$3, VoicePromotionAlert;
2825 var init_voice_promotion_alert = __esmMin((() => {
2826 init_defineProperty();
2827 init_bulb_icon();
2828 init_use_introduction();
2829 import_prop_types$3 = /* @__PURE__ */ __toESM(require_prop_types());
2830 __name(ownKeys$29, "ownKeys");
2831 __name(_objectSpread$29, "_objectSpread");
2832 VoicePromotionAlert = function VoicePromotionAlert(props) {
2833 var _useIntroduction = useIntroduction(props.introductionKey);
2834 var isViewed = _useIntroduction.isViewed;
2835 var markAsViewed = _useIntroduction.markAsViewed;
2836 if (isViewed) return null;
2837 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
2838 sx: _objectSpread$29({ mt: 2 }, props.sx),
2839 alignItems: "top"
2840 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Alert, {
2841 severity: "info",
2842 variant: "standard",
2843 icon: /*#__PURE__*/ react.default.createElement(BulbIcon, { sx: { alignSelf: "flex-start" } }),
2844 onClose: markAsViewed
2845 }, (0, _wordpress_i18n.__)("Get improved results from AI by adding personal context.", "elementor"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
2846 onClick: function onClick() {
2847 return $e.route("panel/global/menu");
2848 },
2849 className: "elementor-clickable",
2850 style: { textDecoration: "none" },
2851 color: "info.main",
2852 href: "#"
2853 }, (0, _wordpress_i18n.__)("Let’s do it", "elementor"))));
2854 };
2855 VoicePromotionAlert.propTypes = {
2856 sx: import_prop_types$3.default.object,
2857 introductionKey: import_prop_types$3.default.string
2858 };
2859 }));
2860
2861 //#endregion
2862 //#region modules/ai/assets/js/editor/pages/form-text/index.js
2863 init_asyncToGenerator();
2864 init_slicedToArray();
2865 init_actions_data();
2866 init_prompt_history_action_context();
2867 init_requests_ids();
2868 init_voice_promotion_alert();
2869 var promptActions = [
2870 {
2871 label: (0, _wordpress_i18n.__)("Simplify language", "elementor"),
2872 icon: /*#__PURE__*/ react.default.createElement(_elementor_icons.MessageIcon, { fontSize: "small" }),
2873 value: "Simplify the language of the following message"
2874 },
2875 {
2876 label: (0, _wordpress_i18n.__)("Make it longer", "elementor"),
2877 icon: /*#__PURE__*/ react.default.createElement(_elementor_icons.ExpandIcon, { fontSize: "small" }),
2878 value: "Make the following message longer"
2879 },
2880 {
2881 label: (0, _wordpress_i18n.__)("Make it shorter", "elementor"),
2882 icon: /*#__PURE__*/ react.default.createElement(_elementor_icons.ShrinkIcon, { fontSize: "small" }),
2883 value: "Make the following message shorter"
2884 },
2885 {
2886 label: (0, _wordpress_i18n.__)("Fix spelling & grammar", "elementor"),
2887 icon: /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { fontSize: "small" }),
2888 value: "Fix the spelling and grammar of the following message"
2889 }
2890 ];
2891 var promptInstructions = [{
2892 label: (0, _wordpress_i18n.__)("Change tone", "elementor"),
2893 options: vocalTones,
2894 getInstruction: function getInstruction(value) {
2895 return "Change the tone of the following message to ".concat(value);
2896 }
2897 }, {
2898 label: (0, _wordpress_i18n.__)("Translate to", "elementor"),
2899 options: translateLanguages,
2900 getInstruction: function getInstruction(value) {
2901 return "Translate the following message to ".concat(value);
2902 }
2903 }];
2904 var FormText = function FormText(_ref) {
2905 var _initialValue$result;
2906 var _initialValue$credits;
2907 var _additionalOptions$in;
2908 var type = _ref.type;
2909 var onClose = _ref.onClose;
2910 var getControlValue = _ref.getControlValue;
2911 var setControlValue = _ref.setControlValue;
2912 var additionalOptions = _ref.additionalOptions;
2913 var credits = _ref.credits;
2914 var children = _ref.children;
2915 var initialValue = getControlValue() === (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.defaultValue) ? "" : getControlValue();
2916 var _useTextPrompt = useTextPrompt({
2917 result: (_initialValue$result = initialValue === null || initialValue === void 0 ? void 0 : initialValue.result) !== null && _initialValue$result !== void 0 ? _initialValue$result : initialValue,
2918 credits: (_initialValue$credits = initialValue === null || initialValue === void 0 ? void 0 : initialValue.credits) !== null && _initialValue$credits !== void 0 ? _initialValue$credits : credits,
2919 responseId: initialValue === null || initialValue === void 0 ? void 0 : initialValue.responseId
2920 });
2921 var data = _useTextPrompt.data;
2922 var isLoading = _useTextPrompt.isLoading;
2923 var txtGenErr = _useTextPrompt.error;
2924 var setResult = _useTextPrompt.setResult;
2925 var reset = _useTextPrompt.reset;
2926 var send = _useTextPrompt.send;
2927 var sendUsageData = _useTextPrompt.sendUsageData;
2928 var error = txtGenErr || (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.initError);
2929 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
2930 var prompt = _useState2[0];
2931 var setPrompt = _useState2[1];
2932 var setGenerate = useRequestIds().setGenerate;
2933 useSubscribeOnPromptHistoryAction([{
2934 type: ACTION_TYPES.REUSE,
2935 handler: function handler(action) {
2936 reset();
2937 setPrompt(action.data);
2938 }
2939 }, {
2940 type: ACTION_TYPES.EDIT,
2941 handler: function handler(action) {
2942 setResult(action.data);
2943 }
2944 }]);
2945 var searchField = (0, react.useRef)(null);
2946 var resultField = (0, react.useRef)(null);
2947 var lastRun = (0, react.useRef)((_additionalOptions$in = additionalOptions.initRetry) !== null && _additionalOptions$in !== void 0 ? _additionalOptions$in : function() {});
2948 var autocompleteItems = "textarea" === type ? textareaAutocomplete : textAutocomplete;
2949 var showSuggestions = !prompt;
2950 var handleSubmit = function handleSubmit(event) {
2951 event.preventDefault();
2952 setGenerate();
2953 lastRun.current = function() {
2954 return send({ prompt });
2955 };
2956 lastRun.current();
2957 };
2958 var handleCustomInstruction = /*#__PURE__*/ function() {
2959 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(instruction) {
2960 return import_regenerator$2.default.wrap(function(_context) {
2961 while (1) switch (_context.prev = _context.next) {
2962 case 0:
2963 setGenerate();
2964 lastRun.current = function() {
2965 return send({
2966 input: resultField.current.value,
2967 instruction
2968 });
2969 };
2970 lastRun.current();
2971 case 1:
2972 case "end": return _context.stop();
2973 }
2974 }, _callee);
2975 }));
2976 return function handleCustomInstruction(_x) {
2977 return _ref2.apply(this, arguments);
2978 };
2979 }();
2980 var handleSuggestion = function handleSuggestion(suggestion) {
2981 setPrompt(suggestion + " ");
2982 searchField.current.focus();
2983 };
2984 var applyPrompt = function applyPrompt() {
2985 sendUsageData();
2986 setControlValue(resultField.current.value);
2987 onClose();
2988 };
2989 if (isLoading) return /*#__PURE__*/ react.default.createElement(Loader, null);
2990 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, error && /*#__PURE__*/ react.default.createElement(PromptErrorMessage, {
2991 error,
2992 onRetry: lastRun.current,
2993 sx: { mb: 2.5 }
2994 }), children, !data.result && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
2995 component: "form",
2996 onSubmit: handleSubmit
2997 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: { mb: 2.5 } }, /*#__PURE__*/ react.default.createElement(PromptSearch, {
2998 ref: searchField,
2999 placeholder: (0, _wordpress_i18n.__)("Describe the text and tone you want to use...", "elementor"),
3000 name: "prompt",
3001 value: prompt,
3002 onChange: function onChange(event) {
3003 return setPrompt(event.target.value);
3004 }
3005 })), showSuggestions && /*#__PURE__*/ react.default.createElement(PromptSuggestions, {
3006 suggestions: autocompleteItems,
3007 onSelect: handleSuggestion,
3008 suggestionFilter: function suggestionFilter(suggestion) {
3009 return suggestion + "...";
3010 }
3011 }, /*#__PURE__*/ react.default.createElement(PromptLibraryLink, { libraryLink: "https://go.elementor.com/ai-prompt-library-text/" })), additionalOptions.hideAiContext ? null : /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, {
3012 introductionKey: "ai-context-text-promotion",
3013 sx: { mb: 2 }
3014 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3015 direction: "row",
3016 alignItems: "center",
3017 sx: {
3018 pb: 1.5,
3019 mt: 2
3020 }
3021 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3022 direction: "row",
3023 justifyContent: "flex-end",
3024 flexGrow: 1
3025 }, /*#__PURE__*/ react.default.createElement(GenerateButton$1, null, (0, _wordpress_i18n.__)("Generate text", "elementor"))))), data.result && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: { mt: 1 } }, /*#__PURE__*/ react.default.createElement(Textarea, {
3026 fullWidth: true,
3027 ref: resultField,
3028 value: data.result,
3029 helperText: (0, _wordpress_i18n.__)("Text generated by AI may be inaccurate or offensive.", "elementor"),
3030 onChange: function onChange(event) {
3031 return setResult(event.target.value);
3032 }
3033 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Grid, {
3034 container: true,
3035 spacing: 1,
3036 sx: { mt: 2.5 }
3037 }, promptActions.map(function(_ref3) {
3038 var label = _ref3.label;
3039 var icon = _ref3.icon;
3040 var value = _ref3.value;
3041 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Grid, {
3042 item: true,
3043 key: label
3044 }, /*#__PURE__*/ react.default.createElement(PromptAction, {
3045 label,
3046 icon,
3047 onClick: function onClick() {
3048 return handleCustomInstruction(value);
3049 }
3050 }));
3051 })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3052 direction: "row",
3053 alignItems: "center",
3054 spacing: 1,
3055 sx: { mt: 2.5 }
3056 }, promptInstructions.map(function(_ref4) {
3057 var label = _ref4.label;
3058 var options = _ref4.options;
3059 var getInstruction = _ref4.getInstruction;
3060 return /*#__PURE__*/ react.default.createElement(PromptActionSelection, {
3061 key: label,
3062 label,
3063 options,
3064 onChange: function onChange(event) {
3065 return handleCustomInstruction(getInstruction(event.target.value));
3066 }
3067 });
3068 })), additionalOptions.hideAiContext ? null : /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, {
3069 introductionKey: "ai-context-text-promotion",
3070 sx: { mb: 2 }
3071 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3072 direction: "row",
3073 alignItems: "center",
3074 sx: { my: 1 }
3075 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3076 direction: "row",
3077 gap: 1,
3078 justifyContent: "flex-end",
3079 flexGrow: 1
3080 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
3081 size: "small",
3082 color: "secondary",
3083 variant: "text",
3084 onClick: reset
3085 }, (0, _wordpress_i18n.__)("New prompt", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
3086 size: "small",
3087 variant: "contained",
3088 color: "primary",
3089 onClick: applyPrompt
3090 }, (0, _wordpress_i18n.__)("Use text", "elementor"))))));
3091 };
3092 FormText.propTypes = {
3093 type: import_prop_types$7.default.string.isRequired,
3094 controlType: import_prop_types$7.default.string,
3095 onClose: import_prop_types$7.default.func.isRequired,
3096 getControlValue: import_prop_types$7.default.func.isRequired,
3097 setControlValue: import_prop_types$7.default.func.isRequired,
3098 additionalOptions: import_prop_types$7.default.object,
3099 credits: import_prop_types$7.default.number,
3100 usagePercentage: import_prop_types$7.default.number,
3101 children: import_prop_types$7.default.node
3102 };
3103
3104 //#endregion
3105 //#region modules/ai/assets/js/editor/pages/connect/index.js
3106 var Connect = function Connect(_ref) {
3107 var connectUrl = _ref.connectUrl;
3108 var onSuccess = _ref.onSuccess;
3109 var approveButtonRef = (0, react.useRef)();
3110 (0, react.useEffect)(function() {
3111 if (!jQuery.fn.elementorConnect) return;
3112 jQuery(approveButtonRef.current).elementorConnect({
3113 success: function success(_, data) {
3114 return onSuccess(data);
3115 },
3116 error: function error() {
3117 throw new Error("Elementor AI: Failed to connect.");
3118 }
3119 });
3120 }, []);
3121 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3122 alignItems: "center",
3123 gap: 2
3124 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { sx: {
3125 color: "text.primary",
3126 fontSize: "60px",
3127 mb: 1
3128 } }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
3129 variant: "h4",
3130 sx: { color: "text.primary" }
3131 }, (0, _wordpress_i18n.__)("Step into the future with Elementor AI", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "body2" }, (0, _wordpress_i18n.__)("Create smarter with AI text and code generators built right into the editor.", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
3132 variant: "caption",
3133 sx: {
3134 maxWidth: 520,
3135 textAlign: "center"
3136 }
3137 }, " ", (0, _wordpress_i18n.__)("By clicking \"Connect\", I approve the ", "elementor"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
3138 href: "https://go.elementor.com/ai-terms/",
3139 target: "_blank",
3140 color: "info.main"
3141 }, (0, _wordpress_i18n.__)("Terms of Service", "elementor")), " & ", /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
3142 href: "https://go.elementor.com/ai-privacy-policy/",
3143 target: "_blank",
3144 color: "info.main"
3145 }, (0, _wordpress_i18n.__)("Privacy Policy", "elementor")), (0, _wordpress_i18n.__)(" of the Elementor AI service.", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
3146 ref: approveButtonRef,
3147 href: connectUrl,
3148 variant: "contained",
3149 sx: {
3150 mt: 1,
3151 "&:hover": { color: "primary.contrastText" }
3152 }
3153 }, (0, _wordpress_i18n.__)("Connect", "elementor")));
3154 };
3155 Connect.propTypes = {
3156 connectUrl: import_prop_types$7.default.string.isRequired,
3157 onSuccess: import_prop_types$7.default.func.isRequired
3158 };
3159
3160 //#endregion
3161 //#region modules/ai/assets/js/editor/pages/get-started/index.js
3162 init_asyncToGenerator();
3163 init_slicedToArray();
3164 init_api();
3165 var GetStarted = function GetStarted(_ref) {
3166 var onSuccess = _ref.onSuccess;
3167 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
3168 var isTermsChecked = _useState2[0];
3169 var setIsTermsChecked = _useState2[1];
3170 var onGetStartedClick = /*#__PURE__*/ function() {
3171 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee() {
3172 return import_regenerator$2.default.wrap(function(_context) {
3173 while (1) switch (_context.prev = _context.next) {
3174 case 0:
3175 _context.next = 1;
3176 return setGetStarted();
3177 case 1: onSuccess();
3178 case 2:
3179 case "end": return _context.stop();
3180 }
3181 }, _callee);
3182 }));
3183 return function onGetStartedClick() {
3184 return _ref2.apply(this, arguments);
3185 };
3186 }();
3187 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3188 alignItems: "center",
3189 gap: 1.5
3190 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { sx: {
3191 color: "text.primary",
3192 fontSize: "60px",
3193 mb: 1
3194 } }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
3195 variant: "h4",
3196 sx: { color: "text.primary" }
3197 }, (0, _wordpress_i18n.__)("Step into the future with Elementor AI", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "body2" }, (0, _wordpress_i18n.__)("Create smarter with AI text and code generators built right into the editor.", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3198 direction: "row",
3199 gap: 1.5,
3200 alignItems: "flex-start"
3201 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Checkbox, {
3202 id: "e-ai-terms-approval",
3203 color: "secondary",
3204 checked: isTermsChecked,
3205 onClick: function onClick() {
3206 return setIsTermsChecked(function(prevState) {
3207 return !prevState;
3208 });
3209 }
3210 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
3211 variant: "caption",
3212 sx: { maxWidth: 520 },
3213 component: "label",
3214 htmlFor: "e-ai-terms-approval"
3215 }, " ", (0, _wordpress_i18n.__)("I approve the ", "elementor"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
3216 href: "https://go.elementor.com/ai-terms/",
3217 target: "_blank",
3218 color: "info.main"
3219 }, (0, _wordpress_i18n.__)("Terms of Service", "elementor")), " & ", /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
3220 href: "https://go.elementor.com/ai-privacy-policy/",
3221 target: "_blank",
3222 color: "info.main"
3223 }, (0, _wordpress_i18n.__)("Privacy Policy", "elementor")), (0, _wordpress_i18n.__)(" of the Elementor AI service.", "elementor"), /*#__PURE__*/ react.default.createElement("br", null), (0, _wordpress_i18n.__)("This includes consenting to the collection and use of data to improve user experience.", "elementor")))), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
3224 disabled: !isTermsChecked,
3225 variant: "contained",
3226 onClick: onGetStartedClick,
3227 sx: {
3228 mt: 1,
3229 "&:hover": { color: "primary.contrastText" }
3230 }
3231 }, (0, _wordpress_i18n.__)("Get Started", "elementor")));
3232 };
3233 GetStarted.propTypes = { onSuccess: import_prop_types$7.default.func.isRequired };
3234
3235 //#endregion
3236 //#region modules/ai/assets/js/editor/hooks/use-user-info.js
3237 init_defineProperty();
3238 init_asyncToGenerator();
3239 init_slicedToArray();
3240 init_api();
3241 function ownKeys$28(e, r) {
3242 var t = Object.keys(e);
3243 if (Object.getOwnPropertySymbols) {
3244 var o = Object.getOwnPropertySymbols(e);
3245 r && (o = o.filter(function(r) {
3246 return Object.getOwnPropertyDescriptor(e, r).enumerable;
3247 })), t.push.apply(t, o);
3248 }
3249 return t;
3250 }
3251 __name(ownKeys$28, "ownKeys");
3252 function _objectSpread$28(e) {
3253 for (var r = 1; r < arguments.length; r++) {
3254 var t = null != arguments[r] ? arguments[r] : {};
3255 r % 2 ? ownKeys$28(Object(t), !0).forEach(function(r) {
3256 _defineProperty(e, r, t[r]);
3257 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$28(Object(t)).forEach(function(r) {
3258 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
3259 });
3260 }
3261 return e;
3262 }
3263 __name(_objectSpread$28, "_objectSpread");
3264 var useUserInfo = function useUserInfo() {
3265 var immediately = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
3266 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
3267 var isLoaded = _useState2[0];
3268 var setIsLoaded = _useState2[1];
3269 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
3270 var isLoading = _useState4[0];
3271 var setIsLoading = _useState4[1];
3272 var _useState6 = _slicedToArray((0, react.useState)({
3273 is_connected: false,
3274 is_get_started: false,
3275 connect_url: "",
3276 usage: {
3277 hasAiSubscription: false,
3278 quota: 0,
3279 usedQuota: 0
3280 }
3281 }), 2);
3282 var userInfo = _useState6[0];
3283 var setUserInfo = _useState6[1];
3284 var credits = userInfo.usage.quota - userInfo.usage.usedQuota;
3285 var usagePercentage = userInfo.usage.quota ? userInfo.usage.usedQuota / userInfo.usage.quota * 100 : 0;
3286 var fetchData = /*#__PURE__*/ function() {
3287 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee() {
3288 var userInfoResult;
3289 return import_regenerator$2.default.wrap(function(_context) {
3290 while (1) switch (_context.prev = _context.next) {
3291 case 0:
3292 setIsLoading(true);
3293 _context.next = 1;
3294 return getUserInformation(immediately);
3295 case 1:
3296 userInfoResult = _context.sent;
3297 setUserInfo(function(prevState) {
3298 return _objectSpread$28(_objectSpread$28({}, prevState), userInfoResult);
3299 });
3300 setIsLoaded(true);
3301 setIsLoading(false);
3302 case 2:
3303 case "end": return _context.stop();
3304 }
3305 }, _callee);
3306 }));
3307 return function fetchData() {
3308 return _ref.apply(this, arguments);
3309 };
3310 }();
3311 if (!isLoaded && !isLoading) fetchData();
3312 return {
3313 isLoading,
3314 isLoaded,
3315 isConnected: userInfo.is_connected,
3316 isGetStarted: userInfo.is_get_started,
3317 connectUrl: userInfo.connect_url,
3318 builderUrl: userInfo.usage.builderUrl,
3319 hasSubscription: userInfo.usage.hasAiSubscription,
3320 credits: credits < 0 ? 0 : credits,
3321 usagePercentage: Math.round(usagePercentage),
3322 fetchData
3323 };
3324 };
3325 useUserInfo.propTypes = { immediately: import_prop_types$7.default.bool };
3326
3327 //#endregion
3328 //#region modules/ai/assets/js/editor/components/dialog-header.js
3329 init_extends();
3330 var StyledElementorLogo = (0, _elementor_ui.styled)(function ElementorLogo(props) {
3331 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 32 32" }, props), /*#__PURE__*/ react.default.createElement("path", {
3332 fillRule: "evenodd",
3333 clipRule: "evenodd",
3334 d: "M2.69648 24.8891C0.938383 22.2579 0 19.1645 0 16C0 11.7566 1.68571 7.68687 4.68629 4.68629C7.68687 1.68571 11.7566 0 16 0C19.1645 0 22.2579 0.938383 24.8891 2.69648C27.5203 4.45459 29.5711 6.95344 30.7821 9.87706C31.9931 12.8007 32.3099 16.0177 31.6926 19.1214C31.0752 22.2251 29.5514 25.0761 27.3137 27.3137C25.0761 29.5514 22.2251 31.0752 19.1214 31.6926C16.0177 32.3099 12.8007 31.9931 9.87706 30.7821C6.95344 29.5711 4.45459 27.5203 2.69648 24.8891ZM12.0006 9.33281H9.33437V22.6665H12.0006V9.33281ZM22.6657 9.33281H14.6669V11.9991H22.6657V9.33281ZM22.6657 14.6654H14.6669V17.3316H22.6657V14.6654ZM22.6657 20.0003H14.6669V22.6665H22.6657V20.0003Z"
3335 }));
3336 })(function(_ref) {
3337 var theme = _ref.theme;
3338 return {
3339 width: theme.spacing(3),
3340 height: theme.spacing(3),
3341 "& path": { fill: theme.palette.text.primary }
3342 };
3343 });
3344 var DialogHeader$1 = function DialogHeader(props) {
3345 var hideAiBetaLogo = props.hideAiBetaLogo;
3346 var onClose = props.onClose;
3347 var children = props.children;
3348 return /*#__PURE__*/ react.default.createElement(_elementor_ui.AppBar, {
3349 sx: { fontWeight: "normal" },
3350 color: "transparent",
3351 position: "relative"
3352 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Toolbar, { variant: "dense" }, !hideAiBetaLogo && /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(StyledElementorLogo, { sx: { mr: 1 } }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
3353 component: "span",
3354 variant: "subtitle2",
3355 sx: {
3356 fontWeight: "bold",
3357 textTransform: "uppercase"
3358 }
3359 }, (0, _wordpress_i18n.__)("AI", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Chip, {
3360 label: (0, _wordpress_i18n.__)("Beta", "elementor"),
3361 color: "default",
3362 size: "small",
3363 sx: { ml: 1 }
3364 })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3365 direction: "row",
3366 spacing: 1,
3367 alignItems: "center",
3368 sx: { ml: hideAiBetaLogo ? 0 : "auto" }
3369 }, children, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
3370 size: "small",
3371 "aria-label": "close",
3372 onClick: onClose,
3373 sx: { "&.MuiButtonBase-root": { mr: -1 } }
3374 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.XIcon, null)))));
3375 };
3376 DialogHeader$1.propTypes = {
3377 onClose: import_prop_types$7.default.func.isRequired,
3378 hideAiBetaLogo: import_prop_types$7.default.bool,
3379 children: import_prop_types$7.default.oneOfType([import_prop_types$7.default.arrayOf(import_prop_types$7.default.node), import_prop_types$7.default.node])
3380 };
3381
3382 //#endregion
3383 //#region modules/ai/assets/js/editor/components/wizard-dialog.js
3384 init_extends();
3385 init_defineProperty();
3386 init_objectWithoutProperties();
3387 var _excluded$30 = ["sx"];
3388 function ownKeys$27(e, r) {
3389 var t = Object.keys(e);
3390 if (Object.getOwnPropertySymbols) {
3391 var o = Object.getOwnPropertySymbols(e);
3392 r && (o = o.filter(function(r) {
3393 return Object.getOwnPropertyDescriptor(e, r).enumerable;
3394 })), t.push.apply(t, o);
3395 }
3396 return t;
3397 }
3398 __name(ownKeys$27, "ownKeys");
3399 function _objectSpread$27(e) {
3400 for (var r = 1; r < arguments.length; r++) {
3401 var t = null != arguments[r] ? arguments[r] : {};
3402 r % 2 ? ownKeys$27(Object(t), !0).forEach(function(r) {
3403 _defineProperty(e, r, t[r]);
3404 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$27(Object(t)).forEach(function(r) {
3405 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
3406 });
3407 }
3408 return e;
3409 }
3410 __name(_objectSpread$27, "_objectSpread");
3411 var WizardDialog = function WizardDialog(props) {
3412 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, {
3413 open: true,
3414 onClose: props.onClose,
3415 fullWidth: true,
3416 hideBackdrop: true,
3417 maxWidth: "lg",
3418 PaperProps: { sx: { height: "88vh" } },
3419 sx: { zIndex: 9999 }
3420 }, props.children);
3421 };
3422 WizardDialog.propTypes = {
3423 onClose: import_prop_types$7.default.func.isRequired,
3424 children: import_prop_types$7.default.node.isRequired
3425 };
3426 var WizardDialogContent = function WizardDialogContent(_ref) {
3427 var _ref$sx = _ref.sx;
3428 var sx = _ref$sx === void 0 ? {} : _ref$sx;
3429 var props = _objectWithoutProperties(_ref, _excluded$30);
3430 return /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogContent, _extends$1({}, props, { sx: _objectSpread$27({
3431 display: "flex",
3432 flexDirection: "column",
3433 justifyContent: "center"
3434 }, sx) }));
3435 };
3436 WizardDialogContent.propTypes = { sx: import_prop_types$7.default.object };
3437 WizardDialog.Header = DialogHeader$1;
3438 WizardDialog.Content = WizardDialogContent;
3439
3440 //#endregion
3441 //#region node_modules/react-draggable/node_modules/clsx/dist/clsx.js
3442 var require_clsx = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3443 function r(e) {
3444 var o;
3445 var t;
3446 var f = "";
3447 if ("string" == typeof e || "number" == typeof e) f += e;
3448 else if ("object" == typeof e) if (Array.isArray(e)) {
3449 var n = e.length;
3450 for (o = 0; o < n; o++) e[o] && (t = r(e[o])) && (f && (f += " "), f += t);
3451 } else for (t in e) e[t] && (f && (f += " "), f += t);
3452 return f;
3453 }
3454 function e() {
3455 for (var e, o, t = 0, f = "", n = arguments.length; t < n; t++) (e = arguments[t]) && (o = r(e)) && (f && (f += " "), f += o);
3456 return f;
3457 }
3458 module.exports = e, module.exports.clsx = e;
3459 }));
3460
3461 //#endregion
3462 //#region node_modules/react-draggable/build/cjs/utils/shims.js
3463 var require_shims = /* @__PURE__ */ __commonJSMin(((exports) => {
3464 Object.defineProperty(exports, "__esModule", { value: true });
3465 exports.dontSetMe = dontSetMe;
3466 exports.findInArray = findInArray;
3467 exports.int = int;
3468 exports.isFunction = isFunction;
3469 exports.isNum = isNum;
3470 function findInArray(array, callback) {
3471 for (let i = 0, length = array.length; i < length; i++) if (callback.apply(callback, [
3472 array[i],
3473 i,
3474 array
3475 ])) return array[i];
3476 }
3477 function isFunction(func) {
3478 return typeof func === "function" || Object.prototype.toString.call(func) === "[object Function]";
3479 }
3480 function isNum(num) {
3481 return typeof num === "number" && !isNaN(num);
3482 }
3483 function int(a) {
3484 return parseInt(a, 10);
3485 }
3486 function dontSetMe(props, propName, componentName) {
3487 if (props[propName]) return /* @__PURE__ */ new Error(`Invalid prop ${propName} passed to ${componentName} - do not set this, set it on the child.`);
3488 }
3489 }));
3490
3491 //#endregion
3492 //#region node_modules/react-draggable/build/cjs/utils/getPrefix.js
3493 var require_getPrefix = /* @__PURE__ */ __commonJSMin(((exports) => {
3494 Object.defineProperty(exports, "__esModule", { value: true });
3495 exports.browserPrefixToKey = browserPrefixToKey;
3496 exports.browserPrefixToStyle = browserPrefixToStyle;
3497 exports.default = void 0;
3498 exports.getPrefix = getPrefix;
3499 var prefixes = [
3500 "Moz",
3501 "Webkit",
3502 "O",
3503 "ms"
3504 ];
3505 function getPrefix() {
3506 var _window$document;
3507 let prop = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "transform";
3508 if (typeof window === "undefined") return "";
3509 const style = (_window$document = window.document) === null || _window$document === void 0 || (_window$document = _window$document.documentElement) === null || _window$document === void 0 ? void 0 : _window$document.style;
3510 if (!style) return "";
3511 if (prop in style) return "";
3512 for (let i = 0; i < prefixes.length; i++) if (browserPrefixToKey(prop, prefixes[i]) in style) return prefixes[i];
3513 return "";
3514 }
3515 function browserPrefixToKey(prop, prefix) {
3516 return prefix ? `${prefix}${kebabToTitleCase(prop)}` : prop;
3517 }
3518 function browserPrefixToStyle(prop, prefix) {
3519 return prefix ? `-${prefix.toLowerCase()}-${prop}` : prop;
3520 }
3521 function kebabToTitleCase(str) {
3522 let out = "";
3523 let shouldCapitalize = true;
3524 for (let i = 0; i < str.length; i++) if (shouldCapitalize) {
3525 out += str[i].toUpperCase();
3526 shouldCapitalize = false;
3527 } else if (str[i] === "-") shouldCapitalize = true;
3528 else out += str[i];
3529 return out;
3530 }
3531 exports.default = getPrefix();
3532 }));
3533
3534 //#endregion
3535 //#region node_modules/react-draggable/build/cjs/utils/domFns.js
3536 var require_domFns = /* @__PURE__ */ __commonJSMin(((exports) => {
3537 init_objectSpread2();
3538 Object.defineProperty(exports, "__esModule", { value: true });
3539 exports.addClassName = addClassName;
3540 exports.addEvent = addEvent;
3541 exports.addUserSelectStyles = addUserSelectStyles;
3542 exports.createCSSTransform = createCSSTransform;
3543 exports.createSVGTransform = createSVGTransform;
3544 exports.getTouch = getTouch;
3545 exports.getTouchIdentifier = getTouchIdentifier;
3546 exports.getTranslation = getTranslation;
3547 exports.innerHeight = innerHeight;
3548 exports.innerWidth = innerWidth;
3549 exports.matchesSelector = matchesSelector;
3550 exports.matchesSelectorAndParentsTo = matchesSelectorAndParentsTo;
3551 exports.offsetXYFromParent = offsetXYFromParent;
3552 exports.outerHeight = outerHeight;
3553 exports.outerWidth = outerWidth;
3554 exports.removeClassName = removeClassName;
3555 exports.removeEvent = removeEvent;
3556 exports.scheduleRemoveUserSelectStyles = scheduleRemoveUserSelectStyles;
3557 var _shims = require_shims();
3558 var _getPrefix = _interopRequireWildcard(require_getPrefix());
3559 function _interopRequireWildcard(e, t) {
3560 if ("function" == typeof WeakMap) {
3561 var r = /* @__PURE__ */ new WeakMap();
3562 var n = /* @__PURE__ */ new WeakMap();
3563 }
3564 return (_interopRequireWildcard = function(e, t) {
3565 if (!t && e && e.__esModule) return e;
3566 var o;
3567 var i;
3568 var f = {
3569 __proto__: null,
3570 default: e
3571 };
3572 if (null === e || "object" != typeof e && "function" != typeof e) return f;
3573 if (o = t ? n : r) {
3574 if (o.has(e)) return o.get(e);
3575 o.set(e, f);
3576 }
3577 for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);
3578 return f;
3579 })(e, t);
3580 }
3581 var matchesSelectorFunc = "";
3582 function matchesSelector(el, selector) {
3583 if (!matchesSelectorFunc) matchesSelectorFunc = (0, _shims.findInArray)([
3584 "matches",
3585 "webkitMatchesSelector",
3586 "mozMatchesSelector",
3587 "msMatchesSelector",
3588 "oMatchesSelector"
3589 ], function(method) {
3590 return (0, _shims.isFunction)(el[method]);
3591 });
3592 if (!(0, _shims.isFunction)(el[matchesSelectorFunc])) return false;
3593 return el[matchesSelectorFunc](selector);
3594 }
3595 function matchesSelectorAndParentsTo(el, selector, baseNode) {
3596 let node = el;
3597 do {
3598 if (matchesSelector(node, selector)) return true;
3599 if (node === baseNode) return false;
3600 node = node.parentNode;
3601 } while (node);
3602 return false;
3603 }
3604 function addEvent(el, event, handler, inputOptions) {
3605 if (!el) return;
3606 const options = _objectSpread2({ capture: true }, inputOptions);
3607 if (el.addEventListener) el.addEventListener(event, handler, options);
3608 else if (el.attachEvent) el.attachEvent("on" + event, handler);
3609 else el["on" + event] = handler;
3610 }
3611 function removeEvent(el, event, handler, inputOptions) {
3612 if (!el) return;
3613 const options = _objectSpread2({ capture: true }, inputOptions);
3614 if (el.removeEventListener) el.removeEventListener(event, handler, options);
3615 else if (el.detachEvent) el.detachEvent("on" + event, handler);
3616 else el["on" + event] = null;
3617 }
3618 function outerHeight(node) {
3619 let height = node.clientHeight;
3620 const computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
3621 height += (0, _shims.int)(computedStyle.borderTopWidth);
3622 height += (0, _shims.int)(computedStyle.borderBottomWidth);
3623 return height;
3624 }
3625 function outerWidth(node) {
3626 let width = node.clientWidth;
3627 const computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
3628 width += (0, _shims.int)(computedStyle.borderLeftWidth);
3629 width += (0, _shims.int)(computedStyle.borderRightWidth);
3630 return width;
3631 }
3632 function innerHeight(node) {
3633 let height = node.clientHeight;
3634 const computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
3635 height -= (0, _shims.int)(computedStyle.paddingTop);
3636 height -= (0, _shims.int)(computedStyle.paddingBottom);
3637 return height;
3638 }
3639 function innerWidth(node) {
3640 let width = node.clientWidth;
3641 const computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
3642 width -= (0, _shims.int)(computedStyle.paddingLeft);
3643 width -= (0, _shims.int)(computedStyle.paddingRight);
3644 return width;
3645 }
3646 function offsetXYFromParent(evt, offsetParent, scale) {
3647 const offsetParentRect = offsetParent === offsetParent.ownerDocument.body ? {
3648 left: 0,
3649 top: 0
3650 } : offsetParent.getBoundingClientRect();
3651 return {
3652 x: (evt.clientX + offsetParent.scrollLeft - offsetParentRect.left) / scale,
3653 y: (evt.clientY + offsetParent.scrollTop - offsetParentRect.top) / scale
3654 };
3655 }
3656 function createCSSTransform(controlPos, positionOffset) {
3657 const translation = getTranslation(controlPos, positionOffset, "px");
3658 return { [(0, _getPrefix.browserPrefixToKey)("transform", _getPrefix.default)]: translation };
3659 }
3660 function createSVGTransform(controlPos, positionOffset) {
3661 return getTranslation(controlPos, positionOffset, "");
3662 }
3663 function getTranslation(_ref, positionOffset, unitSuffix) {
3664 let { x, y } = _ref;
3665 let translation = `translate(${x}${unitSuffix},${y}${unitSuffix})`;
3666 if (positionOffset) translation = `translate(${`${typeof positionOffset.x === "string" ? positionOffset.x : positionOffset.x + unitSuffix}`}, ${`${typeof positionOffset.y === "string" ? positionOffset.y : positionOffset.y + unitSuffix}`})` + translation;
3667 return translation;
3668 }
3669 function getTouch(e, identifier) {
3670 return e.targetTouches && (0, _shims.findInArray)(e.targetTouches, (t) => identifier === t.identifier) || e.changedTouches && (0, _shims.findInArray)(e.changedTouches, (t) => identifier === t.identifier);
3671 }
3672 function getTouchIdentifier(e) {
3673 if (e.targetTouches && e.targetTouches[0]) return e.targetTouches[0].identifier;
3674 if (e.changedTouches && e.changedTouches[0]) return e.changedTouches[0].identifier;
3675 }
3676 function addUserSelectStyles(doc) {
3677 if (!doc) return;
3678 let styleEl = doc.getElementById("react-draggable-style-el");
3679 if (!styleEl) {
3680 styleEl = doc.createElement("style");
3681 styleEl.type = "text/css";
3682 styleEl.id = "react-draggable-style-el";
3683 styleEl.innerHTML = ".react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n";
3684 styleEl.innerHTML += ".react-draggable-transparent-selection *::selection {all: inherit;}\n";
3685 doc.getElementsByTagName("head")[0].appendChild(styleEl);
3686 }
3687 if (doc.body) addClassName(doc.body, "react-draggable-transparent-selection");
3688 }
3689 function scheduleRemoveUserSelectStyles(doc) {
3690 if (window.requestAnimationFrame) window.requestAnimationFrame(() => {
3691 removeUserSelectStyles(doc);
3692 });
3693 else removeUserSelectStyles(doc);
3694 }
3695 function removeUserSelectStyles(doc) {
3696 if (!doc) return;
3697 try {
3698 if (doc.body) removeClassName(doc.body, "react-draggable-transparent-selection");
3699 if (doc.selection) doc.selection.empty();
3700 else {
3701 const selection = (doc.defaultView || window).getSelection();
3702 if (selection && selection.type !== "Caret") selection.removeAllRanges();
3703 }
3704 } catch (e) {}
3705 }
3706 function addClassName(el, className) {
3707 if (el.classList) el.classList.add(className);
3708 else if (!el.className.match(new RegExp(`(?:^|\\s)${className}(?!\\S)`))) el.className += ` ${className}`;
3709 }
3710 function removeClassName(el, className) {
3711 if (el.classList) el.classList.remove(className);
3712 else el.className = el.className.replace(new RegExp(`(?:^|\\s)${className}(?!\\S)`, "g"), "");
3713 }
3714 }));
3715
3716 //#endregion
3717 //#region node_modules/react-draggable/build/cjs/utils/positionFns.js
3718 var require_positionFns = /* @__PURE__ */ __commonJSMin(((exports) => {
3719 Object.defineProperty(exports, "__esModule", { value: true });
3720 exports.canDragX = canDragX;
3721 exports.canDragY = canDragY;
3722 exports.createCoreData = createCoreData;
3723 exports.createDraggableData = createDraggableData;
3724 exports.getBoundPosition = getBoundPosition;
3725 exports.getControlPosition = getControlPosition;
3726 exports.snapToGrid = snapToGrid;
3727 var _shims = require_shims();
3728 var _domFns = require_domFns();
3729 function getBoundPosition(draggable, x, y) {
3730 if (!draggable.props.bounds) return [x, y];
3731 let { bounds } = draggable.props;
3732 bounds = typeof bounds === "string" ? bounds : cloneBounds(bounds);
3733 const node = findDOMNode(draggable);
3734 if (typeof bounds === "string") {
3735 const { ownerDocument } = node;
3736 const ownerWindow = ownerDocument.defaultView;
3737 let boundNode;
3738 if (bounds === "parent") boundNode = node.parentNode;
3739 else boundNode = node.getRootNode().querySelector(bounds);
3740 if (!(boundNode instanceof ownerWindow.HTMLElement)) throw new Error("Bounds selector \"" + bounds + "\" could not find an element.");
3741 const boundNodeEl = boundNode;
3742 const nodeStyle = ownerWindow.getComputedStyle(node);
3743 const boundNodeStyle = ownerWindow.getComputedStyle(boundNodeEl);
3744 bounds = {
3745 left: -node.offsetLeft + (0, _shims.int)(boundNodeStyle.paddingLeft) + (0, _shims.int)(nodeStyle.marginLeft),
3746 top: -node.offsetTop + (0, _shims.int)(boundNodeStyle.paddingTop) + (0, _shims.int)(nodeStyle.marginTop),
3747 right: (0, _domFns.innerWidth)(boundNodeEl) - (0, _domFns.outerWidth)(node) - node.offsetLeft + (0, _shims.int)(boundNodeStyle.paddingRight) - (0, _shims.int)(nodeStyle.marginRight),
3748 bottom: (0, _domFns.innerHeight)(boundNodeEl) - (0, _domFns.outerHeight)(node) - node.offsetTop + (0, _shims.int)(boundNodeStyle.paddingBottom) - (0, _shims.int)(nodeStyle.marginBottom)
3749 };
3750 }
3751 if ((0, _shims.isNum)(bounds.right)) x = Math.min(x, bounds.right);
3752 if ((0, _shims.isNum)(bounds.bottom)) y = Math.min(y, bounds.bottom);
3753 if ((0, _shims.isNum)(bounds.left)) x = Math.max(x, bounds.left);
3754 if ((0, _shims.isNum)(bounds.top)) y = Math.max(y, bounds.top);
3755 return [x, y];
3756 }
3757 function snapToGrid(grid, pendingX, pendingY) {
3758 return [Math.round(pendingX / grid[0]) * grid[0], Math.round(pendingY / grid[1]) * grid[1]];
3759 }
3760 function canDragX(draggable) {
3761 return draggable.props.axis === "both" || draggable.props.axis === "x";
3762 }
3763 function canDragY(draggable) {
3764 return draggable.props.axis === "both" || draggable.props.axis === "y";
3765 }
3766 function getControlPosition(e, touchIdentifier, draggableCore) {
3767 const touchObj = typeof touchIdentifier === "number" ? (0, _domFns.getTouch)(e, touchIdentifier) : null;
3768 if (typeof touchIdentifier === "number" && !touchObj) return null;
3769 const node = findDOMNode(draggableCore);
3770 const offsetParent = draggableCore.props.offsetParent || node.offsetParent || node.ownerDocument.body;
3771 return (0, _domFns.offsetXYFromParent)(touchObj || e, offsetParent, draggableCore.props.scale);
3772 }
3773 function createCoreData(draggable, x, y) {
3774 const isStart = !(0, _shims.isNum)(draggable.lastX);
3775 const node = findDOMNode(draggable);
3776 if (isStart) return {
3777 node,
3778 deltaX: 0,
3779 deltaY: 0,
3780 lastX: x,
3781 lastY: y,
3782 x,
3783 y
3784 };
3785 else return {
3786 node,
3787 deltaX: x - draggable.lastX,
3788 deltaY: y - draggable.lastY,
3789 lastX: draggable.lastX,
3790 lastY: draggable.lastY,
3791 x,
3792 y
3793 };
3794 }
3795 function createDraggableData(draggable, coreData) {
3796 const scale = draggable.props.scale;
3797 return {
3798 node: coreData.node,
3799 x: draggable.state.x + coreData.deltaX / scale,
3800 y: draggable.state.y + coreData.deltaY / scale,
3801 deltaX: coreData.deltaX / scale,
3802 deltaY: coreData.deltaY / scale,
3803 lastX: draggable.state.x,
3804 lastY: draggable.state.y
3805 };
3806 }
3807 function cloneBounds(bounds) {
3808 return {
3809 left: bounds.left,
3810 top: bounds.top,
3811 right: bounds.right,
3812 bottom: bounds.bottom
3813 };
3814 }
3815 function findDOMNode(draggable) {
3816 const node = draggable.findDOMNode();
3817 if (!node) throw new Error("<DraggableCore>: Unmounted during event!");
3818 return node;
3819 }
3820 }));
3821
3822 //#endregion
3823 //#region node_modules/react-draggable/build/cjs/utils/log.js
3824 var require_log = /* @__PURE__ */ __commonJSMin(((exports) => {
3825 Object.defineProperty(exports, "__esModule", { value: true });
3826 exports.default = log;
3827 function log() {}
3828 }));
3829
3830 //#endregion
3831 //#region node_modules/react-draggable/build/cjs/DraggableCore.js
3832 var require_DraggableCore = /* @__PURE__ */ __commonJSMin(((exports) => {
3833 Object.defineProperty(exports, "__esModule", { value: true });
3834 exports.default = void 0;
3835 var React$131 = _interopRequireWildcard((globalThis.React));
3836 var _propTypes = _interopRequireDefault(require_prop_types());
3837 var _reactDom$1 = _interopRequireDefault((globalThis.ReactDOM));
3838 var _domFns = require_domFns();
3839 var _positionFns = require_positionFns();
3840 var _shims = require_shims();
3841 var _log = _interopRequireDefault(require_log());
3842 function _interopRequireDefault(e) {
3843 return e && e.__esModule ? e : { default: e };
3844 }
3845 function _interopRequireWildcard(e, t) {
3846 if ("function" == typeof WeakMap) {
3847 var r = /* @__PURE__ */ new WeakMap();
3848 var n = /* @__PURE__ */ new WeakMap();
3849 }
3850 return (_interopRequireWildcard = function(e, t) {
3851 if (!t && e && e.__esModule) return e;
3852 var o;
3853 var i;
3854 var f = {
3855 __proto__: null,
3856 default: e
3857 };
3858 if (null === e || "object" != typeof e && "function" != typeof e) return f;
3859 if (o = t ? n : r) {
3860 if (o.has(e)) return o.get(e);
3861 o.set(e, f);
3862 }
3863 for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);
3864 return f;
3865 })(e, t);
3866 }
3867 function _defineProperty(e, r, t) {
3868 return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
3869 value: t,
3870 enumerable: !0,
3871 configurable: !0,
3872 writable: !0
3873 }) : e[r] = t, e;
3874 }
3875 function _toPropertyKey(t) {
3876 var i = _toPrimitive(t, "string");
3877 return "symbol" == typeof i ? i : i + "";
3878 }
3879 function _toPrimitive(t, r) {
3880 if ("object" != typeof t || !t) return t;
3881 var e = t[Symbol.toPrimitive];
3882 if (void 0 !== e) {
3883 var i = e.call(t, r || "default");
3884 if ("object" != typeof i) return i;
3885 throw new TypeError("@@toPrimitive must return a primitive value.");
3886 }
3887 return ("string" === r ? String : Number)(t);
3888 }
3889 var eventsFor = {
3890 touch: {
3891 start: "touchstart",
3892 move: "touchmove",
3893 stop: "touchend"
3894 },
3895 mouse: {
3896 start: "mousedown",
3897 move: "mousemove",
3898 stop: "mouseup"
3899 }
3900 };
3901 var dragEventFor = eventsFor.mouse;
3902 var DraggableCore = class extends React$131.Component {
3903 constructor() {
3904 super(...arguments);
3905 _defineProperty(this, "dragging", false);
3906 _defineProperty(this, "lastX", NaN);
3907 _defineProperty(this, "lastY", NaN);
3908 _defineProperty(this, "touchIdentifier", null);
3909 _defineProperty(this, "mounted", false);
3910 _defineProperty(this, "handleDragStart", (e) => {
3911 this.props.onMouseDown(e);
3912 if (!this.props.allowAnyClick && typeof e.button === "number" && e.button !== 0) return false;
3913 const thisNode = this.findDOMNode();
3914 if (!thisNode || !thisNode.ownerDocument || !thisNode.ownerDocument.body) throw new Error("<DraggableCore> not mounted on DragStart!");
3915 const { ownerDocument } = thisNode;
3916 if (this.props.disabled || !(e.target instanceof ownerDocument.defaultView.Node) || this.props.handle && !(0, _domFns.matchesSelectorAndParentsTo)(e.target, this.props.handle, thisNode) || this.props.cancel && (0, _domFns.matchesSelectorAndParentsTo)(e.target, this.props.cancel, thisNode)) return;
3917 if (e.type === "touchstart" && !this.props.allowMobileScroll) e.preventDefault();
3918 const touchIdentifier = (0, _domFns.getTouchIdentifier)(e);
3919 this.touchIdentifier = touchIdentifier;
3920 const position = (0, _positionFns.getControlPosition)(e, touchIdentifier, this);
3921 if (position == null) return;
3922 const { x, y } = position;
3923 const coreEvent = (0, _positionFns.createCoreData)(this, x, y);
3924 (0, _log.default)("DraggableCore: handleDragStart: %j", coreEvent);
3925 (0, _log.default)("calling", this.props.onStart);
3926 if (this.props.onStart(e, coreEvent) === false || this.mounted === false) return;
3927 if (this.props.enableUserSelectHack) (0, _domFns.addUserSelectStyles)(ownerDocument);
3928 this.dragging = true;
3929 this.lastX = x;
3930 this.lastY = y;
3931 (0, _domFns.addEvent)(ownerDocument, dragEventFor.move, this.handleDrag);
3932 (0, _domFns.addEvent)(ownerDocument, dragEventFor.stop, this.handleDragStop);
3933 });
3934 _defineProperty(this, "handleDrag", (e) => {
3935 const position = (0, _positionFns.getControlPosition)(e, this.touchIdentifier, this);
3936 if (position == null) return;
3937 let { x, y } = position;
3938 if (Array.isArray(this.props.grid)) {
3939 let deltaX = x - this.lastX;
3940 let deltaY = y - this.lastY;
3941 [deltaX, deltaY] = (0, _positionFns.snapToGrid)(this.props.grid, deltaX, deltaY);
3942 if (!deltaX && !deltaY) return;
3943 x = this.lastX + deltaX, y = this.lastY + deltaY;
3944 }
3945 const coreEvent = (0, _positionFns.createCoreData)(this, x, y);
3946 (0, _log.default)("DraggableCore: handleDrag: %j", coreEvent);
3947 if (this.props.onDrag(e, coreEvent) === false || this.mounted === false) {
3948 try {
3949 this.handleDragStop(new MouseEvent("mouseup"));
3950 } catch (err) {
3951 const event = document.createEvent("MouseEvents");
3952 event.initMouseEvent("mouseup", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
3953 this.handleDragStop(event);
3954 }
3955 return;
3956 }
3957 this.lastX = x;
3958 this.lastY = y;
3959 });
3960 _defineProperty(this, "handleDragStop", (e) => {
3961 if (!this.dragging) return;
3962 const position = (0, _positionFns.getControlPosition)(e, this.touchIdentifier, this);
3963 if (position == null) return;
3964 let { x, y } = position;
3965 if (Array.isArray(this.props.grid)) {
3966 let deltaX = x - this.lastX || 0;
3967 let deltaY = y - this.lastY || 0;
3968 [deltaX, deltaY] = (0, _positionFns.snapToGrid)(this.props.grid, deltaX, deltaY);
3969 x = this.lastX + deltaX, y = this.lastY + deltaY;
3970 }
3971 const coreEvent = (0, _positionFns.createCoreData)(this, x, y);
3972 if (this.props.onStop(e, coreEvent) === false || this.mounted === false) return false;
3973 const thisNode = this.findDOMNode();
3974 if (thisNode) {
3975 if (this.props.enableUserSelectHack) (0, _domFns.scheduleRemoveUserSelectStyles)(thisNode.ownerDocument);
3976 }
3977 (0, _log.default)("DraggableCore: handleDragStop: %j", coreEvent);
3978 this.dragging = false;
3979 this.lastX = NaN;
3980 this.lastY = NaN;
3981 if (thisNode) {
3982 (0, _log.default)("DraggableCore: Removing handlers");
3983 (0, _domFns.removeEvent)(thisNode.ownerDocument, dragEventFor.move, this.handleDrag);
3984 (0, _domFns.removeEvent)(thisNode.ownerDocument, dragEventFor.stop, this.handleDragStop);
3985 }
3986 });
3987 _defineProperty(this, "onMouseDown", (e) => {
3988 dragEventFor = eventsFor.mouse;
3989 return this.handleDragStart(e);
3990 });
3991 _defineProperty(this, "onMouseUp", (e) => {
3992 dragEventFor = eventsFor.mouse;
3993 return this.handleDragStop(e);
3994 });
3995 _defineProperty(this, "onTouchStart", (e) => {
3996 dragEventFor = eventsFor.touch;
3997 return this.handleDragStart(e);
3998 });
3999 _defineProperty(this, "onTouchEnd", (e) => {
4000 dragEventFor = eventsFor.touch;
4001 return this.handleDragStop(e);
4002 });
4003 }
4004 componentDidMount() {
4005 this.mounted = true;
4006 const thisNode = this.findDOMNode();
4007 if (thisNode) (0, _domFns.addEvent)(thisNode, eventsFor.touch.start, this.onTouchStart, { passive: false });
4008 }
4009 componentWillUnmount() {
4010 this.mounted = false;
4011 const thisNode = this.findDOMNode();
4012 if (thisNode) {
4013 const { ownerDocument } = thisNode;
4014 (0, _domFns.removeEvent)(ownerDocument, eventsFor.mouse.move, this.handleDrag);
4015 (0, _domFns.removeEvent)(ownerDocument, eventsFor.touch.move, this.handleDrag);
4016 (0, _domFns.removeEvent)(ownerDocument, eventsFor.mouse.stop, this.handleDragStop);
4017 (0, _domFns.removeEvent)(ownerDocument, eventsFor.touch.stop, this.handleDragStop);
4018 (0, _domFns.removeEvent)(thisNode, eventsFor.touch.start, this.onTouchStart, { passive: false });
4019 if (this.props.enableUserSelectHack) (0, _domFns.scheduleRemoveUserSelectStyles)(ownerDocument);
4020 }
4021 }
4022 findDOMNode() {
4023 var _this$props;
4024 var _this$props2;
4025 return ((_this$props = this.props) === null || _this$props === void 0 ? void 0 : _this$props.nodeRef) ? (_this$props2 = this.props) === null || _this$props2 === void 0 || (_this$props2 = _this$props2.nodeRef) === null || _this$props2 === void 0 ? void 0 : _this$props2.current : _reactDom$1.default.findDOMNode(this);
4026 }
4027 render() {
4028 return /*#__PURE__*/ React$131.cloneElement(React$131.Children.only(this.props.children), {
4029 onMouseDown: this.onMouseDown,
4030 onMouseUp: this.onMouseUp,
4031 onTouchEnd: this.onTouchEnd
4032 });
4033 }
4034 };
4035 exports.default = DraggableCore;
4036 _defineProperty(DraggableCore, "displayName", "DraggableCore");
4037 _defineProperty(DraggableCore, "propTypes", {
4038 /**
4039 * `allowAnyClick` allows dragging using any mouse button.
4040 * By default, we only accept the left button.
4041 *
4042 * Defaults to `false`.
4043 */
4044 allowAnyClick: _propTypes.default.bool,
4045 /**
4046 * `allowMobileScroll` turns off cancellation of the 'touchstart' event
4047 * on mobile devices. Only enable this if you are having trouble with click
4048 * events. Prefer using 'handle' / 'cancel' instead.
4049 *
4050 * Defaults to `false`.
4051 */
4052 allowMobileScroll: _propTypes.default.bool,
4053 children: _propTypes.default.node.isRequired,
4054 /**
4055 * `disabled`, if true, stops the <Draggable> from dragging. All handlers,
4056 * with the exception of `onMouseDown`, will not fire.
4057 */
4058 disabled: _propTypes.default.bool,
4059 /**
4060 * By default, we add 'user-select:none' attributes to the document body
4061 * to prevent ugly text selection during drag. If this is causing problems
4062 * for your app, set this to `false`.
4063 */
4064 enableUserSelectHack: _propTypes.default.bool,
4065 /**
4066 * `offsetParent`, if set, uses the passed DOM node to compute drag offsets
4067 * instead of using the parent node.
4068 */
4069 offsetParent: function(props, propName) {
4070 if (props[propName] && props[propName].nodeType !== 1) throw new Error("Draggable's offsetParent must be a DOM Node.");
4071 },
4072 /**
4073 * `grid` specifies the x and y that dragging should snap to.
4074 */
4075 grid: _propTypes.default.arrayOf(_propTypes.default.number),
4076 /**
4077 * `handle` specifies a selector to be used as the handle that initiates drag.
4078 *
4079 * Example:
4080 *
4081 * ```jsx
4082 * let App = React.createClass({
4083 * render: function () {
4084 * return (
4085 * <Draggable handle=".handle">
4086 * <div>
4087 * <div className="handle">Click me to drag</div>
4088 * <div>This is some other content</div>
4089 * </div>
4090 * </Draggable>
4091 * );
4092 * }
4093 * });
4094 * ```
4095 */
4096 handle: _propTypes.default.string,
4097 /**
4098 * `cancel` specifies a selector to be used to prevent drag initialization.
4099 *
4100 * Example:
4101 *
4102 * ```jsx
4103 * let App = React.createClass({
4104 * render: function () {
4105 * return(
4106 * <Draggable cancel=".cancel">
4107 * <div>
4108 * <div className="cancel">You can't drag from here</div>
4109 * <div>Dragging here works fine</div>
4110 * </div>
4111 * </Draggable>
4112 * );
4113 * }
4114 * });
4115 * ```
4116 */
4117 cancel: _propTypes.default.string,
4118 nodeRef: _propTypes.default.object,
4119 /**
4120 * Called when dragging starts.
4121 * If this function returns the boolean false, dragging will be canceled.
4122 */
4123 onStart: _propTypes.default.func,
4124 /**
4125 * Called while dragging.
4126 * If this function returns the boolean false, dragging will be canceled.
4127 */
4128 onDrag: _propTypes.default.func,
4129 /**
4130 * Called when dragging stops.
4131 * If this function returns the boolean false, the drag will remain active.
4132 */
4133 onStop: _propTypes.default.func,
4134 /**
4135 * A workaround option which can be passed if onMouseDown needs to be accessed,
4136 * since it'll always be blocked (as there is internal use of onMouseDown)
4137 */
4138 onMouseDown: _propTypes.default.func,
4139 /**
4140 * `scale`, if set, applies scaling while dragging an element
4141 */
4142 scale: _propTypes.default.number,
4143 /**
4144 * These properties should be defined on the child, not here.
4145 */
4146 className: _shims.dontSetMe,
4147 style: _shims.dontSetMe,
4148 transform: _shims.dontSetMe
4149 });
4150 _defineProperty(DraggableCore, "defaultProps", {
4151 allowAnyClick: false,
4152 allowMobileScroll: false,
4153 disabled: false,
4154 enableUserSelectHack: true,
4155 onStart: function() {},
4156 onDrag: function() {},
4157 onStop: function() {},
4158 onMouseDown: function() {},
4159 scale: 1
4160 });
4161 }));
4162
4163 //#endregion
4164 //#region node_modules/react-draggable/build/cjs/Draggable.js
4165 var require_Draggable = /* @__PURE__ */ __commonJSMin(((exports) => {
4166 init_objectSpread2();
4167 init_objectWithoutProperties$1();
4168 var _excluded = [
4169 "axis",
4170 "bounds",
4171 "children",
4172 "defaultPosition",
4173 "defaultClassName",
4174 "defaultClassNameDragging",
4175 "defaultClassNameDragged",
4176 "position",
4177 "positionOffset",
4178 "scale"
4179 ];
4180 Object.defineProperty(exports, "__esModule", { value: true });
4181 Object.defineProperty(exports, "DraggableCore", {
4182 enumerable: true,
4183 get: function() {
4184 return _DraggableCore.default;
4185 }
4186 });
4187 exports.default = void 0;
4188 var React$130 = _interopRequireWildcard((globalThis.React));
4189 var _propTypes = _interopRequireDefault(require_prop_types());
4190 var _reactDom = _interopRequireDefault((globalThis.ReactDOM));
4191 var _clsx = require_clsx();
4192 var _domFns = require_domFns();
4193 var _positionFns = require_positionFns();
4194 var _shims = require_shims();
4195 var _DraggableCore = _interopRequireDefault(require_DraggableCore());
4196 var _log = _interopRequireDefault(require_log());
4197 function _interopRequireDefault(e) {
4198 return e && e.__esModule ? e : { default: e };
4199 }
4200 function _interopRequireWildcard(e, t) {
4201 if ("function" == typeof WeakMap) {
4202 var r = /* @__PURE__ */ new WeakMap();
4203 var n = /* @__PURE__ */ new WeakMap();
4204 }
4205 return (_interopRequireWildcard = function(e, t) {
4206 if (!t && e && e.__esModule) return e;
4207 var o;
4208 var i;
4209 var f = {
4210 __proto__: null,
4211 default: e
4212 };
4213 if (null === e || "object" != typeof e && "function" != typeof e) return f;
4214 if (o = t ? n : r) {
4215 if (o.has(e)) return o.get(e);
4216 o.set(e, f);
4217 }
4218 for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);
4219 return f;
4220 })(e, t);
4221 }
4222 function _extends() {
4223 return _extends = Object.assign ? Object.assign.bind() : function(n) {
4224 for (var e = 1; e < arguments.length; e++) {
4225 var t = arguments[e];
4226 for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
4227 }
4228 return n;
4229 }, _extends.apply(null, arguments);
4230 }
4231 function _defineProperty(e, r, t) {
4232 return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
4233 value: t,
4234 enumerable: !0,
4235 configurable: !0,
4236 writable: !0
4237 }) : e[r] = t, e;
4238 }
4239 function _toPropertyKey(t) {
4240 var i = _toPrimitive(t, "string");
4241 return "symbol" == typeof i ? i : i + "";
4242 }
4243 function _toPrimitive(t, r) {
4244 if ("object" != typeof t || !t) return t;
4245 var e = t[Symbol.toPrimitive];
4246 if (void 0 !== e) {
4247 var i = e.call(t, r || "default");
4248 if ("object" != typeof i) return i;
4249 throw new TypeError("@@toPrimitive must return a primitive value.");
4250 }
4251 return ("string" === r ? String : Number)(t);
4252 }
4253 var Draggable = class extends React$130.Component {
4254 static getDerivedStateFromProps(_ref, _ref2) {
4255 let { position } = _ref;
4256 let { prevPropsPosition } = _ref2;
4257 if (position && (!prevPropsPosition || position.x !== prevPropsPosition.x || position.y !== prevPropsPosition.y)) {
4258 (0, _log.default)("Draggable: getDerivedStateFromProps %j", {
4259 position,
4260 prevPropsPosition
4261 });
4262 return {
4263 x: position.x,
4264 y: position.y,
4265 prevPropsPosition: _objectSpread2({}, position)
4266 };
4267 }
4268 return null;
4269 }
4270 constructor(props) {
4271 super(props);
4272 _defineProperty(this, "onDragStart", (e, coreData) => {
4273 (0, _log.default)("Draggable: onDragStart: %j", coreData);
4274 if (this.props.onStart(e, (0, _positionFns.createDraggableData)(this, coreData)) === false) return false;
4275 this.setState({
4276 dragging: true,
4277 dragged: true
4278 });
4279 });
4280 _defineProperty(this, "onDrag", (e, coreData) => {
4281 if (!this.state.dragging) return false;
4282 (0, _log.default)("Draggable: onDrag: %j", coreData);
4283 const uiData = (0, _positionFns.createDraggableData)(this, coreData);
4284 const newState = {
4285 x: uiData.x,
4286 y: uiData.y,
4287 slackX: 0,
4288 slackY: 0
4289 };
4290 if (this.props.bounds) {
4291 const { x, y } = newState;
4292 newState.x += this.state.slackX;
4293 newState.y += this.state.slackY;
4294 const [newStateX, newStateY] = (0, _positionFns.getBoundPosition)(this, newState.x, newState.y);
4295 newState.x = newStateX;
4296 newState.y = newStateY;
4297 newState.slackX = this.state.slackX + (x - newState.x);
4298 newState.slackY = this.state.slackY + (y - newState.y);
4299 uiData.x = newState.x;
4300 uiData.y = newState.y;
4301 uiData.deltaX = newState.x - this.state.x;
4302 uiData.deltaY = newState.y - this.state.y;
4303 }
4304 if (this.props.onDrag(e, uiData) === false) return false;
4305 this.setState(newState);
4306 });
4307 _defineProperty(this, "onDragStop", (e, coreData) => {
4308 if (!this.state.dragging) return false;
4309 if (this.props.onStop(e, (0, _positionFns.createDraggableData)(this, coreData)) === false) return false;
4310 (0, _log.default)("Draggable: onDragStop: %j", coreData);
4311 const newState = {
4312 dragging: false,
4313 slackX: 0,
4314 slackY: 0
4315 };
4316 if (Boolean(this.props.position)) {
4317 const { x, y } = this.props.position;
4318 newState.x = x;
4319 newState.y = y;
4320 }
4321 this.setState(newState);
4322 });
4323 this.state = {
4324 dragging: false,
4325 dragged: false,
4326 x: props.position ? props.position.x : props.defaultPosition.x,
4327 y: props.position ? props.position.y : props.defaultPosition.y,
4328 prevPropsPosition: _objectSpread2({}, props.position),
4329 slackX: 0,
4330 slackY: 0,
4331 isElementSVG: false
4332 };
4333 if (props.position && !(props.onDrag || props.onStop)) console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.");
4334 }
4335 componentDidMount() {
4336 if (typeof window.SVGElement !== "undefined" && this.findDOMNode() instanceof window.SVGElement) this.setState({ isElementSVG: true });
4337 }
4338 componentWillUnmount() {
4339 if (this.state.dragging) this.setState({ dragging: false });
4340 }
4341 findDOMNode() {
4342 var _this$props$nodeRef$c;
4343 var _this$props;
4344 return (_this$props$nodeRef$c = (_this$props = this.props) === null || _this$props === void 0 || (_this$props = _this$props.nodeRef) === null || _this$props === void 0 ? void 0 : _this$props.current) !== null && _this$props$nodeRef$c !== void 0 ? _this$props$nodeRef$c : _reactDom.default.findDOMNode(this);
4345 }
4346 render() {
4347 const _this$props2 = this.props, { axis, bounds, children, defaultPosition, defaultClassName, defaultClassNameDragging, defaultClassNameDragged, position, positionOffset, scale } = _this$props2, draggableCoreProps = _objectWithoutProperties$1(_this$props2, _excluded);
4348 let style = {};
4349 let svgTransform = null;
4350 const draggable = !Boolean(position) || this.state.dragging;
4351 const validPosition = position || defaultPosition;
4352 const transformOpts = {
4353 x: (0, _positionFns.canDragX)(this) && draggable ? this.state.x : validPosition.x,
4354 y: (0, _positionFns.canDragY)(this) && draggable ? this.state.y : validPosition.y
4355 };
4356 if (this.state.isElementSVG) svgTransform = (0, _domFns.createSVGTransform)(transformOpts, positionOffset);
4357 else style = (0, _domFns.createCSSTransform)(transformOpts, positionOffset);
4358 const className = (0, _clsx.clsx)(children.props.className || "", defaultClassName, {
4359 [defaultClassNameDragging]: this.state.dragging,
4360 [defaultClassNameDragged]: this.state.dragged
4361 });
4362 return /*#__PURE__*/ React$130.createElement(_DraggableCore.default, _extends({}, draggableCoreProps, {
4363 onStart: this.onDragStart,
4364 onDrag: this.onDrag,
4365 onStop: this.onDragStop
4366 }), /*#__PURE__*/ React$130.cloneElement(React$130.Children.only(children), {
4367 className,
4368 style: _objectSpread2(_objectSpread2({}, children.props.style), style),
4369 transform: svgTransform
4370 }));
4371 }
4372 };
4373 exports.default = Draggable;
4374 _defineProperty(Draggable, "displayName", "Draggable");
4375 _defineProperty(Draggable, "propTypes", _objectSpread2(_objectSpread2({}, _DraggableCore.default.propTypes), {}, {
4376 /**
4377 * `axis` determines which axis the draggable can move.
4378 *
4379 * Note that all callbacks will still return data as normal. This only
4380 * controls flushing to the DOM.
4381 *
4382 * 'both' allows movement horizontally and vertically.
4383 * 'x' limits movement to horizontal axis.
4384 * 'y' limits movement to vertical axis.
4385 * 'none' limits all movement.
4386 *
4387 * Defaults to 'both'.
4388 */
4389 axis: _propTypes.default.oneOf([
4390 "both",
4391 "x",
4392 "y",
4393 "none"
4394 ]),
4395 /**
4396 * `bounds` determines the range of movement available to the element.
4397 * Available values are:
4398 *
4399 * 'parent' restricts movement within the Draggable's parent node.
4400 *
4401 * Alternatively, pass an object with the following properties, all of which are optional:
4402 *
4403 * {left: LEFT_BOUND, right: RIGHT_BOUND, bottom: BOTTOM_BOUND, top: TOP_BOUND}
4404 *
4405 * All values are in px.
4406 *
4407 * Example:
4408 *
4409 * ```jsx
4410 * let App = React.createClass({
4411 * render: function () {
4412 * return (
4413 * <Draggable bounds={{right: 300, bottom: 300}}>
4414 * <div>Content</div>
4415 * </Draggable>
4416 * );
4417 * }
4418 * });
4419 * ```
4420 */
4421 bounds: _propTypes.default.oneOfType([
4422 _propTypes.default.shape({
4423 left: _propTypes.default.number,
4424 right: _propTypes.default.number,
4425 top: _propTypes.default.number,
4426 bottom: _propTypes.default.number
4427 }),
4428 _propTypes.default.string,
4429 _propTypes.default.oneOf([false])
4430 ]),
4431 defaultClassName: _propTypes.default.string,
4432 defaultClassNameDragging: _propTypes.default.string,
4433 defaultClassNameDragged: _propTypes.default.string,
4434 /**
4435 * `defaultPosition` specifies the x and y that the dragged item should start at
4436 *
4437 * Example:
4438 *
4439 * ```jsx
4440 * let App = React.createClass({
4441 * render: function () {
4442 * return (
4443 * <Draggable defaultPosition={{x: 25, y: 25}}>
4444 * <div>I start with transformX: 25px and transformY: 25px;</div>
4445 * </Draggable>
4446 * );
4447 * }
4448 * });
4449 * ```
4450 */
4451 defaultPosition: _propTypes.default.shape({
4452 x: _propTypes.default.number,
4453 y: _propTypes.default.number
4454 }),
4455 positionOffset: _propTypes.default.shape({
4456 x: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
4457 y: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
4458 }),
4459 /**
4460 * `position`, if present, defines the current position of the element.
4461 *
4462 * This is similar to how form elements in React work - if no `position` is supplied, the component
4463 * is uncontrolled.
4464 *
4465 * Example:
4466 *
4467 * ```jsx
4468 * let App = React.createClass({
4469 * render: function () {
4470 * return (
4471 * <Draggable position={{x: 25, y: 25}}>
4472 * <div>I start with transformX: 25px and transformY: 25px;</div>
4473 * </Draggable>
4474 * );
4475 * }
4476 * });
4477 * ```
4478 */
4479 position: _propTypes.default.shape({
4480 x: _propTypes.default.number,
4481 y: _propTypes.default.number
4482 }),
4483 /**
4484 * These properties should be defined on the child, not here.
4485 */
4486 className: _shims.dontSetMe,
4487 style: _shims.dontSetMe,
4488 transform: _shims.dontSetMe
4489 }));
4490 _defineProperty(Draggable, "defaultProps", _objectSpread2(_objectSpread2({}, _DraggableCore.default.defaultProps), {}, {
4491 axis: "both",
4492 bounds: false,
4493 defaultClassName: "react-draggable",
4494 defaultClassNameDragging: "react-draggable-dragging",
4495 defaultClassNameDragged: "react-draggable-dragged",
4496 defaultPosition: {
4497 x: 0,
4498 y: 0
4499 },
4500 scale: 1
4501 }));
4502 }));
4503
4504 //#endregion
4505 //#region node_modules/react-draggable/build/cjs/cjs.js
4506 var require_cjs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4507 var { default: Draggable, DraggableCore } = require_Draggable();
4508 module.exports = Draggable;
4509 module.exports.default = Draggable;
4510 module.exports.DraggableCore = DraggableCore;
4511 }));
4512
4513 //#endregion
4514 //#region modules/ai/assets/js/editor/components/prompt-dialog.js
4515 init_extends();
4516 init_defineProperty();
4517 init_slicedToArray();
4518 var import_cjs = /* @__PURE__ */ __toESM(require_cjs());
4519 function ownKeys$26(e, r) {
4520 var t = Object.keys(e);
4521 if (Object.getOwnPropertySymbols) {
4522 var o = Object.getOwnPropertySymbols(e);
4523 r && (o = o.filter(function(r) {
4524 return Object.getOwnPropertyDescriptor(e, r).enumerable;
4525 })), t.push.apply(t, o);
4526 }
4527 return t;
4528 }
4529 __name(ownKeys$26, "ownKeys");
4530 function _objectSpread$26(e) {
4531 for (var r = 1; r < arguments.length; r++) {
4532 var t = null != arguments[r] ? arguments[r] : {};
4533 r % 2 ? ownKeys$26(Object(t), !0).forEach(function(r) {
4534 _defineProperty(e, r, t[r]);
4535 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$26(Object(t)).forEach(function(r) {
4536 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
4537 });
4538 }
4539 return e;
4540 }
4541 __name(_objectSpread$26, "_objectSpread");
4542 var DraggablePaper = function DraggablePaper(props) {
4543 var _useState2 = _slicedToArray((0, react.useState)({
4544 x: 0,
4545 y: 0
4546 }), 2);
4547 var position = _useState2[0];
4548 var setPosition = _useState2[1];
4549 var paperRef = (0, react.useRef)(null);
4550 var timeout = (0, react.useRef)(null);
4551 var onDrag = function onDrag(_e, _ref) {
4552 var x = _ref.x;
4553 var y = _ref.y;
4554 return setPosition({
4555 x,
4556 y
4557 });
4558 };
4559 var handlePositionBoundaries = function handlePositionBoundaries() {
4560 clearTimeout(timeout.current);
4561 timeout.current = setTimeout(function() {
4562 var _paperRef$current;
4563 var dialogTop = (_paperRef$current = paperRef.current) === null || _paperRef$current === void 0 ? void 0 : _paperRef$current.getBoundingClientRect().top;
4564 if (dialogTop < 0) setPosition(function(prev) {
4565 return _objectSpread$26(_objectSpread$26({}, prev), {}, { y: prev.y - dialogTop });
4566 });
4567 }, 50);
4568 };
4569 (0, react.useEffect)(function() {
4570 var resizeObserver = new ResizeObserver(handlePositionBoundaries);
4571 resizeObserver.observe(paperRef.current);
4572 return function() {
4573 resizeObserver.disconnect();
4574 };
4575 }, []);
4576 return /*#__PURE__*/ react.default.createElement(import_cjs.default, {
4577 position,
4578 onDrag,
4579 handle: ".MuiAppBar-root",
4580 cancel: "[class*=\"MuiDialogContent-root\"]",
4581 bounds: "parent"
4582 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Paper, _extends$1({}, props, { ref: paperRef })));
4583 };
4584 var PromptDialog = function PromptDialog(props) {
4585 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, _extends$1({
4586 scroll: "paper",
4587 open: true,
4588 fullWidth: true,
4589 hideBackdrop: true,
4590 PaperComponent: DraggablePaper,
4591 disableScrollLock: true,
4592 sx: { "& .MuiDialog-container": {
4593 alignItems: "flex-start",
4594 mt: "18vh"
4595 } },
4596 PaperProps: { sx: {
4597 m: 0,
4598 maxHeight: "76vh"
4599 } }
4600 }, props), props.children);
4601 };
4602 PromptDialog.propTypes = {
4603 onClose: import_prop_types$7.default.func.isRequired,
4604 children: import_prop_types$7.default.node,
4605 maxWidth: import_prop_types$7.default.oneOf([
4606 "xs",
4607 "sm",
4608 "md",
4609 "lg",
4610 "xl",
4611 false
4612 ])
4613 };
4614 PromptDialog.Header = DialogHeader$1;
4615 PromptDialog.Content = _elementor_ui.DialogContent;
4616
4617 //#endregion
4618 //#region modules/ai/assets/js/editor/components/upgrade-chip.js
4619 init_slicedToArray();
4620 var popoverId$1 = "e-ai-upgrade-popover";
4621 var StyledContent$3 = (0, _elementor_ui.styled)(_elementor_ui.Paper)(function(_ref) {
4622 var theme = _ref.theme;
4623 return {
4624 position: "relative",
4625 "[data-popper-placement=\"top\"] &": { marginBottom: theme.spacing(2.5) },
4626 "[data-popper-placement=\"bottom\"] &": { marginTop: theme.spacing(2.5) },
4627 padding: theme.spacing(3),
4628 boxShadow: theme.shadows[4],
4629 zIndex: "9999"
4630 };
4631 });
4632 var StyledArrow$1 = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref2) {
4633 var theme = _ref2.theme;
4634 return {
4635 width: theme.spacing(5),
4636 height: theme.spacing(2.5),
4637 position: "absolute",
4638 overflow: "hidden",
4639 left: "50% !important",
4640 transform: "translateX(-50%) rotate(var(--rotate, 0deg)) !important",
4641 "[data-popper-placement=\"top\"] &": { top: "100%" },
4642 "[data-popper-placement=\"bottom\"] &": {
4643 "--rotate": "180deg",
4644 top: "calc(".concat(theme.spacing(2.5), " * -1)")
4645 },
4646 "&::after": {
4647 backgroundColor: theme.palette.background.paper,
4648 content: "\"\"",
4649 display: "block",
4650 position: "absolute",
4651 width: theme.spacing(2.5),
4652 height: theme.spacing(2.5),
4653 top: 0,
4654 left: "50%",
4655 transform: "translateX(-50%) translateY(-50%) rotate(45deg)",
4656 boxShadow: "1px 1px 5px 0px rgba(0, 0, 0, 0.2)",
4657 backgroundImage: "linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"
4658 }
4659 };
4660 });
4661 var upgradeBullets = [
4662 (0, _wordpress_i18n.__)("Get spot-on suggestions from AI Copilot and AI Context with appropriate designs, layouts, and content for your business.", "elementor"),
4663 (0, _wordpress_i18n.__)("Generate professional texts about any topic, in any tone.", "elementor"),
4664 (0, _wordpress_i18n.__)("Effortlessly create or enhance stunning images and bring your ideas to life.", "elementor"),
4665 (0, _wordpress_i18n.__)("Unleash infinite possibilities with the custom code generator.", "elementor"),
4666 (0, _wordpress_i18n.__)("Access 30-days of AI History with the AI Starter plan and 90-days with the Power plan.", "elementor")
4667 ];
4668 var Chip$2 = (0, _elementor_ui.styled)(_elementor_ui.Chip)(function() {
4669 return {
4670 "& .MuiChip-label": { lineHeight: 1.5 },
4671 "& .MuiSvgIcon-root.MuiChip-icon": { fontSize: "1.25rem" }
4672 };
4673 });
4674 var UpgradeChip = function UpgradeChip(_ref3) {
4675 var _ref3$hasSubscription = _ref3.hasSubscription;
4676 var hasSubscription = _ref3$hasSubscription === void 0 ? false : _ref3$hasSubscription;
4677 var _ref3$usagePercentage = _ref3.usagePercentage;
4678 var usagePercentage = _ref3$usagePercentage === void 0 ? 0 : _ref3$usagePercentage;
4679 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
4680 var isPopoverOpen = _useState2[0];
4681 var setIsPopoverOpen = _useState2[1];
4682 var anchorEl = (0, react.useRef)(null);
4683 var arrowEl = (0, react.useRef)(null);
4684 var showPopover = function showPopover() {
4685 return setIsPopoverOpen(true);
4686 };
4687 var hidePopover = function hidePopover() {
4688 return setIsPopoverOpen(false);
4689 };
4690 var actionUrl = "https://go.elementor.com/ai-popup-purchase-dropdown/";
4691 if (hasSubscription) actionUrl = usagePercentage >= 100 ? "https://go.elementor.com/ai-popup-upgrade-limit-reached/" : "https://go.elementor.com/ai-popup-upgrade-limit-reached-80-percent/";
4692 var actionLabel = hasSubscription ? (0, _wordpress_i18n.__)("Upgrade Elementor AI", "elementor") : (0, _wordpress_i18n.__)("Get Elementor AI", "elementor");
4693 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
4694 component: "span",
4695 "aria-owns": isPopoverOpen ? popoverId$1 : void 0,
4696 "aria-haspopup": "true",
4697 onMouseEnter: showPopover,
4698 onMouseLeave: hidePopover,
4699 ref: anchorEl,
4700 display: "flex",
4701 alignItems: "center"
4702 }, /*#__PURE__*/ react.default.createElement(Chip$2, {
4703 color: "promotion",
4704 label: (0, _wordpress_i18n.__)("Upgrade", "elementor"),
4705 icon: /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, null),
4706 size: "small"
4707 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Popper, {
4708 open: isPopoverOpen,
4709 anchorEl: anchorEl.current,
4710 sx: {
4711 zIndex: "170001",
4712 maxWidth: 300
4713 },
4714 modifiers: [{
4715 name: "arrow",
4716 enabled: true,
4717 options: { element: arrowEl.current }
4718 }]
4719 }, /*#__PURE__*/ react.default.createElement(StyledContent$3, null, /*#__PURE__*/ react.default.createElement(StyledArrow$1, { ref: arrowEl }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
4720 variant: "h5",
4721 color: "text.primary"
4722 }, (0, _wordpress_i18n.__)("Unlimited access to Elementor AI", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.List, { sx: { mb: 1 } }, upgradeBullets.map(function(bullet, index) {
4723 return /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItem, {
4724 key: index,
4725 disableGutters: true,
4726 sx: { alignItems: "flex-start" }
4727 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemIcon, null, /*#__PURE__*/ react.default.createElement(_elementor_icons.CheckedCircleIcon, null)), /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemText, { sx: { m: 0 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "body2" }, bullet)));
4728 })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
4729 variant: "contained",
4730 color: "promotion",
4731 size: "small",
4732 href: actionUrl,
4733 target: "_blank",
4734 startIcon: /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, null),
4735 sx: { "&:hover": { color: "promotion.contrastText" } }
4736 }, actionLabel))));
4737 };
4738 UpgradeChip.propTypes = {
4739 hasSubscription: import_prop_types$7.default.bool,
4740 usagePercentage: import_prop_types$7.default.number
4741 };
4742
4743 //#endregion
4744 //#region node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
4745 init_arrayLikeToArray();
4746 function _arrayWithoutHoles(r) {
4747 if (Array.isArray(r)) return _arrayLikeToArray$2(r);
4748 }
4749
4750 //#endregion
4751 //#region node_modules/@babel/runtime/helpers/esm/iterableToArray.js
4752 function _iterableToArray(r) {
4753 if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
4754 }
4755
4756 //#endregion
4757 //#region node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
4758 function _nonIterableSpread() {
4759 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4760 }
4761
4762 //#endregion
4763 //#region node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
4764 init_unsupportedIterableToArray();
4765 function _toConsumableArray(r) {
4766 return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray$2(r) || _nonIterableSpread();
4767 }
4768
4769 //#endregion
4770 //#region modules/ai/assets/js/editor/pages/form-media/context/location-context.js
4771 init_slicedToArray();
4772 init_defineProperty();
4773 function ownKeys$25(e, r) {
4774 var t = Object.keys(e);
4775 if (Object.getOwnPropertySymbols) {
4776 var o = Object.getOwnPropertySymbols(e);
4777 r && (o = o.filter(function(r) {
4778 return Object.getOwnPropertyDescriptor(e, r).enumerable;
4779 })), t.push.apply(t, o);
4780 }
4781 return t;
4782 }
4783 __name(ownKeys$25, "ownKeys");
4784 function _objectSpread$25(e) {
4785 for (var r = 1; r < arguments.length; r++) {
4786 var t = null != arguments[r] ? arguments[r] : {};
4787 r % 2 ? ownKeys$25(Object(t), !0).forEach(function(r) {
4788 _defineProperty(e, r, t[r]);
4789 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$25(Object(t)).forEach(function(r) {
4790 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
4791 });
4792 }
4793 return e;
4794 }
4795 __name(_objectSpread$25, "_objectSpread");
4796 var RoutesContext = (0, react.createContext)(null);
4797 var NAVIGATE = "NAVIGATE";
4798 var BACK = "BACK";
4799 var initialValue$1 = {
4800 current: "",
4801 history: []
4802 };
4803 var reducer$2 = function reducer(state, _ref) {
4804 var type = _ref.type;
4805 var payload = _ref.payload;
4806 switch (type) {
4807 case NAVIGATE: return _objectSpread$25(_objectSpread$25({}, state), {}, {
4808 current: payload,
4809 history: [].concat(_toConsumableArray(state.history), [payload])
4810 });
4811 case BACK: return _objectSpread$25(_objectSpread$25({}, state), {}, {
4812 current: state.history[state.history.length - 2],
4813 history: state.history.slice(0, state.history.length - 1)
4814 });
4815 default: return state;
4816 }
4817 };
4818 var LocationProvider = function LocationProvider(_ref2) {
4819 var children = _ref2.children;
4820 var _useReducer2 = _slicedToArray((0, react.useReducer)(reducer$2, initialValue$1), 2);
4821 var state = _useReducer2[0];
4822 var dispatch = _useReducer2[1];
4823 return /*#__PURE__*/ react.default.createElement(RoutesContext.Provider, { value: {
4824 state,
4825 dispatch
4826 } }, children);
4827 };
4828 LocationProvider.propTypes = { children: import_prop_types$7.default.node };
4829 var useLocation = function useLocation() {
4830 var current = (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}).current;
4831 var _useContext = (0, react.useContext)(RoutesContext);
4832 var state = _useContext.state;
4833 var dispatch = _useContext.dispatch;
4834 var navigate = function navigate(location) {
4835 dispatch({
4836 type: NAVIGATE,
4837 payload: location
4838 });
4839 };
4840 var back = function back() {
4841 dispatch({ type: BACK });
4842 };
4843 (0, react.useEffect)(function() {
4844 if (current) navigate(current);
4845 }, []);
4846 return {
4847 current: state.current,
4848 history: state.history,
4849 navigate,
4850 back
4851 };
4852 };
4853
4854 //#endregion
4855 //#region modules/ai/assets/js/editor/components/ui/panel.js
4856 init_extends();
4857 init_defineProperty();
4858 init_objectWithoutProperties();
4859 var _excluded$29 = ["sx"];
4860 function ownKeys$24(e, r) {
4861 var t = Object.keys(e);
4862 if (Object.getOwnPropertySymbols) {
4863 var o = Object.getOwnPropertySymbols(e);
4864 r && (o = o.filter(function(r) {
4865 return Object.getOwnPropertyDescriptor(e, r).enumerable;
4866 })), t.push.apply(t, o);
4867 }
4868 return t;
4869 }
4870 __name(ownKeys$24, "ownKeys");
4871 function _objectSpread$24(e) {
4872 for (var r = 1; r < arguments.length; r++) {
4873 var t = null != arguments[r] ? arguments[r] : {};
4874 r % 2 ? ownKeys$24(Object(t), !0).forEach(function(r) {
4875 _defineProperty(e, r, t[r]);
4876 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$24(Object(t)).forEach(function(r) {
4877 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
4878 });
4879 }
4880 return e;
4881 }
4882 __name(_objectSpread$24, "_objectSpread");
4883 var Panel = function Panel(_ref) {
4884 var _ref$sx = _ref.sx;
4885 var sx = _ref$sx === void 0 ? {} : _ref$sx;
4886 var props = _objectWithoutProperties(_ref, _excluded$29);
4887 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({ sx: _objectSpread$24({
4888 p: 4,
4889 width: 360,
4890 flexShrink: 0,
4891 height: "100%",
4892 overflowY: "auto"
4893 }, sx) }, props), props.children), /*#__PURE__*/ react.default.createElement(_elementor_ui.Divider, { orientation: "vertical" }));
4894 };
4895 Panel.propTypes = {
4896 children: import_prop_types$7.default.node,
4897 sx: import_prop_types$7.default.object
4898 };
4899
4900 //#endregion
4901 //#region modules/ai/assets/js/editor/pages/form-media/components/generate-loader.js
4902 var GenerateLoader = function GenerateLoader() {
4903 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
4904 alignItems: "center",
4905 justifyContent: "center",
4906 gap: 2,
4907 width: "100%"
4908 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { sx: {
4909 color: "text.primary",
4910 fontSize: "60px",
4911 mb: 1
4912 } }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
4913 variant: "h5",
4914 sx: { color: "text.primary" }
4915 }, (0, _wordpress_i18n.__)("Bringing your vision to life...", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "body1" }, (0, _wordpress_i18n.__)("Hold tight, painting dreams might take a moment.", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
4916 px: 1.5,
4917 py: 2.5,
4918 width: "100%",
4919 maxWidth: 600
4920 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.LinearProgress, { color: "inherit" })));
4921 };
4922
4923 //#endregion
4924 //#region modules/ai/assets/js/editor/icons/chevron-left-icon.js
4925 init_extends();
4926 var ChevronLeftIcon = react.default.forwardRef(function(props, ref) {
4927 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
4928 fillRule: "evenodd",
4929 clipRule: "evenodd",
4930 d: "M15.5303 18.2803C15.8232 17.9874 15.8232 17.5126 15.5303 17.2197L10.0607 11.75L15.5303 6.28033C15.8232 5.98744 15.8232 5.51256 15.5303 5.21967C15.2374 4.92678 14.7626 4.92678 14.4697 5.21967L8.46967 11.2197C8.17678 11.5126 8.17678 11.9874 8.46967 12.2803L14.4697 18.2803C14.7626 18.5732 15.2374 18.5732 15.5303 18.2803Z"
4931 }));
4932 });
4933
4934 //#endregion
4935 //#region modules/ai/assets/js/editor/pages/form-media/components/back-button.js
4936 init_extends();
4937 init_objectWithoutProperties();
4938 var _excluded$28 = ["children"];
4939 var StyledChevronLeftIcon$1 = (0, _elementor_ui.withDirection)(ChevronLeftIcon);
4940 var BackButton$1 = function BackButton(_ref) {
4941 var children = _ref.children;
4942 var props = _objectWithoutProperties(_ref, _excluded$28);
4943 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
4944 size: "small",
4945 variant: "text",
4946 color: "secondary",
4947 startIcon: /*#__PURE__*/ react.default.createElement(StyledChevronLeftIcon$1, null)
4948 }, props), children || (0, _wordpress_i18n.__)("Back", "elementor"));
4949 };
4950 BackButton$1.propTypes = { children: import_prop_types$7.default.node };
4951
4952 //#endregion
4953 //#region modules/ai/assets/js/editor/pages/form-media/context/global-settings-context.js
4954 var GlobalSettingsContext = (0, react.createContext)({});
4955 var GlobalSettingsProvider = function GlobalSettingsProvider(_ref) {
4956 var settings = _ref.settings;
4957 var children = _ref.children;
4958 return /*#__PURE__*/ react.default.createElement(GlobalSettingsContext.Provider, { value: settings }, children);
4959 };
4960 GlobalSettingsProvider.propTypes = {
4961 settings: import_prop_types$7.default.object,
4962 children: import_prop_types$7.default.node
4963 };
4964 var useGlobalSettings = function useGlobalSettings() {
4965 return (0, react.useContext)(GlobalSettingsContext);
4966 };
4967
4968 //#endregion
4969 //#region modules/ai/assets/js/editor/components/upgrade-banner.js
4970 init_extends();
4971 init_objectWithoutProperties();
4972 var _excluded$27 = ["onClose"];
4973 var UpgradeBanner = function UpgradeBanner(_ref) {
4974 var onClose = _ref.onClose;
4975 var props = _objectWithoutProperties(_ref, _excluded$27);
4976 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Alert, _extends$1({
4977 icon: false,
4978 action: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertAction, { onClick: function onClick() {
4979 return window.open("https://go.elementor.com/ai-banner-free-upgrade/", "_blank");
4980 } }, (0, _wordpress_i18n.__)("Upgrade", "elementor")),
4981 variant: "filled",
4982 color: "promotion",
4983 onClose
4984 }, props), (0, _wordpress_i18n.__)("You’re using a limited license. Get maximum access to Elementor AI.", "elementor"));
4985 };
4986 UpgradeBanner.propTypes = {
4987 onClose: import_prop_types$7.default.func,
4988 sx: import_prop_types$7.default.object
4989 };
4990
4991 //#endregion
4992 //#region modules/ai/assets/js/editor/helpers/features-enum.js
4993 var FREE_TRIAL_FEATURES_NAMES = {
4994 TEXT: (0, _wordpress_i18n.__)("Text", "elementor"),
4995 IMAGES: (0, _wordpress_i18n.__)("Images", "elementor"),
4996 CODE: (0, _wordpress_i18n.__)("Code", "elementor"),
4997 CONTAINERS: (0, _wordpress_i18n.__)("Containers", "elementor"),
4998 ANIMATION: (0, _wordpress_i18n.__)("Animation", "elementor")
4999 };
5000
5001 //#endregion
5002 //#region modules/ai/assets/js/editor/components/usage-limit-alert.js
5003 init_objectWithoutProperties();
5004 init_extends();
5005 init_defineProperty();
5006 var _excluded$26 = [
5007 "onClose",
5008 "usagePercentage",
5009 "hasSubscription",
5010 "feature"
5011 ];
5012 var KEY_SUBSCRIPTION = "subscription";
5013 var KEY_NO_SUBSCRIPTION = "noSubscription";
5014 var getUsageTitle = function getUsageTitle(percentage) {
5015 return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("You’ve used %s of credits for this AI feature.", "elementor"), percentage);
5016 };
5017 var CREDITS_95_USAGE_TITLE = getUsageTitle("95%");
5018 var CREDITS_80_USAGE_TITLE = getUsageTitle("80%");
5019 var CREDITS_75_USAGE_TITLE = getUsageTitle("75%");
5020 var DESCRIPTION_SUBSCRIPTION = (0, _wordpress_i18n.__)("Get maximum access.", "elementor");
5021 var FEATURES = Object.keys(FREE_TRIAL_FEATURES_NAMES);
5022 var getDescriptionNoSubscription = function getDescriptionNoSubscription(excludedFeature) {
5023 var featuresList = FEATURES.filter(function(feature) {
5024 return feature !== excludedFeature;
5025 }).map(function(feature) {
5026 return FREE_TRIAL_FEATURES_NAMES[feature];
5027 }).join(", ");
5028 return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("Upgrade now to keep using this feature. You still have credits for other AI features (%s, etc.)", "elementor"), featuresList);
5029 };
5030 var alertConfigs = [
5031 {
5032 threshold: 95,
5033 title: _defineProperty(_defineProperty({}, KEY_SUBSCRIPTION, CREDITS_95_USAGE_TITLE), KEY_NO_SUBSCRIPTION, CREDITS_95_USAGE_TITLE),
5034 url: _defineProperty(_defineProperty({}, KEY_SUBSCRIPTION, "https://go.elementor.com/ai-banner-paid-95-limit-reach/"), KEY_NO_SUBSCRIPTION, "https://go.elementor.com/ai-banner-free-95-limit-reach/"),
5035 color: "error"
5036 },
5037 {
5038 threshold: 80,
5039 title: _defineProperty(_defineProperty({}, KEY_SUBSCRIPTION, CREDITS_80_USAGE_TITLE), KEY_NO_SUBSCRIPTION, CREDITS_80_USAGE_TITLE),
5040 url: _defineProperty(_defineProperty({}, KEY_SUBSCRIPTION, "https://go.elementor.com/ai-banner-paid-80-limit-reach/"), KEY_NO_SUBSCRIPTION, "https://go.elementor.com/ai-banner-free-80-limit-reach/"),
5041 color: "warning"
5042 },
5043 {
5044 threshold: 75,
5045 title: _defineProperty(_defineProperty({}, KEY_SUBSCRIPTION, CREDITS_75_USAGE_TITLE), KEY_NO_SUBSCRIPTION, CREDITS_75_USAGE_TITLE),
5046 url: _defineProperty(_defineProperty({}, KEY_SUBSCRIPTION, "https://go.elementor.com/ai-banner-paid-80-limit-reach/"), KEY_NO_SUBSCRIPTION, "https://go.elementor.com/ai-banner-free-80-limit-reach/"),
5047 color: "warning"
5048 }
5049 ];
5050 var UpgradeButton = function UpgradeButton(props) {
5051 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
5052 color: "inherit",
5053 variant: "outlined",
5054 sx: { border: "2px solid" }
5055 }, props), (0, _wordpress_i18n.__)("Upgrade now", "elementor"));
5056 };
5057 var UsageLimitAlert = function UsageLimitAlert(_ref) {
5058 _ref.onClose;
5059 var usagePercentage = _ref.usagePercentage;
5060 var hasSubscription = _ref.hasSubscription;
5061 var feature = _ref.feature;
5062 var props = _objectWithoutProperties(_ref, _excluded$26);
5063 var config = alertConfigs.find(function(_ref2) {
5064 return usagePercentage >= _ref2.threshold;
5065 });
5066 if (!config) return null;
5067 var subscriptionType = hasSubscription ? KEY_SUBSCRIPTION : KEY_NO_SUBSCRIPTION;
5068 var description = _defineProperty(_defineProperty({}, KEY_SUBSCRIPTION, DESCRIPTION_SUBSCRIPTION), KEY_NO_SUBSCRIPTION, getDescriptionNoSubscription(feature));
5069 var title = config.title;
5070 var url = config.url;
5071 var color = config.color;
5072 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Alert, _extends$1({
5073 severity: "warning",
5074 action: /*#__PURE__*/ react.default.createElement(UpgradeButton, { onClick: function handleUpgradeClick() {
5075 return window.open(url[subscriptionType], "_blank");
5076 } }),
5077 color
5078 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, title[subscriptionType]), description[subscriptionType]);
5079 };
5080 UsageLimitAlert.propTypes = {
5081 onClose: import_prop_types$7.default.func,
5082 usagePercentage: import_prop_types$7.default.number,
5083 hasSubscription: import_prop_types$7.default.bool,
5084 feature: import_prop_types$7.default.string
5085 };
5086
5087 //#endregion
5088 //#region modules/ai/assets/js/editor/hooks/use-upgrade-message.js
5089 init_use_introduction();
5090 var USAGE_PERCENTAGE_THRESHOLD = 75;
5091 var useUpgradeMessage = function useUpgradeMessage(_ref) {
5092 var usagePercentage = _ref.usagePercentage;
5093 var hasSubscription = _ref.hasSubscription;
5094 var _useIntroduction = useIntroduction("e-ai-upgrade-message");
5095 var isBannerViewed = _useIntroduction.isViewed;
5096 var markBannerAsViewed = _useIntroduction.markAsViewed;
5097 var isFreeUser = !hasSubscription;
5098 return {
5099 showBadge: usagePercentage >= 75 || isFreeUser,
5100 showBanner: !isBannerViewed && isFreeUser && usagePercentage < 75,
5101 markBannerAsViewed
5102 };
5103 };
5104
5105 //#endregion
5106 //#region modules/ai/assets/js/editor/components/usage-messages.js
5107 var UsageMessages = function UsageMessages(_ref) {
5108 var hasSubscription = _ref.hasSubscription;
5109 var usagePercentage = _ref.usagePercentage;
5110 var sx = _ref.sx;
5111 var feature = _ref.feature;
5112 var _useUpgradeMessage = useUpgradeMessage({
5113 usagePercentage,
5114 hasSubscription
5115 });
5116 var showBanner = _useUpgradeMessage.showBanner;
5117 var markBannerAsViewed = _useUpgradeMessage.markBannerAsViewed;
5118 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, showBanner && /*#__PURE__*/ react.default.createElement(UpgradeBanner, {
5119 onClose: markBannerAsViewed,
5120 sx
5121 }), /*#__PURE__*/ react.default.createElement(UsageLimitAlert, {
5122 hasSubscription,
5123 usagePercentage,
5124 sx,
5125 feature
5126 }));
5127 };
5128 UsageMessages.propTypes = {
5129 hasSubscription: import_prop_types$7.default.bool,
5130 usagePercentage: import_prop_types$7.default.number,
5131 sx: import_prop_types$7.default.object,
5132 feature: import_prop_types$7.default.string
5133 };
5134
5135 //#endregion
5136 //#region modules/ai/assets/js/editor/pages/form-media/components/view.js
5137 init_extends();
5138 init_defineProperty();
5139 init_objectWithoutProperties();
5140 init_loader();
5141 init_prompt_error_message();
5142 var _excluded$25 = ["sx"];
5143 var _excluded2$4 = ["primary", "secondary"];
5144 var _excluded3$2 = ["primary", "secondary"];
5145 var _excluded4$1 = ["children"];
5146 var _excluded5$1 = [
5147 "isLoading",
5148 "isGenerating",
5149 "children"
5150 ];
5151 var _excluded6 = ["sx"];
5152 function ownKeys$23(e, r) {
5153 var t = Object.keys(e);
5154 if (Object.getOwnPropertySymbols) {
5155 var o = Object.getOwnPropertySymbols(e);
5156 r && (o = o.filter(function(r) {
5157 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5158 })), t.push.apply(t, o);
5159 }
5160 return t;
5161 }
5162 __name(ownKeys$23, "ownKeys");
5163 function _objectSpread$23(e) {
5164 for (var r = 1; r < arguments.length; r++) {
5165 var t = null != arguments[r] ? arguments[r] : {};
5166 r % 2 ? ownKeys$23(Object(t), !0).forEach(function(r) {
5167 _defineProperty(e, r, t[r]);
5168 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$23(Object(t)).forEach(function(r) {
5169 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5170 });
5171 }
5172 return e;
5173 }
5174 __name(_objectSpread$23, "_objectSpread");
5175 var ViewBackButton = function ViewBackButton(_ref) {
5176 var _ref$sx = _ref.sx;
5177 var sx = _ref$sx === void 0 ? {} : _ref$sx;
5178 var props = _objectWithoutProperties(_ref, _excluded$25);
5179 var back = useLocation().back;
5180 if (useGlobalSettings().hideBackButton) return null;
5181 return /*#__PURE__*/ react.default.createElement(BackButton$1, _extends$1({ onClick: function onClick(e) {
5182 e.preventDefault();
5183 back();
5184 } }, props, { sx: _objectSpread$23({
5185 mb: 1,
5186 alignSelf: "flex-start"
5187 }, sx) }));
5188 };
5189 ViewBackButton.propTypes = { sx: import_prop_types$7.default.object };
5190 var PanelHeading = function PanelHeading(_ref2) {
5191 var primary = _ref2.primary;
5192 var secondary = _ref2.secondary;
5193 var props = _objectWithoutProperties(_ref2, _excluded2$4);
5194 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, _extends$1({
5195 spacing: 1,
5196 sx: { mb: 3 }
5197 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "h4" }, primary), secondary && /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
5198 variant: "body1",
5199 color: "secondary"
5200 }, secondary));
5201 };
5202 PanelHeading.propTypes = {
5203 primary: import_prop_types$7.default.string.isRequired,
5204 secondary: import_prop_types$7.default.string
5205 };
5206 var ContentHeading = function ContentHeading(_ref3) {
5207 var primary = _ref3.primary;
5208 var secondary = _ref3.secondary;
5209 var props = _objectWithoutProperties(_ref3, _excluded3$2);
5210 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, _extends$1({
5211 gap: 1.5,
5212 sx: { mb: 3 }
5213 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "h6" }, primary), secondary && /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
5214 variant: "subtitle1",
5215 color: "secondary"
5216 }, secondary));
5217 };
5218 ContentHeading.propTypes = {
5219 primary: import_prop_types$7.default.string.isRequired,
5220 secondary: import_prop_types$7.default.string
5221 };
5222 var View = function View(_ref4) {
5223 var children = _ref4.children;
5224 var props = _objectWithoutProperties(_ref4, _excluded4$1);
5225 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
5226 className: "e-ai-dialog-content",
5227 display: "flex",
5228 sx: {
5229 overflowY: "auto",
5230 position: "relative"
5231 },
5232 height: "100%"
5233 }, props), children);
5234 };
5235 var Content = function Content(_ref5) {
5236 var _ref5$isLoading = _ref5.isLoading;
5237 var isLoading = _ref5$isLoading === void 0 ? false : _ref5$isLoading;
5238 var _ref5$isGenerating = _ref5.isGenerating;
5239 var isGenerating = _ref5$isGenerating === void 0 ? false : _ref5$isGenerating;
5240 var children = _ref5.children;
5241 var props = _objectWithoutProperties(_ref5, _excluded5$1);
5242 if (isGenerating) return /*#__PURE__*/ react.default.createElement(GenerateLoader, null);
5243 if (isLoading) return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
5244 width: "100%",
5245 maxWidth: 600,
5246 margin: "0 auto",
5247 alignSelf: "center"
5248 } }, /*#__PURE__*/ react.default.createElement(Loader, { color: "inherit" }));
5249 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
5250 sx: {
5251 overflowY: "auto",
5252 p: 4
5253 },
5254 flexGrow: 1
5255 }, props), children);
5256 };
5257 Content.propTypes = {
5258 children: import_prop_types$7.default.node,
5259 isLoading: import_prop_types$7.default.bool,
5260 isGenerating: import_prop_types$7.default.bool
5261 };
5262 var ErrorMessage = function ErrorMessage(_ref6) {
5263 var _ref6$sx = _ref6.sx;
5264 var sx = _ref6$sx === void 0 ? {} : _ref6$sx;
5265 var props = _objectWithoutProperties(_ref6, _excluded6);
5266 return /*#__PURE__*/ react.default.createElement(PromptErrorMessage, _extends$1({ actionPosition: "bottom" }, props, { sx: _objectSpread$23({ mb: 2.5 }, sx) }));
5267 };
5268 ErrorMessage.propTypes = { sx: import_prop_types$7.default.object };
5269 var ViewPanel = function ViewPanel(props) {
5270 var _useGlobalSettings2 = useGlobalSettings();
5271 var hasSubscription = _useGlobalSettings2.hasSubscription;
5272 var usagePercentage = _useGlobalSettings2.usagePercentage;
5273 return /*#__PURE__*/ react.default.createElement(Panel, null, /*#__PURE__*/ react.default.createElement(UsageMessages, {
5274 hasSubscription,
5275 usagePercentage,
5276 sx: { mb: 4 },
5277 feature: FREE_TRIAL_FEATURES_NAMES.IMAGES
5278 }), props.children);
5279 };
5280 ViewPanel.propTypes = { children: import_prop_types$7.default.node };
5281 View.Panel = ViewPanel;
5282 View.Content = Content;
5283 View.BackButton = ViewBackButton;
5284 View.ErrorMessage = ErrorMessage;
5285 View.PanelHeading = PanelHeading;
5286 View.ContentHeading = ContentHeading;
5287 View.propTypes = { children: import_prop_types$7.default.node };
5288
5289 //#endregion
5290 //#region modules/ai/assets/js/editor/pages/form-media/constants/index.js
5291 var LOCATIONS = {
5292 RESIZE: "resize",
5293 GENERATE: "generate",
5294 VARIATIONS: "variations",
5295 IMAGE_TOOLS: "image-tools",
5296 IN_PAINTING: "in-painting",
5297 OUT_PAINTING: "out-painting",
5298 REMOVE_BACKGROUND: "remove-background",
5299 REPLACE_BACKGROUND: "replace-background",
5300 REMOVE_TEXT: "remove-text",
5301 CLEANUP: "cleanup",
5302 PRODUCT_IMAGE_UNIFICATION: "product-image-unification",
5303 ISOLATE_OBJECT: "isolate-objects"
5304 };
5305 var IMAGE_PROMPT_SETTINGS = {
5306 IMAGE_TYPE: "image_type",
5307 IMAGE_STYLE: "style_preset",
5308 IMAGE_STRENGTH: "image_strength",
5309 IMAGE_RATIO: "ratio",
5310 IMAGE_ZOOM: "zoom",
5311 IMAGE_UPSCALE: "upscale_to",
5312 IMAGE_BACKGROUND_COLOR: "background_color"
5313 };
5314 var FEATURE_IDENTIFIER = { ISOLATE_OBJECT: "isolate-object" };
5315 var IMAGE_PROMPT_CATEGORIES = {
5316 "": {
5317 label: (0, _wordpress_i18n.__)("None", "elementor"),
5318 subCategories: {}
5319 },
5320 photographic: {
5321 label: (0, _wordpress_i18n.__)("Photographic", "elementor"),
5322 subCategories: {
5323 "": (0, _wordpress_i18n.__)("None", "elementor"),
5324 landscape: (0, _wordpress_i18n.__)("Landscape", "elementor"),
5325 macro: (0, _wordpress_i18n.__)("Macro", "elementor"),
5326 portrait: (0, _wordpress_i18n.__)("Portrait", "elementor"),
5327 "long-exposure": (0, _wordpress_i18n.__)("Long Exposure", "elementor"),
5328 product: (0, _wordpress_i18n.__)("Product", "elementor"),
5329 photorealistic: (0, _wordpress_i18n.__)("Photorealistic", "elementor")
5330 }
5331 },
5332 vector: {
5333 label: (0, _wordpress_i18n.__)("Vector / Logo", "elementor"),
5334 subCategories: {
5335 "": (0, _wordpress_i18n.__)("None", "elementor"),
5336 "typographic-logo": (0, _wordpress_i18n.__)("Typographic Logo", "elementor"),
5337 "shape-logo": (0, _wordpress_i18n.__)("Shape Logo", "elementor"),
5338 "handwritten-logo": (0, _wordpress_i18n.__)("Handwritten Logo", "elementor"),
5339 "line-art-logo": (0, _wordpress_i18n.__)("Line Art Logo", "elementor"),
5340 "old-school-logo": (0, _wordpress_i18n.__)("Old School Logo", "elementor")
5341 }
5342 },
5343 background: {
5344 label: (0, _wordpress_i18n.__)("Background", "elementor"),
5345 subCategories: {
5346 "": (0, _wordpress_i18n.__)("None", "elementor"),
5347 floral: (0, _wordpress_i18n.__)("Floral", "elementor"),
5348 gradient: (0, _wordpress_i18n.__)("Gradient", "elementor"),
5349 mosaic: (0, _wordpress_i18n.__)("Mosaic", "elementor"),
5350 neon: (0, _wordpress_i18n.__)("Neon", "elementor"),
5351 bokeh: (0, _wordpress_i18n.__)("Bokeh", "elementor")
5352 }
5353 },
5354 handmade: {
5355 label: (0, _wordpress_i18n.__)("Handmade", "elementor"),
5356 subCategories: {
5357 "": (0, _wordpress_i18n.__)("None", "elementor"),
5358 doodle: (0, _wordpress_i18n.__)("Doodle", "elementor"),
5359 "line-art": (0, _wordpress_i18n.__)("Line Art", "elementor"),
5360 "oil-painting": (0, _wordpress_i18n.__)("Oil Painting", "elementor"),
5361 "pencil-drawing": (0, _wordpress_i18n.__)("Pencil Drawing", "elementor"),
5362 watercolor: (0, _wordpress_i18n.__)("Watercolor", "elementor")
5363 }
5364 },
5365 "digital-art": {
5366 label: (0, _wordpress_i18n.__)("Digital Art", "elementor"),
5367 subCategories: {
5368 "": (0, _wordpress_i18n.__)("None", "elementor"),
5369 amine: (0, _wordpress_i18n.__)("Anime", "elementor"),
5370 cartoon: (0, _wordpress_i18n.__)("Cartoon", "elementor"),
5371 cinematic: (0, _wordpress_i18n.__)("Cinematic", "elementor"),
5372 "comic-book": (0, _wordpress_i18n.__)("Comic Book", "elementor"),
5373 "fantasy-art": (0, _wordpress_i18n.__)("Fantasy Art", "elementor"),
5374 isometric: (0, _wordpress_i18n.__)("Isometric", "elementor"),
5375 vector: (0, _wordpress_i18n.__)("Vector", "elementor"),
5376 "pixel-art": (0, _wordpress_i18n.__)("Pixel Art", "elementor"),
5377 "low-poly": (0, _wordpress_i18n.__)("Low Poly", "elementor"),
5378 "neon-punk": (0, _wordpress_i18n.__)("Neon Punk", "elementor")
5379 }
5380 },
5381 "3d": {
5382 label: (0, _wordpress_i18n.__)("3D", "elementor"),
5383 subCategories: {
5384 "": (0, _wordpress_i18n.__)("None", "elementor"),
5385 clay: (0, _wordpress_i18n.__)("Clay", "elementor"),
5386 digital: (0, _wordpress_i18n.__)("Digital", "elementor"),
5387 origami: (0, _wordpress_i18n.__)("Origami", "elementor"),
5388 stone: (0, _wordpress_i18n.__)("Stone", "elementor"),
5389 wood: (0, _wordpress_i18n.__)("Wood", "elementor")
5390 }
5391 }
5392 };
5393 var IMAGE_ASPECT_RATIO = {
5394 "1:1": {
5395 width: 512,
5396 height: 512,
5397 label: (0, _wordpress_i18n.__)("Square", "elementor") + " (1:1)"
5398 },
5399 "3:2": {
5400 width: 640,
5401 height: 448,
5402 label: (0, _wordpress_i18n.__)("Landscape", "elementor") + " (3:2)"
5403 },
5404 "4:3": {
5405 width: 640,
5406 height: 448,
5407 label: (0, _wordpress_i18n.__)("Landscape", "elementor") + " (4:3)"
5408 },
5409 "16:9": {
5410 width: 704,
5411 height: 384,
5412 label: (0, _wordpress_i18n.__)("Landscape", "elementor") + " (16:9)"
5413 },
5414 "2:3": {
5415 width: 448,
5416 height: 640,
5417 label: (0, _wordpress_i18n.__)("Portrait", "elementor") + " (2:3)"
5418 },
5419 "3:4": {
5420 width: 448,
5421 height: 640,
5422 label: (0, _wordpress_i18n.__)("Portrait", "elementor") + " (3:4)"
5423 },
5424 "9:16": {
5425 width: 384,
5426 height: 704,
5427 label: (0, _wordpress_i18n.__)("Portrait", "elementor") + " (9:16)"
5428 }
5429 };
5430 var IMAGE_PLACEHOLDERS_HOSTS = { WIREFRAME: "gene-\\d+\\.live\\.strattic\\.io" };
5431
5432 //#endregion
5433 //#region modules/ai/assets/js/editor/components/ui/overlay.js
5434 var Overlay = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref) {
5435 var theme = _ref.theme;
5436 return {
5437 width: "100%",
5438 height: "100%",
5439 position: "absolute",
5440 backgroundColor: "rgba(0,0,0,0.5)",
5441 transition: "opacity ".concat(theme.transitions.duration.short, "ms ").concat(theme.transitions.easing.easeInOut),
5442 opacity: 0,
5443 "&:hover": { opacity: 1 }
5444 };
5445 });
5446
5447 //#endregion
5448 //#region modules/ai/assets/js/editor/components/ui/overlay-bar.js
5449 var OverlayBar = (0, _elementor_ui.styled)(_elementor_ui.Stack)(function(_ref) {
5450 var theme = _ref.theme;
5451 var position = _ref.position;
5452 var style = {
5453 width: "100%",
5454 position: "absolute",
5455 left: 0,
5456 padding: theme.spacing(2.5)
5457 };
5458 if ("top" === position) style.top = 0;
5459 else if ("bottom" === position) style.bottom = 0;
5460 return style;
5461 });
5462
5463 //#endregion
5464 //#region modules/ai/assets/js/editor/components/ui/overlay-bar-text.js
5465 init_extends();
5466 init_objectWithoutProperties();
5467 var _excluded$24 = ["children"];
5468 var OverlayBarText = function OverlayBarText(_ref) {
5469 var children = _ref.children;
5470 var props = _objectWithoutProperties(_ref, _excluded$24);
5471 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, _extends$1({
5472 variant: "caption",
5473 color: "common.white"
5474 }, props), children);
5475 };
5476 OverlayBarText.propTypes = { children: import_prop_types$7.default.node };
5477
5478 //#endregion
5479 //#region modules/ai/assets/js/editor/pages/form-media/components/gallery.js
5480 init_defineProperty();
5481 init_slicedToArray();
5482 init_extends();
5483 init_objectWithoutProperties();
5484 var _excluded$23 = ["children"];
5485 var _excluded2$3 = [
5486 "alt",
5487 "src",
5488 "text",
5489 "children",
5490 "aspectRatio",
5491 "variant",
5492 "OverlayBarProps",
5493 "numImagesInRow",
5494 "overlay",
5495 "onSelectChange",
5496 "checkboxColor",
5497 "isLoading",
5498 "initialChecked"
5499 ];
5500 function ownKeys$22(e, r) {
5501 var t = Object.keys(e);
5502 if (Object.getOwnPropertySymbols) {
5503 var o = Object.getOwnPropertySymbols(e);
5504 r && (o = o.filter(function(r) {
5505 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5506 })), t.push.apply(t, o);
5507 }
5508 return t;
5509 }
5510 __name(ownKeys$22, "ownKeys");
5511 function _objectSpread$22(e) {
5512 for (var r = 1; r < arguments.length; r++) {
5513 var t = null != arguments[r] ? arguments[r] : {};
5514 r % 2 ? ownKeys$22(Object(t), !0).forEach(function(r) {
5515 _defineProperty(e, r, t[r]);
5516 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$22(Object(t)).forEach(function(r) {
5517 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5518 });
5519 }
5520 return e;
5521 }
5522 __name(_objectSpread$22, "_objectSpread");
5523 var aspectRatios = Object.keys(IMAGE_ASPECT_RATIO);
5524 var Gallery = function Gallery(_ref) {
5525 var children = _ref.children;
5526 var props = _objectWithoutProperties(_ref, _excluded$23);
5527 return /*#__PURE__*/ react.default.createElement(_elementor_ui.ImageList, _extends$1({
5528 width: "100%",
5529 cols: 2,
5530 gap: 24
5531 }, props), children);
5532 };
5533 Gallery.propTypes = { children: import_prop_types$7.default.node };
5534 var GalleryImage = function GalleryImage(_ref2) {
5535 var _elementorCommon$conf;
5536 var _elementorCommon;
5537 var alt = _ref2.alt;
5538 var src = _ref2.src;
5539 var text = _ref2.text;
5540 var children = _ref2.children;
5541 var _ref2$aspectRatio = _ref2.aspectRatio;
5542 var aspectRatio = _ref2$aspectRatio === void 0 ? "1:1" : _ref2$aspectRatio;
5543 var _ref2$variant = _ref2.variant;
5544 var variant = _ref2$variant === void 0 ? "contained" : _ref2$variant;
5545 var _ref2$OverlayBarProps = _ref2.OverlayBarProps;
5546 var OverlayBarProps = _ref2$OverlayBarProps === void 0 ? {} : _ref2$OverlayBarProps;
5547 var _ref2$numImagesInRow = _ref2.numImagesInRow;
5548 var numImagesInRow = _ref2$numImagesInRow === void 0 ? 2 : _ref2$numImagesInRow;
5549 var _ref2$overlay = _ref2.overlay;
5550 var overlay = _ref2$overlay === void 0 ? true : _ref2$overlay;
5551 var _ref2$onSelectChange = _ref2.onSelectChange;
5552 var onSelectChange = _ref2$onSelectChange === void 0 ? null : _ref2$onSelectChange;
5553 var _ref2$checkboxColor = _ref2.checkboxColor;
5554 var checkboxColor = _ref2$checkboxColor === void 0 ? "rgba(0, 0, 0, 0.54)" : _ref2$checkboxColor;
5555 var _ref2$isLoading = _ref2.isLoading;
5556 var isLoading = _ref2$isLoading === void 0 ? false : _ref2$isLoading;
5557 var _ref2$initialChecked = _ref2.initialChecked;
5558 var initialChecked = _ref2$initialChecked === void 0 ? false : _ref2$initialChecked;
5559 var props = _objectWithoutProperties(_ref2, _excluded2$3);
5560 var _useState2 = _slicedToArray((0, react.useState)(initialChecked), 2);
5561 var isChecked = _useState2[0];
5562 var setIsChecked = _useState2[1];
5563 var style = {};
5564 var isRTL = (_elementorCommon$conf = (_elementorCommon = elementorCommon) === null || _elementorCommon === void 0 || (_elementorCommon = _elementorCommon.config) === null || _elementorCommon === void 0 ? void 0 : _elementorCommon.isRTL) !== null && _elementorCommon$conf !== void 0 ? _elementorCommon$conf : true;
5565 (0, react.useEffect)(function() {
5566 setIsChecked(initialChecked);
5567 }, [initialChecked]);
5568 if ("thumbnail" === variant) {
5569 style.width = "100%";
5570 style.maxHeight = "238px";
5571 style.minWidth = "230px";
5572 } else {
5573 style.width = "auto";
5574 style.height = "auto";
5575 style.maxWidth = "100%";
5576 style.maxHeight = "1:1" === aspectRatio ? "initial" : "100%";
5577 style.objectFit = "contain";
5578 style.aspectRatio = aspectRatio.replace(":", " / ");
5579 }
5580 return /*#__PURE__*/ react.default.createElement(_elementor_ui.ImageListItem, props, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
5581 display: "flex",
5582 justifyContent: "center",
5583 alignItems: "center",
5584 sx: {
5585 bgcolor: "action.selected",
5586 height: "contained" === variant && numImagesInRow <= 2 ? 336 : "auto",
5587 position: "relative",
5588 overflow: "hidden"
5589 }
5590 }, /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, isLoading ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Skeleton, {
5591 sx: _objectSpread$22(_objectSpread$22({}, style), {}, {
5592 width: "100%",
5593 height: "100% "
5594 }),
5595 animation: "wave",
5596 variant: "rounded"
5597 }, /*#__PURE__*/ react.default.createElement("img", {
5598 alt,
5599 src,
5600 style: _objectSpread$22(_objectSpread$22({}, style), {}, { visibility: "hidden" })
5601 })) : /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, onSelectChange && /*#__PURE__*/ react.default.createElement(_elementor_ui.Checkbox, {
5602 onClick: function onClick() {
5603 var newVal = !isChecked;
5604 setIsChecked(newVal);
5605 onSelectChange(newVal);
5606 },
5607 checked: isChecked,
5608 sx: {
5609 position: "absolute",
5610 top: 0,
5611 left: isRTL ? void 0 : 0,
5612 right: isRTL ? 0 : void 0,
5613 "& .MuiSvgIcon-root": { color: checkboxColor }
5614 }
5615 }), /*#__PURE__*/ react.default.createElement("img", {
5616 alt,
5617 src,
5618 style
5619 })))), overlay && children && /*#__PURE__*/ react.default.createElement(Overlay, null, /*#__PURE__*/ react.default.createElement(OverlayBar, _extends$1({
5620 gap: 1,
5621 position: "bottom"
5622 }, OverlayBarProps), text && /*#__PURE__*/ react.default.createElement(OverlayBarText, null, text), children)));
5623 };
5624 GalleryImage.propTypes = {
5625 alt: import_prop_types$7.default.string,
5626 src: import_prop_types$7.default.string,
5627 text: import_prop_types$7.default.string,
5628 children: import_prop_types$7.default.node,
5629 BoxProps: import_prop_types$7.default.object,
5630 OverlayBarProps: import_prop_types$7.default.object,
5631 aspectRatio: import_prop_types$7.default.oneOf(aspectRatios),
5632 variant: import_prop_types$7.default.oneOf(["contained", "thumbnail"]),
5633 numImagesInRow: import_prop_types$7.default.number,
5634 overlay: import_prop_types$7.default.bool,
5635 onSelectChange: import_prop_types$7.default.func,
5636 checkboxColor: import_prop_types$7.default.string,
5637 initialChecked: import_prop_types$7.default.bool,
5638 isLoading: import_prop_types$7.default.bool
5639 };
5640 Gallery.Image = GalleryImage;
5641
5642 //#endregion
5643 //#region modules/ai/assets/js/editor/pages/form-media/components/image-form.js
5644 init_extends();
5645 init_objectWithoutProperties();
5646 var _excluded$22 = ["children"];
5647 var ImageForm = function ImageForm(_ref) {
5648 var children = _ref.children;
5649 var props = _objectWithoutProperties(_ref, _excluded$22);
5650 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({ component: "form" }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, { spacing: 2.5 }, children));
5651 };
5652 ImageForm.propTypes = { children: import_prop_types$7.default.node };
5653
5654 //#endregion
5655 //#region modules/ai/assets/js/editor/icons/wand-icon.js
5656 init_extends();
5657 var WandIcon = react.default.forwardRef(function(props, ref) {
5658 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
5659 fillRule: "evenodd",
5660 clipRule: "evenodd",
5661 d: "M9 2.25C9.41421 2.25 9.75 2.58579 9.75 3C9.75 3.33152 9.8817 3.64946 10.1161 3.88388C10.3505 4.1183 10.6685 4.25 11 4.25C11.4142 4.25 11.75 4.58579 11.75 5C11.75 5.41421 11.4142 5.75 11 5.75C10.6685 5.75 10.3505 5.8817 10.1161 6.11612C9.8817 6.35054 9.75 6.66848 9.75 7C9.75 7.41421 9.41421 7.75 9 7.75C8.58579 7.75 8.25 7.41421 8.25 7C8.25 6.66848 8.1183 6.35054 7.88388 6.11612C7.64946 5.8817 7.33152 5.75 7 5.75C6.58579 5.75 6.25 5.41421 6.25 5C6.25 4.58579 6.58579 4.25 7 4.25C7.33152 4.25 7.64946 4.1183 7.88388 3.88388C8.1183 3.64946 8.25 3.33152 8.25 3C8.25 2.58579 8.58579 2.25 9 2.25ZM9 4.88746C8.98182 4.90673 8.96333 4.92576 8.94454 4.94454C8.92576 4.96333 8.90673 4.98182 8.88746 5C8.90673 5.01818 8.92576 5.03667 8.94454 5.05546C8.96333 5.07424 8.98182 5.09327 9 5.11254C9.01818 5.09327 9.03667 5.07424 9.05546 5.05546C9.07424 5.03667 9.09327 5.01818 9.11254 5C9.09327 4.98182 9.07424 4.96333 9.05546 4.94454C9.03667 4.92576 9.01818 4.90673 9 4.88746Z"
5662 }), /*#__PURE__*/ react.default.createElement("path", {
5663 fillRule: "evenodd",
5664 clipRule: "evenodd",
5665 d: "M18.5303 2.46967C18.2374 2.17678 17.7626 2.17678 17.4697 2.46967L2.46967 17.4697C2.17678 17.7626 2.17678 18.2374 2.46967 18.5303L5.46967 21.5303C5.76256 21.8232 6.23744 21.8232 6.53033 21.5303L21.5303 6.53033C21.8232 6.23744 21.8232 5.76256 21.5303 5.46967L18.5303 2.46967ZM18 7.93934L19.9393 6L18 4.06066L16.0607 6L18 7.93934ZM15 7.06066L16.9393 9L6 19.9393L4.06066 18L15 7.06066Z"
5666 }), /*#__PURE__*/ react.default.createElement("path", {
5667 fillRule: "evenodd",
5668 clipRule: "evenodd",
5669 d: "M19.75 13C19.75 12.5858 19.4142 12.25 19 12.25C18.5858 12.25 18.25 12.5858 18.25 13C18.25 13.3315 18.1183 13.6495 17.8839 13.8839C17.6495 14.1183 17.3315 14.25 17 14.25C16.5858 14.25 16.25 14.5858 16.25 15C16.25 15.4142 16.5858 15.75 17 15.75C17.3315 15.75 17.6495 15.8817 17.8839 16.1161C18.1183 16.3505 18.25 16.6685 18.25 17C18.25 17.4142 18.5858 17.75 19 17.75C19.4142 17.75 19.75 17.4142 19.75 17C19.75 16.6685 19.8817 16.3505 20.1161 16.1161C20.3505 15.8817 20.6685 15.75 21 15.75C21.4142 15.75 21.75 15.4142 21.75 15C21.75 14.5858 21.4142 14.25 21 14.25C20.6685 14.25 20.3505 14.1183 20.1161 13.8839C19.8817 13.6495 19.75 13.3315 19.75 13ZM18.9445 14.9445C18.9633 14.9258 18.9818 14.9067 19 14.8875C19.0182 14.9067 19.0367 14.9258 19.0555 14.9445C19.0742 14.9633 19.0933 14.9818 19.1125 15C19.0933 15.0182 19.0742 15.0367 19.0555 15.0555C19.0367 15.0742 19.0182 15.0933 19 15.1125C18.9818 15.0933 18.9633 15.0742 18.9445 15.0555C18.9258 15.0367 18.9067 15.0182 18.8875 15C18.9067 14.9818 18.9258 14.9633 18.9445 14.9445Z"
5670 }));
5671 });
5672
5673 //#endregion
5674 //#region modules/ai/assets/js/editor/pages/form-media/components/enhance-button.js
5675 init_extends();
5676 init_objectWithoutProperties();
5677 var _excluded$21 = ["isLoading"];
5678 var StyledWandIcon = (0, _elementor_ui.withDirection)(WandIcon);
5679 var EnhanceButton = function EnhanceButton(_ref) {
5680 var isLoading = _ref.isLoading;
5681 var props = _objectWithoutProperties(_ref, _excluded$21);
5682 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: (0, _wordpress_i18n.__)("Enhance prompt", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
5683 component: "span",
5684 sx: { cursor: props.disabled ? "default" : "pointer" }
5685 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, _extends$1({
5686 size: "small",
5687 color: "secondary"
5688 }, props), isLoading ? /*#__PURE__*/ react.default.createElement(_elementor_ui.CircularProgress, {
5689 color: "secondary",
5690 size: 20
5691 }) : /*#__PURE__*/ react.default.createElement(StyledWandIcon, { fontSize: "small" }))));
5692 };
5693 EnhanceButton.propTypes = {
5694 disabled: import_prop_types$7.default.bool,
5695 isLoading: import_prop_types$7.default.bool
5696 };
5697
5698 //#endregion
5699 //#region modules/ai/assets/js/editor/pages/form-layout/context/config.js
5700 var MODE_LAYOUT = "layout";
5701 var MODE_VARIATION = "variation";
5702 var LAYOUT_APP_MODES = [MODE_LAYOUT, MODE_VARIATION];
5703 var ConfigContext = react.default.createContext({});
5704 var useConfig = function useConfig() {
5705 return react.default.useContext(ConfigContext);
5706 };
5707 var ConfigProvider = function ConfigProvider(props) {
5708 return /*#__PURE__*/ react.default.createElement(ConfigContext.Provider, { value: {
5709 mode: props.mode,
5710 attachmentsTypes: props.attachmentsTypes,
5711 onClose: props.onClose,
5712 onConnect: props.onConnect,
5713 onData: props.onData,
5714 onInsert: props.onInsert,
5715 onSelect: props.onSelect,
5716 onGenerate: props.onGenerate,
5717 currentContext: props.currentContext,
5718 hasPro: props.hasPro
5719 } }, props.children);
5720 };
5721 ConfigProvider.propTypes = {
5722 mode: import_prop_types$7.default.oneOf(LAYOUT_APP_MODES).isRequired,
5723 children: import_prop_types$7.default.node.isRequired,
5724 attachmentsTypes: import_prop_types$7.default.object.isRequired,
5725 onClose: import_prop_types$7.default.func.isRequired,
5726 onConnect: import_prop_types$7.default.func.isRequired,
5727 onData: import_prop_types$7.default.func.isRequired,
5728 onInsert: import_prop_types$7.default.func.isRequired,
5729 onSelect: import_prop_types$7.default.func.isRequired,
5730 onGenerate: import_prop_types$7.default.func.isRequired,
5731 currentContext: import_prop_types$7.default.object,
5732 hasPro: import_prop_types$7.default.bool
5733 };
5734
5735 //#endregion
5736 //#region modules/ai/assets/js/editor/hooks/use-prompt-enhancer.js
5737 init_api();
5738 init_use_prompt();
5739 var enhancePromptMap = /* @__PURE__ */ new Map([["media", getImagePromptEnhanced], ["layout", getLayoutPromptEnhanced]]);
5740 var getResult = function getResult(prompt, type, enhanceType) {
5741 if (!enhancePromptMap.has(type)) throw new Error("Invalid prompt type: ".concat(type));
5742 return enhancePromptMap.get(type)(prompt, enhanceType);
5743 };
5744 /**
5745 * Hook to enhance a prompt.
5746 *
5747 * @param {string} prompt
5748 * @param {'media' | 'layout'} type
5749 * @return {{enhancedPrompt: string | undefined, isEnhancing: boolean, enhance: (function(...[*]): Promise)}}
5750 */
5751 var usePromptEnhancer = function usePromptEnhancer(prompt, type) {
5752 var mode = useConfig().mode;
5753 var _usePrompt = usePrompt(function() {
5754 return getResult(prompt, type, mode);
5755 }, prompt);
5756 var enhancedData = _usePrompt.data;
5757 var isEnhancing = _usePrompt.isLoading;
5758 return {
5759 enhance: _usePrompt.send,
5760 isEnhancing,
5761 enhancedPrompt: enhancedData === null || enhancedData === void 0 ? void 0 : enhancedData.result
5762 };
5763 };
5764
5765 //#endregion
5766 //#region modules/ai/assets/js/editor/pages/form-media/components/prompt-field.js
5767 init_extends();
5768 init_objectWithoutProperties();
5769 init_textarea();
5770 var _excluded$20 = ["disabled", "onChange"];
5771 var PromptField = function PromptField(_ref) {
5772 var disabled = _ref.disabled;
5773 var _onChange = _ref.onChange;
5774 var props = _objectWithoutProperties(_ref, _excluded$20);
5775 var _usePromptEnhancer = usePromptEnhancer(props.value, "media");
5776 var enhance = _usePromptEnhancer.enhance;
5777 var isEnhancing = _usePromptEnhancer.isEnhancing;
5778 return /*#__PURE__*/ react.default.createElement(Textarea, _extends$1({
5779 minRows: 3,
5780 maxRows: 6,
5781 InputProps: { endAdornment: /*#__PURE__*/ react.default.createElement(_elementor_ui.InputAdornment, {
5782 position: "end",
5783 sx: {
5784 position: "absolute",
5785 bottom: "24px",
5786 right: "8px"
5787 }
5788 }, /*#__PURE__*/ react.default.createElement(EnhanceButton, {
5789 isLoading: isEnhancing,
5790 disabled: disabled || isEnhancing || !props.value,
5791 onClick: function onClick() {
5792 enhance(prompt).then(function(_ref2) {
5793 var result = _ref2.result;
5794 return _onChange(result);
5795 });
5796 }
5797 })) },
5798 sx: { "& .MuiInputBase-input.MuiOutlinedInput-input.MuiInputBase-inputMultiline": {
5799 pb: 5,
5800 width: "89%"
5801 } },
5802 onKeyDown: function onKeyDown(event) {
5803 if ("Tab" === event.key) {
5804 event.preventDefault();
5805 _onChange(props.placeholder);
5806 }
5807 }
5808 }, props, {
5809 onChange: function onChange(event) {
5810 return _onChange(event.target.value);
5811 },
5812 disabled: disabled || isEnhancing
5813 }));
5814 };
5815 PromptField.propTypes = {
5816 value: import_prop_types$7.default.string,
5817 disabled: import_prop_types$7.default.bool,
5818 placeholder: import_prop_types$7.default.string,
5819 onChange: import_prop_types$7.default.func.isRequired
5820 };
5821
5822 //#endregion
5823 //#region modules/ai/assets/js/editor/pages/form-media/components/image-type-select.js
5824 init_extends();
5825 init_slicedToArray();
5826 init_use_introduction();
5827 var StyledNewChip = (0, _elementor_ui.styled)(_elementor_ui.Chip)(function() {
5828 return { "& .MuiChip-label": {
5829 fontSize: "0.75rem",
5830 fontWeight: "normal"
5831 } };
5832 });
5833 var showLabel = function showLabel(label, key, isViewed, markAsViewed) {
5834 if (isViewed) return {
5835 label,
5836 value: key
5837 };
5838 return {
5839 label: /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
5840 direction: "row",
5841 width: "100%",
5842 justifyContent: "space-between",
5843 alignItems: "center"
5844 }, label, /*#__PURE__*/ react.default.createElement(StyledNewChip, {
5845 label: "New",
5846 color: "info",
5847 variant: "standard",
5848 size: "tiny"
5849 })),
5850 value: key,
5851 onClick: function onClick() {
5852 return markAsViewed();
5853 }
5854 };
5855 };
5856 var changeImageType = function changeImageType(e, props, markVectorAsViewed) {
5857 if ("vector" === e.target.value) markVectorAsViewed();
5858 if (props.onChange) props.onChange(e);
5859 };
5860 var ImageTypeSelect = function ImageTypeSelect(props) {
5861 var _useIntroduction = useIntroduction("e-ai-image-vector-option");
5862 var isVectorViewed = _useIntroduction.isViewed;
5863 var markVectorAsViewed = _useIntroduction.markAsViewed;
5864 var imageTypesWithNewChip = Object.entries(IMAGE_PROMPT_CATEGORIES).map(function(_ref) {
5865 var _ref2 = _slicedToArray(_ref, 2);
5866 var key = _ref2[0];
5867 var label = _ref2[1].label;
5868 if ("vector" === key) return showLabel(label, key, isVectorViewed, markVectorAsViewed);
5869 return {
5870 label,
5871 value: key
5872 };
5873 });
5874 return /*#__PURE__*/ react.default.createElement(PromptActionSelection, _extends$1({
5875 options: imageTypesWithNewChip,
5876 wrapperStyle: { width: "100%" },
5877 label: (0, _wordpress_i18n.__)("Image type", "elementor")
5878 }, props, { onChange: function onChange(e) {
5879 changeImageType(e, props, markVectorAsViewed);
5880 } }));
5881 };
5882 ImageTypeSelect.propTypes = {
5883 onChange: import_prop_types$7.default.func,
5884 value: import_prop_types$7.default.string,
5885 disabled: import_prop_types$7.default.bool
5886 };
5887
5888 //#endregion
5889 //#region modules/ai/assets/js/editor/pages/form-media/components/image-style-select.js
5890 init_extends();
5891 init_slicedToArray();
5892 init_objectWithoutProperties();
5893 var _excluded$19 = ["type"];
5894 var ImageStyleSelect = function ImageStyleSelect(_ref) {
5895 var _IMAGE_PROMPT_CATEGOR;
5896 var _ref$type = _ref.type;
5897 var type = _ref$type === void 0 ? "" : _ref$type;
5898 var props = _objectWithoutProperties(_ref, _excluded$19);
5899 var imageStyles = Object.entries(((_IMAGE_PROMPT_CATEGOR = IMAGE_PROMPT_CATEGORIES[type]) === null || _IMAGE_PROMPT_CATEGOR === void 0 ? void 0 : _IMAGE_PROMPT_CATEGOR.subCategories) || {}).map(function(_ref2) {
5900 var _ref3 = _slicedToArray(_ref2, 2);
5901 var value = _ref3[0];
5902 return {
5903 label: _ref3[1],
5904 value
5905 };
5906 });
5907 return /*#__PURE__*/ react.default.createElement(PromptActionSelection, _extends$1({
5908 options: imageStyles,
5909 wrapperStyle: { width: "100%" },
5910 label: (0, _wordpress_i18n.__)("Style", "elementor")
5911 }, props));
5912 };
5913 ImageStyleSelect.propTypes = { type: import_prop_types$7.default.string.isRequired };
5914
5915 //#endregion
5916 //#region modules/ai/assets/js/editor/pages/form-media/components/image-ratio-select.js
5917 init_extends();
5918 init_slicedToArray();
5919 var imageRatios = Object.entries(IMAGE_ASPECT_RATIO).map(function(_ref) {
5920 var _ref2 = _slicedToArray(_ref, 2);
5921 var value = _ref2[0];
5922 return {
5923 label: _ref2[1].label,
5924 value
5925 };
5926 });
5927 var ImageRatioSelect = function ImageRatioSelect(props) {
5928 return /*#__PURE__*/ react.default.createElement(PromptActionSelection, _extends$1({
5929 options: imageRatios,
5930 wrapperStyle: { width: "100%" },
5931 label: (0, _wordpress_i18n.__)("Aspect ratio", "elementor")
5932 }, props));
5933 };
5934
5935 //#endregion
5936 //#region modules/ai/assets/js/editor/icons/refresh-icon.js
5937 init_extends();
5938 var RefreshIcon = react.default.forwardRef(function(props, ref) {
5939 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
5940 fillRule: "evenodd",
5941 clipRule: "evenodd",
5942 d: "M7.55012 4.45178C9.23098 3.48072 11.1845 3.08925 13.1097 3.33767C15.035 3.58609 16.8251 4.46061 18.2045 5.82653C19.5838 7.19245 20.4757 8.97399 20.743 10.8967C20.8 11.307 20.5136 11.6858 20.1033 11.7428C19.6931 11.7998 19.3142 11.5135 19.2572 11.1032C19.0353 9.50635 18.2945 8.02677 17.149 6.89236C16.0035 5.75795 14.5167 5.03165 12.9178 4.82534C11.3189 4.61902 9.69644 4.94414 8.30047 5.75061C7.24361 6.36117 6.36093 7.22198 5.72541 8.24995H8.00009C8.41431 8.24995 8.75009 8.58574 8.75009 8.99995C8.75009 9.41417 8.41431 9.74995 8.00009 9.74995H4.51686C4.5055 9.75021 4.49412 9.75021 4.48272 9.74995H4.00009C3.58588 9.74995 3.25009 9.41417 3.25009 8.99995V4.99995C3.25009 4.58574 3.58588 4.24995 4.00009 4.24995C4.41431 4.24995 4.75009 4.58574 4.75009 4.99995V7.00691C5.48358 5.96916 6.43655 5.0951 7.55012 4.45178Z"
5943 }), /*#__PURE__*/ react.default.createElement("path", {
5944 fillRule: "evenodd",
5945 clipRule: "evenodd",
5946 d: "M3.89686 12.2571C4.30713 12.2001 4.68594 12.4864 4.74295 12.8967C4.96487 14.4936 5.70565 15.9731 6.85119 17.1075C7.99673 18.242 9.48347 18.9683 11.0824 19.1746C12.6813 19.3809 14.3037 19.0558 15.6997 18.2493C16.7566 17.6387 17.6393 16.7779 18.2748 15.75H16.0001C15.5859 15.75 15.2501 15.4142 15.2501 15C15.2501 14.5857 15.5859 14.25 16.0001 14.25H19.4833C19.4947 14.2497 19.5061 14.2497 19.5175 14.25H20.0001C20.4143 14.25 20.7501 14.5857 20.7501 15V19C20.7501 19.4142 20.4143 19.75 20.0001 19.75C19.5859 19.75 19.2501 19.4142 19.2501 19V16.993C18.5166 18.0307 17.5636 18.9048 16.4501 19.5481C14.7692 20.5192 12.8157 20.9107 10.8904 20.6622C8.9652 20.4138 7.17504 19.5393 5.79572 18.1734C4.4164 16.8074 3.52443 15.0259 3.25723 13.1032C3.20022 12.6929 3.48658 12.3141 3.89686 12.2571Z"
5947 }));
5948 });
5949
5950 //#endregion
5951 //#region modules/ai/assets/js/editor/pages/form-media/components/generate-again-submit.js
5952 init_extends();
5953 var GenerateAgainSubmit = function GenerateAgainSubmit(props) {
5954 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
5955 fullWidth: true,
5956 type: "submit",
5957 variant: "contained",
5958 color: "secondary",
5959 startIcon: /*#__PURE__*/ react.default.createElement(RefreshIcon, null),
5960 sx: { color: "background.paper" }
5961 }, props), (0, _wordpress_i18n.__)("Generate again", "elementor"));
5962 };
5963
5964 //#endregion
5965 //#region modules/ai/assets/js/editor/pages/form-media/components/new-prompt-button.js
5966 init_extends();
5967 var NewPromptButton = function NewPromptButton(props) {
5968 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
5969 fullWidth: true,
5970 variant: "text",
5971 color: "secondary"
5972 }, props), (0, _wordpress_i18n.__)("New prompt", "elementor"));
5973 };
5974
5975 //#endregion
5976 //#region modules/ai/assets/js/editor/pages/form-media/components/generate-images-submit.js
5977 init_extends();
5978 init_generate_button();
5979 init_voice_promotion_alert();
5980 var GenerateImagesSubmit = function GenerateImagesSubmit(props) {
5981 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(GenerateButton$1, _extends$1({
5982 size: "medium",
5983 fullWidth: true
5984 }, props), (0, _wordpress_i18n.__)("Generate images", "elementor")), /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, { introductionKey: "ai-context-media-promotion" }));
5985 };
5986
5987 //#endregion
5988 //#region modules/ai/assets/js/editor/pages/form-media/hooks/use-image-size.js
5989 var useImageSize = function useImageSize(aspectRatio) {
5990 var _IMAGE_ASPECT_RATIO$a = IMAGE_ASPECT_RATIO[aspectRatio];
5991 return {
5992 width: _IMAGE_ASPECT_RATIO$a.width,
5993 height: _IMAGE_ASPECT_RATIO$a.height
5994 };
5995 };
5996
5997 //#endregion
5998 //#region modules/ai/assets/js/editor/hooks/use-image-navigation.js
5999 init_slicedToArray();
6000 var initialIndex = -1;
6001 var useImageNavigation = function useImageNavigation(images) {
6002 var _useState2 = _slicedToArray((0, react.useState)(initialIndex), 2);
6003 var zoomIndex = _useState2[0];
6004 var setZoomIndex = _useState2[1];
6005 return {
6006 zoomIndex,
6007 setZoomIndex,
6008 actions: {
6009 reset: function reset() {
6010 return setZoomIndex(initialIndex);
6011 },
6012 prev: function prev() {
6013 var prevImage = zoomIndex + 1;
6014 if (prevImage >= images.length) prevImage = 0;
6015 setZoomIndex(prevImage);
6016 },
6017 next: function next() {
6018 var nextImage = zoomIndex - 1;
6019 if (nextImage < 0) nextImage = images.length - 1;
6020 setZoomIndex(nextImage);
6021 }
6022 }
6023 };
6024 };
6025
6026 //#endregion
6027 //#region modules/ai/assets/js/editor/icons/chevron-right-icon.js
6028 init_extends();
6029 var ChevronRightIcon = react.default.forwardRef(function(props, ref) {
6030 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
6031 fillRule: "evenodd",
6032 clipRule: "evenodd",
6033 d: "M8.46967 18.2803C8.17678 17.9874 8.17678 17.5126 8.46967 17.2197L13.9393 11.75L8.46967 6.28033C8.17678 5.98744 8.17678 5.51256 8.46967 5.21967C8.76256 4.92678 9.23744 4.92678 9.53033 5.21967L15.5303 11.2197C15.8232 11.5126 15.8232 11.9874 15.5303 12.2803L9.53033 18.2803C9.23744 18.5732 8.76256 18.5732 8.46967 18.2803Z"
6034 }));
6035 });
6036
6037 //#endregion
6038 //#region modules/ai/assets/js/editor/pages/form-media/components/image-slider.js
6039 init_defineProperty();
6040 init_extends();
6041 init_objectWithoutProperties();
6042 var _excluded$18 = [
6043 "onPrev",
6044 "onNext",
6045 "children"
6046 ];
6047 var _excluded2$2 = [
6048 "children",
6049 "startAction",
6050 "sx"
6051 ];
6052 var _excluded3$1 = ["src", "alt"];
6053 function ownKeys$21(e, r) {
6054 var t = Object.keys(e);
6055 if (Object.getOwnPropertySymbols) {
6056 var o = Object.getOwnPropertySymbols(e);
6057 r && (o = o.filter(function(r) {
6058 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6059 })), t.push.apply(t, o);
6060 }
6061 return t;
6062 }
6063 __name(ownKeys$21, "ownKeys");
6064 function _objectSpread$21(e) {
6065 for (var r = 1; r < arguments.length; r++) {
6066 var t = null != arguments[r] ? arguments[r] : {};
6067 r % 2 ? ownKeys$21(Object(t), !0).forEach(function(r) {
6068 _defineProperty(e, r, t[r]);
6069 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$21(Object(t)).forEach(function(r) {
6070 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6071 });
6072 }
6073 return e;
6074 }
6075 __name(_objectSpread$21, "_objectSpread");
6076 var StyledChevronLeftIcon = (0, _elementor_ui.withDirection)(ChevronLeftIcon);
6077 var StyledChevronRightIcon = (0, _elementor_ui.withDirection)(ChevronRightIcon);
6078 var ImageSlider = function ImageSlider(_ref) {
6079 var onPrev = _ref.onPrev;
6080 var onNext = _ref.onNext;
6081 var children = _ref.children;
6082 var props = _objectWithoutProperties(_ref, _excluded$18);
6083 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, _extends$1({
6084 alignItems: "flex-start",
6085 spacing: .5
6086 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
6087 direction: "row",
6088 spacing: 2.5,
6089 alignSelf: "center",
6090 alignItems: "center"
6091 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
6092 onClick: onPrev,
6093 size: "large",
6094 color: "secondary"
6095 }, /*#__PURE__*/ react.default.createElement(StyledChevronLeftIcon, null)), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
6096 spacing: .5,
6097 justifyContent: "space-around",
6098 alignItems: "center"
6099 }, children), /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
6100 onClick: onNext,
6101 size: "large",
6102 color: "secondary"
6103 }, /*#__PURE__*/ react.default.createElement(StyledChevronRightIcon, null))));
6104 };
6105 ImageSlider.propTypes = {
6106 onPrev: import_prop_types$7.default.func.isRequired,
6107 onNext: import_prop_types$7.default.func.isRequired,
6108 children: import_prop_types$7.default.node.isRequired
6109 };
6110 var Actions$1 = function Actions(_ref2) {
6111 var children = _ref2.children;
6112 var startAction = _ref2.startAction;
6113 var _ref2$sx = _ref2.sx;
6114 var sx = _ref2$sx === void 0 ? {} : _ref2$sx;
6115 var props = _objectWithoutProperties(_ref2, _excluded2$2);
6116 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
6117 display: "flex",
6118 justifyContent: "flex-end",
6119 alignItems: "center",
6120 width: "100%"
6121 }, props, { sx: _objectSpread$21({ mb: 1.5 }, sx) }), startAction, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
6122 direction: "row",
6123 spacing: 2,
6124 justifyContent: "flex-end",
6125 flexGrow: 1,
6126 width: "100%"
6127 }, children));
6128 };
6129 Actions$1.propTypes = {
6130 sx: import_prop_types$7.default.object,
6131 startAction: import_prop_types$7.default.node,
6132 children: import_prop_types$7.default.node.isRequired
6133 };
6134 var Image$2 = function Image(_ref3) {
6135 var src = _ref3.src;
6136 var _ref3$alt = _ref3.alt;
6137 var alt = _ref3$alt === void 0 ? "" : _ref3$alt;
6138 var props = _objectWithoutProperties(_ref3, _excluded3$1);
6139 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
6140 display: "flex",
6141 justifyContent: "center",
6142 alignItems: "center"
6143 }, /*#__PURE__*/ react.default.createElement("img", _extends$1({
6144 src,
6145 alt
6146 }, props)));
6147 };
6148 Image$2.propTypes = {
6149 alt: import_prop_types$7.default.string,
6150 src: import_prop_types$7.default.string.isRequired
6151 };
6152 ImageSlider.Actions = Actions$1;
6153 ImageSlider.Image = Image$2;
6154
6155 //#endregion
6156 //#region modules/ai/assets/js/editor/icons/copy-icon.js
6157 init_extends();
6158 var CopyIcon$1 = react.default.forwardRef(function(props, ref) {
6159 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
6160 fillRule: "evenodd",
6161 clipRule: "evenodd",
6162 d: "M9 3.75C8.30964 3.75 7.75 4.30964 7.75 5V15C7.75 15.6904 8.30964 16.25 9 16.25H19C19.6904 16.25 20.25 15.6904 20.25 15V5C20.25 4.30964 19.6904 3.75 19 3.75H9ZM6.25 5C6.25 3.48122 7.48122 2.25 9 2.25H19C20.5188 2.25 21.75 3.48122 21.75 5V15C21.75 16.5188 20.5188 17.75 19 17.75H9C7.48122 17.75 6.25 16.5188 6.25 15V5Z"
6163 }), /*#__PURE__*/ react.default.createElement("path", {
6164 fillRule: "evenodd",
6165 clipRule: "evenodd",
6166 d: "M5 7.75C4.66848 7.75 4.35054 7.8817 4.11612 8.11612C3.8817 8.35054 3.75 8.66848 3.75 9V19C3.75 19.3315 3.8817 19.6495 4.11612 19.8839C4.35054 20.1183 4.66848 20.25 5 20.25H15C15.3315 20.25 15.6495 20.1183 15.8839 19.8839C16.1183 19.6495 16.25 19.3315 16.25 19V17C16.25 16.5858 16.5858 16.25 17 16.25C17.4142 16.25 17.75 16.5858 17.75 17V19C17.75 19.7293 17.4603 20.4288 16.9445 20.9445C16.4288 21.4603 15.7293 21.75 15 21.75H5C4.27065 21.75 3.57118 21.4603 3.05546 20.9445C2.53973 20.4288 2.25 19.7293 2.25 19V9C2.25 8.27065 2.53973 7.57118 3.05546 7.05546C3.57118 6.53973 4.27065 6.25 5 6.25H7C7.41421 6.25 7.75 6.58579 7.75 7C7.75 7.41421 7.41421 7.75 7 7.75H5Z"
6167 }));
6168 });
6169
6170 //#endregion
6171 //#region modules/ai/assets/js/editor/icons/edit-icon.js
6172 init_extends();
6173 var EditIcon$1 = react.default.forwardRef(function(props, ref) {
6174 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
6175 fillRule: "evenodd",
6176 clipRule: "evenodd",
6177 d: "M13.9697 4.96967C14.6408 4.29858 15.5509 3.92157 16.5 3.92157C17.4491 3.92157 18.3592 4.29858 19.0303 4.96967C19.7014 5.64075 20.0784 6.55094 20.0784 7.5C20.0784 8.44905 19.7014 9.35924 19.0303 10.0303L8.53033 20.5303C8.38968 20.671 8.19891 20.75 8 20.75H4C3.58579 20.75 3.25 20.4142 3.25 20V16C3.25 15.8011 3.32902 15.6103 3.46967 15.4697L13.9697 4.96967ZM16.5 5.42157C15.9488 5.42157 15.4201 5.64055 15.0303 6.03033L4.75 16.3107V19.25H7.68934L17.9697 8.96967C18.3595 8.57989 18.5784 8.05123 18.5784 7.5C18.5784 6.94876 18.3595 6.42011 17.9697 6.03033C17.5799 5.64055 17.0512 5.42157 16.5 5.42157Z"
6178 }), /*#__PURE__*/ react.default.createElement("path", {
6179 fillRule: "evenodd",
6180 clipRule: "evenodd",
6181 d: "M12.9697 5.96967C13.2626 5.67677 13.7374 5.67677 14.0303 5.96967L18.0303 9.96967C18.3232 10.2626 18.3232 10.7374 18.0303 11.0303C17.7374 11.3232 17.2626 11.3232 16.9697 11.0303L12.9697 7.03033C12.6768 6.73743 12.6768 6.26256 12.9697 5.96967Z"
6182 }));
6183 });
6184
6185 //#endregion
6186 //#region modules/ai/assets/js/editor/icons/download-icon.js
6187 init_extends();
6188 var DownloadIcon = react.default.forwardRef(function(props, ref) {
6189 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
6190 fillRule: "evenodd",
6191 clipRule: "evenodd",
6192 d: "M4 16.25C4.41421 16.25 4.75 16.5858 4.75 17V19C4.75 19.3315 4.8817 19.6495 5.11612 19.8839C5.35054 20.1183 5.66848 20.25 6 20.25H18C18.3315 20.25 18.6495 20.1183 18.8839 19.8839C19.1183 19.6495 19.25 19.3315 19.25 19V17C19.25 16.5858 19.5858 16.25 20 16.25C20.4142 16.25 20.75 16.5858 20.75 17V19C20.75 19.7293 20.4603 20.4288 19.9445 20.9445C19.4288 21.4603 18.7293 21.75 18 21.75H6C5.27065 21.75 4.57118 21.4603 4.05546 20.9445C3.53973 20.4288 3.25 19.7293 3.25 19V17C3.25 16.5858 3.58579 16.25 4 16.25Z"
6193 }), /*#__PURE__*/ react.default.createElement("path", {
6194 fillRule: "evenodd",
6195 clipRule: "evenodd",
6196 d: "M6.46967 10.4697C6.76256 10.1768 7.23744 10.1768 7.53033 10.4697L12 14.9393L16.4697 10.4697C16.7626 10.1768 17.2374 10.1768 17.5303 10.4697C17.8232 10.7626 17.8232 11.2374 17.5303 11.5303L12.5303 16.5303C12.2374 16.8232 11.7626 16.8232 11.4697 16.5303L6.46967 11.5303C6.17678 11.2374 6.17678 10.7626 6.46967 10.4697Z"
6197 }), /*#__PURE__*/ react.default.createElement("path", {
6198 fillRule: "evenodd",
6199 clipRule: "evenodd",
6200 d: "M12 3.25C12.4142 3.25 12.75 3.58579 12.75 4V16C12.75 16.4142 12.4142 16.75 12 16.75C11.5858 16.75 11.25 16.4142 11.25 16V4C11.25 3.58579 11.5858 3.25 12 3.25Z"
6201 }));
6202 });
6203
6204 //#endregion
6205 //#region modules/ai/assets/js/editor/icons/zoom-in-icon.js
6206 init_extends();
6207 var ZoomInIcon = react.default.forwardRef(function(props, ref) {
6208 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
6209 fillRule: "evenodd",
6210 clipRule: "evenodd",
6211 d: "M10 3.75C6.54822 3.75 3.75 6.54822 3.75 10C3.75 13.4518 6.54822 16.25 10 16.25C13.4518 16.25 16.25 13.4518 16.25 10C16.25 6.54822 13.4518 3.75 10 3.75ZM2.25 10C2.25 5.71979 5.71979 2.25 10 2.25C14.2802 2.25 17.75 5.71979 17.75 10C17.75 14.2802 14.2802 17.75 10 17.75C5.71979 17.75 2.25 14.2802 2.25 10Z"
6212 }), /*#__PURE__*/ react.default.createElement("path", {
6213 fillRule: "evenodd",
6214 clipRule: "evenodd",
6215 d: "M6.25 10C6.25 9.58579 6.58579 9.25 7 9.25H13C13.4142 9.25 13.75 9.58579 13.75 10C13.75 10.4142 13.4142 10.75 13 10.75H7C6.58579 10.75 6.25 10.4142 6.25 10Z"
6216 }), /*#__PURE__*/ react.default.createElement("path", {
6217 fillRule: "evenodd",
6218 clipRule: "evenodd",
6219 d: "M10 6.25C10.4142 6.25 10.75 6.58579 10.75 7V13C10.75 13.4142 10.4142 13.75 10 13.75C9.58579 13.75 9.25 13.4142 9.25 13V7C9.25 6.58579 9.58579 6.25 10 6.25Z"
6220 }), /*#__PURE__*/ react.default.createElement("path", {
6221 fillRule: "evenodd",
6222 clipRule: "evenodd",
6223 d: "M14.4697 14.4697C14.7626 14.1768 15.2374 14.1768 15.5303 14.4697L21.5303 20.4697C21.8232 20.7626 21.8232 21.2374 21.5303 21.5303C21.2374 21.8232 20.7626 21.8232 20.4697 21.5303L14.4697 15.5303C14.1768 15.2374 14.1768 14.7626 14.4697 14.4697Z"
6224 }));
6225 });
6226
6227 //#endregion
6228 //#region modules/ai/assets/js/editor/pages/form-media/components/image-actions.js
6229 init_defineProperty();
6230 init_objectWithoutProperties();
6231 init_extends();
6232 var _excluded$17 = ["children"];
6233 var _excluded2$1 = ["sx"];
6234 var _excluded3 = ["sx"];
6235 var _excluded4 = ["sx"];
6236 var _excluded5 = ["sx"];
6237 function ownKeys$20(e, r) {
6238 var t = Object.keys(e);
6239 if (Object.getOwnPropertySymbols) {
6240 var o = Object.getOwnPropertySymbols(e);
6241 r && (o = o.filter(function(r) {
6242 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6243 })), t.push.apply(t, o);
6244 }
6245 return t;
6246 }
6247 __name(ownKeys$20, "ownKeys");
6248 function _objectSpread$20(e) {
6249 for (var r = 1; r < arguments.length; r++) {
6250 var t = null != arguments[r] ? arguments[r] : {};
6251 r % 2 ? ownKeys$20(Object(t), !0).forEach(function(r) {
6252 _defineProperty(e, r, t[r]);
6253 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$20(Object(t)).forEach(function(r) {
6254 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6255 });
6256 }
6257 return e;
6258 }
6259 __name(_objectSpread$20, "_objectSpread");
6260 var StyledEditSvgIcon = (0, _elementor_ui.withDirection)(EditIcon$1);
6261 var StyledCopySvgIcon = (0, _elementor_ui.withDirection)(CopyIcon$1);
6262 var StyledZoomInIcon = (0, _elementor_ui.withDirection)(ZoomInIcon);
6263 var Tooltip$5 = function Tooltip(props) {
6264 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, _extends$1({ PopperProps: { sx: { "&.MuiTooltip-popper .MuiTooltip-tooltip.MuiTooltip-tooltipPlacementBottom": { mt: 1 } } } }, props));
6265 };
6266 var ImageActions = function ImageActions(_ref) {
6267 var children = _ref.children;
6268 var props = _objectWithoutProperties(_ref, _excluded$17);
6269 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
6270 display: "flex",
6271 justifyContent: "space-between",
6272 alignItems: "center",
6273 width: "100%",
6274 gap: 1
6275 }, props), children);
6276 };
6277 ImageActions.propTypes = { children: import_prop_types$7.default.node };
6278 var UseImage = function UseImage(_ref2) {
6279 var sx = _ref2.sx;
6280 var props = _objectWithoutProperties(_ref2, _excluded2$1);
6281 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
6282 size: "small",
6283 variant: "contained",
6284 startIcon: /*#__PURE__*/ react.default.createElement(DownloadIcon, null),
6285 sx
6286 }, props), (0, _wordpress_i18n.__)("Use Image", "elementor"));
6287 };
6288 UseImage.propTypes = { sx: import_prop_types$7.default.object };
6289 var EditImage = function EditImage(props) {
6290 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
6291 size: "small",
6292 color: "secondary",
6293 startIcon: /*#__PURE__*/ react.default.createElement(StyledEditSvgIcon, null)
6294 }, props), (0, _wordpress_i18n.__)("Edit", "elementor"));
6295 };
6296 var EditIcon = function EditIcon(_ref3) {
6297 var _ref3$sx = _ref3.sx;
6298 var sx = _ref3$sx === void 0 ? {} : _ref3$sx;
6299 var props = _objectWithoutProperties(_ref3, _excluded3);
6300 return /*#__PURE__*/ react.default.createElement(Tooltip$5, { title: (0, _wordpress_i18n.__)("Edit", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, _extends$1({ sx: _objectSpread$20({
6301 mr: -1.5,
6302 ml: .5,
6303 color: "common.white",
6304 "&:hover": { color: "common.white" }
6305 }, sx) }, props), /*#__PURE__*/ react.default.createElement(StyledEditSvgIcon, null)));
6306 };
6307 EditIcon.propTypes = { sx: import_prop_types$7.default.object };
6308 var ZoomIcon = function ZoomIcon(_ref4) {
6309 var _ref4$sx = _ref4.sx;
6310 var sx = _ref4$sx === void 0 ? {} : _ref4$sx;
6311 var props = _objectWithoutProperties(_ref4, _excluded4);
6312 return /*#__PURE__*/ react.default.createElement(Tooltip$5, { title: (0, _wordpress_i18n.__)("Zoom", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, _extends$1({
6313 color: "secondary",
6314 "aria-label": (0, _wordpress_i18n.__)("Zoom", "elementor"),
6315 sx: _objectSpread$20({
6316 color: "common.white",
6317 "&:hover": { color: "common.white" }
6318 }, sx)
6319 }, props), /*#__PURE__*/ react.default.createElement(StyledZoomInIcon, null)));
6320 };
6321 ZoomIcon.propTypes = { sx: import_prop_types$7.default.object };
6322 var CopyIcon = function CopyIcon(_ref5) {
6323 var _ref5$sx = _ref5.sx;
6324 var sx = _ref5$sx === void 0 ? {} : _ref5$sx;
6325 var props = _objectWithoutProperties(_ref5, _excluded5);
6326 return /*#__PURE__*/ react.default.createElement(Tooltip$5, { title: (0, _wordpress_i18n.__)("Copy prompt", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, _extends$1({ sx: _objectSpread$20({
6327 mr: -1.5,
6328 ml: .5,
6329 color: "common.white",
6330 "&:hover": { color: "common.white" }
6331 }, sx) }, props), /*#__PURE__*/ react.default.createElement(StyledCopySvgIcon, null)));
6332 };
6333 CopyIcon.propTypes = { sx: import_prop_types$7.default.object };
6334 ImageActions.UseImage = UseImage;
6335 ImageActions.EditImage = EditImage;
6336 ImageActions.EditIcon = EditIcon;
6337 ImageActions.ZoomIcon = ZoomIcon;
6338 ImageActions.CopyIcon = CopyIcon;
6339
6340 //#endregion
6341 //#region modules/ai/assets/js/editor/pages/form-media/components/single-image-preview.js
6342 init_defineProperty();
6343 init_extends();
6344 init_objectWithoutProperties();
6345 var _excluded$16 = ["children"];
6346 var _excluded2 = ["children", "sx"];
6347 function ownKeys$19(e, r) {
6348 var t = Object.keys(e);
6349 if (Object.getOwnPropertySymbols) {
6350 var o = Object.getOwnPropertySymbols(e);
6351 r && (o = o.filter(function(r) {
6352 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6353 })), t.push.apply(t, o);
6354 }
6355 return t;
6356 }
6357 __name(ownKeys$19, "ownKeys");
6358 function _objectSpread$19(e) {
6359 for (var r = 1; r < arguments.length; r++) {
6360 var t = null != arguments[r] ? arguments[r] : {};
6361 r % 2 ? ownKeys$19(Object(t), !0).forEach(function(r) {
6362 _defineProperty(e, r, t[r]);
6363 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$19(Object(t)).forEach(function(r) {
6364 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6365 });
6366 }
6367 return e;
6368 }
6369 __name(_objectSpread$19, "_objectSpread");
6370 var SingleImagePreview = function SingleImagePreview(_ref) {
6371 var children = _ref.children;
6372 var props = _objectWithoutProperties(_ref, _excluded$16);
6373 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({ display: "flex" }, props), children);
6374 };
6375 SingleImagePreview.propTypes = { children: import_prop_types$7.default.node.isRequired };
6376 var Actions = function Actions(_ref2) {
6377 var children = _ref2.children;
6378 var _ref2$sx = _ref2.sx;
6379 var sx = _ref2$sx === void 0 ? {} : _ref2$sx;
6380 var props = _objectWithoutProperties(_ref2, _excluded2);
6381 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
6382 display: "flex",
6383 width: "100%",
6384 justifyContent: "flex-end",
6385 alignItems: "center"
6386 }, props, { sx: _objectSpread$19({ mb: 1.5 }, sx) }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
6387 direction: "row",
6388 spacing: 2,
6389 justifyContent: "flex-end",
6390 width: "100%"
6391 }, children));
6392 };
6393 Actions.propTypes = {
6394 sx: import_prop_types$7.default.object,
6395 children: import_prop_types$7.default.node.isRequired
6396 };
6397 var Image$1 = function Image(_ref3) {
6398 var src = _ref3.src;
6399 var alt = _ref3.alt;
6400 var _ref3$style = _ref3.style;
6401 var style = _ref3$style === void 0 ? {} : _ref3$style;
6402 var _ref3$isLoading = _ref3.isLoading;
6403 var isLoading = _ref3$isLoading === void 0 ? false : _ref3$isLoading;
6404 var children = _ref3.children;
6405 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { margin: "0 auto" }, children, isLoading ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Skeleton, {
6406 sx: _objectSpread$19({
6407 maxWidth: "100%",
6408 width: "auto",
6409 maxHeight: "100%"
6410 }, style),
6411 animation: "wave",
6412 variant: "rounded"
6413 }) : /*#__PURE__*/ react.default.createElement("img", {
6414 src,
6415 alt,
6416 style: _objectSpread$19({
6417 maxWidth: "100%",
6418 width: "auto",
6419 maxHeight: "100%"
6420 }, style)
6421 }));
6422 };
6423 Image$1.propTypes = {
6424 style: import_prop_types$7.default.object,
6425 children: import_prop_types$7.default.node,
6426 src: import_prop_types$7.default.string.isRequired,
6427 alt: import_prop_types$7.default.string.isRequired,
6428 isLoading: import_prop_types$7.default.bool
6429 };
6430 SingleImagePreview.Actions = Actions;
6431 SingleImagePreview.Image = Image$1;
6432
6433 //#endregion
6434 //#region modules/ai/assets/js/editor/pages/form-media/components/images-display.js
6435 init_extends();
6436 init_defineProperty();
6437 init_objectWithoutProperties();
6438 var _excluded$15 = ["children", "sx"];
6439 function ownKeys$18(e, r) {
6440 var t = Object.keys(e);
6441 if (Object.getOwnPropertySymbols) {
6442 var o = Object.getOwnPropertySymbols(e);
6443 r && (o = o.filter(function(r) {
6444 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6445 })), t.push.apply(t, o);
6446 }
6447 return t;
6448 }
6449 __name(ownKeys$18, "ownKeys");
6450 function _objectSpread$18(e) {
6451 for (var r = 1; r < arguments.length; r++) {
6452 var t = null != arguments[r] ? arguments[r] : {};
6453 r % 2 ? ownKeys$18(Object(t), !0).forEach(function(r) {
6454 _defineProperty(e, r, t[r]);
6455 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$18(Object(t)).forEach(function(r) {
6456 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6457 });
6458 }
6459 return e;
6460 }
6461 __name(_objectSpread$18, "_objectSpread");
6462 var Container = function Container(_ref) {
6463 var children = _ref.children;
6464 var _ref$sx = _ref.sx;
6465 var sx = _ref$sx === void 0 ? {} : _ref$sx;
6466 var props = _objectWithoutProperties(_ref, _excluded$15);
6467 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({ flexGrow: 1 }, props, { sx: _objectSpread$18({ overflowY: "auto" }, sx) }), children);
6468 };
6469 Container.propTypes = {
6470 sx: import_prop_types$7.default.object,
6471 children: import_prop_types$7.default.node
6472 };
6473 var ImagesDisplay = function ImagesDisplay(_ref2) {
6474 var images = _ref2.images;
6475 var _ref2$aspectRatio = _ref2.aspectRatio;
6476 var aspectRatio = _ref2$aspectRatio === void 0 ? "1:1" : _ref2$aspectRatio;
6477 var _ref2$onUseImage = _ref2.onUseImage;
6478 var onUseImage = _ref2$onUseImage === void 0 ? null : _ref2$onUseImage;
6479 var _ref2$onEditImage = _ref2.onEditImage;
6480 var onEditImage = _ref2$onEditImage === void 0 ? null : _ref2$onEditImage;
6481 var _ref2$transparentCont = _ref2.transparentContainer;
6482 var transparentContainer = _ref2$transparentCont === void 0 ? false : _ref2$transparentCont;
6483 var _ref2$cols = _ref2.cols;
6484 var cols = _ref2$cols === void 0 ? 2 : _ref2$cols;
6485 var _ref2$overlay = _ref2.overlay;
6486 var overlay = _ref2$overlay === void 0 ? true : _ref2$overlay;
6487 var _ref2$onSelectChange = _ref2.onSelectChange;
6488 var onSelectChange = _ref2$onSelectChange === void 0 ? null : _ref2$onSelectChange;
6489 var _useImageNavigation = useImageNavigation(images);
6490 var zoomIndex = _useImageNavigation.zoomIndex;
6491 var setZoomIndex = _useImageNavigation.setZoomIndex;
6492 var actions = _useImageNavigation.actions;
6493 var _useImageSize = useImageSize(aspectRatio);
6494 var width = _useImageSize.width;
6495 var height = _useImageSize.height;
6496 if (zoomIndex > -1) {
6497 var currentImage = images[zoomIndex];
6498 return /*#__PURE__*/ react.default.createElement(Container, null, /*#__PURE__*/ react.default.createElement(ImageSlider, {
6499 onPrev: actions.prev,
6500 onNext: actions.next
6501 }, /*#__PURE__*/ react.default.createElement(ImageSlider.Actions, { startAction: /*#__PURE__*/ react.default.createElement(BackButton$1, { onClick: actions.reset }) }, onEditImage && /*#__PURE__*/ react.default.createElement(ImageActions.EditImage, { onClick: function onClick() {
6502 return onEditImage(currentImage);
6503 } }), onUseImage && /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, { onClick: function onClick() {
6504 return onUseImage(currentImage);
6505 } })), /*#__PURE__*/ react.default.createElement(ImageSlider.Image, {
6506 src: currentImage.image_url,
6507 style: {
6508 maxWidth: "630px",
6509 width: "100%",
6510 height: "auto"
6511 }
6512 })));
6513 }
6514 if (1 === images.length) {
6515 var image = images[0];
6516 var singleImageStyle = {
6517 width,
6518 height
6519 };
6520 if (transparentContainer) {
6521 singleImageStyle.backgroundImage = "linear-gradient(45deg, #bbb 25%, transparent 25%), linear-gradient(-45deg, #bbb 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #bbb 75%), linear-gradient(-45deg, transparent 75%, #bbb 75%)";
6522 singleImageStyle.backgroundSize = "20px 20px";
6523 singleImageStyle.backgroundPosition = "0 0, 0 10px, 10px -10px, -10px 0px";
6524 }
6525 return /*#__PURE__*/ react.default.createElement(Container, { flexDirection: "column" }, /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
6526 src: image.image_url || image.url,
6527 style: singleImageStyle,
6528 alt: "generated-image",
6529 isLoading: image.isLoading
6530 }, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Actions, null, onEditImage && /*#__PURE__*/ react.default.createElement(ImageActions.EditImage, { onClick: function onClick() {
6531 return onEditImage(image);
6532 } }), onUseImage && /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, { onClick: function onClick() {
6533 return onUseImage(image);
6534 } })))));
6535 }
6536 return /*#__PURE__*/ react.default.createElement(Container, null, /*#__PURE__*/ react.default.createElement(Gallery, { cols }, images.map(function(image, index) {
6537 return /*#__PURE__*/ react.default.createElement(Gallery.Image, {
6538 key: "result-".concat(image.seed),
6539 alt: "generated-".concat(index),
6540 src: image.image_url,
6541 aspectRatio,
6542 "data-testid": "e-gallery-image",
6543 numImagesInRow: cols,
6544 overlay,
6545 onSelectChange: onSelectChange ? function(isChecked) {
6546 return onSelectChange(image.productId, isChecked);
6547 } : null,
6548 checkboxColor: image.checkboxColor,
6549 initialChecked: image.isChecked,
6550 isLoading: image.isLoading
6551 }, /*#__PURE__*/ react.default.createElement(ImageActions, null, onUseImage && /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, {
6552 onClick: function onClick() {
6553 return onUseImage(image);
6554 },
6555 size: "medium",
6556 fullWidth: true
6557 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
6558 direction: "row",
6559 spacing: .25,
6560 alignItems: "center"
6561 }, /*#__PURE__*/ react.default.createElement(ImageActions.ZoomIcon, {
6562 onClick: function onClick() {
6563 return setZoomIndex(index);
6564 },
6565 size: "medium"
6566 }), onEditImage && /*#__PURE__*/ react.default.createElement(ImageActions.EditIcon, {
6567 onClick: function onClick() {
6568 return onEditImage(image);
6569 },
6570 size: "medium"
6571 }))));
6572 })));
6573 };
6574 ImagesDisplay.propTypes = {
6575 images: import_prop_types$7.default.array,
6576 aspectRatio: import_prop_types$7.default.string,
6577 onUseImage: import_prop_types$7.default.func,
6578 onEditImage: import_prop_types$7.default.func,
6579 transparentContainer: import_prop_types$7.default.bool,
6580 cols: import_prop_types$7.default.number,
6581 overlay: import_prop_types$7.default.bool,
6582 onSelectChange: import_prop_types$7.default.func
6583 };
6584 ImagesDisplay.Container = Container;
6585
6586 //#endregion
6587 //#region modules/ai/assets/js/editor/pages/form-media/hooks/use-prompt-settings.js
6588 init_defineProperty();
6589 init_slicedToArray();
6590 function ownKeys$17(e, r) {
6591 var t = Object.keys(e);
6592 if (Object.getOwnPropertySymbols) {
6593 var o = Object.getOwnPropertySymbols(e);
6594 r && (o = o.filter(function(r) {
6595 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6596 })), t.push.apply(t, o);
6597 }
6598 return t;
6599 }
6600 __name(ownKeys$17, "ownKeys");
6601 function _objectSpread$17(e) {
6602 for (var r = 1; r < arguments.length; r++) {
6603 var t = null != arguments[r] ? arguments[r] : {};
6604 r % 2 ? ownKeys$17(Object(t), !0).forEach(function(r) {
6605 _defineProperty(e, r, t[r]);
6606 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$17(Object(t)).forEach(function(r) {
6607 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6608 });
6609 }
6610 return e;
6611 }
6612 __name(_objectSpread$17, "_objectSpread");
6613 var IMAGE_TYPE = IMAGE_PROMPT_SETTINGS.IMAGE_TYPE;
6614 var IMAGE_STYLE = IMAGE_PROMPT_SETTINGS.IMAGE_STYLE;
6615 var IMAGE_STRENGTH = IMAGE_PROMPT_SETTINGS.IMAGE_STRENGTH;
6616 var IMAGE_RATIO = IMAGE_PROMPT_SETTINGS.IMAGE_RATIO;
6617 var IMAGE_ZOOM = IMAGE_PROMPT_SETTINGS.IMAGE_ZOOM;
6618 var IMAGE_UPSCALE = IMAGE_PROMPT_SETTINGS.IMAGE_UPSCALE;
6619 var IMAGE_BACKGROUND_COLOR = IMAGE_PROMPT_SETTINGS.IMAGE_BACKGROUND_COLOR;
6620 var DEFAULT_TYPE = "";
6621 var DEFAULT_STYLE = "";
6622 var DEFAULT_STRENGTH = 0;
6623 var DEFAULT_RATIO = "1:1";
6624 var DEFAULT_ZOOM = "1";
6625 var DEFAULT_UPSCALE = "512";
6626 var DEFAULT_COLOR = "#FFFFFF";
6627 var usePromptSettings = function usePromptSettings() {
6628 var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
6629 var _ref$type = _ref.type;
6630 var type = _ref$type === void 0 ? DEFAULT_TYPE : _ref$type;
6631 var _ref$style = _ref.style;
6632 var style = _ref$style === void 0 ? DEFAULT_STYLE : _ref$style;
6633 var _ref$imageWeight = _ref.imageWeight;
6634 var imageWeight = _ref$imageWeight === void 0 ? DEFAULT_STRENGTH : _ref$imageWeight;
6635 var _ref$aspectRatio = _ref.aspectRatio;
6636 var aspectRatio = _ref$aspectRatio === void 0 ? DEFAULT_RATIO : _ref$aspectRatio;
6637 var _ref$zoom = _ref.zoom;
6638 var zoom = _ref$zoom === void 0 ? DEFAULT_ZOOM : _ref$zoom;
6639 var _ref$upScaleTo = _ref.upScaleTo;
6640 var upScaleTo = _ref$upScaleTo === void 0 ? DEFAULT_UPSCALE : _ref$upScaleTo;
6641 var _ref$bgColor = _ref.bgColor;
6642 var bgColor = _ref$bgColor === void 0 ? DEFAULT_COLOR : _ref$bgColor;
6643 var _useState2 = _slicedToArray((0, react.useState)(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, IMAGE_TYPE, type), IMAGE_STYLE, style), IMAGE_STRENGTH, imageWeight), IMAGE_RATIO, aspectRatio), IMAGE_ZOOM, zoom), IMAGE_UPSCALE, upScaleTo), IMAGE_BACKGROUND_COLOR, bgColor)), 2);
6644 var settings = _useState2[0];
6645 var setSettings = _useState2[1];
6646 return {
6647 settings,
6648 updateSettings: function updateSettings(updated) {
6649 return setSettings(function(prev) {
6650 return _objectSpread$17(_objectSpread$17({}, prev), updated);
6651 });
6652 },
6653 resetSettings: function resetSettings() {
6654 setSettings(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, IMAGE_TYPE, type), IMAGE_STYLE, DEFAULT_STYLE), IMAGE_STRENGTH, DEFAULT_STRENGTH), IMAGE_RATIO, aspectRatio), IMAGE_ZOOM, DEFAULT_ZOOM), IMAGE_UPSCALE, DEFAULT_UPSCALE), IMAGE_BACKGROUND_COLOR, bgColor));
6655 }
6656 };
6657 };
6658
6659 //#endregion
6660 //#region modules/ai/assets/js/editor/hooks/use-images-preload.js
6661 init_slicedToArray();
6662 var loadImage$1 = function loadImage(url) {
6663 return new Promise(function(resolve, reject) {
6664 var loadImg = new Image();
6665 loadImg.src = url;
6666 loadImg.onload = function() {
6667 return resolve(url);
6668 };
6669 loadImg.onerror = function(err) {
6670 return reject(err);
6671 };
6672 });
6673 };
6674 var useImagesPreload = function useImagesPreload() {
6675 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
6676 var ready = _useState2[0];
6677 var setReady = _useState2[1];
6678 return {
6679 ready,
6680 preloadImages: function preloadImages(images) {
6681 setReady(false);
6682 Promise.all(images.map(function(url) {
6683 return loadImage$1(url);
6684 })).then(function() {
6685 return setReady(true);
6686 }).catch(function(err) {
6687 return console.log("Failed to load images", err);
6688 });
6689 }
6690 };
6691 };
6692
6693 //#endregion
6694 //#region modules/ai/assets/js/editor/pages/form-media/views/generate/hooks/use-suggested-images.js
6695 init_slicedToArray();
6696 var shuffleImages = function shuffleImages(images) {
6697 return images.map(function(image) {
6698 return [Math.random(), image];
6699 }).sort(function(_ref, _ref2) {
6700 return _slicedToArray(_ref, 1)[0] - _slicedToArray(_ref2, 1)[0];
6701 }).map(function(_ref5) {
6702 return _slicedToArray(_ref5, 2)[1];
6703 });
6704 };
6705 var checkImageTypeIgnoreStyle = function checkImageTypeIgnoreStyle(imageType, selectedType) {
6706 return _slicedToArray(imageType.split("/"), 1)[0] === selectedType;
6707 };
6708 var useSuggestedImages = function useSuggestedImages(_ref7) {
6709 var selectedType = _ref7.selectedType;
6710 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
6711 var isLoading = _useState2[0];
6712 var setIsLoading = _useState2[1];
6713 var _useState4 = _slicedToArray((0, react.useState)({ images: [] }), 2);
6714 var data = _useState4[0];
6715 var setImagesState = _useState4[1];
6716 var _useImagesPreload = useImagesPreload();
6717 var ready = _useImagesPreload.ready;
6718 var preloadImages = _useImagesPreload.preloadImages;
6719 var imagesData = (0, react.useMemo)(function() {
6720 var shuffledImages = shuffleImages(data.images);
6721 if (!selectedType) return shuffledImages;
6722 var categoryImages = shuffledImages.filter(function(_ref8) {
6723 var imageType = _ref8.imageType;
6724 return checkImageTypeIgnoreStyle(imageType, selectedType);
6725 });
6726 return categoryImages.length ? categoryImages : shuffledImages;
6727 }, [selectedType, data]);
6728 var fetchImages = function fetchImages() {
6729 setIsLoading(true);
6730 fetch("https://my.elementor.com/ai/images-prompt-gallery/ai-gallery.json").then(function(response) {
6731 return response.json();
6732 }).then(function(json) {
6733 return setImagesState(json);
6734 }).catch(function(e) {
6735 return console.log(e.message);
6736 }).finally(function() {
6737 return setIsLoading(false);
6738 });
6739 };
6740 (0, react.useEffect)(function() {
6741 if (0 === (data === null || data === void 0 ? void 0 : data.images.length)) {
6742 fetchImages();
6743 return;
6744 }
6745 preloadImages(data.images.map(function(_ref9) {
6746 return _ref9.thumbnailUrl;
6747 }));
6748 }, [data]);
6749 return {
6750 imagesData,
6751 isLoading: !ready || isLoading
6752 };
6753 };
6754
6755 //#endregion
6756 //#region modules/ai/assets/js/editor/pages/form-media/utils/index.js
6757 init_asyncToGenerator();
6758 init_defineProperty();
6759 init_slicedToArray();
6760 function ownKeys$16(e, r) {
6761 var t = Object.keys(e);
6762 if (Object.getOwnPropertySymbols) {
6763 var o = Object.getOwnPropertySymbols(e);
6764 r && (o = o.filter(function(r) {
6765 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6766 })), t.push.apply(t, o);
6767 }
6768 return t;
6769 }
6770 __name(ownKeys$16, "ownKeys");
6771 function _objectSpread$16(e) {
6772 for (var r = 1; r < arguments.length; r++) {
6773 var t = null != arguments[r] ? arguments[r] : {};
6774 r % 2 ? ownKeys$16(Object(t), !0).forEach(function(r) {
6775 _defineProperty(e, r, t[r]);
6776 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$16(Object(t)).forEach(function(r) {
6777 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6778 });
6779 }
6780 return e;
6781 }
6782 __name(_objectSpread$16, "_objectSpread");
6783 var getAspectRatioSizes = function getAspectRatioSizes(width, height) {
6784 var aspectRatios = Object.keys(IMAGE_ASPECT_RATIO);
6785 var targetRatio = width / height;
6786 var closestRatio = aspectRatios[0];
6787 var minDiff = Infinity;
6788 aspectRatios.forEach(function(ratio) {
6789 var _ratio$split$map2 = _slicedToArray(ratio.split(":").map(Number), 2);
6790 var w = _ratio$split$map2[0];
6791 var h = _ratio$split$map2[1];
6792 var diff = Math.abs(targetRatio - w / h);
6793 if (diff < minDiff) {
6794 minDiff = diff;
6795 closestRatio = ratio;
6796 }
6797 });
6798 return _objectSpread$16({ ratio: closestRatio }, IMAGE_ASPECT_RATIO[closestRatio]);
6799 };
6800 var fetchImageAsBase64 = /*#__PURE__*/ function() {
6801 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(url) {
6802 var response;
6803 var blob;
6804 var reader;
6805 var _t;
6806 return import_regenerator$2.default.wrap(function(_context) {
6807 while (1) switch (_context.prev = _context.next) {
6808 case 0:
6809 _context.prev = 0;
6810 _context.next = 1;
6811 return fetch(url);
6812 case 1:
6813 response = _context.sent;
6814 _context.next = 2;
6815 return response.blob();
6816 case 2:
6817 blob = _context.sent;
6818 reader = new FileReader();
6819 return _context.abrupt("return", new Promise(function(resolve, reject) {
6820 reader.onloadend = function() {
6821 resolve(reader.result);
6822 };
6823 reader.onerror = reject;
6824 reader.readAsDataURL(blob);
6825 }));
6826 case 3:
6827 _context.prev = 3;
6828 _t = _context["catch"](0);
6829 throw _t;
6830 case 4:
6831 case "end": return _context.stop();
6832 }
6833 }, _callee, null, [[0, 3]]);
6834 }));
6835 return function fetchImageAsBase64(_x) {
6836 return _ref.apply(this, arguments);
6837 };
6838 }();
6839
6840 //#endregion
6841 //#region modules/ai/assets/js/editor/pages/form-media/context/edit-image-context.js
6842 init_slicedToArray();
6843 init_defineProperty();
6844 function ownKeys$15(e, r) {
6845 var t = Object.keys(e);
6846 if (Object.getOwnPropertySymbols) {
6847 var o = Object.getOwnPropertySymbols(e);
6848 r && (o = o.filter(function(r) {
6849 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6850 })), t.push.apply(t, o);
6851 }
6852 return t;
6853 }
6854 __name(ownKeys$15, "ownKeys");
6855 function _objectSpread$15(e) {
6856 for (var r = 1; r < arguments.length; r++) {
6857 var t = null != arguments[r] ? arguments[r] : {};
6858 r % 2 ? ownKeys$15(Object(t), !0).forEach(function(r) {
6859 _defineProperty(e, r, t[r]);
6860 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$15(Object(t)).forEach(function(r) {
6861 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6862 });
6863 }
6864 return e;
6865 }
6866 __name(_objectSpread$15, "_objectSpread");
6867 var EditImageContext = (0, react.createContext)({});
6868 var SET_STATE = "SET_STATE";
6869 var SET_ASPECT_RATIO = "SET_ASPECT_RATIO";
6870 var SET_LOADING = "SET_LOADING";
6871 var RESET = "RESET";
6872 var initialValue = {
6873 id: "",
6874 url: "",
6875 isLoading: false,
6876 aspectRatio: "1:1"
6877 };
6878 var reducer$1 = function reducer(state, _ref) {
6879 var type = _ref.type;
6880 var payload = _ref.payload;
6881 switch (type) {
6882 case SET_STATE: return _objectSpread$15(_objectSpread$15({}, state), payload);
6883 case SET_ASPECT_RATIO: return _objectSpread$15(_objectSpread$15({}, state), {}, { aspectRatio: payload });
6884 case SET_LOADING: return _objectSpread$15(_objectSpread$15({}, state), {}, { isLoading: payload });
6885 case RESET: return initialValue;
6886 default: throw Error("Unknown action.");
6887 }
6888 };
6889 var EditImageProvider = function EditImageProvider(_ref2) {
6890 var children = _ref2.children;
6891 var imageData = _ref2.imageData;
6892 var _useReducer2 = _slicedToArray((0, react.useReducer)(reducer$1, _objectSpread$15(_objectSpread$15({}, initialValue), imageData)), 2);
6893 var state = _useReducer2[0];
6894 var dispatch = _useReducer2[1];
6895 return /*#__PURE__*/ react.default.createElement(EditImageContext.Provider, { value: {
6896 state,
6897 dispatch
6898 } }, children);
6899 };
6900 EditImageProvider.propTypes = {
6901 children: import_prop_types$7.default.node,
6902 imageData: import_prop_types$7.default.object
6903 };
6904 var useEditImage = function useEditImage() {
6905 var _useContext = (0, react.useContext)(EditImageContext);
6906 var state = _useContext.state;
6907 var dispatch = _useContext.dispatch;
6908 var id = state.id;
6909 var url = state.url;
6910 var aspectRatio = state.aspectRatio;
6911 var isLoading = state.isLoading;
6912 var _useImageSize = useImageSize(aspectRatio);
6913 var width = _useImageSize.width;
6914 var height = _useImageSize.height;
6915 var setEditImage = function setEditImage(payload) {
6916 return dispatch({
6917 type: SET_STATE,
6918 payload
6919 });
6920 };
6921 var setAspectRatio = function setAspectRatio(payload) {
6922 return dispatch({
6923 type: SET_ASPECT_RATIO,
6924 payload
6925 });
6926 };
6927 var reset = function reset() {
6928 return dispatch({ type: RESET });
6929 };
6930 (0, react.useEffect)(function() {
6931 if (!id) return;
6932 dispatch({
6933 type: SET_LOADING,
6934 payload: true
6935 });
6936 var img = new Image();
6937 img.src = url;
6938 img.onload = function() {
6939 var ratio = getAspectRatioSizes(img.width, img.height).ratio;
6940 dispatch({
6941 type: SET_STATE,
6942 payload: {
6943 aspectRatio: ratio,
6944 isLoading: false
6945 }
6946 });
6947 };
6948 }, [id]);
6949 return {
6950 editImage: state,
6951 isLoading,
6952 aspectRatio,
6953 width,
6954 height,
6955 setEditImage,
6956 setAspectRatio,
6957 reset
6958 };
6959 };
6960
6961 //#endregion
6962 //#region modules/ai/assets/js/editor/pages/form-media/hooks/use-image-upload.js
6963 init_slicedToArray();
6964 init_api();
6965 var useImageUpload = function useImageUpload() {
6966 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
6967 var isUploading = _useState2[0];
6968 var setIsUploading = _useState2[1];
6969 var _useState4 = _slicedToArray((0, react.useState)(""), 2);
6970 var uploadError = _useState4[0];
6971 var setUploadError = _useState4[1];
6972 var _useState6 = _slicedToArray((0, react.useState)({}), 2);
6973 var attachmentData = _useState6[0];
6974 var setAttachmentData = _useState6[1];
6975 return {
6976 upload: function upload(_ref) {
6977 var image = _ref.image;
6978 var prompt = _ref.prompt;
6979 return new Promise(function(resolve, reject) {
6980 setUploadError("");
6981 setAttachmentData({});
6982 setIsUploading(true);
6983 uploadImage({
6984 image,
6985 prompt
6986 }).then(function(result) {
6987 setAttachmentData(result);
6988 resolve(result);
6989 }).catch(function(err) {
6990 var error = (err === null || err === void 0 ? void 0 : err.responseText) || err;
6991 setUploadError(error);
6992 reject(error);
6993 }).finally(function() {
6994 return setIsUploading(false);
6995 });
6996 });
6997 },
6998 resetUpload: function resetUpload() {
6999 setUploadError("");
7000 setAttachmentData({});
7001 setIsUploading(false);
7002 },
7003 isUploading,
7004 uploadError,
7005 attachmentData
7006 };
7007 };
7008
7009 //#endregion
7010 //#region modules/ai/assets/js/editor/pages/form-media/context/global-actions-context.js
7011 var GlobalActionsContext = (0, react.createContext)({});
7012 var GlobalActionsProvider = function GlobalActionsProvider(_ref) {
7013 var actions = _ref.actions;
7014 var children = _ref.children;
7015 return /*#__PURE__*/ react.default.createElement(GlobalActionsContext.Provider, { value: actions }, children);
7016 };
7017 GlobalActionsProvider.propTypes = {
7018 actions: import_prop_types$7.default.object,
7019 children: import_prop_types$7.default.node
7020 };
7021 var useGlobalActions = function useGlobalActions() {
7022 return (0, react.useContext)(GlobalActionsContext);
7023 };
7024
7025 //#endregion
7026 //#region node_modules/@babel/runtime/helpers/esm/classCallCheck.js
7027 function _classCallCheck(a, n) {
7028 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
7029 }
7030
7031 //#endregion
7032 //#region node_modules/@babel/runtime/helpers/esm/createClass.js
7033 init_toPropertyKey();
7034 function _defineProperties(e, r) {
7035 for (var t = 0; t < r.length; t++) {
7036 var o = r[t];
7037 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
7038 }
7039 }
7040 function _createClass(e, r, t) {
7041 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e;
7042 }
7043
7044 //#endregion
7045 //#region assets/dev/js/editor/utils/files-upload-handler.js
7046 var FilesUploadHandler = /*#__PURE__*/ function() {
7047 function FilesUploadHandler() {
7048 _classCallCheck(this, FilesUploadHandler);
7049 }
7050 return _createClass(FilesUploadHandler, null, [
7051 {
7052 key: "isUploadEnabled",
7053 value: function isUploadEnabled(mediaType) {
7054 if (!["svg", "application/json"].includes(mediaType)) return true;
7055 return elementorCommon.config.filesUpload.unfilteredFiles;
7056 }
7057 },
7058 {
7059 key: "setUploadTypeCaller",
7060 value: function setUploadTypeCaller(frame) {
7061 frame.uploader.uploader.param("uploadTypeCaller", "elementor-wp-media-upload");
7062 }
7063 },
7064 {
7065 key: "getUnfilteredFilesNonAdminDialog",
7066 value: function getUnfilteredFilesNonAdminDialog() {
7067 return elementorCommon.dialogsManager.createWidget("alert", {
7068 id: "e-unfiltered-files-disabled-dialog",
7069 headerMessage: (0, _wordpress_i18n.__)("Sorry, you can't upload that file yet", "elementor"),
7070 message: (0, _wordpress_i18n.__)("This is because JSON files may pose a security risk.", "elementor") + "<br><br>" + (0, _wordpress_i18n.__)("To upload them anyway, ask the site administrator to enable unfiltered file uploads.", "elementor"),
7071 strings: { confirm: (0, _wordpress_i18n.__)("Got it", "elementor") }
7072 });
7073 }
7074 },
7075 {
7076 key: "getUnfilteredFilesNotEnabledDialog",
7077 value: function getUnfilteredFilesNotEnabledDialog(callback) {
7078 var elementorInstance = window.elementorAdmin || window.elementor;
7079 if (!elementorInstance.config.user.is_administrator) return this.getUnfilteredFilesNonAdminDialog();
7080 return elementorInstance.helpers.getSimpleDialog("e-enable-unfiltered-files-dialog", (0, _wordpress_i18n.__)("Enable Unfiltered File Uploads", "elementor"), (0, _wordpress_i18n.__)("Before you enable unfiltered files upload, note that such files include a security risk. Elementor does run a process to remove possible malicious code, but there is still risk involved when using such files.", "elementor"), (0, _wordpress_i18n.__)("Enable", "elementor"), function onConfirm() {
7081 elementorCommon.ajax.addRequest("enable_unfiltered_files_upload", {}, true);
7082 elementorCommon.config.filesUpload.unfilteredFiles = true;
7083 callback();
7084 });
7085 }
7086 },
7087 {
7088 key: "getUnfilteredFilesNotEnabledImportTemplateDialog",
7089 value: function getUnfilteredFilesNotEnabledImportTemplateDialog(callback) {
7090 if (!(window.elementorAdmin || window.elementor).config.user.is_administrator) return this.getUnfilteredFilesNonAdminDialog();
7091 return elementorCommon.dialogsManager.createWidget("confirm", {
7092 id: "e-enable-unfiltered-files-dialog-import-template",
7093 headerMessage: (0, _wordpress_i18n.__)("Enable Unfiltered File Uploads", "elementor"),
7094 message: (0, _wordpress_i18n.__)("Before you enable unfiltered files upload, note that such files include a security risk. Elementor does run a process to remove possible malicious code, but there is still risk involved when using such files.", "elementor") + "<br /><br />" + (0, _wordpress_i18n.__)("If you do not enable uploading unfiltered files, any SVG or JSON (including lottie) files used in the uploaded template will not be imported.", "elementor"),
7095 position: {
7096 my: "center center",
7097 at: "center center"
7098 },
7099 strings: {
7100 confirm: (0, _wordpress_i18n.__)("Enable and Import", "elementor"),
7101 cancel: (0, _wordpress_i18n.__)("Import Without Enabling", "elementor")
7102 },
7103 onConfirm: function onConfirm() {
7104 elementorCommon.ajax.addRequest("enable_unfiltered_files_upload", { success: function success() {
7105 elementorCommon.config.filesUpload.unfilteredFiles = true;
7106 callback();
7107 } }, true);
7108 },
7109 onCancel: function onCancel() {
7110 return callback();
7111 }
7112 });
7113 }
7114 }
7115 ]);
7116 }();
7117
7118 //#endregion
7119 //#region modules/ai/assets/js/editor/pages/form-media/hooks/use-image-actions.js
7120 init_objectWithoutProperties();
7121 init_asyncToGenerator();
7122 init_defineProperty();
7123 var _excluded$14 = ["image"];
7124 function ownKeys$14(e, r) {
7125 var t = Object.keys(e);
7126 if (Object.getOwnPropertySymbols) {
7127 var o = Object.getOwnPropertySymbols(e);
7128 r && (o = o.filter(function(r) {
7129 return Object.getOwnPropertyDescriptor(e, r).enumerable;
7130 })), t.push.apply(t, o);
7131 }
7132 return t;
7133 }
7134 __name(ownKeys$14, "ownKeys");
7135 function _objectSpread$14(e) {
7136 for (var r = 1; r < arguments.length; r++) {
7137 var t = null != arguments[r] ? arguments[r] : {};
7138 r % 2 ? ownKeys$14(Object(t), !0).forEach(function(r) {
7139 _defineProperty(e, r, t[r]);
7140 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$14(Object(t)).forEach(function(r) {
7141 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
7142 });
7143 }
7144 return e;
7145 }
7146 __name(_objectSpread$14, "_objectSpread");
7147 var normalizeImageData = function normalizeImageData(imageToUpload) {
7148 if (!(imageToUpload !== null && imageToUpload !== void 0 && imageToUpload.imageUrl)) return imageToUpload;
7149 return _objectSpread$14(_objectSpread$14({}, imageToUpload), {}, {
7150 image_url: imageToUpload.imageUrl,
7151 use_gallery_image: true
7152 });
7153 };
7154 var useImageActions = function useImageActions() {
7155 var _useEditImage = useEditImage();
7156 var editImage = _useEditImage.editImage;
7157 var setEditImage = _useEditImage.setEditImage;
7158 var _useGlobalActions = useGlobalActions();
7159 var setControlValue = _useGlobalActions.setControlValue;
7160 var saveAndClose = _useGlobalActions.saveAndClose;
7161 var _useImageUpload = useImageUpload();
7162 var attachmentData = _useImageUpload.attachmentData;
7163 var isUploading = _useImageUpload.isUploading;
7164 var uploadError = _useImageUpload.uploadError;
7165 var uploadImage = _useImageUpload.upload;
7166 var resetUpload = _useImageUpload.resetUpload;
7167 var ensureSVGUploading = function ensureSVGUploading(imageUrl) {
7168 if (!imageUrl) return true;
7169 var imageExtension = new URL(imageUrl).pathname.split(".").pop();
7170 var isUploadAllowed = window._wpPluploadSettings.defaults.filters.mime_types[0].extensions.split(",").includes(imageExtension) || elementorCommon.config.filesUpload.unfilteredFiles;
7171 if (!isUploadAllowed) {
7172 var dialog = FilesUploadHandler.getUnfilteredFilesNotEnabledDialog(function() {});
7173 dialog.getElements("widget").css("z-index", "170001");
7174 dialog.show();
7175 }
7176 return isUploadAllowed;
7177 };
7178 var upload = function upload(imageToUpload, prompt) {
7179 if (!ensureSVGUploading(imageToUpload.image_url)) return Promise.reject(/* @__PURE__ */ new Error("SVG Uploading is not allowed"));
7180 return uploadImage({
7181 image: normalizeImageData(imageToUpload),
7182 prompt: prompt || imageToUpload.prompt
7183 });
7184 };
7185 var getFinalImage = /*#__PURE__*/ function() {
7186 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(imageToUpload, prompt) {
7187 var isImageAlreadyUploaded;
7188 var _result;
7189 var result;
7190 return import_regenerator$2.default.wrap(function(_context) {
7191 while (1) switch (_context.prev = _context.next) {
7192 case 0:
7193 isImageAlreadyUploaded = editImage.url === imageToUpload.url;
7194 if (!isImageAlreadyUploaded) {
7195 _context.next = 1;
7196 break;
7197 }
7198 editImage.image, _result = _objectWithoutProperties(editImage, _excluded$14);
7199 return _context.abrupt("return", _result);
7200 case 1:
7201 _context.next = 2;
7202 return upload(imageToUpload, prompt);
7203 case 2:
7204 result = _context.sent;
7205 return _context.abrupt("return", result === null || result === void 0 ? void 0 : result.image);
7206 case 3:
7207 case "end": return _context.stop();
7208 }
7209 }, _callee);
7210 }));
7211 return function getFinalImage(_x, _x2) {
7212 return _ref.apply(this, arguments);
7213 };
7214 }();
7215 return {
7216 use: /* @__PURE__ */ function() {
7217 var _ref3 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee3(imageToUpload, prompt) {
7218 var result;
7219 return import_regenerator$2.default.wrap(function(_context3) {
7220 while (1) switch (_context3.prev = _context3.next) {
7221 case 0:
7222 _context3.next = 1;
7223 return getFinalImage(imageToUpload, prompt);
7224 case 1:
7225 result = _context3.sent;
7226 setControlValue(result);
7227 saveAndClose();
7228 case 2:
7229 case "end": return _context3.stop();
7230 }
7231 }, _callee3);
7232 }));
7233 return function use(_x5, _x6) {
7234 return _ref3.apply(this, arguments);
7235 };
7236 }(),
7237 edit: /* @__PURE__ */ function() {
7238 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee2(imageToUpload, prompt) {
7239 var result;
7240 return import_regenerator$2.default.wrap(function(_context2) {
7241 while (1) switch (_context2.prev = _context2.next) {
7242 case 0:
7243 _context2.next = 1;
7244 return upload(imageToUpload, prompt);
7245 case 1:
7246 result = _context2.sent;
7247 setEditImage(result.image);
7248 case 2:
7249 case "end": return _context2.stop();
7250 }
7251 }, _callee2);
7252 }));
7253 return function edit(_x3, _x4) {
7254 return _ref2.apply(this, arguments);
7255 };
7256 }(),
7257 reset: resetUpload,
7258 error: uploadError,
7259 data: attachmentData,
7260 isLoading: isUploading,
7261 useMultipleImages: /* @__PURE__ */ function() {
7262 var _ref4 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee6(imagesToUpload) {
7263 var results;
7264 return import_regenerator$2.default.wrap(function(_context6) {
7265 while (1) switch (_context6.prev = _context6.next) {
7266 case 0:
7267 _context6.next = 1;
7268 return Promise.all(imagesToUpload.map(/*#__PURE__*/ function() {
7269 var _ref5 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee4(img) {
7270 return import_regenerator$2.default.wrap(function(_context4) {
7271 while (1) switch (_context4.prev = _context4.next) {
7272 case 0:
7273 _context4.next = 1;
7274 return getFinalImage(img, null).catch(function(_) {
7275 return null;
7276 });
7277 case 1: return _context4.abrupt("return", _context4.sent);
7278 case 2:
7279 case "end": return _context4.stop();
7280 }
7281 }, _callee4);
7282 }));
7283 return function(_x8) {
7284 return _ref5.apply(this, arguments);
7285 };
7286 }()));
7287 case 1:
7288 results = _context6.sent;
7289 _context6.next = 2;
7290 return Promise.all(results.filter(function(result) {
7291 return result;
7292 }).map(/*#__PURE__*/ function() {
7293 var _ref6 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee5(result) {
7294 return import_regenerator$2.default.wrap(function(_context5) {
7295 while (1) switch (_context5.prev = _context5.next) {
7296 case 0:
7297 _context5.next = 1;
7298 return setControlValue(result);
7299 case 1: return _context5.abrupt("return", _context5.sent);
7300 case 2:
7301 case "end": return _context5.stop();
7302 }
7303 }, _callee5);
7304 }));
7305 return function(_x9) {
7306 return _ref6.apply(this, arguments);
7307 };
7308 }()));
7309 case 2:
7310 case "end": return _context6.stop();
7311 }
7312 }, _callee6);
7313 }));
7314 return function useMultipleImages(_x7) {
7315 return _ref4.apply(this, arguments);
7316 };
7317 }()
7318 };
7319 };
7320
7321 //#endregion
7322 //#region modules/ai/assets/js/editor/pages/form-media/views/variations/components/images-placeholder.js
7323 var ImagesPlaceholder = function ImagesPlaceholder() {
7324 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7325 sx: { overflowY: "scroll" },
7326 flexGrow: 1
7327 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7328 display: "grid",
7329 gridTemplateColumns: "repeat(2, 1fr)",
7330 gap: 3
7331 }, Array(4).fill(true).map(function(_, index) {
7332 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7333 key: "placeholder-".concat(index),
7334 display: "flex",
7335 justifyContent: "center",
7336 alignItems: "center",
7337 sx: {
7338 bgcolor: "action.selected",
7339 height: 336
7340 }
7341 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, {
7342 color: "secondary",
7343 sx: { fontSize: 36 }
7344 }));
7345 })));
7346 };
7347 ImagesPlaceholder.propTypes = {};
7348
7349 //#endregion
7350 //#region modules/ai/assets/js/editor/pages/form-media/views/generate/index.js
7351 init_defineProperty();
7352 init_slicedToArray();
7353 init_prompt_history_action_context();
7354 init_prompt_library_link();
7355 init_requests_ids();
7356 function ownKeys$13(e, r) {
7357 var t = Object.keys(e);
7358 if (Object.getOwnPropertySymbols) {
7359 var o = Object.getOwnPropertySymbols(e);
7360 r && (o = o.filter(function(r) {
7361 return Object.getOwnPropertyDescriptor(e, r).enumerable;
7362 })), t.push.apply(t, o);
7363 }
7364 return t;
7365 }
7366 __name(ownKeys$13, "ownKeys");
7367 function _objectSpread$13(e) {
7368 for (var r = 1; r < arguments.length; r++) {
7369 var t = null != arguments[r] ? arguments[r] : {};
7370 r % 2 ? ownKeys$13(Object(t), !0).forEach(function(r) {
7371 _defineProperty(e, r, t[r]);
7372 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$13(Object(t)).forEach(function(r) {
7373 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
7374 });
7375 }
7376 return e;
7377 }
7378 __name(_objectSpread$13, "_objectSpread");
7379 var getPromptPlaceholder = function getPromptPlaceholder(images) {
7380 if (!(images !== null && images !== void 0 && images.length)) return (0, _wordpress_i18n.__)("describe your image", "elementor");
7381 return images[Math.floor(Math.random() * images.length)].prompt;
7382 };
7383 var Generate = function Generate(_ref) {
7384 var textToImageHook = _ref.textToImageHook;
7385 var _ref$predefinedPrompt = _ref.predefinedPrompt;
7386 var predefinedPrompt = _ref$predefinedPrompt === void 0 ? "" : _ref$predefinedPrompt;
7387 var _ref$initialSettings = _ref.initialSettings;
7388 var initialSettings = _ref$initialSettings === void 0 ? {} : _ref$initialSettings;
7389 var _useState2 = _slicedToArray((0, react.useState)(predefinedPrompt), 2);
7390 var prompt = _useState2[0];
7391 var setPrompt = _useState2[1];
7392 var setGenerate = useRequestIds().setGenerate;
7393 var initialImageType = useGlobalSettings().initialImageType;
7394 var _usePromptSettings = usePromptSettings(_objectSpread$13({ type: initialImageType }, initialSettings));
7395 var settings = _usePromptSettings.settings;
7396 var updateSettings = _usePromptSettings.updateSettings;
7397 var resetSettings = _usePromptSettings.resetSettings;
7398 var _useSuggestedImages = useSuggestedImages({ selectedType: settings[IMAGE_TYPE] });
7399 var suggestedImages = _useSuggestedImages.imagesData;
7400 var isPreloading = _useSuggestedImages.isLoading;
7401 var promptPlaceholder = getPromptPlaceholder(suggestedImages);
7402 var _textToImageHook = textToImageHook({});
7403 var generatedImages = _textToImageHook.data;
7404 var setResult = _textToImageHook.setResult;
7405 var send = _textToImageHook.send;
7406 var isGenerating = _textToImageHook.isLoading;
7407 var error = _textToImageHook.error;
7408 var reset = _textToImageHook.reset;
7409 var _useImageActions = useImageActions();
7410 var use = _useImageActions.use;
7411 var edit = _useImageActions.edit;
7412 var isUploading = _useImageActions.isLoading;
7413 var isLoading = isPreloading || isGenerating || isUploading;
7414 var generateAspectRatio = (0, react.useMemo)(function() {
7415 return settings[IMAGE_RATIO];
7416 }, [generatedImages === null || generatedImages === void 0 ? void 0 : generatedImages.result]);
7417 var handleSubmit = function handleSubmit(event) {
7418 event.preventDefault();
7419 setGenerate();
7420 if (!settings[IMAGE_STYLE]) settings[IMAGE_STYLE] = "general";
7421 send({
7422 prompt,
7423 settings
7424 });
7425 };
7426 var handleCopyPrompt = function handleCopyPrompt(_ref2) {
7427 var selectedPrompt = _ref2.prompt;
7428 var imageType = _ref2.imageType;
7429 setPrompt(selectedPrompt);
7430 var _imageType$split2 = _slicedToArray(imageType.split("/"), 2);
7431 var type = _imageType$split2[0];
7432 var style = _imageType$split2[1];
7433 updateSettings(_defineProperty(_defineProperty({}, IMAGE_TYPE, type), IMAGE_STYLE, style));
7434 };
7435 useSubscribeOnPromptHistoryAction([{
7436 type: ACTION_TYPES.RESTORE,
7437 handler: function handler(action) {
7438 var _action$data;
7439 var _action$data2;
7440 var _action$data3;
7441 var _action$data4;
7442 handleCopyPrompt({
7443 prompt: (_action$data = action.data) === null || _action$data === void 0 ? void 0 : _action$data.prompt,
7444 imageType: ((_action$data2 = action.data) === null || _action$data2 === void 0 ? void 0 : _action$data2.imageType) || ""
7445 });
7446 updateSettings(_defineProperty({}, IMAGE_RATIO, (_action$data3 = action.data) === null || _action$data3 === void 0 ? void 0 : _action$data3.ratio));
7447 setResult((_action$data4 = action.data) === null || _action$data4 === void 0 ? void 0 : _action$data4.images, action.id);
7448 }
7449 }]);
7450 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
7451 primary: (0, _wordpress_i18n.__)("Imagine anything create everything", "elementor"),
7452 secondary: (0, _wordpress_i18n.__)("Generate images by selecting the desired type and style, and entering a prompt.", "elementor")
7453 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
7454 error,
7455 onRetry: handleSubmit
7456 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(PromptField, {
7457 "data-testid": "e-image-prompt",
7458 value: prompt,
7459 disabled: isLoading,
7460 placeholder: promptPlaceholder,
7461 onChange: setPrompt
7462 }), /*#__PURE__*/ react.default.createElement(ImageTypeSelect, {
7463 disabled: isLoading,
7464 value: settings[IMAGE_TYPE],
7465 onChange: function onChange(event) {
7466 return updateSettings(_defineProperty({}, IMAGE_TYPE, event.target.value));
7467 }
7468 }), /*#__PURE__*/ react.default.createElement(ImageStyleSelect, {
7469 type: settings[IMAGE_TYPE],
7470 value: settings[IMAGE_STYLE],
7471 disabled: isLoading || !settings[IMAGE_TYPE] || false,
7472 onChange: function onChange(event) {
7473 return updateSettings(_defineProperty({}, IMAGE_STYLE, event.target.value));
7474 }
7475 }), /*#__PURE__*/ react.default.createElement(ImageRatioSelect, {
7476 disabled: isLoading,
7477 value: settings[IMAGE_RATIO],
7478 onChange: function onChange(event) {
7479 return updateSettings(_defineProperty({}, IMAGE_RATIO, event.target.value));
7480 }
7481 }), generatedImages !== null && generatedImages !== void 0 && generatedImages.result ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
7482 gap: 2,
7483 sx: { my: 2.5 }
7484 }, /*#__PURE__*/ react.default.createElement(GenerateAgainSubmit, { disabled: isLoading || "" === prompt }), /*#__PURE__*/ react.default.createElement(NewPromptButton, {
7485 disabled: isLoading,
7486 onClick: function onClick() {
7487 resetSettings();
7488 setPrompt("");
7489 reset();
7490 }
7491 })) : /*#__PURE__*/ react.default.createElement(GenerateImagesSubmit, { disabled: isLoading || "" === prompt }))), /*#__PURE__*/ react.default.createElement(View.Content, {
7492 isLoading: isPreloading || isUploading,
7493 isGenerating
7494 }, generatedImages !== null && generatedImages !== void 0 && generatedImages.result ? /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
7495 images: generatedImages === null || generatedImages === void 0 ? void 0 : generatedImages.result,
7496 aspectRatio: generateAspectRatio,
7497 onUseImage: use,
7498 onEditImage: edit
7499 }) : /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, predefinedPrompt ? /*#__PURE__*/ react.default.createElement(ImagesPlaceholder, null) : /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(View.ContentHeading, { primary: (0, _wordpress_i18n.__)("Spark your imagination with images generated by our community", "elementor") }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, { sx: { mb: 3 } }, /*#__PURE__*/ react.default.createElement(PromptLibraryLink, { libraryLink: "https://go.elementor.com/ai-prompt-library-image/" })), /*#__PURE__*/ react.default.createElement(Gallery, { cols: 3 }, suggestedImages === null || suggestedImages === void 0 ? void 0 : suggestedImages.map(function(suggestedPrompt) {
7500 return /*#__PURE__*/ react.default.createElement(Gallery.Image, {
7501 variant: "thumbnail",
7502 key: suggestedPrompt.prompt,
7503 alt: suggestedPrompt.prompt,
7504 text: suggestedPrompt.prompt,
7505 src: suggestedPrompt.thumbnailUrl
7506 }, /*#__PURE__*/ react.default.createElement(ImageActions, null, /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, {
7507 onClick: function onClick() {
7508 return use(suggestedPrompt);
7509 },
7510 fullWidth: true
7511 }), /*#__PURE__*/ react.default.createElement(ImageActions.CopyIcon, { onClick: function onClick() {
7512 return handleCopyPrompt(suggestedPrompt);
7513 } }), /*#__PURE__*/ react.default.createElement(ImageActions.EditIcon, { onClick: function onClick() {
7514 return edit(suggestedPrompt);
7515 } })));
7516 }))))));
7517 };
7518 Generate.propTypes = {
7519 predefinedPrompt: import_prop_types$7.default.string,
7520 textToImageHook: import_prop_types$7.default.func,
7521 initialSettings: import_prop_types$7.default.object
7522 };
7523
7524 //#endregion
7525 //#region modules/ai/assets/js/editor/icons/expand-icon.js
7526 init_extends();
7527 var ExpandIcon$1 = react.default.forwardRef(function(props, ref) {
7528 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7529 fillRule: "evenodd",
7530 clipRule: "evenodd",
7531 d: "M16 3.25C15.5858 3.25 15.25 3.58579 15.25 4C15.25 4.41421 15.5858 4.75 16 4.75H18.1893L13.4697 9.46967C13.1768 9.76256 13.1768 10.2374 13.4697 10.5303C13.7626 10.8232 14.2374 10.8232 14.5303 10.5303L19.25 5.81066V8C19.25 8.41421 19.5858 8.75 20 8.75C20.4142 8.75 20.75 8.41421 20.75 8V4C20.75 3.80806 20.6768 3.61612 20.5303 3.46967C20.4584 3.39776 20.3755 3.34351 20.2871 3.30691C20.1987 3.27024 20.1017 3.25 20 3.25H16ZM4 15.25C4.41421 15.25 4.75 15.5858 4.75 16V18.1893L9.46967 13.4697C9.76256 13.1768 10.2374 13.1768 10.5303 13.4697C10.8232 13.7626 10.8232 14.2374 10.5303 14.5303L5.81066 19.25H8C8.41421 19.25 8.75 19.5858 8.75 20C8.75 20.4142 8.41421 20.75 8 20.75H4C3.80806 20.75 3.61612 20.6768 3.46967 20.5303C3.39776 20.4584 3.34351 20.3755 3.30691 20.2871C3.27024 20.1987 3.25 20.1017 3.25 20V16C3.25 15.5858 3.58579 15.25 4 15.25ZM20.75 16V20C20.75 20.1017 20.7298 20.1987 20.6931 20.2871C20.6565 20.3755 20.6022 20.4584 20.5303 20.5303C20.4584 20.6022 20.3755 20.6565 20.2871 20.6931C20.2099 20.7251 20.1262 20.7446 20.0386 20.749C20.0258 20.7497 20.0129 20.75 20 20.75H16C15.5858 20.75 15.25 20.4142 15.25 20C15.25 19.5858 15.5858 19.25 16 19.25H18.1893L13.4697 14.5303C13.1768 14.2374 13.1768 13.7626 13.4697 13.4697C13.7626 13.1768 14.2374 13.1768 14.5303 13.4697L19.25 18.1893V16C19.25 15.5858 19.5858 15.25 20 15.25C20.4142 15.25 20.75 15.5858 20.75 16ZM3.71291 3.30691C3.80134 3.27024 3.89831 3.25 4 3.25H8C8.41421 3.25 8.75 3.58579 8.75 4C8.75 4.41421 8.41421 4.75 8 4.75H5.81066L10.5303 9.46967C10.8232 9.76256 10.8232 10.2374 10.5303 10.5303C10.2374 10.8232 9.76256 10.8232 9.46967 10.5303L4.75 5.81066V8C4.75 8.41421 4.41421 8.75 4 8.75C3.58579 8.75 3.25 8.41421 3.25 8V4C3.25 3.7937 3.33329 3.60686 3.46808 3.47126C3.46861 3.47073 3.46914 3.4702 3.46967 3.46967C3.4702 3.46914 3.47073 3.46861 3.47126 3.46808C3.5428 3.39696 3.62511 3.34324 3.71291 3.30691Z"
7532 }));
7533 });
7534
7535 //#endregion
7536 //#region modules/ai/assets/js/editor/icons/brush-icon.js
7537 init_extends();
7538 var BrushIcon = react.default.forwardRef(function(props, ref) {
7539 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7540 fillRule: "evenodd",
7541 clipRule: "evenodd",
7542 d: "M20.8815 2.25919C20.9203 2.25301 20.9599 2.24983 21 2.24988C21.0827 2.24978 21.1629 2.26335 21.2384 2.2887C21.367 2.33162 21.4784 2.40776 21.5642 2.5058C21.6895 2.64891 21.76 2.83868 21.749 3.03992C21.7477 3.06492 21.7452 3.08966 21.7414 3.11407C21.3311 6.09743 20.124 8.91507 18.2472 11.2703C16.5079 13.4529 14.2532 15.1635 11.6906 16.2509C11.8289 17.1168 11.7249 18.0054 11.3884 18.8177C11.0289 19.6857 10.4201 20.4275 9.63896 20.9495C8.85782 21.4714 7.93946 21.75 7 21.75H3C2.58579 21.75 2.25 21.4142 2.25 21V17C2.25 16.0605 2.52858 15.1421 3.05052 14.361C3.57246 13.5799 4.3143 12.9711 5.18225 12.6115C5.99455 12.2751 6.88314 12.1711 7.74905 12.3094C8.83643 9.74682 10.547 7.49212 12.7296 5.75287C15.0837 3.87693 17.8998 2.67012 20.8815 2.25919ZM10.0984 16.0649C10.077 16.0082 10.0629 15.9506 10.0557 15.893C9.89413 15.4471 9.63624 15.04 9.2981 14.7019C8.96001 14.3638 8.55301 14.1059 8.10721 13.9444C8.04953 13.9372 7.99178 13.9231 7.93499 13.9016C7.90509 13.8903 7.87632 13.8773 7.84877 13.8628C7.77794 13.8436 7.70633 13.8268 7.63404 13.8124C7.0036 13.687 6.35014 13.7514 5.75628 13.9974C5.16242 14.2433 4.65484 14.6599 4.29772 15.1944C3.94061 15.7288 3.75 16.3572 3.75 17V20.25H7C7.64279 20.25 8.27114 20.0594 8.8056 19.7022C9.34006 19.3451 9.75662 18.8376 10.0026 18.2437C10.2486 17.6498 10.313 16.9964 10.1876 16.3659C10.1732 16.2935 10.1563 16.2218 10.1371 16.1509C10.1226 16.1234 10.1097 16.0947 10.0984 16.0649ZM10.3588 13.6412C10.7069 13.9894 10.9969 14.3876 11.2204 14.8204C12.2258 14.3839 13.1782 13.8417 14.0621 13.2048C13.3066 11.827 12.173 10.6933 10.7952 9.93782C10.1583 10.8218 9.61603 11.7741 9.17957 12.7795C9.61238 13.0031 10.0106 13.293 10.3588 13.6412ZM11.7434 8.75107C13.1943 9.59789 14.4021 10.8057 15.2489 12.2565C15.9093 11.6727 16.5204 11.0304 17.0741 10.3355C18.5698 8.45849 19.5983 6.25889 20.0821 3.9179C17.7411 4.40165 15.5415 5.43018 13.6644 6.92595C12.9696 7.47964 12.3273 8.0907 11.7434 8.75107Z"
7543 }));
7544 });
7545
7546 //#endregion
7547 //#region modules/ai/assets/js/editor/icons/evolve-icon.js
7548 init_extends();
7549 var EvolveIcon = react.default.forwardRef(function(props, ref) {
7550 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7551 fillRule: "evenodd",
7552 clipRule: "evenodd",
7553 d: "M2.30691 2.71291C2.27024 2.80134 2.25 2.89831 2.25 3V8C2.25 8.41421 2.58579 8.75 3 8.75C3.41421 8.75 3.75 8.41421 3.75 8V4.81066L10.0056 11.0663L10.0057 11.0663C10.8022 11.8631 11.2497 12.9434 11.25 14.07V14.0702V15V21C11.25 21.4142 11.5858 21.75 12 21.75C12.4142 21.75 12.75 21.4142 12.75 21V15V14.0702V14.07C12.7503 12.9434 13.1979 11.863 13.9944 11.0663L20.25 4.81066V8C20.25 8.41421 20.5858 8.75 21 8.75C21.4142 8.75 21.75 8.41421 21.75 8V3C21.75 2.98706 21.7497 2.97419 21.749 2.96141C21.7446 2.87376 21.7251 2.79009 21.6931 2.71291C21.6565 2.62445 21.6022 2.54158 21.5303 2.46967C21.4584 2.39776 21.3755 2.34351 21.2871 2.30691C21.1987 2.27024 21.1017 2.25 21 2.25H16C15.5858 2.25 15.25 2.58579 15.25 3C15.25 3.41421 15.5858 3.75 16 3.75H19.1893L12.9337 10.0057L12.9336 10.0057C12.5656 10.3739 12.2526 10.7867 12 11.2316C11.7474 10.7867 11.4344 10.3739 11.0664 10.0057L11.0663 10.0057L4.81066 3.75H8C8.41421 3.75 8.75 3.41421 8.75 3C8.75 2.58579 8.41421 2.25 8 2.25H3C2.7937 2.25 2.60686 2.33329 2.47126 2.46808C2.47073 2.46861 2.4702 2.46914 2.46967 2.46967C2.46914 2.4702 2.46861 2.47073 2.46808 2.47126C2.39696 2.5428 2.34324 2.62511 2.30691 2.71291Z"
7554 }));
7555 });
7556
7557 //#endregion
7558 //#region modules/ai/assets/js/editor/icons/enlarger-icon.js
7559 init_extends();
7560 var ExpandIcon = react.default.forwardRef(function(props, ref) {
7561 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7562 fillRule: "evenodd",
7563 clipRule: "evenodd",
7564 d: "M5.11612 5.11612C5.35054 4.8817 5.66848 4.75 6 4.75H18C18.3315 4.75 18.6495 4.8817 18.8839 5.11612C19.1183 5.35054 19.25 5.66848 19.25 6V18C19.25 18.3315 19.1183 18.6495 18.8839 18.8839C18.6495 19.1183 18.3315 19.25 18 19.25H11.7335C11.7444 19.1709 11.75 19.0908 11.75 19.01V14.01C11.75 13.8051 11.7141 13.604 11.6457 13.4149L16.25 8.81066V11C16.25 11.4142 16.5858 11.75 17 11.75C17.4142 11.75 17.75 11.4142 17.75 11V7C17.75 6.89831 17.7298 6.80134 17.6931 6.71291C17.6565 6.62445 17.6022 6.54158 17.5303 6.46967C17.4584 6.39776 17.3755 6.34351 17.2871 6.30691C17.1993 6.27051 17.1031 6.2503 17.0022 6.25C17.0015 6.25 17.0007 6.25 17 6.25H16.9997H13C12.5858 6.25 12.25 6.58579 12.25 7C12.25 7.41421 12.5858 7.75 13 7.75H15.1893L10.5803 12.359C10.3956 12.2941 10.1995 12.26 10 12.26H5C4.91585 12.26 4.83232 12.2661 4.75 12.278V6C4.75 5.66848 4.8817 5.35054 5.11612 5.11612ZM4.75 14.01V18C4.75 18.3315 4.8817 18.6495 5.11612 18.8839C5.35054 19.1183 5.66848 19.25 6 19.25H10.07C10.11 19.2383 10.1468 19.2168 10.1768 19.1868C10.2237 19.1399 10.25 19.0763 10.25 19.01V14.01C10.25 13.9437 10.2237 13.8801 10.1768 13.8332C10.1299 13.7863 10.0663 13.76 10 13.76H5C4.9337 13.76 4.87011 13.7863 4.82322 13.8332C4.77634 13.8801 4.75 13.9437 4.75 14.01ZM3.25 14.01V6C3.25 5.27065 3.53973 4.57118 4.05546 4.05546C4.57118 3.53973 5.27065 3.25 6 3.25H18C18.7293 3.25 19.4288 3.53973 19.9445 4.05546C20.4603 4.57118 20.75 5.27065 20.75 6V18C20.75 18.7293 20.4603 19.4288 19.9445 19.9445C19.4288 20.4603 18.7293 20.75 18 20.75H10.187C10.1251 20.7566 10.0627 20.76 10 20.76H5C4.53587 20.76 4.09075 20.5756 3.76256 20.2474C3.43438 19.9193 3.25 19.4741 3.25 19.01V18V14.01Z"
7565 }));
7566 });
7567
7568 //#endregion
7569 //#region modules/ai/assets/js/editor/icons/remove-bg.js
7570 init_extends();
7571 var RemoveBackgroundIcon = react.default.forwardRef(function(props, ref) {
7572 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 16 16" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", { d: "M5.74996 2.50038C5.74996 2.2242 5.52607 2.00031 5.24989 2.00031C4.9737 2.00031 4.74981 2.2242 4.74981 2.50038V2.50705C4.74981 2.78323 4.9737 3.00712 5.24989 3.00712C5.52607 3.00712 5.74996 2.78323 5.74996 2.50705V2.50038Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M7.9997 2.00031C8.27588 2.00031 8.49978 2.2242 8.49978 2.50038V2.50705C8.49978 2.78323 8.27588 3.00712 7.9997 3.00712C7.72352 3.00712 7.49963 2.78323 7.49963 2.50705V2.50038C7.49963 2.2242 7.72352 2.00031 7.9997 2.00031Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M11.2496 2.50038C11.2496 2.2242 11.0257 2.00031 10.7495 2.00031C10.4733 2.00031 10.2494 2.2242 10.2494 2.50038V2.50705C10.2494 2.78323 10.4733 3.00712 10.7495 3.00712C11.0257 3.00712 11.2496 2.78323 11.2496 2.50705V2.50038Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M13.4993 2.00031C13.7755 2.00031 13.9994 2.2242 13.9994 2.50038V2.50705C13.9994 2.78323 13.7755 3.00712 13.4993 3.00712C13.2231 3.00712 12.9993 2.78323 12.9993 2.50705V2.50038C12.9993 2.2242 13.2231 2.00031 13.4993 2.00031Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M13.9994 5.25019C13.9994 4.97401 13.7755 4.75012 13.4993 4.75012C13.2231 4.75012 12.9993 4.97401 12.9993 5.25019V5.25686C12.9993 5.53304 13.2231 5.75694 13.4993 5.75694C13.7755 5.75694 13.9994 5.53304 13.9994 5.25686V5.25019Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M13.9994 8.00001C13.9994 7.72382 13.7755 7.49993 13.4993 7.49993C13.2231 7.49993 12.9993 7.72382 12.9993 8.00001V8.00667C12.9993 8.28286 13.2231 8.50675 13.4993 8.50675C13.7755 8.50675 13.9994 8.28286 13.9994 8.00667V8.00001Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M2.50007 7.49993C2.77626 7.49993 3.00015 7.72382 3.00015 8.00001V8.00667C3.00015 8.28286 2.77626 8.50675 2.50007 8.50675C2.22389 8.50675 2 8.28286 2 8.00667V8.00001C2 7.72382 2.22389 7.49993 2.50007 7.49993Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M3.00015 5.25019C3.00015 4.97401 2.77626 4.75012 2.50007 4.75012C2.22389 4.75012 2 4.97401 2 5.25019V5.25686C2 5.53304 2.22389 5.75694 2.50007 5.75694C2.77626 5.75694 3.00015 5.53304 3.00015 5.25686V5.25019Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M2.50007 2.00031C2.77626 2.00031 3.00015 2.2242 3.00015 2.50038V2.50705C3.00015 2.78323 2.77626 3.00712 2.50007 3.00712C2.22389 3.00712 2 2.78323 2 2.50705V2.50038C2 2.2242 2.22389 2.00031 2.50007 2.00031Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M9.37461 7.31255C9.94411 7.31255 10.4058 6.85088 10.4058 6.28137C10.4058 5.71187 9.94411 5.25019 9.37461 5.25019C8.8051 5.25019 8.34343 5.71187 8.34343 6.28137C8.34343 6.85088 8.8051 7.31255 9.37461 7.31255Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M9.37461 9.21061L7.6724 7.44357L7.66567 7.43672C7.27331 7.04478 6.79598 6.81248 6.28107 6.81248C5.76615 6.81248 5.28883 7.04478 4.89647 7.43672L4.88973 7.44358L2.13992 10.2982C2.05015 10.3913 2 10.5157 2 10.6451V13.4996C2 13.7758 2.22389 13.9997 2.50007 13.9997H13.4993C13.7755 13.9997 13.9994 13.7758 13.9994 13.4996V10.6451C13.9994 10.6365 13.9992 10.6279 13.9988 10.6194C13.9958 10.562 13.9833 10.5072 13.9627 10.4566C13.9409 10.403 13.9093 10.3523 13.8681 10.3073C13.8651 10.304 13.8621 10.3008 13.859 10.2976L12.4846 8.87085L12.4778 8.86399C12.0855 8.47205 11.6082 8.23975 11.0932 8.23975C10.5783 8.23975 10.101 8.47205 9.70864 8.86399L9.70191 8.87084L9.37461 9.21061ZM5.60649 8.14113L3.00015 10.8468V12.9996H12.9993V10.8468L11.7678 9.5684C11.5234 9.32549 11.2897 9.2399 11.0932 9.2399C10.8968 9.2399 10.6631 9.32549 10.4187 9.5684L10.069 9.93142L11.1097 11.0118C11.3013 11.2107 11.2954 11.5272 11.0965 11.7188C10.8975 11.9104 10.581 11.9045 10.3894 11.7056L9.01604 10.28C9.01482 10.2787 9.01361 10.2775 9.01241 10.2762L6.95564 8.14113C6.7112 7.89822 6.4775 7.81263 6.28107 7.81263C6.08463 7.81263 5.85094 7.89822 5.60649 8.14113Z" }));
7573 });
7574
7575 //#endregion
7576 //#region modules/ai/assets/js/editor/icons/replace-bg.js
7577 init_extends();
7578 var ReplaceBackgroundIcon = react.default.forwardRef(function(props, ref) {
7579 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 16 16" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", { d: "M4.35355 1.64645C4.54882 1.84171 4.54882 2.15829 4.35355 2.35355L2.35355 4.35355C2.15829 4.54882 1.84171 4.54882 1.64645 4.35355C1.45118 4.15829 1.45118 3.84171 1.64645 3.64645L3.64645 1.64645C3.84171 1.45118 4.15829 1.45118 4.35355 1.64645Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M7.68689 1.64645C7.88215 1.84171 7.88215 2.15829 7.68689 2.35355L2.35355 7.68689C2.15829 7.88215 1.84171 7.88215 1.64645 7.68689C1.45118 7.49162 1.45118 7.17504 1.64645 6.97978L6.97978 1.64645C7.17504 1.45118 7.49162 1.45118 7.68689 1.64645Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M11.0202 1.64645C11.2155 1.84171 11.2155 2.15829 11.0202 2.35355L6.68689 6.68689C6.49162 6.88215 6.17504 6.88215 5.97978 6.68689C5.78452 6.49162 5.78452 6.17504 5.97978 5.97978L10.3131 1.64645C10.5084 1.45118 10.825 1.45118 11.0202 1.64645Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M14.3536 1.64645C14.5488 1.84171 14.5488 2.15829 14.3536 2.35355L11.0202 5.68689C10.825 5.88215 10.5084 5.88215 10.3131 5.68689C10.1179 5.49162 10.1179 5.17504 10.3131 4.97978L13.6464 1.64645C13.8417 1.45118 14.1583 1.45118 14.3536 1.64645Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M14.3536 4.97978C14.5488 5.17504 14.5488 5.49162 14.3536 5.68689L12.0202 8.02022C11.825 8.21548 11.5084 8.21548 11.3131 8.02022C11.1179 7.82496 11.1179 7.50838 11.3131 7.31311L13.6464 4.97978C13.8417 4.78452 14.1583 4.78452 14.3536 4.97978Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M14.3536 8.31311C14.5488 8.50838 14.5488 8.82496 14.3536 9.02022L14.0202 9.35355C13.825 9.54882 13.5084 9.54882 13.3131 9.35355C13.1179 9.15829 13.1179 8.84171 13.3131 8.64645L13.6464 8.31311C13.8417 8.11785 14.1583 8.11785 14.3536 8.31311Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M10.3333 7C10.3333 7.55228 9.88562 8 9.33333 8C8.78105 8 8.33333 7.55228 8.33333 7C8.33333 6.44772 8.78105 6 9.33333 6C9.88562 6 10.3333 6.44772 10.3333 7Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M6.33333 8.5C6.14679 8.5 5.92267 8.58153 5.6867 8.81725C5.67587 8.82806 5.66455 8.83838 5.65278 8.84816L2.5 11.4665V13.5H13.5V11.2318C13.5 10.9556 13.7239 10.7318 14 10.7318C14.2761 10.7318 14.5 10.9556 14.5 11.2318V14C14.5 14.2761 14.2761 14.5 14 14.5H2C1.72386 14.5 1.5 14.2761 1.5 14V11.2318C1.5 11.0831 1.56617 10.9421 1.68056 10.8471L4.99717 8.09274C5.37661 7.72073 5.83674 7.5 6.33333 7.5C6.83746 7.5 7.304 7.72747 7.6867 8.10976L7.69343 8.11662L11.0268 11.5769C11.2183 11.7758 11.2124 12.0923 11.0136 12.2839C10.8147 12.4755 10.4981 12.4696 10.3066 12.2707L6.97679 8.81408C6.74199 8.5808 6.51904 8.5 6.33333 8.5Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M10.3564 10.1984L9.69343 10.8866C9.50185 11.0854 9.18532 11.0914 8.98645 10.8998C8.78757 10.7082 8.78166 10.3917 8.97324 10.1928L9.6399 9.50073L9.64663 9.49387C10.4992 8.64223 11.843 8.83788 12.6387 9.45172C12.6435 9.45538 12.6482 9.45913 12.6528 9.46297L14.3194 10.8471C14.5319 11.0235 14.5611 11.3388 14.3846 11.5512C14.2082 11.7636 13.893 11.7928 13.6806 11.6164L12.0213 10.2384C11.4855 9.82976 10.7405 9.81862 10.3564 10.1984Z" }));
7580 });
7581
7582 //#endregion
7583 //#region modules/ai/assets/js/editor/icons/cleanup-icon.js
7584 init_extends();
7585 var Cleanup$1 = react.default.forwardRef(function(props, ref) {
7586 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 16 16" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7587 fillRule: "evenodd",
7588 clipRule: "evenodd",
7589 d: "M10.6668 11.8334H3.66679C3.53235 11.8334 3.40357 11.7792 3.30952 11.6832L0.505518 8.81921L0.504041 8.81772C0.287672 8.59928 0.16626 8.30423 0.16626 7.99671C0.16626 7.68849 0.288225 7.3928 0.505518 7.17421L0.506568 7.17316L7.17323 0.506492L7.17429 0.505442C7.39288 0.288149 7.68857 0.166183 7.99679 0.166183C8.30501 0.166183 8.6007 0.288149 8.81929 0.505442L8.82034 0.50649L12.1547 3.84088C12.372 4.05947 12.494 4.35516 12.494 4.66338C12.494 4.97134 12.3722 5.26679 12.1553 5.48533L12.1547 5.48588L6.86473 10.8334H10.6668C10.9429 10.8334 11.1668 11.0572 11.1668 11.3334C11.1668 11.6095 10.9429 11.8334 10.6668 11.8334ZM7.87959 1.21435C7.91079 1.18349 7.9529 1.16618 7.99679 1.16618C8.04067 1.16618 8.08278 1.18349 8.11398 1.21434L11.4455 4.54588C11.4763 4.57707 11.494 4.61951 11.494 4.66338C11.494 4.70741 11.4766 4.74965 11.4455 4.78088L11.4447 4.78174L10.0411 6.20059L6.46721 2.62673L7.87959 1.21435ZM5.7601 3.33383L1.21473 7.87921C1.18387 7.91041 1.16626 7.95282 1.16626 7.99671C1.16626 8.04074 1.18368 8.08298 1.21473 8.11421L1.2174 8.11691L3.877 10.8334H5.4581L9.33779 6.91152L5.7601 3.33383Z"
7590 }));
7591 });
7592
7593 //#endregion
7594 //#region modules/ai/assets/js/editor/icons/isolate-object-icon.js
7595 init_extends();
7596 var IsolateObjectIcon = react.default.forwardRef(function(props, ref) {
7597 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 16 16" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7598 fillRule: "evenodd",
7599 clipRule: "evenodd",
7600 d: "M2.6665 2.16699C2.94265 2.16699 3.1665 2.39085 3.1665 2.66699V2.67366C3.1665 2.9498 2.94265 3.17366 2.6665 3.17366C2.39036 3.17366 2.1665 2.9498 2.1665 2.67366V2.66699C2.1665 2.39085 2.39036 2.16699 2.6665 2.16699ZM5.33317 2.16699C5.60931 2.16699 5.83317 2.39085 5.83317 2.66699V2.67366C5.83317 2.9498 5.60931 3.17366 5.33317 3.17366C5.05703 3.17366 4.83317 2.9498 4.83317 2.67366V2.66699C4.83317 2.39085 5.05703 2.16699 5.33317 2.16699ZM7.99984 2.16699C8.27598 2.16699 8.49984 2.39085 8.49984 2.66699V2.67366C8.49984 2.9498 8.27598 3.17366 7.99984 3.17366C7.72369 3.17366 7.49984 2.9498 7.49984 2.67366V2.66699C7.49984 2.39085 7.72369 2.16699 7.99984 2.16699ZM10.6665 2.16699C10.9426 2.16699 11.1665 2.39085 11.1665 2.66699V2.67366C11.1665 2.9498 10.9426 3.17366 10.6665 3.17366C10.3904 3.17366 10.1665 2.9498 10.1665 2.67366V2.66699C10.1665 2.39085 10.3904 2.16699 10.6665 2.16699ZM13.3332 2.16699C13.6093 2.16699 13.8332 2.39085 13.8332 2.66699V2.67366C13.8332 2.9498 13.6093 3.17366 13.3332 3.17366C13.057 3.17366 12.8332 2.9498 12.8332 2.67366V2.66699C12.8332 2.39085 13.057 2.16699 13.3332 2.16699ZM2.6665 4.83366C2.94265 4.83366 3.1665 5.05752 3.1665 5.33366V5.34033C3.1665 5.61647 2.94265 5.84033 2.6665 5.84033C2.39036 5.84033 2.1665 5.61647 2.1665 5.34033V5.33366C2.1665 5.05752 2.39036 4.83366 2.6665 4.83366ZM4.83317 5.33366C4.83317 5.05752 5.05703 4.83366 5.33317 4.83366H10.6665C10.9426 4.83366 11.1665 5.05752 11.1665 5.33366V10.667C11.1665 10.9431 10.9426 11.167 10.6665 11.167H5.33317C5.05703 11.167 4.83317 10.9431 4.83317 10.667V5.33366ZM5.83317 5.83366V10.167H10.1665V5.83366H5.83317ZM13.3332 4.83366C13.6093 4.83366 13.8332 5.05752 13.8332 5.33366V5.34033C13.8332 5.61647 13.6093 5.84033 13.3332 5.84033C13.057 5.84033 12.8332 5.61647 12.8332 5.34033V5.33366C12.8332 5.05752 13.057 4.83366 13.3332 4.83366ZM2.6665 7.50033C2.94265 7.50033 3.1665 7.72418 3.1665 8.00033V8.00699C3.1665 8.28313 2.94265 8.50699 2.6665 8.50699C2.39036 8.50699 2.1665 8.28313 2.1665 8.00699V8.00033C2.1665 7.72418 2.39036 7.50033 2.6665 7.50033ZM13.3332 7.50033C13.6093 7.50033 13.8332 7.72418 13.8332 8.00033V8.00699C13.8332 8.28313 13.6093 8.50699 13.3332 8.50699C13.057 8.50699 12.8332 8.28313 12.8332 8.00699V8.00033C12.8332 7.72418 13.057 7.50033 13.3332 7.50033ZM2.6665 10.167C2.94265 10.167 3.1665 10.3908 3.1665 10.667V10.6737C3.1665 10.9498 2.94265 11.1737 2.6665 11.1737C2.39036 11.1737 2.1665 10.9498 2.1665 10.6737V10.667C2.1665 10.3908 2.39036 10.167 2.6665 10.167ZM13.3332 10.167C13.6093 10.167 13.8332 10.3908 13.8332 10.667V10.6737C13.8332 10.9498 13.6093 11.1737 13.3332 11.1737C13.057 11.1737 12.8332 10.9498 12.8332 10.6737V10.667C12.8332 10.3908 13.057 10.167 13.3332 10.167ZM2.6665 12.8337C2.94265 12.8337 3.1665 13.0575 3.1665 13.3337V13.3403C3.1665 13.6165 2.94265 13.8403 2.6665 13.8403C2.39036 13.8403 2.1665 13.6165 2.1665 13.3403V13.3337C2.1665 13.0575 2.39036 12.8337 2.6665 12.8337ZM5.33317 12.8337C5.60931 12.8337 5.83317 13.0575 5.83317 13.3337V13.3403C5.83317 13.6165 5.60931 13.8403 5.33317 13.8403C5.05703 13.8403 4.83317 13.6165 4.83317 13.3403V13.3337C4.83317 13.0575 5.05703 12.8337 5.33317 12.8337ZM7.99984 12.8337C8.27598 12.8337 8.49984 13.0575 8.49984 13.3337V13.3403C8.49984 13.6165 8.27598 13.8403 7.99984 13.8403C7.72369 13.8403 7.49984 13.6165 7.49984 13.3403V13.3337C7.49984 13.0575 7.72369 12.8337 7.99984 12.8337ZM10.6665 12.8337C10.9426 12.8337 11.1665 13.0575 11.1665 13.3337V13.3403C11.1665 13.6165 10.9426 13.8403 10.6665 13.8403C10.3904 13.8403 10.1665 13.6165 10.1665 13.3403V13.3337C10.1665 13.0575 10.3904 12.8337 10.6665 12.8337ZM13.3332 12.8337C13.6093 12.8337 13.8332 13.0575 13.8332 13.3337V13.3403C13.8332 13.6165 13.6093 13.8403 13.3332 13.8403C13.057 13.8403 12.8332 13.6165 12.8332 13.3403V13.3337C12.8332 13.0575 13.057 12.8337 13.3332 12.8337Z"
7601 }));
7602 });
7603
7604 //#endregion
7605 //#region modules/ai/assets/js/editor/pages/form-media/views/image-tools/image-tools-panel.js
7606 init_use_introduction();
7607 var TeaserDrawing = function TeaserDrawing() {
7608 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, {
7609 viewBox: "0 0 184 80",
7610 sx: {
7611 width: 184,
7612 height: 80
7613 }
7614 }, /*#__PURE__*/ react.default.createElement("g", { clipPath: "url(#clip0_3127_96542)" }, /*#__PURE__*/ react.default.createElement("path", {
7615 fillRule: "evenodd",
7616 clipRule: "evenodd",
7617 d: "M49.6014 1.36364C49.6014 0.610521 48.9907 0 48.2373 0C47.4839 0 46.8731 0.610521 46.8731 1.36364C46.8731 1.9664 46.6336 2.54448 46.2072 2.9707C45.7808 3.39692 45.2025 3.63636 44.5995 3.63636C43.8461 3.63636 43.2354 4.24689 43.2354 5C43.2354 5.75311 43.8461 6.36364 44.5995 6.36364C45.2025 6.36364 45.7808 6.60308 46.2072 7.0293C46.6336 7.45552 46.8731 8.0336 46.8731 8.63636C46.8731 9.38948 47.4839 10 48.2373 10C48.9907 10 49.6014 9.38948 49.6014 8.63636C49.6014 8.0336 49.8409 7.45552 50.2673 7.0293C50.6937 6.60308 51.272 6.36364 51.875 6.36364C52.6284 6.36364 53.2392 5.75311 53.2392 5C53.2392 4.24689 52.6284 3.63636 51.875 3.63636C51.272 3.63636 50.6937 3.39692 50.2673 2.9707C49.8409 2.54448 49.6014 1.9664 49.6014 1.36364ZM48.1364 4.89917C48.1706 4.86501 48.2042 4.83041 48.2373 4.79538C48.2703 4.83041 48.304 4.86501 48.3381 4.89917C48.3723 4.93333 48.4069 4.96694 48.4419 5C48.4069 5.03306 48.3723 5.06667 48.3381 5.10083C48.304 5.13499 48.2703 5.16959 48.2373 5.20462C48.2042 5.16959 48.1706 5.13499 48.1364 5.10083C48.1022 5.06667 48.0676 5.03306 48.0326 5C48.0676 4.96694 48.1022 4.93333 48.1364 4.89917Z",
7618 fill: "#69727D"
7619 }), /*#__PURE__*/ react.default.createElement("path", {
7620 fillRule: "evenodd",
7621 clipRule: "evenodd",
7622 d: "M66.6927 22.3677C66.6927 21.6177 66.082 21.0098 65.3286 21.0098C64.5752 21.0098 63.9644 21.6177 63.9644 22.3677C63.9644 22.9679 63.7249 23.5436 63.2985 23.968C62.8721 24.3924 62.2938 24.6309 61.6908 24.6309C60.9374 24.6309 60.3267 25.2388 60.3267 25.9888C60.3267 26.7387 60.9374 27.3467 61.6908 27.3467C62.2938 27.3467 62.8721 27.5851 63.2985 28.0096C63.7249 28.434 63.9644 29.0096 63.9644 29.6099C63.9644 30.3598 64.5752 30.9678 65.3286 30.9678C66.082 30.9678 66.6927 30.3598 66.6927 29.6099C66.6927 29.0096 66.9323 28.434 67.3586 28.0096C67.785 27.5851 68.3633 27.3467 68.9663 27.3467C69.7197 27.3467 70.3305 26.7387 70.3305 25.9888C70.3305 25.2388 69.7197 24.6309 68.9663 24.6309C68.3633 24.6309 67.785 24.3924 67.3586 23.968C66.9323 23.5436 66.6927 22.9679 66.6927 22.3677ZM65.2277 25.8884C65.2619 25.8544 65.2955 25.8199 65.3286 25.785C65.3616 25.8199 65.3953 25.8544 65.4294 25.8884C65.4636 25.9224 65.4982 25.9559 65.5333 25.9888C65.4982 26.0217 65.4636 26.0552 65.4294 26.0892C65.3953 26.1232 65.3616 26.1577 65.3286 26.1925C65.2955 26.1577 65.2619 26.1232 65.2277 26.0892C65.1935 26.0552 65.1589 26.0217 65.1239 25.9888C65.1589 25.9559 65.1935 25.9224 65.2277 25.8884Z",
7623 fill: "#69727D"
7624 }), /*#__PURE__*/ react.default.createElement("path", {
7625 d: "M53.9717 12L57.2198 17.0456L3.24796 51.4731L-0.000164873 46.4275L53.9717 12Z",
7626 fill: "#69727D"
7627 }), /*#__PURE__*/ react.default.createElement("path", {
7628 d: "M64.9761 5L68.2242 10.0456L57.2612 17.0387L54.013 11.9931L64.9761 5Z",
7629 fill: "#E6E8EA"
7630 }), /*#__PURE__*/ react.default.createElement("path", {
7631 fillRule: "evenodd",
7632 clipRule: "evenodd",
7633 d: "M65.7284 9.49923L64.432 7.48537L56.5088 12.5394L57.8052 14.5533L65.7284 9.49923ZM64.9761 5L54.013 11.9931L57.2612 17.0387L68.2242 10.0456L64.9761 5Z",
7634 fill: "#69727D"
7635 }), /*#__PURE__*/ react.default.createElement("path", {
7636 fillRule: "evenodd",
7637 clipRule: "evenodd",
7638 d: "M128 41C128 43.7687 121.671 46.2089 112.052 47.6451L114.482 74.7976C114.494 74.8647 114.5 74.9322 114.5 75C114.5 75.0001 114.5 75.0002 114.5 75.0003C114.513 75.1456 114.487 75.2779 114.43 75.3982C113.514 77.9735 103.8 80 91.95 80C79.496 80 69.4 77.7614 69.4 75C69.4 74.8146 69.4456 74.6315 69.5343 74.4513L71.2141 47.5326C62.0087 46.0835 56 43.6977 56 41C56 36.5817 72.1177 33 92 33C111.882 33 128 36.5817 128 41Z",
7639 fill: "#69727D"
7640 }), /*#__PURE__*/ react.default.createElement("path", {
7641 d: "M106.685 3.08259C112.562 16.564 109.338 34.1761 106.713 41.4407C106.713 41.4407 105.151 41.9127 100.894 41.9715C96.6371 42.0303 95.0251 41.9866 95.0251 41.4558C95.0252 40.9249 94.6272 34.6461 96.4177 22.3308C98.0343 11.2116 102.692 5.02553 105.448 2.75675C105.865 2.4137 106.47 2.58777 106.685 3.08259Z",
7642 fill: "#E6E8EA"
7643 }), /*#__PURE__*/ react.default.createElement("path", {
7644 fillRule: "evenodd",
7645 clipRule: "evenodd",
7646 d: "M104.883 4.66783C105.347 4.17219 106.14 4.35208 106.38 4.9873C108.716 11.1748 109.254 18.1507 108.889 24.5355C108.513 31.1152 107.184 36.9856 105.954 40.5842C105.778 40.6166 105.55 40.6541 105.265 40.6927C104.388 40.8119 102.974 40.9423 100.88 40.9712C98.7385 41.0008 97.3196 41.0031 96.4377 40.9371C96.2614 40.9239 96.1203 40.9088 96.0088 40.8935C95.9567 39.0573 95.8782 32.9919 97.4073 22.4743C98.766 13.1288 102.302 7.42438 104.883 4.66783ZM106.713 41.4403L107.002 42.3975C107.305 42.3062 107.546 42.0773 107.653 41.7802C109 38.0524 110.481 31.7376 110.886 24.6496C111.29 17.5654 110.626 9.61894 107.602 2.68255C107.147 1.63949 105.792 1.17814 104.812 1.98425C101.838 4.43294 97.0752 10.8574 95.4281 22.1866C93.7715 33.5811 93.975 39.865 94.0187 41.2138C94.0225 41.3324 94.0251 41.4128 94.0251 41.4552C94.025 42.261 94.695 42.5983 95.0067 42.7098C95.3591 42.8358 95.8079 42.8956 96.2886 42.9316C97.2769 43.0055 98.7924 43.0002 100.908 42.971C103.071 42.9411 104.566 42.806 105.534 42.6745C106.018 42.6088 106.371 42.5438 106.61 42.4932C106.729 42.4679 106.82 42.4461 106.885 42.4296C106.917 42.4214 106.943 42.4144 106.962 42.409L106.987 42.4021L106.996 42.3995L106.999 42.3984L107.001 42.398C107.001 42.398 107.002 42.3975 106.713 41.4403ZM106.426 40.4822L106.428 40.4817L106.43 40.4812C106.43 40.4812 106.429 40.4814 106.426 40.4822Z",
7647 fill: "#69727D"
7648 }), /*#__PURE__*/ react.default.createElement("path", {
7649 fillRule: "evenodd",
7650 clipRule: "evenodd",
7651 d: "M104.22 13.8372C104.787 15.7536 104.996 18.3439 104.953 21.2589C104.907 24.4148 104.569 27.8559 104.134 31.0529C103.7 34.2469 103.172 37.1799 102.753 39.3152C102.544 40.3824 102.361 41.2491 102.232 41.8481C102.22 41.9009 102.209 41.9516 102.199 42.0001H100.503C100.526 38.5025 100.676 33.4168 101.183 28.2866C101.724 22.8227 102.66 17.4299 104.22 13.8372ZM103 43.0001C103.974 43.2266 103.974 43.2264 103.974 43.2262L103.978 43.2093L103.989 43.1613C103.999 43.1192 104.013 43.0571 104.031 42.976C104.067 42.814 104.12 42.5763 104.186 42.2713C104.318 41.6613 104.503 40.7819 104.716 39.7006C105.14 37.5391 105.675 34.5658 106.116 31.3223C106.556 28.0818 106.905 24.5541 106.953 21.2881C107 18.0456 106.753 14.9635 105.943 12.6671C105.815 12.3045 105.676 11.9539 105.512 11.6797C105.394 11.4809 105.045 10.9388 104.371 10.9076C103.702 10.8766 103.301 11.3772 103.156 11.5722C102.959 11.8385 102.774 12.1912 102.594 12.5778C100.767 16.4945 99.7565 22.3931 99.1929 28.0897C98.6258 33.8211 98.5 39.4812 98.5 43.0001V44.0001H103.794L103.974 43.2262L103 43.0001Z",
7652 fill: "#69727D"
7653 }), /*#__PURE__*/ react.default.createElement("path", {
7654 d: "M79.2952 3.08259C73.4181 16.564 76.6423 34.1761 79.2676 41.4407C79.2676 41.4407 80.8299 41.9127 85.0867 41.9715C89.3434 42.0303 90.9554 41.9866 90.9554 41.4558C90.9553 40.9249 91.3533 34.6461 89.5628 22.3308C87.9462 11.2116 83.2888 5.02553 80.5325 2.75675C80.1157 2.4137 79.511 2.58777 79.2952 3.08259Z",
7655 fill: "#E6E8EA"
7656 }), /*#__PURE__*/ react.default.createElement("path", {
7657 fillRule: "evenodd",
7658 clipRule: "evenodd",
7659 d: "M81.0978 4.66783C80.6337 4.17219 79.8403 4.35208 79.6005 4.9873C77.2644 11.1748 76.7267 18.1507 77.0914 24.5355C77.4671 31.1152 78.7963 36.9856 80.0267 40.5842C80.2028 40.6166 80.4308 40.6541 80.7155 40.6927C81.5929 40.8119 83.0069 40.9423 85.1005 40.9712C87.242 41.0008 88.6609 41.0031 89.5427 40.9371C89.7191 40.9239 89.8602 40.9088 89.9716 40.8935C90.0238 39.0573 90.1023 32.9919 88.5732 22.4743C87.2145 13.1288 83.6789 7.42438 81.0978 4.66783ZM79.2676 41.4403L78.9784 42.3975C78.676 42.3062 78.4345 42.0773 78.3271 41.7802C76.98 38.0524 75.4994 31.7376 75.0946 24.6496C74.69 17.5654 75.3547 9.61894 78.3786 2.68255C78.8333 1.63949 80.1887 1.17814 81.168 1.98425C84.1429 4.43294 88.9053 10.8574 90.5524 22.1866C92.209 33.5811 92.0055 39.865 91.9618 41.2138C91.958 41.3324 91.9554 41.4128 91.9554 41.4552C91.9554 42.261 91.2855 42.5983 90.9737 42.7098C90.6214 42.8358 90.1726 42.8956 89.6919 42.9316C88.7036 43.0055 87.1881 43.0002 85.0728 42.971C82.9096 42.9411 81.4141 42.806 80.4462 42.6745C79.9621 42.6088 79.6094 42.5438 79.3707 42.4932C79.2514 42.4679 79.1605 42.4461 79.0958 42.4296C79.0635 42.4214 79.0377 42.4144 79.0182 42.409L78.9937 42.4021L78.9849 42.3995L78.9814 42.3984L78.9798 42.398C78.9798 42.398 78.9784 42.3975 79.2676 41.4403ZM79.5541 40.4822L79.5526 40.4817L79.5507 40.4812C79.5507 40.4812 79.5514 40.4814 79.5541 40.4822Z",
7660 fill: "#69727D"
7661 }), /*#__PURE__*/ react.default.createElement("path", {
7662 fillRule: "evenodd",
7663 clipRule: "evenodd",
7664 d: "M81.7604 13.8372C81.1939 15.7536 80.9847 18.3439 81.0272 21.2589C81.0733 24.4148 81.4118 27.8559 81.8464 31.0529C82.2805 34.2469 82.8081 37.1799 83.2274 39.3152C83.4369 40.3824 83.6192 41.2491 83.7488 41.8481C83.7603 41.9009 83.7713 41.9516 83.7819 42.0001H85.4771C85.4542 38.5025 85.3049 33.4168 84.7973 28.2866C84.2567 22.8227 83.32 17.4299 81.7604 13.8372ZM82.9805 43.0001C82.0065 43.2266 82.0064 43.2264 82.0064 43.2262L82.0025 43.2093L81.9914 43.1613C81.9818 43.1192 81.9677 43.0571 81.9494 42.976C81.913 42.814 81.8602 42.5763 81.7941 42.2713C81.6621 41.6613 81.4772 40.7819 81.2648 39.7006C80.8404 37.5391 80.3054 34.5658 79.8646 31.3223C79.4241 28.0818 79.0751 24.5541 79.0275 21.2881C78.9801 18.0456 79.227 14.9635 80.0375 12.6671C80.1655 12.3045 80.305 11.9539 80.4683 11.6797C80.5868 11.4809 80.9351 10.9388 81.6092 10.9076C82.2782 10.8766 82.6793 11.3772 82.8241 11.5722C83.0217 11.8385 83.2064 12.1912 83.3867 12.5778C85.2136 16.4945 86.224 22.3931 86.7876 28.0897C87.3546 33.8211 87.4805 39.4812 87.4805 43.0001V44.0001H82.1863L82.0064 43.2262L82.9805 43.0001Z",
7665 fill: "#69727D"
7666 })), /*#__PURE__*/ react.default.createElement("defs", null, /*#__PURE__*/ react.default.createElement("clipPath", { id: "clip0_3127_96542" }, /*#__PURE__*/ react.default.createElement("rect", {
7667 width: "184",
7668 height: "80",
7669 fill: "white"
7670 }))));
7671 };
7672 var ImageToolsContainer = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref) {
7673 var theme = _ref.theme;
7674 return { height: "calc(100% - ".concat(theme.spacing(13), ")") };
7675 });
7676 var ToolsTeaserContainer = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref2) {
7677 return {
7678 position: "sticky",
7679 top: "100%",
7680 padding: _ref2.theme.spacing(4, 0, 1)
7681 };
7682 });
7683 var StyledChip = (0, _elementor_ui.styled)(_elementor_ui.Chip)(function() {
7684 return {
7685 position: "absolute",
7686 top: 8,
7687 right: 8,
7688 "& .MuiChip-label": {
7689 fontSize: "0.75rem",
7690 fontWeight: "normal"
7691 }
7692 };
7693 });
7694 var ImageToolsPanel = function ImageToolsPanel() {
7695 var navigate = useLocation().navigate;
7696 var _useIntroduction = useIntroduction("e-ai-image-isolate-tool");
7697 var isIsolateViewed = _useIntroduction.isViewed;
7698 var markIsolateAsViewed = _useIntroduction.markAsViewed;
7699 var tools = [
7700 {
7701 label: (0, _wordpress_i18n.__)("Expand Image", "elementor"),
7702 Icon: ExpandIcon$1,
7703 onClick: function onClick() {
7704 return navigate(LOCATIONS.OUT_PAINTING);
7705 }
7706 },
7707 {
7708 label: (0, _wordpress_i18n.__)("Generative Fill", "elementor"),
7709 Icon: BrushIcon,
7710 onClick: function onClick() {
7711 return navigate(LOCATIONS.IN_PAINTING);
7712 }
7713 },
7714 {
7715 label: (0, _wordpress_i18n.__)("Resize", "elementor"),
7716 Icon: ExpandIcon,
7717 onClick: function onClick() {
7718 return navigate(LOCATIONS.RESIZE);
7719 }
7720 },
7721 {
7722 label: (0, _wordpress_i18n.__)("Variations", "elementor"),
7723 Icon: EvolveIcon,
7724 onClick: function onClick() {
7725 return navigate(LOCATIONS.VARIATIONS);
7726 }
7727 },
7728 {
7729 label: (0, _wordpress_i18n.__)("Remove Background", "elementor"),
7730 Icon: RemoveBackgroundIcon,
7731 onClick: function onClick() {
7732 return navigate(LOCATIONS.REMOVE_BACKGROUND);
7733 }
7734 },
7735 {
7736 label: (0, _wordpress_i18n.__)("Replace Background", "elementor"),
7737 Icon: ReplaceBackgroundIcon,
7738 onClick: function onClick() {
7739 return navigate(LOCATIONS.REPLACE_BACKGROUND);
7740 }
7741 },
7742 {
7743 label: (0, _wordpress_i18n.__)("Cleanup", "elementor"),
7744 Icon: Cleanup$1,
7745 onClick: function onClick() {
7746 return navigate(LOCATIONS.CLEANUP);
7747 }
7748 },
7749 {
7750 label: (0, _wordpress_i18n.__)("Isolate object", "elementor"),
7751 Icon: IsolateObjectIcon,
7752 ChipParam: !isIsolateViewed ? /*#__PURE__*/ react.default.createElement(StyledChip, {
7753 label: "New",
7754 color: "info",
7755 variant: "standard",
7756 size: "tiny"
7757 }) : null,
7758 onClick: function onClick() {
7759 markIsolateAsViewed();
7760 navigate(LOCATIONS.ISOLATE_OBJECT);
7761 }
7762 }
7763 ];
7764 return /*#__PURE__*/ react.default.createElement(ImageToolsContainer, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7765 display: "grid",
7766 gridTemplateColumns: "repeat(2, 1fr)",
7767 gap: 1,
7768 justifyContent: "center"
7769 }, tools.map(function(_ref3) {
7770 var label = _ref3.label;
7771 var Icon = _ref3.Icon;
7772 var ChipParam = _ref3.ChipParam;
7773 var onClick = _ref3.onClick;
7774 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
7775 onClick,
7776 key: label,
7777 variant: "outlined",
7778 color: "secondary",
7779 disabled: false,
7780 sx: {
7781 py: 3,
7782 fontSize: "12px",
7783 height: "auto",
7784 borderRadius: "4px"
7785 }
7786 }, ChipParam, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7787 display: "flex",
7788 justifyContent: "center",
7789 alignItems: "center",
7790 flexDirection: "column"
7791 }, /*#__PURE__*/ react.default.createElement(Icon, { sx: { mb: .5 } }), label));
7792 })), /*#__PURE__*/ react.default.createElement(ToolsTeaserContainer, {
7793 display: "flex",
7794 flexDirection: "column",
7795 alignItems: "center"
7796 }, /*#__PURE__*/ react.default.createElement(TeaserDrawing, null), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
7797 variant: "body2",
7798 align: "center",
7799 color: "secondary",
7800 sx: { mt: 2 }
7801 }, (0, _wordpress_i18n.__)("Stay tuned! More incredible AI tools are coming your way soon.", "elementor"))));
7802 };
7803 ImageToolsPanel.propTypes = {
7804 generateNewPrompt: import_prop_types$7.default.func,
7805 panelActive: import_prop_types$7.default.bool
7806 };
7807
7808 //#endregion
7809 //#region modules/ai/assets/js/editor/pages/form-media/views/image-tools/image-tools-content.js
7810 var ImageToolsContent = function ImageToolsContent() {
7811 var _useEditImage = useEditImage();
7812 var editImage = _useEditImage.editImage;
7813 var width = _useEditImage.width;
7814 var height = _useEditImage.height;
7815 var use = useImageActions().use;
7816 return /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
7817 src: editImage.url,
7818 style: {
7819 width,
7820 height
7821 },
7822 alt: editImage.alt || (0, _wordpress_i18n.__)("Image preview", "elementor")
7823 }, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Actions, null, /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, { onClick: function onClick() {
7824 return use(editImage);
7825 } }))));
7826 };
7827
7828 //#endregion
7829 //#region modules/ai/assets/js/editor/pages/form-media/views/image-tools/index.js
7830 var ImageTools = function ImageTools() {
7831 var navigate = useLocation().navigate;
7832 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, { onClick: function onClick() {
7833 return navigate(LOCATIONS.GENERATE);
7834 } }, (0, _wordpress_i18n.__)("Generate with a prompt", "elementor")), /*#__PURE__*/ react.default.createElement(View.PanelHeading, { primary: (0, _wordpress_i18n.__)("Edit with AI", "elementor") }), /*#__PURE__*/ react.default.createElement(ImageToolsPanel, null)), /*#__PURE__*/ react.default.createElement(View.Content, null, /*#__PURE__*/ react.default.createElement(ImageToolsContent, null)));
7835 };
7836
7837 //#endregion
7838 //#region modules/ai/assets/js/editor/pages/form-media/components/generate-submit.js
7839 init_extends();
7840 var GenerateSubmit = function GenerateSubmit(props) {
7841 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
7842 fullWidth: true,
7843 size: "medium",
7844 type: "submit",
7845 variant: "contained"
7846 }, props), props.children || (0, _wordpress_i18n.__)("Generate", "elementor"));
7847 };
7848 GenerateSubmit.propTypes = { children: import_prop_types$7.default.node };
7849
7850 //#endregion
7851 //#region modules/ai/assets/js/editor/pages/form-media/hooks/use-image-prompt.js
7852 init_use_prompt();
7853 var useImagePrompt = function useImagePrompt() {
7854 var promptData = usePrompt.apply(void 0, arguments);
7855 var _useGlobalActions = useGlobalActions();
7856 var setHasUnsavedChanges = _useGlobalActions.setHasUnsavedChanges;
7857 var state = _useGlobalActions.state;
7858 (0, react.useEffect)(function() {
7859 var _promptData$data;
7860 if ((_promptData$data = promptData.data) !== null && _promptData$data !== void 0 && _promptData$data.result) setHasUnsavedChanges(true);
7861 }, [promptData.data]);
7862 (0, react.useEffect)(function() {
7863 if (state.isAllSaved) promptData.sendUsageData();
7864 }, [state.isAllSaved]);
7865 return promptData;
7866 };
7867
7868 //#endregion
7869 //#region modules/ai/assets/js/editor/pages/form-media/views/resize/hooks/use-resize.js
7870 init_api();
7871 var useResize = function useResize(initialValue) {
7872 return useImagePrompt(function fetchAction(payload) {
7873 return getImageToImageUpscale(payload);
7874 }, initialValue);
7875 };
7876
7877 //#endregion
7878 //#region modules/ai/assets/js/editor/pages/form-media/views/resize/index.js
7879 init_defineProperty();
7880 init_requests_ids();
7881 var Resize = function Resize() {
7882 var _useEditImage = useEditImage();
7883 var editImage = _useEditImage.editImage;
7884 var initialEditImageWidth = _useEditImage.width;
7885 var setGenerate = useRequestIds().setGenerate;
7886 var _useImageActions = useImageActions();
7887 var use = _useImageActions.use;
7888 var edit = _useImageActions.edit;
7889 var isUploading = _useImageActions.isLoading;
7890 var _usePromptSettings = usePromptSettings();
7891 var settings = _usePromptSettings.settings;
7892 var updateSettings = _usePromptSettings.updateSettings;
7893 var _useResize = useResize();
7894 var data = _useResize.data;
7895 var send = _useResize.send;
7896 var isGenerating = _useResize.isLoading;
7897 var error = _useResize.error;
7898 var isLoading = isGenerating || isUploading;
7899 var handleSubmit = function handleSubmit(event) {
7900 event.preventDefault();
7901 setGenerate();
7902 send({
7903 promptSettings: settings,
7904 image: editImage
7905 });
7906 };
7907 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, null), /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
7908 primary: (0, _wordpress_i18n.__)("Resize", "elementor"),
7909 secondary: (0, _wordpress_i18n.__)("Make an image larger and improve it’s resolution.", "elementor")
7910 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
7911 error,
7912 onRetry: handleSubmit
7913 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, { spacing: .2 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7914 display: "flex",
7915 justifyContent: "space-between",
7916 alignItems: "center"
7917 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "caption" }, "512px"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "caption" }, "2048px")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Slider, {
7918 marks: true,
7919 step: 64,
7920 min: 512,
7921 max: 2048,
7922 id: "upscale_to",
7923 color: "secondary",
7924 name: "upscale_to",
7925 disabled: isLoading,
7926 defaultValue: initialEditImageWidth,
7927 valueLabelDisplay: "auto",
7928 "aria-label": (0, _wordpress_i18n.__)("Upscale to", "elementor"),
7929 onChange: function onChange(_, value) {
7930 return updateSettings(_defineProperty({}, IMAGE_UPSCALE, value));
7931 }
7932 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7933 display: "flex",
7934 justifyContent: "space-between",
7935 alignItems: "center"
7936 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "caption" }, (0, _wordpress_i18n.__)("Current", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "caption" }, (0, _wordpress_i18n.__)("Output", "elementor")))), /*#__PURE__*/ react.default.createElement(GenerateSubmit, { disabled: isLoading }))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isLoading }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
7937 onUseImage: use,
7938 onEditImage: edit,
7939 images: data.result,
7940 aspectRatio: editImage.aspectRatio
7941 }) : /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
7942 src: editImage.url,
7943 alt: editImage.alt,
7944 style: {
7945 width: editImage.width,
7946 height: editImage.height
7947 }
7948 }))));
7949 };
7950
7951 //#endregion
7952 //#region node_modules/react-sketch-canvas/dist/react-sketch-canvas.esm.js
7953 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
7954 try {
7955 var info = gen[key](arg);
7956 var value = info.value;
7957 } catch (error) {
7958 reject(error);
7959 return;
7960 }
7961 if (info.done) resolve(value);
7962 else Promise.resolve(value).then(_next, _throw);
7963 }
7964 function _asyncToGenerator(fn) {
7965 return function() {
7966 var self = this;
7967 var args = arguments;
7968 return new Promise(function(resolve, reject) {
7969 var gen = fn.apply(self, args);
7970 function _next(value) {
7971 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
7972 }
7973 function _throw(err) {
7974 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
7975 }
7976 _next(void 0);
7977 });
7978 };
7979 }
7980 function _extends() {
7981 _extends = Object.assign || function(target) {
7982 for (var i = 1; i < arguments.length; i++) {
7983 var source = arguments[i];
7984 for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
7985 }
7986 return target;
7987 };
7988 return _extends.apply(this, arguments);
7989 }
7990 var runtime = { exports: {} };
7991 /**
7992 * Copyright (c) 2014-present, Facebook, Inc.
7993 *
7994 * This source code is licensed under the MIT license found in the
7995 * LICENSE file in the root directory of this source tree.
7996 */
7997 (function(module) {
7998 var runtime = function(exports) {
7999 var Op = Object.prototype;
8000 var hasOwn = Op.hasOwnProperty;
8001 var undefined$1;
8002 var $Symbol = typeof Symbol === "function" ? Symbol : {};
8003 var iteratorSymbol = $Symbol.iterator || "@@iterator";
8004 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
8005 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
8006 function define(obj, key, value) {
8007 Object.defineProperty(obj, key, {
8008 value,
8009 enumerable: true,
8010 configurable: true,
8011 writable: true
8012 });
8013 return obj[key];
8014 }
8015 try {
8016 define({}, "");
8017 } catch (err) {
8018 define = function(obj, key, value) {
8019 return obj[key] = value;
8020 };
8021 }
8022 function wrap(innerFn, outerFn, self, tryLocsList) {
8023 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
8024 var generator = Object.create(protoGenerator.prototype);
8025 generator._invoke = makeInvokeMethod(innerFn, self, new Context(tryLocsList || []));
8026 return generator;
8027 }
8028 exports.wrap = wrap;
8029 function tryCatch(fn, obj, arg) {
8030 try {
8031 return {
8032 type: "normal",
8033 arg: fn.call(obj, arg)
8034 };
8035 } catch (err) {
8036 return {
8037 type: "throw",
8038 arg: err
8039 };
8040 }
8041 }
8042 var GenStateSuspendedStart = "suspendedStart";
8043 var GenStateSuspendedYield = "suspendedYield";
8044 var GenStateExecuting = "executing";
8045 var GenStateCompleted = "completed";
8046 var ContinueSentinel = {};
8047 function Generator() {}
8048 function GeneratorFunction() {}
8049 function GeneratorFunctionPrototype() {}
8050 var IteratorPrototype = {};
8051 define(IteratorPrototype, iteratorSymbol, function() {
8052 return this;
8053 });
8054 var getProto = Object.getPrototypeOf;
8055 var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
8056 if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) IteratorPrototype = NativeIteratorPrototype;
8057 var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
8058 GeneratorFunction.prototype = GeneratorFunctionPrototype;
8059 define(Gp, "constructor", GeneratorFunctionPrototype);
8060 define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
8061 GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
8062 function defineIteratorMethods(prototype) {
8063 [
8064 "next",
8065 "throw",
8066 "return"
8067 ].forEach(function(method) {
8068 define(prototype, method, function(arg) {
8069 return this._invoke(method, arg);
8070 });
8071 });
8072 }
8073 exports.isGeneratorFunction = function(genFun) {
8074 var ctor = typeof genFun === "function" && genFun.constructor;
8075 return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
8076 };
8077 exports.mark = function(genFun) {
8078 if (Object.setPrototypeOf) Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
8079 else {
8080 genFun.__proto__ = GeneratorFunctionPrototype;
8081 define(genFun, toStringTagSymbol, "GeneratorFunction");
8082 }
8083 genFun.prototype = Object.create(Gp);
8084 return genFun;
8085 };
8086 exports.awrap = function(arg) {
8087 return { __await: arg };
8088 };
8089 function AsyncIterator(generator, PromiseImpl) {
8090 function invoke(method, arg, resolve, reject) {
8091 var record = tryCatch(generator[method], generator, arg);
8092 if (record.type === "throw") reject(record.arg);
8093 else {
8094 var result = record.arg;
8095 var value = result.value;
8096 if (value && typeof value === "object" && hasOwn.call(value, "__await")) return PromiseImpl.resolve(value.__await).then(function(value) {
8097 invoke("next", value, resolve, reject);
8098 }, function(err) {
8099 invoke("throw", err, resolve, reject);
8100 });
8101 return PromiseImpl.resolve(value).then(function(unwrapped) {
8102 result.value = unwrapped;
8103 resolve(result);
8104 }, function(error) {
8105 return invoke("throw", error, resolve, reject);
8106 });
8107 }
8108 }
8109 var previousPromise;
8110 function enqueue(method, arg) {
8111 function callInvokeWithMethodAndArg() {
8112 return new PromiseImpl(function(resolve, reject) {
8113 invoke(method, arg, resolve, reject);
8114 });
8115 }
8116 return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
8117 }
8118 this._invoke = enqueue;
8119 }
8120 defineIteratorMethods(AsyncIterator.prototype);
8121 define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
8122 return this;
8123 });
8124 exports.AsyncIterator = AsyncIterator;
8125 exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
8126 if (PromiseImpl === void 0) PromiseImpl = Promise;
8127 var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
8128 return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
8129 return result.done ? result.value : iter.next();
8130 });
8131 };
8132 function makeInvokeMethod(innerFn, self, context) {
8133 var state = GenStateSuspendedStart;
8134 return function invoke(method, arg) {
8135 if (state === GenStateExecuting) throw new Error("Generator is already running");
8136 if (state === GenStateCompleted) {
8137 if (method === "throw") throw arg;
8138 return doneResult();
8139 }
8140 context.method = method;
8141 context.arg = arg;
8142 while (true) {
8143 var delegate = context.delegate;
8144 if (delegate) {
8145 var delegateResult = maybeInvokeDelegate(delegate, context);
8146 if (delegateResult) {
8147 if (delegateResult === ContinueSentinel) continue;
8148 return delegateResult;
8149 }
8150 }
8151 if (context.method === "next") context.sent = context._sent = context.arg;
8152 else if (context.method === "throw") {
8153 if (state === GenStateSuspendedStart) {
8154 state = GenStateCompleted;
8155 throw context.arg;
8156 }
8157 context.dispatchException(context.arg);
8158 } else if (context.method === "return") context.abrupt("return", context.arg);
8159 state = GenStateExecuting;
8160 var record = tryCatch(innerFn, self, context);
8161 if (record.type === "normal") {
8162 state = context.done ? GenStateCompleted : GenStateSuspendedYield;
8163 if (record.arg === ContinueSentinel) continue;
8164 return {
8165 value: record.arg,
8166 done: context.done
8167 };
8168 } else if (record.type === "throw") {
8169 state = GenStateCompleted;
8170 context.method = "throw";
8171 context.arg = record.arg;
8172 }
8173 }
8174 };
8175 }
8176 function maybeInvokeDelegate(delegate, context) {
8177 var method = delegate.iterator[context.method];
8178 if (method === undefined$1) {
8179 context.delegate = null;
8180 if (context.method === "throw") {
8181 if (delegate.iterator["return"]) {
8182 context.method = "return";
8183 context.arg = undefined$1;
8184 maybeInvokeDelegate(delegate, context);
8185 if (context.method === "throw") return ContinueSentinel;
8186 }
8187 context.method = "throw";
8188 context.arg = /* @__PURE__ */ new TypeError("The iterator does not provide a 'throw' method");
8189 }
8190 return ContinueSentinel;
8191 }
8192 var record = tryCatch(method, delegate.iterator, context.arg);
8193 if (record.type === "throw") {
8194 context.method = "throw";
8195 context.arg = record.arg;
8196 context.delegate = null;
8197 return ContinueSentinel;
8198 }
8199 var info = record.arg;
8200 if (!info) {
8201 context.method = "throw";
8202 context.arg = /* @__PURE__ */ new TypeError("iterator result is not an object");
8203 context.delegate = null;
8204 return ContinueSentinel;
8205 }
8206 if (info.done) {
8207 context[delegate.resultName] = info.value;
8208 context.next = delegate.nextLoc;
8209 if (context.method !== "return") {
8210 context.method = "next";
8211 context.arg = undefined$1;
8212 }
8213 } else return info;
8214 context.delegate = null;
8215 return ContinueSentinel;
8216 }
8217 defineIteratorMethods(Gp);
8218 define(Gp, toStringTagSymbol, "Generator");
8219 define(Gp, iteratorSymbol, function() {
8220 return this;
8221 });
8222 define(Gp, "toString", function() {
8223 return "[object Generator]";
8224 });
8225 function pushTryEntry(locs) {
8226 var entry = { tryLoc: locs[0] };
8227 if (1 in locs) entry.catchLoc = locs[1];
8228 if (2 in locs) {
8229 entry.finallyLoc = locs[2];
8230 entry.afterLoc = locs[3];
8231 }
8232 this.tryEntries.push(entry);
8233 }
8234 function resetTryEntry(entry) {
8235 var record = entry.completion || {};
8236 record.type = "normal";
8237 delete record.arg;
8238 entry.completion = record;
8239 }
8240 function Context(tryLocsList) {
8241 this.tryEntries = [{ tryLoc: "root" }];
8242 tryLocsList.forEach(pushTryEntry, this);
8243 this.reset(true);
8244 }
8245 exports.keys = function(object) {
8246 var keys = [];
8247 for (var key in object) keys.push(key);
8248 keys.reverse();
8249 return function next() {
8250 while (keys.length) {
8251 var key = keys.pop();
8252 if (key in object) {
8253 next.value = key;
8254 next.done = false;
8255 return next;
8256 }
8257 }
8258 next.done = true;
8259 return next;
8260 };
8261 };
8262 function values(iterable) {
8263 if (iterable) {
8264 var iteratorMethod = iterable[iteratorSymbol];
8265 if (iteratorMethod) return iteratorMethod.call(iterable);
8266 if (typeof iterable.next === "function") return iterable;
8267 if (!isNaN(iterable.length)) {
8268 var i = -1;
8269 var next = function next() {
8270 while (++i < iterable.length) if (hasOwn.call(iterable, i)) {
8271 next.value = iterable[i];
8272 next.done = false;
8273 return next;
8274 }
8275 next.value = undefined$1;
8276 next.done = true;
8277 return next;
8278 };
8279 return next.next = next;
8280 }
8281 }
8282 return { next: doneResult };
8283 }
8284 exports.values = values;
8285 function doneResult() {
8286 return {
8287 value: undefined$1,
8288 done: true
8289 };
8290 }
8291 Context.prototype = {
8292 constructor: Context,
8293 reset: function(skipTempReset) {
8294 this.prev = 0;
8295 this.next = 0;
8296 this.sent = this._sent = undefined$1;
8297 this.done = false;
8298 this.delegate = null;
8299 this.method = "next";
8300 this.arg = undefined$1;
8301 this.tryEntries.forEach(resetTryEntry);
8302 if (!skipTempReset) {
8303 for (var name in this) if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) this[name] = undefined$1;
8304 }
8305 },
8306 stop: function() {
8307 this.done = true;
8308 var rootRecord = this.tryEntries[0].completion;
8309 if (rootRecord.type === "throw") throw rootRecord.arg;
8310 return this.rval;
8311 },
8312 dispatchException: function(exception) {
8313 if (this.done) throw exception;
8314 var context = this;
8315 function handle(loc, caught) {
8316 record.type = "throw";
8317 record.arg = exception;
8318 context.next = loc;
8319 if (caught) {
8320 context.method = "next";
8321 context.arg = undefined$1;
8322 }
8323 return !!caught;
8324 }
8325 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
8326 var entry = this.tryEntries[i];
8327 var record = entry.completion;
8328 if (entry.tryLoc === "root") return handle("end");
8329 if (entry.tryLoc <= this.prev) {
8330 var hasCatch = hasOwn.call(entry, "catchLoc");
8331 var hasFinally = hasOwn.call(entry, "finallyLoc");
8332 if (hasCatch && hasFinally) {
8333 if (this.prev < entry.catchLoc) return handle(entry.catchLoc, true);
8334 else if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
8335 } else if (hasCatch) {
8336 if (this.prev < entry.catchLoc) return handle(entry.catchLoc, true);
8337 } else if (hasFinally) {
8338 if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
8339 } else throw new Error("try statement without catch or finally");
8340 }
8341 }
8342 },
8343 abrupt: function(type, arg) {
8344 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
8345 var entry = this.tryEntries[i];
8346 if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
8347 var finallyEntry = entry;
8348 break;
8349 }
8350 }
8351 if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) finallyEntry = null;
8352 var record = finallyEntry ? finallyEntry.completion : {};
8353 record.type = type;
8354 record.arg = arg;
8355 if (finallyEntry) {
8356 this.method = "next";
8357 this.next = finallyEntry.finallyLoc;
8358 return ContinueSentinel;
8359 }
8360 return this.complete(record);
8361 },
8362 complete: function(record, afterLoc) {
8363 if (record.type === "throw") throw record.arg;
8364 if (record.type === "break" || record.type === "continue") this.next = record.arg;
8365 else if (record.type === "return") {
8366 this.rval = this.arg = record.arg;
8367 this.method = "return";
8368 this.next = "end";
8369 } else if (record.type === "normal" && afterLoc) this.next = afterLoc;
8370 return ContinueSentinel;
8371 },
8372 finish: function(finallyLoc) {
8373 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
8374 var entry = this.tryEntries[i];
8375 if (entry.finallyLoc === finallyLoc) {
8376 this.complete(entry.completion, entry.afterLoc);
8377 resetTryEntry(entry);
8378 return ContinueSentinel;
8379 }
8380 }
8381 },
8382 "catch": function(tryLoc) {
8383 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
8384 var entry = this.tryEntries[i];
8385 if (entry.tryLoc === tryLoc) {
8386 var record = entry.completion;
8387 if (record.type === "throw") {
8388 var thrown = record.arg;
8389 resetTryEntry(entry);
8390 }
8391 return thrown;
8392 }
8393 }
8394 throw new Error("illegal catch attempt");
8395 },
8396 delegateYield: function(iterable, resultName, nextLoc) {
8397 this.delegate = {
8398 iterator: values(iterable),
8399 resultName,
8400 nextLoc
8401 };
8402 if (this.method === "next") this.arg = undefined$1;
8403 return ContinueSentinel;
8404 }
8405 };
8406 return exports;
8407 }(module.exports);
8408 try {
8409 regeneratorRuntime = runtime;
8410 } catch (accidentalStrictMode) {
8411 if (typeof globalThis === "object") globalThis.regeneratorRuntime = runtime;
8412 else Function("r", "regeneratorRuntime = r")(runtime);
8413 }
8414 })(runtime);
8415 var _regeneratorRuntime$22 = runtime.exports;
8416 /**
8417 * Generate SVG Path tag from the given points
8418 */
8419 var SvgPath = function SvgPath(_ref) {
8420 var paths = _ref.paths;
8421 var id = _ref.id;
8422 var strokeWidth = _ref.strokeWidth;
8423 var strokeColor = _ref.strokeColor;
8424 var _ref$command = _ref.command;
8425 var command = _ref$command === void 0 ? bezierCommand : _ref$command;
8426 if (paths.length === 1) {
8427 var _paths$ = paths[0];
8428 var x = _paths$.x;
8429 var y = _paths$.y;
8430 var radius = strokeWidth / 2;
8431 return react.createElement("circle", {
8432 key: id,
8433 id,
8434 cx: x,
8435 cy: y,
8436 r: radius,
8437 stroke: strokeColor,
8438 fill: strokeColor
8439 });
8440 }
8441 var d = paths.reduce(function(acc, point, i, a) {
8442 return i === 0 ? "M " + point.x + "," + point.y : acc + " " + command(point, i, a);
8443 }, "");
8444 return react.createElement("path", {
8445 key: id,
8446 id,
8447 d,
8448 fill: "none",
8449 strokeLinecap: "round",
8450 stroke: strokeColor,
8451 strokeWidth
8452 });
8453 };
8454 var line = function line(pointA, pointB) {
8455 var lengthX = pointB.x - pointA.x;
8456 var lengthY = pointB.y - pointA.y;
8457 return {
8458 length: Math.sqrt(Math.pow(lengthX, 2) + Math.pow(lengthY, 2)),
8459 angle: Math.atan2(lengthY, lengthX)
8460 };
8461 };
8462 var controlPoint = function controlPoint(controlPoints) {
8463 var current = controlPoints.current;
8464 var next = controlPoints.next;
8465 var previous = controlPoints.previous;
8466 var reverse = controlPoints.reverse;
8467 var p = previous || current;
8468 var n = next || current;
8469 var smoothing = .2;
8470 var o = line(p, n);
8471 var angle = o.angle + (reverse ? Math.PI : 0);
8472 var length = o.length * smoothing;
8473 return [current.x + Math.cos(angle) * length, current.y + Math.sin(angle) * length];
8474 };
8475 var bezierCommand = function bezierCommand(point, i, a) {
8476 var cpsX = null;
8477 var cpsY = null;
8478 switch (i) {
8479 case 0:
8480 var _controlPoint = controlPoint({ current: point });
8481 cpsX = _controlPoint[0];
8482 cpsY = _controlPoint[1];
8483 break;
8484 case 1:
8485 var _controlPoint2 = controlPoint({
8486 current: a[i - 1],
8487 next: point
8488 });
8489 cpsX = _controlPoint2[0];
8490 cpsY = _controlPoint2[1];
8491 break;
8492 default:
8493 var _controlPoint3 = controlPoint({
8494 current: a[i - 1],
8495 previous: a[i - 2],
8496 next: point
8497 });
8498 cpsX = _controlPoint3[0];
8499 cpsY = _controlPoint3[1];
8500 break;
8501 }
8502 var _controlPoint4 = controlPoint({
8503 current: point,
8504 previous: a[i - 1],
8505 next: a[i + 1],
8506 reverse: true
8507 });
8508 var cpeX = _controlPoint4[0];
8509 var cpeY = _controlPoint4[1];
8510 return "C " + cpsX + "," + cpsY + " " + cpeX + "," + cpeY + " " + point.x + ", " + point.y;
8511 };
8512 var Paths = function Paths(_ref2) {
8513 var id = _ref2.id;
8514 var paths = _ref2.paths;
8515 return react.createElement(react.Fragment, null, paths.map(function(path, index) {
8516 return react.createElement(SvgPath, {
8517 key: id + "__" + index,
8518 paths: path.paths,
8519 id: id + "__" + index,
8520 strokeWidth: path.strokeWidth,
8521 strokeColor: path.strokeColor,
8522 command: bezierCommand
8523 });
8524 }));
8525 };
8526 var loadImage = function loadImage(url) {
8527 return new Promise(function(resolve, reject) {
8528 var img = new Image();
8529 img.addEventListener("load", function() {
8530 if (img.width > 0) resolve(img);
8531 reject("Image not found");
8532 });
8533 img.addEventListener("error", function(err) {
8534 return reject(err);
8535 });
8536 img.src = url;
8537 img.setAttribute("crossorigin", "anonymous");
8538 });
8539 };
8540 function getCanvasWithViewBox(canvas) {
8541 var _canvas$firstChild;
8542 var svgCanvas = (_canvas$firstChild = canvas.firstChild) == null ? void 0 : _canvas$firstChild.cloneNode(true);
8543 var width = canvas.offsetWidth;
8544 var height = canvas.offsetHeight;
8545 svgCanvas.setAttribute("viewBox", "0 0 " + width + " " + height);
8546 svgCanvas.setAttribute("width", width.toString());
8547 svgCanvas.setAttribute("height", height.toString());
8548 return {
8549 svgCanvas,
8550 width,
8551 height
8552 };
8553 }
8554 var Canvas = /*#__PURE__*/ react.forwardRef(function(props, ref) {
8555 var paths = props.paths;
8556 var isDrawing = props.isDrawing;
8557 var onPointerDown = props.onPointerDown;
8558 var onPointerMove = props.onPointerMove;
8559 var onPointerUp = props.onPointerUp;
8560 var _props$id = props.id;
8561 var id = _props$id === void 0 ? "react-sketch-canvas" : _props$id;
8562 var _props$width = props.width;
8563 var width = _props$width === void 0 ? "100%" : _props$width;
8564 var _props$height = props.height;
8565 var height = _props$height === void 0 ? "100%" : _props$height;
8566 var _props$className = props.className;
8567 var className = _props$className === void 0 ? "react-sketch-canvas" : _props$className;
8568 var _props$canvasColor = props.canvasColor;
8569 var canvasColor = _props$canvasColor === void 0 ? "red" : _props$canvasColor;
8570 var _props$backgroundImag = props.backgroundImage;
8571 var backgroundImage = _props$backgroundImag === void 0 ? "" : _props$backgroundImag;
8572 var _props$exportWithBack = props.exportWithBackgroundImage;
8573 var exportWithBackgroundImage = _props$exportWithBack === void 0 ? false : _props$exportWithBack;
8574 var _props$preserveBackgr = props.preserveBackgroundImageAspectRatio;
8575 var preserveBackgroundImageAspectRatio = _props$preserveBackgr === void 0 ? "none" : _props$preserveBackgr;
8576 var _props$allowOnlyPoint = props.allowOnlyPointerType;
8577 var allowOnlyPointerType = _props$allowOnlyPoint === void 0 ? "all" : _props$allowOnlyPoint;
8578 var _props$style = props.style;
8579 var style = _props$style === void 0 ? {
8580 border: "0.0625rem solid #9c9c9c",
8581 borderRadius: "0.25rem"
8582 } : _props$style;
8583 var _props$svgStyle = props.svgStyle;
8584 var svgStyle = _props$svgStyle === void 0 ? {} : _props$svgStyle;
8585 var canvasRef = react.useRef(null);
8586 var getCoordinates = function getCoordinates(pointerEvent) {
8587 var _canvasRef$current;
8588 var _window$scrollX;
8589 var _window$scrollY;
8590 var boundingArea = (_canvasRef$current = canvasRef.current) == null ? void 0 : _canvasRef$current.getBoundingClientRect();
8591 var scrollLeft = (_window$scrollX = window.scrollX) != null ? _window$scrollX : 0;
8592 var scrollTop = (_window$scrollY = window.scrollY) != null ? _window$scrollY : 0;
8593 if (!boundingArea) return {
8594 x: 0,
8595 y: 0
8596 };
8597 return {
8598 x: pointerEvent.pageX - boundingArea.left - scrollLeft,
8599 y: pointerEvent.pageY - boundingArea.top - scrollTop
8600 };
8601 };
8602 var handlePointerDown = function handlePointerDown(event) {
8603 if (allowOnlyPointerType !== "all" && event.pointerType !== allowOnlyPointerType) return;
8604 if (event.pointerType === "mouse" && event.button !== 0) return;
8605 onPointerDown(getCoordinates(event));
8606 };
8607 var handlePointerMove = function handlePointerMove(event) {
8608 if (!isDrawing) return;
8609 if (allowOnlyPointerType !== "all" && event.pointerType !== allowOnlyPointerType) return;
8610 onPointerMove(getCoordinates(event));
8611 };
8612 var handlePointerUp = function handlePointerUp(event) {
8613 if (event.pointerType === "mouse" && event.button !== 0) return;
8614 if (allowOnlyPointerType !== "all" && event.pointerType !== allowOnlyPointerType) return;
8615 onPointerUp();
8616 };
8617 react.useImperativeHandle(ref, function() {
8618 return {
8619 exportImage: function exportImage(imageType) {
8620 return new Promise(/*#__PURE__*/ function() {
8621 var _ref = _asyncToGenerator(/*#__PURE__*/ _regeneratorRuntime$22.mark(function _callee(resolve, reject) {
8622 var canvas;
8623 var _getCanvasWithViewBox;
8624 var svgCanvas;
8625 var _width;
8626 var _height;
8627 var canvasSketch;
8628 var loadImagePromises;
8629 var img;
8630 return _regeneratorRuntime$22.wrap(function _callee$(_context) {
8631 while (1) switch (_context.prev = _context.next) {
8632 case 0:
8633 _context.prev = 0;
8634 canvas = canvasRef.current;
8635 if (canvas) {
8636 _context.next = 4;
8637 break;
8638 }
8639 throw Error("Canvas not rendered yet");
8640 case 4:
8641 _getCanvasWithViewBox = getCanvasWithViewBox(canvas), svgCanvas = _getCanvasWithViewBox.svgCanvas, _width = _getCanvasWithViewBox.width, _height = _getCanvasWithViewBox.height;
8642 canvasSketch = "data:image/svg+xml;base64," + btoa(svgCanvas.outerHTML);
8643 _context.next = 8;
8644 return loadImage(canvasSketch);
8645 case 8:
8646 _context.t0 = _context.sent;
8647 loadImagePromises = [_context.t0];
8648 if (!exportWithBackgroundImage) {
8649 _context.next = 21;
8650 break;
8651 }
8652 _context.prev = 11;
8653 _context.next = 14;
8654 return loadImage(backgroundImage);
8655 case 14:
8656 img = _context.sent;
8657 loadImagePromises.push(img);
8658 _context.next = 21;
8659 break;
8660 case 18:
8661 _context.prev = 18;
8662 _context.t1 = _context["catch"](11);
8663 console.warn("exportWithBackgroundImage props is set without a valid background image URL. This option is ignored");
8664 case 21:
8665 Promise.all(loadImagePromises).then(function(images) {
8666 var renderCanvas = document.createElement("canvas");
8667 renderCanvas.setAttribute("width", _width.toString());
8668 renderCanvas.setAttribute("height", _height.toString());
8669 var context = renderCanvas.getContext("2d");
8670 if (!context) throw Error("Canvas not rendered yet");
8671 images.reverse().forEach(function(image) {
8672 context.drawImage(image, 0, 0);
8673 });
8674 resolve(renderCanvas.toDataURL("image/" + imageType));
8675 })["catch"](function(e) {
8676 throw e;
8677 });
8678 _context.next = 27;
8679 break;
8680 case 24:
8681 _context.prev = 24;
8682 _context.t2 = _context["catch"](0);
8683 reject(_context.t2);
8684 case 27:
8685 case "end": return _context.stop();
8686 }
8687 }, _callee, null, [[0, 24], [11, 18]]);
8688 }));
8689 return function(_x, _x2) {
8690 return _ref.apply(this, arguments);
8691 };
8692 }());
8693 },
8694 exportSvg: function exportSvg() {
8695 return new Promise(function(resolve, reject) {
8696 try {
8697 var _canvasRef$current2;
8698 var canvas = (_canvasRef$current2 = canvasRef.current) != null ? _canvasRef$current2 : null;
8699 if (canvas !== null) {
8700 var _svgCanvas$querySelec;
8701 var _svgCanvas$querySelec2;
8702 var svgCanvas = getCanvasWithViewBox(canvas).svgCanvas;
8703 if (exportWithBackgroundImage) {
8704 resolve(svgCanvas.outerHTML);
8705 return;
8706 }
8707 (_svgCanvas$querySelec = svgCanvas.querySelector("#" + id + "__background")) == null || _svgCanvas$querySelec.remove();
8708 (_svgCanvas$querySelec2 = svgCanvas.querySelector("#" + id + "__canvas-background")) == null || _svgCanvas$querySelec2.setAttribute("fill", canvasColor);
8709 resolve(svgCanvas.outerHTML);
8710 }
8711 reject(/* @__PURE__ */ new Error("Canvas not loaded"));
8712 } catch (e) {
8713 reject(e);
8714 }
8715 });
8716 }
8717 };
8718 });
8719 react.useEffect(function() {
8720 document.addEventListener("pointerup", handlePointerUp);
8721 return function() {
8722 document.removeEventListener("pointerup", handlePointerUp);
8723 };
8724 }, [handlePointerUp]);
8725 var eraserPaths = paths.filter(function(path) {
8726 return !path.drawMode;
8727 });
8728 var currentGroup = 0;
8729 var pathGroups = paths.reduce(function(arrayGroup, path) {
8730 if (!path.drawMode) {
8731 currentGroup += 1;
8732 return arrayGroup;
8733 }
8734 if (arrayGroup[currentGroup] === void 0) arrayGroup[currentGroup] = [];
8735 arrayGroup[currentGroup].push(path);
8736 return arrayGroup;
8737 }, [[]]);
8738 return react.createElement("div", {
8739 role: "presentation",
8740 ref: canvasRef,
8741 className,
8742 style: _extends({
8743 touchAction: "none",
8744 width,
8745 height
8746 }, style),
8747 "touch-action": "none",
8748 onPointerDown: handlePointerDown,
8749 onPointerMove: handlePointerMove,
8750 onPointerUp: handlePointerUp
8751 }, react.createElement("svg", {
8752 version: "1.1",
8753 baseProfile: "full",
8754 xmlns: "http://www.w3.org/2000/svg",
8755 xmlnsXlink: "http://www.w3.org/1999/xlink",
8756 style: _extends({
8757 width: "100%",
8758 height: "100%"
8759 }, svgStyle),
8760 id
8761 }, react.createElement("g", {
8762 id: id + "__eraser-stroke-group",
8763 display: "none"
8764 }, react.createElement("rect", {
8765 id: id + "__mask-background",
8766 x: "0",
8767 y: "0",
8768 width: "100%",
8769 height: "100%",
8770 fill: "white"
8771 }), eraserPaths.map(function(eraserPath, i) {
8772 return react.createElement(SvgPath, {
8773 key: id + "__eraser-" + i,
8774 id: id + "__eraser-" + i,
8775 paths: eraserPath.paths,
8776 strokeColor: "#000000",
8777 strokeWidth: eraserPath.strokeWidth
8778 });
8779 })), react.createElement("defs", null, backgroundImage && react.createElement("pattern", {
8780 id: id + "__background",
8781 x: "0",
8782 y: "0",
8783 width: "100%",
8784 height: "100%",
8785 patternUnits: "userSpaceOnUse"
8786 }, react.createElement("image", {
8787 x: "0",
8788 y: "0",
8789 width: "100%",
8790 height: "100%",
8791 xlinkHref: backgroundImage,
8792 preserveAspectRatio: preserveBackgroundImageAspectRatio
8793 })), eraserPaths.map(function(_, i) {
8794 return react.createElement("mask", {
8795 id: id + "__eraser-mask-" + i,
8796 key: id + "__eraser-mask-" + i,
8797 maskUnits: "userSpaceOnUse"
8798 }, react.createElement("use", { href: "#" + id + "__mask-background" }), Array.from({ length: eraserPaths.length - i }, function(_, j) {
8799 return j + i;
8800 }).map(function(k) {
8801 return react.createElement("use", {
8802 key: k.toString(),
8803 href: "#" + id + "__eraser-" + k.toString()
8804 });
8805 }));
8806 })), react.createElement("g", { id: id + "__canvas-background-group" }, react.createElement("rect", {
8807 id: id + "__canvas-background",
8808 x: "0",
8809 y: "0",
8810 width: "100%",
8811 height: "100%",
8812 fill: backgroundImage ? "url(#" + id + "__background)" : canvasColor
8813 })), pathGroups.map(function(pathGroup, i) {
8814 return react.createElement("g", {
8815 id: id + "__stroke-group-" + i,
8816 key: id + "__stroke-group-" + i,
8817 mask: "url(#" + id + "__eraser-mask-" + i + ")"
8818 }, react.createElement(Paths, {
8819 id,
8820 paths: pathGroup
8821 }));
8822 })));
8823 });
8824 var ReactSketchCanvas = /*#__PURE__*/ react.forwardRef(function(props, ref) {
8825 var _props$id = props.id;
8826 var id = _props$id === void 0 ? "react-sketch-canvas" : _props$id;
8827 var _props$width = props.width;
8828 var width = _props$width === void 0 ? "100%" : _props$width;
8829 var _props$height = props.height;
8830 var height = _props$height === void 0 ? "100%" : _props$height;
8831 var _props$className = props.className;
8832 var className = _props$className === void 0 ? "" : _props$className;
8833 var _props$canvasColor = props.canvasColor;
8834 var canvasColor = _props$canvasColor === void 0 ? "white" : _props$canvasColor;
8835 var _props$strokeColor = props.strokeColor;
8836 var strokeColor = _props$strokeColor === void 0 ? "red" : _props$strokeColor;
8837 var _props$backgroundImag = props.backgroundImage;
8838 var backgroundImage = _props$backgroundImag === void 0 ? "" : _props$backgroundImag;
8839 var _props$exportWithBack = props.exportWithBackgroundImage;
8840 var exportWithBackgroundImage = _props$exportWithBack === void 0 ? false : _props$exportWithBack;
8841 var _props$preserveBackgr = props.preserveBackgroundImageAspectRatio;
8842 var preserveBackgroundImageAspectRatio = _props$preserveBackgr === void 0 ? "none" : _props$preserveBackgr;
8843 var _props$strokeWidth = props.strokeWidth;
8844 var strokeWidth = _props$strokeWidth === void 0 ? 4 : _props$strokeWidth;
8845 var _props$eraserWidth = props.eraserWidth;
8846 var eraserWidth = _props$eraserWidth === void 0 ? 8 : _props$eraserWidth;
8847 var _props$allowOnlyPoint = props.allowOnlyPointerType;
8848 var allowOnlyPointerType = _props$allowOnlyPoint === void 0 ? "all" : _props$allowOnlyPoint;
8849 var _props$style = props.style;
8850 var style = _props$style === void 0 ? {
8851 border: "0.0625rem solid #9c9c9c",
8852 borderRadius: "0.25rem"
8853 } : _props$style;
8854 var _props$svgStyle = props.svgStyle;
8855 var svgStyle = _props$svgStyle === void 0 ? {} : _props$svgStyle;
8856 var _props$onChange = props.onChange;
8857 var onChange = _props$onChange === void 0 ? function(_paths) {} : _props$onChange;
8858 var _props$onStroke = props.onStroke;
8859 var onStroke = _props$onStroke === void 0 ? function(_path, _isEraser) {} : _props$onStroke;
8860 var _props$withTimestamp = props.withTimestamp;
8861 var withTimestamp = _props$withTimestamp === void 0 ? false : _props$withTimestamp;
8862 var svgCanvas = react.createRef();
8863 var _React$useState = react.useState(true);
8864 var drawMode = _React$useState[0];
8865 var setDrawMode = _React$useState[1];
8866 var _React$useState2 = react.useState(false);
8867 var isDrawing = _React$useState2[0];
8868 var setIsDrawing = _React$useState2[1];
8869 var _React$useState3 = react.useState([]);
8870 var resetStack = _React$useState3[0];
8871 var setResetStack = _React$useState3[1];
8872 var _React$useState4 = react.useState([]);
8873 var undoStack = _React$useState4[0];
8874 var setUndoStack = _React$useState4[1];
8875 var _React$useState5 = react.useState([]);
8876 var currentPaths = _React$useState5[0];
8877 var setCurrentPaths = _React$useState5[1];
8878 var liftStrokeUp = react.useCallback(function() {
8879 var _currentPaths$slice$;
8880 var _currentPaths$slice;
8881 var lastStroke = (_currentPaths$slice$ = (_currentPaths$slice = currentPaths.slice(-1)) == null ? void 0 : _currentPaths$slice[0]) != null ? _currentPaths$slice$ : null;
8882 if (lastStroke === null) {
8883 console.warn("No stroke found!");
8884 return;
8885 }
8886 onStroke(lastStroke, !lastStroke.drawMode);
8887 }, [isDrawing]);
8888 react.useEffect(function() {
8889 liftStrokeUp();
8890 }, [isDrawing]);
8891 react.useEffect(function() {
8892 onChange(currentPaths);
8893 }, [currentPaths]);
8894 react.useImperativeHandle(ref, function() {
8895 return {
8896 eraseMode: function eraseMode(erase) {
8897 setDrawMode(!erase);
8898 },
8899 clearCanvas: function clearCanvas() {
8900 setResetStack([].concat(currentPaths));
8901 setCurrentPaths([]);
8902 },
8903 undo: function undo() {
8904 if (resetStack.length !== 0) {
8905 setCurrentPaths([].concat(resetStack));
8906 setResetStack([]);
8907 return;
8908 }
8909 setUndoStack(function(undoStack) {
8910 return [].concat(undoStack, currentPaths.slice(-1));
8911 });
8912 setCurrentPaths(function(currentPaths) {
8913 return currentPaths.slice(0, -1);
8914 });
8915 },
8916 redo: function redo() {
8917 if (undoStack.length === 0) return;
8918 setCurrentPaths(function(currentPaths) {
8919 return [].concat(currentPaths, undoStack.slice(-1));
8920 });
8921 setUndoStack(function(undoStack) {
8922 return undoStack.slice(0, -1);
8923 });
8924 },
8925 exportImage: function exportImage(imageType) {
8926 var _svgCanvas$current;
8927 var exportImage = (_svgCanvas$current = svgCanvas.current) == null ? void 0 : _svgCanvas$current.exportImage;
8928 if (!exportImage) throw Error("Export function called before canvas loaded");
8929 else return exportImage(imageType);
8930 },
8931 exportSvg: function exportSvg() {
8932 return new Promise(function(resolve, reject) {
8933 var _svgCanvas$current2;
8934 var exportSvg = (_svgCanvas$current2 = svgCanvas.current) == null ? void 0 : _svgCanvas$current2.exportSvg;
8935 if (!exportSvg) reject(Error("Export function called before canvas loaded"));
8936 else exportSvg().then(function(data) {
8937 resolve(data);
8938 })["catch"](function(e) {
8939 reject(e);
8940 });
8941 });
8942 },
8943 exportPaths: function exportPaths() {
8944 return new Promise(function(resolve, reject) {
8945 try {
8946 resolve(currentPaths);
8947 } catch (e) {
8948 reject(e);
8949 }
8950 });
8951 },
8952 loadPaths: function loadPaths(paths) {
8953 setCurrentPaths(function(currentPaths) {
8954 return [].concat(currentPaths, paths);
8955 });
8956 },
8957 getSketchingTime: function getSketchingTime() {
8958 return new Promise(function(resolve, reject) {
8959 if (!withTimestamp) reject(/* @__PURE__ */ new Error("Set 'withTimestamp' prop to get sketching time"));
8960 try {
8961 resolve(currentPaths.reduce(function(totalSketchingTime, path) {
8962 var _path$startTimestamp;
8963 var _path$endTimestamp;
8964 var startTimestamp = (_path$startTimestamp = path.startTimestamp) != null ? _path$startTimestamp : 0;
8965 return totalSketchingTime + (((_path$endTimestamp = path.endTimestamp) != null ? _path$endTimestamp : 0) - startTimestamp);
8966 }, 0));
8967 } catch (e) {
8968 reject(e);
8969 }
8970 });
8971 },
8972 resetCanvas: function resetCanvas() {
8973 setResetStack([]);
8974 setUndoStack([]);
8975 setCurrentPaths([]);
8976 }
8977 };
8978 });
8979 return react.createElement(Canvas, {
8980 ref: svgCanvas,
8981 id,
8982 width,
8983 height,
8984 className,
8985 canvasColor,
8986 backgroundImage,
8987 exportWithBackgroundImage,
8988 preserveBackgroundImageAspectRatio,
8989 allowOnlyPointerType,
8990 style,
8991 svgStyle,
8992 paths: currentPaths,
8993 isDrawing,
8994 onPointerDown: function handlePointerDown(point) {
8995 setIsDrawing(true);
8996 setUndoStack([]);
8997 var stroke = {
8998 drawMode,
8999 strokeColor: drawMode ? strokeColor : "#000000",
9000 strokeWidth: drawMode ? strokeWidth : eraserWidth,
9001 paths: [point]
9002 };
9003 if (withTimestamp) stroke = _extends({}, stroke, {
9004 startTimestamp: Date.now(),
9005 endTimestamp: 0
9006 });
9007 setCurrentPaths(function(currentPaths) {
9008 return [].concat(currentPaths, [stroke]);
9009 });
9010 },
9011 onPointerMove: function handlePointerMove(point) {
9012 if (!isDrawing) return;
9013 var currentStroke = currentPaths.slice(-1)[0];
9014 var updatedStroke = _extends({}, currentStroke, { paths: [].concat(currentStroke.paths, [point]) });
9015 setCurrentPaths(function(currentPaths) {
9016 return [].concat(currentPaths.slice(0, -1), [updatedStroke]);
9017 });
9018 },
9019 onPointerUp: function handlePointerUp() {
9020 var _currentPaths$slice$2;
9021 var _currentPaths$slice2;
9022 if (!isDrawing) return;
9023 setIsDrawing(false);
9024 if (!withTimestamp) return;
9025 var currentStroke = (_currentPaths$slice$2 = (_currentPaths$slice2 = currentPaths.slice(-1)) == null ? void 0 : _currentPaths$slice2[0]) != null ? _currentPaths$slice$2 : null;
9026 if (currentStroke === null) return;
9027 var updatedStroke = _extends({}, currentStroke, { endTimestamp: Date.now() });
9028 setCurrentPaths(function(currentPaths) {
9029 return [].concat(currentPaths.slice(0, -1), [updatedStroke]);
9030 });
9031 }
9032 });
9033 });
9034
9035 //#endregion
9036 //#region modules/ai/assets/js/editor/icons/undo-icon.js
9037 init_extends();
9038 var UndoIcon = react.default.forwardRef(function(props, ref) {
9039 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", { d: "M9.53033 6.53033C9.82322 6.23744 9.82322 5.76256 9.53033 5.46967C9.23744 5.17678 8.76256 5.17678 8.46967 5.46967L4.46967 9.46967C4.39776 9.54158 4.34351 9.62445 4.30691 9.71291C4.27024 9.80134 4.25 9.89831 4.25 10C4.25 10.1017 4.27024 10.1987 4.30691 10.2871C4.34351 10.3755 4.39776 10.4584 4.46967 10.5303L8.46967 14.5303C8.76256 14.8232 9.23744 14.8232 9.53033 14.5303C9.82322 14.2374 9.82322 13.7626 9.53033 13.4697L6.81066 10.75H16C16.862 10.75 17.6886 11.0924 18.2981 11.7019C18.9076 12.3114 19.25 13.138 19.25 14C19.25 14.862 18.9076 15.6886 18.2981 16.2981C17.6886 16.9076 16.862 17.25 16 17.25H15C14.5858 17.25 14.25 17.5858 14.25 18C14.25 18.4142 14.5858 18.75 15 18.75H16C17.2598 18.75 18.468 18.2496 19.3588 17.3588C20.2496 16.468 20.75 15.2598 20.75 14C20.75 12.7402 20.2496 11.532 19.3588 10.6412C18.468 9.75044 17.2598 9.25 16 9.25H6.81066L9.53033 6.53033Z" }));
9040 });
9041
9042 //#endregion
9043 //#region modules/ai/assets/js/editor/icons/redo-icon.js
9044 init_extends();
9045 var RedoIcon = react.default.forwardRef(function(props, ref) {
9046 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", { d: "M15.5303 5.46967C15.2374 5.17678 14.7626 5.17678 14.4697 5.46967C14.1768 5.76256 14.1768 6.23744 14.4697 6.53033L17.1893 9.25H8C6.74022 9.25 5.53204 9.75044 4.64124 10.6412C3.75044 11.532 3.25 12.7402 3.25 14C3.25 15.2598 3.75044 16.468 4.64124 17.3588C5.53204 18.2496 6.74022 18.75 8 18.75H9C9.41421 18.75 9.75 18.4142 9.75 18C9.75 17.5858 9.41421 17.25 9 17.25H8C7.13805 17.25 6.3114 16.9076 5.7019 16.2981C5.09241 15.6886 4.75 14.862 4.75 14C4.75 13.138 5.09241 12.3114 5.7019 11.7019C6.3114 11.0924 7.13805 10.75 8 10.75H17.1893L14.4697 13.4697C14.1768 13.7626 14.1768 14.2374 14.4697 14.5303C14.7626 14.8232 15.2374 14.8232 15.5303 14.5303L19.5303 10.5303C19.6768 10.3839 19.75 10.1919 19.75 10C19.75 9.89831 19.7298 9.80134 19.6931 9.71291C19.6565 9.62445 19.6022 9.54158 19.5303 9.46967L15.5303 5.46967Z" }));
9047 });
9048
9049 //#endregion
9050 //#region modules/ai/assets/js/editor/pages/form-media/views/in-painting/in-painting-content.js
9051 init_asyncToGenerator();
9052 init_slicedToArray();
9053 var STROKE_SELECT_WIDTH$1 = 120;
9054 var BRUSH_COLOR$1 = "rgba(255, 255, 255)";
9055 var CANVAS_COLOR$1 = "rgba(0, 0, 0)";
9056 var StyledUndoIcon$1 = (0, _elementor_ui.withDirection)(UndoIcon);
9057 var StyledRedoIcon$1 = (0, _elementor_ui.withDirection)(RedoIcon);
9058 var BrushCursor$1 = (0, _elementor_ui.styled)(_elementor_ui.Box, { shouldForwardProp: function shouldForwardProp(prop) {
9059 return "size" === prop;
9060 } })(function(_ref) {
9061 var theme = _ref.theme;
9062 var size = _ref.size;
9063 return {
9064 position: "absolute",
9065 width: size,
9066 height: size,
9067 borderRadius: "50%",
9068 backgroundColor: BRUSH_COLOR$1,
9069 pointerEvents: "none",
9070 transform: "translate(".concat("rtl" === theme.direction ? "50%" : "-50%", ", -50%)"),
9071 border: "1px solid #fff"
9072 };
9073 });
9074 var BrishSizeIcon$1 = (0, _elementor_ui.styled)(_elementor_ui.Box, { shouldForwardProp: function shouldForwardProp(prop) {
9075 return "size" === prop;
9076 } })(function(_ref2) {
9077 var theme = _ref2.theme;
9078 var size = _ref2.size;
9079 return {
9080 width: size / 2,
9081 height: size / 2,
9082 borderRadius: "50%",
9083 backgroundColor: theme.palette.secondary.main
9084 };
9085 });
9086 var InPaintingContent = function InPaintingContent(_ref3) {
9087 var editImage = _ref3.editImage;
9088 var setMask = _ref3.setMask;
9089 var setIsCanvasChanged = _ref3.setIsCanvasChanged;
9090 var canvasWidth = _ref3.width;
9091 var canvasHeight = _ref3.height;
9092 var sketchRef = (0, react.useRef)();
9093 var _useState2 = _slicedToArray((0, react.useState)(30), 2);
9094 var stroke = _useState2[0];
9095 var setStroke = _useState2[1];
9096 var brushCursorRef = (0, react.useRef)();
9097 (0, react.useEffect)(function() {
9098 var canvas = document.querySelector(".eui-in-painting-canvas");
9099 var positionElement = function positionElement(e) {
9100 var _canvas$getBoundingCl = canvas.getBoundingClientRect();
9101 var left = _canvas$getBoundingCl.left;
9102 var top = _canvas$getBoundingCl.top;
9103 var width = _canvas$getBoundingCl.width;
9104 var height = _canvas$getBoundingCl.height;
9105 var x = e.clientX - left;
9106 var y = e.clientY - top;
9107 if (x > 0 && x < width && y > 0 && y < height) {
9108 brushCursorRef.current.style.left = "".concat(x, "px");
9109 brushCursorRef.current.style.top = "".concat(y, "px");
9110 }
9111 };
9112 window.addEventListener("mousemove", positionElement);
9113 return function() {
9114 window.removeEventListener("mousemove", positionElement);
9115 };
9116 }, [stroke]);
9117 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
9118 alignItems: "flex-start",
9119 spacing: .5,
9120 flexGrow: 1
9121 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
9122 width: "100%",
9123 direction: "row",
9124 spacing: 3,
9125 alignSelf: "center",
9126 justifyContent: "center",
9127 sx: { marginBottom: "20px !important" }
9128 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
9129 direction: "row",
9130 gap: 1
9131 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: (0, _wordpress_i18n.__)("Undo", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
9132 variant: "outlined",
9133 color: "secondary",
9134 onClick: function onClick() {
9135 return sketchRef.current.undo();
9136 },
9137 sx: { px: 0 }
9138 }, /*#__PURE__*/ react.default.createElement(StyledUndoIcon$1, null))), /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: (0, _wordpress_i18n.__)("Redo", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
9139 variant: "outlined",
9140 color: "secondary",
9141 onClick: function onClick() {
9142 return sketchRef.current.redo();
9143 },
9144 sx: { px: 0 }
9145 }, /*#__PURE__*/ react.default.createElement(StyledRedoIcon$1, null)))), /*#__PURE__*/ react.default.createElement(_elementor_ui.FormControl, {
9146 size: "small",
9147 color: "secondary",
9148 sx: { minWidth: STROKE_SELECT_WIDTH$1 }
9149 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.InputLabel, { id: "stroke" }, "Stroke"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Select, {
9150 autoWidth: true,
9151 label: "Stroke",
9152 value: stroke,
9153 id: "demo-simple-select",
9154 labelId: "demo-simple-select-label",
9155 onChange: function onChange(e) {
9156 return setStroke(e.target.value);
9157 },
9158 MenuProps: {
9159 PaperProps: { sx: { maxWidth: STROKE_SELECT_WIDTH$1 } },
9160 MenuListProps: { sx: { minWidth: STROKE_SELECT_WIDTH$1 } }
9161 },
9162 sx: { "& .MuiSelect-select .MuiListItemIcon-root": {
9163 mr: .25,
9164 width: "initial",
9165 minWidth: "initial",
9166 justifyContent: "flex-start"
9167 } }
9168 }, [
9169 10,
9170 20,
9171 30,
9172 40,
9173 50
9174 ].map(function(value) {
9175 return /*#__PURE__*/ react.default.createElement(_elementor_ui.MenuItem, {
9176 key: "stroke-width-option-" + value,
9177 value
9178 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
9179 direction: "row",
9180 alignItems: "center",
9181 gap: 1
9182 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemIcon, { sx: {
9183 width: 30,
9184 display: "flex",
9185 justifyContent: "center"
9186 } }, /*#__PURE__*/ react.default.createElement(BrishSizeIcon$1, { size: value })), /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemText, null, value)));
9187 })))), /*#__PURE__*/ react.default.createElement("div", { style: {
9188 margin: "0 auto",
9189 position: "relative",
9190 cursor: "none",
9191 overflow: "hidden"
9192 } }, /*#__PURE__*/ react.default.createElement(BrushCursor$1, {
9193 ref: brushCursorRef,
9194 size: stroke
9195 }), /*#__PURE__*/ react.default.createElement(ReactSketchCanvas, {
9196 className: "eui-in-painting-canvas",
9197 withViewBox: true,
9198 ref: sketchRef,
9199 height: canvasHeight + "px",
9200 width: canvasWidth + "px",
9201 strokeWidth: stroke,
9202 strokeColor: BRUSH_COLOR$1,
9203 canvasColor: CANVAS_COLOR$1,
9204 backgroundImage: editImage.url,
9205 onStroke: function onStroke() {
9206 return setIsCanvasChanged(true);
9207 },
9208 onChange: /*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee() {
9209 var svg;
9210 return import_regenerator$2.default.wrap(function(_context) {
9211 while (1) switch (_context.prev = _context.next) {
9212 case 0:
9213 _context.next = 1;
9214 return sketchRef.current.exportSvg();
9215 case 1:
9216 svg = _context.sent;
9217 setMask(svg);
9218 case 2:
9219 case "end": return _context.stop();
9220 }
9221 }, _callee);
9222 }))
9223 })));
9224 };
9225 InPaintingContent.propTypes = {
9226 setMask: import_prop_types$7.default.func.isRequired,
9227 setIsCanvasChanged: import_prop_types$7.default.func.isRequired,
9228 width: import_prop_types$7.default.number.isRequired,
9229 height: import_prop_types$7.default.number.isRequired,
9230 editImage: import_prop_types$7.default.object.isRequired
9231 };
9232
9233 //#endregion
9234 //#region modules/ai/assets/js/editor/pages/form-media/views/in-painting/hooks/use-in-painting.js
9235 init_api();
9236 var useInPainting = function useInPainting(initialValue) {
9237 return useImagePrompt(function fetchAction(payload) {
9238 return getImageToImageMaskGeneration(payload);
9239 }, initialValue);
9240 };
9241
9242 //#endregion
9243 //#region modules/ai/assets/js/editor/pages/form-media/views/in-painting/index.js
9244 init_asyncToGenerator();
9245 init_slicedToArray();
9246 init_requests_ids();
9247 var InPainting = function InPainting() {
9248 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
9249 var prompt = _useState2[0];
9250 var setPrompt = _useState2[1];
9251 var setGenerate = useRequestIds().setGenerate;
9252 var _useState4 = _slicedToArray((0, react.useState)(""), 2);
9253 var mask = _useState4[0];
9254 var setMask = _useState4[1];
9255 var _useState6 = _slicedToArray((0, react.useState)(false), 2);
9256 var isCanvasChanged = _useState6[0];
9257 var setIsCanvasChanged = _useState6[1];
9258 var _usePromptSettings = usePromptSettings();
9259 var settings = _usePromptSettings.settings;
9260 var resetSettings = _usePromptSettings.resetSettings;
9261 var _useEditImage = useEditImage();
9262 var editImage = _useEditImage.editImage;
9263 var width = _useEditImage.width;
9264 var height = _useEditImage.height;
9265 var _useImageActions = useImageActions();
9266 var use = _useImageActions.use;
9267 var edit = _useImageActions.edit;
9268 var isUploading = _useImageActions.isLoading;
9269 var _useInPainting = useInPainting();
9270 var data = _useInPainting.data;
9271 var send = _useInPainting.send;
9272 var isGenerating = _useInPainting.isLoading;
9273 var error = _useInPainting.error;
9274 var reset = _useInPainting.reset;
9275 var isLoading = isGenerating || isUploading;
9276 var handleSubmit = /*#__PURE__*/ function() {
9277 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(event) {
9278 var finalPrompt;
9279 return import_regenerator$2.default.wrap(function(_context) {
9280 while (1) switch (_context.prev = _context.next) {
9281 case 0:
9282 event.preventDefault();
9283 finalPrompt = prompt || "Remove object and fill based on the surroundings";
9284 setGenerate();
9285 send({
9286 prompt: finalPrompt,
9287 settings,
9288 image: editImage,
9289 mask
9290 });
9291 case 1:
9292 case "end": return _context.stop();
9293 }
9294 }, _callee);
9295 }));
9296 return function handleSubmit(_x) {
9297 return _ref.apply(this, arguments);
9298 };
9299 }();
9300 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, null), /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
9301 primary: (0, _wordpress_i18n.__)("Generative Fill", "elementor"),
9302 secondary: (0, _wordpress_i18n.__)("Mark an area and edit it with a prompt.", "elementor")
9303 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
9304 error,
9305 onRetry: handleSubmit
9306 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(PromptField, {
9307 value: prompt,
9308 disabled: isLoading,
9309 onChange: setPrompt,
9310 placeholder: (0, _wordpress_i18n.__)("Describe what you want to generate in the marked area (English only)", "elementor")
9311 }), data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
9312 gap: 2,
9313 sx: { my: 2.5 }
9314 }, /*#__PURE__*/ react.default.createElement(GenerateAgainSubmit, { disabled: isLoading }), /*#__PURE__*/ react.default.createElement(NewPromptButton, {
9315 disabled: isLoading,
9316 onClick: function onClick() {
9317 resetSettings();
9318 setPrompt("");
9319 reset();
9320 }
9321 })) : /*#__PURE__*/ react.default.createElement(GenerateSubmit, { disabled: isLoading || !prompt || !isCanvasChanged }))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isLoading }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
9322 images: data.result,
9323 aspectRatio: editImage.aspectRatio,
9324 onUseImage: use,
9325 onEditImage: edit
9326 }) : /*#__PURE__*/ react.default.createElement(InPaintingContent, {
9327 editImage,
9328 width,
9329 height,
9330 setMask,
9331 setIsCanvasChanged
9332 })));
9333 };
9334
9335 //#endregion
9336 //#region node_modules/react-avatar-editor/dist/index.js
9337 var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9338 (function(e, t) {
9339 "object" == typeof exports && "undefined" != typeof module ? module.exports = t(require_prop_types(), (globalThis.React)) : "function" == typeof define && define.amd ? define(["prop-types", "react"], t) : (e = "undefined" != typeof globalThis ? globalThis : e || self).AvatarEditor = t(e.PropTypes, e.React);
9340 })(exports, function(e, t) {
9341 "use strict";
9342 function o(e) {
9343 return e && "object" == typeof e && "default" in e ? e : { default: e };
9344 }
9345 var n = o(e);
9346 var i = o(t);
9347 function r(e, t) {
9348 for (var o = 0; o < t.length; o++) {
9349 var n = t[o];
9350 n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, n.key, n);
9351 }
9352 }
9353 function s(e, t, o) {
9354 return t in e ? Object.defineProperty(e, t, {
9355 value: o,
9356 enumerable: !0,
9357 configurable: !0,
9358 writable: !0
9359 }) : e[t] = o, e;
9360 }
9361 function u() {
9362 return (u = Object.assign || function(e) {
9363 for (var t = 1; t < arguments.length; t++) {
9364 var o = arguments[t];
9365 for (var n in o) Object.prototype.hasOwnProperty.call(o, n) && (e[n] = o[n]);
9366 }
9367 return e;
9368 }).apply(this, arguments);
9369 }
9370 function a(t, e) {
9371 var o;
9372 var n = Object.keys(t);
9373 return Object.getOwnPropertySymbols && (o = Object.getOwnPropertySymbols(t), e && (o = o.filter(function(e) {
9374 return Object.getOwnPropertyDescriptor(t, e).enumerable;
9375 })), n.push.apply(n, o)), n;
9376 }
9377 function y(t) {
9378 for (var e = 1; e < arguments.length; e++) {
9379 var o = null != arguments[e] ? arguments[e] : {};
9380 e % 2 ? a(Object(o), !0).forEach(function(e) {
9381 s(t, e, o[e]);
9382 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(o)) : a(Object(o)).forEach(function(e) {
9383 Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(o, e));
9384 });
9385 }
9386 return t;
9387 }
9388 function h(e) {
9389 return (h = Object.setPrototypeOf ? Object.getPrototypeOf : function(e) {
9390 return e.__proto__ || Object.getPrototypeOf(e);
9391 })(e);
9392 }
9393 function c(e, t) {
9394 return (c = Object.setPrototypeOf || function(e, t) {
9395 return e.__proto__ = t, e;
9396 })(e, t);
9397 }
9398 function l(e, t) {
9399 if (null == e) return {};
9400 var o;
9401 var n = function(e, t) {
9402 if (null == e) return {};
9403 for (var o, n = {}, a = Object.keys(e), r = 0; r < a.length; r++) o = a[r], 0 <= t.indexOf(o) || (n[o] = e[o]);
9404 return n;
9405 }(e, t);
9406 if (Object.getOwnPropertySymbols) for (var a = Object.getOwnPropertySymbols(e), r = 0; r < a.length; r++) o = a[r], 0 <= t.indexOf(o) || Object.prototype.propertyIsEnumerable.call(e, o) && (n[o] = e[o]);
9407 return n;
9408 }
9409 function d(e) {
9410 if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
9411 return e;
9412 }
9413 function p(r) {
9414 var i = function() {
9415 if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
9416 if (Reflect.construct.sham) return !1;
9417 if ("function" == typeof Proxy) return !0;
9418 try {
9419 return Date.prototype.toString.call(Reflect.construct(Date, [], function() {})), !0;
9420 } catch (e) {
9421 return !1;
9422 }
9423 }();
9424 return function() {
9425 var e;
9426 var t;
9427 var o;
9428 var n;
9429 var a = h(r);
9430 return t = i ? (e = h(this).constructor, Reflect.construct(a, arguments, e)) : a.apply(this, arguments), o = this, !(n = t) || "object" != typeof n && "function" != typeof n ? d(o) : n;
9431 };
9432 }
9433 function m(e, t) {
9434 return function(e) {
9435 if (Array.isArray(e)) return e;
9436 }(e) || function(e, t) {
9437 if ("undefined" == typeof Symbol || !(Symbol.iterator in Object(e))) return;
9438 var o = [];
9439 var n = !0;
9440 var a = !1;
9441 var r = void 0;
9442 try {
9443 for (var i, s = e[Symbol.iterator](); !(n = (i = s.next()).done) && (o.push(i.value), !t || o.length !== t); n = !0);
9444 } catch (e) {
9445 a = !0, r = e;
9446 } finally {
9447 try {
9448 n || null == s.return || s.return();
9449 } finally {
9450 if (a) throw r;
9451 }
9452 }
9453 return o;
9454 }(e, t) || g(e, t) || function() {
9455 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9456 }();
9457 }
9458 function g(e, t) {
9459 if (e) {
9460 if ("string" == typeof e) return f(e, t);
9461 var o = Object.prototype.toString.call(e).slice(8, -1);
9462 return "Object" === o && e.constructor && (o = e.constructor.name), "Map" === o || "Set" === o ? Array.from(e) : "Arguments" === o || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o) ? f(e, t) : void 0;
9463 }
9464 }
9465 function f(e, t) {
9466 (null == t || t > e.length) && (t = e.length);
9467 for (var o = 0, n = new Array(t); o < t; o++) n[o] = e[o];
9468 return n;
9469 }
9470 function v(a, r) {
9471 return new Promise(function(e, t) {
9472 var o;
9473 var n = new Image();
9474 n.onload = function() {
9475 return e(n);
9476 }, n.onerror = t, !1 == (null !== (o = a) && !!o.match(/^\s*data:([a-z]+\/[a-z]+(;[a-z-]+=[a-z-]+)?)?(;base64)?,[a-z0-9!$&',()*+;=\-._~:@/?%\s]*\s*$/i)) && r && (n.crossOrigin = r), n.src = a;
9477 });
9478 }
9479 var b;
9480 var w = !("undefined" == typeof window || "undefined" == typeof navigator || !("ontouchstart" in window || 0 < navigator.msMaxTouchPoints));
9481 var M = "undefined" != typeof File;
9482 var O = {
9483 touch: {
9484 react: {
9485 down: "onTouchStart",
9486 mouseDown: "onMouseDown",
9487 drag: "onTouchMove",
9488 move: "onTouchMove",
9489 mouseMove: "onMouseMove",
9490 up: "onTouchEnd",
9491 mouseUp: "onMouseUp"
9492 },
9493 native: {
9494 down: "touchstart",
9495 mouseDown: "mousedown",
9496 drag: "touchmove",
9497 move: "touchmove",
9498 mouseMove: "mousemove",
9499 up: "touchend",
9500 mouseUp: "mouseup"
9501 }
9502 },
9503 desktop: {
9504 react: {
9505 down: "onMouseDown",
9506 drag: "onDragOver",
9507 move: "onMouseMove",
9508 up: "onMouseUp"
9509 },
9510 native: {
9511 down: "mousedown",
9512 drag: "dragStart",
9513 move: "mousemove",
9514 up: "mouseup"
9515 }
9516 }
9517 };
9518 var I = w ? O.touch : O.desktop;
9519 var P = "undefined" != typeof window && window.devicePixelRatio ? window.devicePixelRatio : 1;
9520 var C = {
9521 x: .5,
9522 y: .5
9523 };
9524 var x = function() {
9525 (function(e, t) {
9526 if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
9527 e.prototype = Object.create(t && t.prototype, { constructor: {
9528 value: e,
9529 writable: !0,
9530 configurable: !0
9531 } }), t && c(e, t);
9532 })(a, i["default"].Component);
9533 var e;
9534 var t;
9535 var o;
9536 var n = p(a);
9537 function a(e) {
9538 var v;
9539 return function(e, t) {
9540 if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
9541 }(this, a), s(d(v = n.call(this, e)), "state", {
9542 drag: !1,
9543 my: null,
9544 mx: null,
9545 image: C
9546 }), s(d(v), "handleImageReady", function(e) {
9547 var t = v.getInitialSize(e.width, e.height);
9548 t.resource = e, t.x = .5, t.y = .5, t.backgroundColor = v.props.backgroundColor, v.setState({
9549 drag: !1,
9550 image: t
9551 }, v.props.onImageReady), v.props.onLoadSuccess(t);
9552 }), s(d(v), "clearImage", function() {
9553 v.canvas.getContext("2d").clearRect(0, 0, v.canvas.width, v.canvas.height), v.setState({ image: C });
9554 }), s(d(v), "handleMouseDown", function(e) {
9555 (e = e || window.event).preventDefault(), v.setState({
9556 drag: !0,
9557 mx: null,
9558 my: null
9559 });
9560 }), s(d(v), "handleMouseUp", function() {
9561 v.state.drag && (v.setState({ drag: !1 }), v.props.onMouseUp());
9562 }), s(d(v), "handleMouseMove", function(e) {
9563 var t;
9564 var o;
9565 var n;
9566 var a;
9567 var r;
9568 var i;
9569 var s;
9570 var u;
9571 var h;
9572 var c;
9573 var l;
9574 var d;
9575 var p;
9576 var g;
9577 var f;
9578 var m;
9579 e = e || window.event, !1 !== v.state.drag && (e.preventDefault(), n = {
9580 mx: t = e.targetTouches ? e.targetTouches[0].pageX : e.clientX,
9581 my: o = e.targetTouches ? e.targetTouches[0].pageY : e.clientY
9582 }, m = v.props.rotate, m = (m %= 360) < 0 ? m + 360 : m, v.state.mx && v.state.my && (a = v.state.mx - t, r = v.state.my - o, i = v.state.image.width * v.props.scale, s = v.state.image.height * v.props.scale, h = (u = v.getCroppingRect()).x, c = u.y, h *= i, c *= s, l = function(e) {
9583 return e * (Math.PI / 180);
9584 }, d = Math.cos(l(m)), g = c + -a * (p = Math.sin(l(m))) + r * d, f = {
9585 x: (h + a * d + r * p) / i + 1 / v.props.scale * v.getXScale() / 2,
9586 y: g / s + 1 / v.props.scale * v.getYScale() / 2
9587 }, v.props.onPositionChange(f), n.image = y(y({}, v.state.image), f)), v.setState(n), v.props.onMouseMove(e));
9588 }), s(d(v), "setCanvas", function(e) {
9589 v.canvas = e;
9590 }), v.canvas = null, v;
9591 }
9592 return e = a, (t = [
9593 {
9594 key: "componentDidMount",
9595 value: function() {
9596 this.props.disableHiDPIScaling && (P = 1);
9597 var e;
9598 var t;
9599 var o = this.canvas.getContext("2d");
9600 this.props.image && this.loadImage(this.props.image), this.paint(o), document && (e = !!function() {
9601 var t = !1;
9602 try {
9603 var e = Object.defineProperty({}, "passive", { get: function() {
9604 t = !0;
9605 } });
9606 window.addEventListener("test", e, e), window.removeEventListener("test", e, e);
9607 } catch (e) {
9608 t = !1;
9609 }
9610 return t;
9611 }() && { passive: !1 }, t = I.native, document.addEventListener(t.move, this.handleMouseMove, e), document.addEventListener(t.up, this.handleMouseUp, e), w && (document.addEventListener(t.mouseMove, this.handleMouseMove, e), document.addEventListener(t.mouseUp, this.handleMouseUp, e)));
9612 }
9613 },
9614 {
9615 key: "componentDidUpdate",
9616 value: function(e, t) {
9617 this.props.image && this.props.image !== e.image || this.props.width !== e.width || this.props.height !== e.height || this.props.backgroundColor !== e.backgroundColor ? this.loadImage(this.props.image) : this.props.image || t.image === C || this.clearImage();
9618 var o = this.canvas.getContext("2d");
9619 o.clearRect(0, 0, this.canvas.width, this.canvas.height), this.paint(o), this.paintImage(o, this.state.image, this.props.border), e.image === this.props.image && e.width === this.props.width && e.height === this.props.height && e.position === this.props.position && e.scale === this.props.scale && e.rotate === this.props.rotate && t.my === this.state.my && t.mx === this.state.mx && t.image.x === this.state.image.x && t.image.y === this.state.image.y && t.backgroundColor === this.state.backgroundColor || this.props.onImageChange();
9620 }
9621 },
9622 {
9623 key: "componentWillUnmount",
9624 value: function() {
9625 var e;
9626 document && (e = I.native, document.removeEventListener(e.move, this.handleMouseMove, !1), document.removeEventListener(e.up, this.handleMouseUp, !1), w && (document.removeEventListener(e.mouseMove, this.handleMouseMove, !1), document.removeEventListener(e.mouseUp, this.handleMouseUp, !1)));
9627 }
9628 },
9629 {
9630 key: "isVertical",
9631 value: function() {
9632 return !this.props.disableCanvasRotation && this.props.rotate % 180 != 0;
9633 }
9634 },
9635 {
9636 key: "getBorders",
9637 value: function(e) {
9638 var t = 0 < arguments.length && void 0 !== e ? e : this.props.border;
9639 return Array.isArray(t) ? t : [t, t];
9640 }
9641 },
9642 {
9643 key: "getDimensions",
9644 value: function() {
9645 var e = this.props;
9646 var t = e.width;
9647 var o = e.height;
9648 var n = e.rotate;
9649 var a = e.border;
9650 var r = {};
9651 var i = m(this.getBorders(a), 2);
9652 var s = i[0];
9653 var u = i[1];
9654 var h = t;
9655 var c = o;
9656 return this.isVertical() ? (r.width = c, r.height = h) : (r.width = h, r.height = c), r.width += 2 * s, r.height += 2 * u, {
9657 canvas: r,
9658 rotate: n,
9659 width: t,
9660 height: o,
9661 border: a
9662 };
9663 }
9664 },
9665 {
9666 key: "getImage",
9667 value: function() {
9668 var e = this.getCroppingRect();
9669 var t = this.state.image;
9670 e.x *= t.resource.width, e.y *= t.resource.height, e.width *= t.resource.width, e.height *= t.resource.height;
9671 var o = document.createElement("canvas");
9672 this.isVertical() ? (o.width = e.height, o.height = e.width) : (o.width = e.width, o.height = e.height);
9673 var n = o.getContext("2d");
9674 return n.translate(o.width / 2, o.height / 2), n.rotate(this.props.rotate * Math.PI / 180), n.translate(-o.width / 2, -o.height / 2), this.isVertical() && n.translate((o.width - o.height) / 2, (o.height - o.width) / 2), t.backgroundColor && (n.fillStyle = t.backgroundColor, n.fillRect(-e.x, -e.y, t.resource.width, t.resource.height)), n.drawImage(t.resource, -e.x, -e.y), o;
9675 }
9676 },
9677 {
9678 key: "getImageScaledToCanvas",
9679 value: function() {
9680 var e = this.getDimensions();
9681 var t = e.width;
9682 var o = e.height;
9683 var n = document.createElement("canvas");
9684 return this.isVertical() ? (n.width = o, n.height = t) : (n.width = t, n.height = o), this.paintImage(n.getContext("2d"), this.state.image, 0, 1), n;
9685 }
9686 },
9687 {
9688 key: "getXScale",
9689 value: function() {
9690 var e = this.props.width / this.props.height;
9691 var t = this.state.image.width / this.state.image.height;
9692 return Math.min(1, e / t);
9693 }
9694 },
9695 {
9696 key: "getYScale",
9697 value: function() {
9698 var e = this.props.height / this.props.width;
9699 var t = this.state.image.height / this.state.image.width;
9700 return Math.min(1, e / t);
9701 }
9702 },
9703 {
9704 key: "getCroppingRect",
9705 value: function() {
9706 var e = this.props.position || {
9707 x: this.state.image.x,
9708 y: this.state.image.y
9709 };
9710 var t = 1 / this.props.scale * this.getXScale();
9711 var o = 1 / this.props.scale * this.getYScale();
9712 var n = {
9713 x: e.x - t / 2,
9714 y: e.y - o / 2,
9715 width: t,
9716 height: o
9717 };
9718 var a = 0;
9719 var r = 1 - n.width;
9720 var i = 0;
9721 var s = 1 - n.height;
9722 return (this.props.disableBoundaryChecks || 1 < t || 1 < o) && (a = -n.width, i = -n.height, s = r = 1), y(y({}, n), {}, {
9723 x: Math.max(a, Math.min(n.x, r)),
9724 y: Math.max(i, Math.min(n.y, s))
9725 });
9726 }
9727 },
9728 {
9729 key: "loadImage",
9730 value: function(e) {
9731 var t;
9732 M && e instanceof File ? this.loadingImage = (t = e, new Promise(function(o, n) {
9733 var e = new FileReader();
9734 e.onload = function(e) {
9735 try {
9736 o(v(e.target.result));
9737 } catch (e) {
9738 n(e);
9739 }
9740 }, e.readAsDataURL(t);
9741 }).then(this.handleImageReady).catch(this.props.onLoadFailure)) : "string" == typeof e && (this.loadingImage = v(e, this.props.crossOrigin).then(this.handleImageReady).catch(this.props.onLoadFailure));
9742 }
9743 },
9744 {
9745 key: "getInitialSize",
9746 value: function(e, t) {
9747 var o;
9748 var n;
9749 var a = this.getDimensions();
9750 return t / e < a.height / a.width ? n = e * ((o = this.getDimensions().height) / t) : o = t * ((n = this.getDimensions().width) / e), {
9751 height: o,
9752 width: n
9753 };
9754 }
9755 },
9756 {
9757 key: "paintImage",
9758 value: function(e, t, o, n) {
9759 var a;
9760 var r = 3 < arguments.length && void 0 !== n ? n : P;
9761 t.resource && (a = this.calculatePosition(t, o), e.save(), e.translate(e.canvas.width / 2, e.canvas.height / 2), e.rotate(this.props.rotate * Math.PI / 180), e.translate(-e.canvas.width / 2, -e.canvas.height / 2), this.isVertical() && e.translate((e.canvas.width - e.canvas.height) / 2, (e.canvas.height - e.canvas.width) / 2), e.scale(r, r), e.globalCompositeOperation = "destination-over", e.drawImage(t.resource, a.x, a.y, a.width, a.height), t.backgroundColor && (e.fillStyle = t.backgroundColor, e.fillRect(a.x, a.y, a.width, a.height)), e.restore());
9762 }
9763 },
9764 {
9765 key: "calculatePosition",
9766 value: function(e, t) {
9767 e = e || this.state.image;
9768 var o = m(this.getBorders(t), 2);
9769 var n = o[0];
9770 var a = o[1];
9771 var r = this.getCroppingRect();
9772 var i = e.width * this.props.scale;
9773 var s = e.height * this.props.scale;
9774 var u = -r.x * i;
9775 var h = -r.y * s;
9776 return this.isVertical() ? (u += a, h += n) : (u += n, h += a), {
9777 x: u,
9778 y: h,
9779 height: s,
9780 width: i
9781 };
9782 }
9783 },
9784 {
9785 key: "paint",
9786 value: function(e) {
9787 e.save(), e.scale(P, P), e.translate(0, 0), e.fillStyle = "rgba(" + this.props.color.slice(0, 4).join(",") + ")";
9788 var t;
9789 var o;
9790 var n;
9791 var a;
9792 var r;
9793 var i;
9794 var s;
9795 var u;
9796 var h = this.props.borderRadius;
9797 var c = this.getDimensions();
9798 var l = m(this.getBorders(c.border), 2);
9799 var d = l[0];
9800 var p = l[1];
9801 var g = c.canvas.height;
9802 var f = c.canvas.width;
9803 var h = Math.max(h, 0);
9804 h = Math.min(h, f / 2 - d, g / 2 - p), e.beginPath(), t = e, a = f - 2 * (o = d), r = g - 2 * (n = p), 0 === (i = h) ? t.rect(o, n, a, r) : (s = a - i, u = r - i, t.translate(o, n), t.arc(i, i, i, Math.PI, 1.5 * Math.PI), t.lineTo(s, 0), t.arc(s, i, i, 1.5 * Math.PI, 2 * Math.PI), t.lineTo(a, u), t.arc(s, u, i, 2 * Math.PI, .5 * Math.PI), t.lineTo(i, r), t.arc(i, u, i, .5 * Math.PI, Math.PI), t.translate(-o, -n)), e.rect(f, 0, -f, g), e.fill("evenodd"), e.restore();
9805 }
9806 },
9807 {
9808 key: "render",
9809 value: function() {
9810 var e = this.props;
9811 var t = (e.scale, e.rotate, e.image, e.border, e.borderRadius, e.width, e.height, e.position, e.color, e.backgroundColor, e.style);
9812 var o = (e.crossOrigin, e.onLoadFailure, e.onLoadSuccess, e.onImageReady, e.onImageChange, e.onMouseUp, e.onMouseMove, e.onPositionChange, e.disableBoundaryChecks, e.disableHiDPIScaling, e.disableCanvasRotation, l(e, [
9813 "scale",
9814 "rotate",
9815 "image",
9816 "border",
9817 "borderRadius",
9818 "width",
9819 "height",
9820 "position",
9821 "color",
9822 "backgroundColor",
9823 "style",
9824 "crossOrigin",
9825 "onLoadFailure",
9826 "onLoadSuccess",
9827 "onImageReady",
9828 "onImageChange",
9829 "onMouseUp",
9830 "onMouseMove",
9831 "onPositionChange",
9832 "disableBoundaryChecks",
9833 "disableHiDPIScaling",
9834 "disableCanvasRotation"
9835 ]));
9836 var n = this.getDimensions();
9837 var a = {
9838 width: n.canvas.width,
9839 height: n.canvas.height,
9840 cursor: this.state.drag ? "grabbing" : "grab",
9841 touchAction: "none"
9842 };
9843 var r = {
9844 width: n.canvas.width * P,
9845 height: n.canvas.height * P,
9846 style: y(y({}, a), t)
9847 };
9848 return r[I.react.down] = this.handleMouseDown, w && (r[I.react.mouseDown] = this.handleMouseDown), i.default.createElement("canvas", u({ ref: this.setCanvas }, r, o));
9849 }
9850 }
9851 ]) && r(e.prototype, t), o && r(e, o), a;
9852 }();
9853 return s(x, "propTypes", {
9854 scale: n.default.number,
9855 rotate: n.default.number,
9856 image: n.default.oneOfType([n.default.string].concat(function(e) {
9857 if (Array.isArray(e)) return f(e);
9858 }(b = M ? [n.default.instanceOf(File)] : []) || function(e) {
9859 if ("undefined" != typeof Symbol && Symbol.iterator in Object(e)) return Array.from(e);
9860 }(b) || g(b) || function() {
9861 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9862 }())),
9863 border: n.default.oneOfType([n.default.number, n.default.arrayOf(n.default.number)]),
9864 borderRadius: n.default.number,
9865 width: n.default.number,
9866 height: n.default.number,
9867 position: n.default.shape({
9868 x: n.default.number,
9869 y: n.default.number
9870 }),
9871 color: n.default.arrayOf(n.default.number),
9872 backgroundColor: n.default.string,
9873 crossOrigin: n.default.oneOf([
9874 "",
9875 "anonymous",
9876 "use-credentials"
9877 ]),
9878 onLoadFailure: n.default.func,
9879 onLoadSuccess: n.default.func,
9880 onImageReady: n.default.func,
9881 onImageChange: n.default.func,
9882 onMouseUp: n.default.func,
9883 onMouseMove: n.default.func,
9884 onPositionChange: n.default.func,
9885 disableBoundaryChecks: n.default.bool,
9886 disableHiDPIScaling: n.default.bool,
9887 disableCanvasRotation: n.default.bool
9888 }), s(x, "defaultProps", {
9889 scale: 1,
9890 rotate: 0,
9891 border: 25,
9892 borderRadius: 0,
9893 width: 200,
9894 height: 200,
9895 color: [
9896 0,
9897 0,
9898 0,
9899 .5
9900 ],
9901 onLoadFailure: function() {},
9902 onLoadSuccess: function() {},
9903 onImageReady: function() {},
9904 onImageChange: function() {},
9905 onMouseUp: function() {},
9906 onMouseMove: function() {},
9907 onPositionChange: function() {},
9908 disableBoundaryChecks: !1,
9909 disableHiDPIScaling: !1,
9910 disableCanvasRotation: !0
9911 }), x;
9912 });
9913 }));
9914
9915 //#endregion
9916 //#region modules/ai/assets/js/editor/pages/form-media/views/out-painting/out-painting-content.js
9917 init_asyncToGenerator();
9918 var import_dist = /* @__PURE__ */ __toESM(require_dist());
9919 var OutPaintingContent = function OutPaintingContent(_ref) {
9920 var scale = _ref.scale;
9921 var setMask = _ref.setMask;
9922 var editImage = _ref.editImage;
9923 var aspectRatio = _ref.aspectRatio;
9924 var setImageSize = _ref.setImageSize;
9925 var setPosition = _ref.setPosition;
9926 var cropperRef = (0, react.useRef)();
9927 var position = (0, react.useRef)({
9928 x: .5,
9929 y: .5
9930 });
9931 var _useImageSize = useImageSize(aspectRatio);
9932 var width = _useImageSize.width;
9933 var height = _useImageSize.height;
9934 var imageSize = {
9935 width,
9936 height
9937 };
9938 var updateMask = /*#__PURE__*/ function() {
9939 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee() {
9940 var imageDataURL;
9941 return import_regenerator$2.default.wrap(function(_context) {
9942 while (1) switch (_context.prev = _context.next) {
9943 case 0:
9944 _context.next = 1;
9945 return cropperRef.current.getImageScaledToCanvas().toDataURL();
9946 case 1:
9947 imageDataURL = _context.sent;
9948 setMask(imageDataURL);
9949 case 2:
9950 case "end": return _context.stop();
9951 }
9952 }, _callee);
9953 }));
9954 return function updateMask() {
9955 return _ref2.apply(this, arguments);
9956 };
9957 }();
9958 var _onPositionChange = /*#__PURE__*/ function() {
9959 var _ref3 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee2(args) {
9960 return import_regenerator$2.default.wrap(function(_context2) {
9961 while (1) switch (_context2.prev = _context2.next) {
9962 case 0:
9963 position.current = {
9964 x: args.x,
9965 y: args.y
9966 };
9967 _context2.next = 1;
9968 return updateMask();
9969 case 1: setPosition(position.current);
9970 case 2:
9971 case "end": return _context2.stop();
9972 }
9973 }, _callee2);
9974 }));
9975 return function onPositionChange(_x) {
9976 return _ref3.apply(this, arguments);
9977 };
9978 }();
9979 var onImageChange = /*#__PURE__*/ function() {
9980 var _ref4 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee3() {
9981 return import_regenerator$2.default.wrap(function(_context3) {
9982 while (1) switch (_context3.prev = _context3.next) {
9983 case 0:
9984 imageSize = {
9985 width: imageSize.width * scale,
9986 height: imageSize.height * scale
9987 };
9988 _context3.next = 1;
9989 return updateMask();
9990 case 1: setImageSize(imageSize);
9991 case 2:
9992 case "end": return _context3.stop();
9993 }
9994 }, _callee3);
9995 }));
9996 return function onImageChange() {
9997 return _ref4.apply(this, arguments);
9998 };
9999 }();
10000 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10001 alignItems: "center",
10002 spacing: .5,
10003 flexGrow: 1
10004 }, /*#__PURE__*/ react.default.createElement(import_dist.default, {
10005 ref: cropperRef,
10006 image: editImage.url,
10007 style: {
10008 backgroundImage: "linear-gradient(45deg, #bbb 25%, transparent 25%), linear-gradient(-45deg, #bbb 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #bbb 75%), linear-gradient(-45deg, transparent 75%, #bbb 75%)",
10009 backgroundSize: "20px 20px",
10010 backgroundPosition: "0 0, 0 10px, 10px -10px, -10px 0px",
10011 outline: "2px dashed #000",
10012 marginTop: "12px"
10013 },
10014 color: [
10015 0,
10016 0,
10017 0,
10018 .9
10019 ],
10020 rotate: 0,
10021 border: 0,
10022 allowZoomOut: true,
10023 backgroundColor: "transparent",
10024 showGrid: true,
10025 onImageChange,
10026 onPositionChange: function onPositionChange(args) {
10027 return _onPositionChange(args);
10028 },
10029 width,
10030 height,
10031 scale
10032 }));
10033 };
10034 OutPaintingContent.propTypes = {
10035 scale: import_prop_types$7.default.number.isRequired,
10036 setMask: import_prop_types$7.default.func.isRequired,
10037 editImage: import_prop_types$7.default.object.isRequired,
10038 aspectRatio: import_prop_types$7.default.string.isRequired,
10039 setImageSize: import_prop_types$7.default.func.isRequired,
10040 setPosition: import_prop_types$7.default.func.isRequired
10041 };
10042
10043 //#endregion
10044 //#region modules/ai/assets/js/editor/pages/form-media/views/out-painting/hooks/use-out-painting.js
10045 init_api();
10046 var useOutPainting = function useOutPainting(initialValue) {
10047 return useImagePrompt(function fetchAction(payload) {
10048 return getImageToImageOutPainting(payload);
10049 }, initialValue);
10050 };
10051
10052 //#endregion
10053 //#region modules/ai/assets/js/editor/pages/form-media/views/out-painting/index.js
10054 init_defineProperty();
10055 init_asyncToGenerator();
10056 init_slicedToArray();
10057 init_requests_ids();
10058 var OutPainting = function OutPainting() {
10059 var _useState2 = _slicedToArray((0, react.useState)({
10060 width: 0,
10061 height: 0
10062 }), 2);
10063 var imageSize = _useState2[0];
10064 var setImageSize = _useState2[1];
10065 var _useState4 = _slicedToArray((0, react.useState)({
10066 x: .5,
10067 y: .5
10068 }), 2);
10069 var position = _useState4[0];
10070 var setPosition = _useState4[1];
10071 var _useState6 = _slicedToArray((0, react.useState)(""), 2);
10072 var mask = _useState6[0];
10073 var setMask = _useState6[1];
10074 var setGenerate = useRequestIds().setGenerate;
10075 var _useEditImage = useEditImage();
10076 var editImage = _useEditImage.editImage;
10077 var initialAspectRatio = _useEditImage.aspectRatio;
10078 var _usePromptSettings = usePromptSettings({ aspectRatio: initialAspectRatio });
10079 var settings = _usePromptSettings.settings;
10080 var updateSettings = _usePromptSettings.updateSettings;
10081 var _useImageActions = useImageActions();
10082 var use = _useImageActions.use;
10083 var edit = _useImageActions.edit;
10084 var isUploading = _useImageActions.isLoading;
10085 var _useOutPainting = useOutPainting();
10086 var data = _useOutPainting.data;
10087 var send = _useOutPainting.send;
10088 var isGenerating = _useOutPainting.isLoading;
10089 var error = _useOutPainting.error;
10090 var isLoading = isGenerating || isUploading;
10091 var generatedAspectRatio = (0, react.useMemo)(function() {
10092 return settings[IMAGE_RATIO];
10093 }, [data === null || data === void 0 ? void 0 : data.result]);
10094 var hasGeneratedResult = !!(data !== null && data !== void 0 && data.result);
10095 var handleSubmit = /*#__PURE__*/ function() {
10096 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(event) {
10097 var imageBase64;
10098 return import_regenerator$2.default.wrap(function(_context) {
10099 while (1) switch (_context.prev = _context.next) {
10100 case 0:
10101 event.preventDefault();
10102 setGenerate();
10103 _context.next = 1;
10104 return fetchImageAsBase64(editImage.url);
10105 case 1:
10106 imageBase64 = _context.sent;
10107 send({
10108 settings,
10109 image: editImage,
10110 mask,
10111 size: imageSize,
10112 position,
10113 image_base64: imageBase64
10114 });
10115 case 2:
10116 case "end": return _context.stop();
10117 }
10118 }, _callee);
10119 }));
10120 return function handleSubmit(_x) {
10121 return _ref.apply(this, arguments);
10122 };
10123 }();
10124 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, null), /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
10125 primary: (0, _wordpress_i18n.__)("Expand Image", "elementor"),
10126 secondary: (0, _wordpress_i18n.__)("Position image in it’s new size to generate content around the edges.", "elementor")
10127 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
10128 error,
10129 onRetry: handleSubmit
10130 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(ImageRatioSelect, {
10131 disabled: isLoading || hasGeneratedResult,
10132 value: settings[IMAGE_RATIO],
10133 onChange: function onChange(event) {
10134 return updateSettings(_defineProperty({}, IMAGE_RATIO, event.target.value));
10135 }
10136 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.FormControl, { sx: {
10137 width: "100%",
10138 mb: 2.5
10139 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Slider, {
10140 marks: true,
10141 id: "zoom",
10142 name: "zoom",
10143 max: 1,
10144 min: .1,
10145 step: .1,
10146 color: "secondary",
10147 defaultValue: 1,
10148 disabled: isLoading || hasGeneratedResult,
10149 valueLabelDisplay: "auto",
10150 "aria-labelledby": "image-size-slider",
10151 "aria-label": (0, _wordpress_i18n.__)("Reference strength", "elementor"),
10152 onChange: function onChange(_, value) {
10153 return updateSettings(_defineProperty({}, IMAGE_ZOOM, value));
10154 }
10155 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
10156 id: "image-size-slider",
10157 variant: "caption",
10158 gutterBottom: true
10159 }, (0, _wordpress_i18n.__)("Original image size", "elementor"))), data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10160 gap: 2,
10161 sx: { my: 2.5 }
10162 }, /*#__PURE__*/ react.default.createElement(GenerateAgainSubmit, { disabled: isLoading })) : /*#__PURE__*/ react.default.createElement(GenerateSubmit, { disabled: isLoading }))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isLoading }, hasGeneratedResult ? /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
10163 onUseImage: use,
10164 onEditImage: edit,
10165 images: data.result,
10166 aspectRatio: generatedAspectRatio
10167 }) : /*#__PURE__*/ react.default.createElement(OutPaintingContent, {
10168 setMask,
10169 editImage,
10170 scale: settings[IMAGE_ZOOM],
10171 aspectRatio: settings[IMAGE_RATIO],
10172 setImageSize,
10173 setPosition
10174 })));
10175 };
10176
10177 //#endregion
10178 //#region modules/ai/assets/js/editor/pages/form-media/views/variations/hooks/use-image-to-image.js
10179 init_api();
10180 var useImageToImage = function useImageToImage(initialValue) {
10181 return useImagePrompt(function fetchAction(payload) {
10182 return getImageToImageGeneration(payload);
10183 }, initialValue);
10184 };
10185
10186 //#endregion
10187 //#region modules/ai/assets/js/editor/pages/form-media/views/variations/index.js
10188 init_slicedToArray();
10189 init_requests_ids();
10190 var IMAGE_WEIGHT_DEFAULT = 45;
10191 var Variations = function Variations() {
10192 var _data$result;
10193 var prompt = _slicedToArray((0, react.useState)(""), 1)[0];
10194 var setGenerate = useRequestIds().setGenerate;
10195 var _useEditImage = useEditImage();
10196 var editImage = _useEditImage.editImage;
10197 var initialAspectRatio = _useEditImage.aspectRatio;
10198 var settings = usePromptSettings({
10199 aspectRatio: initialAspectRatio,
10200 imageWeight: IMAGE_WEIGHT_DEFAULT
10201 }).settings;
10202 var _useImageToImage = useImageToImage();
10203 var data = _useImageToImage.data;
10204 var send = _useImageToImage.send;
10205 var isGenerating = _useImageToImage.isLoading;
10206 var error = _useImageToImage.error;
10207 var _useImageActions = useImageActions();
10208 var use = _useImageActions.use;
10209 var edit = _useImageActions.edit;
10210 var isUploading = _useImageActions.isLoading;
10211 var isLoading = isGenerating || isUploading;
10212 var generatedAspectRatio = (0, react.useMemo)(function() {
10213 return settings[IMAGE_RATIO];
10214 }, [data === null || data === void 0 ? void 0 : data.result]);
10215 var handleSubmit = function handleSubmit(event) {
10216 event.preventDefault();
10217 setGenerate();
10218 send({
10219 prompt,
10220 settings,
10221 image: editImage
10222 });
10223 };
10224 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, null), /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
10225 primary: (0, _wordpress_i18n.__)("Variations", "elementor"),
10226 secondary: (0, _wordpress_i18n.__)("Create new versions of the original image.", "elementor")
10227 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
10228 error,
10229 onRetry: handleSubmit
10230 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
10231 display: "flex",
10232 alignItems: "center",
10233 justifyContent: "center",
10234 bgcolor: "action.selected"
10235 } }, /*#__PURE__*/ react.default.createElement("img", {
10236 src: (editImage === null || editImage === void 0 ? void 0 : editImage.image_url) || (editImage === null || editImage === void 0 ? void 0 : editImage.url),
10237 alt: prompt,
10238 style: {
10239 width: "auto",
10240 height: "auto",
10241 maxWidth: "100%",
10242 maxHeight: 166,
10243 objectFit: "contained"
10244 }
10245 })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10246 gap: 2,
10247 sx: { my: 2.5 }
10248 }, (data === null || data === void 0 || (_data$result = data.result) === null || _data$result === void 0 ? void 0 : _data$result.length) > 0 ? /*#__PURE__*/ react.default.createElement(GenerateAgainSubmit, { disabled: isLoading }) : /*#__PURE__*/ react.default.createElement(GenerateImagesSubmit, { disabled: isLoading })))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isLoading }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
10249 images: data.result,
10250 aspectRatio: generatedAspectRatio,
10251 onUseImage: use,
10252 onEditImage: edit
10253 }) : /*#__PURE__*/ react.default.createElement(ImagesPlaceholder, null)));
10254 };
10255 Variations.propTypes = {};
10256
10257 //#endregion
10258 //#region modules/ai/assets/js/editor/pages/form-media/views/replace-background/hooks/use-replace-background.js
10259 init_api();
10260 var useReplaceBackground = function useReplaceBackground(initialValue) {
10261 return useImagePrompt(function fetchAction(payload) {
10262 return getImageToImageReplaceBackground(payload);
10263 }, initialValue);
10264 };
10265
10266 //#endregion
10267 //#region modules/ai/assets/js/editor/pages/form-media/views/replace-background/index.js
10268 init_slicedToArray();
10269 init_requests_ids();
10270 var ReplaceBackground = function ReplaceBackground() {
10271 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
10272 var prompt = _useState2[0];
10273 var setPrompt = _useState2[1];
10274 var setGenerate = useRequestIds().setGenerate;
10275 var editImage = useEditImage().editImage;
10276 var _useImageActions = useImageActions();
10277 var use = _useImageActions.use;
10278 var edit = _useImageActions.edit;
10279 var isUploading = _useImageActions.isLoading;
10280 var _useReplaceBackground = useReplaceBackground();
10281 var data = _useReplaceBackground.data;
10282 var send = _useReplaceBackground.send;
10283 var isGenerating = _useReplaceBackground.isLoading;
10284 var error = _useReplaceBackground.error;
10285 var navigate = useLocation().navigate;
10286 var isLoading = isGenerating || isUploading;
10287 var handleSubmit = function handleSubmit(event) {
10288 event.preventDefault();
10289 setGenerate();
10290 send({
10291 prompt,
10292 image: editImage
10293 });
10294 };
10295 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, null), /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
10296 primary: (0, _wordpress_i18n.__)("Replace Background", "elementor"),
10297 secondary: (0, _wordpress_i18n.__)("Generate a new background with a prompt.", "elementor")
10298 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
10299 error,
10300 onRetry: handleSubmit
10301 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(PromptField, {
10302 value: prompt,
10303 disabled: isLoading,
10304 onChange: setPrompt,
10305 placeholder: (0, _wordpress_i18n.__)("Describe what you want to generate in the background (English only)", "elementor")
10306 }), /*#__PURE__*/ react.default.createElement(GenerateSubmit, {
10307 disabled: isLoading || "" === prompt,
10308 color: data !== null && data !== void 0 && data.result ? "secondary" : "primary"
10309 }, data !== null && data !== void 0 && data.result ? (0, _wordpress_i18n.__)("Generate Again", "elementor") : (0, _wordpress_i18n.__)("Replace Background", "elementor")), (data === null || data === void 0 ? void 0 : data.result) && /*#__PURE__*/ react.default.createElement(NewPromptButton, {
10310 disabled: isLoading,
10311 onClick: function onClick() {
10312 return navigate(LOCATIONS.GENERATE);
10313 }
10314 }))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isLoading }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
10315 onUseImage: use,
10316 onEditImage: edit,
10317 images: data.result,
10318 aspectRatio: editImage.aspectRatio
10319 }) : /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
10320 src: editImage.url,
10321 alt: editImage.alt,
10322 style: {
10323 width: editImage.width,
10324 height: editImage.height
10325 }
10326 }))));
10327 };
10328
10329 //#endregion
10330 //#region modules/ai/assets/js/editor/pages/form-media/views/remove-background/hooks/use-remove-background.js
10331 init_api();
10332 var useRemoveBackground = function useRemoveBackground(initialValue) {
10333 return useImagePrompt(function fetchAction(payload) {
10334 return getImageToImageRemoveBackground(payload);
10335 }, initialValue);
10336 };
10337
10338 //#endregion
10339 //#region modules/ai/assets/js/editor/pages/form-media/views/remove-background/index.js
10340 init_requests_ids();
10341 var RemoveBackground = function RemoveBackground() {
10342 var editImage = useEditImage().editImage;
10343 var setGenerate = useRequestIds().setGenerate;
10344 var _useImageActions = useImageActions();
10345 var use = _useImageActions.use;
10346 var edit = _useImageActions.edit;
10347 var isUploading = _useImageActions.isLoading;
10348 var _useRemoveBackground = useRemoveBackground();
10349 var data = _useRemoveBackground.data;
10350 var send = _useRemoveBackground.send;
10351 var isGenerating = _useRemoveBackground.isLoading;
10352 var error = _useRemoveBackground.error;
10353 var navigate = useLocation().navigate;
10354 var isLoading = isGenerating || isUploading;
10355 var _useImageSize = useImageSize(editImage.aspectRatio);
10356 var width = _useImageSize.width;
10357 var height = _useImageSize.height;
10358 var handleSubmit = function handleSubmit(event) {
10359 event.preventDefault();
10360 setGenerate();
10361 send({ image: editImage });
10362 };
10363 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, null), /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
10364 primary: (0, _wordpress_i18n.__)("Remove Background", "elementor"),
10365 secondary: (0, _wordpress_i18n.__)("Create an image of the subject with a transparent background", "elementor")
10366 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
10367 error,
10368 onRetry: handleSubmit
10369 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(NewPromptButton, {
10370 variant: "contained",
10371 disabled: isLoading,
10372 onClick: function onClick() {
10373 return navigate(LOCATIONS.GENERATE);
10374 }
10375 }) : /*#__PURE__*/ react.default.createElement(GenerateSubmit, { disabled: isLoading }, (0, _wordpress_i18n.__)("Remove Background", "elementor")))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isLoading }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, null, /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
10376 transparentContainer: true,
10377 onUseImage: use,
10378 onEditImage: edit,
10379 images: data.result,
10380 aspectRatio: editImage.aspectRatio
10381 })) : /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
10382 src: editImage.url,
10383 alt: editImage.alt,
10384 style: {
10385 width,
10386 height
10387 }
10388 })))));
10389 };
10390
10391 //#endregion
10392 //#region modules/ai/assets/js/editor/pages/form-media/views/cleanup/cleanup-content.js
10393 init_asyncToGenerator();
10394 init_slicedToArray();
10395 var STROKE_SELECT_WIDTH = 120;
10396 var BRUSH_COLOR = "rgba(255, 255, 255)";
10397 var CANVAS_COLOR = "rgba(0, 0, 0)";
10398 var StyledUndoIcon = (0, _elementor_ui.withDirection)(UndoIcon);
10399 var StyledRedoIcon = (0, _elementor_ui.withDirection)(RedoIcon);
10400 var BrushCursor = (0, _elementor_ui.styled)(_elementor_ui.Box, { shouldForwardProp: function shouldForwardProp(prop) {
10401 return "size" === prop;
10402 } })(function(_ref) {
10403 var theme = _ref.theme;
10404 var size = _ref.size;
10405 return {
10406 position: "absolute",
10407 width: size,
10408 height: size,
10409 borderRadius: "50%",
10410 backgroundColor: BRUSH_COLOR,
10411 pointerEvents: "none",
10412 transform: "translate(".concat("rtl" === theme.direction ? "50%" : "-50%", ", -50%)"),
10413 border: "1px solid #fff"
10414 };
10415 });
10416 var BrishSizeIcon = (0, _elementor_ui.styled)(_elementor_ui.Box, { shouldForwardProp: function shouldForwardProp(prop) {
10417 return "size" === prop;
10418 } })(function(_ref2) {
10419 var theme = _ref2.theme;
10420 var size = _ref2.size;
10421 return {
10422 width: size / 2,
10423 height: size / 2,
10424 borderRadius: "50%",
10425 backgroundColor: theme.palette.secondary.main
10426 };
10427 });
10428 var CleanupContent = function CleanupContent(_ref3) {
10429 var editImage = _ref3.editImage;
10430 var setMask = _ref3.setMask;
10431 var setIsCanvasChanged = _ref3.setIsCanvasChanged;
10432 var canvasWidth = _ref3.width;
10433 var canvasHeight = _ref3.height;
10434 var sketchRef = (0, react.useRef)();
10435 var _useState2 = _slicedToArray((0, react.useState)(30), 2);
10436 var stroke = _useState2[0];
10437 var setStroke = _useState2[1];
10438 var brushCursorRef = (0, react.useRef)();
10439 (0, react.useEffect)(function() {
10440 var canvas = document.querySelector(".eui-in-painting-canvas");
10441 var positionElement = function positionElement(e) {
10442 var _canvas$getBoundingCl = canvas.getBoundingClientRect();
10443 var left = _canvas$getBoundingCl.left;
10444 var top = _canvas$getBoundingCl.top;
10445 var width = _canvas$getBoundingCl.width;
10446 var height = _canvas$getBoundingCl.height;
10447 var x = e.clientX - left;
10448 var y = e.clientY - top;
10449 if (x > 0 && x < width && y > 0 && y < height) {
10450 brushCursorRef.current.style.left = "".concat(x, "px");
10451 brushCursorRef.current.style.top = "".concat(y, "px");
10452 }
10453 };
10454 window.addEventListener("mousemove", positionElement);
10455 return function() {
10456 window.removeEventListener("mousemove", positionElement);
10457 };
10458 }, [stroke]);
10459 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10460 alignItems: "flex-start",
10461 spacing: .5,
10462 flexGrow: 1
10463 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10464 width: "100%",
10465 direction: "row",
10466 spacing: 3,
10467 alignSelf: "center",
10468 justifyContent: "center",
10469 sx: { mb: 2.5 }
10470 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10471 direction: "row",
10472 gap: 1
10473 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: (0, _wordpress_i18n.__)("Undo", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
10474 variant: "outlined",
10475 color: "secondary",
10476 onClick: function onClick() {
10477 return sketchRef.current.undo();
10478 },
10479 sx: { px: 0 }
10480 }, /*#__PURE__*/ react.default.createElement(StyledUndoIcon, null))), /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: (0, _wordpress_i18n.__)("Redo", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
10481 variant: "outlined",
10482 color: "secondary",
10483 onClick: function onClick() {
10484 return sketchRef.current.redo();
10485 },
10486 sx: { px: 0 }
10487 }, /*#__PURE__*/ react.default.createElement(StyledRedoIcon, null)))), /*#__PURE__*/ react.default.createElement(_elementor_ui.FormControl, {
10488 size: "small",
10489 color: "secondary",
10490 sx: { minWidth: STROKE_SELECT_WIDTH }
10491 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.InputLabel, { id: "stroke" }, "Stroke"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Select, {
10492 autoWidth: true,
10493 label: "Stroke",
10494 value: stroke,
10495 id: "demo-simple-select",
10496 labelId: "demo-simple-select-label",
10497 onChange: function onChange(e) {
10498 return setStroke(e.target.value);
10499 },
10500 MenuProps: {
10501 PaperProps: { sx: { maxWidth: STROKE_SELECT_WIDTH } },
10502 MenuListProps: { sx: { minWidth: STROKE_SELECT_WIDTH } }
10503 },
10504 sx: { "& .MuiSelect-select .MuiListItemIcon-root": {
10505 mr: .25,
10506 width: "initial",
10507 minWidth: "initial",
10508 justifyContent: "flex-start"
10509 } }
10510 }, [
10511 10,
10512 20,
10513 30,
10514 40,
10515 50
10516 ].map(function(value) {
10517 return /*#__PURE__*/ react.default.createElement(_elementor_ui.MenuItem, {
10518 key: "stroke-width-option-" + value,
10519 value
10520 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10521 direction: "row",
10522 alignItems: "center",
10523 gap: 1
10524 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemIcon, { sx: {
10525 width: 30,
10526 display: "flex",
10527 justifyContent: "center"
10528 } }, /*#__PURE__*/ react.default.createElement(BrishSizeIcon, { size: value })), /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemText, null, value)));
10529 })))), /*#__PURE__*/ react.default.createElement("div", { style: {
10530 margin: "0 auto",
10531 position: "relative",
10532 cursor: "none",
10533 overflow: "hidden"
10534 } }, /*#__PURE__*/ react.default.createElement(BrushCursor, {
10535 ref: brushCursorRef,
10536 size: stroke
10537 }), /*#__PURE__*/ react.default.createElement(ReactSketchCanvas, {
10538 className: "eui-in-painting-canvas",
10539 withViewBox: true,
10540 ref: sketchRef,
10541 height: canvasHeight + "px",
10542 width: canvasWidth + "px",
10543 strokeWidth: stroke,
10544 strokeColor: BRUSH_COLOR,
10545 canvasColor: CANVAS_COLOR,
10546 backgroundImage: editImage.url,
10547 onStroke: function onStroke() {
10548 return setIsCanvasChanged(true);
10549 },
10550 onChange: /*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee() {
10551 var svg;
10552 return import_regenerator$2.default.wrap(function(_context) {
10553 while (1) switch (_context.prev = _context.next) {
10554 case 0:
10555 _context.next = 1;
10556 return sketchRef.current.exportSvg();
10557 case 1:
10558 svg = _context.sent;
10559 setMask(svg);
10560 case 2:
10561 case "end": return _context.stop();
10562 }
10563 }, _callee);
10564 }))
10565 })));
10566 };
10567 CleanupContent.propTypes = {
10568 setMask: import_prop_types$7.default.func.isRequired,
10569 setIsCanvasChanged: import_prop_types$7.default.func.isRequired,
10570 width: import_prop_types$7.default.number.isRequired,
10571 height: import_prop_types$7.default.number.isRequired,
10572 editImage: import_prop_types$7.default.object.isRequired
10573 };
10574
10575 //#endregion
10576 //#region modules/ai/assets/js/editor/pages/form-media/views/cleanup/hooks/use-cleanup.js
10577 init_api();
10578 var useCleanup = function useCleanup(initialValue) {
10579 return useImagePrompt(function fetchAction(payload) {
10580 return getImageToImageMaskCleanup(payload);
10581 }, initialValue);
10582 };
10583
10584 //#endregion
10585 //#region modules/ai/assets/js/editor/pages/form-media/views/cleanup/index.js
10586 init_asyncToGenerator();
10587 init_slicedToArray();
10588 init_requests_ids();
10589 var Cleanup = function Cleanup() {
10590 var setGenerate = useRequestIds().setGenerate;
10591 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
10592 var mask = _useState2[0];
10593 var setMask = _useState2[1];
10594 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
10595 var isCanvasChanged = _useState4[0];
10596 var setIsCanvasChanged = _useState4[1];
10597 var _usePromptSettings = usePromptSettings();
10598 var settings = _usePromptSettings.settings;
10599 var resetSettings = _usePromptSettings.resetSettings;
10600 var _useEditImage = useEditImage();
10601 var editImage = _useEditImage.editImage;
10602 var width = _useEditImage.width;
10603 var height = _useEditImage.height;
10604 var _useImageActions = useImageActions();
10605 var use = _useImageActions.use;
10606 var edit = _useImageActions.edit;
10607 var isUploading = _useImageActions.isLoading;
10608 var _useCleanup = useCleanup();
10609 var data = _useCleanup.data;
10610 var send = _useCleanup.send;
10611 var isGenerating = _useCleanup.isLoading;
10612 var error = _useCleanup.error;
10613 var reset = _useCleanup.reset;
10614 var isLoading = isGenerating || isUploading;
10615 var handleSubmit = /*#__PURE__*/ function() {
10616 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(event) {
10617 return import_regenerator$2.default.wrap(function(_context) {
10618 while (1) switch (_context.prev = _context.next) {
10619 case 0:
10620 event.preventDefault();
10621 setGenerate();
10622 send({
10623 settings,
10624 image: editImage,
10625 mask
10626 });
10627 case 1:
10628 case "end": return _context.stop();
10629 }
10630 }, _callee);
10631 }));
10632 return function handleSubmit(_x) {
10633 return _ref.apply(this, arguments);
10634 };
10635 }();
10636 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, null), /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
10637 primary: (0, _wordpress_i18n.__)("Cleanup", "elementor"),
10638 secondary: (0, _wordpress_i18n.__)("Remove unwanted area from your image.", "elementor")
10639 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
10640 error,
10641 onRetry: handleSubmit
10642 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10643 gap: 2,
10644 sx: { my: 2.5 }
10645 }, /*#__PURE__*/ react.default.createElement(GenerateAgainSubmit, { disabled: isLoading }), /*#__PURE__*/ react.default.createElement(NewPromptButton, {
10646 disabled: isLoading,
10647 onClick: function onClick() {
10648 resetSettings();
10649 reset();
10650 }
10651 })) : /*#__PURE__*/ react.default.createElement(GenerateSubmit, { disabled: isLoading || !isCanvasChanged }))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isLoading }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
10652 images: data.result,
10653 aspectRatio: editImage.aspectRatio,
10654 onUseImage: use,
10655 onEditImage: edit
10656 }) : /*#__PURE__*/ react.default.createElement(CleanupContent, {
10657 editImage,
10658 width,
10659 height,
10660 setMask,
10661 setIsCanvasChanged
10662 })));
10663 };
10664
10665 //#endregion
10666 //#region modules/ai/assets/js/editor/pages/form-media/views/generate/hooks/use-text-to-image.js
10667 init_api();
10668 var useTextToImage = function useTextToImage(initialValue) {
10669 return useImagePrompt(getTextToImageGeneration, initialValue);
10670 };
10671
10672 //#endregion
10673 //#region node_modules/react-colorful/dist/index.mjs
10674 function u() {
10675 return (u = Object.assign || function(e) {
10676 for (var r = 1; r < arguments.length; r++) {
10677 var t = arguments[r];
10678 for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
10679 }
10680 return e;
10681 }).apply(this, arguments);
10682 }
10683 function c(e, r) {
10684 if (null == e) return {};
10685 var t;
10686 var n;
10687 var o = {};
10688 var a = Object.keys(e);
10689 for (n = 0; n < a.length; n++) r.indexOf(t = a[n]) >= 0 || (o[t] = e[t]);
10690 return o;
10691 }
10692 function i(e) {
10693 var t = (0, react$1.useRef)(e);
10694 var n = (0, react$1.useRef)(function(e) {
10695 t.current && t.current(e);
10696 });
10697 return t.current = e, n.current;
10698 }
10699 var s = function(e, r, t) {
10700 return void 0 === r && (r = 0), void 0 === t && (t = 1), e > t ? t : e < r ? r : e;
10701 };
10702 var f = function(e) {
10703 return "touches" in e;
10704 };
10705 var v = function(e) {
10706 return e && e.ownerDocument.defaultView || self;
10707 };
10708 var d = function(e, r, t) {
10709 var n = e.getBoundingClientRect();
10710 var o = f(r) ? function(e, r) {
10711 for (var t = 0; t < e.length; t++) if (e[t].identifier === r) return e[t];
10712 return e[0];
10713 }(r.touches, t) : r;
10714 return {
10715 left: s((o.pageX - (n.left + v(e).pageXOffset)) / n.width),
10716 top: s((o.pageY - (n.top + v(e).pageYOffset)) / n.height)
10717 };
10718 };
10719 var h = function(e) {
10720 !f(e) && e.preventDefault();
10721 };
10722 var m = react$1.default.memo(function(o) {
10723 var a = o.onMove;
10724 var l = o.onKey;
10725 var s = c(o, ["onMove", "onKey"]);
10726 var m = (0, react$1.useRef)(null);
10727 var g = i(a);
10728 var p = i(l);
10729 var b = (0, react$1.useRef)(null);
10730 var _ = (0, react$1.useRef)(!1);
10731 var x = (0, react$1.useMemo)(function() {
10732 var e = function(e) {
10733 h(e), (f(e) ? e.touches.length > 0 : e.buttons > 0) && m.current ? g(d(m.current, e, b.current)) : t(!1);
10734 };
10735 var r = function() {
10736 return t(!1);
10737 };
10738 function t(t) {
10739 var n = _.current;
10740 var o = v(m.current);
10741 var a = t ? o.addEventListener : o.removeEventListener;
10742 a(n ? "touchmove" : "mousemove", e), a(n ? "touchend" : "mouseup", r);
10743 }
10744 return [
10745 function(e) {
10746 var r = e.nativeEvent;
10747 var n = m.current;
10748 if (n && (h(r), !function(e, r) {
10749 return r && !f(e);
10750 }(r, _.current) && n)) {
10751 if (f(r)) {
10752 _.current = !0;
10753 var o = r.changedTouches || [];
10754 o.length && (b.current = o[0].identifier);
10755 }
10756 n.focus(), g(d(n, r, b.current)), t(!0);
10757 }
10758 },
10759 function(e) {
10760 var r = e.which || e.keyCode;
10761 r < 37 || r > 40 || (e.preventDefault(), p({
10762 left: 39 === r ? .05 : 37 === r ? -.05 : 0,
10763 top: 40 === r ? .05 : 38 === r ? -.05 : 0
10764 }));
10765 },
10766 t
10767 ];
10768 }, [p, g]);
10769 var C = x[0];
10770 var E = x[1];
10771 var H = x[2];
10772 return (0, react$1.useEffect)(function() {
10773 return H;
10774 }, [H]), react$1.default.createElement("div", u({}, s, {
10775 onTouchStart: C,
10776 onMouseDown: C,
10777 className: "react-colorful__interactive",
10778 ref: m,
10779 onKeyDown: E,
10780 tabIndex: 0,
10781 role: "slider"
10782 }));
10783 });
10784 var g = function(e) {
10785 return e.filter(Boolean).join(" ");
10786 };
10787 var p = function(r) {
10788 var t = r.color;
10789 var n = r.left;
10790 var o = r.top;
10791 var a = void 0 === o ? .5 : o;
10792 var l = g(["react-colorful__pointer", r.className]);
10793 return react$1.default.createElement("div", {
10794 className: l,
10795 style: {
10796 top: 100 * a + "%",
10797 left: 100 * n + "%"
10798 }
10799 }, react$1.default.createElement("div", {
10800 className: "react-colorful__pointer-fill",
10801 style: { backgroundColor: t }
10802 }));
10803 };
10804 var b = function(e, r, t) {
10805 return void 0 === r && (r = 0), void 0 === t && (t = Math.pow(10, r)), Math.round(t * e) / t;
10806 };
10807 var _ = {
10808 grad: .9,
10809 turn: 360,
10810 rad: 360 / (2 * Math.PI)
10811 };
10812 var x = function(e) {
10813 return L(C(e));
10814 };
10815 var C = function(e) {
10816 return "#" === e[0] && (e = e.substring(1)), e.length < 6 ? {
10817 r: parseInt(e[0] + e[0], 16),
10818 g: parseInt(e[1] + e[1], 16),
10819 b: parseInt(e[2] + e[2], 16),
10820 a: 4 === e.length ? b(parseInt(e[3] + e[3], 16) / 255, 2) : 1
10821 } : {
10822 r: parseInt(e.substring(0, 2), 16),
10823 g: parseInt(e.substring(2, 4), 16),
10824 b: parseInt(e.substring(4, 6), 16),
10825 a: 8 === e.length ? b(parseInt(e.substring(6, 8), 16) / 255, 2) : 1
10826 };
10827 };
10828 var w = function(e) {
10829 return K(I(e));
10830 };
10831 var y = function(e) {
10832 var r = e.s;
10833 var t = e.v;
10834 var n = e.a;
10835 var o = (200 - r) * t / 100;
10836 return {
10837 h: b(e.h),
10838 s: b(o > 0 && o < 200 ? r * t / 100 / (o <= 100 ? o : 200 - o) * 100 : 0),
10839 l: b(o / 2),
10840 a: b(n, 2)
10841 };
10842 };
10843 var q = function(e) {
10844 var r = y(e);
10845 return "hsl(" + r.h + ", " + r.s + "%, " + r.l + "%)";
10846 };
10847 var I = function(e) {
10848 var r = e.h;
10849 var t = e.s;
10850 var n = e.v;
10851 var o = e.a;
10852 r = r / 360 * 6, t /= 100, n /= 100;
10853 var a = Math.floor(r);
10854 var l = n * (1 - t);
10855 var u = n * (1 - (r - a) * t);
10856 var c = n * (1 - (1 - r + a) * t);
10857 var i = a % 6;
10858 return {
10859 r: b(255 * [
10860 n,
10861 u,
10862 l,
10863 l,
10864 c,
10865 n
10866 ][i]),
10867 g: b(255 * [
10868 c,
10869 n,
10870 n,
10871 u,
10872 l,
10873 l
10874 ][i]),
10875 b: b(255 * [
10876 l,
10877 l,
10878 c,
10879 n,
10880 n,
10881 u
10882 ][i]),
10883 a: b(o, 2)
10884 };
10885 };
10886 var D = function(e) {
10887 var r = e.toString(16);
10888 return r.length < 2 ? "0" + r : r;
10889 };
10890 var K = function(e) {
10891 var r = e.r;
10892 var t = e.g;
10893 var n = e.b;
10894 var o = e.a;
10895 var a = o < 1 ? D(b(255 * o)) : "";
10896 return "#" + D(r) + D(t) + D(n) + a;
10897 };
10898 var L = function(e) {
10899 var r = e.r;
10900 var t = e.g;
10901 var n = e.b;
10902 var o = e.a;
10903 var a = Math.max(r, t, n);
10904 var l = a - Math.min(r, t, n);
10905 var u = l ? a === r ? (t - n) / l : a === t ? 2 + (n - r) / l : 4 + (r - t) / l : 0;
10906 return {
10907 h: b(60 * (u < 0 ? u + 6 : u)),
10908 s: b(a ? l / a * 100 : 0),
10909 v: b(a / 255 * 100),
10910 a: o
10911 };
10912 };
10913 var S = react$1.default.memo(function(r) {
10914 var t = r.hue;
10915 var n = r.onChange;
10916 var o = g(["react-colorful__hue", r.className]);
10917 return react$1.default.createElement("div", { className: o }, react$1.default.createElement(m, {
10918 onMove: function(e) {
10919 n({ h: 360 * e.left });
10920 },
10921 onKey: function(e) {
10922 n({ h: s(t + 360 * e.left, 0, 360) });
10923 },
10924 "aria-label": "Hue",
10925 "aria-valuenow": b(t),
10926 "aria-valuemax": "360",
10927 "aria-valuemin": "0"
10928 }, react$1.default.createElement(p, {
10929 className: "react-colorful__hue-pointer",
10930 left: t / 360,
10931 color: q({
10932 h: t,
10933 s: 100,
10934 v: 100,
10935 a: 1
10936 })
10937 })));
10938 });
10939 var T = react$1.default.memo(function(r) {
10940 var t = r.hsva;
10941 var n = r.onChange;
10942 var o = { backgroundColor: q({
10943 h: t.h,
10944 s: 100,
10945 v: 100,
10946 a: 1
10947 }) };
10948 return react$1.default.createElement("div", {
10949 className: "react-colorful__saturation",
10950 style: o
10951 }, react$1.default.createElement(m, {
10952 onMove: function(e) {
10953 n({
10954 s: 100 * e.left,
10955 v: 100 - 100 * e.top
10956 });
10957 },
10958 onKey: function(e) {
10959 n({
10960 s: s(t.s + 100 * e.left, 0, 100),
10961 v: s(t.v - 100 * e.top, 0, 100)
10962 });
10963 },
10964 "aria-label": "Color",
10965 "aria-valuetext": "Saturation " + b(t.s) + "%, Brightness " + b(t.v) + "%"
10966 }, react$1.default.createElement(p, {
10967 className: "react-colorful__saturation-pointer",
10968 top: 1 - t.v / 100,
10969 left: t.s / 100,
10970 color: q(t)
10971 })));
10972 });
10973 var F = function(e, r) {
10974 if (e === r) return !0;
10975 for (var t in e) if (e[t] !== r[t]) return !1;
10976 return !0;
10977 };
10978 var X = function(e, r) {
10979 return e.toLowerCase() === r.toLowerCase() || F(C(e), C(r));
10980 };
10981 function Y(e, t, l) {
10982 var u = i(l);
10983 var c = (0, react$1.useState)(function() {
10984 return e.toHsva(t);
10985 });
10986 var s = c[0];
10987 var f = c[1];
10988 var v = (0, react$1.useRef)({
10989 color: t,
10990 hsva: s
10991 });
10992 (0, react$1.useEffect)(function() {
10993 if (!e.equal(t, v.current.color)) {
10994 var r = e.toHsva(t);
10995 v.current = {
10996 hsva: r,
10997 color: t
10998 }, f(r);
10999 }
11000 }, [t, e]), (0, react$1.useEffect)(function() {
11001 var r;
11002 F(s, v.current.hsva) || e.equal(r = e.fromHsva(s), v.current.color) || (v.current = {
11003 hsva: s,
11004 color: r
11005 }, u(r));
11006 }, [
11007 s,
11008 e,
11009 u
11010 ]);
11011 return [s, (0, react$1.useCallback)(function(e) {
11012 f(function(r) {
11013 return Object.assign({}, r, e);
11014 });
11015 }, [])];
11016 }
11017 var R;
11018 var V = "undefined" != typeof window ? react$1.useLayoutEffect : react$1.useEffect;
11019 var $ = function() {
11020 return R || ("undefined" != typeof __webpack_nonce__ ? __webpack_nonce__ : void 0);
11021 };
11022 var J = /* @__PURE__ */ new Map();
11023 var Q = function(e) {
11024 V(function() {
11025 var r = e.current ? e.current.ownerDocument : document;
11026 if (void 0 !== r && !J.has(r)) {
11027 var t = r.createElement("style");
11028 t.innerHTML = ".react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:\"\";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill-opacity=\".05\"><path d=\"M8 0h8v8H8zM0 8h8v8H0z\"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}", J.set(r, t);
11029 var n = $();
11030 n && t.setAttribute("nonce", n), r.head.appendChild(t);
11031 }
11032 }, []);
11033 };
11034 var U = function(t) {
11035 var n = t.className;
11036 var o = t.colorModel;
11037 var a = t.color;
11038 var l = void 0 === a ? o.defaultColor : a;
11039 var i = t.onChange;
11040 var s = c(t, [
11041 "className",
11042 "colorModel",
11043 "color",
11044 "onChange"
11045 ]);
11046 var f = (0, react$1.useRef)(null);
11047 Q(f);
11048 var v = Y(o, l, i);
11049 var d = v[0];
11050 var h = v[1];
11051 var m = g(["react-colorful", n]);
11052 return react$1.default.createElement("div", u({}, s, {
11053 ref: f,
11054 className: m
11055 }), react$1.default.createElement(T, {
11056 hsva: d,
11057 onChange: h
11058 }), react$1.default.createElement(S, {
11059 hue: d.h,
11060 onChange: h,
11061 className: "react-colorful__last-control"
11062 }));
11063 };
11064 var W = {
11065 defaultColor: "000",
11066 toHsva: x,
11067 fromHsva: function(e) {
11068 return w({
11069 h: e.h,
11070 s: e.s,
11071 v: e.v,
11072 a: 1
11073 });
11074 },
11075 equal: X
11076 };
11077 var Z = function(r) {
11078 return react$1.default.createElement(U, u({}, r, { colorModel: W }));
11079 };
11080
11081 //#endregion
11082 //#region modules/ai/assets/js/editor/pages/form-media/components/color-picker.js
11083 init_defineProperty();
11084 init_slicedToArray();
11085 function ownKeys$12(e, r) {
11086 var t = Object.keys(e);
11087 if (Object.getOwnPropertySymbols) {
11088 var o = Object.getOwnPropertySymbols(e);
11089 r && (o = o.filter(function(r) {
11090 return Object.getOwnPropertyDescriptor(e, r).enumerable;
11091 })), t.push.apply(t, o);
11092 }
11093 return t;
11094 }
11095 __name(ownKeys$12, "ownKeys");
11096 function _objectSpread$12(e) {
11097 for (var r = 1; r < arguments.length; r++) {
11098 var t = null != arguments[r] ? arguments[r] : {};
11099 r % 2 ? ownKeys$12(Object(t), !0).forEach(function(r) {
11100 _defineProperty(e, r, t[r]);
11101 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$12(Object(t)).forEach(function(r) {
11102 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
11103 });
11104 }
11105 return e;
11106 }
11107 __name(_objectSpread$12, "_objectSpread");
11108 var ColorInput = function ColorInput(_ref) {
11109 var _elementorCommon$conf;
11110 var _elementorCommon;
11111 var label = _ref.label;
11112 var color = _ref.color;
11113 var onChange = _ref.onChange;
11114 var disabled = _ref.disabled;
11115 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
11116 var isOpened = _useState2[0];
11117 var setIsOpened = _useState2[1];
11118 var anchorEl = (0, react.useRef)();
11119 var _useState4 = _slicedToArray((0, react.useState)(170001), 2);
11120 var zIndex = _useState4[0];
11121 var setZIndex = _useState4[1];
11122 var isRTL = (_elementorCommon$conf = (_elementorCommon = elementorCommon) === null || _elementorCommon === void 0 || (_elementorCommon = _elementorCommon.config) === null || _elementorCommon === void 0 ? void 0 : _elementorCommon.isRTL) !== null && _elementorCommon$conf !== void 0 ? _elementorCommon$conf : true;
11123 (0, react.useEffect)(function() {
11124 if (anchorEl.current) {
11125 var element = anchorEl.current;
11126 var currentZIndex = 0;
11127 while (element && element !== document.body) {
11128 var computedZIndex = window.getComputedStyle(element).zIndex;
11129 if (computedZIndex !== "auto") {
11130 currentZIndex = parseInt(computedZIndex, 10) || 0;
11131 break;
11132 }
11133 element = element.parentElement;
11134 }
11135 setZIndex(currentZIndex > 0 ? currentZIndex + 1 : 170001);
11136 }
11137 }, [isOpened]);
11138 var handleClick = function handleClick() {
11139 return setIsOpened(true);
11140 };
11141 var handleClose = function handleClose() {
11142 setIsOpened(false);
11143 };
11144 var handleKeyDown = function handleKeyDown(event) {
11145 if ("Enter" === event.key || " " === event.key) {
11146 event.preventDefault();
11147 handleClick();
11148 }
11149 };
11150 var handleTextFieldChange = function handleTextFieldChange(event) {
11151 onChange("#".concat(event.target.value));
11152 };
11153 var handleColorPickerChange = function handleColorPickerChange(colorValue) {
11154 onChange(colorValue);
11155 };
11156 var id = isOpened ? "simple-popover" : void 0;
11157 return /*#__PURE__*/ react.default.createElement("div", {
11158 className: "el-ai-color-input-wrapper",
11159 style: _objectSpread$12({
11160 display: "flex",
11161 alignItems: "center"
11162 }, disabled ? {
11163 pointerEvents: "none",
11164 opacity: .5
11165 } : {})
11166 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.FormLabel, { sx: {
11167 whiteSpace: "nowrap",
11168 flex: 4
11169 } }, label), /*#__PURE__*/ react.default.createElement("button", {
11170 type: "button",
11171 onClick: handleClick,
11172 onKeyDown: handleKeyDown,
11173 style: {
11174 cursor: "pointer",
11175 borderRadius: "4px",
11176 marginRight: "8px",
11177 marginLeft: "8px",
11178 background: color,
11179 width: "100%",
11180 height: "auto",
11181 borderColor: "rgba(0, 0, 0, 0.23)",
11182 borderWidth: "1px",
11183 borderStyle: "solid",
11184 aspectRatio: "1 / 1",
11185 flex: 1.1
11186 },
11187 "aria-describedby": id,
11188 ref: anchorEl
11189 }), /*#__PURE__*/ react.default.createElement(StyledTextField, {
11190 value: color.substring(1, 7),
11191 color: "secondary",
11192 fullWidth: true,
11193 InputProps: {
11194 autoComplete: "off",
11195 color: "secondary",
11196 sx: { height: "100%" },
11197 startAdornment: /*#__PURE__*/ react.default.createElement(_elementor_ui.InputAdornment, { position: "start" }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
11198 variant: "body1",
11199 color: "secondary"
11200 }, "#"))
11201 },
11202 onChange: handleTextFieldChange,
11203 sx: {
11204 flex: 3,
11205 height: "40px"
11206 }
11207 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Popover, {
11208 id,
11209 anchorOrigin: {
11210 vertical: "bottom",
11211 horizontal: isRTL ? "right" : "left"
11212 },
11213 transformOrigin: {
11214 vertical: "top",
11215 horizontal: isRTL ? "right" : "left"
11216 },
11217 onClose: handleClose,
11218 open: isOpened,
11219 anchorEl: anchorEl.current,
11220 style: {
11221 zIndex,
11222 overflow: "hidden"
11223 }
11224 }, /*#__PURE__*/ react.default.createElement("div", {
11225 className: "el-ai-custom-color-picker",
11226 style: {
11227 height: "min-content",
11228 overflow: "hidden"
11229 }
11230 }, /*#__PURE__*/ react.default.createElement(Z, {
11231 color,
11232 onChange: handleColorPickerChange
11233 }))));
11234 };
11235 var StyledTextField = (0, _elementor_ui.styled)(_elementor_ui_TextField.default)(function() {
11236 return { ".wp-admin & .MuiInputBase-input, & .MuiInputBase-input:focus": {
11237 backgroundColor: "initial",
11238 boxShadow: "none",
11239 border: 0,
11240 color: "inherit",
11241 outline: 0,
11242 padding: 0,
11243 fontFamily: "inherit",
11244 minHeight: "2.4375em"
11245 } };
11246 });
11247 ColorInput.propTypes = {
11248 label: import_prop_types$7.default.string,
11249 color: import_prop_types$7.default.string,
11250 onChange: import_prop_types$7.default.func.isRequired,
11251 disabled: import_prop_types$7.default.bool
11252 };
11253
11254 //#endregion
11255 //#region modules/ai/assets/js/editor/pages/form-media/views/product-image-unification/hooks/use-product-image-unification.js
11256 init_api();
11257 var useProductImageUnification = function useProductImageUnification(initialValue) {
11258 return useImagePrompt((0, react.useRef)(function(payload) {
11259 return getProductImageUnification(payload, true);
11260 }).current, initialValue);
11261 };
11262
11263 //#endregion
11264 //#region modules/ai/assets/js/editor/pages/form-media/views/product-image-unification/components/product-image.js
11265 init_defineProperty();
11266 var ProductImage = function ProductImage(_ref) {
11267 var productId = _ref.productId;
11268 var ratio = _ref.ratio;
11269 var bgColor = _ref.bgColor;
11270 var image = _ref.image;
11271 var onUpdate = _ref.onUpdate;
11272 var isUploading = useImageActions().isLoading;
11273 var _useProductImageUnifi = useProductImageUnification(_defineProperty(_defineProperty(_defineProperty({ productId }, IMAGE_RATIO, ratio), IMAGE_BACKGROUND_COLOR, bgColor), "image", image));
11274 var data = _useProductImageUnifi.data;
11275 var isGenerating = _useProductImageUnifi.isLoading;
11276 var error = _useProductImageUnifi.error;
11277 var send = _useProductImageUnifi.send;
11278 var sendUsageData = _useProductImageUnifi.sendUsageData;
11279 (0, react.useEffect)(function() {
11280 if (onUpdate) onUpdate(data, isGenerating || isUploading, error, send, productId, ratio, bgColor, image, sendUsageData);
11281 }, [
11282 data,
11283 isGenerating,
11284 error,
11285 send,
11286 productId,
11287 ratio,
11288 bgColor,
11289 image,
11290 isUploading,
11291 onUpdate,
11292 sendUsageData
11293 ]);
11294 return /*#__PURE__*/ react.default.createElement("div", { style: { visibility: "hidden" } });
11295 };
11296 ProductImage.propTypes = {
11297 productId: import_prop_types$7.default.number,
11298 ratio: import_prop_types$7.default.string,
11299 bgColor: import_prop_types$7.default.string,
11300 image: import_prop_types$7.default.object,
11301 onUpdate: import_prop_types$7.default.func
11302 };
11303
11304 //#endregion
11305 //#region modules/ai/assets/js/editor/pages/form-media/views/product-image-unification/index.js
11306 init_defineProperty();
11307 init_asyncToGenerator();
11308 init_slicedToArray();
11309 init_requests_ids();
11310 function ownKeys$11(e, r) {
11311 var t = Object.keys(e);
11312 if (Object.getOwnPropertySymbols) {
11313 var o = Object.getOwnPropertySymbols(e);
11314 r && (o = o.filter(function(r) {
11315 return Object.getOwnPropertyDescriptor(e, r).enumerable;
11316 })), t.push.apply(t, o);
11317 }
11318 return t;
11319 }
11320 __name(ownKeys$11, "ownKeys");
11321 function _objectSpread$11(e) {
11322 for (var r = 1; r < arguments.length; r++) {
11323 var t = null != arguments[r] ? arguments[r] : {};
11324 r % 2 ? ownKeys$11(Object(t), !0).forEach(function(r) {
11325 _defineProperty(e, r, t[r]);
11326 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$11(Object(t)).forEach(function(r) {
11327 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
11328 });
11329 }
11330 return e;
11331 }
11332 __name(_objectSpread$11, "_objectSpread");
11333 var ProductImageUnification = function ProductImageUnification(_ref) {
11334 var _products$images$leng;
11335 var _products$images;
11336 var _Object$values;
11337 var _products$images$leng2;
11338 var _products$images2;
11339 var _products$images$leng3;
11340 var _products$images3;
11341 var _errorlessProducts$le;
11342 var _products$images4;
11343 var onClose = _ref.onClose;
11344 var setGenerate = useRequestIds().setGenerate;
11345 var products = useEditImage().editImage;
11346 var _usePromptSettings = usePromptSettings();
11347 var settings = _usePromptSettings.settings;
11348 var updateSettings = _usePromptSettings.updateSettings;
11349 var _useState2 = _slicedToArray((0, react.useState)({}), 2);
11350 var productsData = _useState2[0];
11351 var setProductsData = _useState2[1];
11352 var _useState4 = _slicedToArray((0, react.useState)({}), 2);
11353 var loadingMap = _useState4[0];
11354 var setLoadingMap = _useState4[1];
11355 var _useState6 = _slicedToArray((0, react.useState)({}), 2);
11356 var errorMap = _useState6[0];
11357 var setErrorMap = _useState6[1];
11358 var _useState8 = _slicedToArray((0, react.useState)({}), 2);
11359 var checkboxColorMap = _useState8[0];
11360 var setCheckboxColorMap = _useState8[1];
11361 var _useState0 = _slicedToArray((0, react.useState)(false), 2);
11362 var wasGeneratedOnce = _useState0[0];
11363 var setWasGeneratedOnce = _useState0[1];
11364 var useMultipleImages = useImageActions().useMultipleImages;
11365 var _useState10 = _slicedToArray((0, react.useState)(false), 2);
11366 var isSavingImages = _useState10[0];
11367 var setIsSavingImages = _useState10[1];
11368 var errorlessProducts = Object.values(productsData).filter(function(_ref2) {
11369 var _errorMap$productId;
11370 return !((_errorMap$productId = errorMap[_ref2.productId]) !== null && _errorMap$productId !== void 0 && _errorMap$productId.errorGenerating);
11371 });
11372 var use = (0, react.useCallback)(/*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee() {
11373 var generatedImages;
11374 var imagesToSave;
11375 return import_regenerator$2.default.wrap(function(_context) {
11376 while (1) switch (_context.prev = _context.next) {
11377 case 0:
11378 setIsSavingImages(true);
11379 generatedImages = errorlessProducts.filter(function(_ref4) {
11380 var data = _ref4.data;
11381 return _ref4.wasGenerated && (data === null || data === void 0 ? void 0 : data.isChecked) && (data === null || data === void 0 ? void 0 : data.productId) !== void 0;
11382 });
11383 imagesToSave = generatedImages.map(function(_ref5) {
11384 var data = _ref5.data;
11385 return _objectSpread$11(_objectSpread$11({}, data), {}, {
11386 editor_post_id: data.productId,
11387 unique_id: "ai-product-unification-".concat(data.productId)
11388 });
11389 });
11390 _context.next = 1;
11391 return useMultipleImages(imagesToSave);
11392 case 1:
11393 generatedImages.forEach(function(_ref6) {
11394 var sendUsageData = _ref6.sendUsageData;
11395 sendUsageData();
11396 });
11397 onClose();
11398 case 2:
11399 case "end": return _context.stop();
11400 }
11401 }, _callee);
11402 })), [
11403 onClose,
11404 errorlessProducts,
11405 useMultipleImages
11406 ]);
11407 var generatedAspectRatio = (0, react.useMemo)(function() {
11408 return settings[IMAGE_RATIO];
11409 }, [settings]);
11410 var generatedBgColor = (0, react.useMemo)(function() {
11411 return settings[IMAGE_BACKGROUND_COLOR];
11412 }, [settings]);
11413 var onProductUpdate = (0, react.useCallback)(function(res, isLoadingResult, errorGenerating, _req, productId, ratio, bgColor, image, sendUsageData) {
11414 setLoadingMap(function(prevState) {
11415 return _objectSpread$11(_objectSpread$11({}, prevState), {}, _defineProperty({}, productId, !!isLoadingResult));
11416 });
11417 setErrorMap(function(prevState) {
11418 return _objectSpread$11(_objectSpread$11({}, prevState), {}, _defineProperty({}, productId, { errorGenerating }));
11419 });
11420 setProductsData(function(prevState) {
11421 var _res$result;
11422 var _ref7;
11423 var _res$result$;
11424 var _res$result2;
11425 var _prevState$productId;
11426 var _prevState$productId$;
11427 var _prevState$productId2;
11428 var _checkboxColorMap$pro;
11429 return _objectSpread$11(_objectSpread$11({}, prevState), {}, _defineProperty({}, productId, _objectSpread$11(_objectSpread$11({}, prevState[productId]), {}, {
11430 productId,
11431 res,
11432 req: function req() {
11433 return _req({
11434 postId: productId,
11435 settings: _defineProperty(_defineProperty({}, IMAGE_RATIO, ratio), IMAGE_BACKGROUND_COLOR, bgColor),
11436 image
11437 });
11438 },
11439 sendUsageData,
11440 wasGenerated: (res === null || res === void 0 || (_res$result = res.result) === null || _res$result === void 0 ? void 0 : _res$result[0]) !== void 0,
11441 data: _objectSpread$11(_objectSpread$11({ productId }, !errorGenerating ? (_ref7 = (_res$result$ = res === null || res === void 0 || (_res$result2 = res.result) === null || _res$result2 === void 0 ? void 0 : _res$result2[0]) !== null && _res$result$ !== void 0 ? _res$result$ : image) !== null && _ref7 !== void 0 ? _ref7 : (_prevState$productId = prevState[productId]) === null || _prevState$productId === void 0 ? void 0 : _prevState$productId.image : {}), {}, {
11442 seed: productId,
11443 isChecked: (_prevState$productId$ = (_prevState$productId2 = prevState[productId]) === null || _prevState$productId2 === void 0 || (_prevState$productId2 = _prevState$productId2.data) === null || _prevState$productId2 === void 0 ? void 0 : _prevState$productId2.isChecked) !== null && _prevState$productId$ !== void 0 ? _prevState$productId$ : true,
11444 isLoading: isLoadingResult,
11445 checkboxColor: (_checkboxColorMap$pro = checkboxColorMap[productId]) !== null && _checkboxColorMap$pro !== void 0 ? _checkboxColorMap$pro : "rgba(0, 0, 0, 0.54)"
11446 })
11447 })));
11448 });
11449 }, [checkboxColorMap]);
11450 var isLoading = errorlessProducts.some(function(_ref8) {
11451 return loadingMap[_ref8.productId];
11452 });
11453 var isError = Object.values(errorMap).length && Object.values(errorMap).every(function(_ref9) {
11454 return _ref9.errorGenerating;
11455 });
11456 var thumbnailThreshold = 10;
11457 var exceedThumbnailThreshold = ((_products$images$leng = products === null || products === void 0 || (_products$images = products.images) === null || _products$images === void 0 ? void 0 : _products$images.length) !== null && _products$images$leng !== void 0 ? _products$images$leng : 0) - thumbnailThreshold > 0;
11458 var selectedProducts = errorlessProducts.filter(function(_ref0) {
11459 var data = _ref0.data;
11460 return data.isChecked && !data.isLoading;
11461 });
11462 var handleSubmit = (0, react.useCallback)(function(event) {
11463 event.preventDefault();
11464 setGenerate();
11465 setWasGeneratedOnce(true);
11466 var isLightColor = function isLightColor(color) {
11467 var rgb = parseInt(color.slice(1), 16);
11468 var r = rgb >> 16 & 255;
11469 var g = rgb >> 8 & 255;
11470 var b = rgb >> 0 & 255;
11471 return .299 * r + .587 * g + .114 * b > 128;
11472 };
11473 var productsToUnify = (errorlessProducts.length ? errorlessProducts : Object.values(productsData)).filter(function(product) {
11474 var _product$data;
11475 return ((_product$data = product.data) === null || _product$data === void 0 ? void 0 : _product$data.isChecked) && product.req;
11476 });
11477 var newCheckboxColor = isLightColor(generatedBgColor) ? "rgba(0, 0, 0, 0.54)" : "rgba( 255, 255, 255, 0.7 )";
11478 if (productsToUnify.find(function(product) {
11479 return checkboxColorMap[product.productId] !== newCheckboxColor;
11480 })) setCheckboxColorMap(function(prevState) {
11481 var newColorMap = _objectSpread$11({}, prevState);
11482 productsToUnify.forEach(function(product) {
11483 newColorMap[product.productId] = newCheckboxColor;
11484 });
11485 return newColorMap;
11486 });
11487 productsToUnify.forEach(function(product) {
11488 return product.req().catch(function() {});
11489 });
11490 }, [
11491 checkboxColorMap,
11492 errorlessProducts,
11493 generatedBgColor,
11494 productsData,
11495 setGenerate
11496 ]);
11497 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
11498 primary: (0, _wordpress_i18n.__)("Unify images", "elementor"),
11499 secondary: (0, _wordpress_i18n.__)("Select a set of parameters and AI will automate your adjustments:", "elementor")
11500 }), isError && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
11501 error: (_Object$values = Object.values(errorMap)) === null || _Object$values === void 0 || (_Object$values = _Object$values[0]) === null || _Object$values === void 0 ? void 0 : _Object$values.errorGenerating,
11502 onRetry: handleSubmit
11503 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, { gap: 2 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
11504 display: "flex",
11505 flexWrap: "wrap",
11506 width: "100%",
11507 "& .MuiAvatar-root": { margin: .5 }
11508 } }, products === null || products === void 0 ? void 0 : products.images.slice(0, exceedThumbnailThreshold ? thumbnailThreshold - 1 : thumbnailThreshold).map(function(img) {
11509 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Avatar, {
11510 key: img.productId,
11511 alt: img.productId + "",
11512 src: img.image_url,
11513 variant: "square",
11514 sx: {
11515 width: 50,
11516 height: 50
11517 }
11518 });
11519 }), exceedThumbnailThreshold && /*#__PURE__*/ react.default.createElement(_elementor_ui.Avatar, {
11520 variant: "square",
11521 sx: {
11522 bgcolor: "lightgray",
11523 width: 50,
11524 height: 50
11525 }
11526 }, ((_products$images$leng2 = products === null || products === void 0 || (_products$images2 = products.images) === null || _products$images2 === void 0 ? void 0 : _products$images2.length) !== null && _products$images$leng2 !== void 0 ? _products$images$leng2 : 0) - (thumbnailThreshold - 1))), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
11527 gap: 2,
11528 sx: { my: 2.5 }
11529 }, /*#__PURE__*/ react.default.createElement(ColorInput, {
11530 label: (0, _wordpress_i18n.__)("Background Color", "elementor"),
11531 color: generatedBgColor,
11532 onChange: function onChange(color) {
11533 return updateSettings(_defineProperty({}, IMAGE_BACKGROUND_COLOR, color));
11534 },
11535 disabled: isLoading
11536 }), /*#__PURE__*/ react.default.createElement(ImageRatioSelect, {
11537 disabled: true,
11538 value: generatedAspectRatio,
11539 onChange: function onChange(event) {
11540 return updateSettings(_defineProperty({}, IMAGE_RATIO, event.target.value));
11541 }
11542 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
11543 gap: 2,
11544 sx: { my: 2.5 }
11545 }, wasGeneratedOnce ? /*#__PURE__*/ react.default.createElement(GenerateAgainSubmit, { disabled: isLoading }) : /*#__PURE__*/ react.default.createElement(GenerateSubmit, { disabled: isLoading })))))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isSavingImages }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
11546 display: "flex",
11547 flexDirection: "column",
11548 height: "100%",
11549 alignItems: "center",
11550 justifyContent: "center",
11551 minHeight: "76vh"
11552 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
11553 flex: 1,
11554 overflowY: "auto",
11555 display: "flex",
11556 flexDirection: "column",
11557 height: "100%",
11558 alignItems: "center",
11559 justifyContent: "center",
11560 overflowX: "hidden"
11561 } }, wasGeneratedOnce ? /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, errorlessProducts.length > 1 && errorlessProducts.some(function(_ref1) {
11562 return !_ref1.data.isLoading;
11563 }) && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
11564 display: "flex",
11565 flexDirection: "row",
11566 alignItems: "inherit",
11567 justifyContent: "space-between",
11568 width: "100%"
11569 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
11570 variant: "body2",
11571 color: "secondary"
11572 }, (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("%1$d/%2$d selected", "elementor"), selectedProducts.length, (_products$images$leng3 = products === null || products === void 0 || (_products$images3 = products.images) === null || _products$images3 === void 0 ? void 0 : _products$images3.length) !== null && _products$images$leng3 !== void 0 ? _products$images$leng3 : 0)), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
11573 variant: "text",
11574 color: "secondary",
11575 onClick: function onClick() {
11576 var isChecked = !selectedProducts.some(function(product) {
11577 var _product$data2;
11578 return (_product$data2 = product.data) === null || _product$data2 === void 0 ? void 0 : _product$data2.isChecked;
11579 });
11580 setProductsData(function(prevState) {
11581 var newState = _objectSpread$11({}, prevState);
11582 Object.values(newState).forEach(function(product) {
11583 var _product$data3;
11584 if (isChecked !== ((_product$data3 = product.data) === null || _product$data3 === void 0 ? void 0 : _product$data3.isChecked)) newState[product.productId] = _objectSpread$11(_objectSpread$11({}, product), {}, { data: _objectSpread$11(_objectSpread$11({}, product.data), {}, { isChecked }) });
11585 });
11586 return newState;
11587 });
11588 }
11589 }, selectedProducts.some(function(product) {
11590 var _product$data4;
11591 return (_product$data4 = product.data) === null || _product$data4 === void 0 ? void 0 : _product$data4.isChecked;
11592 }) ? (0, _wordpress_i18n.__)("Clear all", "elementor") : (0, _wordpress_i18n.__)("Select all", "elementor"))), /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
11593 images: errorlessProducts.map(function(product) {
11594 return product.data;
11595 }),
11596 cols: function getCols() {
11597 var dataLength = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1;
11598 return Math.min(Math.ceil(Math.sqrt(dataLength !== null && dataLength !== void 0 ? dataLength : 1)), 4);
11599 }((_errorlessProducts$le = errorlessProducts.length) !== null && _errorlessProducts$le !== void 0 ? _errorlessProducts$le : 1),
11600 overlay: false,
11601 onSelectChange: function onSelectChange(productId, isChecked) {
11602 return setProductsData(function(prevState) {
11603 var _prevState$productId3;
11604 if ((_prevState$productId3 = prevState[productId]) !== null && _prevState$productId3 !== void 0 && _prevState$productId3.data) prevState[productId].data.isChecked = isChecked;
11605 return _objectSpread$11({}, prevState);
11606 });
11607 }
11608 })) : /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
11609 component: "img",
11610 src: window.UnifyProductImagesConfig.placeholder,
11611 alt: (0, _wordpress_i18n.__)("Example GIF", "elementor")
11612 })), wasGeneratedOnce && !isError && errorlessProducts.length && errorlessProducts.some(function(_ref10) {
11613 var data = _ref10.data;
11614 var errorGenerating = _ref10.errorGenerating;
11615 var wasGenerated = _ref10.wasGenerated;
11616 return (data === null || data === void 0 ? void 0 : data.isChecked) && !(data !== null && data !== void 0 && data.isLoadingResult) && !errorGenerating && wasGenerated;
11617 }) && /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, {
11618 onClick: use,
11619 sx: {
11620 alignSelf: "flex-end",
11621 mt: 2
11622 }
11623 }))), (_products$images4 = products.images) === null || _products$images4 === void 0 ? void 0 : _products$images4.filter(function(img) {
11624 return img.productId;
11625 }).map(function(img) {
11626 return /*#__PURE__*/ react.default.createElement(ProductImage, {
11627 key: "product-".concat(img.productId),
11628 productId: img.productId,
11629 ratio: settings[IMAGE_RATIO],
11630 bgColor: settings[IMAGE_BACKGROUND_COLOR],
11631 image: img,
11632 onUpdate: onProductUpdate
11633 });
11634 }));
11635 };
11636 ProductImageUnification.propTypes = { onClose: import_prop_types$7.default.func };
11637
11638 //#endregion
11639 //#region modules/ai/assets/js/editor/pages/form-media/views/isolate-objects/hooks/use-isolate-objects.js
11640 init_api();
11641 var useIsolateObject = function useIsolateObject(initialValue) {
11642 return useImagePrompt(function fetchAction(payload) {
11643 return getImageToImageIsolateObjects(payload);
11644 }, initialValue);
11645 };
11646
11647 //#endregion
11648 //#region modules/ai/assets/js/editor/pages/form-media/views/isolate-objects/index.js
11649 init_defineProperty();
11650 init_requests_ids();
11651 var IsolateObject = function IsolateObject() {
11652 var editImage = useEditImage().editImage;
11653 var setGenerate = useRequestIds().setGenerate;
11654 var _useImageActions = useImageActions();
11655 var use = _useImageActions.use;
11656 var edit = _useImageActions.edit;
11657 var isUploading = _useImageActions.isLoading;
11658 var _usePromptSettings = usePromptSettings();
11659 var settings = _usePromptSettings.settings;
11660 var updateSettings = _usePromptSettings.updateSettings;
11661 var _useIsolateObject = useIsolateObject();
11662 var data = _useIsolateObject.data;
11663 var send = _useIsolateObject.send;
11664 var isGenerating = _useIsolateObject.isLoading;
11665 var error = _useIsolateObject.error;
11666 var isLoading = isGenerating || isUploading;
11667 var _useImageSize = useImageSize(editImage.aspectRatio);
11668 var width = _useImageSize.width;
11669 var height = _useImageSize.height;
11670 var generatedAspectRatio = (0, react.useMemo)(function() {
11671 return settings[IMAGE_RATIO];
11672 }, [settings]);
11673 var generatedBgColor = (0, react.useMemo)(function() {
11674 return settings[IMAGE_BACKGROUND_COLOR];
11675 }, [settings]);
11676 var handleSubmit = function handleSubmit(event) {
11677 event.preventDefault();
11678 setGenerate();
11679 send({
11680 image: editImage,
11681 settings: _defineProperty(_defineProperty({}, IMAGE_RATIO, generatedAspectRatio), IMAGE_BACKGROUND_COLOR, generatedBgColor),
11682 featureIdentifier: FEATURE_IDENTIFIER.ISOLATE_OBJECT
11683 });
11684 };
11685 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, null), /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
11686 primary: (0, _wordpress_i18n.__)("Isolate Object", "elementor"),
11687 secondary: (0, _wordpress_i18n.__)("Remove the background, center your object, and add a drop shadow for a clean look.", "elementor")
11688 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
11689 error,
11690 onRetry: handleSubmit
11691 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
11692 gap: 2,
11693 sx: { my: 2.5 }
11694 }, /*#__PURE__*/ react.default.createElement(ColorInput, {
11695 label: (0, _wordpress_i18n.__)("Background Color", "elementor"),
11696 color: generatedBgColor,
11697 onChange: function onChange(color) {
11698 return updateSettings(_defineProperty({}, IMAGE_BACKGROUND_COLOR, color));
11699 },
11700 disabled: isLoading
11701 }), /*#__PURE__*/ react.default.createElement(GenerateSubmit, {
11702 disabled: isLoading,
11703 loading: isLoading
11704 }, (0, _wordpress_i18n.__)("Isolate Object", "elementor"))))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isLoading }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, null, /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
11705 transparentContainer: true,
11706 onUseImage: use,
11707 onEditImage: edit,
11708 images: data.result,
11709 aspectRatio: editImage.aspectRatio
11710 })) : /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
11711 src: editImage.url,
11712 alt: editImage.alt,
11713 style: {
11714 width,
11715 height
11716 }
11717 })))));
11718 };
11719
11720 //#endregion
11721 //#region modules/ai/assets/js/editor/pages/form-media/media-outlet.js
11722 init_loader();
11723 init_prompt_history_action_context();
11724 var MediaOutlet = function MediaOutlet(_ref) {
11725 var _ref$additionalOption = _ref.additionalOptions;
11726 var additionalOptions = _ref$additionalOption === void 0 ? null : _ref$additionalOption;
11727 var _ref$onClose = _ref.onClose;
11728 var onClose = _ref$onClose === void 0 ? null : _ref$onClose;
11729 var editImage = useEditImage().editImage;
11730 var _useLocation = useLocation({ current: (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.location) || LOCATIONS.GENERATE });
11731 var current = _useLocation.current;
11732 var navigate = _useLocation.navigate;
11733 (0, react.useEffect)(function() {
11734 if ((additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.location) && additionalOptions.location !== LOCATIONS.GENERATE) {
11735 navigate(additionalOptions.location);
11736 return;
11737 }
11738 if (editImage.url) if (new RegExp(IMAGE_PLACEHOLDERS_HOSTS.WIREFRAME).test(new URL(editImage.url).host)) navigate(LOCATIONS.GENERATE);
11739 else if ("url" === editImage.source || editImage.id) navigate(LOCATIONS.IMAGE_TOOLS);
11740 else navigate(LOCATIONS.GENERATE);
11741 }, [
11742 editImage.id,
11743 editImage.url,
11744 editImage.source,
11745 additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.location
11746 ]);
11747 useSubscribeOnPromptHistoryAction([{
11748 type: ACTION_TYPES.RESTORE,
11749 handler: function handler() {
11750 if (current !== LOCATIONS.GENERATE) navigate(LOCATIONS.GENERATE);
11751 }
11752 }]);
11753 if (!current) return /*#__PURE__*/ react.default.createElement(View, { alignItems: "center" }, /*#__PURE__*/ react.default.createElement(Loader, null));
11754 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, current === LOCATIONS.GENERATE && /*#__PURE__*/ react.default.createElement(Generate, {
11755 textToImageHook: additionalOptions !== null && additionalOptions !== void 0 && additionalOptions.textToImageHook ? additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.textToImageHook : useTextToImage,
11756 predefinedPrompt: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.predefinedPrompt,
11757 initialSettings: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.initialSettings
11758 }), current === LOCATIONS.IMAGE_TOOLS && /*#__PURE__*/ react.default.createElement(ImageTools, null), current === LOCATIONS.VARIATIONS && /*#__PURE__*/ react.default.createElement(Variations, null), current === LOCATIONS.IN_PAINTING && /*#__PURE__*/ react.default.createElement(InPainting, null), current === LOCATIONS.OUT_PAINTING && /*#__PURE__*/ react.default.createElement(OutPainting, null), current === LOCATIONS.RESIZE && /*#__PURE__*/ react.default.createElement(Resize, null), current === LOCATIONS.REPLACE_BACKGROUND && /*#__PURE__*/ react.default.createElement(ReplaceBackground, null), current === LOCATIONS.REMOVE_BACKGROUND && /*#__PURE__*/ react.default.createElement(RemoveBackground, null), current === LOCATIONS.CLEANUP && /*#__PURE__*/ react.default.createElement(Cleanup, null), current === LOCATIONS.PRODUCT_IMAGE_UNIFICATION && /*#__PURE__*/ react.default.createElement(ProductImageUnification, { onClose }), current === LOCATIONS.ISOLATE_OBJECT && /*#__PURE__*/ react.default.createElement(IsolateObject, null));
11759 };
11760 MediaOutlet.propTypes = {
11761 additionalOptions: import_prop_types$7.default.object,
11762 onClose: import_prop_types$7.default.func
11763 };
11764
11765 //#endregion
11766 //#region modules/ai/assets/js/editor/pages/form-media/components/unsaved-changes-alert.js
11767 init_extends();
11768 init_objectWithoutProperties();
11769 var _excluded$13 = ["onClose", "onCancel"];
11770 var UnsavedChangesAlert$1 = function UnsavedChangesAlert(_ref) {
11771 var onClose = _ref.onClose;
11772 var onCancel = _ref.onCancel;
11773 var props = _objectWithoutProperties(_ref, _excluded$13);
11774 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, _extends$1({
11775 sx: { zIndex: 2e5 },
11776 "aria-labelledby": "unsaved-changes-alert-title",
11777 "aria-describedby": "unsaved-changes-alert-description"
11778 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogTitle, { id: "unsaved-changes-alert-title" }, (0, _wordpress_i18n.__)("Leave Elementor AI?", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogContent, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogContentText, { id: "unsaved-changes-alert-description" }, (0, _wordpress_i18n.__)("Images will be gone forever and we won’t be able to recover them.", "elementor"))), /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogActions, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
11779 onClick: onCancel,
11780 color: "secondary"
11781 }, (0, _wordpress_i18n.__)("Cancel", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
11782 onClick: onClose,
11783 color: "error",
11784 variant: "contained"
11785 }, (0, _wordpress_i18n.__)("Yes, leave", "elementor"))));
11786 };
11787 UnsavedChangesAlert$1.propTypes = {
11788 onClose: import_prop_types$7.default.func,
11789 onCancel: import_prop_types$7.default.func
11790 };
11791
11792 //#endregion
11793 //#region node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteral.js
11794 function _taggedTemplateLiteral(e, t) {
11795 return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } }));
11796 }
11797
11798 //#endregion
11799 //#region modules/ai/assets/js/editor/components/prompt-history/history-button.js
11800 init_extends();
11801 init_objectWithoutProperties();
11802 var _excluded$12 = ["isActive"];
11803 var _templateObject$6;
11804 var StyledHistoryButton = (0, _elementor_ui.styled)(_elementor_ui.IconButton)(_templateObject$6 || (_templateObject$6 = _taggedTemplateLiteral([
11805 "\n margin-right: ",
11806 ";\n\n ",
11807 "\n"
11808 ])), function(_ref) {
11809 return _ref.theme.spacing(2);
11810 }, function(_ref2) {
11811 var isActive = _ref2.isActive;
11812 var theme = _ref2.theme;
11813 return isActive && "\n background-color: ".concat(theme.palette.action.hover, ";\n color: ").concat(theme.palette.text.tertiary, ";\n ");
11814 });
11815 var PromptHistoryButton = function PromptHistoryButton(_ref3) {
11816 var isActive = _ref3.isActive;
11817 var props = _objectWithoutProperties(_ref3, _excluded$12);
11818 return /*#__PURE__*/ react.default.createElement(StyledHistoryButton, _extends$1({
11819 "aria-label": (0, _wordpress_i18n.__)("Show prompt history", "elementor"),
11820 type: "button",
11821 size: "small",
11822 isActive
11823 }, props), /*#__PURE__*/ react.default.createElement(_elementor_icons.HistoryIcon, null));
11824 };
11825 PromptHistoryButton.propTypes = { isActive: import_prop_types$7.default.bool.isRequired };
11826
11827 //#endregion
11828 //#region modules/ai/assets/js/editor/hooks/use-prompt-history.js
11829 init_asyncToGenerator();
11830 init_slicedToArray();
11831 init_defineProperty();
11832 init_api();
11833 function ownKeys$10(e, r) {
11834 var t = Object.keys(e);
11835 if (Object.getOwnPropertySymbols) {
11836 var o = Object.getOwnPropertySymbols(e);
11837 r && (o = o.filter(function(r) {
11838 return Object.getOwnPropertyDescriptor(e, r).enumerable;
11839 })), t.push.apply(t, o);
11840 }
11841 return t;
11842 }
11843 __name(ownKeys$10, "ownKeys");
11844 function _objectSpread$10(e) {
11845 for (var r = 1; r < arguments.length; r++) {
11846 var t = null != arguments[r] ? arguments[r] : {};
11847 r % 2 ? ownKeys$10(Object(t), !0).forEach(function(r) {
11848 _defineProperty(e, r, t[r]);
11849 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$10(Object(t)).forEach(function(r) {
11850 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
11851 });
11852 }
11853 return e;
11854 }
11855 __name(_objectSpread$10, "_objectSpread");
11856 var getImageThumbnailURL = function getImageThumbnailURL(base, imageURL) {
11857 if (!base) return imageURL;
11858 return "".concat(base, "/?o=").concat(btoa(imageURL, false));
11859 };
11860 var normalizeItems = function normalizeItems(response) {
11861 var meta = response.meta;
11862 var items = response.items;
11863 return items === null || items === void 0 ? void 0 : items.map(function(item) {
11864 var _item$request;
11865 var _item$request2;
11866 var _item$request3;
11867 var _item$response;
11868 var _item$response2;
11869 var _item$response3;
11870 return {
11871 id: item === null || item === void 0 ? void 0 : item.elementorApiId,
11872 date: item === null || item === void 0 ? void 0 : item.createdAt,
11873 action: item === null || item === void 0 ? void 0 : item.action,
11874 prompt: item === null || item === void 0 || (_item$request = item.request) === null || _item$request === void 0 ? void 0 : _item$request.prompt,
11875 imageType: item === null || item === void 0 || (_item$request2 = item.request) === null || _item$request2 === void 0 ? void 0 : _item$request2.image_type,
11876 ratio: item === null || item === void 0 || (_item$request3 = item.request) === null || _item$request3 === void 0 ? void 0 : _item$request3.ratio,
11877 text: item === null || item === void 0 || (_item$response = item.response) === null || _item$response === void 0 || (_item$response = _item$response.results) === null || _item$response === void 0 ? void 0 : _item$response.text,
11878 images: item === null || item === void 0 || (_item$response2 = item.response) === null || _item$response2 === void 0 || (_item$response2 = _item$response2.results) === null || _item$response2 === void 0 ? void 0 : _item$response2.images,
11879 thumbnails: item === null || item === void 0 || (_item$response3 = item.response) === null || _item$response3 === void 0 || (_item$response3 = _item$response3.results) === null || _item$response3 === void 0 || (_item$response3 = _item$response3.images) === null || _item$response3 === void 0 ? void 0 : _item$response3.map(function(image) {
11880 return _objectSpread$10(_objectSpread$10({}, image), {}, { image_url: getImageThumbnailURL(meta.thumbnailUrl, image.image_url) });
11881 })
11882 };
11883 });
11884 };
11885 var usePromptHistory = function usePromptHistory(historyType) {
11886 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
11887 var isLoading = _useState2[0];
11888 var setIsLoading = _useState2[1];
11889 var _useState4 = _slicedToArray((0, react.useState)({}), 2);
11890 var data = _useState4[0];
11891 var setData = _useState4[1];
11892 var _useState6 = _slicedToArray((0, react.useState)(""), 2);
11893 var error = _useState6[0];
11894 var setError = _useState6[1];
11895 var fetchData = /*#__PURE__*/ function() {
11896 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(_ref) {
11897 var page;
11898 var limit;
11899 return import_regenerator$2.default.wrap(function(_context) {
11900 while (1) switch (_context.prev = _context.next) {
11901 case 0:
11902 page = _ref.page, limit = _ref.limit;
11903 return _context.abrupt("return", new Promise(function(resolve, reject) {
11904 setIsLoading(true);
11905 getHistory(historyType, page, limit).then(function(response) {
11906 var clone = JSON.parse(JSON.stringify(data));
11907 clone.meta = response.meta;
11908 clone.items = [].concat(_toConsumableArray((clone === null || clone === void 0 ? void 0 : clone.items) || []), _toConsumableArray(normalizeItems(response)));
11909 setData(clone);
11910 resolve(true);
11911 }).catch(function(err) {
11912 var finalError = (err === null || err === void 0 ? void 0 : err.responseText) || err;
11913 setError(finalError);
11914 reject(finalError);
11915 }).finally(function() {
11916 return setIsLoading(false);
11917 });
11918 }));
11919 case 1:
11920 case "end": return _context.stop();
11921 }
11922 }, _callee);
11923 }));
11924 return function fetchData(_x) {
11925 return _ref2.apply(this, arguments);
11926 };
11927 }();
11928 return {
11929 isLoading,
11930 error,
11931 items: data.items,
11932 meta: data.meta,
11933 fetchData,
11934 deleteItemById: function deleteItemById(id) {
11935 var itemIndex = data.items.findIndex(function(item) {
11936 return item.id === id;
11937 });
11938 if (-1 === itemIndex) return false;
11939 var clone = JSON.parse(JSON.stringify(data));
11940 clone.items.splice(itemIndex, 1);
11941 setData(clone);
11942 return true;
11943 }
11944 };
11945 };
11946
11947 //#endregion
11948 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-header.js
11949 var StyledContent$2 = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref) {
11950 var theme = _ref.theme;
11951 return {
11952 marginTop: 0,
11953 padding: theme.spacing(1.5),
11954 borderBottom: "1px solid ".concat(theme.palette.action.focus),
11955 display: "flex",
11956 alignItems: "center",
11957 justifyContent: "space-between"
11958 };
11959 });
11960 var PromptHistoryModalHeader = function PromptHistoryModalHeader(_ref2) {
11961 var onClose = _ref2.onClose;
11962 return /*#__PURE__*/ react.default.createElement(StyledContent$2, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
11963 fontWeight: "bolder",
11964 variant: "h6",
11965 sx: { userSelect: "none" }
11966 }, (0, _wordpress_i18n.__)("History", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
11967 size: "small",
11968 "aria-label": (0, _wordpress_i18n.__)("Hide prompt history", "elementor"),
11969 onClick: onClose
11970 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.XIcon, { fontSize: "small" })));
11971 };
11972 PromptHistoryModalHeader.propTypes = { onClose: import_prop_types$7.default.func.isRequired };
11973
11974 //#endregion
11975 //#region modules/ai/assets/js/editor/hooks/use-delete-prompt-history-item.js
11976 init_asyncToGenerator();
11977 init_slicedToArray();
11978 init_api();
11979 var useDeletePromptHistoryItem = function useDeletePromptHistoryItem() {
11980 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
11981 var isLoading = _useState2[0];
11982 var setIsLoading = _useState2[1];
11983 var _useState4 = _slicedToArray((0, react.useState)(""), 2);
11984 var error = _useState4[0];
11985 var setError = _useState4[1];
11986 return {
11987 isLoading,
11988 error,
11989 deleteItem: /* @__PURE__ */ function() {
11990 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(id) {
11991 return import_regenerator$2.default.wrap(function(_context) {
11992 while (1) switch (_context.prev = _context.next) {
11993 case 0: return _context.abrupt("return", new Promise(function(resolve, reject) {
11994 setError("");
11995 setIsLoading(true);
11996 deleteHistoryItem(id).then(function() {
11997 resolve(true);
11998 }).catch(function(err) {
11999 var finalError = (err === null || err === void 0 ? void 0 : err.responseText) || err;
12000 setError(finalError);
12001 reject(finalError);
12002 }).finally(function() {
12003 return setIsLoading(false);
12004 });
12005 }));
12006 case 1:
12007 case "end": return _context.stop();
12008 }
12009 }, _callee);
12010 }));
12011 return function deleteItem(_x) {
12012 return _ref.apply(this, arguments);
12013 };
12014 }()
12015 };
12016 };
12017
12018 //#endregion
12019 //#region modules/ai/assets/js/editor/helpers/date-helpers.js
12020 /**
12021 * Formats a date (like wp_date() in PHP), translating it into site's locale.
12022 *
12023 * @param {string} format PHP-style formatting string.
12024 * @param {Date | string | undefined} date Date object
12025 * @param {string | number | undefined=} timezone Timezone to output result in or a UTC offset. Defaults to timezone from site.
12026 * @return {string}
12027 */
12028 var translateDate = function translateDate(format, date, timezone) {
12029 var _window$wp;
12030 if ((_window$wp = window.wp) !== null && _window$wp !== void 0 && _window$wp.date) {
12031 var _window$wp2;
12032 var dateI18n = ((_window$wp2 = window.wp) === null || _window$wp2 === void 0 ? void 0 : _window$wp2.date).dateI18n;
12033 return dateI18n(format, date, timezone);
12034 }
12035 return date;
12036 };
12037 /**
12038 * Returns difference in days between two dates
12039 *
12040 * @param {Date} firstDate
12041 * @param {Date} secondDate
12042 * @return {number} Positive or negative number in days
12043 */
12044 var daysDiff = function daysDiff(firstDate, secondDate) {
12045 var MS_PER_DAY = 1e3 * 60 * 60 * 24;
12046 var firstUTC = Date.UTC(firstDate.getFullYear(), firstDate.getMonth(), firstDate.getDate());
12047 var secondUTC = Date.UTC(secondDate.getFullYear(), secondDate.getMonth(), secondDate.getDate());
12048 return Math.floor((secondUTC - firstUTC) / MS_PER_DAY);
12049 };
12050
12051 //#endregion
12052 //#region modules/ai/assets/js/editor/icons/restore-icon.js
12053 init_extends();
12054 var RestoreIcon = react.default.forwardRef(function(props, ref) {
12055 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
12056 fillRule: "evenodd",
12057 d: "M11.913 3.22a8.781 8.781 0 0 1 3.367.634.75.75 0 1 1-.56 1.392A7.281 7.281 0 0 0 8.25 18.24V15a.75.75 0 0 1 1.5 0v4.433a.73.73 0 0 1 0 .034V20a.75.75 0 0 1-.75.75H4a.75.75 0 0 1 0-1.5h3.045a8.782 8.782 0 0 1 4.868-16.03ZM18.37 6.41a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-1.5 0v-.01a.75.75 0 0 1 .75-.75ZM13 19.19a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-1.5 0v-.01a.75.75 0 0 1 .75-.75ZM16.84 17.62a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-1.5 0v-.01a.75.75 0 0 1 .75-.75ZM19.37 14.35a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-1.5 0v-.01a.75.75 0 0 1 .75-.75ZM19.94 10.25a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-1.5 0V11a.75.75 0 0 1 .75-.75Z",
12058 clipRule: "evenodd"
12059 }));
12060 });
12061
12062 //#endregion
12063 //#region modules/ai/assets/js/editor/components/tooltip.js
12064 init_extends();
12065 init_objectWithoutProperties();
12066 var _excluded$11 = ["children"];
12067 var Tooltip$2 = function Tooltip(_ref) {
12068 var children = _ref.children;
12069 var props = _objectWithoutProperties(_ref, _excluded$11);
12070 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, _extends$1({ componentsProps: { tooltip: { sx: {
12071 "&.MuiTooltip-tooltip[class*=\"MuiTooltip-tooltipPlacement\"]": {
12072 m: 0,
12073 fontSize: "10px",
12074 fontWeight: 500,
12075 lineHeight: "1.4em"
12076 },
12077 py: .5,
12078 px: 1
12079 } } } }, props), children);
12080 };
12081 Tooltip$2.propTypes = { children: import_prop_types$7.default.oneOfType([import_prop_types$7.default.arrayOf(import_prop_types$7.default.node), import_prop_types$7.default.node]) };
12082
12083 //#endregion
12084 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-item-action-button.js
12085 init_extends();
12086 init_objectWithoutProperties();
12087 var _excluded$10 = ["tooltipTitle"];
12088 var ActionButton = function ActionButton(_ref) {
12089 var tooltipTitle = _ref.tooltipTitle;
12090 var props = _objectWithoutProperties(_ref, _excluded$10);
12091 return /*#__PURE__*/ react.default.createElement(Tooltip$2, {
12092 title: tooltipTitle,
12093 placement: "top"
12094 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, _extends$1({
12095 type: "button",
12096 size: "small",
12097 disableRipple: true,
12098 disableFocusRipple: true,
12099 disableTouchRipple: true
12100 }, props)));
12101 };
12102 ActionButton.propTypes = { tooltipTitle: import_prop_types$7.default.string.isRequired };
12103
12104 //#endregion
12105 //#region modules/ai/assets/js/editor/icons/text-icon.js
12106 init_extends();
12107 var TextIcon = react.default.forwardRef(function(props, ref) {
12108 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
12109 fillRule: "evenodd",
12110 d: "M4.25 5A.75.75 0 0 1 5 4.25h14a.75.75 0 0 1 .75.75v2a.75.75 0 0 1-1.5 0V5.75H5.75V7a.75.75 0 0 1-1.5 0V5Z",
12111 clipRule: "evenodd"
12112 }), /*#__PURE__*/ react.default.createElement("path", {
12113 fillRule: "evenodd",
12114 d: "M12 4.25a.75.75 0 0 1 .75.75v14a.75.75 0 0 1-1.5 0V5a.75.75 0 0 1 .75-.75Z",
12115 clipRule: "evenodd"
12116 }), /*#__PURE__*/ react.default.createElement("path", {
12117 fillRule: "evenodd",
12118 d: "M9.25 19a.75.75 0 0 1 .75-.75h4a.75.75 0 0 1 0 1.5h-4a.75.75 0 0 1-.75-.75Z",
12119 clipRule: "evenodd"
12120 }));
12121 });
12122
12123 //#endregion
12124 //#region modules/ai/assets/js/editor/icons/code-icon.js
12125 init_extends();
12126 var CodeIcon = react.default.forwardRef(function(props, ref) {
12127 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
12128 fillRule: "evenodd",
12129 d: "M7.53 7.47a.75.75 0 0 1 0 1.06L4.06 12l3.47 3.47a.75.75 0 1 1-1.06 1.06l-4-4a.75.75 0 0 1 0-1.06l4-4a.75.75 0 0 1 1.06 0ZM16.47 7.47a.75.75 0 0 1 1.06 0l4 4a.75.75 0 0 1 0 1.06l-4 4a.75.75 0 1 1-1.06-1.06L19.94 12l-3.47-3.47a.75.75 0 0 1 0-1.06ZM14.182 3.272a.75.75 0 0 1 .546.91l-4 16a.75.75 0 0 1-1.456-.364l4-16a.75.75 0 0 1 .91-.546Z",
12130 clipRule: "evenodd"
12131 }));
12132 });
12133
12134 //#endregion
12135 //#region modules/ai/assets/js/editor/components/prompt-history/parts/action-icon.js
12136 var FALLBACK_ICON = /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { "data-testid": "e-ph-fi" });
12137 var ICONS_BY_ACTIONS = Object.freeze({
12138 "enhance-image-prompt": /*#__PURE__*/ react.default.createElement(TextIcon, null),
12139 "get-text": /*#__PURE__*/ react.default.createElement(TextIcon, null),
12140 "edit-text": /*#__PURE__*/ react.default.createElement(TextIcon, null),
12141 "custom-css": /*#__PURE__*/ react.default.createElement(CodeIcon, null),
12142 "custom-code": /*#__PURE__*/ react.default.createElement(CodeIcon, null)
12143 });
12144 var PromptHistoryActionIcon = function PromptHistoryActionIcon(_ref) {
12145 var action = _ref.action;
12146 if (ICONS_BY_ACTIONS[action]) return ICONS_BY_ACTIONS[action];
12147 return FALLBACK_ICON;
12148 };
12149 PromptHistoryActionIcon.propTypes = { action: import_prop_types$7.default.string.isRequired };
12150
12151 //#endregion
12152 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-item-title.js
12153 var _templateObject$5;
12154 var StyledTitle = (0, _elementor_ui.styled)(_elementor_ui.Typography)(_templateObject$5 || (_templateObject$5 = _taggedTemplateLiteral(["\n margin-bottom: ", ";\n"])), function(_ref) {
12155 return _ref.theme.spacing(.5);
12156 });
12157 var PromptHistoryItemTitle = function PromptHistoryItemTitle(_ref2) {
12158 var prompt = _ref2.prompt;
12159 return /*#__PURE__*/ react.default.createElement(Tooltip$2, {
12160 title: prompt,
12161 arrow: false,
12162 placement: "bottom-start"
12163 }, /*#__PURE__*/ react.default.createElement(StyledTitle, {
12164 variant: "body2",
12165 noWrap: true,
12166 paragraph: true
12167 }, prompt));
12168 };
12169 PromptHistoryItemTitle.propTypes = { prompt: import_prop_types$7.default.string.isRequired };
12170
12171 //#endregion
12172 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-item-secondary-content.js
12173 var _templateObject$4;
12174 var _templateObject2$2;
12175 var StyledDateSubtitle = (0, _elementor_ui.styled)(_elementor_ui.Typography)(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteral(["\n color: ", ";\n"])), function(_ref) {
12176 return _ref.theme.palette.secondary.light;
12177 });
12178 var StyledImage = (0, _elementor_ui.styled)("img")(_templateObject2$2 || (_templateObject2$2 = _taggedTemplateLiteral(["\n height: 72px;\n width: 72px;\n object-fit: cover;\n margin-right: ", ";\n"])), function(_ref2) {
12179 return _ref2.theme.spacing(.5);
12180 });
12181 var PromptHistoryItemSecondaryContent = function PromptHistoryItemSecondaryContent(_ref3) {
12182 var date = _ref3.date;
12183 var thumbnails = _ref3.thumbnails;
12184 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
12185 direction: "column",
12186 width: "90%"
12187 }, /*#__PURE__*/ react.default.createElement(StyledDateSubtitle, { variant: "caption" }, date), (thumbnails === null || thumbnails === void 0 ? void 0 : thumbnails.length) > 0 && /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
12188 flexDirection: "row",
12189 mt: 1
12190 }, thumbnails.map(
12191 /**
12192 * @param {Object} thumb
12193 * @return {React.ReactNode}
12194 */
12195 function(thumb) {
12196 return /*#__PURE__*/ react.default.createElement(StyledImage, {
12197 key: "thumbnail-".concat(thumb.seed),
12198 alt: "",
12199 src: thumb.image_url
12200 });
12201 }
12202 )));
12203 };
12204 PromptHistoryItemSecondaryContent.propTypes = {
12205 date: import_prop_types$7.default.string.isRequired,
12206 thumbnails: import_prop_types$7.default.array
12207 };
12208
12209 //#endregion
12210 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-item.js
12211 init_objectWithoutProperties();
12212 init_prompt_history_action_context();
12213 var _excluded$9 = [
12214 "id",
12215 "date",
12216 "onHistoryItemDelete"
12217 ];
12218 var _templateObject$3;
12219 var _templateObject2$1;
12220 var _templateObject3;
12221 var _templateObject4;
12222 var StyledListItem = (0, _elementor_ui.styled)(_elementor_ui.ListItem)(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteral(["\n & .e-prompt-history-item-actions {\n position: absolute;\n top: -9999px;\n }\n\n &:hover,\n &:focus-visible,\n &:focus-within {\n .MuiTypography-body2 {\n font-weight: 700;\n max-width: ", ";\n }\n\n .e-prompt-history-item-actions {\n position: relative;\n top: -3px;\n }\n }\n"])), function(_ref) {
12223 var actionsCount = _ref.actionsCount;
12224 return "calc(100% - ".concat(actionsCount, " * 26px)");
12225 });
12226 var StyledListItemButton = (0, _elementor_ui.styled)(_elementor_ui.ListItemButton)(_templateObject2$1 || (_templateObject2$1 = _taggedTemplateLiteral(["\n padding: ", ";\n align-items: flex-start;\n cursor: inherit;\n"])), function(_ref2) {
12227 return _ref2.theme.spacing(.5, 2);
12228 });
12229 var StyledListItemIcon = (0, _elementor_ui.styled)(_elementor_ui.ListItemIcon)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral([
12230 "\n min-width: auto;\n\n & > .MuiSvgIcon-root {\n margin-right: ",
12231 ";\n font-size: 1rem;\n position: relative;\n top: ",
12232 ";\n }\n"
12233 ])), function(_ref3) {
12234 return _ref3.theme.spacing(1.5);
12235 }, function(_ref4) {
12236 return _ref4.theme.spacing(.5);
12237 });
12238 var StyledButtonsWrapper = (0, _elementor_ui.styled)(_elementor_ui.Box)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n & .MuiSvgIcon-root {\n font-size: 1rem;\n }\n"])));
12239 var PromptHistoryItem = function PromptHistoryItem(_ref5) {
12240 var id = _ref5.id;
12241 var date = _ref5.date;
12242 var onHistoryItemDelete = _ref5.onHistoryItemDelete;
12243 var props = _objectWithoutProperties(_ref5, _excluded$9);
12244 var _usePromptHistoryActi = usePromptHistoryAction();
12245 var getAllowedActions = _usePromptHistoryActi.getAllowedActions;
12246 var onPromptReuse = _usePromptHistoryActi.onPromptReuse;
12247 var onResultEdit = _usePromptHistoryActi.onResultEdit;
12248 var onImagesRestore = _usePromptHistoryActi.onImagesRestore;
12249 var action = props.action;
12250 var prompt = props.prompt;
12251 var text = props.text;
12252 var images = props.images;
12253 var thumbnails = props.thumbnails;
12254 var imageType = props.imageType;
12255 var ratio = props.ratio;
12256 var allowedActions = getAllowedActions();
12257 return /*#__PURE__*/ react.default.createElement(StyledListItem, {
12258 tabIndex: "0",
12259 "data-testid": "e-ph-i",
12260 disableGutters: true,
12261 disablePadding: true,
12262 actionsCount: Object.keys(allowedActions).length
12263 }, /*#__PURE__*/ react.default.createElement(StyledListItemButton, {
12264 component: "div",
12265 role: void 0
12266 }, /*#__PURE__*/ react.default.createElement(StyledListItemIcon, null, /*#__PURE__*/ react.default.createElement(PromptHistoryActionIcon, { action })), /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemText, {
12267 disableTypography: true,
12268 primary: /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
12269 direction: "row",
12270 justifyContent: "space-between",
12271 alignItems: "center",
12272 height: "16px"
12273 }, /*#__PURE__*/ react.default.createElement(PromptHistoryItemTitle, { prompt }), /*#__PURE__*/ react.default.createElement(StyledButtonsWrapper, { className: "e-prompt-history-item-actions" }, allowedActions[ACTION_TYPES.REMOVE] && /*#__PURE__*/ react.default.createElement(ActionButton, {
12274 onClick: function onClick() {
12275 return onHistoryItemDelete(id);
12276 },
12277 "aria-label": (0, _wordpress_i18n.__)("Remove item", "elementor"),
12278 tooltipTitle: (0, _wordpress_i18n.__)("Remove", "elementor")
12279 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.TrashIcon, null)), allowedActions[ACTION_TYPES.REUSE] && /*#__PURE__*/ react.default.createElement(ActionButton, {
12280 onClick: function onClick() {
12281 return onPromptReuse(id, prompt);
12282 },
12283 "aria-label": (0, _wordpress_i18n.__)("Reuse prompt", "elementor"),
12284 tooltipTitle: (0, _wordpress_i18n.__)("Reuse prompt", "elementor")
12285 }, /*#__PURE__*/ react.default.createElement(RefreshIcon, null)), allowedActions[ACTION_TYPES.RESTORE] && /*#__PURE__*/ react.default.createElement(ActionButton, {
12286 onClick: function onClick() {
12287 return onImagesRestore(id, {
12288 prompt,
12289 images,
12290 imageType,
12291 ratio
12292 });
12293 },
12294 "aria-label": (0, _wordpress_i18n.__)("Restore", "elementor"),
12295 tooltipTitle: (0, _wordpress_i18n.__)("Restore", "elementor")
12296 }, /*#__PURE__*/ react.default.createElement(RestoreIcon, null)), allowedActions[ACTION_TYPES.EDIT] && /*#__PURE__*/ react.default.createElement(ActionButton, {
12297 onClick: function onClick() {
12298 return onResultEdit(id, text);
12299 },
12300 "aria-label": (0, _wordpress_i18n.__)("Edit result", "elementor"),
12301 tooltipTitle: (0, _wordpress_i18n.__)("Edit", "elementor")
12302 }, /*#__PURE__*/ react.default.createElement(EditIcon$1, null)))),
12303 secondary: /*#__PURE__*/ react.default.createElement(PromptHistoryItemSecondaryContent, {
12304 date,
12305 thumbnails
12306 })
12307 })));
12308 };
12309 PromptHistoryItem.propTypes = {
12310 id: import_prop_types$7.default.string.isRequired,
12311 action: import_prop_types$7.default.string.isRequired,
12312 prompt: import_prop_types$7.default.string.isRequired,
12313 date: import_prop_types$7.default.string.isRequired,
12314 onHistoryItemDelete: import_prop_types$7.default.func.isRequired,
12315 text: import_prop_types$7.default.string,
12316 images: import_prop_types$7.default.array,
12317 thumbnails: import_prop_types$7.default.array,
12318 imageType: import_prop_types$7.default.string,
12319 ratio: import_prop_types$7.default.string
12320 };
12321
12322 //#endregion
12323 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-period.js
12324 init_extends();
12325 init_objectWithoutProperties();
12326 var _excluded$8 = ["id", "date"];
12327 var StyledPeriodList = (0, _elementor_ui.styled)(_elementor_ui.List)(function(_ref) {
12328 var theme = _ref.theme;
12329 return { borderBottom: "1px solid ".concat(theme.palette.action.focus) };
12330 });
12331 var StyledPeriodTitle = (0, _elementor_ui.styled)(_elementor_ui.Typography)(function(_ref2) {
12332 var theme = _ref2.theme;
12333 return {
12334 padding: theme.spacing(1.5, 2),
12335 color: theme.palette.secondary.light
12336 };
12337 });
12338 var DATE_FORMAT = (0, _wordpress_i18n.__)("F j, g:i A", "elementor");
12339 var PromptHistoryPeriod = function PromptHistoryPeriod(_ref3) {
12340 var periodTitle = _ref3.periodTitle;
12341 var historyItems = _ref3.historyItems;
12342 var _onHistoryItemDelete = _ref3.onHistoryItemDelete;
12343 return /*#__PURE__*/ react.default.createElement(StyledPeriodList, {
12344 "data-testid": "e-ph-p",
12345 subheader: /*#__PURE__*/ react.default.createElement(_elementor_ui.ListSubheader, {
12346 disableSticky: true,
12347 disableGutters: true
12348 }, /*#__PURE__*/ react.default.createElement(StyledPeriodTitle, {
12349 variant: "body2",
12350 role: "heading",
12351 "aria-level": "6"
12352 }, periodTitle))
12353 }, historyItems.map(function(_ref4) {
12354 var id = _ref4.id;
12355 var date = _ref4.date;
12356 var props = _objectWithoutProperties(_ref4, _excluded$8);
12357 return /*#__PURE__*/ react.default.createElement(PromptHistoryItem, _extends$1({
12358 key: id,
12359 date: translateDate(DATE_FORMAT, date),
12360 onHistoryItemDelete: function onHistoryItemDelete() {
12361 return _onHistoryItemDelete(id);
12362 },
12363 id
12364 }, props));
12365 }));
12366 };
12367 PromptHistoryPeriod.propTypes = {
12368 periodTitle: import_prop_types$7.default.string.isRequired,
12369 historyItems: import_prop_types$7.default.array.isRequired,
12370 onHistoryItemDelete: import_prop_types$7.default.func.isRequired
12371 };
12372
12373 //#endregion
12374 //#region modules/ai/assets/js/editor/components/prompt-history/helpers/history-period-helpers.js
12375 init_defineProperty();
12376 function _createForOfIteratorHelper(r, e) {
12377 var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
12378 if (!t) {
12379 if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
12380 t && (r = t);
12381 var _n = 0;
12382 var F = function F() {};
12383 return {
12384 s: F,
12385 n: function n() {
12386 return _n >= r.length ? { done: !0 } : {
12387 done: !1,
12388 value: r[_n++]
12389 };
12390 },
12391 e: function e(r) {
12392 throw r;
12393 },
12394 f: F
12395 };
12396 }
12397 throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
12398 }
12399 var o;
12400 var a = !0;
12401 var u = !1;
12402 return {
12403 s: function s() {
12404 t = t.call(r);
12405 },
12406 n: function n() {
12407 var r = t.next();
12408 return a = r.done, r;
12409 },
12410 e: function e(r) {
12411 u = !0, o = r;
12412 },
12413 f: function f() {
12414 try {
12415 a || null == t.return || t.return();
12416 } finally {
12417 if (u) throw o;
12418 }
12419 }
12420 };
12421 }
12422 function _unsupportedIterableToArray(r, a) {
12423 if (r) {
12424 if ("string" == typeof r) return _arrayLikeToArray(r, a);
12425 var t = {}.toString.call(r).slice(8, -1);
12426 return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
12427 }
12428 }
12429 function _arrayLikeToArray(r, a) {
12430 (null == a || a > r.length) && (a = r.length);
12431 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
12432 return n;
12433 }
12434 var DATE_KEY = "date";
12435 var LAST_7_DAYS_KEY = "7-days";
12436 var LAST_30_DAYS_KEY = "30-days";
12437 var MONTH_FORMAT = (0, _wordpress_i18n.__)("F", "elementor");
12438 /**
12439 * Sorts items in ascending order by date.
12440 *
12441 * @param {Array} historyData
12442 * @return {Array}
12443 */
12444 var sortPromptHistoryData = function sortPromptHistoryData(historyData) {
12445 return _toConsumableArray(historyData).sort(function(a, b) {
12446 return new Date(b[DATE_KEY]) - new Date(a[DATE_KEY]);
12447 });
12448 };
12449 /**
12450 * Groups prompt history data by time periods.
12451 *
12452 * @param {Array} historyData
12453 * @return {Object.<string, {label: string, items: any[]}>}
12454 */
12455 var groupPromptHistoryData = function groupPromptHistoryData(historyData) {
12456 var data = sortPromptHistoryData(historyData);
12457 var currentDate = /* @__PURE__ */ new Date();
12458 var result = _defineProperty(_defineProperty({}, LAST_7_DAYS_KEY, {
12459 label: (0, _wordpress_i18n.__)("Last 7 days", "elementor"),
12460 items: []
12461 }), LAST_30_DAYS_KEY, {
12462 label: (0, _wordpress_i18n.__)("Last 30 days", "elementor"),
12463 items: []
12464 });
12465 var _iterator = _createForOfIteratorHelper(data);
12466 var _step;
12467 try {
12468 for (_iterator.s(); !(_step = _iterator.n()).done;) {
12469 var item = _step.value;
12470 var date = new Date(item[DATE_KEY]);
12471 var diff = daysDiff(date, currentDate);
12472 if (diff <= 7) {
12473 result[LAST_7_DAYS_KEY].items.push(item);
12474 continue;
12475 }
12476 if (diff <= 30) {
12477 result[LAST_30_DAYS_KEY].items.push(item);
12478 continue;
12479 }
12480 var month = date.getMonth();
12481 if (!result[month]) result[month] = {
12482 label: translateDate(MONTH_FORMAT, date),
12483 items: []
12484 };
12485 result[month].items.push(item);
12486 }
12487 } catch (err) {
12488 _iterator.e(err);
12489 } finally {
12490 _iterator.f();
12491 }
12492 return result;
12493 };
12494 var renderPeriods = function renderPeriods(_ref) {
12495 var _groupData$LAST_7_DAY;
12496 var _groupData$LAST_30_DA;
12497 var items = _ref.items;
12498 var onDelete = _ref.onDelete;
12499 var groupData = groupPromptHistoryData(items);
12500 var periods = [];
12501 if ((_groupData$LAST_7_DAY = groupData["7-days"]) !== null && _groupData$LAST_7_DAY !== void 0 && (_groupData$LAST_7_DAY = _groupData$LAST_7_DAY.items) !== null && _groupData$LAST_7_DAY !== void 0 && _groupData$LAST_7_DAY.length) periods.push(/*#__PURE__*/ react.default.createElement(PromptHistoryPeriod, {
12502 periodTitle: groupData[LAST_7_DAYS_KEY].label,
12503 onHistoryItemDelete: onDelete,
12504 historyItems: groupData[LAST_7_DAYS_KEY].items
12505 }));
12506 if ((_groupData$LAST_30_DA = groupData["30-days"]) !== null && _groupData$LAST_30_DA !== void 0 && (_groupData$LAST_30_DA = _groupData$LAST_30_DA.items) !== null && _groupData$LAST_30_DA !== void 0 && _groupData$LAST_30_DA.length) periods.push(/*#__PURE__*/ react.default.createElement(PromptHistoryPeriod, {
12507 periodTitle: groupData[LAST_30_DAYS_KEY].label,
12508 onHistoryItemDelete: onDelete,
12509 historyItems: groupData[LAST_30_DAYS_KEY].items
12510 }));
12511 for (var i = 12; i >= 0; i--) if (groupData[i]) periods.push(/*#__PURE__*/ react.default.createElement(PromptHistoryPeriod, {
12512 periodTitle: groupData[i].label,
12513 onHistoryItemDelete: onDelete,
12514 historyItems: groupData[i].items
12515 }));
12516 return periods;
12517 };
12518
12519 //#endregion
12520 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-empty.js
12521 init_history_types();
12522 var PromptHistoryEmpty = function PromptHistoryEmpty(_ref) {
12523 var historyType = _ref.historyType;
12524 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
12525 justifyContent: "center",
12526 sx: {
12527 height: "100%",
12528 textAlign: "center"
12529 },
12530 "data-testid": "e-ph-empty"
12531 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "h6" }, (0, _wordpress_i18n.__)("Prepare to be amazed", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "body1" }, (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("This is where you'll find all the %s you've generated using Elementor AI.", "elementor"), getTranslatedPromptHistoryType(historyType))));
12532 };
12533 PromptHistoryEmpty.propTypes = { historyType: import_prop_types$7.default.oneOf(Object.values(HISTORY_TYPES)).isRequired };
12534
12535 //#endregion
12536 //#region node_modules/react-infinite-scroller/src/InfiniteScroll.js
12537 init_objectWithoutProperties$1();
12538 init_defineProperty$1();
12539 var _excluded$7 = [
12540 "children",
12541 "element",
12542 "hasMore",
12543 "initialLoad",
12544 "isReverse",
12545 "loader",
12546 "loadMore",
12547 "pageStart",
12548 "ref",
12549 "threshold",
12550 "useCapture",
12551 "useWindow",
12552 "getScrollParent"
12553 ];
12554 var InfiniteScroll = class extends react.Component {
12555 constructor(props) {
12556 super(props);
12557 this.scrollListener = this.scrollListener.bind(this);
12558 this.eventListenerOptions = this.eventListenerOptions.bind(this);
12559 this.mousewheelListener = this.mousewheelListener.bind(this);
12560 }
12561 componentDidMount() {
12562 this.pageLoaded = this.props.pageStart;
12563 this.options = this.eventListenerOptions();
12564 this.attachScrollListener();
12565 }
12566 componentDidUpdate() {
12567 if (this.props.isReverse && this.loadMore) {
12568 const parentElement = this.getParentElement(this.scrollComponent);
12569 parentElement.scrollTop = parentElement.scrollHeight - this.beforeScrollHeight + this.beforeScrollTop;
12570 this.loadMore = false;
12571 }
12572 this.attachScrollListener();
12573 }
12574 componentWillUnmount() {
12575 this.detachScrollListener();
12576 this.detachMousewheelListener();
12577 }
12578 isPassiveSupported() {
12579 let passive = false;
12580 const testOptions = { get passive() {
12581 passive = true;
12582 } };
12583 try {
12584 document.addEventListener("test", null, testOptions);
12585 document.removeEventListener("test", null, testOptions);
12586 } catch (e) {}
12587 return passive;
12588 }
12589 eventListenerOptions() {
12590 let options = this.props.useCapture;
12591 if (this.isPassiveSupported()) options = {
12592 useCapture: this.props.useCapture,
12593 passive: true
12594 };
12595 else options = { passive: false };
12596 return options;
12597 }
12598 setDefaultLoader(loader) {
12599 this.defaultLoader = loader;
12600 }
12601 detachMousewheelListener() {
12602 let scrollEl = window;
12603 if (this.props.useWindow === false) scrollEl = this.scrollComponent.parentNode;
12604 scrollEl.removeEventListener("mousewheel", this.mousewheelListener, this.options ? this.options : this.props.useCapture);
12605 }
12606 detachScrollListener() {
12607 let scrollEl = window;
12608 if (this.props.useWindow === false) scrollEl = this.getParentElement(this.scrollComponent);
12609 scrollEl.removeEventListener("scroll", this.scrollListener, this.options ? this.options : this.props.useCapture);
12610 scrollEl.removeEventListener("resize", this.scrollListener, this.options ? this.options : this.props.useCapture);
12611 }
12612 getParentElement(el) {
12613 const scrollParent = this.props.getScrollParent && this.props.getScrollParent();
12614 if (scrollParent != null) return scrollParent;
12615 return el && el.parentNode;
12616 }
12617 filterProps(props) {
12618 return props;
12619 }
12620 attachScrollListener() {
12621 const parentElement = this.getParentElement(this.scrollComponent);
12622 if (!this.props.hasMore || !parentElement) return;
12623 let scrollEl = window;
12624 if (this.props.useWindow === false) scrollEl = parentElement;
12625 scrollEl.addEventListener("mousewheel", this.mousewheelListener, this.options ? this.options : this.props.useCapture);
12626 scrollEl.addEventListener("scroll", this.scrollListener, this.options ? this.options : this.props.useCapture);
12627 scrollEl.addEventListener("resize", this.scrollListener, this.options ? this.options : this.props.useCapture);
12628 if (this.props.initialLoad) this.scrollListener();
12629 }
12630 mousewheelListener(e) {
12631 if (e.deltaY === 1 && !this.isPassiveSupported()) e.preventDefault();
12632 }
12633 scrollListener() {
12634 const el = this.scrollComponent;
12635 const scrollEl = window;
12636 const parentNode = this.getParentElement(el);
12637 let offset;
12638 if (this.props.useWindow) {
12639 const doc = document.documentElement || document.body.parentNode || document.body;
12640 const scrollTop = scrollEl.pageYOffset !== void 0 ? scrollEl.pageYOffset : doc.scrollTop;
12641 if (this.props.isReverse) offset = scrollTop;
12642 else offset = this.calculateOffset(el, scrollTop);
12643 } else if (this.props.isReverse) offset = parentNode.scrollTop;
12644 else offset = el.scrollHeight - parentNode.scrollTop - parentNode.clientHeight;
12645 if (offset < Number(this.props.threshold) && el && el.offsetParent !== null) {
12646 this.detachScrollListener();
12647 this.beforeScrollHeight = parentNode.scrollHeight;
12648 this.beforeScrollTop = parentNode.scrollTop;
12649 if (typeof this.props.loadMore === "function") {
12650 this.props.loadMore(this.pageLoaded += 1);
12651 this.loadMore = true;
12652 }
12653 }
12654 }
12655 calculateOffset(el, scrollTop) {
12656 if (!el) return 0;
12657 return this.calculateTopPosition(el) + (el.offsetHeight - scrollTop - window.innerHeight);
12658 }
12659 calculateTopPosition(el) {
12660 if (!el) return 0;
12661 return el.offsetTop + this.calculateTopPosition(el.offsetParent);
12662 }
12663 render() {
12664 const renderProps = this.filterProps(this.props);
12665 const { children, element, hasMore, initialLoad, isReverse, loader, loadMore, pageStart, ref, threshold, useCapture, useWindow, getScrollParent } = renderProps, props = _objectWithoutProperties$1(renderProps, _excluded$7);
12666 props.ref = (node) => {
12667 this.scrollComponent = node;
12668 if (ref) ref(node);
12669 };
12670 const childrenArray = [children];
12671 if (hasMore) {
12672 if (loader) isReverse ? childrenArray.unshift(loader) : childrenArray.push(loader);
12673 else if (this.defaultLoader) isReverse ? childrenArray.unshift(this.defaultLoader) : childrenArray.push(this.defaultLoader);
12674 }
12675 return react.default.createElement(element, props, childrenArray);
12676 }
12677 };
12678 _defineProperty$1(InfiniteScroll, "propTypes", {
12679 children: import_prop_types$7.default.node.isRequired,
12680 element: import_prop_types$7.default.node,
12681 hasMore: import_prop_types$7.default.bool,
12682 initialLoad: import_prop_types$7.default.bool,
12683 isReverse: import_prop_types$7.default.bool,
12684 loader: import_prop_types$7.default.node,
12685 loadMore: import_prop_types$7.default.func.isRequired,
12686 pageStart: import_prop_types$7.default.number,
12687 ref: import_prop_types$7.default.func,
12688 getScrollParent: import_prop_types$7.default.func,
12689 threshold: import_prop_types$7.default.number,
12690 useCapture: import_prop_types$7.default.bool,
12691 useWindow: import_prop_types$7.default.bool
12692 });
12693 _defineProperty$1(InfiniteScroll, "defaultProps", {
12694 element: "div",
12695 hasMore: false,
12696 initialLoad: true,
12697 pageStart: 0,
12698 ref: null,
12699 threshold: 250,
12700 useWindow: true,
12701 isReverse: false,
12702 useCapture: false,
12703 loader: null,
12704 getScrollParent: null
12705 });
12706
12707 //#endregion
12708 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-upgrade.js
12709 init_defineProperty();
12710 init_history_types();
12711 var VARIANT_FULL = "full";
12712 var VARIANT_SMALL = "small";
12713 var messages = _defineProperty(_defineProperty({}, VARIANT_FULL, (0, _wordpress_i18n.__)("Want to see your %s generation history for as far as the past 90 days?", "elementor")), VARIANT_SMALL, (0, _wordpress_i18n.__)("Want to see your %s generation history for the past 90 days?", "elementor"));
12714 var actionUrl = "https://go.elementor.com/ai-popup-purchase-dropdown/";
12715 var getMessage = function getMessage(variant, historyType) {
12716 return (0, _wordpress_i18n.sprintf)(messages[variant] || messages[VARIANT_FULL], getTranslatedPromptHistoryType(historyType));
12717 };
12718 var PromptHistoryUpgrade = function PromptHistoryUpgrade(_ref) {
12719 var variant = _ref.variant;
12720 var historyType = _ref.historyType;
12721 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
12722 justifyContent: "center",
12723 sx: {
12724 height: VARIANT_SMALL === variant ? "auto" : "100%",
12725 textAlign: "center",
12726 p: 2
12727 },
12728 "data-testid": "e-ph-upgrade-".concat(variant)
12729 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
12730 variant: "body1",
12731 sx: { marginBottom: 2 }
12732 }, getMessage(variant, historyType)), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
12733 variant: "contained",
12734 color: "promotion",
12735 size: "small",
12736 href: actionUrl,
12737 target: "_blank",
12738 rel: "noopener noreferrer",
12739 startIcon: /*#__PURE__*/ react.default.createElement(_elementor_icons.UpgradeIcon, null),
12740 sx: {
12741 width: "50%",
12742 alignSelf: "center",
12743 "&:hover": { color: "promotion.contrastText" }
12744 }
12745 }, (0, _wordpress_i18n.__)("Upgrade now", "elementor")));
12746 };
12747 PromptHistoryUpgrade.propTypes = {
12748 variant: import_prop_types$7.default.oneOf([VARIANT_FULL, VARIANT_SMALL]).isRequired,
12749 historyType: import_prop_types$7.default.oneOf(Object.values(HISTORY_TYPES)).isRequired
12750 };
12751
12752 //#endregion
12753 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-container.js
12754 init_extends();
12755 init_objectWithoutProperties();
12756 init_prompt_history_context();
12757 var _excluded$6 = ["children"];
12758 var _templateObject$2;
12759 var StyledContent$1 = (0, _elementor_ui.styled)(_elementor_ui.Box)(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral([
12760 "\n width: 360px;\n position: relative;\n margin-top: ",
12761 ";\n margin-right: ",
12762 ";\n background-color: ",
12763 ";\n border-radius: ",
12764 ";\n height: ",
12765 ";\n\n @media screen and (max-width: 456px) {\n width: 320px;\n }\n\n @media screen and (max-width: 420px) {\n width: 230px;\n }\n"
12766 ])), function(_ref) {
12767 return _ref.theme.spacing(2);
12768 }, function(_ref2) {
12769 return _ref2.theme.spacing(2);
12770 }, function(_ref3) {
12771 return _ref3.theme.palette.background.paper;
12772 }, function(_ref4) {
12773 var theme = _ref4.theme;
12774 return "".concat(theme.shape.borderRadius, "px");
12775 }, function(_ref5) {
12776 var height = _ref5.height;
12777 return "calc( ".concat(height, "px - 32px )");
12778 });
12779 var ModalContainer = function ModalContainer(_ref6) {
12780 var children = _ref6.children;
12781 var props = _objectWithoutProperties(_ref6, _excluded$6);
12782 var _usePromptHistoryCont = usePromptHistoryContext();
12783 var isOpen = _usePromptHistoryCont.isOpen;
12784 var isModalOpen = _usePromptHistoryCont.isModalOpen;
12785 var onClose = _usePromptHistoryCont.onClose;
12786 var getContainerHeight = _usePromptHistoryCont.getContainerHeight;
12787 var getContainer = _usePromptHistoryCont.getContainer;
12788 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Modal, _extends$1({
12789 container: getContainer(),
12790 open: isModalOpen,
12791 hideBackdrop: true,
12792 onClose,
12793 sx: { position: "absolute" }
12794 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.Backdrop, {
12795 open: true,
12796 sx: {
12797 position: "absolute",
12798 justifyContent: "flex-end",
12799 alignItems: "flex-start"
12800 },
12801 "aria-hidden": false
12802 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Slide, {
12803 direction: "left",
12804 in: isOpen,
12805 timeout: 500,
12806 easing: "ease-in-out"
12807 }, /*#__PURE__*/ react.default.createElement(StyledContent$1, {
12808 "aria-label": (0, _wordpress_i18n.__)("Prompt history modal", "elementor"),
12809 height: getContainerHeight()
12810 }, children))));
12811 };
12812 ModalContainer.propTypes = {
12813 isOpen: import_prop_types$7.default.bool.isRequired,
12814 isModalOpen: import_prop_types$7.default.bool.isRequired,
12815 onClose: import_prop_types$7.default.func.isRequired,
12816 children: import_prop_types$7.default.oneOfType([import_prop_types$7.default.arrayOf(import_prop_types$7.default.node), import_prop_types$7.default.node])
12817 };
12818
12819 //#endregion
12820 //#region modules/ai/assets/js/editor/components/prompt-history/history-modal.js
12821 init_asyncToGenerator();
12822 init_prompt_error_message();
12823 init_prompt_history_context();
12824 var ITEMS_LIMIT = 10;
12825 var FREE_PLAN_ERRORS = ["invalid_connect_data", "no_subscription"];
12826 var PromptHistoryModal = function PromptHistoryModal(props) {
12827 var lastRun = (0, react.useRef)(function() {});
12828 var scrollContainer = (0, react.useRef)(null);
12829 var _usePromptHistoryCont = usePromptHistoryContext();
12830 var historyType = _usePromptHistoryCont.historyType;
12831 var onClose = _usePromptHistoryCont.onClose;
12832 var _usePromptHistory = usePromptHistory(historyType);
12833 var items = _usePromptHistory.items;
12834 var meta = _usePromptHistory.meta;
12835 var isHistoryFetchingInProgress = _usePromptHistory.isLoading;
12836 var historyFetchingError = _usePromptHistory.error;
12837 var fetchData = _usePromptHistory.fetchData;
12838 var deleteItemFromState = _usePromptHistory.deleteItemById;
12839 var _useDeletePromptHisto = useDeletePromptHistoryItem();
12840 var isDeletingInProgress = _useDeletePromptHisto.isLoading;
12841 var historyDeletingError = _useDeletePromptHisto.error;
12842 var deleteItem = _useDeletePromptHisto.deleteItem;
12843 var error = historyFetchingError || historyDeletingError;
12844 var isLoading = isHistoryFetchingInProgress || isDeletingInProgress;
12845 var isLastPage = meta && (meta === null || meta === void 0 ? void 0 : meta.currentPage) === (meta === null || meta === void 0 ? void 0 : meta.totalPages);
12846 var showUpgrade = (items === null || items === void 0 ? void 0 : items.length) > 0 && (meta === null || meta === void 0 ? void 0 : meta.allowedDays) < 90 && isLastPage;
12847 (0, react.useEffect)(function() {
12848 lastRun.current = /*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee() {
12849 return import_regenerator$2.default.wrap(function(_context) {
12850 while (1) switch (_context.prev = _context.next) {
12851 case 0: return _context.abrupt("return", fetchData({
12852 page: 1,
12853 limit: ITEMS_LIMIT
12854 }));
12855 case 1:
12856 case "end": return _context.stop();
12857 }
12858 }, _callee);
12859 }));
12860 lastRun.current();
12861 }, []);
12862 var loadNext = function loadNext() {
12863 if (isLoading || isLastPage) return;
12864 lastRun.current = /*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee2() {
12865 return import_regenerator$2.default.wrap(function(_context2) {
12866 while (1) switch (_context2.prev = _context2.next) {
12867 case 0: return _context2.abrupt("return", fetchData({
12868 page: meta.currentPage + 1,
12869 limit: ITEMS_LIMIT
12870 }));
12871 case 1:
12872 case "end": return _context2.stop();
12873 }
12874 }, _callee2);
12875 }));
12876 lastRun.current();
12877 };
12878 var onHistoryItemDelete = /*#__PURE__*/ function() {
12879 var _ref3 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee4(id) {
12880 return import_regenerator$2.default.wrap(function(_context4) {
12881 while (1) switch (_context4.prev = _context4.next) {
12882 case 0:
12883 lastRun.current = /*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee3() {
12884 return import_regenerator$2.default.wrap(function(_context3) {
12885 while (1) switch (_context3.prev = _context3.next) {
12886 case 0:
12887 _context3.next = 1;
12888 return deleteItem(id);
12889 case 1: return _context3.abrupt("return", _context3.sent);
12890 case 2:
12891 case "end": return _context3.stop();
12892 }
12893 }, _callee3);
12894 }));
12895 _context4.next = 1;
12896 return lastRun.current();
12897 case 1: if (!historyDeletingError) deleteItemFromState(id);
12898 case 2:
12899 case "end": return _context4.stop();
12900 }
12901 }, _callee4);
12902 }));
12903 return function onHistoryItemDelete(_x) {
12904 return _ref3.apply(this, arguments);
12905 };
12906 }();
12907 return /*#__PURE__*/ react.default.createElement(ModalContainer, props, /*#__PURE__*/ react.default.createElement(PromptHistoryModalHeader, { onClose }), error && !FREE_PLAN_ERRORS.includes(error) && /*#__PURE__*/ react.default.createElement(PromptErrorMessage, {
12908 error,
12909 onRetry: lastRun.current,
12910 sx: {
12911 position: "absolute",
12912 zIndex: 1,
12913 marginTop: isLoading ? .5 : "revert"
12914 }
12915 }), isLoading && /*#__PURE__*/ react.default.createElement(_elementor_ui.LinearProgress, {
12916 role: "progressbar",
12917 "aria-label": (0, _wordpress_i18n.__)("Loading", "elementor"),
12918 color: "secondary"
12919 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
12920 sx: {
12921 overflowY: "scroll",
12922 height: "85%"
12923 },
12924 ref: scrollContainer
12925 }, error && FREE_PLAN_ERRORS.includes(error) && /*#__PURE__*/ react.default.createElement(PromptHistoryUpgrade, {
12926 variant: "full",
12927 historyType
12928 }), !error && 0 === (items === null || items === void 0 ? void 0 : items.length) && /*#__PURE__*/ react.default.createElement(PromptHistoryEmpty, { historyType }), (items === null || items === void 0 ? void 0 : items.length) > 0 && /*#__PURE__*/ react.default.createElement(InfiniteScroll, {
12929 loadMore: loadNext,
12930 getScrollParent: function getScrollParent() {
12931 return scrollContainer.current;
12932 },
12933 useWindow: false,
12934 isReverse: false,
12935 threshold: 30,
12936 initialLoad: false,
12937 hasMore: !isLastPage
12938 }, renderPeriods({
12939 items,
12940 onDelete: onHistoryItemDelete
12941 })), showUpgrade && /*#__PURE__*/ react.default.createElement(PromptHistoryUpgrade, {
12942 variant: "small",
12943 historyType
12944 })));
12945 };
12946
12947 //#endregion
12948 //#region modules/ai/assets/js/editor/components/prompt-history/index.js
12949 init_prompt_history_context();
12950 var PROMPT_HISTORY_MODAL_ID = "prompt-history-modal";
12951 var PromptHistory = function PromptHistory() {
12952 var _usePromptHistoryCont = usePromptHistoryContext();
12953 var isOpen = _usePromptHistoryCont.isOpen;
12954 var isModalOpen = _usePromptHistoryCont.isModalOpen;
12955 var onOpen = _usePromptHistoryCont.onOpen;
12956 var onClose = _usePromptHistoryCont.onClose;
12957 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(PromptHistoryButton, {
12958 isActive: isOpen,
12959 onClick: function onClick() {
12960 return isOpen ? onClose() : onOpen();
12961 },
12962 "aria-haspopup": "dialog",
12963 "aria-controls": PROMPT_HISTORY_MODAL_ID
12964 }), isModalOpen && /*#__PURE__*/ react.default.createElement(PromptHistoryModal, { id: PROMPT_HISTORY_MODAL_ID }));
12965 };
12966
12967 //#endregion
12968 //#region modules/ai/assets/js/editor/pages/form-media/index.js
12969 init_extends();
12970 init_slicedToArray();
12971 init_defineProperty();
12972 function ownKeys$9(e, r) {
12973 var t = Object.keys(e);
12974 if (Object.getOwnPropertySymbols) {
12975 var o = Object.getOwnPropertySymbols(e);
12976 r && (o = o.filter(function(r) {
12977 return Object.getOwnPropertyDescriptor(e, r).enumerable;
12978 })), t.push.apply(t, o);
12979 }
12980 return t;
12981 }
12982 __name(ownKeys$9, "ownKeys");
12983 function _objectSpread$9(e) {
12984 for (var r = 1; r < arguments.length; r++) {
12985 var t = null != arguments[r] ? arguments[r] : {};
12986 r % 2 ? ownKeys$9(Object(t), !0).forEach(function(r) {
12987 _defineProperty(e, r, t[r]);
12988 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function(r) {
12989 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
12990 });
12991 }
12992 return e;
12993 }
12994 __name(_objectSpread$9, "_objectSpread");
12995 var initialData = {
12996 isAllSaved: false,
12997 hasUnsavedChanges: false
12998 };
12999 var SET_UNSAVED_CHANGES = "SET_UNSAVED_CHANGES";
13000 var SAVE_AND_CLOSE = "SAVE_AND_CLOSE";
13001 var reducer = function reducer(state, _ref) {
13002 var type = _ref.type;
13003 var payload = _ref.payload;
13004 switch (type) {
13005 case SET_UNSAVED_CHANGES: return _objectSpread$9(_objectSpread$9({}, state), {}, {
13006 hasUnsavedChanges: payload,
13007 isAllSaved: payload ? false : state.isAllSaved
13008 });
13009 case SAVE_AND_CLOSE: return _objectSpread$9(_objectSpread$9({}, state), {}, {
13010 isAllSaved: true,
13011 hasUnsavedChanges: false
13012 });
13013 default: throw Error("Unknown action.");
13014 }
13015 };
13016 var FormMedia = function FormMedia(_ref2) {
13017 var onClose = _ref2.onClose;
13018 var DialogProps = _ref2.DialogProps;
13019 var getControlValue = _ref2.getControlValue;
13020 var setControlValue = _ref2.setControlValue;
13021 var additionalOptions = _ref2.additionalOptions;
13022 var maybeRenderUpgradeChip = _ref2.maybeRenderUpgradeChip;
13023 var hasSubscription = _ref2.hasSubscription;
13024 var usagePercentage = _ref2.usagePercentage;
13025 var _useReducer2 = _slicedToArray((0, react.useReducer)(reducer, initialData), 2);
13026 var state = _useReducer2[0];
13027 var dispatch = _useReducer2[1];
13028 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
13029 var showUnsavedChangeAlert = _useState2[0];
13030 var setShowUnsavedChangeAlert = _useState2[1];
13031 var setHasUnsavedChanges = function setHasUnsavedChanges(payload) {
13032 return dispatch({
13033 type: SET_UNSAVED_CHANGES,
13034 payload
13035 });
13036 };
13037 var saveAndClose = function saveAndClose() {
13038 return dispatch({ type: SAVE_AND_CLOSE });
13039 };
13040 var onCloseIntent = function onCloseIntent() {
13041 if (state.hasUnsavedChanges) {
13042 setShowUnsavedChangeAlert(true);
13043 return;
13044 }
13045 onClose();
13046 };
13047 var editImageInitialData = getControlValue() === (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.defaultValue) ? {} : getControlValue();
13048 var globalSettings = {
13049 initialImageType: (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.defaultImageType) || "",
13050 hasSubscription,
13051 usagePercentage,
13052 hideBackButton: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.hideBackButton
13053 };
13054 var globalActions = {
13055 state,
13056 getControlValue,
13057 setControlValue,
13058 saveAndClose,
13059 close: onCloseIntent,
13060 setHasUnsavedChanges
13061 };
13062 (0, react.useEffect)(function() {
13063 if (state.isAllSaved) onClose();
13064 }, [state.isAllSaved]);
13065 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(PromptDialog, _extends$1({
13066 id: "e-form-media",
13067 onClose: function onClose() {
13068 return onCloseIntent();
13069 },
13070 maxWidth: "lg"
13071 }, DialogProps), /*#__PURE__*/ react.default.createElement(PromptDialog.Header, {
13072 onClose: function onClose() {
13073 return onCloseIntent();
13074 },
13075 hideAiBetaLogo: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.hideAiBetaLogo
13076 }, !additionalOptions.withoutHistory && /*#__PURE__*/ react.default.createElement(PromptHistory, null), maybeRenderUpgradeChip()), /*#__PURE__*/ react.default.createElement(_elementor_ui.Divider, null), /*#__PURE__*/ react.default.createElement(GlobalSettingsProvider, { settings: globalSettings }, /*#__PURE__*/ react.default.createElement(GlobalActionsProvider, { actions: globalActions }, /*#__PURE__*/ react.default.createElement(LocationProvider, null, /*#__PURE__*/ react.default.createElement(EditImageProvider, { imageData: editImageInitialData }, /*#__PURE__*/ react.default.createElement(MediaOutlet, {
13077 additionalOptions,
13078 onClose
13079 })))))), showUnsavedChangeAlert && /*#__PURE__*/ react.default.createElement(UnsavedChangesAlert$1, {
13080 onClose,
13081 onCancel: function onCancel() {
13082 return setShowUnsavedChangeAlert(false);
13083 },
13084 open: true
13085 }));
13086 };
13087 FormMedia.propTypes = {
13088 onClose: import_prop_types$7.default.func.isRequired,
13089 DialogProps: import_prop_types$7.default.object,
13090 getControlValue: import_prop_types$7.default.func.isRequired,
13091 setControlValue: import_prop_types$7.default.func.isRequired,
13092 additionalOptions: import_prop_types$7.default.object,
13093 credits: import_prop_types$7.default.number,
13094 maybeRenderUpgradeChip: import_prop_types$7.default.func,
13095 hasSubscription: import_prop_types$7.default.bool,
13096 usagePercentage: import_prop_types$7.default.number
13097 };
13098
13099 //#endregion
13100 //#region modules/ai/assets/js/editor/hooks/use-animation-prompt.js
13101 init_typeof();
13102 init_slicedToArray();
13103 init_defineProperty();
13104 init_asyncToGenerator();
13105 init_api();
13106 init_use_prompt();
13107 function ownKeys$8(e, r) {
13108 var t = Object.keys(e);
13109 if (Object.getOwnPropertySymbols) {
13110 var o = Object.getOwnPropertySymbols(e);
13111 r && (o = o.filter(function(r) {
13112 return Object.getOwnPropertyDescriptor(e, r).enumerable;
13113 })), t.push.apply(t, o);
13114 }
13115 return t;
13116 }
13117 __name(ownKeys$8, "ownKeys");
13118 function _objectSpread$8(e) {
13119 for (var r = 1; r < arguments.length; r++) {
13120 var t = null != arguments[r] ? arguments[r] : {};
13121 r % 2 ? ownKeys$8(Object(t), !0).forEach(function(r) {
13122 _defineProperty(e, r, t[r]);
13123 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function(r) {
13124 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
13125 });
13126 }
13127 return e;
13128 }
13129 __name(_objectSpread$8, "_objectSpread");
13130 var getAnimationResult = /*#__PURE__*/ function() {
13131 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(payload, motionEffectType) {
13132 return import_regenerator$2.default.wrap(function(_context) {
13133 while (1) switch (_context.prev = _context.next) {
13134 case 0: return _context.abrupt("return", getAnimation(_objectSpread$8(_objectSpread$8({}, payload), {}, { motionEffectType })));
13135 case 1:
13136 case "end": return _context.stop();
13137 }
13138 }, _callee);
13139 }));
13140 return function getAnimationResult(_x, _x2) {
13141 return _ref.apply(this, arguments);
13142 };
13143 }();
13144 var useAnimationPrompt = function useAnimationPrompt(motionEffectType, widgetType, initialValue) {
13145 var _usePrompt = usePrompt(function(payload) {
13146 return getAnimationResult(payload, motionEffectType);
13147 }, initialValue);
13148 var data = _usePrompt.data;
13149 var isLoading = _usePrompt.isLoading;
13150 var error = _usePrompt.error;
13151 var reset = _usePrompt.reset;
13152 var send = _usePrompt.send;
13153 var sendUsageData = _usePrompt.sendUsageData;
13154 var getControlData = function getControlData(controlKey) {
13155 var _elementor$widgetsCac;
13156 var _elementor$widgetsCac2;
13157 return {
13158 label: (_elementor$widgetsCac = elementor.widgetsCache) === null || _elementor$widgetsCac === void 0 || (_elementor$widgetsCac = _elementor$widgetsCac[widgetType !== null && widgetType !== void 0 ? widgetType : ""]) === null || _elementor$widgetsCac === void 0 || (_elementor$widgetsCac = _elementor$widgetsCac.controls[controlKey]) === null || _elementor$widgetsCac === void 0 ? void 0 : _elementor$widgetsCac.label,
13159 innerTab: (_elementor$widgetsCac2 = elementor.widgetsCache) === null || _elementor$widgetsCac2 === void 0 || (_elementor$widgetsCac2 = _elementor$widgetsCac2[widgetType !== null && widgetType !== void 0 ? widgetType : ""]) === null || _elementor$widgetsCac2 === void 0 || (_elementor$widgetsCac2 = _elementor$widgetsCac2.controls[controlKey]) === null || _elementor$widgetsCac2 === void 0 ? void 0 : _elementor$widgetsCac2.inner_tab
13160 };
13161 };
13162 var processMotionEffects = function processMotionEffects(jsonObject) {
13163 var result = {};
13164 var firstChild = jsonObject[Object.keys(jsonObject)[0]];
13165 var firstEnableControlKey = Object.keys(firstChild)[0];
13166 result[firstEnableControlKey] = {
13167 isParent: true,
13168 label: getControlData(firstEnableControlKey).label,
13169 value: jsonObject.enabled[firstEnableControlKey],
13170 tabs: 0
13171 };
13172 var processOtherProps = function processOtherProps(props) {
13173 for (var _i = 0, _Object$entries = Object.entries(props); _i < _Object$entries.length; _i++) {
13174 var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2);
13175 var key = _Object$entries$_i[0];
13176 var value = _Object$entries$_i[1];
13177 if ("enabled" === key && value) {
13178 var enableControlKey = Object.keys(value)[0];
13179 result[enableControlKey] = {
13180 isParent: false,
13181 label: getControlData(enableControlKey).label,
13182 value: value[enableControlKey],
13183 tabs: 1
13184 };
13185 } else {
13186 if ("none" === value || "normal" === value) continue;
13187 result[key] = { value };
13188 }
13189 }
13190 };
13191 for (var _i2 = 0, _Object$entries2 = Object.entries(jsonObject); _i2 < _Object$entries2.length; _i2++) {
13192 var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2);
13193 var propKey = _Object$entries2$_i[0];
13194 var propValue = _Object$entries2$_i[1];
13195 if (propKey !== "enabled" && "object" === _typeof(propValue)) processOtherProps(propValue);
13196 }
13197 return result;
13198 };
13199 var processEntranceEffects = function processEntranceEffects(jsonObject) {
13200 var result = {};
13201 var firstChildKey = Object.keys(jsonObject)[0];
13202 var firstChild = jsonObject[firstChildKey];
13203 result[firstChildKey] = {
13204 isParent: true,
13205 label: getControlData(firstChildKey).label,
13206 value: firstChild,
13207 tabs: 0
13208 };
13209 result[firstChild] = {
13210 isParent: false,
13211 label: firstChild,
13212 tabs: 1
13213 };
13214 var processProps = function processProps(props) {
13215 for (var _i3 = 0, _Object$entries3 = Object.entries(props); _i3 < _Object$entries3.length; _i3++) {
13216 var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2);
13217 var key = _Object$entries3$_i[0];
13218 var value = _Object$entries3$_i[1];
13219 if ("none" === value || "normal" === value) continue;
13220 result[key] = { value };
13221 }
13222 };
13223 for (var _i4 = 0, _Object$entries4 = Object.entries(jsonObject); _i4 < _Object$entries4.length; _i4++) {
13224 var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2);
13225 var propKey = _Object$entries4$_i[0];
13226 var propValue = _Object$entries4$_i[1];
13227 if (propKey !== firstChildKey && "object" === _typeof(propValue)) processProps(propValue);
13228 }
13229 return result;
13230 };
13231 var processHoverEffects = function processHoverEffects(jsonObject) {
13232 var result = {};
13233 var isHoverLabelAdded = false;
13234 var processProps = function processProps(props) {
13235 for (var _i5 = 0, _Object$entries5 = Object.entries(props); _i5 < _Object$entries5.length; _i5++) {
13236 var _Object$entries5$_i = _slicedToArray(_Object$entries5[_i5], 2);
13237 var key = _Object$entries5$_i[0];
13238 var value = _Object$entries5$_i[1];
13239 if ("enabled" === key && value) {
13240 var enableControlKey = Object.keys(value)[0];
13241 var _getControlData = getControlData(enableControlKey);
13242 var label = _getControlData.label;
13243 var innerTab = _getControlData.innerTab;
13244 if (!isHoverLabelAdded) {
13245 result[innerTab] = {
13246 isParent: true,
13247 label: getControlData(innerTab).label,
13248 tabs: 0
13249 };
13250 isHoverLabelAdded = true;
13251 }
13252 result[enableControlKey] = {
13253 isParent: false,
13254 label,
13255 value: value[enableControlKey],
13256 tabs: 1
13257 };
13258 } else {
13259 if ("none" === value || "normal" === value) continue;
13260 result[key] = { value };
13261 }
13262 }
13263 };
13264 for (var _i6 = 0, _Object$entries6 = Object.entries(jsonObject); _i6 < _Object$entries6.length; _i6++) {
13265 var propValue = _slicedToArray(_Object$entries6[_i6], 2)[1];
13266 if ("object" === _typeof(propValue)) processProps(propValue);
13267 }
13268 return result;
13269 };
13270 var digestResult = function digestResult(jsonString) {
13271 var result = {};
13272 function traverse(currentObj) {
13273 if (!currentObj || _typeof(currentObj) !== "object") return;
13274 for (var key in currentObj) {
13275 if (!currentObj.hasOwnProperty(key)) continue;
13276 if (["scrolling_effects", "mouse_effects"].includes(key)) {
13277 result = _objectSpread$8(_objectSpread$8({}, result), processMotionEffects(currentObj[key]));
13278 continue;
13279 }
13280 if ("entrance_effects" === key) {
13281 result = _objectSpread$8(_objectSpread$8({}, result), processEntranceEffects(currentObj[key]));
13282 continue;
13283 }
13284 if ("hover_effects" === key) {
13285 result = _objectSpread$8(_objectSpread$8({}, result), processHoverEffects(currentObj[key]));
13286 return;
13287 }
13288 traverse(currentObj[key]);
13289 }
13290 }
13291 traverse(JSON.parse(jsonString));
13292 return result;
13293 };
13294 (0, react.useEffect)(function() {
13295 if (data.result) data.result = digestResult(data.result);
13296 }, [data]);
13297 return {
13298 data,
13299 isLoading,
13300 error,
13301 reset,
13302 send,
13303 sendUsageData
13304 };
13305 };
13306
13307 //#endregion
13308 //#region modules/ai/assets/js/editor/pages/form-animation/index.js
13309 init_asyncToGenerator();
13310 init_slicedToArray();
13311 init_actions_data();
13312 init_loader();
13313 init_prompt_search();
13314 init_prompt_suggestions();
13315 init_generate_button();
13316 init_prompt_error_message();
13317 init_requests_ids();
13318 init_voice_promotion_alert();
13319 var CodeDisplayWrapper$1 = (0, _elementor_ui.styled)(_elementor_ui.Box)(function() {
13320 return {
13321 "& p": {
13322 mb: "10px",
13323 fontSize: "14px",
13324 lineHeight: "1.5"
13325 },
13326 "& pre": { position: "relative" },
13327 "& textarea": {
13328 fontSize: "13px",
13329 lineHeight: "1.7"
13330 }
13331 };
13332 });
13333 var FormAnimation = function FormAnimation(_ref) {
13334 var onClose = _ref.onClose;
13335 var getControlValue = _ref.getControlValue;
13336 var setControlValue = _ref.setControlValue;
13337 var additionalOptions = _ref.additionalOptions;
13338 var credits = _ref.credits;
13339 var children = _ref.children;
13340 var _useAnimationPrompt = useAnimationPrompt(additionalOptions.animationType, additionalOptions.widgetType, credits);
13341 var data = _useAnimationPrompt.data;
13342 var isLoading = _useAnimationPrompt.isLoading;
13343 var error = _useAnimationPrompt.error;
13344 var reset = _useAnimationPrompt.reset;
13345 var send = _useAnimationPrompt.send;
13346 var sendUsageData = _useAnimationPrompt.sendUsageData;
13347 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
13348 var prompt = _useState2[0];
13349 var setPrompt = _useState2[1];
13350 var setGenerate = useRequestIds().setGenerate;
13351 var _useState4 = _slicedToArray((0, react.useState)(""), 2);
13352 var animationSummary = _useState4[0];
13353 var setAnimationSummary = _useState4[1];
13354 var _useState6 = _slicedToArray((0, react.useState)(), 2);
13355 var prevControlValue = _useState6[0];
13356 var setPrevControlValue = _useState6[1];
13357 var lastRun = (0, react.useRef)(function() {});
13358 var autocompleteItems = "hover" === additionalOptions.animationType ? hoverEffectAutocomplete : motionEffectAutocomplete;
13359 var showSuggestions = !prompt;
13360 var handleSubmit = /*#__PURE__*/ function() {
13361 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(event) {
13362 return import_regenerator$2.default.wrap(function(_context) {
13363 while (1) switch (_context.prev = _context.next) {
13364 case 0:
13365 event.preventDefault();
13366 setGenerate();
13367 lastRun.current = function() {
13368 return send({ prompt });
13369 };
13370 _context.next = 1;
13371 return lastRun.current();
13372 case 1:
13373 case "end": return _context.stop();
13374 }
13375 }, _callee);
13376 }));
13377 return function handleSubmit(_x) {
13378 return _ref2.apply(this, arguments);
13379 };
13380 }();
13381 (0, react.useEffect)(function() {
13382 if (data.result) showPreview(data.result);
13383 }, [data]);
13384 (0, react.useEffect)(function() {
13385 return function() {
13386 restorePrevSettings();
13387 };
13388 }, []);
13389 var showPreview = function showPreview(result) {
13390 var summary = Object.keys(result).filter(function(key) {
13391 return result[key].label;
13392 }).map(function(key) {
13393 var item = result[key];
13394 var tabs = "&nbsp;".repeat(item.tabs);
13395 var bulletIcon = item.tabs > 0 ? "&#8226; " : "";
13396 var label = item.isParent ? "<br/><b>".concat(item.label, ":</b>") : "".concat(bulletIcon, " ").concat(item.label);
13397 return "".concat(tabs).concat(label);
13398 }).join("<br/>");
13399 var title = "".concat((0, _wordpress_i18n.__)("Here’s a breakdown of what was done for creating the animation", "elementor"));
13400 setAnimationSummary("<b>".concat(title, ":</b><br/>").concat(summary));
13401 setPrevControlValue(getControlValue());
13402 elementor.documents.getCurrent().history.setActive(false);
13403 setControlValue(getValidElementor(result));
13404 };
13405 var restorePrevSettings = function restorePrevSettings() {
13406 setControlValue(prevControlValue);
13407 elementor.documents.getCurrent().history.setActive(true);
13408 };
13409 var getValidElementor = function getValidElementor(result) {
13410 return Object.entries(result).filter(function(_ref3) {
13411 return _slicedToArray(_ref3, 2)[1].hasOwnProperty("value");
13412 }).reduce(function(previousValue, _ref5) {
13413 var _ref6 = _slicedToArray(_ref5, 2);
13414 var key = _ref6[0];
13415 previousValue[key] = _ref6[1].value;
13416 return previousValue;
13417 }, {});
13418 };
13419 var applyPrompt = function applyPrompt(result) {
13420 sendUsageData();
13421 restorePrevSettings();
13422 setControlValue(getValidElementor(result));
13423 onClose();
13424 };
13425 if (isLoading) return /*#__PURE__*/ react.default.createElement(Loader, null);
13426 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, error && /*#__PURE__*/ react.default.createElement(PromptErrorMessage, {
13427 error,
13428 onRetry: lastRun.current,
13429 sx: { mb: 2.5 }
13430 }), children, !data.result && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
13431 component: "form",
13432 onSubmit: handleSubmit
13433 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: { pb: 1.5 } }, /*#__PURE__*/ react.default.createElement(PromptSearch, {
13434 placeholder: (0, _wordpress_i18n.__)("Describe the animation you want to create...", "elementor"),
13435 name: "prompt",
13436 value: prompt,
13437 color: "secondary",
13438 onChange: function onChange(event) {
13439 return setPrompt(event.target.value);
13440 }
13441 })), showSuggestions && /*#__PURE__*/ react.default.createElement(PromptSuggestions, {
13442 suggestions: autocompleteItems,
13443 onSelect: setPrompt
13444 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
13445 direction: "row",
13446 alignItems: "center",
13447 sx: {
13448 py: 1.5,
13449 mt: 4
13450 }
13451 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
13452 direction: "row",
13453 justifyContent: "flex-end",
13454 flexGrow: 1
13455 }, /*#__PURE__*/ react.default.createElement(GenerateButton$1, null, (0, _wordpress_i18n.__)("Generate Animation", "elementor"))))), data.result && animationSummary && /*#__PURE__*/ react.default.createElement(CodeDisplayWrapper$1, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
13456 backgroundColor: "rgba(0, 0, 0, 0.06); ",
13457 padding: "1em",
13458 borderRadius: "4px",
13459 width: "100%",
13460 height: "260px",
13461 overflowX: "auto"
13462 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
13463 variant: "body1",
13464 dangerouslySetInnerHTML: { __html: animationSummary }
13465 })), /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, { introductionKey: "ai-context-animation-promotion" }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
13466 direction: "row",
13467 alignItems: "center",
13468 sx: { mt: 4 }
13469 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
13470 direction: "row",
13471 gap: 1,
13472 justifyContent: "flex-end",
13473 flexGrow: 1
13474 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
13475 size: "small",
13476 color: "secondary",
13477 variant: "text",
13478 onClick: function onClick() {
13479 restorePrevSettings();
13480 reset();
13481 }
13482 }, (0, _wordpress_i18n.__)("New prompt", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
13483 size: "small",
13484 variant: "contained",
13485 color: "primary",
13486 onClick: function onClick() {
13487 return applyPrompt(data.result);
13488 }
13489 }, (0, _wordpress_i18n.__)("Use animation", "elementor"))))));
13490 };
13491 FormAnimation.propTypes = {
13492 onClose: import_prop_types$7.default.func.isRequired,
13493 getControlValue: import_prop_types$7.default.func.isRequired,
13494 setControlValue: import_prop_types$7.default.func.isRequired,
13495 additionalOptions: import_prop_types$7.default.shape({
13496 animationType: import_prop_types$7.default.string,
13497 widgetType: import_prop_types$7.default.string
13498 }),
13499 credits: import_prop_types$7.default.number,
13500 children: import_prop_types$7.default.node
13501 };
13502
13503 //#endregion
13504 //#region \0vite/preload-helper.js
13505 var scriptRel, assetsURL, seen, __vitePreload;
13506 var init_preload_helper = __esmMin((() => {
13507 scriptRel = "modulepreload";
13508 assetsURL = function(dep) {
13509 return "/" + dep;
13510 };
13511 seen = {};
13512 __vitePreload = function preload(baseModule, deps, importerUrl) {
13513 let promise = Promise.resolve();
13514 if (false && deps && deps.length > 0) {
13515 const links = document.getElementsByTagName("link");
13516 const cspNonceMeta = document.querySelector("meta[property=csp-nonce]");
13517 const cspNonce = (cspNonceMeta === null || cspNonceMeta === void 0 ? void 0 : cspNonceMeta.nonce) || (cspNonceMeta === null || cspNonceMeta === void 0 ? void 0 : cspNonceMeta.getAttribute("nonce"));
13518 function allSettled(promises) {
13519 return Promise.all(promises.map((p) => Promise.resolve(p).then((value) => ({
13520 status: "fulfilled",
13521 value
13522 }), (reason) => ({
13523 status: "rejected",
13524 reason
13525 }))));
13526 }
13527 function importMetaResolve(specifier) {
13528 if ({}.resolve) return {}.resolve(specifier);
13529 return new URL(
13530 specifier,
13531 /** #__KEEP__ */
13532 {}.url
13533 ).href;
13534 }
13535 promise = allSettled(deps.map((dep) => {
13536 dep = assetsURL(dep, importerUrl);
13537 dep = importMetaResolve(dep);
13538 if (dep in seen) return;
13539 seen[dep] = true;
13540 const isCss = dep.endsWith(".css");
13541 for (let i = links.length - 1; i >= 0; i--) {
13542 const link = links[i];
13543 if (link.href === dep && (!isCss || link.rel === "stylesheet")) return;
13544 }
13545 const link = document.createElement("link");
13546 link.rel = isCss ? "stylesheet" : scriptRel;
13547 if (!isCss) link.as = "script";
13548 link.crossOrigin = "";
13549 link.href = dep;
13550 if (cspNonce) link.setAttribute("nonce", cspNonce);
13551 document.head.appendChild(link);
13552 if (isCss) return new Promise((res, rej) => {
13553 link.addEventListener("load", res);
13554 link.addEventListener("error", () => rej(/* @__PURE__ */ new Error(`Unable to preload CSS for ${dep}`)));
13555 });
13556 }));
13557 }
13558 function handlePreloadError(err) {
13559 const e = new Event("vite:preloadError", { cancelable: true });
13560 e.payload = err;
13561 window.dispatchEvent(e);
13562 if (!e.defaultPrevented) throw err;
13563 }
13564 return promise.then((res) => {
13565 for (const item of res || []) {
13566 if (item.status !== "rejected") continue;
13567 handlePreloadError(item.reason);
13568 }
13569 return baseModule().catch(handlePreloadError);
13570 });
13571 };
13572 }));
13573
13574 //#endregion
13575 //#region modules/ai/assets/js/editor/pages/form-code/code-block.js
13576 var import_prop_types$2, _excluded$5, CodeBlock;
13577 var init_code_block = __esmMin((() => {
13578 init_extends();
13579 init_objectWithoutProperties();
13580 import_prop_types$2 = /* @__PURE__ */ __toESM(require_prop_types());
13581 init_textarea();
13582 _excluded$5 = [
13583 "node",
13584 "inline",
13585 "children",
13586 "defaultValue",
13587 "onInsert"
13588 ];
13589 CodeBlock = function CodeBlock(_ref) {
13590 _ref.node;
13591 var inline = _ref.inline;
13592 var children = _ref.children;
13593 var defaultValue = _ref.defaultValue;
13594 var onInsert = _ref.onInsert;
13595 var props = _objectWithoutProperties(_ref, _excluded$5);
13596 var codeBlockInput = (0, react.useRef)(null);
13597 if (inline) return /*#__PURE__*/ react.default.createElement("code", props);
13598 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
13599 sx: { position: "relative" },
13600 dir: "ltr"
13601 }, /*#__PURE__*/ react.default.createElement(Textarea, _extends$1({
13602 fullWidth: true,
13603 ref: codeBlockInput,
13604 defaultValue: children[0],
13605 sx: { mb: 1 },
13606 helperText: (0, _wordpress_i18n.__)("Code generated by AI may be inaccurate.", "elementor")
13607 }, props)), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
13608 size: "small",
13609 variant: "contained",
13610 onClick: function onClick() {
13611 return onInsert(defaultValue + "\n" + codeBlockInput.current.value);
13612 },
13613 sx: {
13614 position: "absolute",
13615 right: "11px /* @noflip */",
13616 bottom: "44px"
13617 }
13618 }, (0, _wordpress_i18n.__)("Insert", "elementor")));
13619 };
13620 CodeBlock.propTypes = {
13621 node: import_prop_types$2.default.object,
13622 inline: import_prop_types$2.default.bool,
13623 children: import_prop_types$2.default.arrayOf(import_prop_types$2.default.node).isRequired,
13624 defaultValue: import_prop_types$2.default.string,
13625 onInsert: import_prop_types$2.default.func.isRequired
13626 };
13627 }));
13628
13629 //#endregion
13630 //#region modules/ai/assets/js/editor/hooks/use-code-prompt.js
13631 function ownKeys$7(e, r) {
13632 var t = Object.keys(e);
13633 if (Object.getOwnPropertySymbols) {
13634 var o = Object.getOwnPropertySymbols(e);
13635 r && (o = o.filter(function(r) {
13636 return Object.getOwnPropertyDescriptor(e, r).enumerable;
13637 })), t.push.apply(t, o);
13638 }
13639 return t;
13640 }
13641 function _objectSpread$7(e) {
13642 for (var r = 1; r < arguments.length; r++) {
13643 var t = null != arguments[r] ? arguments[r] : {};
13644 r % 2 ? ownKeys$7(Object(t), !0).forEach(function(r) {
13645 _defineProperty(e, r, t[r]);
13646 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function(r) {
13647 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
13648 });
13649 }
13650 return e;
13651 }
13652 var import_regenerator$1, getCodeResult, useCodePrompt;
13653 var init_use_code_prompt = __esmMin((() => {
13654 init_defineProperty();
13655 init_asyncToGenerator();
13656 import_regenerator$1 = /* @__PURE__ */ __toESM(require_regenerator());
13657 init_api();
13658 init_use_prompt();
13659 __name(ownKeys$7, "ownKeys");
13660 __name(_objectSpread$7, "_objectSpread");
13661 getCodeResult = /*#__PURE__*/ function() {
13662 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$1.default.mark(function _callee(payload, _ref) {
13663 var codeLanguage;
13664 var htmlMarkup;
13665 var elementId;
13666 return import_regenerator$1.default.wrap(function(_context) {
13667 while (1) switch (_context.prev = _context.next) {
13668 case 0:
13669 codeLanguage = _ref.codeLanguage, htmlMarkup = _ref.htmlMarkup, elementId = _ref.elementId;
13670 if (!("css" === codeLanguage)) {
13671 _context.next = 1;
13672 break;
13673 }
13674 return _context.abrupt("return", getCustomCSS(_objectSpread$7(_objectSpread$7({}, payload), {}, {
13675 html_markup: htmlMarkup,
13676 element_id: elementId
13677 })));
13678 case 1: return _context.abrupt("return", getCustomCode(_objectSpread$7(_objectSpread$7({}, payload), {}, { language: codeLanguage })));
13679 case 2:
13680 case "end": return _context.stop();
13681 }
13682 }, _callee);
13683 }));
13684 return function getCodeResult(_x, _x2) {
13685 return _ref2.apply(this, arguments);
13686 };
13687 }();
13688 useCodePrompt = function useCodePrompt(_ref3) {
13689 var codeLanguage = _ref3.codeLanguage;
13690 var htmlMarkup = _ref3.htmlMarkup;
13691 var elementId = _ref3.elementId;
13692 var credits = _ref3.initialCredits;
13693 return usePrompt(function(payload) {
13694 return getCodeResult(payload, {
13695 codeLanguage,
13696 htmlMarkup,
13697 elementId
13698 });
13699 }, { credits });
13700 };
13701 }));
13702
13703 //#endregion
13704 //#region modules/ai/assets/js/editor/pages/form-code/splitTextResult.js
13705 function splitText(inputText) {
13706 if (!inputText) return {};
13707 var codeMatch = inputText.match(/```([\s\S]*?)```/);
13708 var code = codeMatch ? "```".concat(codeMatch[1], "```").trim() : "";
13709 var detailsMatch = inputText.match(/```[\s\S]*?```([\s\S]*)/);
13710 return {
13711 code,
13712 details: detailsMatch === null || detailsMatch === void 0 ? void 0 : detailsMatch[1].trim()
13713 };
13714 }
13715 var init_splitTextResult = __esmMin((() => {}));
13716
13717 //#endregion
13718 //#region node_modules/react-markdown/lib/uri-transformer.js
13719 /**
13720 * @param {string} uri
13721 * @returns {string}
13722 */
13723 function uriTransformer(uri) {
13724 const url = (uri || "").trim();
13725 const first = url.charAt(0);
13726 if (first === "#" || first === "/") return url;
13727 const colon = url.indexOf(":");
13728 if (colon === -1) return url;
13729 let index = -1;
13730 while (++index < protocols.length) {
13731 const protocol = protocols[index];
13732 if (colon === protocol.length && url.slice(0, protocol.length).toLowerCase() === protocol) return url;
13733 }
13734 index = url.indexOf("?");
13735 if (index !== -1 && colon > index) return url;
13736 index = url.indexOf("#");
13737 if (index !== -1 && colon > index) return url;
13738 return "javascript:void(0)";
13739 }
13740 var protocols;
13741 var init_uri_transformer = __esmMin((() => {
13742 protocols = [
13743 "http",
13744 "https",
13745 "mailto",
13746 "tel"
13747 ];
13748 }));
13749
13750 //#endregion
13751 //#region node_modules/vfile/node_modules/is-buffer/index.js
13752 var require_is_buffer$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13753 /*!
13754 * Determine if an object is a Buffer
13755 *
13756 * @author Feross Aboukhadijeh <https://feross.org>
13757 * @license MIT
13758 */
13759 module.exports = function isBuffer(obj) {
13760 return obj != null && obj.constructor != null && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
13761 };
13762 }));
13763
13764 //#endregion
13765 //#region node_modules/unist-util-stringify-position/lib/index.js
13766 /**
13767 * @typedef {import('unist').Node} Node
13768 * @typedef {import('unist').Point} Point
13769 * @typedef {import('unist').Position} Position
13770 */
13771 /**
13772 * @typedef NodeLike
13773 * @property {string} type
13774 * @property {PositionLike | null | undefined} [position]
13775 *
13776 * @typedef PositionLike
13777 * @property {PointLike | null | undefined} [start]
13778 * @property {PointLike | null | undefined} [end]
13779 *
13780 * @typedef PointLike
13781 * @property {number | null | undefined} [line]
13782 * @property {number | null | undefined} [column]
13783 * @property {number | null | undefined} [offset]
13784 */
13785 /**
13786 * Serialize the positional info of a point, position (start and end points),
13787 * or node.
13788 *
13789 * @param {Node | NodeLike | Position | PositionLike | Point | PointLike | null | undefined} [value]
13790 * Node, position, or point.
13791 * @returns {string}
13792 * Pretty printed positional info of a node (`string`).
13793 *
13794 * In the format of a range `ls:cs-le:ce` (when given `node` or `position`)
13795 * or a point `l:c` (when given `point`), where `l` stands for line, `c` for
13796 * column, `s` for `start`, and `e` for end.
13797 * An empty string (`''`) is returned if the given value is neither `node`,
13798 * `position`, nor `point`.
13799 */
13800 function stringifyPosition(value) {
13801 if (!value || typeof value !== "object") return "";
13802 if ("position" in value || "type" in value) return position$1(value.position);
13803 if ("start" in value || "end" in value) return position$1(value);
13804 if ("line" in value || "column" in value) return point$2(value);
13805 return "";
13806 }
13807 /**
13808 * @param {Point | PointLike | null | undefined} point
13809 * @returns {string}
13810 */
13811 function point$2(point) {
13812 return index(point && point.line) + ":" + index(point && point.column);
13813 }
13814 /**
13815 * @param {Position | PositionLike | null | undefined} pos
13816 * @returns {string}
13817 */
13818 function position$1(pos) {
13819 return point$2(pos && pos.start) + "-" + point$2(pos && pos.end);
13820 }
13821 /**
13822 * @param {number | null | undefined} value
13823 * @returns {number}
13824 */
13825 function index(value) {
13826 return value && typeof value === "number" ? value : 1;
13827 }
13828 var init_lib$15 = __esmMin((() => {
13829 __name(point$2, "point");
13830 __name(position$1, "position");
13831 }));
13832
13833 //#endregion
13834 //#region node_modules/unist-util-stringify-position/index.js
13835 var init_unist_util_stringify_position = __esmMin((() => {
13836 init_lib$15();
13837 }));
13838
13839 //#endregion
13840 //#region node_modules/vfile-message/lib/index.js
13841 var VFileMessage;
13842 var init_lib$14 = __esmMin((() => {
13843 init_unist_util_stringify_position();
13844 VFileMessage = class extends Error {
13845 /**
13846 * Create a message for `reason` at `place` from `origin`.
13847 *
13848 * When an error is passed in as `reason`, the `stack` is copied.
13849 *
13850 * @param {string | Error | VFileMessage} reason
13851 * Reason for message, uses the stack and message of the error if given.
13852 *
13853 * > 👉 **Note**: you should use markdown.
13854 * @param {Node | NodeLike | Position | Point | null | undefined} [place]
13855 * Place in file where the message occurred.
13856 * @param {string | null | undefined} [origin]
13857 * Place in code where the message originates (example:
13858 * `'my-package:my-rule'` or `'my-rule'`).
13859 * @returns
13860 * Instance of `VFileMessage`.
13861 */
13862 constructor(reason, place, origin) {
13863 /** @type {[string | null, string | null]} */
13864 const parts = [null, null];
13865 /** @type {Position} */
13866 let position = {
13867 start: {
13868 line: null,
13869 column: null
13870 },
13871 end: {
13872 line: null,
13873 column: null
13874 }
13875 };
13876 super();
13877 if (typeof place === "string") {
13878 origin = place;
13879 place = void 0;
13880 }
13881 if (typeof origin === "string") {
13882 const index = origin.indexOf(":");
13883 if (index === -1) parts[1] = origin;
13884 else {
13885 parts[0] = origin.slice(0, index);
13886 parts[1] = origin.slice(index + 1);
13887 }
13888 }
13889 if (place) {
13890 if ("type" in place || "position" in place) {
13891 if (place.position) position = place.position;
13892 } else if ("start" in place || "end" in place) position = place;
13893 else if ("line" in place || "column" in place) position.start = place;
13894 }
13895 /**
13896 * Serialized positional info of error.
13897 *
13898 * On normal errors, this would be something like `ParseError`, buit in
13899 * `VFile` messages we use this space to show where an error happened.
13900 */
13901 this.name = stringifyPosition(place) || "1:1";
13902 /**
13903 * Reason for message.
13904 *
13905 * @type {string}
13906 */
13907 this.message = typeof reason === "object" ? reason.message : reason;
13908 /**
13909 * Stack of message.
13910 *
13911 * This is used by normal errors to show where something happened in
13912 * programming code, irrelevant for `VFile` messages,
13913 *
13914 * @type {string}
13915 */
13916 this.stack = "";
13917 if (typeof reason === "object" && reason.stack) this.stack = reason.stack;
13918 /**
13919 * Reason for message.
13920 *
13921 * > 👉 **Note**: you should use markdown.
13922 *
13923 * @type {string}
13924 */
13925 this.reason = this.message;
13926 /**
13927 * State of problem.
13928 *
13929 * * `true` — marks associated file as no longer processable (error)
13930 * * `false` — necessitates a (potential) change (warning)
13931 * * `null | undefined` — for things that might not need changing (info)
13932 *
13933 * @type {boolean | null | undefined}
13934 */
13935 this.fatal;
13936 /**
13937 * Starting line of error.
13938 *
13939 * @type {number | null}
13940 */
13941 this.line = position.start.line;
13942 /**
13943 * Starting column of error.
13944 *
13945 * @type {number | null}
13946 */
13947 this.column = position.start.column;
13948 /**
13949 * Full unist position.
13950 *
13951 * @type {Position | null}
13952 */
13953 this.position = position;
13954 /**
13955 * Namespace of message (example: `'my-package'`).
13956 *
13957 * @type {string | null}
13958 */
13959 this.source = parts[0];
13960 /**
13961 * Category of message (example: `'my-rule'`).
13962 *
13963 * @type {string | null}
13964 */
13965 this.ruleId = parts[1];
13966 /**
13967 * Path of a file (used throughout the `VFile` ecosystem).
13968 *
13969 * @type {string | null}
13970 */
13971 this.file;
13972 /**
13973 * Specify the source value that’s being reported, which is deemed
13974 * incorrect.
13975 *
13976 * @type {string | null}
13977 */
13978 this.actual;
13979 /**
13980 * Suggest acceptable values that can be used instead of `actual`.
13981 *
13982 * @type {Array<string> | null}
13983 */
13984 this.expected;
13985 /**
13986 * Link to docs for the message.
13987 *
13988 * > 👉 **Note**: this must be an absolute URL that can be passed as `x`
13989 * > to `new URL(x)`.
13990 *
13991 * @type {string | null}
13992 */
13993 this.url;
13994 /**
13995 * Long form description of the message (you should use markdown).
13996 *
13997 * @type {string | null}
13998 */
13999 this.note;
14000 }
14001 };
14002 VFileMessage.prototype.file = "";
14003 VFileMessage.prototype.name = "";
14004 VFileMessage.prototype.reason = "";
14005 VFileMessage.prototype.message = "";
14006 VFileMessage.prototype.stack = "";
14007 VFileMessage.prototype.fatal = null;
14008 VFileMessage.prototype.column = null;
14009 VFileMessage.prototype.line = null;
14010 VFileMessage.prototype.source = null;
14011 VFileMessage.prototype.ruleId = null;
14012 VFileMessage.prototype.position = null;
14013 }));
14014
14015 //#endregion
14016 //#region node_modules/vfile-message/index.js
14017 var init_vfile_message = __esmMin((() => {
14018 init_lib$14();
14019 }));
14020
14021 //#endregion
14022 //#region node_modules/vfile/lib/minpath.browser.js
14023 /**
14024 * Get the basename from a path.
14025 *
14026 * @param {string} path
14027 * File path.
14028 * @param {string | undefined} [ext]
14029 * Extension to strip.
14030 * @returns {string}
14031 * Stem or basename.
14032 */
14033 function basename(path, ext) {
14034 if (ext !== void 0 && typeof ext !== "string") throw new TypeError("\"ext\" argument must be a string");
14035 assertPath$1(path);
14036 let start = 0;
14037 let end = -1;
14038 let index = path.length;
14039 /** @type {boolean | undefined} */
14040 let seenNonSlash;
14041 if (ext === void 0 || ext.length === 0 || ext.length > path.length) {
14042 while (index--) if (path.charCodeAt(index) === 47) {
14043 if (seenNonSlash) {
14044 start = index + 1;
14045 break;
14046 }
14047 } else if (end < 0) {
14048 seenNonSlash = true;
14049 end = index + 1;
14050 }
14051 return end < 0 ? "" : path.slice(start, end);
14052 }
14053 if (ext === path) return "";
14054 let firstNonSlashEnd = -1;
14055 let extIndex = ext.length - 1;
14056 while (index--) if (path.charCodeAt(index) === 47) {
14057 if (seenNonSlash) {
14058 start = index + 1;
14059 break;
14060 }
14061 } else {
14062 if (firstNonSlashEnd < 0) {
14063 seenNonSlash = true;
14064 firstNonSlashEnd = index + 1;
14065 }
14066 if (extIndex > -1) if (path.charCodeAt(index) === ext.charCodeAt(extIndex--)) {
14067 if (extIndex < 0) end = index;
14068 } else {
14069 extIndex = -1;
14070 end = firstNonSlashEnd;
14071 }
14072 }
14073 if (start === end) end = firstNonSlashEnd;
14074 else if (end < 0) end = path.length;
14075 return path.slice(start, end);
14076 }
14077 /**
14078 * Get the dirname from a path.
14079 *
14080 * @param {string} path
14081 * File path.
14082 * @returns {string}
14083 * File path.
14084 */
14085 function dirname(path) {
14086 assertPath$1(path);
14087 if (path.length === 0) return ".";
14088 let end = -1;
14089 let index = path.length;
14090 /** @type {boolean | undefined} */
14091 let unmatchedSlash;
14092 while (--index) if (path.charCodeAt(index) === 47) {
14093 if (unmatchedSlash) {
14094 end = index;
14095 break;
14096 }
14097 } else if (!unmatchedSlash) unmatchedSlash = true;
14098 return end < 0 ? path.charCodeAt(0) === 47 ? "/" : "." : end === 1 && path.charCodeAt(0) === 47 ? "//" : path.slice(0, end);
14099 }
14100 /**
14101 * Get an extname from a path.
14102 *
14103 * @param {string} path
14104 * File path.
14105 * @returns {string}
14106 * Extname.
14107 */
14108 function extname(path) {
14109 assertPath$1(path);
14110 let index = path.length;
14111 let end = -1;
14112 let startPart = 0;
14113 let startDot = -1;
14114 let preDotState = 0;
14115 /** @type {boolean | undefined} */
14116 let unmatchedSlash;
14117 while (index--) {
14118 const code = path.charCodeAt(index);
14119 if (code === 47) {
14120 if (unmatchedSlash) {
14121 startPart = index + 1;
14122 break;
14123 }
14124 continue;
14125 }
14126 if (end < 0) {
14127 unmatchedSlash = true;
14128 end = index + 1;
14129 }
14130 if (code === 46) {
14131 if (startDot < 0) startDot = index;
14132 else if (preDotState !== 1) preDotState = 1;
14133 } else if (startDot > -1) preDotState = -1;
14134 }
14135 if (startDot < 0 || end < 0 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) return "";
14136 return path.slice(startDot, end);
14137 }
14138 /**
14139 * Join segments from a path.
14140 *
14141 * @param {Array<string>} segments
14142 * Path segments.
14143 * @returns {string}
14144 * File path.
14145 */
14146 function join(...segments) {
14147 let index = -1;
14148 /** @type {string | undefined} */
14149 let joined;
14150 while (++index < segments.length) {
14151 assertPath$1(segments[index]);
14152 if (segments[index]) joined = joined === void 0 ? segments[index] : joined + "/" + segments[index];
14153 }
14154 return joined === void 0 ? "." : normalize$1(joined);
14155 }
14156 /**
14157 * Normalize a basic file path.
14158 *
14159 * @param {string} path
14160 * File path.
14161 * @returns {string}
14162 * File path.
14163 */
14164 function normalize$1(path) {
14165 assertPath$1(path);
14166 const absolute = path.charCodeAt(0) === 47;
14167 let value = normalizeString(path, !absolute);
14168 if (value.length === 0 && !absolute) value = ".";
14169 if (value.length > 0 && path.charCodeAt(path.length - 1) === 47) value += "/";
14170 return absolute ? "/" + value : value;
14171 }
14172 /**
14173 * Resolve `.` and `..` elements in a path with directory names.
14174 *
14175 * @param {string} path
14176 * File path.
14177 * @param {boolean} allowAboveRoot
14178 * Whether `..` can move above root.
14179 * @returns {string}
14180 * File path.
14181 */
14182 function normalizeString(path, allowAboveRoot) {
14183 let result = "";
14184 let lastSegmentLength = 0;
14185 let lastSlash = -1;
14186 let dots = 0;
14187 let index = -1;
14188 /** @type {number | undefined} */
14189 let code;
14190 /** @type {number} */
14191 let lastSlashIndex;
14192 while (++index <= path.length) {
14193 if (index < path.length) code = path.charCodeAt(index);
14194 else if (code === 47) break;
14195 else code = 47;
14196 if (code === 47) {
14197 if (lastSlash === index - 1 || dots === 1) {} else if (lastSlash !== index - 1 && dots === 2) {
14198 if (result.length < 2 || lastSegmentLength !== 2 || result.charCodeAt(result.length - 1) !== 46 || result.charCodeAt(result.length - 2) !== 46) {
14199 if (result.length > 2) {
14200 lastSlashIndex = result.lastIndexOf("/");
14201 if (lastSlashIndex !== result.length - 1) {
14202 if (lastSlashIndex < 0) {
14203 result = "";
14204 lastSegmentLength = 0;
14205 } else {
14206 result = result.slice(0, lastSlashIndex);
14207 lastSegmentLength = result.length - 1 - result.lastIndexOf("/");
14208 }
14209 lastSlash = index;
14210 dots = 0;
14211 continue;
14212 }
14213 } else if (result.length > 0) {
14214 result = "";
14215 lastSegmentLength = 0;
14216 lastSlash = index;
14217 dots = 0;
14218 continue;
14219 }
14220 }
14221 if (allowAboveRoot) {
14222 result = result.length > 0 ? result + "/.." : "..";
14223 lastSegmentLength = 2;
14224 }
14225 } else {
14226 if (result.length > 0) result += "/" + path.slice(lastSlash + 1, index);
14227 else result = path.slice(lastSlash + 1, index);
14228 lastSegmentLength = index - lastSlash - 1;
14229 }
14230 lastSlash = index;
14231 dots = 0;
14232 } else if (code === 46 && dots > -1) dots++;
14233 else dots = -1;
14234 }
14235 return result;
14236 }
14237 /**
14238 * Make sure `path` is a string.
14239 *
14240 * @param {string} path
14241 * File path.
14242 * @returns {asserts path is string}
14243 * Nothing.
14244 */
14245 function assertPath$1(path) {
14246 if (typeof path !== "string") throw new TypeError("Path must be a string. Received " + JSON.stringify(path));
14247 }
14248 var path;
14249 var init_minpath_browser = __esmMin((() => {
14250 path = {
14251 basename,
14252 dirname,
14253 extname,
14254 join,
14255 sep: "/"
14256 };
14257 __name(normalize$1, "normalize");
14258 __name(assertPath$1, "assertPath");
14259 }));
14260
14261 //#endregion
14262 //#region node_modules/vfile/lib/minproc.browser.js
14263 function cwd() {
14264 return "/";
14265 }
14266 var proc;
14267 var init_minproc_browser = __esmMin((() => {
14268 proc = { cwd };
14269 }));
14270
14271 //#endregion
14272 //#region node_modules/vfile/lib/minurl.shared.js
14273 /**
14274 * @typedef URL
14275 * @property {string} hash
14276 * @property {string} host
14277 * @property {string} hostname
14278 * @property {string} href
14279 * @property {string} origin
14280 * @property {string} password
14281 * @property {string} pathname
14282 * @property {string} port
14283 * @property {string} protocol
14284 * @property {string} search
14285 * @property {any} searchParams
14286 * @property {string} username
14287 * @property {() => string} toString
14288 * @property {() => string} toJSON
14289 */
14290 /**
14291 * Check if `fileUrlOrPath` looks like a URL.
14292 *
14293 * @param {unknown} fileUrlOrPath
14294 * File path or URL.
14295 * @returns {fileUrlOrPath is URL}
14296 * Whether it’s a URL.
14297 */
14298 function isUrl(fileUrlOrPath) {
14299 return fileUrlOrPath !== null && typeof fileUrlOrPath === "object" && fileUrlOrPath.href && fileUrlOrPath.origin;
14300 }
14301 var init_minurl_shared = __esmMin((() => {}));
14302
14303 //#endregion
14304 //#region node_modules/vfile/lib/minurl.browser.js
14305 /**
14306 * @param {string | URL} path
14307 * File URL.
14308 * @returns {string}
14309 * File URL.
14310 */
14311 function urlToPath(path) {
14312 if (typeof path === "string") path = new URL(path);
14313 else if (!isUrl(path)) {
14314 /** @type {NodeJS.ErrnoException} */
14315 const error = /* @__PURE__ */ new TypeError("The \"path\" argument must be of type string or an instance of URL. Received `" + path + "`");
14316 error.code = "ERR_INVALID_ARG_TYPE";
14317 throw error;
14318 }
14319 if (path.protocol !== "file:") {
14320 /** @type {NodeJS.ErrnoException} */
14321 const error = /* @__PURE__ */ new TypeError("The URL must be of scheme file");
14322 error.code = "ERR_INVALID_URL_SCHEME";
14323 throw error;
14324 }
14325 return getPathFromURLPosix(path);
14326 }
14327 /**
14328 * Get a path from a POSIX URL.
14329 *
14330 * @param {URL} url
14331 * URL.
14332 * @returns {string}
14333 * File path.
14334 */
14335 function getPathFromURLPosix(url) {
14336 if (url.hostname !== "") {
14337 /** @type {NodeJS.ErrnoException} */
14338 const error = /* @__PURE__ */ new TypeError("File URL host must be \"localhost\" or empty on darwin");
14339 error.code = "ERR_INVALID_FILE_URL_HOST";
14340 throw error;
14341 }
14342 const pathname = url.pathname;
14343 let index = -1;
14344 while (++index < pathname.length) if (pathname.charCodeAt(index) === 37 && pathname.charCodeAt(index + 1) === 50) {
14345 const third = pathname.charCodeAt(index + 2);
14346 if (third === 70 || third === 102) {
14347 /** @type {NodeJS.ErrnoException} */
14348 const error = /* @__PURE__ */ new TypeError("File URL path must not include encoded / characters");
14349 error.code = "ERR_INVALID_FILE_URL_PATH";
14350 throw error;
14351 }
14352 }
14353 return decodeURIComponent(pathname);
14354 }
14355 var init_minurl_browser = __esmMin((() => {
14356 init_minurl_shared();
14357 }));
14358
14359 //#endregion
14360 //#region node_modules/vfile/lib/index.js
14361 /**
14362 * Assert that `part` is not a path (as in, does not contain `path.sep`).
14363 *
14364 * @param {string | null | undefined} part
14365 * File path part.
14366 * @param {string} name
14367 * Part name.
14368 * @returns {void}
14369 * Nothing.
14370 */
14371 function assertPart(part, name) {
14372 if (part && part.includes(path.sep)) throw new Error("`" + name + "` cannot be a path: did not expect `" + path.sep + "`");
14373 }
14374 /**
14375 * Assert that `part` is not empty.
14376 *
14377 * @param {string | undefined} part
14378 * Thing.
14379 * @param {string} name
14380 * Part name.
14381 * @returns {asserts part is string}
14382 * Nothing.
14383 */
14384 function assertNonEmpty(part, name) {
14385 if (!part) throw new Error("`" + name + "` cannot be empty");
14386 }
14387 /**
14388 * Assert `path` exists.
14389 *
14390 * @param {string | undefined} path
14391 * Path.
14392 * @param {string} name
14393 * Dependency name.
14394 * @returns {asserts path is string}
14395 * Nothing.
14396 */
14397 function assertPath(path, name) {
14398 if (!path) throw new Error("Setting `" + name + "` requires `path` to be set too");
14399 }
14400 /**
14401 * Assert `value` is a buffer.
14402 *
14403 * @param {unknown} value
14404 * thing.
14405 * @returns {value is Buffer}
14406 * Whether `value` is a Node.js buffer.
14407 */
14408 function buffer(value) {
14409 return (0, import_is_buffer$1.default)(value);
14410 }
14411 var import_is_buffer$1, order, VFile;
14412 var init_lib$13 = __esmMin((() => {
14413 import_is_buffer$1 = /* @__PURE__ */ __toESM(require_is_buffer$1(), 1);
14414 init_vfile_message();
14415 init_minpath_browser();
14416 init_minproc_browser();
14417 init_minurl_browser();
14418 order = [
14419 "history",
14420 "path",
14421 "basename",
14422 "stem",
14423 "extname",
14424 "dirname"
14425 ];
14426 VFile = class {
14427 /**
14428 * Create a new virtual file.
14429 *
14430 * `options` is treated as:
14431 *
14432 * * `string` or `Buffer` — `{value: options}`
14433 * * `URL` — `{path: options}`
14434 * * `VFile` — shallow copies its data over to the new file
14435 * * `object` — all fields are shallow copied over to the new file
14436 *
14437 * Path related fields are set in the following order (least specific to
14438 * most specific): `history`, `path`, `basename`, `stem`, `extname`,
14439 * `dirname`.
14440 *
14441 * You cannot set `dirname` or `extname` without setting either `history`,
14442 * `path`, `basename`, or `stem` too.
14443 *
14444 * @param {Compatible | null | undefined} [value]
14445 * File value.
14446 * @returns
14447 * New instance.
14448 */
14449 constructor(value) {
14450 /** @type {Options | VFile} */
14451 let options;
14452 if (!value) options = {};
14453 else if (typeof value === "string" || buffer(value)) options = { value };
14454 else if (isUrl(value)) options = { path: value };
14455 else options = value;
14456 /**
14457 * Place to store custom information (default: `{}`).
14458 *
14459 * It’s OK to store custom data directly on the file but moving it to
14460 * `data` is recommended.
14461 *
14462 * @type {Data}
14463 */
14464 this.data = {};
14465 /**
14466 * List of messages associated with the file.
14467 *
14468 * @type {Array<VFileMessage>}
14469 */
14470 this.messages = [];
14471 /**
14472 * List of filepaths the file moved between.
14473 *
14474 * The first is the original path and the last is the current path.
14475 *
14476 * @type {Array<string>}
14477 */
14478 this.history = [];
14479 /**
14480 * Base of `path` (default: `process.cwd()` or `'/'` in browsers).
14481 *
14482 * @type {string}
14483 */
14484 this.cwd = proc.cwd();
14485 /**
14486 * Raw value.
14487 *
14488 * @type {Value}
14489 */
14490 this.value;
14491 /**
14492 * Whether a file was saved to disk.
14493 *
14494 * This is used by vfile reporters.
14495 *
14496 * @type {boolean}
14497 */
14498 this.stored;
14499 /**
14500 * Custom, non-string, compiled, representation.
14501 *
14502 * This is used by unified to store non-string results.
14503 * One example is when turning markdown into React nodes.
14504 *
14505 * @type {unknown}
14506 */
14507 this.result;
14508 /**
14509 * Source map.
14510 *
14511 * This type is equivalent to the `RawSourceMap` type from the `source-map`
14512 * module.
14513 *
14514 * @type {Map | null | undefined}
14515 */
14516 this.map;
14517 let index = -1;
14518 while (++index < order.length) {
14519 const prop = order[index];
14520 if (prop in options && options[prop] !== void 0 && options[prop] !== null) this[prop] = prop === "history" ? [...options[prop]] : options[prop];
14521 }
14522 /** @type {string} */
14523 let prop;
14524 for (prop in options) if (!order.includes(prop)) this[prop] = options[prop];
14525 }
14526 /**
14527 * Get the full path (example: `'~/index.min.js'`).
14528 *
14529 * @returns {string}
14530 */
14531 get path() {
14532 return this.history[this.history.length - 1];
14533 }
14534 /**
14535 * Set the full path (example: `'~/index.min.js'`).
14536 *
14537 * Cannot be nullified.
14538 * You can set a file URL (a `URL` object with a `file:` protocol) which will
14539 * be turned into a path with `url.fileURLToPath`.
14540 *
14541 * @param {string | URL} path
14542 */
14543 set path(path) {
14544 if (isUrl(path)) path = urlToPath(path);
14545 assertNonEmpty(path, "path");
14546 if (this.path !== path) this.history.push(path);
14547 }
14548 /**
14549 * Get the parent path (example: `'~'`).
14550 */
14551 get dirname() {
14552 return typeof this.path === "string" ? path.dirname(this.path) : void 0;
14553 }
14554 /**
14555 * Set the parent path (example: `'~'`).
14556 *
14557 * Cannot be set if there’s no `path` yet.
14558 */
14559 set dirname(dirname) {
14560 assertPath(this.basename, "dirname");
14561 this.path = path.join(dirname || "", this.basename);
14562 }
14563 /**
14564 * Get the basename (including extname) (example: `'index.min.js'`).
14565 */
14566 get basename() {
14567 return typeof this.path === "string" ? path.basename(this.path) : void 0;
14568 }
14569 /**
14570 * Set basename (including extname) (`'index.min.js'`).
14571 *
14572 * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
14573 * on windows).
14574 * Cannot be nullified (use `file.path = file.dirname` instead).
14575 */
14576 set basename(basename) {
14577 assertNonEmpty(basename, "basename");
14578 assertPart(basename, "basename");
14579 this.path = path.join(this.dirname || "", basename);
14580 }
14581 /**
14582 * Get the extname (including dot) (example: `'.js'`).
14583 */
14584 get extname() {
14585 return typeof this.path === "string" ? path.extname(this.path) : void 0;
14586 }
14587 /**
14588 * Set the extname (including dot) (example: `'.js'`).
14589 *
14590 * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
14591 * on windows).
14592 * Cannot be set if there’s no `path` yet.
14593 */
14594 set extname(extname) {
14595 assertPart(extname, "extname");
14596 assertPath(this.dirname, "extname");
14597 if (extname) {
14598 if (extname.charCodeAt(0) !== 46) throw new Error("`extname` must start with `.`");
14599 if (extname.includes(".", 1)) throw new Error("`extname` cannot contain multiple dots");
14600 }
14601 this.path = path.join(this.dirname, this.stem + (extname || ""));
14602 }
14603 /**
14604 * Get the stem (basename w/o extname) (example: `'index.min'`).
14605 */
14606 get stem() {
14607 return typeof this.path === "string" ? path.basename(this.path, this.extname) : void 0;
14608 }
14609 /**
14610 * Set the stem (basename w/o extname) (example: `'index.min'`).
14611 *
14612 * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
14613 * on windows).
14614 * Cannot be nullified (use `file.path = file.dirname` instead).
14615 */
14616 set stem(stem) {
14617 assertNonEmpty(stem, "stem");
14618 assertPart(stem, "stem");
14619 this.path = path.join(this.dirname || "", stem + (this.extname || ""));
14620 }
14621 /**
14622 * Serialize the file.
14623 *
14624 * @param {BufferEncoding | null | undefined} [encoding='utf8']
14625 * Character encoding to understand `value` as when it’s a `Buffer`
14626 * (default: `'utf8'`).
14627 * @returns {string}
14628 * Serialized file.
14629 */
14630 toString(encoding) {
14631 return (this.value || "").toString(encoding || void 0);
14632 }
14633 /**
14634 * Create a warning message associated with the file.
14635 *
14636 * Its `fatal` is set to `false` and `file` is set to the current file path.
14637 * Its added to `file.messages`.
14638 *
14639 * @param {string | Error | VFileMessage} reason
14640 * Reason for message, uses the stack and message of the error if given.
14641 * @param {Node | NodeLike | Position | Point | null | undefined} [place]
14642 * Place in file where the message occurred.
14643 * @param {string | null | undefined} [origin]
14644 * Place in code where the message originates (example:
14645 * `'my-package:my-rule'` or `'my-rule'`).
14646 * @returns {VFileMessage}
14647 * Message.
14648 */
14649 message(reason, place, origin) {
14650 const message = new VFileMessage(reason, place, origin);
14651 if (this.path) {
14652 message.name = this.path + ":" + message.name;
14653 message.file = this.path;
14654 }
14655 message.fatal = false;
14656 this.messages.push(message);
14657 return message;
14658 }
14659 /**
14660 * Create an info message associated with the file.
14661 *
14662 * Its `fatal` is set to `null` and `file` is set to the current file path.
14663 * Its added to `file.messages`.
14664 *
14665 * @param {string | Error | VFileMessage} reason
14666 * Reason for message, uses the stack and message of the error if given.
14667 * @param {Node | NodeLike | Position | Point | null | undefined} [place]
14668 * Place in file where the message occurred.
14669 * @param {string | null | undefined} [origin]
14670 * Place in code where the message originates (example:
14671 * `'my-package:my-rule'` or `'my-rule'`).
14672 * @returns {VFileMessage}
14673 * Message.
14674 */
14675 info(reason, place, origin) {
14676 const message = this.message(reason, place, origin);
14677 message.fatal = null;
14678 return message;
14679 }
14680 /**
14681 * Create a fatal error associated with the file.
14682 *
14683 * Its `fatal` is set to `true` and `file` is set to the current file path.
14684 * Its added to `file.messages`.
14685 *
14686 * > 👉 **Note**: a fatal error means that a file is no longer processable.
14687 *
14688 * @param {string | Error | VFileMessage} reason
14689 * Reason for message, uses the stack and message of the error if given.
14690 * @param {Node | NodeLike | Position | Point | null | undefined} [place]
14691 * Place in file where the message occurred.
14692 * @param {string | null | undefined} [origin]
14693 * Place in code where the message originates (example:
14694 * `'my-package:my-rule'` or `'my-rule'`).
14695 * @returns {never}
14696 * Message.
14697 * @throws {VFileMessage}
14698 * Message.
14699 */
14700 fail(reason, place, origin) {
14701 const message = this.message(reason, place, origin);
14702 message.fatal = true;
14703 throw message;
14704 }
14705 };
14706 }));
14707
14708 //#endregion
14709 //#region node_modules/vfile/index.js
14710 var init_vfile = __esmMin((() => {
14711 init_lib$13();
14712 }));
14713
14714 //#endregion
14715 //#region node_modules/bail/index.js
14716 /**
14717 * Throw a given error.
14718 *
14719 * @param {Error|null|undefined} [error]
14720 * Maybe error.
14721 * @returns {asserts error is null|undefined}
14722 */
14723 function bail(error) {
14724 if (error) throw error;
14725 }
14726 var init_bail = __esmMin((() => {}));
14727
14728 //#endregion
14729 //#region node_modules/unified/node_modules/is-buffer/index.js
14730 var require_is_buffer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14731 /*!
14732 * Determine if an object is a Buffer
14733 *
14734 * @author Feross Aboukhadijeh <https://feross.org>
14735 * @license MIT
14736 */
14737 module.exports = function isBuffer(obj) {
14738 return obj != null && obj.constructor != null && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
14739 };
14740 }));
14741
14742 //#endregion
14743 //#region node_modules/extend/index.js
14744 var require_extend = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14745 var hasOwn = Object.prototype.hasOwnProperty;
14746 var toStr = Object.prototype.toString;
14747 var defineProperty = Object.defineProperty;
14748 var gOPD = Object.getOwnPropertyDescriptor;
14749 var isArray = function isArray(arr) {
14750 if (typeof Array.isArray === "function") return Array.isArray(arr);
14751 return toStr.call(arr) === "[object Array]";
14752 };
14753 var isPlainObject = function isPlainObject(obj) {
14754 if (!obj || toStr.call(obj) !== "[object Object]") return false;
14755 var hasOwnConstructor = hasOwn.call(obj, "constructor");
14756 var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, "isPrototypeOf");
14757 if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) return false;
14758 var key;
14759 for (key in obj);
14760 return typeof key === "undefined" || hasOwn.call(obj, key);
14761 };
14762 var setProperty = function setProperty(target, options) {
14763 if (defineProperty && options.name === "__proto__") defineProperty(target, options.name, {
14764 enumerable: true,
14765 configurable: true,
14766 value: options.newValue,
14767 writable: true
14768 });
14769 else target[options.name] = options.newValue;
14770 };
14771 var getProperty = function getProperty(obj, name) {
14772 if (name === "__proto__") {
14773 if (!hasOwn.call(obj, name)) return;
14774 else if (gOPD) return gOPD(obj, name).value;
14775 }
14776 return obj[name];
14777 };
14778 module.exports = function extend() {
14779 var options;
14780 var name;
14781 var src;
14782 var copy;
14783 var copyIsArray;
14784 var clone;
14785 var target = arguments[0];
14786 var i = 1;
14787 var length = arguments.length;
14788 var deep = false;
14789 if (typeof target === "boolean") {
14790 deep = target;
14791 target = arguments[1] || {};
14792 i = 2;
14793 }
14794 if (target == null || typeof target !== "object" && typeof target !== "function") target = {};
14795 for (; i < length; ++i) {
14796 options = arguments[i];
14797 if (options != null) for (name in options) {
14798 src = getProperty(target, name);
14799 copy = getProperty(options, name);
14800 if (target !== copy) {
14801 if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
14802 if (copyIsArray) {
14803 copyIsArray = false;
14804 clone = src && isArray(src) ? src : [];
14805 } else clone = src && isPlainObject(src) ? src : {};
14806 setProperty(target, {
14807 name,
14808 newValue: extend(deep, clone, copy)
14809 });
14810 } else if (typeof copy !== "undefined") setProperty(target, {
14811 name,
14812 newValue: copy
14813 });
14814 }
14815 }
14816 }
14817 return target;
14818 };
14819 }));
14820
14821 //#endregion
14822 //#region node_modules/is-plain-obj/index.js
14823 function isPlainObject(value) {
14824 if (typeof value !== "object" || value === null) return false;
14825 const prototype = Object.getPrototypeOf(value);
14826 return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
14827 }
14828 var init_is_plain_obj = __esmMin((() => {}));
14829
14830 //#endregion
14831 //#region node_modules/trough/lib/index.js
14832 /**
14833 * @typedef {(error?: Error | null | undefined, ...output: Array<any>) => void} Callback
14834 * Callback.
14835 *
14836 * @typedef {(...input: Array<any>) => any} Middleware
14837 * Ware.
14838 *
14839 * @typedef Pipeline
14840 * Pipeline.
14841 * @property {Run} run
14842 * Run the pipeline.
14843 * @property {Use} use
14844 * Add middleware.
14845 *
14846 * @typedef {(...input: Array<any>) => void} Run
14847 * Call all middleware.
14848 *
14849 * Calls `done` on completion with either an error or the output of the
14850 * last middleware.
14851 *
14852 * > 👉 **Note**: as the length of input defines whether async functions get a
14853 * > `next` function,
14854 * > it’s recommended to keep `input` at one value normally.
14855
14856 *
14857 * @typedef {(fn: Middleware) => Pipeline} Use
14858 * Add middleware.
14859 */
14860 /**
14861 * Create new middleware.
14862 *
14863 * @returns {Pipeline}
14864 * Pipeline.
14865 */
14866 function trough() {
14867 /** @type {Array<Middleware>} */
14868 const fns = [];
14869 /** @type {Pipeline} */
14870 const pipeline = {
14871 run,
14872 use
14873 };
14874 return pipeline;
14875 /** @type {Run} */
14876 function run(...values) {
14877 let middlewareIndex = -1;
14878 /** @type {Callback} */
14879 const callback = values.pop();
14880 if (typeof callback !== "function") throw new TypeError("Expected function as last argument, not " + callback);
14881 next(null, ...values);
14882 /**
14883 * Run the next `fn`, or we’re done.
14884 *
14885 * @param {Error | null | undefined} error
14886 * @param {Array<any>} output
14887 */
14888 function next(error, ...output) {
14889 const fn = fns[++middlewareIndex];
14890 let index = -1;
14891 if (error) {
14892 callback(error);
14893 return;
14894 }
14895 while (++index < values.length) if (output[index] === null || output[index] === void 0) output[index] = values[index];
14896 values = output;
14897 if (fn) wrap$1(fn, next)(...output);
14898 else callback(null, ...output);
14899 }
14900 }
14901 /** @type {Use} */
14902 function use(middelware) {
14903 if (typeof middelware !== "function") throw new TypeError("Expected `middelware` to be a function, not " + middelware);
14904 fns.push(middelware);
14905 return pipeline;
14906 }
14907 }
14908 /**
14909 * Wrap `middleware` into a uniform interface.
14910 *
14911 * You can pass all input to the resulting function.
14912 * `callback` is then called with the output of `middleware`.
14913 *
14914 * If `middleware` accepts more arguments than the later given in input,
14915 * an extra `done` function is passed to it after that input,
14916 * which must be called by `middleware`.
14917 *
14918 * The first value in `input` is the main input value.
14919 * All other input values are the rest input values.
14920 * The values given to `callback` are the input values,
14921 * merged with every non-nullish output value.
14922 *
14923 * * if `middleware` throws an error,
14924 * returns a promise that is rejected,
14925 * or calls the given `done` function with an error,
14926 * `callback` is called with that error
14927 * * if `middleware` returns a value or returns a promise that is resolved,
14928 * that value is the main output value
14929 * * if `middleware` calls `done`,
14930 * all non-nullish values except for the first one (the error) overwrite the
14931 * output values
14932 *
14933 * @param {Middleware} middleware
14934 * Function to wrap.
14935 * @param {Callback} callback
14936 * Callback called with the output of `middleware`.
14937 * @returns {Run}
14938 * Wrapped middleware.
14939 */
14940 function wrap$1(middleware, callback) {
14941 /** @type {boolean} */
14942 let called;
14943 return wrapped;
14944 /**
14945 * Call `middleware`.
14946 * @this {any}
14947 * @param {Array<any>} parameters
14948 * @returns {void}
14949 */
14950 function wrapped(...parameters) {
14951 const fnExpectsCallback = middleware.length > parameters.length;
14952 /** @type {any} */
14953 let result;
14954 if (fnExpectsCallback) parameters.push(done);
14955 try {
14956 result = middleware.apply(this, parameters);
14957 } catch (error) {
14958 const exception = error;
14959 if (fnExpectsCallback && called) throw exception;
14960 return done(exception);
14961 }
14962 if (!fnExpectsCallback) if (result && result.then && typeof result.then === "function") result.then(then, done);
14963 else if (result instanceof Error) done(result);
14964 else then(result);
14965 }
14966 /**
14967 * Call `callback`, only once.
14968 *
14969 * @type {Callback}
14970 */
14971 function done(error, ...output) {
14972 if (!called) {
14973 called = true;
14974 callback(error, ...output);
14975 }
14976 }
14977 /**
14978 * Call `done` with one value.
14979 *
14980 * @param {any} [value]
14981 */
14982 function then(value) {
14983 done(null, value);
14984 }
14985 }
14986 var init_lib$12 = __esmMin((() => {
14987 __name(wrap$1, "wrap");
14988 }));
14989
14990 //#endregion
14991 //#region node_modules/trough/index.js
14992 var init_trough = __esmMin((() => {
14993 init_lib$12();
14994 }));
14995
14996 //#endregion
14997 //#region node_modules/unified/lib/index.js
14998 /**
14999 * @returns {Processor}
15000 */
15001 function base() {
15002 const transformers = trough();
15003 /** @type {Processor['attachers']} */
15004 const attachers = [];
15005 /** @type {Record<string, unknown>} */
15006 let namespace = {};
15007 /** @type {boolean|undefined} */
15008 let frozen;
15009 let freezeIndex = -1;
15010 processor.data = data;
15011 processor.Parser = void 0;
15012 processor.Compiler = void 0;
15013 processor.freeze = freeze;
15014 processor.attachers = attachers;
15015 processor.use = use;
15016 processor.parse = parse;
15017 processor.stringify = stringify;
15018 processor.run = run;
15019 processor.runSync = runSync;
15020 processor.process = process;
15021 processor.processSync = processSync;
15022 return processor;
15023 /** @type {Processor} */
15024 function processor() {
15025 const destination = base();
15026 let index = -1;
15027 while (++index < attachers.length) destination.use(...attachers[index]);
15028 destination.data((0, import_extend.default)(true, {}, namespace));
15029 return destination;
15030 }
15031 /**
15032 * @param {string|Record<string, unknown>} [key]
15033 * @param {unknown} [value]
15034 * @returns {unknown}
15035 */
15036 function data(key, value) {
15037 if (typeof key === "string") {
15038 if (arguments.length === 2) {
15039 assertUnfrozen("data", frozen);
15040 namespace[key] = value;
15041 return processor;
15042 }
15043 return own$6.call(namespace, key) && namespace[key] || null;
15044 }
15045 if (key) {
15046 assertUnfrozen("data", frozen);
15047 namespace = key;
15048 return processor;
15049 }
15050 return namespace;
15051 }
15052 /** @type {Processor['freeze']} */
15053 function freeze() {
15054 if (frozen) return processor;
15055 while (++freezeIndex < attachers.length) {
15056 const [attacher, ...options] = attachers[freezeIndex];
15057 if (options[0] === false) continue;
15058 if (options[0] === true) options[0] = void 0;
15059 /** @type {Transformer|void} */
15060 const transformer = attacher.call(processor, ...options);
15061 if (typeof transformer === "function") transformers.use(transformer);
15062 }
15063 frozen = true;
15064 freezeIndex = Number.POSITIVE_INFINITY;
15065 return processor;
15066 }
15067 /**
15068 * @param {Pluggable|null|undefined} [value]
15069 * @param {...unknown} options
15070 * @returns {Processor}
15071 */
15072 function use(value, ...options) {
15073 /** @type {Record<string, unknown>|undefined} */
15074 let settings;
15075 assertUnfrozen("use", frozen);
15076 if (value === null || value === void 0) {} else if (typeof value === "function") addPlugin(value, ...options);
15077 else if (typeof value === "object") if (Array.isArray(value)) addList(value);
15078 else addPreset(value);
15079 else throw new TypeError("Expected usable value, not `" + value + "`");
15080 if (settings) namespace.settings = Object.assign(namespace.settings || {}, settings);
15081 return processor;
15082 /**
15083 * @param {import('..').Pluggable<unknown[]>} value
15084 * @returns {void}
15085 */
15086 function add(value) {
15087 if (typeof value === "function") addPlugin(value);
15088 else if (typeof value === "object") if (Array.isArray(value)) {
15089 const [plugin, ...options] = value;
15090 addPlugin(plugin, ...options);
15091 } else addPreset(value);
15092 else throw new TypeError("Expected usable value, not `" + value + "`");
15093 }
15094 /**
15095 * @param {Preset} result
15096 * @returns {void}
15097 */
15098 function addPreset(result) {
15099 addList(result.plugins);
15100 if (result.settings) settings = Object.assign(settings || {}, result.settings);
15101 }
15102 /**
15103 * @param {PluggableList|null|undefined} [plugins]
15104 * @returns {void}
15105 */
15106 function addList(plugins) {
15107 let index = -1;
15108 if (plugins === null || plugins === void 0) {} else if (Array.isArray(plugins)) while (++index < plugins.length) {
15109 const thing = plugins[index];
15110 add(thing);
15111 }
15112 else throw new TypeError("Expected a list of plugins, not `" + plugins + "`");
15113 }
15114 /**
15115 * @param {Plugin} plugin
15116 * @param {...unknown} [value]
15117 * @returns {void}
15118 */
15119 function addPlugin(plugin, value) {
15120 let index = -1;
15121 /** @type {Processor['attachers'][number]|undefined} */
15122 let entry;
15123 while (++index < attachers.length) if (attachers[index][0] === plugin) {
15124 entry = attachers[index];
15125 break;
15126 }
15127 if (entry) {
15128 if (isPlainObject(entry[1]) && isPlainObject(value)) value = (0, import_extend.default)(true, entry[1], value);
15129 entry[1] = value;
15130 } else attachers.push([...arguments]);
15131 }
15132 }
15133 /** @type {Processor['parse']} */
15134 function parse(doc) {
15135 processor.freeze();
15136 const file = vfile(doc);
15137 const Parser = processor.Parser;
15138 assertParser("parse", Parser);
15139 if (newable(Parser, "parse")) return new Parser(String(file), file).parse();
15140 return Parser(String(file), file);
15141 }
15142 /** @type {Processor['stringify']} */
15143 function stringify(node, doc) {
15144 processor.freeze();
15145 const file = vfile(doc);
15146 const Compiler = processor.Compiler;
15147 assertCompiler("stringify", Compiler);
15148 assertNode(node);
15149 if (newable(Compiler, "compile")) return new Compiler(node, file).compile();
15150 return Compiler(node, file);
15151 }
15152 /**
15153 * @param {Node} node
15154 * @param {VFileCompatible|RunCallback} [doc]
15155 * @param {RunCallback} [callback]
15156 * @returns {Promise<Node>|void}
15157 */
15158 function run(node, doc, callback) {
15159 assertNode(node);
15160 processor.freeze();
15161 if (!callback && typeof doc === "function") {
15162 callback = doc;
15163 doc = void 0;
15164 }
15165 if (!callback) return new Promise(executor);
15166 executor(null, callback);
15167 /**
15168 * @param {null|((node: Node) => void)} resolve
15169 * @param {(error: Error) => void} reject
15170 * @returns {void}
15171 */
15172 function executor(resolve, reject) {
15173 transformers.run(node, vfile(doc), done);
15174 /**
15175 * @param {Error|null} error
15176 * @param {Node} tree
15177 * @param {VFile} file
15178 * @returns {void}
15179 */
15180 function done(error, tree, file) {
15181 tree = tree || node;
15182 if (error) reject(error);
15183 else if (resolve) resolve(tree);
15184 else callback(null, tree, file);
15185 }
15186 }
15187 }
15188 /** @type {Processor['runSync']} */
15189 function runSync(node, file) {
15190 /** @type {Node|undefined} */
15191 let result;
15192 /** @type {boolean|undefined} */
15193 let complete;
15194 processor.run(node, file, done);
15195 assertDone("runSync", "run", complete);
15196 return result;
15197 /**
15198 * @param {Error|null} [error]
15199 * @param {Node} [tree]
15200 * @returns {void}
15201 */
15202 function done(error, tree) {
15203 bail(error);
15204 result = tree;
15205 complete = true;
15206 }
15207 }
15208 /**
15209 * @param {VFileCompatible} doc
15210 * @param {ProcessCallback} [callback]
15211 * @returns {Promise<VFile>|undefined}
15212 */
15213 function process(doc, callback) {
15214 processor.freeze();
15215 assertParser("process", processor.Parser);
15216 assertCompiler("process", processor.Compiler);
15217 if (!callback) return new Promise(executor);
15218 executor(null, callback);
15219 /**
15220 * @param {null|((file: VFile) => void)} resolve
15221 * @param {(error?: Error|null|undefined) => void} reject
15222 * @returns {void}
15223 */
15224 function executor(resolve, reject) {
15225 const file = vfile(doc);
15226 processor.run(processor.parse(file), file, (error, tree, file) => {
15227 if (error || !tree || !file) done(error);
15228 else {
15229 /** @type {unknown} */
15230 const result = processor.stringify(tree, file);
15231 if (result === void 0 || result === null) {} else if (looksLikeAVFileValue(result)) file.value = result;
15232 else file.result = result;
15233 done(error, file);
15234 }
15235 });
15236 /**
15237 * @param {Error|null|undefined} [error]
15238 * @param {VFile|undefined} [file]
15239 * @returns {void}
15240 */
15241 function done(error, file) {
15242 if (error || !file) reject(error);
15243 else if (resolve) resolve(file);
15244 else callback(null, file);
15245 }
15246 }
15247 }
15248 /** @type {Processor['processSync']} */
15249 function processSync(doc) {
15250 /** @type {boolean|undefined} */
15251 let complete;
15252 processor.freeze();
15253 assertParser("processSync", processor.Parser);
15254 assertCompiler("processSync", processor.Compiler);
15255 const file = vfile(doc);
15256 processor.process(file, done);
15257 assertDone("processSync", "process", complete);
15258 return file;
15259 /**
15260 * @param {Error|null|undefined} [error]
15261 * @returns {void}
15262 */
15263 function done(error) {
15264 complete = true;
15265 bail(error);
15266 }
15267 }
15268 }
15269 /**
15270 * Check if `value` is a constructor.
15271 *
15272 * @param {unknown} value
15273 * @param {string} name
15274 * @returns {boolean}
15275 */
15276 function newable(value, name) {
15277 return typeof value === "function" && value.prototype && (keys(value.prototype) || name in value.prototype);
15278 }
15279 /**
15280 * Check if `value` is an object with keys.
15281 *
15282 * @param {Record<string, unknown>} value
15283 * @returns {boolean}
15284 */
15285 function keys(value) {
15286 /** @type {string} */
15287 let key;
15288 for (key in value) if (own$6.call(value, key)) return true;
15289 return false;
15290 }
15291 /**
15292 * Assert a parser is available.
15293 *
15294 * @param {string} name
15295 * @param {unknown} value
15296 * @returns {asserts value is Parser}
15297 */
15298 function assertParser(name, value) {
15299 if (typeof value !== "function") throw new TypeError("Cannot `" + name + "` without `Parser`");
15300 }
15301 /**
15302 * Assert a compiler is available.
15303 *
15304 * @param {string} name
15305 * @param {unknown} value
15306 * @returns {asserts value is Compiler}
15307 */
15308 function assertCompiler(name, value) {
15309 if (typeof value !== "function") throw new TypeError("Cannot `" + name + "` without `Compiler`");
15310 }
15311 /**
15312 * Assert the processor is not frozen.
15313 *
15314 * @param {string} name
15315 * @param {unknown} frozen
15316 * @returns {asserts frozen is false}
15317 */
15318 function assertUnfrozen(name, frozen) {
15319 if (frozen) throw new Error("Cannot call `" + name + "` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.");
15320 }
15321 /**
15322 * Assert `node` is a unist node.
15323 *
15324 * @param {unknown} node
15325 * @returns {asserts node is Node}
15326 */
15327 function assertNode(node) {
15328 if (!isPlainObject(node) || typeof node.type !== "string") throw new TypeError("Expected node, got `" + node + "`");
15329 }
15330 /**
15331 * Assert that `complete` is `true`.
15332 *
15333 * @param {string} name
15334 * @param {string} asyncName
15335 * @param {unknown} complete
15336 * @returns {asserts complete is true}
15337 */
15338 function assertDone(name, asyncName, complete) {
15339 if (!complete) throw new Error("`" + name + "` finished async. Use `" + asyncName + "` instead");
15340 }
15341 /**
15342 * @param {VFileCompatible} [value]
15343 * @returns {VFile}
15344 */
15345 function vfile(value) {
15346 return looksLikeAVFile(value) ? value : new VFile(value);
15347 }
15348 /**
15349 * @param {VFileCompatible} [value]
15350 * @returns {value is VFile}
15351 */
15352 function looksLikeAVFile(value) {
15353 return Boolean(value && typeof value === "object" && "message" in value && "messages" in value);
15354 }
15355 /**
15356 * @param {unknown} [value]
15357 * @returns {value is VFileValue}
15358 */
15359 function looksLikeAVFileValue(value) {
15360 return typeof value === "string" || (0, import_is_buffer.default)(value);
15361 }
15362 var import_is_buffer, import_extend, unified, own$6;
15363 var init_lib$11 = __esmMin((() => {
15364 init_bail();
15365 import_is_buffer = /* @__PURE__ */ __toESM(require_is_buffer(), 1);
15366 import_extend = /* @__PURE__ */ __toESM(require_extend(), 1);
15367 init_is_plain_obj();
15368 init_trough();
15369 init_vfile();
15370 unified = base().freeze();
15371 own$6 = {}.hasOwnProperty;
15372 }));
15373
15374 //#endregion
15375 //#region node_modules/unified/index.js
15376 var init_unified = __esmMin((() => {
15377 init_lib$11();
15378 }));
15379
15380 //#endregion
15381 //#region node_modules/mdast-util-to-string/lib/index.js
15382 /**
15383 * Get the text content of a node or list of nodes.
15384 *
15385 * Prefers the node’s plain-text fields, otherwise serializes its children,
15386 * and if the given value is an array, serialize the nodes in it.
15387 *
15388 * @param {unknown} value
15389 * Thing to serialize, typically `Node`.
15390 * @param {Options | null | undefined} [options]
15391 * Configuration (optional).
15392 * @returns {string}
15393 * Serialized `value`.
15394 */
15395 function toString(value, options) {
15396 const settings = options || emptyOptions;
15397 return one$1(value, typeof settings.includeImageAlt === "boolean" ? settings.includeImageAlt : true, typeof settings.includeHtml === "boolean" ? settings.includeHtml : true);
15398 }
15399 /**
15400 * One node or several nodes.
15401 *
15402 * @param {unknown} value
15403 * Thing to serialize.
15404 * @param {boolean} includeImageAlt
15405 * Include image `alt`s.
15406 * @param {boolean} includeHtml
15407 * Include HTML.
15408 * @returns {string}
15409 * Serialized node.
15410 */
15411 function one$1(value, includeImageAlt, includeHtml) {
15412 if (node(value)) {
15413 if ("value" in value) return value.type === "html" && !includeHtml ? "" : value.value;
15414 if (includeImageAlt && "alt" in value && value.alt) return value.alt;
15415 if ("children" in value) return all$1(value.children, includeImageAlt, includeHtml);
15416 }
15417 if (Array.isArray(value)) return all$1(value, includeImageAlt, includeHtml);
15418 return "";
15419 }
15420 /**
15421 * Serialize a list of nodes.
15422 *
15423 * @param {Array<unknown>} values
15424 * Thing to serialize.
15425 * @param {boolean} includeImageAlt
15426 * Include image `alt`s.
15427 * @param {boolean} includeHtml
15428 * Include HTML.
15429 * @returns {string}
15430 * Serialized nodes.
15431 */
15432 function all$1(values, includeImageAlt, includeHtml) {
15433 /** @type {Array<string>} */
15434 const result = [];
15435 let index = -1;
15436 while (++index < values.length) result[index] = one$1(values[index], includeImageAlt, includeHtml);
15437 return result.join("");
15438 }
15439 /**
15440 * Check if `value` looks like a node.
15441 *
15442 * @param {unknown} value
15443 * Thing.
15444 * @returns {value is Node}
15445 * Whether `value` is a node.
15446 */
15447 function node(value) {
15448 return Boolean(value && typeof value === "object");
15449 }
15450 var emptyOptions;
15451 var init_lib$10 = __esmMin((() => {
15452 emptyOptions = {};
15453 __name(one$1, "one");
15454 __name(all$1, "all");
15455 }));
15456
15457 //#endregion
15458 //#region node_modules/mdast-util-to-string/index.js
15459 var init_mdast_util_to_string = __esmMin((() => {
15460 init_lib$10();
15461 }));
15462
15463 //#endregion
15464 //#region node_modules/micromark-util-chunked/index.js
15465 /**
15466 * Like `Array#splice`, but smarter for giant arrays.
15467 *
15468 * `Array#splice` takes all items to be inserted as individual argument which
15469 * causes a stack overflow in V8 when trying to insert 100k items for instance.
15470 *
15471 * Otherwise, this does not return the removed items, and takes `items` as an
15472 * array instead of rest parameters.
15473 *
15474 * @template {unknown} T
15475 * Item type.
15476 * @param {Array<T>} list
15477 * List to operate on.
15478 * @param {number} start
15479 * Index to remove/insert at (can be negative).
15480 * @param {number} remove
15481 * Number of items to remove.
15482 * @param {Array<T>} items
15483 * Items to inject into `list`.
15484 * @returns {void}
15485 * Nothing.
15486 */
15487 function splice(list, start, remove, items) {
15488 const end = list.length;
15489 let chunkStart = 0;
15490 /** @type {Array<unknown>} */
15491 let parameters;
15492 if (start < 0) start = -start > end ? 0 : end + start;
15493 else start = start > end ? end : start;
15494 remove = remove > 0 ? remove : 0;
15495 if (items.length < 1e4) {
15496 parameters = Array.from(items);
15497 parameters.unshift(start, remove);
15498 list.splice(...parameters);
15499 } else {
15500 if (remove) list.splice(start, remove);
15501 while (chunkStart < items.length) {
15502 parameters = items.slice(chunkStart, chunkStart + 1e4);
15503 parameters.unshift(start, 0);
15504 list.splice(...parameters);
15505 chunkStart += 1e4;
15506 start += 1e4;
15507 }
15508 }
15509 }
15510 /**
15511 * Append `items` (an array) at the end of `list` (another array).
15512 * When `list` was empty, returns `items` instead.
15513 *
15514 * This prevents a potentially expensive operation when `list` is empty,
15515 * and adds items in batches to prevent V8 from hanging.
15516 *
15517 * @template {unknown} T
15518 * Item type.
15519 * @param {Array<T>} list
15520 * List to operate on.
15521 * @param {Array<T>} items
15522 * Items to add to `list`.
15523 * @returns {Array<T>}
15524 * Either `list` or `items`.
15525 */
15526 function push(list, items) {
15527 if (list.length > 0) {
15528 splice(list, list.length, 0, items);
15529 return list;
15530 }
15531 return items;
15532 }
15533 var init_micromark_util_chunked = __esmMin((() => {}));
15534
15535 //#endregion
15536 //#region node_modules/micromark-util-combine-extensions/index.js
15537 /**
15538 * Combine multiple syntax extensions into one.
15539 *
15540 * @param {Array<Extension>} extensions
15541 * List of syntax extensions.
15542 * @returns {NormalizedExtension}
15543 * A single combined extension.
15544 */
15545 function combineExtensions(extensions) {
15546 /** @type {NormalizedExtension} */
15547 const all = {};
15548 let index = -1;
15549 while (++index < extensions.length) syntaxExtension(all, extensions[index]);
15550 return all;
15551 }
15552 /**
15553 * Merge `extension` into `all`.
15554 *
15555 * @param {NormalizedExtension} all
15556 * Extension to merge into.
15557 * @param {Extension} extension
15558 * Extension to merge.
15559 * @returns {void}
15560 */
15561 function syntaxExtension(all, extension) {
15562 /** @type {keyof Extension} */
15563 let hook;
15564 for (hook in extension) {
15565 /** @type {Record<string, unknown>} */
15566 const left = (hasOwnProperty.call(all, hook) ? all[hook] : void 0) || (all[hook] = {});
15567 /** @type {Record<string, unknown> | undefined} */
15568 const right = extension[hook];
15569 /** @type {string} */
15570 let code;
15571 if (right) for (code in right) {
15572 if (!hasOwnProperty.call(left, code)) left[code] = [];
15573 const value = right[code];
15574 constructs(left[code], Array.isArray(value) ? value : value ? [value] : []);
15575 }
15576 }
15577 }
15578 /**
15579 * Merge `list` into `existing` (both lists of constructs).
15580 * Mutates `existing`.
15581 *
15582 * @param {Array<unknown>} existing
15583 * @param {Array<unknown>} list
15584 * @returns {void}
15585 */
15586 function constructs(existing, list) {
15587 let index = -1;
15588 /** @type {Array<unknown>} */
15589 const before = [];
15590 while (++index < list.length) (list[index].add === "after" ? existing : before).push(list[index]);
15591 splice(existing, 0, 0, before);
15592 }
15593 var hasOwnProperty;
15594 var init_micromark_util_combine_extensions = __esmMin((() => {
15595 init_micromark_util_chunked();
15596 hasOwnProperty = {}.hasOwnProperty;
15597 }));
15598
15599 //#endregion
15600 //#region node_modules/micromark-util-character/lib/unicode-punctuation-regex.js
15601 var unicodePunctuationRegex;
15602 var init_unicode_punctuation_regex = __esmMin((() => {
15603 unicodePunctuationRegex = /[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/;
15604 }));
15605
15606 //#endregion
15607 //#region node_modules/micromark-util-character/index.js
15608 /**
15609 * Check whether a character code is an ASCII control character.
15610 *
15611 * An **ASCII control** is a character in the inclusive range U+0000 NULL (NUL)
15612 * to U+001F (US), or U+007F (DEL).
15613 *
15614 * @param {Code} code
15615 * Code.
15616 * @returns {boolean}
15617 * Whether it matches.
15618 */
15619 function asciiControl(code) {
15620 return code !== null && (code < 32 || code === 127);
15621 }
15622 /**
15623 * Check whether a character code is a markdown line ending.
15624 *
15625 * A **markdown line ending** is the virtual characters M-0003 CARRIAGE RETURN
15626 * LINE FEED (CRLF), M-0004 LINE FEED (LF) and M-0005 CARRIAGE RETURN (CR).
15627 *
15628 * In micromark, the actual character U+000A LINE FEED (LF) and U+000D CARRIAGE
15629 * RETURN (CR) are replaced by these virtual characters depending on whether
15630 * they occurred together.
15631 *
15632 * @param {Code} code
15633 * Code.
15634 * @returns {boolean}
15635 * Whether it matches.
15636 */
15637 function markdownLineEnding(code) {
15638 return code !== null && code < -2;
15639 }
15640 /**
15641 * Check whether a character code is a markdown line ending (see
15642 * `markdownLineEnding`) or markdown space (see `markdownSpace`).
15643 *
15644 * @param {Code} code
15645 * Code.
15646 * @returns {boolean}
15647 * Whether it matches.
15648 */
15649 function markdownLineEndingOrSpace(code) {
15650 return code !== null && (code < 0 || code === 32);
15651 }
15652 /**
15653 * Check whether a character code is a markdown space.
15654 *
15655 * A **markdown space** is the concrete character U+0020 SPACE (SP) and the
15656 * virtual characters M-0001 VIRTUAL SPACE (VS) and M-0002 HORIZONTAL TAB (HT).
15657 *
15658 * In micromark, the actual character U+0009 CHARACTER TABULATION (HT) is
15659 * replaced by one M-0002 HORIZONTAL TAB (HT) and between 0 and 3 M-0001 VIRTUAL
15660 * SPACE (VS) characters, depending on the column at which the tab occurred.
15661 *
15662 * @param {Code} code
15663 * Code.
15664 * @returns {boolean}
15665 * Whether it matches.
15666 */
15667 function markdownSpace(code) {
15668 return code === -2 || code === -1 || code === 32;
15669 }
15670 /**
15671 * Create a code check from a regex.
15672 *
15673 * @param {RegExp} regex
15674 * @returns {(code: Code) => boolean}
15675 */
15676 function regexCheck(regex) {
15677 return check;
15678 /**
15679 * Check whether a code matches the bound regex.
15680 *
15681 * @param {Code} code
15682 * Character code.
15683 * @returns {boolean}
15684 * Whether the character code matches the bound regex.
15685 */
15686 function check(code) {
15687 return code !== null && regex.test(String.fromCharCode(code));
15688 }
15689 }
15690 var asciiAlpha, asciiAlphanumeric, asciiAtext, asciiDigit, asciiHexDigit, asciiPunctuation, unicodePunctuation, unicodeWhitespace;
15691 var init_micromark_util_character = __esmMin((() => {
15692 init_unicode_punctuation_regex();
15693 asciiAlpha = regexCheck(/[A-Za-z]/);
15694 asciiAlphanumeric = regexCheck(/[\dA-Za-z]/);
15695 asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/);
15696 asciiDigit = regexCheck(/\d/);
15697 asciiHexDigit = regexCheck(/[\dA-Fa-f]/);
15698 asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/);
15699 unicodePunctuation = regexCheck(unicodePunctuationRegex);
15700 unicodeWhitespace = regexCheck(/\s/);
15701 }));
15702
15703 //#endregion
15704 //#region node_modules/micromark-factory-space/index.js
15705 /**
15706 * Parse spaces and tabs.
15707 *
15708 * There is no `nok` parameter:
15709 *
15710 * * spaces in markdown are often optional, in which case this factory can be
15711 * used and `ok` will be switched to whether spaces were found or not
15712 * * one line ending or space can be detected with `markdownSpace(code)` right
15713 * before using `factorySpace`
15714 *
15715 * ###### Examples
15716 *
15717 * Where `␉` represents a tab (plus how much it expands) and `␠` represents a
15718 * single space.
15719 *
15720 * ```markdown
15721 * ␉
15722 * ␠␠␠␠
15723 * ␉␠
15724 * ```
15725 *
15726 * @param {Effects} effects
15727 * Context.
15728 * @param {State} ok
15729 * State switched to when successful.
15730 * @param {TokenType} type
15731 * Type (`' \t'`).
15732 * @param {number | undefined} [max=Infinity]
15733 * Max (exclusive).
15734 * @returns
15735 * Start state.
15736 */
15737 function factorySpace(effects, ok, type, max) {
15738 const limit = max ? max - 1 : Number.POSITIVE_INFINITY;
15739 let size = 0;
15740 return start;
15741 /** @type {State} */
15742 function start(code) {
15743 if (markdownSpace(code)) {
15744 effects.enter(type);
15745 return prefix(code);
15746 }
15747 return ok(code);
15748 }
15749 /** @type {State} */
15750 function prefix(code) {
15751 if (markdownSpace(code) && size++ < limit) {
15752 effects.consume(code);
15753 return prefix;
15754 }
15755 effects.exit(type);
15756 return ok(code);
15757 }
15758 }
15759 var init_micromark_factory_space = __esmMin((() => {
15760 init_micromark_util_character();
15761 }));
15762
15763 //#endregion
15764 //#region node_modules/micromark/lib/initialize/content.js
15765 /**
15766 * @this {TokenizeContext}
15767 * @type {Initializer}
15768 */
15769 function initializeContent(effects) {
15770 const contentStart = effects.attempt(this.parser.constructs.contentInitial, afterContentStartConstruct, paragraphInitial);
15771 /** @type {Token} */
15772 let previous;
15773 return contentStart;
15774 /** @type {State} */
15775 function afterContentStartConstruct(code) {
15776 if (code === null) {
15777 effects.consume(code);
15778 return;
15779 }
15780 effects.enter("lineEnding");
15781 effects.consume(code);
15782 effects.exit("lineEnding");
15783 return factorySpace(effects, contentStart, "linePrefix");
15784 }
15785 /** @type {State} */
15786 function paragraphInitial(code) {
15787 effects.enter("paragraph");
15788 return lineStart(code);
15789 }
15790 /** @type {State} */
15791 function lineStart(code) {
15792 const token = effects.enter("chunkText", {
15793 contentType: "text",
15794 previous
15795 });
15796 if (previous) previous.next = token;
15797 previous = token;
15798 return data(code);
15799 }
15800 /** @type {State} */
15801 function data(code) {
15802 if (code === null) {
15803 effects.exit("chunkText");
15804 effects.exit("paragraph");
15805 effects.consume(code);
15806 return;
15807 }
15808 if (markdownLineEnding(code)) {
15809 effects.consume(code);
15810 effects.exit("chunkText");
15811 return lineStart;
15812 }
15813 effects.consume(code);
15814 return data;
15815 }
15816 }
15817 var content$1;
15818 var init_content$1 = __esmMin((() => {
15819 init_micromark_factory_space();
15820 init_micromark_util_character();
15821 content$1 = { tokenize: initializeContent };
15822 }));
15823
15824 //#endregion
15825 //#region node_modules/micromark/lib/initialize/document.js
15826 /**
15827 * @this {TokenizeContext}
15828 * @type {Initializer}
15829 */
15830 function initializeDocument(effects) {
15831 const self = this;
15832 /** @type {Array<StackItem>} */
15833 const stack = [];
15834 let continued = 0;
15835 /** @type {TokenizeContext | undefined} */
15836 let childFlow;
15837 /** @type {Token | undefined} */
15838 let childToken;
15839 /** @type {number} */
15840 let lineStartOffset;
15841 return start;
15842 /** @type {State} */
15843 function start(code) {
15844 if (continued < stack.length) {
15845 const item = stack[continued];
15846 self.containerState = item[1];
15847 return effects.attempt(item[0].continuation, documentContinue, checkNewContainers)(code);
15848 }
15849 return checkNewContainers(code);
15850 }
15851 /** @type {State} */
15852 function documentContinue(code) {
15853 continued++;
15854 if (self.containerState._closeFlow) {
15855 self.containerState._closeFlow = void 0;
15856 if (childFlow) closeFlow();
15857 const indexBeforeExits = self.events.length;
15858 let indexBeforeFlow = indexBeforeExits;
15859 /** @type {Point | undefined} */
15860 let point;
15861 while (indexBeforeFlow--) if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === "chunkFlow") {
15862 point = self.events[indexBeforeFlow][1].end;
15863 break;
15864 }
15865 exitContainers(continued);
15866 let index = indexBeforeExits;
15867 while (index < self.events.length) {
15868 self.events[index][1].end = Object.assign({}, point);
15869 index++;
15870 }
15871 splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
15872 self.events.length = index;
15873 return checkNewContainers(code);
15874 }
15875 return start(code);
15876 }
15877 /** @type {State} */
15878 function checkNewContainers(code) {
15879 if (continued === stack.length) {
15880 if (!childFlow) return documentContinued(code);
15881 if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) return flowStart(code);
15882 self.interrupt = Boolean(childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack);
15883 }
15884 self.containerState = {};
15885 return effects.check(containerConstruct, thereIsANewContainer, thereIsNoNewContainer)(code);
15886 }
15887 /** @type {State} */
15888 function thereIsANewContainer(code) {
15889 if (childFlow) closeFlow();
15890 exitContainers(continued);
15891 return documentContinued(code);
15892 }
15893 /** @type {State} */
15894 function thereIsNoNewContainer(code) {
15895 self.parser.lazy[self.now().line] = continued !== stack.length;
15896 lineStartOffset = self.now().offset;
15897 return flowStart(code);
15898 }
15899 /** @type {State} */
15900 function documentContinued(code) {
15901 self.containerState = {};
15902 return effects.attempt(containerConstruct, containerContinue, flowStart)(code);
15903 }
15904 /** @type {State} */
15905 function containerContinue(code) {
15906 continued++;
15907 stack.push([self.currentConstruct, self.containerState]);
15908 return documentContinued(code);
15909 }
15910 /** @type {State} */
15911 function flowStart(code) {
15912 if (code === null) {
15913 if (childFlow) closeFlow();
15914 exitContainers(0);
15915 effects.consume(code);
15916 return;
15917 }
15918 childFlow = childFlow || self.parser.flow(self.now());
15919 effects.enter("chunkFlow", {
15920 contentType: "flow",
15921 previous: childToken,
15922 _tokenizer: childFlow
15923 });
15924 return flowContinue(code);
15925 }
15926 /** @type {State} */
15927 function flowContinue(code) {
15928 if (code === null) {
15929 writeToChild(effects.exit("chunkFlow"), true);
15930 exitContainers(0);
15931 effects.consume(code);
15932 return;
15933 }
15934 if (markdownLineEnding(code)) {
15935 effects.consume(code);
15936 writeToChild(effects.exit("chunkFlow"));
15937 continued = 0;
15938 self.interrupt = void 0;
15939 return start;
15940 }
15941 effects.consume(code);
15942 return flowContinue;
15943 }
15944 /**
15945 * @param {Token} token
15946 * @param {boolean | undefined} [eof]
15947 * @returns {void}
15948 */
15949 function writeToChild(token, eof) {
15950 const stream = self.sliceStream(token);
15951 if (eof) stream.push(null);
15952 token.previous = childToken;
15953 if (childToken) childToken.next = token;
15954 childToken = token;
15955 childFlow.defineSkip(token.start);
15956 childFlow.write(stream);
15957 if (self.parser.lazy[token.start.line]) {
15958 let index = childFlow.events.length;
15959 while (index--) if (childFlow.events[index][1].start.offset < lineStartOffset && (!childFlow.events[index][1].end || childFlow.events[index][1].end.offset > lineStartOffset)) return;
15960 const indexBeforeExits = self.events.length;
15961 let indexBeforeFlow = indexBeforeExits;
15962 /** @type {boolean | undefined} */
15963 let seen;
15964 /** @type {Point | undefined} */
15965 let point;
15966 while (indexBeforeFlow--) if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === "chunkFlow") {
15967 if (seen) {
15968 point = self.events[indexBeforeFlow][1].end;
15969 break;
15970 }
15971 seen = true;
15972 }
15973 exitContainers(continued);
15974 index = indexBeforeExits;
15975 while (index < self.events.length) {
15976 self.events[index][1].end = Object.assign({}, point);
15977 index++;
15978 }
15979 splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
15980 self.events.length = index;
15981 }
15982 }
15983 /**
15984 * @param {number} size
15985 * @returns {void}
15986 */
15987 function exitContainers(size) {
15988 let index = stack.length;
15989 while (index-- > size) {
15990 const entry = stack[index];
15991 self.containerState = entry[1];
15992 entry[0].exit.call(self, effects);
15993 }
15994 stack.length = size;
15995 }
15996 function closeFlow() {
15997 childFlow.write([null]);
15998 childToken = void 0;
15999 childFlow = void 0;
16000 self.containerState._closeFlow = void 0;
16001 }
16002 }
16003 /**
16004 * @this {TokenizeContext}
16005 * @type {Tokenizer}
16006 */
16007 function tokenizeContainer(effects, ok, nok) {
16008 return factorySpace(effects, effects.attempt(this.parser.constructs.document, ok, nok), "linePrefix", this.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4);
16009 }
16010 var document$2, containerConstruct;
16011 var init_document = __esmMin((() => {
16012 init_micromark_factory_space();
16013 init_micromark_util_character();
16014 init_micromark_util_chunked();
16015 document$2 = { tokenize: initializeDocument };
16016 containerConstruct = { tokenize: tokenizeContainer };
16017 }));
16018
16019 //#endregion
16020 //#region node_modules/micromark-util-classify-character/index.js
16021 /**
16022 * Classify whether a code represents whitespace, punctuation, or something
16023 * else.
16024 *
16025 * Used for attention (emphasis, strong), whose sequences can open or close
16026 * based on the class of surrounding characters.
16027 *
16028 * > 👉 **Note**: eof (`null`) is seen as whitespace.
16029 *
16030 * @param {Code} code
16031 * Code.
16032 * @returns {typeof constants.characterGroupWhitespace | typeof constants.characterGroupPunctuation | undefined}
16033 * Group.
16034 */
16035 function classifyCharacter(code) {
16036 if (code === null || markdownLineEndingOrSpace(code) || unicodeWhitespace(code)) return 1;
16037 if (unicodePunctuation(code)) return 2;
16038 }
16039 var init_micromark_util_classify_character = __esmMin((() => {
16040 init_micromark_util_character();
16041 }));
16042
16043 //#endregion
16044 //#region node_modules/micromark-util-resolve-all/index.js
16045 /**
16046 * @typedef {import('micromark-util-types').Event} Event
16047 * @typedef {import('micromark-util-types').Resolver} Resolver
16048 * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
16049 */
16050 /**
16051 * Call all `resolveAll`s.
16052 *
16053 * @param {Array<{resolveAll?: Resolver | undefined}>} constructs
16054 * List of constructs, optionally with `resolveAll`s.
16055 * @param {Array<Event>} events
16056 * List of events.
16057 * @param {TokenizeContext} context
16058 * Context used by `tokenize`.
16059 * @returns {Array<Event>}
16060 * Changed events.
16061 */
16062 function resolveAll(constructs, events, context) {
16063 /** @type {Array<Resolver>} */
16064 const called = [];
16065 let index = -1;
16066 while (++index < constructs.length) {
16067 const resolve = constructs[index].resolveAll;
16068 if (resolve && !called.includes(resolve)) {
16069 events = resolve(events, context);
16070 called.push(resolve);
16071 }
16072 }
16073 return events;
16074 }
16075 var init_micromark_util_resolve_all = __esmMin((() => {}));
16076
16077 //#endregion
16078 //#region node_modules/micromark-core-commonmark/lib/attention.js
16079 /**
16080 * Take all events and resolve attention to emphasis or strong.
16081 *
16082 * @type {Resolver}
16083 */
16084 function resolveAllAttention(events, context) {
16085 let index = -1;
16086 /** @type {number} */
16087 let open;
16088 /** @type {Token} */
16089 let group;
16090 /** @type {Token} */
16091 let text;
16092 /** @type {Token} */
16093 let openingSequence;
16094 /** @type {Token} */
16095 let closingSequence;
16096 /** @type {number} */
16097 let use;
16098 /** @type {Array<Event>} */
16099 let nextEvents;
16100 /** @type {number} */
16101 let offset;
16102 while (++index < events.length) if (events[index][0] === "enter" && events[index][1].type === "attentionSequence" && events[index][1]._close) {
16103 open = index;
16104 while (open--) if (events[open][0] === "exit" && events[open][1].type === "attentionSequence" && events[open][1]._open && context.sliceSerialize(events[open][1]).charCodeAt(0) === context.sliceSerialize(events[index][1]).charCodeAt(0)) {
16105 if ((events[open][1]._close || events[index][1]._open) && (events[index][1].end.offset - events[index][1].start.offset) % 3 && !((events[open][1].end.offset - events[open][1].start.offset + events[index][1].end.offset - events[index][1].start.offset) % 3)) continue;
16106 use = events[open][1].end.offset - events[open][1].start.offset > 1 && events[index][1].end.offset - events[index][1].start.offset > 1 ? 2 : 1;
16107 const start = Object.assign({}, events[open][1].end);
16108 const end = Object.assign({}, events[index][1].start);
16109 movePoint(start, -use);
16110 movePoint(end, use);
16111 openingSequence = {
16112 type: use > 1 ? "strongSequence" : "emphasisSequence",
16113 start,
16114 end: Object.assign({}, events[open][1].end)
16115 };
16116 closingSequence = {
16117 type: use > 1 ? "strongSequence" : "emphasisSequence",
16118 start: Object.assign({}, events[index][1].start),
16119 end
16120 };
16121 text = {
16122 type: use > 1 ? "strongText" : "emphasisText",
16123 start: Object.assign({}, events[open][1].end),
16124 end: Object.assign({}, events[index][1].start)
16125 };
16126 group = {
16127 type: use > 1 ? "strong" : "emphasis",
16128 start: Object.assign({}, openingSequence.start),
16129 end: Object.assign({}, closingSequence.end)
16130 };
16131 events[open][1].end = Object.assign({}, openingSequence.start);
16132 events[index][1].start = Object.assign({}, closingSequence.end);
16133 nextEvents = [];
16134 if (events[open][1].end.offset - events[open][1].start.offset) nextEvents = push(nextEvents, [[
16135 "enter",
16136 events[open][1],
16137 context
16138 ], [
16139 "exit",
16140 events[open][1],
16141 context
16142 ]]);
16143 nextEvents = push(nextEvents, [
16144 [
16145 "enter",
16146 group,
16147 context
16148 ],
16149 [
16150 "enter",
16151 openingSequence,
16152 context
16153 ],
16154 [
16155 "exit",
16156 openingSequence,
16157 context
16158 ],
16159 [
16160 "enter",
16161 text,
16162 context
16163 ]
16164 ]);
16165 nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + 1, index), context));
16166 nextEvents = push(nextEvents, [
16167 [
16168 "exit",
16169 text,
16170 context
16171 ],
16172 [
16173 "enter",
16174 closingSequence,
16175 context
16176 ],
16177 [
16178 "exit",
16179 closingSequence,
16180 context
16181 ],
16182 [
16183 "exit",
16184 group,
16185 context
16186 ]
16187 ]);
16188 if (events[index][1].end.offset - events[index][1].start.offset) {
16189 offset = 2;
16190 nextEvents = push(nextEvents, [[
16191 "enter",
16192 events[index][1],
16193 context
16194 ], [
16195 "exit",
16196 events[index][1],
16197 context
16198 ]]);
16199 } else offset = 0;
16200 splice(events, open - 1, index - open + 3, nextEvents);
16201 index = open + nextEvents.length - offset - 2;
16202 break;
16203 }
16204 }
16205 index = -1;
16206 while (++index < events.length) if (events[index][1].type === "attentionSequence") events[index][1].type = "data";
16207 return events;
16208 }
16209 /**
16210 * @this {TokenizeContext}
16211 * @type {Tokenizer}
16212 */
16213 function tokenizeAttention(effects, ok) {
16214 const attentionMarkers = this.parser.constructs.attentionMarkers.null;
16215 const previous = this.previous;
16216 const before = classifyCharacter(previous);
16217 /** @type {NonNullable<Code>} */
16218 let marker;
16219 return start;
16220 /**
16221 * Before a sequence.
16222 *
16223 * ```markdown
16224 * > | **
16225 * ^
16226 * ```
16227 *
16228 * @type {State}
16229 */
16230 function start(code) {
16231 marker = code;
16232 effects.enter("attentionSequence");
16233 return inside(code);
16234 }
16235 /**
16236 * In a sequence.
16237 *
16238 * ```markdown
16239 * > | **
16240 * ^^
16241 * ```
16242 *
16243 * @type {State}
16244 */
16245 function inside(code) {
16246 if (code === marker) {
16247 effects.consume(code);
16248 return inside;
16249 }
16250 const token = effects.exit("attentionSequence");
16251 const after = classifyCharacter(code);
16252 const open = !after || after === 2 && before || attentionMarkers.includes(code);
16253 const close = !before || before === 2 && after || attentionMarkers.includes(previous);
16254 token._open = Boolean(marker === 42 ? open : open && (before || !close));
16255 token._close = Boolean(marker === 42 ? close : close && (after || !open));
16256 return ok(code);
16257 }
16258 }
16259 /**
16260 * Move a point a bit.
16261 *
16262 * Note: `move` only works inside lines! It’s not possible to move past other
16263 * chunks (replacement characters, tabs, or line endings).
16264 *
16265 * @param {Point} point
16266 * @param {number} offset
16267 * @returns {void}
16268 */
16269 function movePoint(point, offset) {
16270 point.column += offset;
16271 point.offset += offset;
16272 point._bufferIndex += offset;
16273 }
16274 var attention;
16275 var init_attention = __esmMin((() => {
16276 init_micromark_util_chunked();
16277 init_micromark_util_classify_character();
16278 init_micromark_util_resolve_all();
16279 attention = {
16280 name: "attention",
16281 tokenize: tokenizeAttention,
16282 resolveAll: resolveAllAttention
16283 };
16284 }));
16285
16286 //#endregion
16287 //#region node_modules/micromark-core-commonmark/lib/autolink.js
16288 /**
16289 * @this {TokenizeContext}
16290 * @type {Tokenizer}
16291 */
16292 function tokenizeAutolink(effects, ok, nok) {
16293 let size = 0;
16294 return start;
16295 /**
16296 * Start of an autolink.
16297 *
16298 * ```markdown
16299 * > | a<https://example.com>b
16300 * ^
16301 * > | a<[email protected]>b
16302 * ^
16303 * ```
16304 *
16305 * @type {State}
16306 */
16307 function start(code) {
16308 effects.enter("autolink");
16309 effects.enter("autolinkMarker");
16310 effects.consume(code);
16311 effects.exit("autolinkMarker");
16312 effects.enter("autolinkProtocol");
16313 return open;
16314 }
16315 /**
16316 * After `<`, at protocol or atext.
16317 *
16318 * ```markdown
16319 * > | a<https://example.com>b
16320 * ^
16321 * > | a<[email protected]>b
16322 * ^
16323 * ```
16324 *
16325 * @type {State}
16326 */
16327 function open(code) {
16328 if (asciiAlpha(code)) {
16329 effects.consume(code);
16330 return schemeOrEmailAtext;
16331 }
16332 return emailAtext(code);
16333 }
16334 /**
16335 * At second byte of protocol or atext.
16336 *
16337 * ```markdown
16338 * > | a<https://example.com>b
16339 * ^
16340 * > | a<[email protected]>b
16341 * ^
16342 * ```
16343 *
16344 * @type {State}
16345 */
16346 function schemeOrEmailAtext(code) {
16347 if (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) {
16348 size = 1;
16349 return schemeInsideOrEmailAtext(code);
16350 }
16351 return emailAtext(code);
16352 }
16353 /**
16354 * In ambiguous protocol or atext.
16355 *
16356 * ```markdown
16357 * > | a<https://example.com>b
16358 * ^
16359 * > | a<[email protected]>b
16360 * ^
16361 * ```
16362 *
16363 * @type {State}
16364 */
16365 function schemeInsideOrEmailAtext(code) {
16366 if (code === 58) {
16367 effects.consume(code);
16368 size = 0;
16369 return urlInside;
16370 }
16371 if ((code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) && size++ < 32) {
16372 effects.consume(code);
16373 return schemeInsideOrEmailAtext;
16374 }
16375 size = 0;
16376 return emailAtext(code);
16377 }
16378 /**
16379 * After protocol, in URL.
16380 *
16381 * ```markdown
16382 * > | a<https://example.com>b
16383 * ^
16384 * ```
16385 *
16386 * @type {State}
16387 */
16388 function urlInside(code) {
16389 if (code === 62) {
16390 effects.exit("autolinkProtocol");
16391 effects.enter("autolinkMarker");
16392 effects.consume(code);
16393 effects.exit("autolinkMarker");
16394 effects.exit("autolink");
16395 return ok;
16396 }
16397 if (code === null || code === 32 || code === 60 || asciiControl(code)) return nok(code);
16398 effects.consume(code);
16399 return urlInside;
16400 }
16401 /**
16402 * In email atext.
16403 *
16404 * ```markdown
16405 * > | a<[email protected]>b
16406 * ^
16407 * ```
16408 *
16409 * @type {State}
16410 */
16411 function emailAtext(code) {
16412 if (code === 64) {
16413 effects.consume(code);
16414 return emailAtSignOrDot;
16415 }
16416 if (asciiAtext(code)) {
16417 effects.consume(code);
16418 return emailAtext;
16419 }
16420 return nok(code);
16421 }
16422 /**
16423 * In label, after at-sign or dot.
16424 *
16425 * ```markdown
16426 * > | a<[email protected]>b
16427 * ^ ^
16428 * ```
16429 *
16430 * @type {State}
16431 */
16432 function emailAtSignOrDot(code) {
16433 return asciiAlphanumeric(code) ? emailLabel(code) : nok(code);
16434 }
16435 /**
16436 * In label, where `.` and `>` are allowed.
16437 *
16438 * ```markdown
16439 * > | a<[email protected]>b
16440 * ^
16441 * ```
16442 *
16443 * @type {State}
16444 */
16445 function emailLabel(code) {
16446 if (code === 46) {
16447 effects.consume(code);
16448 size = 0;
16449 return emailAtSignOrDot;
16450 }
16451 if (code === 62) {
16452 effects.exit("autolinkProtocol").type = "autolinkEmail";
16453 effects.enter("autolinkMarker");
16454 effects.consume(code);
16455 effects.exit("autolinkMarker");
16456 effects.exit("autolink");
16457 return ok;
16458 }
16459 return emailValue(code);
16460 }
16461 /**
16462 * In label, where `.` and `>` are *not* allowed.
16463 *
16464 * Though, this is also used in `emailLabel` to parse other values.
16465 *
16466 * ```markdown
16467 * > | a<[email protected]>b
16468 * ^
16469 * ```
16470 *
16471 * @type {State}
16472 */
16473 function emailValue(code) {
16474 if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) {
16475 const next = code === 45 ? emailValue : emailLabel;
16476 effects.consume(code);
16477 return next;
16478 }
16479 return nok(code);
16480 }
16481 }
16482 var autolink;
16483 var init_autolink = __esmMin((() => {
16484 init_micromark_util_character();
16485 autolink = {
16486 name: "autolink",
16487 tokenize: tokenizeAutolink
16488 };
16489 }));
16490
16491 //#endregion
16492 //#region node_modules/micromark-core-commonmark/lib/blank-line.js
16493 /**
16494 * @this {TokenizeContext}
16495 * @type {Tokenizer}
16496 */
16497 function tokenizeBlankLine(effects, ok, nok) {
16498 return start;
16499 /**
16500 * Start of blank line.
16501 *
16502 * > 👉 **Note**: `␠` represents a space character.
16503 *
16504 * ```markdown
16505 * > | ␠␠␊
16506 * ^
16507 * > | ␊
16508 * ^
16509 * ```
16510 *
16511 * @type {State}
16512 */
16513 function start(code) {
16514 return markdownSpace(code) ? factorySpace(effects, after, "linePrefix")(code) : after(code);
16515 }
16516 /**
16517 * At eof/eol, after optional whitespace.
16518 *
16519 * > 👉 **Note**: `␠` represents a space character.
16520 *
16521 * ```markdown
16522 * > | ␠␠␊
16523 * ^
16524 * > | ␊
16525 * ^
16526 * ```
16527 *
16528 * @type {State}
16529 */
16530 function after(code) {
16531 return code === null || markdownLineEnding(code) ? ok(code) : nok(code);
16532 }
16533 }
16534 var blankLine;
16535 var init_blank_line = __esmMin((() => {
16536 init_micromark_factory_space();
16537 init_micromark_util_character();
16538 blankLine = {
16539 tokenize: tokenizeBlankLine,
16540 partial: true
16541 };
16542 }));
16543
16544 //#endregion
16545 //#region node_modules/micromark-core-commonmark/lib/block-quote.js
16546 /**
16547 * @this {TokenizeContext}
16548 * @type {Tokenizer}
16549 */
16550 function tokenizeBlockQuoteStart(effects, ok, nok) {
16551 const self = this;
16552 return start;
16553 /**
16554 * Start of block quote.
16555 *
16556 * ```markdown
16557 * > | > a
16558 * ^
16559 * ```
16560 *
16561 * @type {State}
16562 */
16563 function start(code) {
16564 if (code === 62) {
16565 const state = self.containerState;
16566 if (!state.open) {
16567 effects.enter("blockQuote", { _container: true });
16568 state.open = true;
16569 }
16570 effects.enter("blockQuotePrefix");
16571 effects.enter("blockQuoteMarker");
16572 effects.consume(code);
16573 effects.exit("blockQuoteMarker");
16574 return after;
16575 }
16576 return nok(code);
16577 }
16578 /**
16579 * After `>`, before optional whitespace.
16580 *
16581 * ```markdown
16582 * > | > a
16583 * ^
16584 * ```
16585 *
16586 * @type {State}
16587 */
16588 function after(code) {
16589 if (markdownSpace(code)) {
16590 effects.enter("blockQuotePrefixWhitespace");
16591 effects.consume(code);
16592 effects.exit("blockQuotePrefixWhitespace");
16593 effects.exit("blockQuotePrefix");
16594 return ok;
16595 }
16596 effects.exit("blockQuotePrefix");
16597 return ok(code);
16598 }
16599 }
16600 /**
16601 * Start of block quote continuation.
16602 *
16603 * ```markdown
16604 * | > a
16605 * > | > b
16606 * ^
16607 * ```
16608 *
16609 * @this {TokenizeContext}
16610 * @type {Tokenizer}
16611 */
16612 function tokenizeBlockQuoteContinuation(effects, ok, nok) {
16613 const self = this;
16614 return contStart;
16615 /**
16616 * Start of block quote continuation.
16617 *
16618 * Also used to parse the first block quote opening.
16619 *
16620 * ```markdown
16621 * | > a
16622 * > | > b
16623 * ^
16624 * ```
16625 *
16626 * @type {State}
16627 */
16628 function contStart(code) {
16629 if (markdownSpace(code)) return factorySpace(effects, contBefore, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code);
16630 return contBefore(code);
16631 }
16632 /**
16633 * At `>`, after optional whitespace.
16634 *
16635 * Also used to parse the first block quote opening.
16636 *
16637 * ```markdown
16638 * | > a
16639 * > | > b
16640 * ^
16641 * ```
16642 *
16643 * @type {State}
16644 */
16645 function contBefore(code) {
16646 return effects.attempt(blockQuote, ok, nok)(code);
16647 }
16648 }
16649 /** @type {Exiter} */
16650 function exit(effects) {
16651 effects.exit("blockQuote");
16652 }
16653 var blockQuote;
16654 var init_block_quote = __esmMin((() => {
16655 init_micromark_factory_space();
16656 init_micromark_util_character();
16657 blockQuote = {
16658 name: "blockQuote",
16659 tokenize: tokenizeBlockQuoteStart,
16660 continuation: { tokenize: tokenizeBlockQuoteContinuation },
16661 exit
16662 };
16663 }));
16664
16665 //#endregion
16666 //#region node_modules/micromark-core-commonmark/lib/character-escape.js
16667 /**
16668 * @this {TokenizeContext}
16669 * @type {Tokenizer}
16670 */
16671 function tokenizeCharacterEscape(effects, ok, nok) {
16672 return start;
16673 /**
16674 * Start of character escape.
16675 *
16676 * ```markdown
16677 * > | a\*b
16678 * ^
16679 * ```
16680 *
16681 * @type {State}
16682 */
16683 function start(code) {
16684 effects.enter("characterEscape");
16685 effects.enter("escapeMarker");
16686 effects.consume(code);
16687 effects.exit("escapeMarker");
16688 return inside;
16689 }
16690 /**
16691 * After `\`, at punctuation.
16692 *
16693 * ```markdown
16694 * > | a\*b
16695 * ^
16696 * ```
16697 *
16698 * @type {State}
16699 */
16700 function inside(code) {
16701 if (asciiPunctuation(code)) {
16702 effects.enter("characterEscapeValue");
16703 effects.consume(code);
16704 effects.exit("characterEscapeValue");
16705 effects.exit("characterEscape");
16706 return ok;
16707 }
16708 return nok(code);
16709 }
16710 }
16711 var characterEscape;
16712 var init_character_escape = __esmMin((() => {
16713 init_micromark_util_character();
16714 characterEscape = {
16715 name: "characterEscape",
16716 tokenize: tokenizeCharacterEscape
16717 };
16718 }));
16719
16720 //#endregion
16721 //#region node_modules/decode-named-character-reference/index.dom.js
16722 /**
16723 * @param {string} value
16724 * @returns {string | false}
16725 */
16726 function decodeNamedCharacterReference(value) {
16727 const characterReference = "&" + value + ";";
16728 element.innerHTML = characterReference;
16729 const character = element.textContent;
16730 if (character.charCodeAt(character.length - 1) === 59 && value !== "semi") return false;
16731 return character === characterReference ? false : character;
16732 }
16733 var element;
16734 var init_index_dom = __esmMin((() => {
16735 element = document.createElement("i");
16736 }));
16737
16738 //#endregion
16739 //#region node_modules/micromark-core-commonmark/lib/character-reference.js
16740 /**
16741 * @this {TokenizeContext}
16742 * @type {Tokenizer}
16743 */
16744 function tokenizeCharacterReference(effects, ok, nok) {
16745 const self = this;
16746 let size = 0;
16747 /** @type {number} */
16748 let max;
16749 /** @type {(code: Code) => boolean} */
16750 let test;
16751 return start;
16752 /**
16753 * Start of character reference.
16754 *
16755 * ```markdown
16756 * > | a&amp;b
16757 * ^
16758 * > | a&#123;b
16759 * ^
16760 * > | a&#x9;b
16761 * ^
16762 * ```
16763 *
16764 * @type {State}
16765 */
16766 function start(code) {
16767 effects.enter("characterReference");
16768 effects.enter("characterReferenceMarker");
16769 effects.consume(code);
16770 effects.exit("characterReferenceMarker");
16771 return open;
16772 }
16773 /**
16774 * After `&`, at `#` for numeric references or alphanumeric for named
16775 * references.
16776 *
16777 * ```markdown
16778 * > | a&amp;b
16779 * ^
16780 * > | a&#123;b
16781 * ^
16782 * > | a&#x9;b
16783 * ^
16784 * ```
16785 *
16786 * @type {State}
16787 */
16788 function open(code) {
16789 if (code === 35) {
16790 effects.enter("characterReferenceMarkerNumeric");
16791 effects.consume(code);
16792 effects.exit("characterReferenceMarkerNumeric");
16793 return numeric;
16794 }
16795 effects.enter("characterReferenceValue");
16796 max = 31;
16797 test = asciiAlphanumeric;
16798 return value(code);
16799 }
16800 /**
16801 * After `#`, at `x` for hexadecimals or digit for decimals.
16802 *
16803 * ```markdown
16804 * > | a&#123;b
16805 * ^
16806 * > | a&#x9;b
16807 * ^
16808 * ```
16809 *
16810 * @type {State}
16811 */
16812 function numeric(code) {
16813 if (code === 88 || code === 120) {
16814 effects.enter("characterReferenceMarkerHexadecimal");
16815 effects.consume(code);
16816 effects.exit("characterReferenceMarkerHexadecimal");
16817 effects.enter("characterReferenceValue");
16818 max = 6;
16819 test = asciiHexDigit;
16820 return value;
16821 }
16822 effects.enter("characterReferenceValue");
16823 max = 7;
16824 test = asciiDigit;
16825 return value(code);
16826 }
16827 /**
16828 * After markers (`&#x`, `&#`, or `&`), in value, before `;`.
16829 *
16830 * The character reference kind defines what and how many characters are
16831 * allowed.
16832 *
16833 * ```markdown
16834 * > | a&amp;b
16835 * ^^^
16836 * > | a&#123;b
16837 * ^^^
16838 * > | a&#x9;b
16839 * ^
16840 * ```
16841 *
16842 * @type {State}
16843 */
16844 function value(code) {
16845 if (code === 59 && size) {
16846 const token = effects.exit("characterReferenceValue");
16847 if (test === asciiAlphanumeric && !decodeNamedCharacterReference(self.sliceSerialize(token))) return nok(code);
16848 effects.enter("characterReferenceMarker");
16849 effects.consume(code);
16850 effects.exit("characterReferenceMarker");
16851 effects.exit("characterReference");
16852 return ok;
16853 }
16854 if (test(code) && size++ < max) {
16855 effects.consume(code);
16856 return value;
16857 }
16858 return nok(code);
16859 }
16860 }
16861 var characterReference;
16862 var init_character_reference = __esmMin((() => {
16863 init_index_dom();
16864 init_micromark_util_character();
16865 characterReference = {
16866 name: "characterReference",
16867 tokenize: tokenizeCharacterReference
16868 };
16869 }));
16870
16871 //#endregion
16872 //#region node_modules/micromark-core-commonmark/lib/code-fenced.js
16873 /**
16874 * @this {TokenizeContext}
16875 * @type {Tokenizer}
16876 */
16877 function tokenizeCodeFenced(effects, ok, nok) {
16878 const self = this;
16879 /** @type {Construct} */
16880 const closeStart = {
16881 tokenize: tokenizeCloseStart,
16882 partial: true
16883 };
16884 let initialPrefix = 0;
16885 let sizeOpen = 0;
16886 /** @type {NonNullable<Code>} */
16887 let marker;
16888 return start;
16889 /**
16890 * Start of code.
16891 *
16892 * ```markdown
16893 * > | ~~~js
16894 * ^
16895 * | alert(1)
16896 * | ~~~
16897 * ```
16898 *
16899 * @type {State}
16900 */
16901 function start(code) {
16902 return beforeSequenceOpen(code);
16903 }
16904 /**
16905 * In opening fence, after prefix, at sequence.
16906 *
16907 * ```markdown
16908 * > | ~~~js
16909 * ^
16910 * | alert(1)
16911 * | ~~~
16912 * ```
16913 *
16914 * @type {State}
16915 */
16916 function beforeSequenceOpen(code) {
16917 const tail = self.events[self.events.length - 1];
16918 initialPrefix = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0;
16919 marker = code;
16920 effects.enter("codeFenced");
16921 effects.enter("codeFencedFence");
16922 effects.enter("codeFencedFenceSequence");
16923 return sequenceOpen(code);
16924 }
16925 /**
16926 * In opening fence sequence.
16927 *
16928 * ```markdown
16929 * > | ~~~js
16930 * ^
16931 * | alert(1)
16932 * | ~~~
16933 * ```
16934 *
16935 * @type {State}
16936 */
16937 function sequenceOpen(code) {
16938 if (code === marker) {
16939 sizeOpen++;
16940 effects.consume(code);
16941 return sequenceOpen;
16942 }
16943 if (sizeOpen < 3) return nok(code);
16944 effects.exit("codeFencedFenceSequence");
16945 return markdownSpace(code) ? factorySpace(effects, infoBefore, "whitespace")(code) : infoBefore(code);
16946 }
16947 /**
16948 * In opening fence, after the sequence (and optional whitespace), before info.
16949 *
16950 * ```markdown
16951 * > | ~~~js
16952 * ^
16953 * | alert(1)
16954 * | ~~~
16955 * ```
16956 *
16957 * @type {State}
16958 */
16959 function infoBefore(code) {
16960 if (code === null || markdownLineEnding(code)) {
16961 effects.exit("codeFencedFence");
16962 return self.interrupt ? ok(code) : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
16963 }
16964 effects.enter("codeFencedFenceInfo");
16965 effects.enter("chunkString", { contentType: "string" });
16966 return info(code);
16967 }
16968 /**
16969 * In info.
16970 *
16971 * ```markdown
16972 * > | ~~~js
16973 * ^
16974 * | alert(1)
16975 * | ~~~
16976 * ```
16977 *
16978 * @type {State}
16979 */
16980 function info(code) {
16981 if (code === null || markdownLineEnding(code)) {
16982 effects.exit("chunkString");
16983 effects.exit("codeFencedFenceInfo");
16984 return infoBefore(code);
16985 }
16986 if (markdownSpace(code)) {
16987 effects.exit("chunkString");
16988 effects.exit("codeFencedFenceInfo");
16989 return factorySpace(effects, metaBefore, "whitespace")(code);
16990 }
16991 if (code === 96 && code === marker) return nok(code);
16992 effects.consume(code);
16993 return info;
16994 }
16995 /**
16996 * In opening fence, after info and whitespace, before meta.
16997 *
16998 * ```markdown
16999 * > | ~~~js eval
17000 * ^
17001 * | alert(1)
17002 * | ~~~
17003 * ```
17004 *
17005 * @type {State}
17006 */
17007 function metaBefore(code) {
17008 if (code === null || markdownLineEnding(code)) return infoBefore(code);
17009 effects.enter("codeFencedFenceMeta");
17010 effects.enter("chunkString", { contentType: "string" });
17011 return meta(code);
17012 }
17013 /**
17014 * In meta.
17015 *
17016 * ```markdown
17017 * > | ~~~js eval
17018 * ^
17019 * | alert(1)
17020 * | ~~~
17021 * ```
17022 *
17023 * @type {State}
17024 */
17025 function meta(code) {
17026 if (code === null || markdownLineEnding(code)) {
17027 effects.exit("chunkString");
17028 effects.exit("codeFencedFenceMeta");
17029 return infoBefore(code);
17030 }
17031 if (code === 96 && code === marker) return nok(code);
17032 effects.consume(code);
17033 return meta;
17034 }
17035 /**
17036 * At eol/eof in code, before a non-lazy closing fence or content.
17037 *
17038 * ```markdown
17039 * > | ~~~js
17040 * ^
17041 * > | alert(1)
17042 * ^
17043 * | ~~~
17044 * ```
17045 *
17046 * @type {State}
17047 */
17048 function atNonLazyBreak(code) {
17049 return effects.attempt(closeStart, after, contentBefore)(code);
17050 }
17051 /**
17052 * Before code content, not a closing fence, at eol.
17053 *
17054 * ```markdown
17055 * | ~~~js
17056 * > | alert(1)
17057 * ^
17058 * | ~~~
17059 * ```
17060 *
17061 * @type {State}
17062 */
17063 function contentBefore(code) {
17064 effects.enter("lineEnding");
17065 effects.consume(code);
17066 effects.exit("lineEnding");
17067 return contentStart;
17068 }
17069 /**
17070 * Before code content, not a closing fence.
17071 *
17072 * ```markdown
17073 * | ~~~js
17074 * > | alert(1)
17075 * ^
17076 * | ~~~
17077 * ```
17078 *
17079 * @type {State}
17080 */
17081 function contentStart(code) {
17082 return initialPrefix > 0 && markdownSpace(code) ? factorySpace(effects, beforeContentChunk, "linePrefix", initialPrefix + 1)(code) : beforeContentChunk(code);
17083 }
17084 /**
17085 * Before code content, after optional prefix.
17086 *
17087 * ```markdown
17088 * | ~~~js
17089 * > | alert(1)
17090 * ^
17091 * | ~~~
17092 * ```
17093 *
17094 * @type {State}
17095 */
17096 function beforeContentChunk(code) {
17097 if (code === null || markdownLineEnding(code)) return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
17098 effects.enter("codeFlowValue");
17099 return contentChunk(code);
17100 }
17101 /**
17102 * In code content.
17103 *
17104 * ```markdown
17105 * | ~~~js
17106 * > | alert(1)
17107 * ^^^^^^^^
17108 * | ~~~
17109 * ```
17110 *
17111 * @type {State}
17112 */
17113 function contentChunk(code) {
17114 if (code === null || markdownLineEnding(code)) {
17115 effects.exit("codeFlowValue");
17116 return beforeContentChunk(code);
17117 }
17118 effects.consume(code);
17119 return contentChunk;
17120 }
17121 /**
17122 * After code.
17123 *
17124 * ```markdown
17125 * | ~~~js
17126 * | alert(1)
17127 * > | ~~~
17128 * ^
17129 * ```
17130 *
17131 * @type {State}
17132 */
17133 function after(code) {
17134 effects.exit("codeFenced");
17135 return ok(code);
17136 }
17137 /**
17138 * @this {TokenizeContext}
17139 * @type {Tokenizer}
17140 */
17141 function tokenizeCloseStart(effects, ok, nok) {
17142 let size = 0;
17143 return startBefore;
17144 /**
17145 *
17146 *
17147 * @type {State}
17148 */
17149 function startBefore(code) {
17150 effects.enter("lineEnding");
17151 effects.consume(code);
17152 effects.exit("lineEnding");
17153 return start;
17154 }
17155 /**
17156 * Before closing fence, at optional whitespace.
17157 *
17158 * ```markdown
17159 * | ~~~js
17160 * | alert(1)
17161 * > | ~~~
17162 * ^
17163 * ```
17164 *
17165 * @type {State}
17166 */
17167 function start(code) {
17168 effects.enter("codeFencedFence");
17169 return markdownSpace(code) ? factorySpace(effects, beforeSequenceClose, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code) : beforeSequenceClose(code);
17170 }
17171 /**
17172 * In closing fence, after optional whitespace, at sequence.
17173 *
17174 * ```markdown
17175 * | ~~~js
17176 * | alert(1)
17177 * > | ~~~
17178 * ^
17179 * ```
17180 *
17181 * @type {State}
17182 */
17183 function beforeSequenceClose(code) {
17184 if (code === marker) {
17185 effects.enter("codeFencedFenceSequence");
17186 return sequenceClose(code);
17187 }
17188 return nok(code);
17189 }
17190 /**
17191 * In closing fence sequence.
17192 *
17193 * ```markdown
17194 * | ~~~js
17195 * | alert(1)
17196 * > | ~~~
17197 * ^
17198 * ```
17199 *
17200 * @type {State}
17201 */
17202 function sequenceClose(code) {
17203 if (code === marker) {
17204 size++;
17205 effects.consume(code);
17206 return sequenceClose;
17207 }
17208 if (size >= sizeOpen) {
17209 effects.exit("codeFencedFenceSequence");
17210 return markdownSpace(code) ? factorySpace(effects, sequenceCloseAfter, "whitespace")(code) : sequenceCloseAfter(code);
17211 }
17212 return nok(code);
17213 }
17214 /**
17215 * After closing fence sequence, after optional whitespace.
17216 *
17217 * ```markdown
17218 * | ~~~js
17219 * | alert(1)
17220 * > | ~~~
17221 * ^
17222 * ```
17223 *
17224 * @type {State}
17225 */
17226 function sequenceCloseAfter(code) {
17227 if (code === null || markdownLineEnding(code)) {
17228 effects.exit("codeFencedFence");
17229 return ok(code);
17230 }
17231 return nok(code);
17232 }
17233 }
17234 }
17235 /**
17236 * @this {TokenizeContext}
17237 * @type {Tokenizer}
17238 */
17239 function tokenizeNonLazyContinuation(effects, ok, nok) {
17240 const self = this;
17241 return start;
17242 /**
17243 *
17244 *
17245 * @type {State}
17246 */
17247 function start(code) {
17248 if (code === null) return nok(code);
17249 effects.enter("lineEnding");
17250 effects.consume(code);
17251 effects.exit("lineEnding");
17252 return lineStart;
17253 }
17254 /**
17255 *
17256 *
17257 * @type {State}
17258 */
17259 function lineStart(code) {
17260 return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
17261 }
17262 }
17263 var nonLazyContinuation, codeFenced;
17264 var init_code_fenced = __esmMin((() => {
17265 init_micromark_factory_space();
17266 init_micromark_util_character();
17267 nonLazyContinuation = {
17268 tokenize: tokenizeNonLazyContinuation,
17269 partial: true
17270 };
17271 codeFenced = {
17272 name: "codeFenced",
17273 tokenize: tokenizeCodeFenced,
17274 concrete: true
17275 };
17276 }));
17277
17278 //#endregion
17279 //#region node_modules/micromark-core-commonmark/lib/code-indented.js
17280 /**
17281 * @this {TokenizeContext}
17282 * @type {Tokenizer}
17283 */
17284 function tokenizeCodeIndented(effects, ok, nok) {
17285 const self = this;
17286 return start;
17287 /**
17288 * Start of code (indented).
17289 *
17290 * > **Parsing note**: it is not needed to check if this first line is a
17291 * > filled line (that it has a non-whitespace character), because blank lines
17292 * > are parsed already, so we never run into that.
17293 *
17294 * ```markdown
17295 * > | aaa
17296 * ^
17297 * ```
17298 *
17299 * @type {State}
17300 */
17301 function start(code) {
17302 effects.enter("codeIndented");
17303 return factorySpace(effects, afterPrefix, "linePrefix", 5)(code);
17304 }
17305 /**
17306 * At start, after 1 or 4 spaces.
17307 *
17308 * ```markdown
17309 * > | aaa
17310 * ^
17311 * ```
17312 *
17313 * @type {State}
17314 */
17315 function afterPrefix(code) {
17316 const tail = self.events[self.events.length - 1];
17317 return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? atBreak(code) : nok(code);
17318 }
17319 /**
17320 * At a break.
17321 *
17322 * ```markdown
17323 * > | aaa
17324 * ^ ^
17325 * ```
17326 *
17327 * @type {State}
17328 */
17329 function atBreak(code) {
17330 if (code === null) return after(code);
17331 if (markdownLineEnding(code)) return effects.attempt(furtherStart, atBreak, after)(code);
17332 effects.enter("codeFlowValue");
17333 return inside(code);
17334 }
17335 /**
17336 * In code content.
17337 *
17338 * ```markdown
17339 * > | aaa
17340 * ^^^^
17341 * ```
17342 *
17343 * @type {State}
17344 */
17345 function inside(code) {
17346 if (code === null || markdownLineEnding(code)) {
17347 effects.exit("codeFlowValue");
17348 return atBreak(code);
17349 }
17350 effects.consume(code);
17351 return inside;
17352 }
17353 /** @type {State} */
17354 function after(code) {
17355 effects.exit("codeIndented");
17356 return ok(code);
17357 }
17358 }
17359 /**
17360 * @this {TokenizeContext}
17361 * @type {Tokenizer}
17362 */
17363 function tokenizeFurtherStart(effects, ok, nok) {
17364 const self = this;
17365 return furtherStart;
17366 /**
17367 * At eol, trying to parse another indent.
17368 *
17369 * ```markdown
17370 * > | aaa
17371 * ^
17372 * | bbb
17373 * ```
17374 *
17375 * @type {State}
17376 */
17377 function furtherStart(code) {
17378 if (self.parser.lazy[self.now().line]) return nok(code);
17379 if (markdownLineEnding(code)) {
17380 effects.enter("lineEnding");
17381 effects.consume(code);
17382 effects.exit("lineEnding");
17383 return furtherStart;
17384 }
17385 return factorySpace(effects, afterPrefix, "linePrefix", 5)(code);
17386 }
17387 /**
17388 * At start, after 1 or 4 spaces.
17389 *
17390 * ```markdown
17391 * > | aaa
17392 * ^
17393 * ```
17394 *
17395 * @type {State}
17396 */
17397 function afterPrefix(code) {
17398 const tail = self.events[self.events.length - 1];
17399 return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? ok(code) : markdownLineEnding(code) ? furtherStart(code) : nok(code);
17400 }
17401 }
17402 var codeIndented, furtherStart;
17403 var init_code_indented = __esmMin((() => {
17404 init_micromark_factory_space();
17405 init_micromark_util_character();
17406 codeIndented = {
17407 name: "codeIndented",
17408 tokenize: tokenizeCodeIndented
17409 };
17410 furtherStart = {
17411 tokenize: tokenizeFurtherStart,
17412 partial: true
17413 };
17414 }));
17415
17416 //#endregion
17417 //#region node_modules/micromark-core-commonmark/lib/code-text.js
17418 /** @type {Resolver} */
17419 function resolveCodeText(events) {
17420 let tailExitIndex = events.length - 4;
17421 let headEnterIndex = 3;
17422 /** @type {number} */
17423 let index;
17424 /** @type {number | undefined} */
17425 let enter;
17426 if ((events[headEnterIndex][1].type === "lineEnding" || events[headEnterIndex][1].type === "space") && (events[tailExitIndex][1].type === "lineEnding" || events[tailExitIndex][1].type === "space")) {
17427 index = headEnterIndex;
17428 while (++index < tailExitIndex) if (events[index][1].type === "codeTextData") {
17429 events[headEnterIndex][1].type = "codeTextPadding";
17430 events[tailExitIndex][1].type = "codeTextPadding";
17431 headEnterIndex += 2;
17432 tailExitIndex -= 2;
17433 break;
17434 }
17435 }
17436 index = headEnterIndex - 1;
17437 tailExitIndex++;
17438 while (++index <= tailExitIndex) if (enter === void 0) {
17439 if (index !== tailExitIndex && events[index][1].type !== "lineEnding") enter = index;
17440 } else if (index === tailExitIndex || events[index][1].type === "lineEnding") {
17441 events[enter][1].type = "codeTextData";
17442 if (index !== enter + 2) {
17443 events[enter][1].end = events[index - 1][1].end;
17444 events.splice(enter + 2, index - enter - 2);
17445 tailExitIndex -= index - enter - 2;
17446 index = enter + 2;
17447 }
17448 enter = void 0;
17449 }
17450 return events;
17451 }
17452 /**
17453 * @this {TokenizeContext}
17454 * @type {Previous}
17455 */
17456 function previous(code) {
17457 return code !== 96 || this.events[this.events.length - 1][1].type === "characterEscape";
17458 }
17459 /**
17460 * @this {TokenizeContext}
17461 * @type {Tokenizer}
17462 */
17463 function tokenizeCodeText(effects, ok, nok) {
17464 let sizeOpen = 0;
17465 /** @type {number} */
17466 let size;
17467 /** @type {Token} */
17468 let token;
17469 return start;
17470 /**
17471 * Start of code (text).
17472 *
17473 * ```markdown
17474 * > | `a`
17475 * ^
17476 * > | \`a`
17477 * ^
17478 * ```
17479 *
17480 * @type {State}
17481 */
17482 function start(code) {
17483 effects.enter("codeText");
17484 effects.enter("codeTextSequence");
17485 return sequenceOpen(code);
17486 }
17487 /**
17488 * In opening sequence.
17489 *
17490 * ```markdown
17491 * > | `a`
17492 * ^
17493 * ```
17494 *
17495 * @type {State}
17496 */
17497 function sequenceOpen(code) {
17498 if (code === 96) {
17499 effects.consume(code);
17500 sizeOpen++;
17501 return sequenceOpen;
17502 }
17503 effects.exit("codeTextSequence");
17504 return between(code);
17505 }
17506 /**
17507 * Between something and something else.
17508 *
17509 * ```markdown
17510 * > | `a`
17511 * ^^
17512 * ```
17513 *
17514 * @type {State}
17515 */
17516 function between(code) {
17517 if (code === null) return nok(code);
17518 if (code === 32) {
17519 effects.enter("space");
17520 effects.consume(code);
17521 effects.exit("space");
17522 return between;
17523 }
17524 if (code === 96) {
17525 token = effects.enter("codeTextSequence");
17526 size = 0;
17527 return sequenceClose(code);
17528 }
17529 if (markdownLineEnding(code)) {
17530 effects.enter("lineEnding");
17531 effects.consume(code);
17532 effects.exit("lineEnding");
17533 return between;
17534 }
17535 effects.enter("codeTextData");
17536 return data(code);
17537 }
17538 /**
17539 * In data.
17540 *
17541 * ```markdown
17542 * > | `a`
17543 * ^
17544 * ```
17545 *
17546 * @type {State}
17547 */
17548 function data(code) {
17549 if (code === null || code === 32 || code === 96 || markdownLineEnding(code)) {
17550 effects.exit("codeTextData");
17551 return between(code);
17552 }
17553 effects.consume(code);
17554 return data;
17555 }
17556 /**
17557 * In closing sequence.
17558 *
17559 * ```markdown
17560 * > | `a`
17561 * ^
17562 * ```
17563 *
17564 * @type {State}
17565 */
17566 function sequenceClose(code) {
17567 if (code === 96) {
17568 effects.consume(code);
17569 size++;
17570 return sequenceClose;
17571 }
17572 if (size === sizeOpen) {
17573 effects.exit("codeTextSequence");
17574 effects.exit("codeText");
17575 return ok(code);
17576 }
17577 token.type = "codeTextData";
17578 return data(code);
17579 }
17580 }
17581 var codeText;
17582 var init_code_text = __esmMin((() => {
17583 init_micromark_util_character();
17584 codeText = {
17585 name: "codeText",
17586 tokenize: tokenizeCodeText,
17587 resolve: resolveCodeText,
17588 previous
17589 };
17590 }));
17591
17592 //#endregion
17593 //#region node_modules/micromark-util-subtokenize/index.js
17594 /**
17595 * Tokenize subcontent.
17596 *
17597 * @param {Array<Event>} events
17598 * List of events.
17599 * @returns {boolean}
17600 * Whether subtokens were found.
17601 */
17602 function subtokenize(events) {
17603 /** @type {Record<string, number>} */
17604 const jumps = {};
17605 let index = -1;
17606 /** @type {Event} */
17607 let event;
17608 /** @type {number | undefined} */
17609 let lineIndex;
17610 /** @type {number} */
17611 let otherIndex;
17612 /** @type {Event} */
17613 let otherEvent;
17614 /** @type {Array<Event>} */
17615 let parameters;
17616 /** @type {Array<Event>} */
17617 let subevents;
17618 /** @type {boolean | undefined} */
17619 let more;
17620 while (++index < events.length) {
17621 while (index in jumps) index = jumps[index];
17622 event = events[index];
17623 if (index && event[1].type === "chunkFlow" && events[index - 1][1].type === "listItemPrefix") {
17624 subevents = event[1]._tokenizer.events;
17625 otherIndex = 0;
17626 if (otherIndex < subevents.length && subevents[otherIndex][1].type === "lineEndingBlank") otherIndex += 2;
17627 if (otherIndex < subevents.length && subevents[otherIndex][1].type === "content") while (++otherIndex < subevents.length) {
17628 if (subevents[otherIndex][1].type === "content") break;
17629 if (subevents[otherIndex][1].type === "chunkText") {
17630 subevents[otherIndex][1]._isInFirstContentOfListItem = true;
17631 otherIndex++;
17632 }
17633 }
17634 }
17635 if (event[0] === "enter") {
17636 if (event[1].contentType) {
17637 Object.assign(jumps, subcontent(events, index));
17638 index = jumps[index];
17639 more = true;
17640 }
17641 } else if (event[1]._container) {
17642 otherIndex = index;
17643 lineIndex = void 0;
17644 while (otherIndex--) {
17645 otherEvent = events[otherIndex];
17646 if (otherEvent[1].type === "lineEnding" || otherEvent[1].type === "lineEndingBlank") {
17647 if (otherEvent[0] === "enter") {
17648 if (lineIndex) events[lineIndex][1].type = "lineEndingBlank";
17649 otherEvent[1].type = "lineEnding";
17650 lineIndex = otherIndex;
17651 }
17652 } else break;
17653 }
17654 if (lineIndex) {
17655 event[1].end = Object.assign({}, events[lineIndex][1].start);
17656 parameters = events.slice(lineIndex, index);
17657 parameters.unshift(event);
17658 splice(events, lineIndex, index - lineIndex + 1, parameters);
17659 }
17660 }
17661 }
17662 return !more;
17663 }
17664 /**
17665 * Tokenize embedded tokens.
17666 *
17667 * @param {Array<Event>} events
17668 * @param {number} eventIndex
17669 * @returns {Record<string, number>}
17670 */
17671 function subcontent(events, eventIndex) {
17672 const token = events[eventIndex][1];
17673 const context = events[eventIndex][2];
17674 let startPosition = eventIndex - 1;
17675 /** @type {Array<number>} */
17676 const startPositions = [];
17677 const tokenizer = token._tokenizer || context.parser[token.contentType](token.start);
17678 const childEvents = tokenizer.events;
17679 /** @type {Array<[number, number]>} */
17680 const jumps = [];
17681 /** @type {Record<string, number>} */
17682 const gaps = {};
17683 /** @type {Array<Chunk>} */
17684 let stream;
17685 /** @type {Token | undefined} */
17686 let previous;
17687 let index = -1;
17688 /** @type {Token | undefined} */
17689 let current = token;
17690 let adjust = 0;
17691 let start = 0;
17692 const breaks = [start];
17693 while (current) {
17694 while (events[++startPosition][1] !== current);
17695 startPositions.push(startPosition);
17696 if (!current._tokenizer) {
17697 stream = context.sliceStream(current);
17698 if (!current.next) stream.push(null);
17699 if (previous) tokenizer.defineSkip(current.start);
17700 if (current._isInFirstContentOfListItem) tokenizer._gfmTasklistFirstContentOfListItem = true;
17701 tokenizer.write(stream);
17702 if (current._isInFirstContentOfListItem) tokenizer._gfmTasklistFirstContentOfListItem = void 0;
17703 }
17704 previous = current;
17705 current = current.next;
17706 }
17707 current = token;
17708 while (++index < childEvents.length) if (childEvents[index][0] === "exit" && childEvents[index - 1][0] === "enter" && childEvents[index][1].type === childEvents[index - 1][1].type && childEvents[index][1].start.line !== childEvents[index][1].end.line) {
17709 start = index + 1;
17710 breaks.push(start);
17711 current._tokenizer = void 0;
17712 current.previous = void 0;
17713 current = current.next;
17714 }
17715 tokenizer.events = [];
17716 if (current) {
17717 current._tokenizer = void 0;
17718 current.previous = void 0;
17719 } else breaks.pop();
17720 index = breaks.length;
17721 while (index--) {
17722 const slice = childEvents.slice(breaks[index], breaks[index + 1]);
17723 const start = startPositions.pop();
17724 jumps.unshift([start, start + slice.length - 1]);
17725 splice(events, start, 2, slice);
17726 }
17727 index = -1;
17728 while (++index < jumps.length) {
17729 gaps[adjust + jumps[index][0]] = adjust + jumps[index][1];
17730 adjust += jumps[index][1] - jumps[index][0] - 1;
17731 }
17732 return gaps;
17733 }
17734 var init_micromark_util_subtokenize = __esmMin((() => {
17735 init_micromark_util_chunked();
17736 }));
17737
17738 //#endregion
17739 //#region node_modules/micromark-core-commonmark/lib/content.js
17740 /**
17741 * Content is transparent: it’s parsed right now. That way, definitions are also
17742 * parsed right now: before text in paragraphs (specifically, media) are parsed.
17743 *
17744 * @type {Resolver}
17745 */
17746 function resolveContent(events) {
17747 subtokenize(events);
17748 return events;
17749 }
17750 /**
17751 * @this {TokenizeContext}
17752 * @type {Tokenizer}
17753 */
17754 function tokenizeContent(effects, ok) {
17755 /** @type {Token | undefined} */
17756 let previous;
17757 return chunkStart;
17758 /**
17759 * Before a content chunk.
17760 *
17761 * ```markdown
17762 * > | abc
17763 * ^
17764 * ```
17765 *
17766 * @type {State}
17767 */
17768 function chunkStart(code) {
17769 effects.enter("content");
17770 previous = effects.enter("chunkContent", { contentType: "content" });
17771 return chunkInside(code);
17772 }
17773 /**
17774 * In a content chunk.
17775 *
17776 * ```markdown
17777 * > | abc
17778 * ^^^
17779 * ```
17780 *
17781 * @type {State}
17782 */
17783 function chunkInside(code) {
17784 if (code === null) return contentEnd(code);
17785 if (markdownLineEnding(code)) return effects.check(continuationConstruct, contentContinue, contentEnd)(code);
17786 effects.consume(code);
17787 return chunkInside;
17788 }
17789 /**
17790 *
17791 *
17792 * @type {State}
17793 */
17794 function contentEnd(code) {
17795 effects.exit("chunkContent");
17796 effects.exit("content");
17797 return ok(code);
17798 }
17799 /**
17800 *
17801 *
17802 * @type {State}
17803 */
17804 function contentContinue(code) {
17805 effects.consume(code);
17806 effects.exit("chunkContent");
17807 previous.next = effects.enter("chunkContent", {
17808 contentType: "content",
17809 previous
17810 });
17811 previous = previous.next;
17812 return chunkInside;
17813 }
17814 }
17815 /**
17816 * @this {TokenizeContext}
17817 * @type {Tokenizer}
17818 */
17819 function tokenizeContinuation(effects, ok, nok) {
17820 const self = this;
17821 return startLookahead;
17822 /**
17823 *
17824 *
17825 * @type {State}
17826 */
17827 function startLookahead(code) {
17828 effects.exit("chunkContent");
17829 effects.enter("lineEnding");
17830 effects.consume(code);
17831 effects.exit("lineEnding");
17832 return factorySpace(effects, prefixed, "linePrefix");
17833 }
17834 /**
17835 *
17836 *
17837 * @type {State}
17838 */
17839 function prefixed(code) {
17840 if (code === null || markdownLineEnding(code)) return nok(code);
17841 const tail = self.events[self.events.length - 1];
17842 if (!self.parser.constructs.disable.null.includes("codeIndented") && tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4) return ok(code);
17843 return effects.interrupt(self.parser.constructs.flow, nok, ok)(code);
17844 }
17845 }
17846 var content, continuationConstruct;
17847 var init_content = __esmMin((() => {
17848 init_micromark_factory_space();
17849 init_micromark_util_character();
17850 init_micromark_util_subtokenize();
17851 content = {
17852 tokenize: tokenizeContent,
17853 resolve: resolveContent
17854 };
17855 continuationConstruct = {
17856 tokenize: tokenizeContinuation,
17857 partial: true
17858 };
17859 }));
17860
17861 //#endregion
17862 //#region node_modules/micromark-factory-destination/index.js
17863 /**
17864 * Parse destinations.
17865 *
17866 * ###### Examples
17867 *
17868 * ```markdown
17869 * <a>
17870 * <a\>b>
17871 * <a b>
17872 * <a)>
17873 * a
17874 * a\)b
17875 * a(b)c
17876 * a(b)
17877 * ```
17878 *
17879 * @param {Effects} effects
17880 * Context.
17881 * @param {State} ok
17882 * State switched to when successful.
17883 * @param {State} nok
17884 * State switched to when unsuccessful.
17885 * @param {TokenType} type
17886 * Type for whole (`<a>` or `b`).
17887 * @param {TokenType} literalType
17888 * Type when enclosed (`<a>`).
17889 * @param {TokenType} literalMarkerType
17890 * Type for enclosing (`<` and `>`).
17891 * @param {TokenType} rawType
17892 * Type when not enclosed (`b`).
17893 * @param {TokenType} stringType
17894 * Type for the value (`a` or `b`).
17895 * @param {number | undefined} [max=Infinity]
17896 * Depth of nested parens (inclusive).
17897 * @returns {State}
17898 * Start state.
17899 */ function factoryDestination(effects, ok, nok, type, literalType, literalMarkerType, rawType, stringType, max) {
17900 const limit = max || Number.POSITIVE_INFINITY;
17901 let balance = 0;
17902 return start;
17903 /**
17904 * Start of destination.
17905 *
17906 * ```markdown
17907 * > | <aa>
17908 * ^
17909 * > | aa
17910 * ^
17911 * ```
17912 *
17913 * @type {State}
17914 */
17915 function start(code) {
17916 if (code === 60) {
17917 effects.enter(type);
17918 effects.enter(literalType);
17919 effects.enter(literalMarkerType);
17920 effects.consume(code);
17921 effects.exit(literalMarkerType);
17922 return enclosedBefore;
17923 }
17924 if (code === null || code === 32 || code === 41 || asciiControl(code)) return nok(code);
17925 effects.enter(type);
17926 effects.enter(rawType);
17927 effects.enter(stringType);
17928 effects.enter("chunkString", { contentType: "string" });
17929 return raw(code);
17930 }
17931 /**
17932 * After `<`, at an enclosed destination.
17933 *
17934 * ```markdown
17935 * > | <aa>
17936 * ^
17937 * ```
17938 *
17939 * @type {State}
17940 */
17941 function enclosedBefore(code) {
17942 if (code === 62) {
17943 effects.enter(literalMarkerType);
17944 effects.consume(code);
17945 effects.exit(literalMarkerType);
17946 effects.exit(literalType);
17947 effects.exit(type);
17948 return ok;
17949 }
17950 effects.enter(stringType);
17951 effects.enter("chunkString", { contentType: "string" });
17952 return enclosed(code);
17953 }
17954 /**
17955 * In enclosed destination.
17956 *
17957 * ```markdown
17958 * > | <aa>
17959 * ^
17960 * ```
17961 *
17962 * @type {State}
17963 */
17964 function enclosed(code) {
17965 if (code === 62) {
17966 effects.exit("chunkString");
17967 effects.exit(stringType);
17968 return enclosedBefore(code);
17969 }
17970 if (code === null || code === 60 || markdownLineEnding(code)) return nok(code);
17971 effects.consume(code);
17972 return code === 92 ? enclosedEscape : enclosed;
17973 }
17974 /**
17975 * After `\`, at a special character.
17976 *
17977 * ```markdown
17978 * > | <a\*a>
17979 * ^
17980 * ```
17981 *
17982 * @type {State}
17983 */
17984 function enclosedEscape(code) {
17985 if (code === 60 || code === 62 || code === 92) {
17986 effects.consume(code);
17987 return enclosed;
17988 }
17989 return enclosed(code);
17990 }
17991 /**
17992 * In raw destination.
17993 *
17994 * ```markdown
17995 * > | aa
17996 * ^
17997 * ```
17998 *
17999 * @type {State}
18000 */
18001 function raw(code) {
18002 if (!balance && (code === null || code === 41 || markdownLineEndingOrSpace(code))) {
18003 effects.exit("chunkString");
18004 effects.exit(stringType);
18005 effects.exit(rawType);
18006 effects.exit(type);
18007 return ok(code);
18008 }
18009 if (balance < limit && code === 40) {
18010 effects.consume(code);
18011 balance++;
18012 return raw;
18013 }
18014 if (code === 41) {
18015 effects.consume(code);
18016 balance--;
18017 return raw;
18018 }
18019 if (code === null || code === 32 || code === 40 || asciiControl(code)) return nok(code);
18020 effects.consume(code);
18021 return code === 92 ? rawEscape : raw;
18022 }
18023 /**
18024 * After `\`, at special character.
18025 *
18026 * ```markdown
18027 * > | a\*a
18028 * ^
18029 * ```
18030 *
18031 * @type {State}
18032 */
18033 function rawEscape(code) {
18034 if (code === 40 || code === 41 || code === 92) {
18035 effects.consume(code);
18036 return raw;
18037 }
18038 return raw(code);
18039 }
18040 }
18041 var init_micromark_factory_destination = __esmMin((() => {
18042 init_micromark_util_character();
18043 }));
18044
18045 //#endregion
18046 //#region node_modules/micromark-factory-label/index.js
18047 /**
18048 * Parse labels.
18049 *
18050 * > 👉 **Note**: labels in markdown are capped at 999 characters in the string.
18051 *
18052 * ###### Examples
18053 *
18054 * ```markdown
18055 * [a]
18056 * [a
18057 * b]
18058 * [a\]b]
18059 * ```
18060 *
18061 * @this {TokenizeContext}
18062 * Tokenize context.
18063 * @param {Effects} effects
18064 * Context.
18065 * @param {State} ok
18066 * State switched to when successful.
18067 * @param {State} nok
18068 * State switched to when unsuccessful.
18069 * @param {TokenType} type
18070 * Type of the whole label (`[a]`).
18071 * @param {TokenType} markerType
18072 * Type for the markers (`[` and `]`).
18073 * @param {TokenType} stringType
18074 * Type for the identifier (`a`).
18075 * @returns {State}
18076 * Start state.
18077 */ function factoryLabel(effects, ok, nok, type, markerType, stringType) {
18078 const self = this;
18079 let size = 0;
18080 /** @type {boolean} */
18081 let seen;
18082 return start;
18083 /**
18084 * Start of label.
18085 *
18086 * ```markdown
18087 * > | [a]
18088 * ^
18089 * ```
18090 *
18091 * @type {State}
18092 */
18093 function start(code) {
18094 effects.enter(type);
18095 effects.enter(markerType);
18096 effects.consume(code);
18097 effects.exit(markerType);
18098 effects.enter(stringType);
18099 return atBreak;
18100 }
18101 /**
18102 * In label, at something, before something else.
18103 *
18104 * ```markdown
18105 * > | [a]
18106 * ^
18107 * ```
18108 *
18109 * @type {State}
18110 */
18111 function atBreak(code) {
18112 if (size > 999 || code === null || code === 91 || code === 93 && !seen || code === 94 && !size && "_hiddenFootnoteSupport" in self.parser.constructs) return nok(code);
18113 if (code === 93) {
18114 effects.exit(stringType);
18115 effects.enter(markerType);
18116 effects.consume(code);
18117 effects.exit(markerType);
18118 effects.exit(type);
18119 return ok;
18120 }
18121 if (markdownLineEnding(code)) {
18122 effects.enter("lineEnding");
18123 effects.consume(code);
18124 effects.exit("lineEnding");
18125 return atBreak;
18126 }
18127 effects.enter("chunkString", { contentType: "string" });
18128 return labelInside(code);
18129 }
18130 /**
18131 * In label, in text.
18132 *
18133 * ```markdown
18134 * > | [a]
18135 * ^
18136 * ```
18137 *
18138 * @type {State}
18139 */
18140 function labelInside(code) {
18141 if (code === null || code === 91 || code === 93 || markdownLineEnding(code) || size++ > 999) {
18142 effects.exit("chunkString");
18143 return atBreak(code);
18144 }
18145 effects.consume(code);
18146 if (!seen) seen = !markdownSpace(code);
18147 return code === 92 ? labelEscape : labelInside;
18148 }
18149 /**
18150 * After `\`, at a special character.
18151 *
18152 * ```markdown
18153 * > | [a\*a]
18154 * ^
18155 * ```
18156 *
18157 * @type {State}
18158 */
18159 function labelEscape(code) {
18160 if (code === 91 || code === 92 || code === 93) {
18161 effects.consume(code);
18162 size++;
18163 return labelInside;
18164 }
18165 return labelInside(code);
18166 }
18167 }
18168 var init_micromark_factory_label = __esmMin((() => {
18169 init_micromark_util_character();
18170 }));
18171
18172 //#endregion
18173 //#region node_modules/micromark-factory-title/index.js
18174 /**
18175 * Parse titles.
18176 *
18177 * ###### Examples
18178 *
18179 * ```markdown
18180 * "a"
18181 * 'b'
18182 * (c)
18183 * "a
18184 * b"
18185 * 'a
18186 * b'
18187 * (a\)b)
18188 * ```
18189 *
18190 * @param {Effects} effects
18191 * Context.
18192 * @param {State} ok
18193 * State switched to when successful.
18194 * @param {State} nok
18195 * State switched to when unsuccessful.
18196 * @param {TokenType} type
18197 * Type of the whole title (`"a"`, `'b'`, `(c)`).
18198 * @param {TokenType} markerType
18199 * Type for the markers (`"`, `'`, `(`, and `)`).
18200 * @param {TokenType} stringType
18201 * Type for the value (`a`).
18202 * @returns {State}
18203 * Start state.
18204 */ function factoryTitle(effects, ok, nok, type, markerType, stringType) {
18205 /** @type {NonNullable<Code>} */
18206 let marker;
18207 return start;
18208 /**
18209 * Start of title.
18210 *
18211 * ```markdown
18212 * > | "a"
18213 * ^
18214 * ```
18215 *
18216 * @type {State}
18217 */
18218 function start(code) {
18219 if (code === 34 || code === 39 || code === 40) {
18220 effects.enter(type);
18221 effects.enter(markerType);
18222 effects.consume(code);
18223 effects.exit(markerType);
18224 marker = code === 40 ? 41 : code;
18225 return begin;
18226 }
18227 return nok(code);
18228 }
18229 /**
18230 * After opening marker.
18231 *
18232 * This is also used at the closing marker.
18233 *
18234 * ```markdown
18235 * > | "a"
18236 * ^
18237 * ```
18238 *
18239 * @type {State}
18240 */
18241 function begin(code) {
18242 if (code === marker) {
18243 effects.enter(markerType);
18244 effects.consume(code);
18245 effects.exit(markerType);
18246 effects.exit(type);
18247 return ok;
18248 }
18249 effects.enter(stringType);
18250 return atBreak(code);
18251 }
18252 /**
18253 * At something, before something else.
18254 *
18255 * ```markdown
18256 * > | "a"
18257 * ^
18258 * ```
18259 *
18260 * @type {State}
18261 */
18262 function atBreak(code) {
18263 if (code === marker) {
18264 effects.exit(stringType);
18265 return begin(marker);
18266 }
18267 if (code === null) return nok(code);
18268 if (markdownLineEnding(code)) {
18269 effects.enter("lineEnding");
18270 effects.consume(code);
18271 effects.exit("lineEnding");
18272 return factorySpace(effects, atBreak, "linePrefix");
18273 }
18274 effects.enter("chunkString", { contentType: "string" });
18275 return inside(code);
18276 }
18277 /**
18278 *
18279 *
18280 * @type {State}
18281 */
18282 function inside(code) {
18283 if (code === marker || code === null || markdownLineEnding(code)) {
18284 effects.exit("chunkString");
18285 return atBreak(code);
18286 }
18287 effects.consume(code);
18288 return code === 92 ? escape : inside;
18289 }
18290 /**
18291 * After `\`, at a special character.
18292 *
18293 * ```markdown
18294 * > | "a\*b"
18295 * ^
18296 * ```
18297 *
18298 * @type {State}
18299 */
18300 function escape(code) {
18301 if (code === marker || code === 92) {
18302 effects.consume(code);
18303 return inside;
18304 }
18305 return inside(code);
18306 }
18307 }
18308 var init_micromark_factory_title = __esmMin((() => {
18309 init_micromark_factory_space();
18310 init_micromark_util_character();
18311 }));
18312
18313 //#endregion
18314 //#region node_modules/micromark-factory-whitespace/index.js
18315 /**
18316 * Parse spaces and tabs.
18317 *
18318 * There is no `nok` parameter:
18319 *
18320 * * line endings or spaces in markdown are often optional, in which case this
18321 * factory can be used and `ok` will be switched to whether spaces were found
18322 * or not
18323 * * one line ending or space can be detected with
18324 * `markdownLineEndingOrSpace(code)` right before using `factoryWhitespace`
18325 *
18326 * @param {Effects} effects
18327 * Context.
18328 * @param {State} ok
18329 * State switched to when successful.
18330 * @returns
18331 * Start state.
18332 */
18333 function factoryWhitespace(effects, ok) {
18334 /** @type {boolean} */
18335 let seen;
18336 return start;
18337 /** @type {State} */
18338 function start(code) {
18339 if (markdownLineEnding(code)) {
18340 effects.enter("lineEnding");
18341 effects.consume(code);
18342 effects.exit("lineEnding");
18343 seen = true;
18344 return start;
18345 }
18346 if (markdownSpace(code)) return factorySpace(effects, start, seen ? "linePrefix" : "lineSuffix")(code);
18347 return ok(code);
18348 }
18349 }
18350 var init_micromark_factory_whitespace = __esmMin((() => {
18351 init_micromark_factory_space();
18352 init_micromark_util_character();
18353 }));
18354
18355 //#endregion
18356 //#region node_modules/micromark-util-normalize-identifier/index.js
18357 /**
18358 * Normalize an identifier (as found in references, definitions).
18359 *
18360 * Collapses markdown whitespace, trim, and then lower- and uppercase.
18361 *
18362 * Some characters are considered “uppercase”, such as U+03F4 (`ϴ`), but if their
18363 * lowercase counterpart (U+03B8 (`θ`)) is uppercased will result in a different
18364 * uppercase character (U+0398 (`Θ`)).
18365 * So, to get a canonical form, we perform both lower- and uppercase.
18366 *
18367 * Using uppercase last makes sure keys will never interact with default
18368 * prototypal values (such as `constructor`): nothing in the prototype of
18369 * `Object` is uppercase.
18370 *
18371 * @param {string} value
18372 * Identifier to normalize.
18373 * @returns {string}
18374 * Normalized identifier.
18375 */
18376 function normalizeIdentifier(value) {
18377 return value.replace(/[\t\n\r ]+/g, " ").replace(/^ | $/g, "").toLowerCase().toUpperCase();
18378 }
18379 var init_micromark_util_normalize_identifier = __esmMin((() => {}));
18380
18381 //#endregion
18382 //#region node_modules/micromark-core-commonmark/lib/definition.js
18383 /**
18384 * @this {TokenizeContext}
18385 * @type {Tokenizer}
18386 */
18387 function tokenizeDefinition(effects, ok, nok) {
18388 const self = this;
18389 /** @type {string} */
18390 let identifier;
18391 return start;
18392 /**
18393 * At start of a definition.
18394 *
18395 * ```markdown
18396 * > | [a]: b "c"
18397 * ^
18398 * ```
18399 *
18400 * @type {State}
18401 */
18402 function start(code) {
18403 effects.enter("definition");
18404 return before(code);
18405 }
18406 /**
18407 * After optional whitespace, at `[`.
18408 *
18409 * ```markdown
18410 * > | [a]: b "c"
18411 * ^
18412 * ```
18413 *
18414 * @type {State}
18415 */
18416 function before(code) {
18417 return factoryLabel.call(self, effects, labelAfter, nok, "definitionLabel", "definitionLabelMarker", "definitionLabelString")(code);
18418 }
18419 /**
18420 * After label.
18421 *
18422 * ```markdown
18423 * > | [a]: b "c"
18424 * ^
18425 * ```
18426 *
18427 * @type {State}
18428 */
18429 function labelAfter(code) {
18430 identifier = normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1));
18431 if (code === 58) {
18432 effects.enter("definitionMarker");
18433 effects.consume(code);
18434 effects.exit("definitionMarker");
18435 return markerAfter;
18436 }
18437 return nok(code);
18438 }
18439 /**
18440 * After marker.
18441 *
18442 * ```markdown
18443 * > | [a]: b "c"
18444 * ^
18445 * ```
18446 *
18447 * @type {State}
18448 */
18449 function markerAfter(code) {
18450 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, destinationBefore)(code) : destinationBefore(code);
18451 }
18452 /**
18453 * Before destination.
18454 *
18455 * ```markdown
18456 * > | [a]: b "c"
18457 * ^
18458 * ```
18459 *
18460 * @type {State}
18461 */
18462 function destinationBefore(code) {
18463 return factoryDestination(effects, destinationAfter, nok, "definitionDestination", "definitionDestinationLiteral", "definitionDestinationLiteralMarker", "definitionDestinationRaw", "definitionDestinationString")(code);
18464 }
18465 /**
18466 * After destination.
18467 *
18468 * ```markdown
18469 * > | [a]: b "c"
18470 * ^
18471 * ```
18472 *
18473 * @type {State}
18474 */
18475 function destinationAfter(code) {
18476 return effects.attempt(titleBefore, after, after)(code);
18477 }
18478 /**
18479 * After definition.
18480 *
18481 * ```markdown
18482 * > | [a]: b
18483 * ^
18484 * > | [a]: b "c"
18485 * ^
18486 * ```
18487 *
18488 * @type {State}
18489 */
18490 function after(code) {
18491 return markdownSpace(code) ? factorySpace(effects, afterWhitespace, "whitespace")(code) : afterWhitespace(code);
18492 }
18493 /**
18494 * After definition, after optional whitespace.
18495 *
18496 * ```markdown
18497 * > | [a]: b
18498 * ^
18499 * > | [a]: b "c"
18500 * ^
18501 * ```
18502 *
18503 * @type {State}
18504 */
18505 function afterWhitespace(code) {
18506 if (code === null || markdownLineEnding(code)) {
18507 effects.exit("definition");
18508 self.parser.defined.push(identifier);
18509 return ok(code);
18510 }
18511 return nok(code);
18512 }
18513 }
18514 /**
18515 * @this {TokenizeContext}
18516 * @type {Tokenizer}
18517 */
18518 function tokenizeTitleBefore(effects, ok, nok) {
18519 return titleBefore;
18520 /**
18521 * After destination, at whitespace.
18522 *
18523 * ```markdown
18524 * > | [a]: b
18525 * ^
18526 * > | [a]: b "c"
18527 * ^
18528 * ```
18529 *
18530 * @type {State}
18531 */
18532 function titleBefore(code) {
18533 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, beforeMarker)(code) : nok(code);
18534 }
18535 /**
18536 * At title.
18537 *
18538 * ```markdown
18539 * | [a]: b
18540 * > | "c"
18541 * ^
18542 * ```
18543 *
18544 * @type {State}
18545 */
18546 function beforeMarker(code) {
18547 return factoryTitle(effects, titleAfter, nok, "definitionTitle", "definitionTitleMarker", "definitionTitleString")(code);
18548 }
18549 /**
18550 * After title.
18551 *
18552 * ```markdown
18553 * > | [a]: b "c"
18554 * ^
18555 * ```
18556 *
18557 * @type {State}
18558 */
18559 function titleAfter(code) {
18560 return markdownSpace(code) ? factorySpace(effects, titleAfterOptionalWhitespace, "whitespace")(code) : titleAfterOptionalWhitespace(code);
18561 }
18562 /**
18563 * After title, after optional whitespace.
18564 *
18565 * ```markdown
18566 * > | [a]: b "c"
18567 * ^
18568 * ```
18569 *
18570 * @type {State}
18571 */
18572 function titleAfterOptionalWhitespace(code) {
18573 return code === null || markdownLineEnding(code) ? ok(code) : nok(code);
18574 }
18575 }
18576 var definition, titleBefore;
18577 var init_definition = __esmMin((() => {
18578 init_micromark_factory_destination();
18579 init_micromark_factory_label();
18580 init_micromark_factory_space();
18581 init_micromark_factory_title();
18582 init_micromark_factory_whitespace();
18583 init_micromark_util_character();
18584 init_micromark_util_normalize_identifier();
18585 definition = {
18586 name: "definition",
18587 tokenize: tokenizeDefinition
18588 };
18589 titleBefore = {
18590 tokenize: tokenizeTitleBefore,
18591 partial: true
18592 };
18593 }));
18594
18595 //#endregion
18596 //#region node_modules/micromark-core-commonmark/lib/hard-break-escape.js
18597 /**
18598 * @this {TokenizeContext}
18599 * @type {Tokenizer}
18600 */
18601 function tokenizeHardBreakEscape(effects, ok, nok) {
18602 return start;
18603 /**
18604 * Start of a hard break (escape).
18605 *
18606 * ```markdown
18607 * > | a\
18608 * ^
18609 * | b
18610 * ```
18611 *
18612 * @type {State}
18613 */
18614 function start(code) {
18615 effects.enter("hardBreakEscape");
18616 effects.consume(code);
18617 return after;
18618 }
18619 /**
18620 * After `\`, at eol.
18621 *
18622 * ```markdown
18623 * > | a\
18624 * ^
18625 * | b
18626 * ```
18627 *
18628 * @type {State}
18629 */
18630 function after(code) {
18631 if (markdownLineEnding(code)) {
18632 effects.exit("hardBreakEscape");
18633 return ok(code);
18634 }
18635 return nok(code);
18636 }
18637 }
18638 var hardBreakEscape;
18639 var init_hard_break_escape = __esmMin((() => {
18640 init_micromark_util_character();
18641 hardBreakEscape = {
18642 name: "hardBreakEscape",
18643 tokenize: tokenizeHardBreakEscape
18644 };
18645 }));
18646
18647 //#endregion
18648 //#region node_modules/micromark-core-commonmark/lib/heading-atx.js
18649 /** @type {Resolver} */
18650 function resolveHeadingAtx(events, context) {
18651 let contentEnd = events.length - 2;
18652 let contentStart = 3;
18653 /** @type {Token} */
18654 let content;
18655 /** @type {Token} */
18656 let text;
18657 if (events[contentStart][1].type === "whitespace") contentStart += 2;
18658 if (contentEnd - 2 > contentStart && events[contentEnd][1].type === "whitespace") contentEnd -= 2;
18659 if (events[contentEnd][1].type === "atxHeadingSequence" && (contentStart === contentEnd - 1 || contentEnd - 4 > contentStart && events[contentEnd - 2][1].type === "whitespace")) contentEnd -= contentStart + 1 === contentEnd ? 2 : 4;
18660 if (contentEnd > contentStart) {
18661 content = {
18662 type: "atxHeadingText",
18663 start: events[contentStart][1].start,
18664 end: events[contentEnd][1].end
18665 };
18666 text = {
18667 type: "chunkText",
18668 start: events[contentStart][1].start,
18669 end: events[contentEnd][1].end,
18670 contentType: "text"
18671 };
18672 splice(events, contentStart, contentEnd - contentStart + 1, [
18673 [
18674 "enter",
18675 content,
18676 context
18677 ],
18678 [
18679 "enter",
18680 text,
18681 context
18682 ],
18683 [
18684 "exit",
18685 text,
18686 context
18687 ],
18688 [
18689 "exit",
18690 content,
18691 context
18692 ]
18693 ]);
18694 }
18695 return events;
18696 }
18697 /**
18698 * @this {TokenizeContext}
18699 * @type {Tokenizer}
18700 */
18701 function tokenizeHeadingAtx(effects, ok, nok) {
18702 let size = 0;
18703 return start;
18704 /**
18705 * Start of a heading (atx).
18706 *
18707 * ```markdown
18708 * > | ## aa
18709 * ^
18710 * ```
18711 *
18712 * @type {State}
18713 */
18714 function start(code) {
18715 effects.enter("atxHeading");
18716 return before(code);
18717 }
18718 /**
18719 * After optional whitespace, at `#`.
18720 *
18721 * ```markdown
18722 * > | ## aa
18723 * ^
18724 * ```
18725 *
18726 * @type {State}
18727 */
18728 function before(code) {
18729 effects.enter("atxHeadingSequence");
18730 return sequenceOpen(code);
18731 }
18732 /**
18733 * In opening sequence.
18734 *
18735 * ```markdown
18736 * > | ## aa
18737 * ^
18738 * ```
18739 *
18740 * @type {State}
18741 */
18742 function sequenceOpen(code) {
18743 if (code === 35 && size++ < 6) {
18744 effects.consume(code);
18745 return sequenceOpen;
18746 }
18747 if (code === null || markdownLineEndingOrSpace(code)) {
18748 effects.exit("atxHeadingSequence");
18749 return atBreak(code);
18750 }
18751 return nok(code);
18752 }
18753 /**
18754 * After something, before something else.
18755 *
18756 * ```markdown
18757 * > | ## aa
18758 * ^
18759 * ```
18760 *
18761 * @type {State}
18762 */
18763 function atBreak(code) {
18764 if (code === 35) {
18765 effects.enter("atxHeadingSequence");
18766 return sequenceFurther(code);
18767 }
18768 if (code === null || markdownLineEnding(code)) {
18769 effects.exit("atxHeading");
18770 return ok(code);
18771 }
18772 if (markdownSpace(code)) return factorySpace(effects, atBreak, "whitespace")(code);
18773 effects.enter("atxHeadingText");
18774 return data(code);
18775 }
18776 /**
18777 * In further sequence (after whitespace).
18778 *
18779 * Could be normal “visible” hashes in the heading or a final sequence.
18780 *
18781 * ```markdown
18782 * > | ## aa ##
18783 * ^
18784 * ```
18785 *
18786 * @type {State}
18787 */
18788 function sequenceFurther(code) {
18789 if (code === 35) {
18790 effects.consume(code);
18791 return sequenceFurther;
18792 }
18793 effects.exit("atxHeadingSequence");
18794 return atBreak(code);
18795 }
18796 /**
18797 * In text.
18798 *
18799 * ```markdown
18800 * > | ## aa
18801 * ^
18802 * ```
18803 *
18804 * @type {State}
18805 */
18806 function data(code) {
18807 if (code === null || code === 35 || markdownLineEndingOrSpace(code)) {
18808 effects.exit("atxHeadingText");
18809 return atBreak(code);
18810 }
18811 effects.consume(code);
18812 return data;
18813 }
18814 }
18815 var headingAtx;
18816 var init_heading_atx = __esmMin((() => {
18817 init_micromark_factory_space();
18818 init_micromark_util_character();
18819 init_micromark_util_chunked();
18820 headingAtx = {
18821 name: "headingAtx",
18822 tokenize: tokenizeHeadingAtx,
18823 resolve: resolveHeadingAtx
18824 };
18825 }));
18826
18827 //#endregion
18828 //#region node_modules/micromark-util-html-tag-name/index.js
18829 var htmlBlockNames, htmlRawNames;
18830 var init_micromark_util_html_tag_name = __esmMin((() => {
18831 htmlBlockNames = [
18832 "address",
18833 "article",
18834 "aside",
18835 "base",
18836 "basefont",
18837 "blockquote",
18838 "body",
18839 "caption",
18840 "center",
18841 "col",
18842 "colgroup",
18843 "dd",
18844 "details",
18845 "dialog",
18846 "dir",
18847 "div",
18848 "dl",
18849 "dt",
18850 "fieldset",
18851 "figcaption",
18852 "figure",
18853 "footer",
18854 "form",
18855 "frame",
18856 "frameset",
18857 "h1",
18858 "h2",
18859 "h3",
18860 "h4",
18861 "h5",
18862 "h6",
18863 "head",
18864 "header",
18865 "hr",
18866 "html",
18867 "iframe",
18868 "legend",
18869 "li",
18870 "link",
18871 "main",
18872 "menu",
18873 "menuitem",
18874 "nav",
18875 "noframes",
18876 "ol",
18877 "optgroup",
18878 "option",
18879 "p",
18880 "param",
18881 "search",
18882 "section",
18883 "summary",
18884 "table",
18885 "tbody",
18886 "td",
18887 "tfoot",
18888 "th",
18889 "thead",
18890 "title",
18891 "tr",
18892 "track",
18893 "ul"
18894 ];
18895 htmlRawNames = [
18896 "pre",
18897 "script",
18898 "style",
18899 "textarea"
18900 ];
18901 }));
18902
18903 //#endregion
18904 //#region node_modules/micromark-core-commonmark/lib/html-flow.js
18905 /** @type {Resolver} */
18906 function resolveToHtmlFlow(events) {
18907 let index = events.length;
18908 while (index--) if (events[index][0] === "enter" && events[index][1].type === "htmlFlow") break;
18909 if (index > 1 && events[index - 2][1].type === "linePrefix") {
18910 events[index][1].start = events[index - 2][1].start;
18911 events[index + 1][1].start = events[index - 2][1].start;
18912 events.splice(index - 2, 2);
18913 }
18914 return events;
18915 }
18916 /**
18917 * @this {TokenizeContext}
18918 * @type {Tokenizer}
18919 */
18920 function tokenizeHtmlFlow(effects, ok, nok) {
18921 const self = this;
18922 /** @type {number} */
18923 let marker;
18924 /** @type {boolean} */
18925 let closingTag;
18926 /** @type {string} */
18927 let buffer;
18928 /** @type {number} */
18929 let index;
18930 /** @type {Code} */
18931 let markerB;
18932 return start;
18933 /**
18934 * Start of HTML (flow).
18935 *
18936 * ```markdown
18937 * > | <x />
18938 * ^
18939 * ```
18940 *
18941 * @type {State}
18942 */
18943 function start(code) {
18944 return before(code);
18945 }
18946 /**
18947 * At `<`, after optional whitespace.
18948 *
18949 * ```markdown
18950 * > | <x />
18951 * ^
18952 * ```
18953 *
18954 * @type {State}
18955 */
18956 function before(code) {
18957 effects.enter("htmlFlow");
18958 effects.enter("htmlFlowData");
18959 effects.consume(code);
18960 return open;
18961 }
18962 /**
18963 * After `<`, at tag name or other stuff.
18964 *
18965 * ```markdown
18966 * > | <x />
18967 * ^
18968 * > | <!doctype>
18969 * ^
18970 * > | <!--xxx-->
18971 * ^
18972 * ```
18973 *
18974 * @type {State}
18975 */
18976 function open(code) {
18977 if (code === 33) {
18978 effects.consume(code);
18979 return declarationOpen;
18980 }
18981 if (code === 47) {
18982 effects.consume(code);
18983 closingTag = true;
18984 return tagCloseStart;
18985 }
18986 if (code === 63) {
18987 effects.consume(code);
18988 marker = 3;
18989 return self.interrupt ? ok : continuationDeclarationInside;
18990 }
18991 if (asciiAlpha(code)) {
18992 effects.consume(code);
18993 buffer = String.fromCharCode(code);
18994 return tagName;
18995 }
18996 return nok(code);
18997 }
18998 /**
18999 * After `<!`, at declaration, comment, or CDATA.
19000 *
19001 * ```markdown
19002 * > | <!doctype>
19003 * ^
19004 * > | <!--xxx-->
19005 * ^
19006 * > | <![CDATA[>&<]]>
19007 * ^
19008 * ```
19009 *
19010 * @type {State}
19011 */
19012 function declarationOpen(code) {
19013 if (code === 45) {
19014 effects.consume(code);
19015 marker = 2;
19016 return commentOpenInside;
19017 }
19018 if (code === 91) {
19019 effects.consume(code);
19020 marker = 5;
19021 index = 0;
19022 return cdataOpenInside;
19023 }
19024 if (asciiAlpha(code)) {
19025 effects.consume(code);
19026 marker = 4;
19027 return self.interrupt ? ok : continuationDeclarationInside;
19028 }
19029 return nok(code);
19030 }
19031 /**
19032 * After `<!-`, inside a comment, at another `-`.
19033 *
19034 * ```markdown
19035 * > | <!--xxx-->
19036 * ^
19037 * ```
19038 *
19039 * @type {State}
19040 */
19041 function commentOpenInside(code) {
19042 if (code === 45) {
19043 effects.consume(code);
19044 return self.interrupt ? ok : continuationDeclarationInside;
19045 }
19046 return nok(code);
19047 }
19048 /**
19049 * After `<![`, inside CDATA, expecting `CDATA[`.
19050 *
19051 * ```markdown
19052 * > | <![CDATA[>&<]]>
19053 * ^^^^^^
19054 * ```
19055 *
19056 * @type {State}
19057 */
19058 function cdataOpenInside(code) {
19059 if (code === "CDATA[".charCodeAt(index++)) {
19060 effects.consume(code);
19061 if (index === 6) return self.interrupt ? ok : continuation;
19062 return cdataOpenInside;
19063 }
19064 return nok(code);
19065 }
19066 /**
19067 * After `</`, in closing tag, at tag name.
19068 *
19069 * ```markdown
19070 * > | </x>
19071 * ^
19072 * ```
19073 *
19074 * @type {State}
19075 */
19076 function tagCloseStart(code) {
19077 if (asciiAlpha(code)) {
19078 effects.consume(code);
19079 buffer = String.fromCharCode(code);
19080 return tagName;
19081 }
19082 return nok(code);
19083 }
19084 /**
19085 * In tag name.
19086 *
19087 * ```markdown
19088 * > | <ab>
19089 * ^^
19090 * > | </ab>
19091 * ^^
19092 * ```
19093 *
19094 * @type {State}
19095 */
19096 function tagName(code) {
19097 if (code === null || code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
19098 const slash = code === 47;
19099 const name = buffer.toLowerCase();
19100 if (!slash && !closingTag && htmlRawNames.includes(name)) {
19101 marker = 1;
19102 return self.interrupt ? ok(code) : continuation(code);
19103 }
19104 if (htmlBlockNames.includes(buffer.toLowerCase())) {
19105 marker = 6;
19106 if (slash) {
19107 effects.consume(code);
19108 return basicSelfClosing;
19109 }
19110 return self.interrupt ? ok(code) : continuation(code);
19111 }
19112 marker = 7;
19113 return self.interrupt && !self.parser.lazy[self.now().line] ? nok(code) : closingTag ? completeClosingTagAfter(code) : completeAttributeNameBefore(code);
19114 }
19115 if (code === 45 || asciiAlphanumeric(code)) {
19116 effects.consume(code);
19117 buffer += String.fromCharCode(code);
19118 return tagName;
19119 }
19120 return nok(code);
19121 }
19122 /**
19123 * After closing slash of a basic tag name.
19124 *
19125 * ```markdown
19126 * > | <div/>
19127 * ^
19128 * ```
19129 *
19130 * @type {State}
19131 */
19132 function basicSelfClosing(code) {
19133 if (code === 62) {
19134 effects.consume(code);
19135 return self.interrupt ? ok : continuation;
19136 }
19137 return nok(code);
19138 }
19139 /**
19140 * After closing slash of a complete tag name.
19141 *
19142 * ```markdown
19143 * > | <x/>
19144 * ^
19145 * ```
19146 *
19147 * @type {State}
19148 */
19149 function completeClosingTagAfter(code) {
19150 if (markdownSpace(code)) {
19151 effects.consume(code);
19152 return completeClosingTagAfter;
19153 }
19154 return completeEnd(code);
19155 }
19156 /**
19157 * At an attribute name.
19158 *
19159 * At first, this state is used after a complete tag name, after whitespace,
19160 * where it expects optional attributes or the end of the tag.
19161 * It is also reused after attributes, when expecting more optional
19162 * attributes.
19163 *
19164 * ```markdown
19165 * > | <a />
19166 * ^
19167 * > | <a :b>
19168 * ^
19169 * > | <a _b>
19170 * ^
19171 * > | <a b>
19172 * ^
19173 * > | <a >
19174 * ^
19175 * ```
19176 *
19177 * @type {State}
19178 */
19179 function completeAttributeNameBefore(code) {
19180 if (code === 47) {
19181 effects.consume(code);
19182 return completeEnd;
19183 }
19184 if (code === 58 || code === 95 || asciiAlpha(code)) {
19185 effects.consume(code);
19186 return completeAttributeName;
19187 }
19188 if (markdownSpace(code)) {
19189 effects.consume(code);
19190 return completeAttributeNameBefore;
19191 }
19192 return completeEnd(code);
19193 }
19194 /**
19195 * In attribute name.
19196 *
19197 * ```markdown
19198 * > | <a :b>
19199 * ^
19200 * > | <a _b>
19201 * ^
19202 * > | <a b>
19203 * ^
19204 * ```
19205 *
19206 * @type {State}
19207 */
19208 function completeAttributeName(code) {
19209 if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) {
19210 effects.consume(code);
19211 return completeAttributeName;
19212 }
19213 return completeAttributeNameAfter(code);
19214 }
19215 /**
19216 * After attribute name, at an optional initializer, the end of the tag, or
19217 * whitespace.
19218 *
19219 * ```markdown
19220 * > | <a b>
19221 * ^
19222 * > | <a b=c>
19223 * ^
19224 * ```
19225 *
19226 * @type {State}
19227 */
19228 function completeAttributeNameAfter(code) {
19229 if (code === 61) {
19230 effects.consume(code);
19231 return completeAttributeValueBefore;
19232 }
19233 if (markdownSpace(code)) {
19234 effects.consume(code);
19235 return completeAttributeNameAfter;
19236 }
19237 return completeAttributeNameBefore(code);
19238 }
19239 /**
19240 * Before unquoted, double quoted, or single quoted attribute value, allowing
19241 * whitespace.
19242 *
19243 * ```markdown
19244 * > | <a b=c>
19245 * ^
19246 * > | <a b="c">
19247 * ^
19248 * ```
19249 *
19250 * @type {State}
19251 */
19252 function completeAttributeValueBefore(code) {
19253 if (code === null || code === 60 || code === 61 || code === 62 || code === 96) return nok(code);
19254 if (code === 34 || code === 39) {
19255 effects.consume(code);
19256 markerB = code;
19257 return completeAttributeValueQuoted;
19258 }
19259 if (markdownSpace(code)) {
19260 effects.consume(code);
19261 return completeAttributeValueBefore;
19262 }
19263 return completeAttributeValueUnquoted(code);
19264 }
19265 /**
19266 * In double or single quoted attribute value.
19267 *
19268 * ```markdown
19269 * > | <a b="c">
19270 * ^
19271 * > | <a b='c'>
19272 * ^
19273 * ```
19274 *
19275 * @type {State}
19276 */
19277 function completeAttributeValueQuoted(code) {
19278 if (code === markerB) {
19279 effects.consume(code);
19280 markerB = null;
19281 return completeAttributeValueQuotedAfter;
19282 }
19283 if (code === null || markdownLineEnding(code)) return nok(code);
19284 effects.consume(code);
19285 return completeAttributeValueQuoted;
19286 }
19287 /**
19288 * In unquoted attribute value.
19289 *
19290 * ```markdown
19291 * > | <a b=c>
19292 * ^
19293 * ```
19294 *
19295 * @type {State}
19296 */
19297 function completeAttributeValueUnquoted(code) {
19298 if (code === null || code === 34 || code === 39 || code === 47 || code === 60 || code === 61 || code === 62 || code === 96 || markdownLineEndingOrSpace(code)) return completeAttributeNameAfter(code);
19299 effects.consume(code);
19300 return completeAttributeValueUnquoted;
19301 }
19302 /**
19303 * After double or single quoted attribute value, before whitespace or the
19304 * end of the tag.
19305 *
19306 * ```markdown
19307 * > | <a b="c">
19308 * ^
19309 * ```
19310 *
19311 * @type {State}
19312 */
19313 function completeAttributeValueQuotedAfter(code) {
19314 if (code === 47 || code === 62 || markdownSpace(code)) return completeAttributeNameBefore(code);
19315 return nok(code);
19316 }
19317 /**
19318 * In certain circumstances of a complete tag where only an `>` is allowed.
19319 *
19320 * ```markdown
19321 * > | <a b="c">
19322 * ^
19323 * ```
19324 *
19325 * @type {State}
19326 */
19327 function completeEnd(code) {
19328 if (code === 62) {
19329 effects.consume(code);
19330 return completeAfter;
19331 }
19332 return nok(code);
19333 }
19334 /**
19335 * After `>` in a complete tag.
19336 *
19337 * ```markdown
19338 * > | <x>
19339 * ^
19340 * ```
19341 *
19342 * @type {State}
19343 */
19344 function completeAfter(code) {
19345 if (code === null || markdownLineEnding(code)) return continuation(code);
19346 if (markdownSpace(code)) {
19347 effects.consume(code);
19348 return completeAfter;
19349 }
19350 return nok(code);
19351 }
19352 /**
19353 * In continuation of any HTML kind.
19354 *
19355 * ```markdown
19356 * > | <!--xxx-->
19357 * ^
19358 * ```
19359 *
19360 * @type {State}
19361 */
19362 function continuation(code) {
19363 if (code === 45 && marker === 2) {
19364 effects.consume(code);
19365 return continuationCommentInside;
19366 }
19367 if (code === 60 && marker === 1) {
19368 effects.consume(code);
19369 return continuationRawTagOpen;
19370 }
19371 if (code === 62 && marker === 4) {
19372 effects.consume(code);
19373 return continuationClose;
19374 }
19375 if (code === 63 && marker === 3) {
19376 effects.consume(code);
19377 return continuationDeclarationInside;
19378 }
19379 if (code === 93 && marker === 5) {
19380 effects.consume(code);
19381 return continuationCdataInside;
19382 }
19383 if (markdownLineEnding(code) && (marker === 6 || marker === 7)) {
19384 effects.exit("htmlFlowData");
19385 return effects.check(blankLineBefore, continuationAfter, continuationStart)(code);
19386 }
19387 if (code === null || markdownLineEnding(code)) {
19388 effects.exit("htmlFlowData");
19389 return continuationStart(code);
19390 }
19391 effects.consume(code);
19392 return continuation;
19393 }
19394 /**
19395 * In continuation, at eol.
19396 *
19397 * ```markdown
19398 * > | <x>
19399 * ^
19400 * | asd
19401 * ```
19402 *
19403 * @type {State}
19404 */
19405 function continuationStart(code) {
19406 return effects.check(nonLazyContinuationStart, continuationStartNonLazy, continuationAfter)(code);
19407 }
19408 /**
19409 * In continuation, at eol, before non-lazy content.
19410 *
19411 * ```markdown
19412 * > | <x>
19413 * ^
19414 * | asd
19415 * ```
19416 *
19417 * @type {State}
19418 */
19419 function continuationStartNonLazy(code) {
19420 effects.enter("lineEnding");
19421 effects.consume(code);
19422 effects.exit("lineEnding");
19423 return continuationBefore;
19424 }
19425 /**
19426 * In continuation, before non-lazy content.
19427 *
19428 * ```markdown
19429 * | <x>
19430 * > | asd
19431 * ^
19432 * ```
19433 *
19434 * @type {State}
19435 */
19436 function continuationBefore(code) {
19437 if (code === null || markdownLineEnding(code)) return continuationStart(code);
19438 effects.enter("htmlFlowData");
19439 return continuation(code);
19440 }
19441 /**
19442 * In comment continuation, after one `-`, expecting another.
19443 *
19444 * ```markdown
19445 * > | <!--xxx-->
19446 * ^
19447 * ```
19448 *
19449 * @type {State}
19450 */
19451 function continuationCommentInside(code) {
19452 if (code === 45) {
19453 effects.consume(code);
19454 return continuationDeclarationInside;
19455 }
19456 return continuation(code);
19457 }
19458 /**
19459 * In raw continuation, after `<`, at `/`.
19460 *
19461 * ```markdown
19462 * > | <script>console.log(1)<\/script>
19463 * ^
19464 * ```
19465 *
19466 * @type {State}
19467 */
19468 function continuationRawTagOpen(code) {
19469 if (code === 47) {
19470 effects.consume(code);
19471 buffer = "";
19472 return continuationRawEndTag;
19473 }
19474 return continuation(code);
19475 }
19476 /**
19477 * In raw continuation, after `</`, in a raw tag name.
19478 *
19479 * ```markdown
19480 * > | <script>console.log(1)<\/script>
19481 * ^^^^^^
19482 * ```
19483 *
19484 * @type {State}
19485 */
19486 function continuationRawEndTag(code) {
19487 if (code === 62) {
19488 const name = buffer.toLowerCase();
19489 if (htmlRawNames.includes(name)) {
19490 effects.consume(code);
19491 return continuationClose;
19492 }
19493 return continuation(code);
19494 }
19495 if (asciiAlpha(code) && buffer.length < 8) {
19496 effects.consume(code);
19497 buffer += String.fromCharCode(code);
19498 return continuationRawEndTag;
19499 }
19500 return continuation(code);
19501 }
19502 /**
19503 * In cdata continuation, after `]`, expecting `]>`.
19504 *
19505 * ```markdown
19506 * > | <![CDATA[>&<]]>
19507 * ^
19508 * ```
19509 *
19510 * @type {State}
19511 */
19512 function continuationCdataInside(code) {
19513 if (code === 93) {
19514 effects.consume(code);
19515 return continuationDeclarationInside;
19516 }
19517 return continuation(code);
19518 }
19519 /**
19520 * In declaration or instruction continuation, at `>`.
19521 *
19522 * ```markdown
19523 * > | <!-->
19524 * ^
19525 * > | <?>
19526 * ^
19527 * > | <!q>
19528 * ^
19529 * > | <!--ab-->
19530 * ^
19531 * > | <![CDATA[>&<]]>
19532 * ^
19533 * ```
19534 *
19535 * @type {State}
19536 */
19537 function continuationDeclarationInside(code) {
19538 if (code === 62) {
19539 effects.consume(code);
19540 return continuationClose;
19541 }
19542 if (code === 45 && marker === 2) {
19543 effects.consume(code);
19544 return continuationDeclarationInside;
19545 }
19546 return continuation(code);
19547 }
19548 /**
19549 * In closed continuation: everything we get until the eol/eof is part of it.
19550 *
19551 * ```markdown
19552 * > | <!doctype>
19553 * ^
19554 * ```
19555 *
19556 * @type {State}
19557 */
19558 function continuationClose(code) {
19559 if (code === null || markdownLineEnding(code)) {
19560 effects.exit("htmlFlowData");
19561 return continuationAfter(code);
19562 }
19563 effects.consume(code);
19564 return continuationClose;
19565 }
19566 /**
19567 * Done.
19568 *
19569 * ```markdown
19570 * > | <!doctype>
19571 * ^
19572 * ```
19573 *
19574 * @type {State}
19575 */
19576 function continuationAfter(code) {
19577 effects.exit("htmlFlow");
19578 return ok(code);
19579 }
19580 }
19581 /**
19582 * @this {TokenizeContext}
19583 * @type {Tokenizer}
19584 */
19585 function tokenizeNonLazyContinuationStart(effects, ok, nok) {
19586 const self = this;
19587 return start;
19588 /**
19589 * At eol, before continuation.
19590 *
19591 * ```markdown
19592 * > | * ```js
19593 * ^
19594 * | b
19595 * ```
19596 *
19597 * @type {State}
19598 */
19599 function start(code) {
19600 if (markdownLineEnding(code)) {
19601 effects.enter("lineEnding");
19602 effects.consume(code);
19603 effects.exit("lineEnding");
19604 return after;
19605 }
19606 return nok(code);
19607 }
19608 /**
19609 * A continuation.
19610 *
19611 * ```markdown
19612 * | * ```js
19613 * > | b
19614 * ^
19615 * ```
19616 *
19617 * @type {State}
19618 */
19619 function after(code) {
19620 return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
19621 }
19622 }
19623 /**
19624 * @this {TokenizeContext}
19625 * @type {Tokenizer}
19626 */
19627 function tokenizeBlankLineBefore(effects, ok, nok) {
19628 return start;
19629 /**
19630 * Before eol, expecting blank line.
19631 *
19632 * ```markdown
19633 * > | <div>
19634 * ^
19635 * |
19636 * ```
19637 *
19638 * @type {State}
19639 */
19640 function start(code) {
19641 effects.enter("lineEnding");
19642 effects.consume(code);
19643 effects.exit("lineEnding");
19644 return effects.attempt(blankLine, ok, nok);
19645 }
19646 }
19647 var htmlFlow, blankLineBefore, nonLazyContinuationStart;
19648 var init_html_flow = __esmMin((() => {
19649 init_micromark_util_character();
19650 init_micromark_util_html_tag_name();
19651 init_blank_line();
19652 htmlFlow = {
19653 name: "htmlFlow",
19654 tokenize: tokenizeHtmlFlow,
19655 resolveTo: resolveToHtmlFlow,
19656 concrete: true
19657 };
19658 blankLineBefore = {
19659 tokenize: tokenizeBlankLineBefore,
19660 partial: true
19661 };
19662 nonLazyContinuationStart = {
19663 tokenize: tokenizeNonLazyContinuationStart,
19664 partial: true
19665 };
19666 }));
19667
19668 //#endregion
19669 //#region node_modules/micromark-core-commonmark/lib/html-text.js
19670 /**
19671 * @this {TokenizeContext}
19672 * @type {Tokenizer}
19673 */
19674 function tokenizeHtmlText(effects, ok, nok) {
19675 const self = this;
19676 /** @type {NonNullable<Code> | undefined} */
19677 let marker;
19678 /** @type {number} */
19679 let index;
19680 /** @type {State} */
19681 let returnState;
19682 return start;
19683 /**
19684 * Start of HTML (text).
19685 *
19686 * ```markdown
19687 * > | a <b> c
19688 * ^
19689 * ```
19690 *
19691 * @type {State}
19692 */
19693 function start(code) {
19694 effects.enter("htmlText");
19695 effects.enter("htmlTextData");
19696 effects.consume(code);
19697 return open;
19698 }
19699 /**
19700 * After `<`, at tag name or other stuff.
19701 *
19702 * ```markdown
19703 * > | a <b> c
19704 * ^
19705 * > | a <!doctype> c
19706 * ^
19707 * > | a <!--b--> c
19708 * ^
19709 * ```
19710 *
19711 * @type {State}
19712 */
19713 function open(code) {
19714 if (code === 33) {
19715 effects.consume(code);
19716 return declarationOpen;
19717 }
19718 if (code === 47) {
19719 effects.consume(code);
19720 return tagCloseStart;
19721 }
19722 if (code === 63) {
19723 effects.consume(code);
19724 return instruction;
19725 }
19726 if (asciiAlpha(code)) {
19727 effects.consume(code);
19728 return tagOpen;
19729 }
19730 return nok(code);
19731 }
19732 /**
19733 * After `<!`, at declaration, comment, or CDATA.
19734 *
19735 * ```markdown
19736 * > | a <!doctype> c
19737 * ^
19738 * > | a <!--b--> c
19739 * ^
19740 * > | a <![CDATA[>&<]]> c
19741 * ^
19742 * ```
19743 *
19744 * @type {State}
19745 */
19746 function declarationOpen(code) {
19747 if (code === 45) {
19748 effects.consume(code);
19749 return commentOpenInside;
19750 }
19751 if (code === 91) {
19752 effects.consume(code);
19753 index = 0;
19754 return cdataOpenInside;
19755 }
19756 if (asciiAlpha(code)) {
19757 effects.consume(code);
19758 return declaration;
19759 }
19760 return nok(code);
19761 }
19762 /**
19763 * In a comment, after `<!-`, at another `-`.
19764 *
19765 * ```markdown
19766 * > | a <!--b--> c
19767 * ^
19768 * ```
19769 *
19770 * @type {State}
19771 */
19772 function commentOpenInside(code) {
19773 if (code === 45) {
19774 effects.consume(code);
19775 return commentEnd;
19776 }
19777 return nok(code);
19778 }
19779 /**
19780 * In comment.
19781 *
19782 * ```markdown
19783 * > | a <!--b--> c
19784 * ^
19785 * ```
19786 *
19787 * @type {State}
19788 */
19789 function comment(code) {
19790 if (code === null) return nok(code);
19791 if (code === 45) {
19792 effects.consume(code);
19793 return commentClose;
19794 }
19795 if (markdownLineEnding(code)) {
19796 returnState = comment;
19797 return lineEndingBefore(code);
19798 }
19799 effects.consume(code);
19800 return comment;
19801 }
19802 /**
19803 * In comment, after `-`.
19804 *
19805 * ```markdown
19806 * > | a <!--b--> c
19807 * ^
19808 * ```
19809 *
19810 * @type {State}
19811 */
19812 function commentClose(code) {
19813 if (code === 45) {
19814 effects.consume(code);
19815 return commentEnd;
19816 }
19817 return comment(code);
19818 }
19819 /**
19820 * In comment, after `--`.
19821 *
19822 * ```markdown
19823 * > | a <!--b--> c
19824 * ^
19825 * ```
19826 *
19827 * @type {State}
19828 */
19829 function commentEnd(code) {
19830 return code === 62 ? end(code) : code === 45 ? commentClose(code) : comment(code);
19831 }
19832 /**
19833 * After `<![`, in CDATA, expecting `CDATA[`.
19834 *
19835 * ```markdown
19836 * > | a <![CDATA[>&<]]> b
19837 * ^^^^^^
19838 * ```
19839 *
19840 * @type {State}
19841 */
19842 function cdataOpenInside(code) {
19843 if (code === "CDATA[".charCodeAt(index++)) {
19844 effects.consume(code);
19845 return index === 6 ? cdata : cdataOpenInside;
19846 }
19847 return nok(code);
19848 }
19849 /**
19850 * In CDATA.
19851 *
19852 * ```markdown
19853 * > | a <![CDATA[>&<]]> b
19854 * ^^^
19855 * ```
19856 *
19857 * @type {State}
19858 */
19859 function cdata(code) {
19860 if (code === null) return nok(code);
19861 if (code === 93) {
19862 effects.consume(code);
19863 return cdataClose;
19864 }
19865 if (markdownLineEnding(code)) {
19866 returnState = cdata;
19867 return lineEndingBefore(code);
19868 }
19869 effects.consume(code);
19870 return cdata;
19871 }
19872 /**
19873 * In CDATA, after `]`, at another `]`.
19874 *
19875 * ```markdown
19876 * > | a <![CDATA[>&<]]> b
19877 * ^
19878 * ```
19879 *
19880 * @type {State}
19881 */
19882 function cdataClose(code) {
19883 if (code === 93) {
19884 effects.consume(code);
19885 return cdataEnd;
19886 }
19887 return cdata(code);
19888 }
19889 /**
19890 * In CDATA, after `]]`, at `>`.
19891 *
19892 * ```markdown
19893 * > | a <![CDATA[>&<]]> b
19894 * ^
19895 * ```
19896 *
19897 * @type {State}
19898 */
19899 function cdataEnd(code) {
19900 if (code === 62) return end(code);
19901 if (code === 93) {
19902 effects.consume(code);
19903 return cdataEnd;
19904 }
19905 return cdata(code);
19906 }
19907 /**
19908 * In declaration.
19909 *
19910 * ```markdown
19911 * > | a <!b> c
19912 * ^
19913 * ```
19914 *
19915 * @type {State}
19916 */
19917 function declaration(code) {
19918 if (code === null || code === 62) return end(code);
19919 if (markdownLineEnding(code)) {
19920 returnState = declaration;
19921 return lineEndingBefore(code);
19922 }
19923 effects.consume(code);
19924 return declaration;
19925 }
19926 /**
19927 * In instruction.
19928 *
19929 * ```markdown
19930 * > | a <?b?> c
19931 * ^
19932 * ```
19933 *
19934 * @type {State}
19935 */
19936 function instruction(code) {
19937 if (code === null) return nok(code);
19938 if (code === 63) {
19939 effects.consume(code);
19940 return instructionClose;
19941 }
19942 if (markdownLineEnding(code)) {
19943 returnState = instruction;
19944 return lineEndingBefore(code);
19945 }
19946 effects.consume(code);
19947 return instruction;
19948 }
19949 /**
19950 * In instruction, after `?`, at `>`.
19951 *
19952 * ```markdown
19953 * > | a <?b?> c
19954 * ^
19955 * ```
19956 *
19957 * @type {State}
19958 */
19959 function instructionClose(code) {
19960 return code === 62 ? end(code) : instruction(code);
19961 }
19962 /**
19963 * After `</`, in closing tag, at tag name.
19964 *
19965 * ```markdown
19966 * > | a </b> c
19967 * ^
19968 * ```
19969 *
19970 * @type {State}
19971 */
19972 function tagCloseStart(code) {
19973 if (asciiAlpha(code)) {
19974 effects.consume(code);
19975 return tagClose;
19976 }
19977 return nok(code);
19978 }
19979 /**
19980 * After `</x`, in a tag name.
19981 *
19982 * ```markdown
19983 * > | a </b> c
19984 * ^
19985 * ```
19986 *
19987 * @type {State}
19988 */
19989 function tagClose(code) {
19990 if (code === 45 || asciiAlphanumeric(code)) {
19991 effects.consume(code);
19992 return tagClose;
19993 }
19994 return tagCloseBetween(code);
19995 }
19996 /**
19997 * In closing tag, after tag name.
19998 *
19999 * ```markdown
20000 * > | a </b> c
20001 * ^
20002 * ```
20003 *
20004 * @type {State}
20005 */
20006 function tagCloseBetween(code) {
20007 if (markdownLineEnding(code)) {
20008 returnState = tagCloseBetween;
20009 return lineEndingBefore(code);
20010 }
20011 if (markdownSpace(code)) {
20012 effects.consume(code);
20013 return tagCloseBetween;
20014 }
20015 return end(code);
20016 }
20017 /**
20018 * After `<x`, in opening tag name.
20019 *
20020 * ```markdown
20021 * > | a <b> c
20022 * ^
20023 * ```
20024 *
20025 * @type {State}
20026 */
20027 function tagOpen(code) {
20028 if (code === 45 || asciiAlphanumeric(code)) {
20029 effects.consume(code);
20030 return tagOpen;
20031 }
20032 if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) return tagOpenBetween(code);
20033 return nok(code);
20034 }
20035 /**
20036 * In opening tag, after tag name.
20037 *
20038 * ```markdown
20039 * > | a <b> c
20040 * ^
20041 * ```
20042 *
20043 * @type {State}
20044 */
20045 function tagOpenBetween(code) {
20046 if (code === 47) {
20047 effects.consume(code);
20048 return end;
20049 }
20050 if (code === 58 || code === 95 || asciiAlpha(code)) {
20051 effects.consume(code);
20052 return tagOpenAttributeName;
20053 }
20054 if (markdownLineEnding(code)) {
20055 returnState = tagOpenBetween;
20056 return lineEndingBefore(code);
20057 }
20058 if (markdownSpace(code)) {
20059 effects.consume(code);
20060 return tagOpenBetween;
20061 }
20062 return end(code);
20063 }
20064 /**
20065 * In attribute name.
20066 *
20067 * ```markdown
20068 * > | a <b c> d
20069 * ^
20070 * ```
20071 *
20072 * @type {State}
20073 */
20074 function tagOpenAttributeName(code) {
20075 if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) {
20076 effects.consume(code);
20077 return tagOpenAttributeName;
20078 }
20079 return tagOpenAttributeNameAfter(code);
20080 }
20081 /**
20082 * After attribute name, before initializer, the end of the tag, or
20083 * whitespace.
20084 *
20085 * ```markdown
20086 * > | a <b c> d
20087 * ^
20088 * ```
20089 *
20090 * @type {State}
20091 */
20092 function tagOpenAttributeNameAfter(code) {
20093 if (code === 61) {
20094 effects.consume(code);
20095 return tagOpenAttributeValueBefore;
20096 }
20097 if (markdownLineEnding(code)) {
20098 returnState = tagOpenAttributeNameAfter;
20099 return lineEndingBefore(code);
20100 }
20101 if (markdownSpace(code)) {
20102 effects.consume(code);
20103 return tagOpenAttributeNameAfter;
20104 }
20105 return tagOpenBetween(code);
20106 }
20107 /**
20108 * Before unquoted, double quoted, or single quoted attribute value, allowing
20109 * whitespace.
20110 *
20111 * ```markdown
20112 * > | a <b c=d> e
20113 * ^
20114 * ```
20115 *
20116 * @type {State}
20117 */
20118 function tagOpenAttributeValueBefore(code) {
20119 if (code === null || code === 60 || code === 61 || code === 62 || code === 96) return nok(code);
20120 if (code === 34 || code === 39) {
20121 effects.consume(code);
20122 marker = code;
20123 return tagOpenAttributeValueQuoted;
20124 }
20125 if (markdownLineEnding(code)) {
20126 returnState = tagOpenAttributeValueBefore;
20127 return lineEndingBefore(code);
20128 }
20129 if (markdownSpace(code)) {
20130 effects.consume(code);
20131 return tagOpenAttributeValueBefore;
20132 }
20133 effects.consume(code);
20134 return tagOpenAttributeValueUnquoted;
20135 }
20136 /**
20137 * In double or single quoted attribute value.
20138 *
20139 * ```markdown
20140 * > | a <b c="d"> e
20141 * ^
20142 * ```
20143 *
20144 * @type {State}
20145 */
20146 function tagOpenAttributeValueQuoted(code) {
20147 if (code === marker) {
20148 effects.consume(code);
20149 marker = void 0;
20150 return tagOpenAttributeValueQuotedAfter;
20151 }
20152 if (code === null) return nok(code);
20153 if (markdownLineEnding(code)) {
20154 returnState = tagOpenAttributeValueQuoted;
20155 return lineEndingBefore(code);
20156 }
20157 effects.consume(code);
20158 return tagOpenAttributeValueQuoted;
20159 }
20160 /**
20161 * In unquoted attribute value.
20162 *
20163 * ```markdown
20164 * > | a <b c=d> e
20165 * ^
20166 * ```
20167 *
20168 * @type {State}
20169 */
20170 function tagOpenAttributeValueUnquoted(code) {
20171 if (code === null || code === 34 || code === 39 || code === 60 || code === 61 || code === 96) return nok(code);
20172 if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) return tagOpenBetween(code);
20173 effects.consume(code);
20174 return tagOpenAttributeValueUnquoted;
20175 }
20176 /**
20177 * After double or single quoted attribute value, before whitespace or the end
20178 * of the tag.
20179 *
20180 * ```markdown
20181 * > | a <b c="d"> e
20182 * ^
20183 * ```
20184 *
20185 * @type {State}
20186 */
20187 function tagOpenAttributeValueQuotedAfter(code) {
20188 if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) return tagOpenBetween(code);
20189 return nok(code);
20190 }
20191 /**
20192 * In certain circumstances of a tag where only an `>` is allowed.
20193 *
20194 * ```markdown
20195 * > | a <b c="d"> e
20196 * ^
20197 * ```
20198 *
20199 * @type {State}
20200 */
20201 function end(code) {
20202 if (code === 62) {
20203 effects.consume(code);
20204 effects.exit("htmlTextData");
20205 effects.exit("htmlText");
20206 return ok;
20207 }
20208 return nok(code);
20209 }
20210 /**
20211 * At eol.
20212 *
20213 * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about
20214 * > empty tokens.
20215 *
20216 * ```markdown
20217 * > | a <!--a
20218 * ^
20219 * | b-->
20220 * ```
20221 *
20222 * @type {State}
20223 */
20224 function lineEndingBefore(code) {
20225 effects.exit("htmlTextData");
20226 effects.enter("lineEnding");
20227 effects.consume(code);
20228 effects.exit("lineEnding");
20229 return lineEndingAfter;
20230 }
20231 /**
20232 * After eol, at optional whitespace.
20233 *
20234 * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about
20235 * > empty tokens.
20236 *
20237 * ```markdown
20238 * | a <!--a
20239 * > | b-->
20240 * ^
20241 * ```
20242 *
20243 * @type {State}
20244 */
20245 function lineEndingAfter(code) {
20246 return markdownSpace(code) ? factorySpace(effects, lineEndingAfterPrefix, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code) : lineEndingAfterPrefix(code);
20247 }
20248 /**
20249 * After eol, after optional whitespace.
20250 *
20251 * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about
20252 * > empty tokens.
20253 *
20254 * ```markdown
20255 * | a <!--a
20256 * > | b-->
20257 * ^
20258 * ```
20259 *
20260 * @type {State}
20261 */
20262 function lineEndingAfterPrefix(code) {
20263 effects.enter("htmlTextData");
20264 return returnState(code);
20265 }
20266 }
20267 var htmlText;
20268 var init_html_text = __esmMin((() => {
20269 init_micromark_factory_space();
20270 init_micromark_util_character();
20271 htmlText = {
20272 name: "htmlText",
20273 tokenize: tokenizeHtmlText
20274 };
20275 }));
20276
20277 //#endregion
20278 //#region node_modules/micromark-core-commonmark/lib/label-end.js
20279 /** @type {Resolver} */
20280 function resolveAllLabelEnd(events) {
20281 let index = -1;
20282 while (++index < events.length) {
20283 const token = events[index][1];
20284 if (token.type === "labelImage" || token.type === "labelLink" || token.type === "labelEnd") {
20285 events.splice(index + 1, token.type === "labelImage" ? 4 : 2);
20286 token.type = "data";
20287 index++;
20288 }
20289 }
20290 return events;
20291 }
20292 /** @type {Resolver} */
20293 function resolveToLabelEnd(events, context) {
20294 let index = events.length;
20295 let offset = 0;
20296 /** @type {Token} */
20297 let token;
20298 /** @type {number | undefined} */
20299 let open;
20300 /** @type {number | undefined} */
20301 let close;
20302 /** @type {Array<Event>} */
20303 let media;
20304 while (index--) {
20305 token = events[index][1];
20306 if (open) {
20307 if (token.type === "link" || token.type === "labelLink" && token._inactive) break;
20308 if (events[index][0] === "enter" && token.type === "labelLink") token._inactive = true;
20309 } else if (close) {
20310 if (events[index][0] === "enter" && (token.type === "labelImage" || token.type === "labelLink") && !token._balanced) {
20311 open = index;
20312 if (token.type !== "labelLink") {
20313 offset = 2;
20314 break;
20315 }
20316 }
20317 } else if (token.type === "labelEnd") close = index;
20318 }
20319 const group = {
20320 type: events[open][1].type === "labelLink" ? "link" : "image",
20321 start: Object.assign({}, events[open][1].start),
20322 end: Object.assign({}, events[events.length - 1][1].end)
20323 };
20324 const label = {
20325 type: "label",
20326 start: Object.assign({}, events[open][1].start),
20327 end: Object.assign({}, events[close][1].end)
20328 };
20329 const text = {
20330 type: "labelText",
20331 start: Object.assign({}, events[open + offset + 2][1].end),
20332 end: Object.assign({}, events[close - 2][1].start)
20333 };
20334 media = [[
20335 "enter",
20336 group,
20337 context
20338 ], [
20339 "enter",
20340 label,
20341 context
20342 ]];
20343 media = push(media, events.slice(open + 1, open + offset + 3));
20344 media = push(media, [[
20345 "enter",
20346 text,
20347 context
20348 ]]);
20349 media = push(media, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + offset + 4, close - 3), context));
20350 media = push(media, [
20351 [
20352 "exit",
20353 text,
20354 context
20355 ],
20356 events[close - 2],
20357 events[close - 1],
20358 [
20359 "exit",
20360 label,
20361 context
20362 ]
20363 ]);
20364 media = push(media, events.slice(close + 1));
20365 media = push(media, [[
20366 "exit",
20367 group,
20368 context
20369 ]]);
20370 splice(events, open, events.length, media);
20371 return events;
20372 }
20373 /**
20374 * @this {TokenizeContext}
20375 * @type {Tokenizer}
20376 */
20377 function tokenizeLabelEnd(effects, ok, nok) {
20378 const self = this;
20379 let index = self.events.length;
20380 /** @type {Token} */
20381 let labelStart;
20382 /** @type {boolean} */
20383 let defined;
20384 while (index--) if ((self.events[index][1].type === "labelImage" || self.events[index][1].type === "labelLink") && !self.events[index][1]._balanced) {
20385 labelStart = self.events[index][1];
20386 break;
20387 }
20388 return start;
20389 /**
20390 * Start of label end.
20391 *
20392 * ```markdown
20393 * > | [a](b) c
20394 * ^
20395 * > | [a][b] c
20396 * ^
20397 * > | [a][] b
20398 * ^
20399 * > | [a] b
20400 * ```
20401 *
20402 * @type {State}
20403 */
20404 function start(code) {
20405 if (!labelStart) return nok(code);
20406 if (labelStart._inactive) return labelEndNok(code);
20407 defined = self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize({
20408 start: labelStart.end,
20409 end: self.now()
20410 })));
20411 effects.enter("labelEnd");
20412 effects.enter("labelMarker");
20413 effects.consume(code);
20414 effects.exit("labelMarker");
20415 effects.exit("labelEnd");
20416 return after;
20417 }
20418 /**
20419 * After `]`.
20420 *
20421 * ```markdown
20422 * > | [a](b) c
20423 * ^
20424 * > | [a][b] c
20425 * ^
20426 * > | [a][] b
20427 * ^
20428 * > | [a] b
20429 * ^
20430 * ```
20431 *
20432 * @type {State}
20433 */
20434 function after(code) {
20435 if (code === 40) return effects.attempt(resourceConstruct, labelEndOk, defined ? labelEndOk : labelEndNok)(code);
20436 if (code === 91) return effects.attempt(referenceFullConstruct, labelEndOk, defined ? referenceNotFull : labelEndNok)(code);
20437 return defined ? labelEndOk(code) : labelEndNok(code);
20438 }
20439 /**
20440 * After `]`, at `[`, but not at a full reference.
20441 *
20442 * > 👉 **Note**: we only get here if the label is defined.
20443 *
20444 * ```markdown
20445 * > | [a][] b
20446 * ^
20447 * > | [a] b
20448 * ^
20449 * ```
20450 *
20451 * @type {State}
20452 */
20453 function referenceNotFull(code) {
20454 return effects.attempt(referenceCollapsedConstruct, labelEndOk, labelEndNok)(code);
20455 }
20456 /**
20457 * Done, we found something.
20458 *
20459 * ```markdown
20460 * > | [a](b) c
20461 * ^
20462 * > | [a][b] c
20463 * ^
20464 * > | [a][] b
20465 * ^
20466 * > | [a] b
20467 * ^
20468 * ```
20469 *
20470 * @type {State}
20471 */
20472 function labelEndOk(code) {
20473 return ok(code);
20474 }
20475 /**
20476 * Done, it’s nothing.
20477 *
20478 * There was an okay opening, but we didn’t match anything.
20479 *
20480 * ```markdown
20481 * > | [a](b c
20482 * ^
20483 * > | [a][b c
20484 * ^
20485 * > | [a] b
20486 * ^
20487 * ```
20488 *
20489 * @type {State}
20490 */
20491 function labelEndNok(code) {
20492 labelStart._balanced = true;
20493 return nok(code);
20494 }
20495 }
20496 /**
20497 * @this {TokenizeContext}
20498 * @type {Tokenizer}
20499 */
20500 function tokenizeResource(effects, ok, nok) {
20501 return resourceStart;
20502 /**
20503 * At a resource.
20504 *
20505 * ```markdown
20506 * > | [a](b) c
20507 * ^
20508 * ```
20509 *
20510 * @type {State}
20511 */
20512 function resourceStart(code) {
20513 effects.enter("resource");
20514 effects.enter("resourceMarker");
20515 effects.consume(code);
20516 effects.exit("resourceMarker");
20517 return resourceBefore;
20518 }
20519 /**
20520 * In resource, after `(`, at optional whitespace.
20521 *
20522 * ```markdown
20523 * > | [a](b) c
20524 * ^
20525 * ```
20526 *
20527 * @type {State}
20528 */
20529 function resourceBefore(code) {
20530 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceOpen)(code) : resourceOpen(code);
20531 }
20532 /**
20533 * In resource, after optional whitespace, at `)` or a destination.
20534 *
20535 * ```markdown
20536 * > | [a](b) c
20537 * ^
20538 * ```
20539 *
20540 * @type {State}
20541 */
20542 function resourceOpen(code) {
20543 if (code === 41) return resourceEnd(code);
20544 return factoryDestination(effects, resourceDestinationAfter, resourceDestinationMissing, "resourceDestination", "resourceDestinationLiteral", "resourceDestinationLiteralMarker", "resourceDestinationRaw", "resourceDestinationString", 32)(code);
20545 }
20546 /**
20547 * In resource, after destination, at optional whitespace.
20548 *
20549 * ```markdown
20550 * > | [a](b) c
20551 * ^
20552 * ```
20553 *
20554 * @type {State}
20555 */
20556 function resourceDestinationAfter(code) {
20557 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceBetween)(code) : resourceEnd(code);
20558 }
20559 /**
20560 * At invalid destination.
20561 *
20562 * ```markdown
20563 * > | [a](<<) b
20564 * ^
20565 * ```
20566 *
20567 * @type {State}
20568 */
20569 function resourceDestinationMissing(code) {
20570 return nok(code);
20571 }
20572 /**
20573 * In resource, after destination and whitespace, at `(` or title.
20574 *
20575 * ```markdown
20576 * > | [a](b ) c
20577 * ^
20578 * ```
20579 *
20580 * @type {State}
20581 */
20582 function resourceBetween(code) {
20583 if (code === 34 || code === 39 || code === 40) return factoryTitle(effects, resourceTitleAfter, nok, "resourceTitle", "resourceTitleMarker", "resourceTitleString")(code);
20584 return resourceEnd(code);
20585 }
20586 /**
20587 * In resource, after title, at optional whitespace.
20588 *
20589 * ```markdown
20590 * > | [a](b "c") d
20591 * ^
20592 * ```
20593 *
20594 * @type {State}
20595 */
20596 function resourceTitleAfter(code) {
20597 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceEnd)(code) : resourceEnd(code);
20598 }
20599 /**
20600 * In resource, at `)`.
20601 *
20602 * ```markdown
20603 * > | [a](b) d
20604 * ^
20605 * ```
20606 *
20607 * @type {State}
20608 */
20609 function resourceEnd(code) {
20610 if (code === 41) {
20611 effects.enter("resourceMarker");
20612 effects.consume(code);
20613 effects.exit("resourceMarker");
20614 effects.exit("resource");
20615 return ok;
20616 }
20617 return nok(code);
20618 }
20619 }
20620 /**
20621 * @this {TokenizeContext}
20622 * @type {Tokenizer}
20623 */
20624 function tokenizeReferenceFull(effects, ok, nok) {
20625 const self = this;
20626 return referenceFull;
20627 /**
20628 * In a reference (full), at the `[`.
20629 *
20630 * ```markdown
20631 * > | [a][b] d
20632 * ^
20633 * ```
20634 *
20635 * @type {State}
20636 */
20637 function referenceFull(code) {
20638 return factoryLabel.call(self, effects, referenceFullAfter, referenceFullMissing, "reference", "referenceMarker", "referenceString")(code);
20639 }
20640 /**
20641 * In a reference (full), after `]`.
20642 *
20643 * ```markdown
20644 * > | [a][b] d
20645 * ^
20646 * ```
20647 *
20648 * @type {State}
20649 */
20650 function referenceFullAfter(code) {
20651 return self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1))) ? ok(code) : nok(code);
20652 }
20653 /**
20654 * In reference (full) that was missing.
20655 *
20656 * ```markdown
20657 * > | [a][b d
20658 * ^
20659 * ```
20660 *
20661 * @type {State}
20662 */
20663 function referenceFullMissing(code) {
20664 return nok(code);
20665 }
20666 }
20667 /**
20668 * @this {TokenizeContext}
20669 * @type {Tokenizer}
20670 */
20671 function tokenizeReferenceCollapsed(effects, ok, nok) {
20672 return referenceCollapsedStart;
20673 /**
20674 * In reference (collapsed), at `[`.
20675 *
20676 * > 👉 **Note**: we only get here if the label is defined.
20677 *
20678 * ```markdown
20679 * > | [a][] d
20680 * ^
20681 * ```
20682 *
20683 * @type {State}
20684 */
20685 function referenceCollapsedStart(code) {
20686 effects.enter("reference");
20687 effects.enter("referenceMarker");
20688 effects.consume(code);
20689 effects.exit("referenceMarker");
20690 return referenceCollapsedOpen;
20691 }
20692 /**
20693 * In reference (collapsed), at `]`.
20694 *
20695 * > 👉 **Note**: we only get here if the label is defined.
20696 *
20697 * ```markdown
20698 * > | [a][] d
20699 * ^
20700 * ```
20701 *
20702 * @type {State}
20703 */
20704 function referenceCollapsedOpen(code) {
20705 if (code === 93) {
20706 effects.enter("referenceMarker");
20707 effects.consume(code);
20708 effects.exit("referenceMarker");
20709 effects.exit("reference");
20710 return ok;
20711 }
20712 return nok(code);
20713 }
20714 }
20715 var labelEnd, resourceConstruct, referenceFullConstruct, referenceCollapsedConstruct;
20716 var init_label_end = __esmMin((() => {
20717 init_micromark_factory_destination();
20718 init_micromark_factory_label();
20719 init_micromark_factory_title();
20720 init_micromark_factory_whitespace();
20721 init_micromark_util_character();
20722 init_micromark_util_chunked();
20723 init_micromark_util_normalize_identifier();
20724 init_micromark_util_resolve_all();
20725 labelEnd = {
20726 name: "labelEnd",
20727 tokenize: tokenizeLabelEnd,
20728 resolveTo: resolveToLabelEnd,
20729 resolveAll: resolveAllLabelEnd
20730 };
20731 resourceConstruct = { tokenize: tokenizeResource };
20732 referenceFullConstruct = { tokenize: tokenizeReferenceFull };
20733 referenceCollapsedConstruct = { tokenize: tokenizeReferenceCollapsed };
20734 }));
20735
20736 //#endregion
20737 //#region node_modules/micromark-core-commonmark/lib/label-start-image.js
20738 /**
20739 * @this {TokenizeContext}
20740 * @type {Tokenizer}
20741 */
20742 function tokenizeLabelStartImage(effects, ok, nok) {
20743 const self = this;
20744 return start;
20745 /**
20746 * Start of label (image) start.
20747 *
20748 * ```markdown
20749 * > | a ![b] c
20750 * ^
20751 * ```
20752 *
20753 * @type {State}
20754 */
20755 function start(code) {
20756 effects.enter("labelImage");
20757 effects.enter("labelImageMarker");
20758 effects.consume(code);
20759 effects.exit("labelImageMarker");
20760 return open;
20761 }
20762 /**
20763 * After `!`, at `[`.
20764 *
20765 * ```markdown
20766 * > | a ![b] c
20767 * ^
20768 * ```
20769 *
20770 * @type {State}
20771 */
20772 function open(code) {
20773 if (code === 91) {
20774 effects.enter("labelMarker");
20775 effects.consume(code);
20776 effects.exit("labelMarker");
20777 effects.exit("labelImage");
20778 return after;
20779 }
20780 return nok(code);
20781 }
20782 /**
20783 * After `![`.
20784 *
20785 * ```markdown
20786 * > | a ![b] c
20787 * ^
20788 * ```
20789 *
20790 * This is needed in because, when GFM footnotes are enabled, images never
20791 * form when started with a `^`.
20792 * Instead, links form:
20793 *
20794 * ```markdown
20795 * ![^a](b)
20796 *
20797 * ![^a][b]
20798 *
20799 * [b]: c
20800 * ```
20801 *
20802 * ```html
20803 * <p>!<a href=\"b\">^a</a></p>
20804 * <p>!<a href=\"c\">^a</a></p>
20805 * ```
20806 *
20807 * @type {State}
20808 */
20809 function after(code) {
20810 /* c8 ignore next 3 */
20811 return code === 94 && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code) : ok(code);
20812 }
20813 }
20814 var labelStartImage;
20815 var init_label_start_image = __esmMin((() => {
20816 init_label_end();
20817 labelStartImage = {
20818 name: "labelStartImage",
20819 tokenize: tokenizeLabelStartImage,
20820 resolveAll: labelEnd.resolveAll
20821 };
20822 }));
20823
20824 //#endregion
20825 //#region node_modules/micromark-core-commonmark/lib/label-start-link.js
20826 /**
20827 * @this {TokenizeContext}
20828 * @type {Tokenizer}
20829 */
20830 function tokenizeLabelStartLink(effects, ok, nok) {
20831 const self = this;
20832 return start;
20833 /**
20834 * Start of label (link) start.
20835 *
20836 * ```markdown
20837 * > | a [b] c
20838 * ^
20839 * ```
20840 *
20841 * @type {State}
20842 */
20843 function start(code) {
20844 effects.enter("labelLink");
20845 effects.enter("labelMarker");
20846 effects.consume(code);
20847 effects.exit("labelMarker");
20848 effects.exit("labelLink");
20849 return after;
20850 }
20851 /** @type {State} */
20852 function after(code) {
20853 /* c8 ignore next 3 */
20854 return code === 94 && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code) : ok(code);
20855 }
20856 }
20857 var labelStartLink;
20858 var init_label_start_link = __esmMin((() => {
20859 init_label_end();
20860 labelStartLink = {
20861 name: "labelStartLink",
20862 tokenize: tokenizeLabelStartLink,
20863 resolveAll: labelEnd.resolveAll
20864 };
20865 }));
20866
20867 //#endregion
20868 //#region node_modules/micromark-core-commonmark/lib/line-ending.js
20869 /**
20870 * @this {TokenizeContext}
20871 * @type {Tokenizer}
20872 */
20873 function tokenizeLineEnding(effects, ok) {
20874 return start;
20875 /** @type {State} */
20876 function start(code) {
20877 effects.enter("lineEnding");
20878 effects.consume(code);
20879 effects.exit("lineEnding");
20880 return factorySpace(effects, ok, "linePrefix");
20881 }
20882 }
20883 var lineEnding;
20884 var init_line_ending = __esmMin((() => {
20885 init_micromark_factory_space();
20886 lineEnding = {
20887 name: "lineEnding",
20888 tokenize: tokenizeLineEnding
20889 };
20890 }));
20891
20892 //#endregion
20893 //#region node_modules/micromark-core-commonmark/lib/thematic-break.js
20894 /**
20895 * @this {TokenizeContext}
20896 * @type {Tokenizer}
20897 */
20898 function tokenizeThematicBreak(effects, ok, nok) {
20899 let size = 0;
20900 /** @type {NonNullable<Code>} */
20901 let marker;
20902 return start;
20903 /**
20904 * Start of thematic break.
20905 *
20906 * ```markdown
20907 * > | ***
20908 * ^
20909 * ```
20910 *
20911 * @type {State}
20912 */
20913 function start(code) {
20914 effects.enter("thematicBreak");
20915 return before(code);
20916 }
20917 /**
20918 * After optional whitespace, at marker.
20919 *
20920 * ```markdown
20921 * > | ***
20922 * ^
20923 * ```
20924 *
20925 * @type {State}
20926 */
20927 function before(code) {
20928 marker = code;
20929 return atBreak(code);
20930 }
20931 /**
20932 * After something, before something else.
20933 *
20934 * ```markdown
20935 * > | ***
20936 * ^
20937 * ```
20938 *
20939 * @type {State}
20940 */
20941 function atBreak(code) {
20942 if (code === marker) {
20943 effects.enter("thematicBreakSequence");
20944 return sequence(code);
20945 }
20946 if (size >= 3 && (code === null || markdownLineEnding(code))) {
20947 effects.exit("thematicBreak");
20948 return ok(code);
20949 }
20950 return nok(code);
20951 }
20952 /**
20953 * In sequence.
20954 *
20955 * ```markdown
20956 * > | ***
20957 * ^
20958 * ```
20959 *
20960 * @type {State}
20961 */
20962 function sequence(code) {
20963 if (code === marker) {
20964 effects.consume(code);
20965 size++;
20966 return sequence;
20967 }
20968 effects.exit("thematicBreakSequence");
20969 return markdownSpace(code) ? factorySpace(effects, atBreak, "whitespace")(code) : atBreak(code);
20970 }
20971 }
20972 var thematicBreak$1;
20973 var init_thematic_break$1 = __esmMin((() => {
20974 init_micromark_factory_space();
20975 init_micromark_util_character();
20976 thematicBreak$1 = {
20977 name: "thematicBreak",
20978 tokenize: tokenizeThematicBreak
20979 };
20980 }));
20981
20982 //#endregion
20983 //#region node_modules/micromark-core-commonmark/lib/list.js
20984 /**
20985 * @type {Tokenizer}
20986 * @this {TokenizeContext}
20987 */
20988 function tokenizeListStart(effects, ok, nok) {
20989 const self = this;
20990 const tail = self.events[self.events.length - 1];
20991 let initialSize = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0;
20992 let size = 0;
20993 return start;
20994 /** @type {State} */
20995 function start(code) {
20996 const kind = self.containerState.type || (code === 42 || code === 43 || code === 45 ? "listUnordered" : "listOrdered");
20997 if (kind === "listUnordered" ? !self.containerState.marker || code === self.containerState.marker : asciiDigit(code)) {
20998 if (!self.containerState.type) {
20999 self.containerState.type = kind;
21000 effects.enter(kind, { _container: true });
21001 }
21002 if (kind === "listUnordered") {
21003 effects.enter("listItemPrefix");
21004 return code === 42 || code === 45 ? effects.check(thematicBreak$1, nok, atMarker)(code) : atMarker(code);
21005 }
21006 if (!self.interrupt || code === 49) {
21007 effects.enter("listItemPrefix");
21008 effects.enter("listItemValue");
21009 return inside(code);
21010 }
21011 }
21012 return nok(code);
21013 }
21014 /** @type {State} */
21015 function inside(code) {
21016 if (asciiDigit(code) && ++size < 10) {
21017 effects.consume(code);
21018 return inside;
21019 }
21020 if ((!self.interrupt || size < 2) && (self.containerState.marker ? code === self.containerState.marker : code === 41 || code === 46)) {
21021 effects.exit("listItemValue");
21022 return atMarker(code);
21023 }
21024 return nok(code);
21025 }
21026 /**
21027 * @type {State}
21028 **/
21029 function atMarker(code) {
21030 effects.enter("listItemMarker");
21031 effects.consume(code);
21032 effects.exit("listItemMarker");
21033 self.containerState.marker = self.containerState.marker || code;
21034 return effects.check(blankLine, self.interrupt ? nok : onBlank, effects.attempt(listItemPrefixWhitespaceConstruct, endOfPrefix, otherPrefix));
21035 }
21036 /** @type {State} */
21037 function onBlank(code) {
21038 self.containerState.initialBlankLine = true;
21039 initialSize++;
21040 return endOfPrefix(code);
21041 }
21042 /** @type {State} */
21043 function otherPrefix(code) {
21044 if (markdownSpace(code)) {
21045 effects.enter("listItemPrefixWhitespace");
21046 effects.consume(code);
21047 effects.exit("listItemPrefixWhitespace");
21048 return endOfPrefix;
21049 }
21050 return nok(code);
21051 }
21052 /** @type {State} */
21053 function endOfPrefix(code) {
21054 self.containerState.size = initialSize + self.sliceSerialize(effects.exit("listItemPrefix"), true).length;
21055 return ok(code);
21056 }
21057 }
21058 /**
21059 * @type {Tokenizer}
21060 * @this {TokenizeContext}
21061 */
21062 function tokenizeListContinuation(effects, ok, nok) {
21063 const self = this;
21064 self.containerState._closeFlow = void 0;
21065 return effects.check(blankLine, onBlank, notBlank);
21066 /** @type {State} */
21067 function onBlank(code) {
21068 self.containerState.furtherBlankLines = self.containerState.furtherBlankLines || self.containerState.initialBlankLine;
21069 return factorySpace(effects, ok, "listItemIndent", self.containerState.size + 1)(code);
21070 }
21071 /** @type {State} */
21072 function notBlank(code) {
21073 if (self.containerState.furtherBlankLines || !markdownSpace(code)) {
21074 self.containerState.furtherBlankLines = void 0;
21075 self.containerState.initialBlankLine = void 0;
21076 return notInCurrentItem(code);
21077 }
21078 self.containerState.furtherBlankLines = void 0;
21079 self.containerState.initialBlankLine = void 0;
21080 return effects.attempt(indentConstruct, ok, notInCurrentItem)(code);
21081 }
21082 /** @type {State} */
21083 function notInCurrentItem(code) {
21084 self.containerState._closeFlow = true;
21085 self.interrupt = void 0;
21086 return factorySpace(effects, effects.attempt(list$1, ok, nok), "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code);
21087 }
21088 }
21089 /**
21090 * @type {Tokenizer}
21091 * @this {TokenizeContext}
21092 */
21093 function tokenizeIndent(effects, ok, nok) {
21094 const self = this;
21095 return factorySpace(effects, afterPrefix, "listItemIndent", self.containerState.size + 1);
21096 /** @type {State} */
21097 function afterPrefix(code) {
21098 const tail = self.events[self.events.length - 1];
21099 return tail && tail[1].type === "listItemIndent" && tail[2].sliceSerialize(tail[1], true).length === self.containerState.size ? ok(code) : nok(code);
21100 }
21101 }
21102 /**
21103 * @type {Exiter}
21104 * @this {TokenizeContext}
21105 */
21106 function tokenizeListEnd(effects) {
21107 effects.exit(this.containerState.type);
21108 }
21109 /**
21110 * @type {Tokenizer}
21111 * @this {TokenizeContext}
21112 */
21113 function tokenizeListItemPrefixWhitespace(effects, ok, nok) {
21114 const self = this;
21115 return factorySpace(effects, afterPrefix, "listItemPrefixWhitespace", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 5);
21116 /** @type {State} */
21117 function afterPrefix(code) {
21118 const tail = self.events[self.events.length - 1];
21119 return !markdownSpace(code) && tail && tail[1].type === "listItemPrefixWhitespace" ? ok(code) : nok(code);
21120 }
21121 }
21122 var list$1, listItemPrefixWhitespaceConstruct, indentConstruct;
21123 var init_list$1 = __esmMin((() => {
21124 init_micromark_factory_space();
21125 init_micromark_util_character();
21126 init_blank_line();
21127 init_thematic_break$1();
21128 list$1 = {
21129 name: "list",
21130 tokenize: tokenizeListStart,
21131 continuation: { tokenize: tokenizeListContinuation },
21132 exit: tokenizeListEnd
21133 };
21134 listItemPrefixWhitespaceConstruct = {
21135 tokenize: tokenizeListItemPrefixWhitespace,
21136 partial: true
21137 };
21138 indentConstruct = {
21139 tokenize: tokenizeIndent,
21140 partial: true
21141 };
21142 }));
21143
21144 //#endregion
21145 //#region node_modules/micromark-core-commonmark/lib/setext-underline.js
21146 /** @type {Resolver} */
21147 function resolveToSetextUnderline(events, context) {
21148 let index = events.length;
21149 /** @type {number | undefined} */
21150 let content;
21151 /** @type {number | undefined} */
21152 let text;
21153 /** @type {number | undefined} */
21154 let definition;
21155 while (index--) if (events[index][0] === "enter") {
21156 if (events[index][1].type === "content") {
21157 content = index;
21158 break;
21159 }
21160 if (events[index][1].type === "paragraph") text = index;
21161 } else {
21162 if (events[index][1].type === "content") events.splice(index, 1);
21163 if (!definition && events[index][1].type === "definition") definition = index;
21164 }
21165 const heading = {
21166 type: "setextHeading",
21167 start: Object.assign({}, events[text][1].start),
21168 end: Object.assign({}, events[events.length - 1][1].end)
21169 };
21170 events[text][1].type = "setextHeadingText";
21171 if (definition) {
21172 events.splice(text, 0, [
21173 "enter",
21174 heading,
21175 context
21176 ]);
21177 events.splice(definition + 1, 0, [
21178 "exit",
21179 events[content][1],
21180 context
21181 ]);
21182 events[content][1].end = Object.assign({}, events[definition][1].end);
21183 } else events[content][1] = heading;
21184 events.push([
21185 "exit",
21186 heading,
21187 context
21188 ]);
21189 return events;
21190 }
21191 /**
21192 * @this {TokenizeContext}
21193 * @type {Tokenizer}
21194 */
21195 function tokenizeSetextUnderline(effects, ok, nok) {
21196 const self = this;
21197 /** @type {NonNullable<Code>} */
21198 let marker;
21199 return start;
21200 /**
21201 * At start of heading (setext) underline.
21202 *
21203 * ```markdown
21204 * | aa
21205 * > | ==
21206 * ^
21207 * ```
21208 *
21209 * @type {State}
21210 */
21211 function start(code) {
21212 let index = self.events.length;
21213 /** @type {boolean | undefined} */
21214 let paragraph;
21215 while (index--) if (self.events[index][1].type !== "lineEnding" && self.events[index][1].type !== "linePrefix" && self.events[index][1].type !== "content") {
21216 paragraph = self.events[index][1].type === "paragraph";
21217 break;
21218 }
21219 if (!self.parser.lazy[self.now().line] && (self.interrupt || paragraph)) {
21220 effects.enter("setextHeadingLine");
21221 marker = code;
21222 return before(code);
21223 }
21224 return nok(code);
21225 }
21226 /**
21227 * After optional whitespace, at `-` or `=`.
21228 *
21229 * ```markdown
21230 * | aa
21231 * > | ==
21232 * ^
21233 * ```
21234 *
21235 * @type {State}
21236 */
21237 function before(code) {
21238 effects.enter("setextHeadingLineSequence");
21239 return inside(code);
21240 }
21241 /**
21242 * In sequence.
21243 *
21244 * ```markdown
21245 * | aa
21246 * > | ==
21247 * ^
21248 * ```
21249 *
21250 * @type {State}
21251 */
21252 function inside(code) {
21253 if (code === marker) {
21254 effects.consume(code);
21255 return inside;
21256 }
21257 effects.exit("setextHeadingLineSequence");
21258 return markdownSpace(code) ? factorySpace(effects, after, "lineSuffix")(code) : after(code);
21259 }
21260 /**
21261 * After sequence, after optional whitespace.
21262 *
21263 * ```markdown
21264 * | aa
21265 * > | ==
21266 * ^
21267 * ```
21268 *
21269 * @type {State}
21270 */
21271 function after(code) {
21272 if (code === null || markdownLineEnding(code)) {
21273 effects.exit("setextHeadingLine");
21274 return ok(code);
21275 }
21276 return nok(code);
21277 }
21278 }
21279 var setextUnderline;
21280 var init_setext_underline = __esmMin((() => {
21281 init_micromark_factory_space();
21282 init_micromark_util_character();
21283 setextUnderline = {
21284 name: "setextUnderline",
21285 tokenize: tokenizeSetextUnderline,
21286 resolveTo: resolveToSetextUnderline
21287 };
21288 }));
21289
21290 //#endregion
21291 //#region node_modules/micromark-core-commonmark/index.js
21292 var init_micromark_core_commonmark = __esmMin((() => {
21293 init_attention();
21294 init_autolink();
21295 init_blank_line();
21296 init_block_quote();
21297 init_character_escape();
21298 init_character_reference();
21299 init_code_fenced();
21300 init_code_indented();
21301 init_code_text();
21302 init_content();
21303 init_definition();
21304 init_hard_break_escape();
21305 init_heading_atx();
21306 init_html_flow();
21307 init_html_text();
21308 init_label_end();
21309 init_label_start_image();
21310 init_label_start_link();
21311 init_line_ending();
21312 init_list$1();
21313 init_setext_underline();
21314 init_thematic_break$1();
21315 }));
21316
21317 //#endregion
21318 //#region node_modules/micromark/lib/initialize/flow.js
21319 /**
21320 * @this {TokenizeContext}
21321 * @type {Initializer}
21322 */
21323 function initializeFlow(effects) {
21324 const self = this;
21325 const initial = effects.attempt(blankLine, atBlankEnding, effects.attempt(this.parser.constructs.flowInitial, afterConstruct, factorySpace(effects, effects.attempt(this.parser.constructs.flow, afterConstruct, effects.attempt(content, afterConstruct)), "linePrefix")));
21326 return initial;
21327 /** @type {State} */
21328 function atBlankEnding(code) {
21329 if (code === null) {
21330 effects.consume(code);
21331 return;
21332 }
21333 effects.enter("lineEndingBlank");
21334 effects.consume(code);
21335 effects.exit("lineEndingBlank");
21336 self.currentConstruct = void 0;
21337 return initial;
21338 }
21339 /** @type {State} */
21340 function afterConstruct(code) {
21341 if (code === null) {
21342 effects.consume(code);
21343 return;
21344 }
21345 effects.enter("lineEnding");
21346 effects.consume(code);
21347 effects.exit("lineEnding");
21348 self.currentConstruct = void 0;
21349 return initial;
21350 }
21351 }
21352 var flow$1;
21353 var init_flow = __esmMin((() => {
21354 init_micromark_core_commonmark();
21355 init_micromark_factory_space();
21356 flow$1 = { tokenize: initializeFlow };
21357 }));
21358
21359 //#endregion
21360 //#region node_modules/micromark/lib/initialize/text.js
21361 /**
21362 * @param {'string' | 'text'} field
21363 * @returns {InitialConstruct}
21364 */
21365 function initializeFactory(field) {
21366 return {
21367 tokenize: initializeText,
21368 resolveAll: createResolver(field === "text" ? resolveAllLineSuffixes : void 0)
21369 };
21370 /**
21371 * @this {TokenizeContext}
21372 * @type {Initializer}
21373 */
21374 function initializeText(effects) {
21375 const self = this;
21376 const constructs = this.parser.constructs[field];
21377 const text = effects.attempt(constructs, start, notText);
21378 return start;
21379 /** @type {State} */
21380 function start(code) {
21381 return atBreak(code) ? text(code) : notText(code);
21382 }
21383 /** @type {State} */
21384 function notText(code) {
21385 if (code === null) {
21386 effects.consume(code);
21387 return;
21388 }
21389 effects.enter("data");
21390 effects.consume(code);
21391 return data;
21392 }
21393 /** @type {State} */
21394 function data(code) {
21395 if (atBreak(code)) {
21396 effects.exit("data");
21397 return text(code);
21398 }
21399 effects.consume(code);
21400 return data;
21401 }
21402 /**
21403 * @param {Code} code
21404 * @returns {boolean}
21405 */
21406 function atBreak(code) {
21407 if (code === null) return true;
21408 const list = constructs[code];
21409 let index = -1;
21410 if (list) while (++index < list.length) {
21411 const item = list[index];
21412 if (!item.previous || item.previous.call(self, self.previous)) return true;
21413 }
21414 return false;
21415 }
21416 }
21417 }
21418 /**
21419 * @param {Resolver | undefined} [extraResolver]
21420 * @returns {Resolver}
21421 */
21422 function createResolver(extraResolver) {
21423 return resolveAllText;
21424 /** @type {Resolver} */
21425 function resolveAllText(events, context) {
21426 let index = -1;
21427 /** @type {number | undefined} */
21428 let enter;
21429 while (++index <= events.length) if (enter === void 0) {
21430 if (events[index] && events[index][1].type === "data") {
21431 enter = index;
21432 index++;
21433 }
21434 } else if (!events[index] || events[index][1].type !== "data") {
21435 if (index !== enter + 2) {
21436 events[enter][1].end = events[index - 1][1].end;
21437 events.splice(enter + 2, index - enter - 2);
21438 index = enter + 2;
21439 }
21440 enter = void 0;
21441 }
21442 return extraResolver ? extraResolver(events, context) : events;
21443 }
21444 }
21445 /**
21446 * A rather ugly set of instructions which again looks at chunks in the input
21447 * stream.
21448 * The reason to do this here is that it is *much* faster to parse in reverse.
21449 * And that we can’t hook into `null` to split the line suffix before an EOF.
21450 * To do: figure out if we can make this into a clean utility, or even in core.
21451 * As it will be useful for GFMs literal autolink extension (and maybe even
21452 * tables?)
21453 *
21454 * @type {Resolver}
21455 */
21456 function resolveAllLineSuffixes(events, context) {
21457 let eventIndex = 0;
21458 while (++eventIndex <= events.length) if ((eventIndex === events.length || events[eventIndex][1].type === "lineEnding") && events[eventIndex - 1][1].type === "data") {
21459 const data = events[eventIndex - 1][1];
21460 const chunks = context.sliceStream(data);
21461 let index = chunks.length;
21462 let bufferIndex = -1;
21463 let size = 0;
21464 /** @type {boolean | undefined} */
21465 let tabs;
21466 while (index--) {
21467 const chunk = chunks[index];
21468 if (typeof chunk === "string") {
21469 bufferIndex = chunk.length;
21470 while (chunk.charCodeAt(bufferIndex - 1) === 32) {
21471 size++;
21472 bufferIndex--;
21473 }
21474 if (bufferIndex) break;
21475 bufferIndex = -1;
21476 } else if (chunk === -2) {
21477 tabs = true;
21478 size++;
21479 } else if (chunk === -1) {} else {
21480 index++;
21481 break;
21482 }
21483 }
21484 if (size) {
21485 const token = {
21486 type: eventIndex === events.length || tabs || size < 2 ? "lineSuffix" : "hardBreakTrailing",
21487 start: {
21488 line: data.end.line,
21489 column: data.end.column - size,
21490 offset: data.end.offset - size,
21491 _index: data.start._index + index,
21492 _bufferIndex: index ? bufferIndex : data.start._bufferIndex + bufferIndex
21493 },
21494 end: Object.assign({}, data.end)
21495 };
21496 data.end = Object.assign({}, token.start);
21497 if (data.start.offset === data.end.offset) Object.assign(data, token);
21498 else {
21499 events.splice(eventIndex, 0, [
21500 "enter",
21501 token,
21502 context
21503 ], [
21504 "exit",
21505 token,
21506 context
21507 ]);
21508 eventIndex += 2;
21509 }
21510 }
21511 eventIndex++;
21512 }
21513 return events;
21514 }
21515 var resolver, string$1, text$2;
21516 var init_text$1 = __esmMin((() => {
21517 resolver = { resolveAll: createResolver() };
21518 string$1 = initializeFactory("string");
21519 text$2 = initializeFactory("text");
21520 }));
21521
21522 //#endregion
21523 //#region node_modules/micromark/lib/create-tokenizer.js
21524 /**
21525 * Create a tokenizer.
21526 * Tokenizers deal with one type of data (e.g., containers, flow, text).
21527 * The parser is the object dealing with it all.
21528 * `initialize` works like other constructs, except that only its `tokenize`
21529 * function is used, in which case it doesn’t receive an `ok` or `nok`.
21530 * `from` can be given to set the point before the first character, although
21531 * when further lines are indented, they must be set with `defineSkip`.
21532 *
21533 * @param {ParseContext} parser
21534 * @param {InitialConstruct} initialize
21535 * @param {Omit<Point, '_bufferIndex' | '_index'> | undefined} [from]
21536 * @returns {TokenizeContext}
21537 */
21538 function createTokenizer(parser, initialize, from) {
21539 /** @type {Point} */
21540 let point = Object.assign(from ? Object.assign({}, from) : {
21541 line: 1,
21542 column: 1,
21543 offset: 0
21544 }, {
21545 _index: 0,
21546 _bufferIndex: -1
21547 });
21548 /** @type {Record<string, number>} */
21549 const columnStart = {};
21550 /** @type {Array<Construct>} */
21551 const resolveAllConstructs = [];
21552 /** @type {Array<Chunk>} */
21553 let chunks = [];
21554 /** @type {Array<Token>} */
21555 let stack = [];
21556 /**
21557 * Tools used for tokenizing.
21558 *
21559 * @type {Effects}
21560 */
21561 const effects = {
21562 consume,
21563 enter,
21564 exit,
21565 attempt: constructFactory(onsuccessfulconstruct),
21566 check: constructFactory(onsuccessfulcheck),
21567 interrupt: constructFactory(onsuccessfulcheck, { interrupt: true })
21568 };
21569 /**
21570 * State and tools for resolving and serializing.
21571 *
21572 * @type {TokenizeContext}
21573 */
21574 const context = {
21575 previous: null,
21576 code: null,
21577 containerState: {},
21578 events: [],
21579 parser,
21580 sliceStream,
21581 sliceSerialize,
21582 now,
21583 defineSkip,
21584 write
21585 };
21586 /**
21587 * The state function.
21588 *
21589 * @type {State | void}
21590 */
21591 let state = initialize.tokenize.call(context, effects);
21592 if (initialize.resolveAll) resolveAllConstructs.push(initialize);
21593 return context;
21594 /** @type {TokenizeContext['write']} */
21595 function write(slice) {
21596 chunks = push(chunks, slice);
21597 main();
21598 if (chunks[chunks.length - 1] !== null) return [];
21599 addResult(initialize, 0);
21600 context.events = resolveAll(resolveAllConstructs, context.events, context);
21601 return context.events;
21602 }
21603 /** @type {TokenizeContext['sliceSerialize']} */
21604 function sliceSerialize(token, expandTabs) {
21605 return serializeChunks(sliceStream(token), expandTabs);
21606 }
21607 /** @type {TokenizeContext['sliceStream']} */
21608 function sliceStream(token) {
21609 return sliceChunks(chunks, token);
21610 }
21611 /** @type {TokenizeContext['now']} */
21612 function now() {
21613 const { line, column, offset, _index, _bufferIndex } = point;
21614 return {
21615 line,
21616 column,
21617 offset,
21618 _index,
21619 _bufferIndex
21620 };
21621 }
21622 /** @type {TokenizeContext['defineSkip']} */
21623 function defineSkip(value) {
21624 columnStart[value.line] = value.column;
21625 accountForPotentialSkip();
21626 }
21627 /**
21628 * Main loop (note that `_index` and `_bufferIndex` in `point` are modified by
21629 * `consume`).
21630 * Here is where we walk through the chunks, which either include strings of
21631 * several characters, or numerical character codes.
21632 * The reason to do this in a loop instead of a call is so the stack can
21633 * drain.
21634 *
21635 * @returns {void}
21636 */
21637 function main() {
21638 /** @type {number} */
21639 let chunkIndex;
21640 while (point._index < chunks.length) {
21641 const chunk = chunks[point._index];
21642 if (typeof chunk === "string") {
21643 chunkIndex = point._index;
21644 if (point._bufferIndex < 0) point._bufferIndex = 0;
21645 while (point._index === chunkIndex && point._bufferIndex < chunk.length) go(chunk.charCodeAt(point._bufferIndex));
21646 } else go(chunk);
21647 }
21648 }
21649 /**
21650 * Deal with one code.
21651 *
21652 * @param {Code} code
21653 * @returns {void}
21654 */
21655 function go(code) {
21656 state = state(code);
21657 }
21658 /** @type {Effects['consume']} */
21659 function consume(code) {
21660 if (markdownLineEnding(code)) {
21661 point.line++;
21662 point.column = 1;
21663 point.offset += code === -3 ? 2 : 1;
21664 accountForPotentialSkip();
21665 } else if (code !== -1) {
21666 point.column++;
21667 point.offset++;
21668 }
21669 if (point._bufferIndex < 0) point._index++;
21670 else {
21671 point._bufferIndex++;
21672 if (point._bufferIndex === chunks[point._index].length) {
21673 point._bufferIndex = -1;
21674 point._index++;
21675 }
21676 }
21677 context.previous = code;
21678 }
21679 /** @type {Effects['enter']} */
21680 function enter(type, fields) {
21681 /** @type {Token} */
21682 const token = fields || {};
21683 token.type = type;
21684 token.start = now();
21685 context.events.push([
21686 "enter",
21687 token,
21688 context
21689 ]);
21690 stack.push(token);
21691 return token;
21692 }
21693 /** @type {Effects['exit']} */
21694 function exit(type) {
21695 const token = stack.pop();
21696 token.end = now();
21697 context.events.push([
21698 "exit",
21699 token,
21700 context
21701 ]);
21702 return token;
21703 }
21704 /**
21705 * Use results.
21706 *
21707 * @type {ReturnHandle}
21708 */
21709 function onsuccessfulconstruct(construct, info) {
21710 addResult(construct, info.from);
21711 }
21712 /**
21713 * Discard results.
21714 *
21715 * @type {ReturnHandle}
21716 */
21717 function onsuccessfulcheck(_, info) {
21718 info.restore();
21719 }
21720 /**
21721 * Factory to attempt/check/interrupt.
21722 *
21723 * @param {ReturnHandle} onreturn
21724 * @param {{interrupt?: boolean | undefined} | undefined} [fields]
21725 */
21726 function constructFactory(onreturn, fields) {
21727 return hook;
21728 /**
21729 * Handle either an object mapping codes to constructs, a list of
21730 * constructs, or a single construct.
21731 *
21732 * @param {Array<Construct> | Construct | ConstructRecord} constructs
21733 * @param {State} returnState
21734 * @param {State | undefined} [bogusState]
21735 * @returns {State}
21736 */
21737 function hook(constructs, returnState, bogusState) {
21738 /** @type {Array<Construct>} */
21739 let listOfConstructs;
21740 /** @type {number} */
21741 let constructIndex;
21742 /** @type {Construct} */
21743 let currentConstruct;
21744 /** @type {Info} */
21745 let info;
21746 return Array.isArray(constructs) ? handleListOfConstructs(constructs) : "tokenize" in constructs ? handleListOfConstructs([constructs]) : handleMapOfConstructs(constructs);
21747 /**
21748 * Handle a list of construct.
21749 *
21750 * @param {ConstructRecord} map
21751 * @returns {State}
21752 */
21753 function handleMapOfConstructs(map) {
21754 return start;
21755 /** @type {State} */
21756 function start(code) {
21757 const def = code !== null && map[code];
21758 const all = code !== null && map.null;
21759 return handleListOfConstructs([...Array.isArray(def) ? def : def ? [def] : [], ...Array.isArray(all) ? all : all ? [all] : []])(code);
21760 }
21761 }
21762 /**
21763 * Handle a list of construct.
21764 *
21765 * @param {Array<Construct>} list
21766 * @returns {State}
21767 */
21768 function handleListOfConstructs(list) {
21769 listOfConstructs = list;
21770 constructIndex = 0;
21771 if (list.length === 0) return bogusState;
21772 return handleConstruct(list[constructIndex]);
21773 }
21774 /**
21775 * Handle a single construct.
21776 *
21777 * @param {Construct} construct
21778 * @returns {State}
21779 */
21780 function handleConstruct(construct) {
21781 return start;
21782 /** @type {State} */
21783 function start(code) {
21784 info = store();
21785 currentConstruct = construct;
21786 if (!construct.partial) context.currentConstruct = construct;
21787 if (construct.name && context.parser.constructs.disable.null.includes(construct.name)) return nok(code);
21788 return construct.tokenize.call(fields ? Object.assign(Object.create(context), fields) : context, effects, ok, nok)(code);
21789 }
21790 }
21791 /** @type {State} */
21792 function ok(code) {
21793 onreturn(currentConstruct, info);
21794 return returnState;
21795 }
21796 /** @type {State} */
21797 function nok(code) {
21798 info.restore();
21799 if (++constructIndex < listOfConstructs.length) return handleConstruct(listOfConstructs[constructIndex]);
21800 return bogusState;
21801 }
21802 }
21803 }
21804 /**
21805 * @param {Construct} construct
21806 * @param {number} from
21807 * @returns {void}
21808 */
21809 function addResult(construct, from) {
21810 if (construct.resolveAll && !resolveAllConstructs.includes(construct)) resolveAllConstructs.push(construct);
21811 if (construct.resolve) splice(context.events, from, context.events.length - from, construct.resolve(context.events.slice(from), context));
21812 if (construct.resolveTo) context.events = construct.resolveTo(context.events, context);
21813 }
21814 /**
21815 * Store state.
21816 *
21817 * @returns {Info}
21818 */
21819 function store() {
21820 const startPoint = now();
21821 const startPrevious = context.previous;
21822 const startCurrentConstruct = context.currentConstruct;
21823 const startEventsIndex = context.events.length;
21824 const startStack = Array.from(stack);
21825 return {
21826 restore,
21827 from: startEventsIndex
21828 };
21829 /**
21830 * Restore state.
21831 *
21832 * @returns {void}
21833 */
21834 function restore() {
21835 point = startPoint;
21836 context.previous = startPrevious;
21837 context.currentConstruct = startCurrentConstruct;
21838 context.events.length = startEventsIndex;
21839 stack = startStack;
21840 accountForPotentialSkip();
21841 }
21842 }
21843 /**
21844 * Move the current point a bit forward in the line when it’s on a column
21845 * skip.
21846 *
21847 * @returns {void}
21848 */
21849 function accountForPotentialSkip() {
21850 if (point.line in columnStart && point.column < 2) {
21851 point.column = columnStart[point.line];
21852 point.offset += columnStart[point.line] - 1;
21853 }
21854 }
21855 }
21856 /**
21857 * Get the chunks from a slice of chunks in the range of a token.
21858 *
21859 * @param {Array<Chunk>} chunks
21860 * @param {Pick<Token, 'end' | 'start'>} token
21861 * @returns {Array<Chunk>}
21862 */
21863 function sliceChunks(chunks, token) {
21864 const startIndex = token.start._index;
21865 const startBufferIndex = token.start._bufferIndex;
21866 const endIndex = token.end._index;
21867 const endBufferIndex = token.end._bufferIndex;
21868 /** @type {Array<Chunk>} */
21869 let view;
21870 if (startIndex === endIndex) view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)];
21871 else {
21872 view = chunks.slice(startIndex, endIndex);
21873 if (startBufferIndex > -1) {
21874 const head = view[0];
21875 if (typeof head === "string") view[0] = head.slice(startBufferIndex);
21876 else view.shift();
21877 }
21878 if (endBufferIndex > 0) view.push(chunks[endIndex].slice(0, endBufferIndex));
21879 }
21880 return view;
21881 }
21882 /**
21883 * Get the string value of a slice of chunks.
21884 *
21885 * @param {Array<Chunk>} chunks
21886 * @param {boolean | undefined} [expandTabs=false]
21887 * @returns {string}
21888 */
21889 function serializeChunks(chunks, expandTabs) {
21890 let index = -1;
21891 /** @type {Array<string>} */
21892 const result = [];
21893 /** @type {boolean | undefined} */
21894 let atTab;
21895 while (++index < chunks.length) {
21896 const chunk = chunks[index];
21897 /** @type {string} */
21898 let value;
21899 if (typeof chunk === "string") value = chunk;
21900 else switch (chunk) {
21901 case -5:
21902 value = "\r";
21903 break;
21904 case -4:
21905 value = "\n";
21906 break;
21907 case -3:
21908 value = "\r\n";
21909 break;
21910 case -2:
21911 value = expandTabs ? " " : " ";
21912 break;
21913 case -1:
21914 if (!expandTabs && atTab) continue;
21915 value = " ";
21916 break;
21917 default: value = String.fromCharCode(chunk);
21918 }
21919 atTab = chunk === -2;
21920 result.push(value);
21921 }
21922 return result.join("");
21923 }
21924 var init_create_tokenizer = __esmMin((() => {
21925 init_micromark_util_character();
21926 init_micromark_util_chunked();
21927 init_micromark_util_resolve_all();
21928 }));
21929
21930 //#endregion
21931 //#region node_modules/micromark/lib/constructs.js
21932 var constructs_exports = /* @__PURE__ */ __exportAll({
21933 attentionMarkers: () => attentionMarkers,
21934 contentInitial: () => contentInitial,
21935 disable: () => disable,
21936 document: () => document$1,
21937 flow: () => flow,
21938 flowInitial: () => flowInitial,
21939 insideSpan: () => insideSpan,
21940 string: () => string,
21941 text: () => text$1
21942 });
21943 var document$1, contentInitial, flowInitial, flow, string, text$1, insideSpan, attentionMarkers, disable;
21944 var init_constructs = __esmMin((() => {
21945 init_micromark_core_commonmark();
21946 init_text$1();
21947 document$1 = {
21948 [42]: list$1,
21949 [43]: list$1,
21950 [45]: list$1,
21951 [48]: list$1,
21952 [49]: list$1,
21953 [50]: list$1,
21954 [51]: list$1,
21955 [52]: list$1,
21956 [53]: list$1,
21957 [54]: list$1,
21958 [55]: list$1,
21959 [56]: list$1,
21960 [57]: list$1,
21961 [62]: blockQuote
21962 };
21963 contentInitial = { [91]: definition };
21964 flowInitial = {
21965 [-2]: codeIndented,
21966 [-1]: codeIndented,
21967 [32]: codeIndented
21968 };
21969 flow = {
21970 [35]: headingAtx,
21971 [42]: thematicBreak$1,
21972 [45]: [setextUnderline, thematicBreak$1],
21973 [60]: htmlFlow,
21974 [61]: setextUnderline,
21975 [95]: thematicBreak$1,
21976 [96]: codeFenced,
21977 [126]: codeFenced
21978 };
21979 string = {
21980 [38]: characterReference,
21981 [92]: characterEscape
21982 };
21983 text$1 = {
21984 [-5]: lineEnding,
21985 [-4]: lineEnding,
21986 [-3]: lineEnding,
21987 [33]: labelStartImage,
21988 [38]: characterReference,
21989 [42]: attention,
21990 [60]: [autolink, htmlText],
21991 [91]: labelStartLink,
21992 [92]: [hardBreakEscape, characterEscape],
21993 [93]: labelEnd,
21994 [95]: attention,
21995 [96]: codeText
21996 };
21997 insideSpan = { null: [attention, resolver] };
21998 attentionMarkers = { null: [42, 95] };
21999 disable = { null: [] };
22000 }));
22001
22002 //#endregion
22003 //#region node_modules/micromark/lib/parse.js
22004 /**
22005 * @param {ParseOptions | null | undefined} [options]
22006 * @returns {ParseContext}
22007 */
22008 function parse(options) {
22009 /** @type {ParseContext} */
22010 const parser = {
22011 defined: [],
22012 lazy: {},
22013 constructs: combineExtensions([constructs_exports, ...(options || {}).extensions || []]),
22014 content: create(content$1),
22015 document: create(document$2),
22016 flow: create(flow$1),
22017 string: create(string$1),
22018 text: create(text$2)
22019 };
22020 return parser;
22021 /**
22022 * @param {InitialConstruct} initial
22023 */
22024 function create(initial) {
22025 return creator;
22026 /** @type {Create} */
22027 function creator(from) {
22028 return createTokenizer(parser, initial, from);
22029 }
22030 }
22031 }
22032 var init_parse = __esmMin((() => {
22033 init_micromark_util_combine_extensions();
22034 init_content$1();
22035 init_document();
22036 init_flow();
22037 init_text$1();
22038 init_create_tokenizer();
22039 init_constructs();
22040 }));
22041
22042 //#endregion
22043 //#region node_modules/micromark/lib/preprocess.js
22044 /**
22045 * @returns {Preprocessor}
22046 */
22047 function preprocess() {
22048 let column = 1;
22049 let buffer = "";
22050 /** @type {boolean | undefined} */
22051 let start = true;
22052 /** @type {boolean | undefined} */
22053 let atCarriageReturn;
22054 return preprocessor;
22055 /** @type {Preprocessor} */
22056 function preprocessor(value, encoding, end) {
22057 /** @type {Array<Chunk>} */
22058 const chunks = [];
22059 /** @type {RegExpMatchArray | null} */
22060 let match;
22061 /** @type {number} */
22062 let next;
22063 /** @type {number} */
22064 let startPosition;
22065 /** @type {number} */
22066 let endPosition;
22067 /** @type {Code} */
22068 let code;
22069 value = buffer + value.toString(encoding);
22070 startPosition = 0;
22071 buffer = "";
22072 if (start) {
22073 if (value.charCodeAt(0) === 65279) startPosition++;
22074 start = void 0;
22075 }
22076 while (startPosition < value.length) {
22077 search.lastIndex = startPosition;
22078 match = search.exec(value);
22079 endPosition = match && match.index !== void 0 ? match.index : value.length;
22080 code = value.charCodeAt(endPosition);
22081 if (!match) {
22082 buffer = value.slice(startPosition);
22083 break;
22084 }
22085 if (code === 10 && startPosition === endPosition && atCarriageReturn) {
22086 chunks.push(-3);
22087 atCarriageReturn = void 0;
22088 } else {
22089 if (atCarriageReturn) {
22090 chunks.push(-5);
22091 atCarriageReturn = void 0;
22092 }
22093 if (startPosition < endPosition) {
22094 chunks.push(value.slice(startPosition, endPosition));
22095 column += endPosition - startPosition;
22096 }
22097 switch (code) {
22098 case 0:
22099 chunks.push(65533);
22100 column++;
22101 break;
22102 case 9:
22103 next = Math.ceil(column / 4) * 4;
22104 chunks.push(-2);
22105 while (column++ < next) chunks.push(-1);
22106 break;
22107 case 10:
22108 chunks.push(-4);
22109 column = 1;
22110 break;
22111 default:
22112 atCarriageReturn = true;
22113 column = 1;
22114 }
22115 }
22116 startPosition = endPosition + 1;
22117 }
22118 if (end) {
22119 if (atCarriageReturn) chunks.push(-5);
22120 if (buffer) chunks.push(buffer);
22121 chunks.push(null);
22122 }
22123 return chunks;
22124 }
22125 }
22126 var search;
22127 var init_preprocess = __esmMin((() => {
22128 search = /[\0\t\n\r]/g;
22129 }));
22130
22131 //#endregion
22132 //#region node_modules/micromark/lib/postprocess.js
22133 /**
22134 * @param {Array<Event>} events
22135 * @returns {Array<Event>}
22136 */
22137 function postprocess(events) {
22138 while (!subtokenize(events));
22139 return events;
22140 }
22141 var init_postprocess = __esmMin((() => {
22142 init_micromark_util_subtokenize();
22143 }));
22144
22145 //#endregion
22146 //#region node_modules/micromark-util-decode-numeric-character-reference/index.js
22147 /**
22148 * Turn the number (in string form as either hexa- or plain decimal) coming from
22149 * a numeric character reference into a character.
22150 *
22151 * Sort of like `String.fromCharCode(Number.parseInt(value, base))`, but makes
22152 * non-characters and control characters safe.
22153 *
22154 * @param {string} value
22155 * Value to decode.
22156 * @param {number} base
22157 * Numeric base.
22158 * @returns {string}
22159 * Character.
22160 */
22161 function decodeNumericCharacterReference(value, base) {
22162 const code = Number.parseInt(value, base);
22163 if (code < 9 || code === 11 || code > 13 && code < 32 || code > 126 && code < 160 || code > 55295 && code < 57344 || code > 64975 && code < 65008 || (code & 65535) === 65535 || (code & 65535) === 65534 || code > 1114111) return "�";
22164 return String.fromCharCode(code);
22165 }
22166 var init_micromark_util_decode_numeric_character_reference = __esmMin((() => {}));
22167
22168 //#endregion
22169 //#region node_modules/micromark-util-decode-string/index.js
22170 /**
22171 * Decode markdown strings (which occur in places such as fenced code info
22172 * strings, destinations, labels, and titles).
22173 *
22174 * The “string” content type allows character escapes and -references.
22175 * This decodes those.
22176 *
22177 * @param {string} value
22178 * Value to decode.
22179 * @returns {string}
22180 * Decoded value.
22181 */
22182 function decodeString(value) {
22183 return value.replace(characterEscapeOrReference, decode);
22184 }
22185 /**
22186 * @param {string} $0
22187 * @param {string} $1
22188 * @param {string} $2
22189 * @returns {string}
22190 */
22191 function decode($0, $1, $2) {
22192 if ($1) return $1;
22193 if ($2.charCodeAt(0) === 35) {
22194 const head = $2.charCodeAt(1);
22195 const hex = head === 120 || head === 88;
22196 return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10);
22197 }
22198 return decodeNamedCharacterReference($2) || $0;
22199 }
22200 var characterEscapeOrReference;
22201 var init_micromark_util_decode_string = __esmMin((() => {
22202 init_index_dom();
22203 init_micromark_util_decode_numeric_character_reference();
22204 characterEscapeOrReference = /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;
22205 }));
22206
22207 //#endregion
22208 //#region node_modules/mdast-util-from-markdown/lib/index.js
22209 /**
22210 * Note this compiler only understand complete buffering, not streaming.
22211 *
22212 * @param {Options | null | undefined} [options]
22213 */
22214 function compiler(options) {
22215 /** @type {Config} */
22216 const config = {
22217 transforms: [],
22218 canContainEols: [
22219 "emphasis",
22220 "fragment",
22221 "heading",
22222 "paragraph",
22223 "strong"
22224 ],
22225 enter: {
22226 autolink: opener(link),
22227 autolinkProtocol: onenterdata,
22228 autolinkEmail: onenterdata,
22229 atxHeading: opener(heading),
22230 blockQuote: opener(blockQuote),
22231 characterEscape: onenterdata,
22232 characterReference: onenterdata,
22233 codeFenced: opener(codeFlow),
22234 codeFencedFenceInfo: buffer,
22235 codeFencedFenceMeta: buffer,
22236 codeIndented: opener(codeFlow, buffer),
22237 codeText: opener(codeText, buffer),
22238 codeTextData: onenterdata,
22239 data: onenterdata,
22240 codeFlowValue: onenterdata,
22241 definition: opener(definition),
22242 definitionDestinationString: buffer,
22243 definitionLabelString: buffer,
22244 definitionTitleString: buffer,
22245 emphasis: opener(emphasis),
22246 hardBreakEscape: opener(hardBreak),
22247 hardBreakTrailing: opener(hardBreak),
22248 htmlFlow: opener(html, buffer),
22249 htmlFlowData: onenterdata,
22250 htmlText: opener(html, buffer),
22251 htmlTextData: onenterdata,
22252 image: opener(image),
22253 label: buffer,
22254 link: opener(link),
22255 listItem: opener(listItem),
22256 listItemValue: onenterlistitemvalue,
22257 listOrdered: opener(list, onenterlistordered),
22258 listUnordered: opener(list),
22259 paragraph: opener(paragraph),
22260 reference: onenterreference,
22261 referenceString: buffer,
22262 resourceDestinationString: buffer,
22263 resourceTitleString: buffer,
22264 setextHeading: opener(heading),
22265 strong: opener(strong),
22266 thematicBreak: opener(thematicBreak)
22267 },
22268 exit: {
22269 atxHeading: closer(),
22270 atxHeadingSequence: onexitatxheadingsequence,
22271 autolink: closer(),
22272 autolinkEmail: onexitautolinkemail,
22273 autolinkProtocol: onexitautolinkprotocol,
22274 blockQuote: closer(),
22275 characterEscapeValue: onexitdata,
22276 characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker,
22277 characterReferenceMarkerNumeric: onexitcharacterreferencemarker,
22278 characterReferenceValue: onexitcharacterreferencevalue,
22279 codeFenced: closer(onexitcodefenced),
22280 codeFencedFence: onexitcodefencedfence,
22281 codeFencedFenceInfo: onexitcodefencedfenceinfo,
22282 codeFencedFenceMeta: onexitcodefencedfencemeta,
22283 codeFlowValue: onexitdata,
22284 codeIndented: closer(onexitcodeindented),
22285 codeText: closer(onexitcodetext),
22286 codeTextData: onexitdata,
22287 data: onexitdata,
22288 definition: closer(),
22289 definitionDestinationString: onexitdefinitiondestinationstring,
22290 definitionLabelString: onexitdefinitionlabelstring,
22291 definitionTitleString: onexitdefinitiontitlestring,
22292 emphasis: closer(),
22293 hardBreakEscape: closer(onexithardbreak),
22294 hardBreakTrailing: closer(onexithardbreak),
22295 htmlFlow: closer(onexithtmlflow),
22296 htmlFlowData: onexitdata,
22297 htmlText: closer(onexithtmltext),
22298 htmlTextData: onexitdata,
22299 image: closer(onexitimage),
22300 label: onexitlabel,
22301 labelText: onexitlabeltext,
22302 lineEnding: onexitlineending,
22303 link: closer(onexitlink),
22304 listItem: closer(),
22305 listOrdered: closer(),
22306 listUnordered: closer(),
22307 paragraph: closer(),
22308 referenceString: onexitreferencestring,
22309 resourceDestinationString: onexitresourcedestinationstring,
22310 resourceTitleString: onexitresourcetitlestring,
22311 resource: onexitresource,
22312 setextHeading: closer(onexitsetextheading),
22313 setextHeadingLineSequence: onexitsetextheadinglinesequence,
22314 setextHeadingText: onexitsetextheadingtext,
22315 strong: closer(),
22316 thematicBreak: closer()
22317 }
22318 };
22319 configure(config, (options || {}).mdastExtensions || []);
22320 /** @type {CompileData} */
22321 const data = {};
22322 return compile;
22323 /**
22324 * Turn micromark events into an mdast tree.
22325 *
22326 * @param {Array<Event>} events
22327 * Events.
22328 * @returns {Root}
22329 * mdast tree.
22330 */
22331 function compile(events) {
22332 /** @type {Root} */
22333 let tree = {
22334 type: "root",
22335 children: []
22336 };
22337 /** @type {Omit<CompileContext, 'sliceSerialize'>} */
22338 const context = {
22339 stack: [tree],
22340 tokenStack: [],
22341 config,
22342 enter,
22343 exit,
22344 buffer,
22345 resume,
22346 setData,
22347 getData
22348 };
22349 /** @type {Array<number>} */
22350 const listStack = [];
22351 let index = -1;
22352 while (++index < events.length) if (events[index][1].type === "listOrdered" || events[index][1].type === "listUnordered") if (events[index][0] === "enter") listStack.push(index);
22353 else index = prepareList(events, listStack.pop(), index);
22354 index = -1;
22355 while (++index < events.length) {
22356 const handler = config[events[index][0]];
22357 if (own$5.call(handler, events[index][1].type)) handler[events[index][1].type].call(Object.assign({ sliceSerialize: events[index][2].sliceSerialize }, context), events[index][1]);
22358 }
22359 if (context.tokenStack.length > 0) {
22360 const tail = context.tokenStack[context.tokenStack.length - 1];
22361 (tail[1] || defaultOnError).call(context, void 0, tail[0]);
22362 }
22363 tree.position = {
22364 start: point$1(events.length > 0 ? events[0][1].start : {
22365 line: 1,
22366 column: 1,
22367 offset: 0
22368 }),
22369 end: point$1(events.length > 0 ? events[events.length - 2][1].end : {
22370 line: 1,
22371 column: 1,
22372 offset: 0
22373 })
22374 };
22375 index = -1;
22376 while (++index < config.transforms.length) tree = config.transforms[index](tree) || tree;
22377 return tree;
22378 }
22379 /**
22380 * @param {Array<Event>} events
22381 * @param {number} start
22382 * @param {number} length
22383 * @returns {number}
22384 */
22385 function prepareList(events, start, length) {
22386 let index = start - 1;
22387 let containerBalance = -1;
22388 let listSpread = false;
22389 /** @type {Token | undefined} */
22390 let listItem;
22391 /** @type {number | undefined} */
22392 let lineIndex;
22393 /** @type {number | undefined} */
22394 let firstBlankLineIndex;
22395 /** @type {boolean | undefined} */
22396 let atMarker;
22397 while (++index <= length) {
22398 const event = events[index];
22399 if (event[1].type === "listUnordered" || event[1].type === "listOrdered" || event[1].type === "blockQuote") {
22400 if (event[0] === "enter") containerBalance++;
22401 else containerBalance--;
22402 atMarker = void 0;
22403 } else if (event[1].type === "lineEndingBlank") {
22404 if (event[0] === "enter") {
22405 if (listItem && !atMarker && !containerBalance && !firstBlankLineIndex) firstBlankLineIndex = index;
22406 atMarker = void 0;
22407 }
22408 } else if (event[1].type === "linePrefix" || event[1].type === "listItemValue" || event[1].type === "listItemMarker" || event[1].type === "listItemPrefix" || event[1].type === "listItemPrefixWhitespace") {} else atMarker = void 0;
22409 if (!containerBalance && event[0] === "enter" && event[1].type === "listItemPrefix" || containerBalance === -1 && event[0] === "exit" && (event[1].type === "listUnordered" || event[1].type === "listOrdered")) {
22410 if (listItem) {
22411 let tailIndex = index;
22412 lineIndex = void 0;
22413 while (tailIndex--) {
22414 const tailEvent = events[tailIndex];
22415 if (tailEvent[1].type === "lineEnding" || tailEvent[1].type === "lineEndingBlank") {
22416 if (tailEvent[0] === "exit") continue;
22417 if (lineIndex) {
22418 events[lineIndex][1].type = "lineEndingBlank";
22419 listSpread = true;
22420 }
22421 tailEvent[1].type = "lineEnding";
22422 lineIndex = tailIndex;
22423 } else if (tailEvent[1].type === "linePrefix" || tailEvent[1].type === "blockQuotePrefix" || tailEvent[1].type === "blockQuotePrefixWhitespace" || tailEvent[1].type === "blockQuoteMarker" || tailEvent[1].type === "listItemIndent") {} else break;
22424 }
22425 if (firstBlankLineIndex && (!lineIndex || firstBlankLineIndex < lineIndex)) listItem._spread = true;
22426 listItem.end = Object.assign({}, lineIndex ? events[lineIndex][1].start : event[1].end);
22427 events.splice(lineIndex || index, 0, [
22428 "exit",
22429 listItem,
22430 event[2]
22431 ]);
22432 index++;
22433 length++;
22434 }
22435 if (event[1].type === "listItemPrefix") {
22436 listItem = {
22437 type: "listItem",
22438 _spread: false,
22439 start: Object.assign({}, event[1].start),
22440 end: void 0
22441 };
22442 events.splice(index, 0, [
22443 "enter",
22444 listItem,
22445 event[2]
22446 ]);
22447 index++;
22448 length++;
22449 firstBlankLineIndex = void 0;
22450 atMarker = true;
22451 }
22452 }
22453 }
22454 events[start][1]._spread = listSpread;
22455 return length;
22456 }
22457 /**
22458 * Set data.
22459 *
22460 * @template {keyof CompileData} Key
22461 * Field type.
22462 * @param {Key} key
22463 * Key of field.
22464 * @param {CompileData[Key]} [value]
22465 * New value.
22466 * @returns {void}
22467 * Nothing.
22468 */
22469 function setData(key, value) {
22470 data[key] = value;
22471 }
22472 /**
22473 * Get data.
22474 *
22475 * @template {keyof CompileData} Key
22476 * Field type.
22477 * @param {Key} key
22478 * Key of field.
22479 * @returns {CompileData[Key]}
22480 * Value.
22481 */
22482 function getData(key) {
22483 return data[key];
22484 }
22485 /**
22486 * Create an opener handle.
22487 *
22488 * @param {(token: Token) => Node} create
22489 * Create a node.
22490 * @param {Handle} [and]
22491 * Optional function to also run.
22492 * @returns {Handle}
22493 * Handle.
22494 */
22495 function opener(create, and) {
22496 return open;
22497 /**
22498 * @this {CompileContext}
22499 * @param {Token} token
22500 * @returns {void}
22501 */
22502 function open(token) {
22503 enter.call(this, create(token), token);
22504 if (and) and.call(this, token);
22505 }
22506 }
22507 /**
22508 * @this {CompileContext}
22509 * @returns {void}
22510 */
22511 function buffer() {
22512 this.stack.push({
22513 type: "fragment",
22514 children: []
22515 });
22516 }
22517 /**
22518 * @template {Node} Kind
22519 * Node type.
22520 * @this {CompileContext}
22521 * Context.
22522 * @param {Kind} node
22523 * Node to enter.
22524 * @param {Token} token
22525 * Corresponding token.
22526 * @param {OnEnterError | undefined} [errorHandler]
22527 * Handle the case where this token is open, but it is closed by something else.
22528 * @returns {Kind}
22529 * The given node.
22530 */
22531 function enter(node, token, errorHandler) {
22532 this.stack[this.stack.length - 1].children.push(node);
22533 this.stack.push(node);
22534 this.tokenStack.push([token, errorHandler]);
22535 node.position = { start: point$1(token.start) };
22536 return node;
22537 }
22538 /**
22539 * Create a closer handle.
22540 *
22541 * @param {Handle} [and]
22542 * Optional function to also run.
22543 * @returns {Handle}
22544 * Handle.
22545 */
22546 function closer(and) {
22547 return close;
22548 /**
22549 * @this {CompileContext}
22550 * @param {Token} token
22551 * @returns {void}
22552 */
22553 function close(token) {
22554 if (and) and.call(this, token);
22555 exit.call(this, token);
22556 }
22557 }
22558 /**
22559 * @this {CompileContext}
22560 * Context.
22561 * @param {Token} token
22562 * Corresponding token.
22563 * @param {OnExitError | undefined} [onExitError]
22564 * Handle the case where another token is open.
22565 * @returns {Node}
22566 * The closed node.
22567 */
22568 function exit(token, onExitError) {
22569 const node = this.stack.pop();
22570 const open = this.tokenStack.pop();
22571 if (!open) throw new Error("Cannot close `" + token.type + "` (" + stringifyPosition({
22572 start: token.start,
22573 end: token.end
22574 }) + "): it’s not open");
22575 else if (open[0].type !== token.type) if (onExitError) onExitError.call(this, token, open[0]);
22576 else (open[1] || defaultOnError).call(this, token, open[0]);
22577 node.position.end = point$1(token.end);
22578 return node;
22579 }
22580 /**
22581 * @this {CompileContext}
22582 * @returns {string}
22583 */
22584 function resume() {
22585 return toString(this.stack.pop());
22586 }
22587 /**
22588 * @this {CompileContext}
22589 * @type {Handle}
22590 */
22591 function onenterlistordered() {
22592 setData("expectingFirstListItemValue", true);
22593 }
22594 /**
22595 * @this {CompileContext}
22596 * @type {Handle}
22597 */
22598 function onenterlistitemvalue(token) {
22599 if (getData("expectingFirstListItemValue")) {
22600 const ancestor = this.stack[this.stack.length - 2];
22601 ancestor.start = Number.parseInt(this.sliceSerialize(token), 10);
22602 setData("expectingFirstListItemValue");
22603 }
22604 }
22605 /**
22606 * @this {CompileContext}
22607 * @type {Handle}
22608 */
22609 function onexitcodefencedfenceinfo() {
22610 const data = this.resume();
22611 const node = this.stack[this.stack.length - 1];
22612 node.lang = data;
22613 }
22614 /**
22615 * @this {CompileContext}
22616 * @type {Handle}
22617 */
22618 function onexitcodefencedfencemeta() {
22619 const data = this.resume();
22620 const node = this.stack[this.stack.length - 1];
22621 node.meta = data;
22622 }
22623 /**
22624 * @this {CompileContext}
22625 * @type {Handle}
22626 */
22627 function onexitcodefencedfence() {
22628 if (getData("flowCodeInside")) return;
22629 this.buffer();
22630 setData("flowCodeInside", true);
22631 }
22632 /**
22633 * @this {CompileContext}
22634 * @type {Handle}
22635 */
22636 function onexitcodefenced() {
22637 const data = this.resume();
22638 const node = this.stack[this.stack.length - 1];
22639 node.value = data.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, "");
22640 setData("flowCodeInside");
22641 }
22642 /**
22643 * @this {CompileContext}
22644 * @type {Handle}
22645 */
22646 function onexitcodeindented() {
22647 const data = this.resume();
22648 const node = this.stack[this.stack.length - 1];
22649 node.value = data.replace(/(\r?\n|\r)$/g, "");
22650 }
22651 /**
22652 * @this {CompileContext}
22653 * @type {Handle}
22654 */
22655 function onexitdefinitionlabelstring(token) {
22656 const label = this.resume();
22657 const node = this.stack[this.stack.length - 1];
22658 node.label = label;
22659 node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();
22660 }
22661 /**
22662 * @this {CompileContext}
22663 * @type {Handle}
22664 */
22665 function onexitdefinitiontitlestring() {
22666 const data = this.resume();
22667 const node = this.stack[this.stack.length - 1];
22668 node.title = data;
22669 }
22670 /**
22671 * @this {CompileContext}
22672 * @type {Handle}
22673 */
22674 function onexitdefinitiondestinationstring() {
22675 const data = this.resume();
22676 const node = this.stack[this.stack.length - 1];
22677 node.url = data;
22678 }
22679 /**
22680 * @this {CompileContext}
22681 * @type {Handle}
22682 */
22683 function onexitatxheadingsequence(token) {
22684 const node = this.stack[this.stack.length - 1];
22685 if (!node.depth) node.depth = this.sliceSerialize(token).length;
22686 }
22687 /**
22688 * @this {CompileContext}
22689 * @type {Handle}
22690 */
22691 function onexitsetextheadingtext() {
22692 setData("setextHeadingSlurpLineEnding", true);
22693 }
22694 /**
22695 * @this {CompileContext}
22696 * @type {Handle}
22697 */
22698 function onexitsetextheadinglinesequence(token) {
22699 const node = this.stack[this.stack.length - 1];
22700 node.depth = this.sliceSerialize(token).charCodeAt(0) === 61 ? 1 : 2;
22701 }
22702 /**
22703 * @this {CompileContext}
22704 * @type {Handle}
22705 */
22706 function onexitsetextheading() {
22707 setData("setextHeadingSlurpLineEnding");
22708 }
22709 /**
22710 * @this {CompileContext}
22711 * @type {Handle}
22712 */
22713 function onenterdata(token) {
22714 const node = this.stack[this.stack.length - 1];
22715 let tail = node.children[node.children.length - 1];
22716 if (!tail || tail.type !== "text") {
22717 tail = text();
22718 tail.position = { start: point$1(token.start) };
22719 node.children.push(tail);
22720 }
22721 this.stack.push(tail);
22722 }
22723 /**
22724 * @this {CompileContext}
22725 * @type {Handle}
22726 */
22727 function onexitdata(token) {
22728 const tail = this.stack.pop();
22729 tail.value += this.sliceSerialize(token);
22730 tail.position.end = point$1(token.end);
22731 }
22732 /**
22733 * @this {CompileContext}
22734 * @type {Handle}
22735 */
22736 function onexitlineending(token) {
22737 const context = this.stack[this.stack.length - 1];
22738 if (getData("atHardBreak")) {
22739 const tail = context.children[context.children.length - 1];
22740 tail.position.end = point$1(token.end);
22741 setData("atHardBreak");
22742 return;
22743 }
22744 if (!getData("setextHeadingSlurpLineEnding") && config.canContainEols.includes(context.type)) {
22745 onenterdata.call(this, token);
22746 onexitdata.call(this, token);
22747 }
22748 }
22749 /**
22750 * @this {CompileContext}
22751 * @type {Handle}
22752 */
22753 function onexithardbreak() {
22754 setData("atHardBreak", true);
22755 }
22756 /**
22757 * @this {CompileContext}
22758 * @type {Handle}
22759 */
22760 function onexithtmlflow() {
22761 const data = this.resume();
22762 const node = this.stack[this.stack.length - 1];
22763 node.value = data;
22764 }
22765 /**
22766 * @this {CompileContext}
22767 * @type {Handle}
22768 */
22769 function onexithtmltext() {
22770 const data = this.resume();
22771 const node = this.stack[this.stack.length - 1];
22772 node.value = data;
22773 }
22774 /**
22775 * @this {CompileContext}
22776 * @type {Handle}
22777 */
22778 function onexitcodetext() {
22779 const data = this.resume();
22780 const node = this.stack[this.stack.length - 1];
22781 node.value = data;
22782 }
22783 /**
22784 * @this {CompileContext}
22785 * @type {Handle}
22786 */
22787 function onexitlink() {
22788 const node = this.stack[this.stack.length - 1];
22789 if (getData("inReference")) {
22790 /** @type {ReferenceType} */
22791 const referenceType = getData("referenceType") || "shortcut";
22792 node.type += "Reference";
22793 node.referenceType = referenceType;
22794 delete node.url;
22795 delete node.title;
22796 } else {
22797 delete node.identifier;
22798 delete node.label;
22799 }
22800 setData("referenceType");
22801 }
22802 /**
22803 * @this {CompileContext}
22804 * @type {Handle}
22805 */
22806 function onexitimage() {
22807 const node = this.stack[this.stack.length - 1];
22808 if (getData("inReference")) {
22809 /** @type {ReferenceType} */
22810 const referenceType = getData("referenceType") || "shortcut";
22811 node.type += "Reference";
22812 node.referenceType = referenceType;
22813 delete node.url;
22814 delete node.title;
22815 } else {
22816 delete node.identifier;
22817 delete node.label;
22818 }
22819 setData("referenceType");
22820 }
22821 /**
22822 * @this {CompileContext}
22823 * @type {Handle}
22824 */
22825 function onexitlabeltext(token) {
22826 const string = this.sliceSerialize(token);
22827 const ancestor = this.stack[this.stack.length - 2];
22828 ancestor.label = decodeString(string);
22829 ancestor.identifier = normalizeIdentifier(string).toLowerCase();
22830 }
22831 /**
22832 * @this {CompileContext}
22833 * @type {Handle}
22834 */
22835 function onexitlabel() {
22836 const fragment = this.stack[this.stack.length - 1];
22837 const value = this.resume();
22838 const node = this.stack[this.stack.length - 1];
22839 setData("inReference", true);
22840 if (node.type === "link") node.children = fragment.children;
22841 else node.alt = value;
22842 }
22843 /**
22844 * @this {CompileContext}
22845 * @type {Handle}
22846 */
22847 function onexitresourcedestinationstring() {
22848 const data = this.resume();
22849 const node = this.stack[this.stack.length - 1];
22850 node.url = data;
22851 }
22852 /**
22853 * @this {CompileContext}
22854 * @type {Handle}
22855 */
22856 function onexitresourcetitlestring() {
22857 const data = this.resume();
22858 const node = this.stack[this.stack.length - 1];
22859 node.title = data;
22860 }
22861 /**
22862 * @this {CompileContext}
22863 * @type {Handle}
22864 */
22865 function onexitresource() {
22866 setData("inReference");
22867 }
22868 /**
22869 * @this {CompileContext}
22870 * @type {Handle}
22871 */
22872 function onenterreference() {
22873 setData("referenceType", "collapsed");
22874 }
22875 /**
22876 * @this {CompileContext}
22877 * @type {Handle}
22878 */
22879 function onexitreferencestring(token) {
22880 const label = this.resume();
22881 const node = this.stack[this.stack.length - 1];
22882 node.label = label;
22883 node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();
22884 setData("referenceType", "full");
22885 }
22886 /**
22887 * @this {CompileContext}
22888 * @type {Handle}
22889 */
22890 function onexitcharacterreferencemarker(token) {
22891 setData("characterReferenceType", token.type);
22892 }
22893 /**
22894 * @this {CompileContext}
22895 * @type {Handle}
22896 */
22897 function onexitcharacterreferencevalue(token) {
22898 const data = this.sliceSerialize(token);
22899 const type = getData("characterReferenceType");
22900 /** @type {string} */
22901 let value;
22902 if (type) {
22903 value = decodeNumericCharacterReference(data, type === "characterReferenceMarkerNumeric" ? 10 : 16);
22904 setData("characterReferenceType");
22905 } else value = decodeNamedCharacterReference(data);
22906 const tail = this.stack.pop();
22907 tail.value += value;
22908 tail.position.end = point$1(token.end);
22909 }
22910 /**
22911 * @this {CompileContext}
22912 * @type {Handle}
22913 */
22914 function onexitautolinkprotocol(token) {
22915 onexitdata.call(this, token);
22916 const node = this.stack[this.stack.length - 1];
22917 node.url = this.sliceSerialize(token);
22918 }
22919 /**
22920 * @this {CompileContext}
22921 * @type {Handle}
22922 */
22923 function onexitautolinkemail(token) {
22924 onexitdata.call(this, token);
22925 const node = this.stack[this.stack.length - 1];
22926 node.url = "mailto:" + this.sliceSerialize(token);
22927 }
22928 /** @returns {Blockquote} */
22929 function blockQuote() {
22930 return {
22931 type: "blockquote",
22932 children: []
22933 };
22934 }
22935 /** @returns {Code} */
22936 function codeFlow() {
22937 return {
22938 type: "code",
22939 lang: null,
22940 meta: null,
22941 value: ""
22942 };
22943 }
22944 /** @returns {InlineCode} */
22945 function codeText() {
22946 return {
22947 type: "inlineCode",
22948 value: ""
22949 };
22950 }
22951 /** @returns {Definition} */
22952 function definition() {
22953 return {
22954 type: "definition",
22955 identifier: "",
22956 label: null,
22957 title: null,
22958 url: ""
22959 };
22960 }
22961 /** @returns {Emphasis} */
22962 function emphasis() {
22963 return {
22964 type: "emphasis",
22965 children: []
22966 };
22967 }
22968 /** @returns {Heading} */
22969 function heading() {
22970 return {
22971 type: "heading",
22972 depth: void 0,
22973 children: []
22974 };
22975 }
22976 /** @returns {Break} */
22977 function hardBreak() {
22978 return { type: "break" };
22979 }
22980 /** @returns {HTML} */
22981 function html() {
22982 return {
22983 type: "html",
22984 value: ""
22985 };
22986 }
22987 /** @returns {Image} */
22988 function image() {
22989 return {
22990 type: "image",
22991 title: null,
22992 url: "",
22993 alt: null
22994 };
22995 }
22996 /** @returns {Link} */
22997 function link() {
22998 return {
22999 type: "link",
23000 title: null,
23001 url: "",
23002 children: []
23003 };
23004 }
23005 /**
23006 * @param {Token} token
23007 * @returns {List}
23008 */
23009 function list(token) {
23010 return {
23011 type: "list",
23012 ordered: token.type === "listOrdered",
23013 start: null,
23014 spread: token._spread,
23015 children: []
23016 };
23017 }
23018 /**
23019 * @param {Token} token
23020 * @returns {ListItem}
23021 */
23022 function listItem(token) {
23023 return {
23024 type: "listItem",
23025 spread: token._spread,
23026 checked: null,
23027 children: []
23028 };
23029 }
23030 /** @returns {Paragraph} */
23031 function paragraph() {
23032 return {
23033 type: "paragraph",
23034 children: []
23035 };
23036 }
23037 /** @returns {Strong} */
23038 function strong() {
23039 return {
23040 type: "strong",
23041 children: []
23042 };
23043 }
23044 /** @returns {Text} */
23045 function text() {
23046 return {
23047 type: "text",
23048 value: ""
23049 };
23050 }
23051 /** @returns {ThematicBreak} */
23052 function thematicBreak() {
23053 return { type: "thematicBreak" };
23054 }
23055 }
23056 /**
23057 * Copy a point-like value.
23058 *
23059 * @param {Point} d
23060 * Point-like value.
23061 * @returns {Point}
23062 * unist point.
23063 */
23064 function point$1(d) {
23065 return {
23066 line: d.line,
23067 column: d.column,
23068 offset: d.offset
23069 };
23070 }
23071 /**
23072 * @param {Config} combined
23073 * @param {Array<Extension | Array<Extension>>} extensions
23074 * @returns {void}
23075 */
23076 function configure(combined, extensions) {
23077 let index = -1;
23078 while (++index < extensions.length) {
23079 const value = extensions[index];
23080 if (Array.isArray(value)) configure(combined, value);
23081 else extension(combined, value);
23082 }
23083 }
23084 /**
23085 * @param {Config} combined
23086 * @param {Extension} extension
23087 * @returns {void}
23088 */
23089 function extension(combined, extension) {
23090 /** @type {keyof Extension} */
23091 let key;
23092 for (key in extension) if (own$5.call(extension, key)) {
23093 if (key === "canContainEols") {
23094 const right = extension[key];
23095 if (right) combined[key].push(...right);
23096 } else if (key === "transforms") {
23097 const right = extension[key];
23098 if (right) combined[key].push(...right);
23099 } else if (key === "enter" || key === "exit") {
23100 const right = extension[key];
23101 if (right) Object.assign(combined[key], right);
23102 }
23103 }
23104 }
23105 /** @type {OnEnterError} */
23106 function defaultOnError(left, right) {
23107 if (left) throw new Error("Cannot close `" + left.type + "` (" + stringifyPosition({
23108 start: left.start,
23109 end: left.end
23110 }) + "): a different token (`" + right.type + "`, " + stringifyPosition({
23111 start: right.start,
23112 end: right.end
23113 }) + ") is open");
23114 else throw new Error("Cannot close document, a token (`" + right.type + "`, " + stringifyPosition({
23115 start: right.start,
23116 end: right.end
23117 }) + ") is still open");
23118 }
23119 var own$5, fromMarkdown;
23120 var init_lib$9 = __esmMin((() => {
23121 init_mdast_util_to_string();
23122 init_parse();
23123 init_preprocess();
23124 init_postprocess();
23125 init_micromark_util_decode_numeric_character_reference();
23126 init_micromark_util_decode_string();
23127 init_micromark_util_normalize_identifier();
23128 init_index_dom();
23129 init_unist_util_stringify_position();
23130 own$5 = {}.hasOwnProperty;
23131 fromMarkdown = function(value, encoding, options) {
23132 if (typeof encoding !== "string") {
23133 options = encoding;
23134 encoding = void 0;
23135 }
23136 return compiler(options)(postprocess(parse(options).document().write(preprocess()(value, encoding, true))));
23137 };
23138 __name(point$1, "point");
23139 }));
23140
23141 //#endregion
23142 //#region node_modules/mdast-util-from-markdown/index.js
23143 var init_mdast_util_from_markdown = __esmMin((() => {
23144 init_lib$9();
23145 }));
23146
23147 //#endregion
23148 //#region node_modules/remark-parse/lib/index.js
23149 /**
23150 * @this {import('unified').Processor}
23151 * @type {import('unified').Plugin<[Options?] | void[], string, Root>}
23152 */
23153 function remarkParse(options) {
23154 /** @type {import('unified').ParserFunction<Root>} */
23155 const parser = (doc) => {
23156 const settings = this.data("settings");
23157 return fromMarkdown(doc, Object.assign({}, settings, options, {
23158 extensions: this.data("micromarkExtensions") || [],
23159 mdastExtensions: this.data("fromMarkdownExtensions") || []
23160 }));
23161 };
23162 Object.assign(this, { Parser: parser });
23163 }
23164 var init_lib$8 = __esmMin((() => {
23165 init_mdast_util_from_markdown();
23166 }));
23167
23168 //#endregion
23169 //#region node_modules/remark-parse/index.js
23170 var init_remark_parse = __esmMin((() => {
23171 init_lib$8();
23172 }));
23173
23174 //#endregion
23175 //#region node_modules/mdast-util-to-hast/lib/handlers/blockquote.js
23176 /**
23177 * @typedef {import('hast').Element} Element
23178 * @typedef {import('mdast').Blockquote} Blockquote
23179 * @typedef {import('../state.js').State} State
23180 */
23181 /**
23182 * Turn an mdast `blockquote` node into hast.
23183 *
23184 * @param {State} state
23185 * Info passed around.
23186 * @param {Blockquote} node
23187 * mdast node.
23188 * @returns {Element}
23189 * hast node.
23190 */
23191 function blockquote(state, node) {
23192 /** @type {Element} */
23193 const result = {
23194 type: "element",
23195 tagName: "blockquote",
23196 properties: {},
23197 children: state.wrap(state.all(node), true)
23198 };
23199 state.patch(node, result);
23200 return state.applyData(node, result);
23201 }
23202 var init_blockquote = __esmMin((() => {}));
23203
23204 //#endregion
23205 //#region node_modules/mdast-util-to-hast/lib/handlers/break.js
23206 /**
23207 * @typedef {import('hast').Element} Element
23208 * @typedef {import('hast').Text} Text
23209 * @typedef {import('mdast').Break} Break
23210 * @typedef {import('../state.js').State} State
23211 */
23212 /**
23213 * Turn an mdast `break` node into hast.
23214 *
23215 * @param {State} state
23216 * Info passed around.
23217 * @param {Break} node
23218 * mdast node.
23219 * @returns {Array<Element | Text>}
23220 * hast element content.
23221 */
23222 function hardBreak(state, node) {
23223 /** @type {Element} */
23224 const result = {
23225 type: "element",
23226 tagName: "br",
23227 properties: {},
23228 children: []
23229 };
23230 state.patch(node, result);
23231 return [state.applyData(node, result), {
23232 type: "text",
23233 value: "\n"
23234 }];
23235 }
23236 var init_break = __esmMin((() => {}));
23237
23238 //#endregion
23239 //#region node_modules/mdast-util-to-hast/lib/handlers/code.js
23240 /**
23241 * @typedef {import('hast').Element} Element
23242 * @typedef {import('hast').Properties} Properties
23243 * @typedef {import('mdast').Code} Code
23244 * @typedef {import('../state.js').State} State
23245
23246 */
23247 /**
23248 * Turn an mdast `code` node into hast.
23249 *
23250 * @param {State} state
23251 * Info passed around.
23252 * @param {Code} node
23253 * mdast node.
23254 * @returns {Element}
23255 * hast node.
23256 */
23257 function code(state, node) {
23258 const value = node.value ? node.value + "\n" : "";
23259 const lang = node.lang ? node.lang.match(/^[^ \t]+(?=[ \t]|$)/) : null;
23260 /** @type {Properties} */
23261 const properties = {};
23262 if (lang) properties.className = ["language-" + lang];
23263 /** @type {Element} */
23264 let result = {
23265 type: "element",
23266 tagName: "code",
23267 properties,
23268 children: [{
23269 type: "text",
23270 value
23271 }]
23272 };
23273 if (node.meta) result.data = { meta: node.meta };
23274 state.patch(node, result);
23275 result = state.applyData(node, result);
23276 result = {
23277 type: "element",
23278 tagName: "pre",
23279 properties: {},
23280 children: [result]
23281 };
23282 state.patch(node, result);
23283 return result;
23284 }
23285 var init_code = __esmMin((() => {}));
23286
23287 //#endregion
23288 //#region node_modules/mdast-util-to-hast/lib/handlers/delete.js
23289 /**
23290 * @typedef {import('hast').Element} Element
23291 * @typedef {import('mdast').Delete} Delete
23292 * @typedef {import('../state.js').State} State
23293
23294 */
23295 /**
23296 * Turn an mdast `delete` node into hast.
23297 *
23298 * @param {State} state
23299 * Info passed around.
23300 * @param {Delete} node
23301 * mdast node.
23302 * @returns {Element}
23303 * hast node.
23304 */
23305 function strikethrough(state, node) {
23306 /** @type {Element} */
23307 const result = {
23308 type: "element",
23309 tagName: "del",
23310 properties: {},
23311 children: state.all(node)
23312 };
23313 state.patch(node, result);
23314 return state.applyData(node, result);
23315 }
23316 var init_delete = __esmMin((() => {}));
23317
23318 //#endregion
23319 //#region node_modules/mdast-util-to-hast/lib/handlers/emphasis.js
23320 /**
23321 * @typedef {import('hast').Element} Element
23322 * @typedef {import('mdast').Emphasis} Emphasis
23323 * @typedef {import('../state.js').State} State
23324 */
23325 /**
23326 * Turn an mdast `emphasis` node into hast.
23327 *
23328 * @param {State} state
23329 * Info passed around.
23330 * @param {Emphasis} node
23331 * mdast node.
23332 * @returns {Element}
23333 * hast node.
23334 */
23335 function emphasis(state, node) {
23336 /** @type {Element} */
23337 const result = {
23338 type: "element",
23339 tagName: "em",
23340 properties: {},
23341 children: state.all(node)
23342 };
23343 state.patch(node, result);
23344 return state.applyData(node, result);
23345 }
23346 var init_emphasis = __esmMin((() => {}));
23347
23348 //#endregion
23349 //#region node_modules/micromark-util-sanitize-uri/index.js
23350 /**
23351 * Normalize a URL.
23352 *
23353 * Encode unsafe characters with percent-encoding, skipping already encoded
23354 * sequences.
23355 *
23356 * @param {string} value
23357 * URI to normalize.
23358 * @returns {string}
23359 * Normalized URI.
23360 */
23361 function normalizeUri(value) {
23362 /** @type {Array<string>} */
23363 const result = [];
23364 let index = -1;
23365 let start = 0;
23366 let skip = 0;
23367 while (++index < value.length) {
23368 const code = value.charCodeAt(index);
23369 /** @type {string} */
23370 let replace = "";
23371 if (code === 37 && asciiAlphanumeric(value.charCodeAt(index + 1)) && asciiAlphanumeric(value.charCodeAt(index + 2))) skip = 2;
23372 else if (code < 128) {
23373 if (!/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(code))) replace = String.fromCharCode(code);
23374 } else if (code > 55295 && code < 57344) {
23375 const next = value.charCodeAt(index + 1);
23376 if (code < 56320 && next > 56319 && next < 57344) {
23377 replace = String.fromCharCode(code, next);
23378 skip = 1;
23379 } else replace = "�";
23380 } else replace = String.fromCharCode(code);
23381 if (replace) {
23382 result.push(value.slice(start, index), encodeURIComponent(replace));
23383 start = index + skip + 1;
23384 replace = "";
23385 }
23386 if (skip) {
23387 index += skip;
23388 skip = 0;
23389 }
23390 }
23391 return result.join("") + value.slice(start);
23392 }
23393 var init_micromark_util_sanitize_uri = __esmMin((() => {
23394 init_micromark_util_character();
23395 }));
23396
23397 //#endregion
23398 //#region node_modules/mdast-util-to-hast/lib/handlers/footnote-reference.js
23399 /**
23400 * Turn an mdast `footnoteReference` node into hast.
23401 *
23402 * @param {State} state
23403 * Info passed around.
23404 * @param {FootnoteReference} node
23405 * mdast node.
23406 * @returns {Element}
23407 * hast node.
23408 */
23409 function footnoteReference(state, node) {
23410 const id = String(node.identifier).toUpperCase();
23411 const safeId = normalizeUri(id.toLowerCase());
23412 const index = state.footnoteOrder.indexOf(id);
23413 /** @type {number} */
23414 let counter;
23415 if (index === -1) {
23416 state.footnoteOrder.push(id);
23417 state.footnoteCounts[id] = 1;
23418 counter = state.footnoteOrder.length;
23419 } else {
23420 state.footnoteCounts[id]++;
23421 counter = index + 1;
23422 }
23423 const reuseCounter = state.footnoteCounts[id];
23424 /** @type {Element} */
23425 const link = {
23426 type: "element",
23427 tagName: "a",
23428 properties: {
23429 href: "#" + state.clobberPrefix + "fn-" + safeId,
23430 id: state.clobberPrefix + "fnref-" + safeId + (reuseCounter > 1 ? "-" + reuseCounter : ""),
23431 dataFootnoteRef: true,
23432 ariaDescribedBy: ["footnote-label"]
23433 },
23434 children: [{
23435 type: "text",
23436 value: String(counter)
23437 }]
23438 };
23439 state.patch(node, link);
23440 /** @type {Element} */
23441 const sup = {
23442 type: "element",
23443 tagName: "sup",
23444 properties: {},
23445 children: [link]
23446 };
23447 state.patch(node, sup);
23448 return state.applyData(node, sup);
23449 }
23450 var init_footnote_reference = __esmMin((() => {
23451 init_micromark_util_sanitize_uri();
23452 }));
23453
23454 //#endregion
23455 //#region node_modules/mdast-util-to-hast/lib/handlers/footnote.js
23456 /**
23457 * Turn an mdast `footnote` node into hast.
23458 *
23459 * @param {State} state
23460 * Info passed around.
23461 * @param {Footnote} node
23462 * mdast node.
23463 * @returns {Element}
23464 * hast node.
23465 */
23466 function footnote(state, node) {
23467 const footnoteById = state.footnoteById;
23468 let no = 1;
23469 while (no in footnoteById) no++;
23470 const identifier = String(no);
23471 footnoteById[identifier] = {
23472 type: "footnoteDefinition",
23473 identifier,
23474 children: [{
23475 type: "paragraph",
23476 children: node.children
23477 }],
23478 position: node.position
23479 };
23480 return footnoteReference(state, {
23481 type: "footnoteReference",
23482 identifier,
23483 position: node.position
23484 });
23485 }
23486 var init_footnote = __esmMin((() => {
23487 init_footnote_reference();
23488 }));
23489
23490 //#endregion
23491 //#region node_modules/mdast-util-to-hast/lib/handlers/heading.js
23492 /**
23493 * @typedef {import('hast').Element} Element
23494 * @typedef {import('mdast').Heading} Heading
23495 * @typedef {import('../state.js').State} State
23496 */
23497 /**
23498 * Turn an mdast `heading` node into hast.
23499 *
23500 * @param {State} state
23501 * Info passed around.
23502 * @param {Heading} node
23503 * mdast node.
23504 * @returns {Element}
23505 * hast node.
23506 */
23507 function heading(state, node) {
23508 /** @type {Element} */
23509 const result = {
23510 type: "element",
23511 tagName: "h" + node.depth,
23512 properties: {},
23513 children: state.all(node)
23514 };
23515 state.patch(node, result);
23516 return state.applyData(node, result);
23517 }
23518 var init_heading = __esmMin((() => {}));
23519
23520 //#endregion
23521 //#region node_modules/mdast-util-to-hast/lib/handlers/html.js
23522 /**
23523 * @typedef {import('hast').Element} Element
23524 * @typedef {import('mdast').HTML} Html
23525 * @typedef {import('../state.js').State} State
23526 * @typedef {import('../../index.js').Raw} Raw
23527 */
23528 /**
23529 * Turn an mdast `html` node into hast (`raw` node in dangerous mode, otherwise
23530 * nothing).
23531 *
23532 * @param {State} state
23533 * Info passed around.
23534 * @param {Html} node
23535 * mdast node.
23536 * @returns {Raw | Element | null}
23537 * hast node.
23538 */
23539 function html$2(state, node) {
23540 if (state.dangerous) {
23541 /** @type {Raw} */
23542 const result = {
23543 type: "raw",
23544 value: node.value
23545 };
23546 state.patch(node, result);
23547 return state.applyData(node, result);
23548 }
23549 return null;
23550 }
23551 var init_html$1 = __esmMin((() => {
23552 __name(html$2, "html");
23553 }));
23554
23555 //#endregion
23556 //#region node_modules/mdast-util-to-hast/lib/revert.js
23557 /**
23558 * @typedef {import('hast').ElementContent} ElementContent
23559 *
23560 * @typedef {import('mdast').Content} Content
23561 * @typedef {import('mdast').Reference} Reference
23562 * @typedef {import('mdast').Root} Root
23563 *
23564 * @typedef {import('./state.js').State} State
23565 */
23566 /**
23567 * @typedef {Root | Content} Nodes
23568 * @typedef {Extract<Nodes, Reference>} References
23569 */
23570 /**
23571 * Return the content of a reference without definition as plain text.
23572 *
23573 * @param {State} state
23574 * Info passed around.
23575 * @param {References} node
23576 * Reference node (image, link).
23577 * @returns {ElementContent | Array<ElementContent>}
23578 * hast content.
23579 */
23580 function revert(state, node) {
23581 const subtype = node.referenceType;
23582 let suffix = "]";
23583 if (subtype === "collapsed") suffix += "[]";
23584 else if (subtype === "full") suffix += "[" + (node.label || node.identifier) + "]";
23585 if (node.type === "imageReference") return {
23586 type: "text",
23587 value: "![" + node.alt + suffix
23588 };
23589 const contents = state.all(node);
23590 const head = contents[0];
23591 if (head && head.type === "text") head.value = "[" + head.value;
23592 else contents.unshift({
23593 type: "text",
23594 value: "["
23595 });
23596 const tail = contents[contents.length - 1];
23597 if (tail && tail.type === "text") tail.value += suffix;
23598 else contents.push({
23599 type: "text",
23600 value: suffix
23601 });
23602 return contents;
23603 }
23604 var init_revert = __esmMin((() => {}));
23605
23606 //#endregion
23607 //#region node_modules/mdast-util-to-hast/lib/handlers/image-reference.js
23608 /**
23609 * Turn an mdast `imageReference` node into hast.
23610 *
23611 * @param {State} state
23612 * Info passed around.
23613 * @param {ImageReference} node
23614 * mdast node.
23615 * @returns {ElementContent | Array<ElementContent>}
23616 * hast node.
23617 */
23618 function imageReference(state, node) {
23619 const def = state.definition(node.identifier);
23620 if (!def) return revert(state, node);
23621 /** @type {Properties} */
23622 const properties = {
23623 src: normalizeUri(def.url || ""),
23624 alt: node.alt
23625 };
23626 if (def.title !== null && def.title !== void 0) properties.title = def.title;
23627 /** @type {Element} */
23628 const result = {
23629 type: "element",
23630 tagName: "img",
23631 properties,
23632 children: []
23633 };
23634 state.patch(node, result);
23635 return state.applyData(node, result);
23636 }
23637 var init_image_reference = __esmMin((() => {
23638 init_micromark_util_sanitize_uri();
23639 init_revert();
23640 }));
23641
23642 //#endregion
23643 //#region node_modules/mdast-util-to-hast/lib/handlers/image.js
23644 /**
23645 * Turn an mdast `image` node into hast.
23646 *
23647 * @param {State} state
23648 * Info passed around.
23649 * @param {Image} node
23650 * mdast node.
23651 * @returns {Element}
23652 * hast node.
23653 */
23654 function image(state, node) {
23655 /** @type {Properties} */
23656 const properties = { src: normalizeUri(node.url) };
23657 if (node.alt !== null && node.alt !== void 0) properties.alt = node.alt;
23658 if (node.title !== null && node.title !== void 0) properties.title = node.title;
23659 /** @type {Element} */
23660 const result = {
23661 type: "element",
23662 tagName: "img",
23663 properties,
23664 children: []
23665 };
23666 state.patch(node, result);
23667 return state.applyData(node, result);
23668 }
23669 var init_image = __esmMin((() => {
23670 init_micromark_util_sanitize_uri();
23671 }));
23672
23673 //#endregion
23674 //#region node_modules/mdast-util-to-hast/lib/handlers/inline-code.js
23675 /**
23676 * @typedef {import('hast').Element} Element
23677 * @typedef {import('hast').Text} Text
23678 * @typedef {import('mdast').InlineCode} InlineCode
23679 * @typedef {import('../state.js').State} State
23680 */
23681 /**
23682 * Turn an mdast `inlineCode` node into hast.
23683 *
23684 * @param {State} state
23685 * Info passed around.
23686 * @param {InlineCode} node
23687 * mdast node.
23688 * @returns {Element}
23689 * hast node.
23690 */
23691 function inlineCode(state, node) {
23692 /** @type {Text} */
23693 const text = {
23694 type: "text",
23695 value: node.value.replace(/\r?\n|\r/g, " ")
23696 };
23697 state.patch(node, text);
23698 /** @type {Element} */
23699 const result = {
23700 type: "element",
23701 tagName: "code",
23702 properties: {},
23703 children: [text]
23704 };
23705 state.patch(node, result);
23706 return state.applyData(node, result);
23707 }
23708 var init_inline_code = __esmMin((() => {}));
23709
23710 //#endregion
23711 //#region node_modules/mdast-util-to-hast/lib/handlers/link-reference.js
23712 /**
23713 * Turn an mdast `linkReference` node into hast.
23714 *
23715 * @param {State} state
23716 * Info passed around.
23717 * @param {LinkReference} node
23718 * mdast node.
23719 * @returns {ElementContent | Array<ElementContent>}
23720 * hast node.
23721 */
23722 function linkReference(state, node) {
23723 const def = state.definition(node.identifier);
23724 if (!def) return revert(state, node);
23725 /** @type {Properties} */
23726 const properties = { href: normalizeUri(def.url || "") };
23727 if (def.title !== null && def.title !== void 0) properties.title = def.title;
23728 /** @type {Element} */
23729 const result = {
23730 type: "element",
23731 tagName: "a",
23732 properties,
23733 children: state.all(node)
23734 };
23735 state.patch(node, result);
23736 return state.applyData(node, result);
23737 }
23738 var init_link_reference = __esmMin((() => {
23739 init_micromark_util_sanitize_uri();
23740 init_revert();
23741 }));
23742
23743 //#endregion
23744 //#region node_modules/mdast-util-to-hast/lib/handlers/link.js
23745 /**
23746 * Turn an mdast `link` node into hast.
23747 *
23748 * @param {State} state
23749 * Info passed around.
23750 * @param {Link} node
23751 * mdast node.
23752 * @returns {Element}
23753 * hast node.
23754 */
23755 function link(state, node) {
23756 /** @type {Properties} */
23757 const properties = { href: normalizeUri(node.url) };
23758 if (node.title !== null && node.title !== void 0) properties.title = node.title;
23759 /** @type {Element} */
23760 const result = {
23761 type: "element",
23762 tagName: "a",
23763 properties,
23764 children: state.all(node)
23765 };
23766 state.patch(node, result);
23767 return state.applyData(node, result);
23768 }
23769 var init_link = __esmMin((() => {
23770 init_micromark_util_sanitize_uri();
23771 }));
23772
23773 //#endregion
23774 //#region node_modules/mdast-util-to-hast/lib/handlers/list-item.js
23775 /**
23776 * @typedef {import('hast').Element} Element
23777 * @typedef {import('hast').ElementContent} ElementContent
23778 * @typedef {import('hast').Properties} Properties
23779 * @typedef {import('mdast').Content} Content
23780 * @typedef {import('mdast').ListItem} ListItem
23781 * @typedef {import('mdast').Parent} Parent
23782 * @typedef {import('mdast').Root} Root
23783 * @typedef {import('../state.js').State} State
23784 */
23785 /**
23786 * @typedef {Root | Content} Nodes
23787 * @typedef {Extract<Nodes, Parent>} Parents
23788 */
23789 /**
23790 * Turn an mdast `listItem` node into hast.
23791 *
23792 * @param {State} state
23793 * Info passed around.
23794 * @param {ListItem} node
23795 * mdast node.
23796 * @param {Parents | null | undefined} parent
23797 * Parent of `node`.
23798 * @returns {Element}
23799 * hast node.
23800 */
23801 function listItem(state, node, parent) {
23802 const results = state.all(node);
23803 const loose = parent ? listLoose(parent) : listItemLoose(node);
23804 /** @type {Properties} */
23805 const properties = {};
23806 /** @type {Array<ElementContent>} */
23807 const children = [];
23808 if (typeof node.checked === "boolean") {
23809 const head = results[0];
23810 /** @type {Element} */
23811 let paragraph;
23812 if (head && head.type === "element" && head.tagName === "p") paragraph = head;
23813 else {
23814 paragraph = {
23815 type: "element",
23816 tagName: "p",
23817 properties: {},
23818 children: []
23819 };
23820 results.unshift(paragraph);
23821 }
23822 if (paragraph.children.length > 0) paragraph.children.unshift({
23823 type: "text",
23824 value: " "
23825 });
23826 paragraph.children.unshift({
23827 type: "element",
23828 tagName: "input",
23829 properties: {
23830 type: "checkbox",
23831 checked: node.checked,
23832 disabled: true
23833 },
23834 children: []
23835 });
23836 properties.className = ["task-list-item"];
23837 }
23838 let index = -1;
23839 while (++index < results.length) {
23840 const child = results[index];
23841 if (loose || index !== 0 || child.type !== "element" || child.tagName !== "p") children.push({
23842 type: "text",
23843 value: "\n"
23844 });
23845 if (child.type === "element" && child.tagName === "p" && !loose) children.push(...child.children);
23846 else children.push(child);
23847 }
23848 const tail = results[results.length - 1];
23849 if (tail && (loose || tail.type !== "element" || tail.tagName !== "p")) children.push({
23850 type: "text",
23851 value: "\n"
23852 });
23853 /** @type {Element} */
23854 const result = {
23855 type: "element",
23856 tagName: "li",
23857 properties,
23858 children
23859 };
23860 state.patch(node, result);
23861 return state.applyData(node, result);
23862 }
23863 /**
23864 * @param {Parents} node
23865 * @return {Boolean}
23866 */
23867 function listLoose(node) {
23868 let loose = false;
23869 if (node.type === "list") {
23870 loose = node.spread || false;
23871 const children = node.children;
23872 let index = -1;
23873 while (!loose && ++index < children.length) loose = listItemLoose(children[index]);
23874 }
23875 return loose;
23876 }
23877 /**
23878 * @param {ListItem} node
23879 * @return {Boolean}
23880 */
23881 function listItemLoose(node) {
23882 const spread = node.spread;
23883 return spread === void 0 || spread === null ? node.children.length > 1 : spread;
23884 }
23885 var init_list_item = __esmMin((() => {}));
23886
23887 //#endregion
23888 //#region node_modules/mdast-util-to-hast/lib/handlers/list.js
23889 /**
23890 * @typedef {import('hast').Element} Element
23891 * @typedef {import('hast').Properties} Properties
23892 * @typedef {import('mdast').List} List
23893 * @typedef {import('../state.js').State} State
23894 */
23895 /**
23896 * Turn an mdast `list` node into hast.
23897 *
23898 * @param {State} state
23899 * Info passed around.
23900 * @param {List} node
23901 * mdast node.
23902 * @returns {Element}
23903 * hast node.
23904 */
23905 function list(state, node) {
23906 /** @type {Properties} */
23907 const properties = {};
23908 const results = state.all(node);
23909 let index = -1;
23910 if (typeof node.start === "number" && node.start !== 1) properties.start = node.start;
23911 while (++index < results.length) {
23912 const child = results[index];
23913 if (child.type === "element" && child.tagName === "li" && child.properties && Array.isArray(child.properties.className) && child.properties.className.includes("task-list-item")) {
23914 properties.className = ["contains-task-list"];
23915 break;
23916 }
23917 }
23918 /** @type {Element} */
23919 const result = {
23920 type: "element",
23921 tagName: node.ordered ? "ol" : "ul",
23922 properties,
23923 children: state.wrap(results, true)
23924 };
23925 state.patch(node, result);
23926 return state.applyData(node, result);
23927 }
23928 var init_list = __esmMin((() => {}));
23929
23930 //#endregion
23931 //#region node_modules/mdast-util-to-hast/lib/handlers/paragraph.js
23932 /**
23933 * @typedef {import('hast').Element} Element
23934 * @typedef {import('mdast').Paragraph} Paragraph
23935 * @typedef {import('../state.js').State} State
23936 */
23937 /**
23938 * Turn an mdast `paragraph` node into hast.
23939 *
23940 * @param {State} state
23941 * Info passed around.
23942 * @param {Paragraph} node
23943 * mdast node.
23944 * @returns {Element}
23945 * hast node.
23946 */
23947 function paragraph(state, node) {
23948 /** @type {Element} */
23949 const result = {
23950 type: "element",
23951 tagName: "p",
23952 properties: {},
23953 children: state.all(node)
23954 };
23955 state.patch(node, result);
23956 return state.applyData(node, result);
23957 }
23958 var init_paragraph = __esmMin((() => {}));
23959
23960 //#endregion
23961 //#region node_modules/mdast-util-to-hast/lib/handlers/root.js
23962 /**
23963 * @typedef {import('hast').Root} HastRoot
23964 * @typedef {import('hast').Element} HastElement
23965 * @typedef {import('mdast').Root} MdastRoot
23966 * @typedef {import('../state.js').State} State
23967 */
23968 /**
23969 * Turn an mdast `root` node into hast.
23970 *
23971 * @param {State} state
23972 * Info passed around.
23973 * @param {MdastRoot} node
23974 * mdast node.
23975 * @returns {HastRoot | HastElement}
23976 * hast node.
23977 */
23978 function root(state, node) {
23979 /** @type {HastRoot} */
23980 const result = {
23981 type: "root",
23982 children: state.wrap(state.all(node))
23983 };
23984 state.patch(node, result);
23985 return state.applyData(node, result);
23986 }
23987 var init_root = __esmMin((() => {}));
23988
23989 //#endregion
23990 //#region node_modules/mdast-util-to-hast/lib/handlers/strong.js
23991 /**
23992 * @typedef {import('hast').Element} Element
23993 * @typedef {import('mdast').Strong} Strong
23994 * @typedef {import('../state.js').State} State
23995 */
23996 /**
23997 * Turn an mdast `strong` node into hast.
23998 *
23999 * @param {State} state
24000 * Info passed around.
24001 * @param {Strong} node
24002 * mdast node.
24003 * @returns {Element}
24004 * hast node.
24005 */
24006 function strong(state, node) {
24007 /** @type {Element} */
24008 const result = {
24009 type: "element",
24010 tagName: "strong",
24011 properties: {},
24012 children: state.all(node)
24013 };
24014 state.patch(node, result);
24015 return state.applyData(node, result);
24016 }
24017 var init_strong = __esmMin((() => {}));
24018
24019 //#endregion
24020 //#region node_modules/unist-util-position/lib/index.js
24021 /**
24022 * Get the positional info of `node`.
24023 *
24024 * @param {NodeLike | Node | null | undefined} [node]
24025 * Node.
24026 * @returns {Position}
24027 * Position.
24028 */
24029 function position(node) {
24030 return {
24031 start: pointStart(node),
24032 end: pointEnd(node)
24033 };
24034 }
24035 /**
24036 * Get the positional info of `node`.
24037 *
24038 * @param {'start' | 'end'} type
24039 * Side.
24040 * @returns
24041 * Getter.
24042 */
24043 function point(type) {
24044 return point;
24045 /**
24046 * Get the point info of `node` at a bound side.
24047 *
24048 * @param {NodeLike | Node | null | undefined} [node]
24049 * @returns {Point}
24050 */
24051 function point(node) {
24052 const point = node && node.position && node.position[type] || {};
24053 return {
24054 line: point.line || null,
24055 column: point.column || null,
24056 offset: point.offset > -1 ? point.offset : null
24057 };
24058 }
24059 }
24060 var pointStart, pointEnd;
24061 var init_lib$7 = __esmMin((() => {
24062 pointStart = point("start");
24063 pointEnd = point("end");
24064 }));
24065
24066 //#endregion
24067 //#region node_modules/unist-util-position/index.js
24068 var init_unist_util_position = __esmMin((() => {
24069 init_lib$7();
24070 }));
24071
24072 //#endregion
24073 //#region node_modules/mdast-util-to-hast/lib/handlers/table.js
24074 /**
24075 * Turn an mdast `table` node into hast.
24076 *
24077 * @param {State} state
24078 * Info passed around.
24079 * @param {Table} node
24080 * mdast node.
24081 * @returns {Element}
24082 * hast node.
24083 */
24084 function table(state, node) {
24085 const rows = state.all(node);
24086 const firstRow = rows.shift();
24087 /** @type {Array<Element>} */
24088 const tableContent = [];
24089 if (firstRow) {
24090 /** @type {Element} */
24091 const head = {
24092 type: "element",
24093 tagName: "thead",
24094 properties: {},
24095 children: state.wrap([firstRow], true)
24096 };
24097 state.patch(node.children[0], head);
24098 tableContent.push(head);
24099 }
24100 if (rows.length > 0) {
24101 /** @type {Element} */
24102 const body = {
24103 type: "element",
24104 tagName: "tbody",
24105 properties: {},
24106 children: state.wrap(rows, true)
24107 };
24108 const start = pointStart(node.children[1]);
24109 const end = pointEnd(node.children[node.children.length - 1]);
24110 if (start.line && end.line) body.position = {
24111 start,
24112 end
24113 };
24114 tableContent.push(body);
24115 }
24116 /** @type {Element} */
24117 const result = {
24118 type: "element",
24119 tagName: "table",
24120 properties: {},
24121 children: state.wrap(tableContent, true)
24122 };
24123 state.patch(node, result);
24124 return state.applyData(node, result);
24125 }
24126 var init_table = __esmMin((() => {
24127 init_unist_util_position();
24128 }));
24129
24130 //#endregion
24131 //#region node_modules/mdast-util-to-hast/lib/handlers/table-row.js
24132 /**
24133 * @typedef {import('hast').Properties} Properties
24134 * @typedef {import('hast').Element} Element
24135 * @typedef {import('hast').ElementContent} ElementContent
24136 * @typedef {import('mdast').Content} Content
24137 * @typedef {import('mdast').Parent} Parent
24138 * @typedef {import('mdast').Root} Root
24139 * @typedef {import('mdast').TableRow} TableRow
24140 * @typedef {import('../state.js').State} State
24141 */
24142 /**
24143 * @typedef {Root | Content} Nodes
24144 * @typedef {Extract<Nodes, Parent>} Parents
24145 */
24146 /**
24147 * Turn an mdast `tableRow` node into hast.
24148 *
24149 * @param {State} state
24150 * Info passed around.
24151 * @param {TableRow} node
24152 * mdast node.
24153 * @param {Parents | null | undefined} parent
24154 * Parent of `node`.
24155 * @returns {Element}
24156 * hast node.
24157 */
24158 function tableRow(state, node, parent) {
24159 const siblings = parent ? parent.children : void 0;
24160 const tagName = (siblings ? siblings.indexOf(node) : 1) === 0 ? "th" : "td";
24161 const align = parent && parent.type === "table" ? parent.align : void 0;
24162 const length = align ? align.length : node.children.length;
24163 let cellIndex = -1;
24164 /** @type {Array<ElementContent>} */
24165 const cells = [];
24166 while (++cellIndex < length) {
24167 const cell = node.children[cellIndex];
24168 /** @type {Properties} */
24169 const properties = {};
24170 const alignValue = align ? align[cellIndex] : void 0;
24171 if (alignValue) properties.align = alignValue;
24172 /** @type {Element} */
24173 let result = {
24174 type: "element",
24175 tagName,
24176 properties,
24177 children: []
24178 };
24179 if (cell) {
24180 result.children = state.all(cell);
24181 state.patch(cell, result);
24182 result = state.applyData(node, result);
24183 }
24184 cells.push(result);
24185 }
24186 /** @type {Element} */
24187 const result = {
24188 type: "element",
24189 tagName: "tr",
24190 properties: {},
24191 children: state.wrap(cells, true)
24192 };
24193 state.patch(node, result);
24194 return state.applyData(node, result);
24195 }
24196 var init_table_row = __esmMin((() => {}));
24197
24198 //#endregion
24199 //#region node_modules/mdast-util-to-hast/lib/handlers/table-cell.js
24200 /**
24201 * @typedef {import('hast').Element} Element
24202 * @typedef {import('mdast').TableCell} TableCell
24203 * @typedef {import('../state.js').State} State
24204 */
24205 /**
24206 * Turn an mdast `tableCell` node into hast.
24207 *
24208 * @param {State} state
24209 * Info passed around.
24210 * @param {TableCell} node
24211 * mdast node.
24212 * @returns {Element}
24213 * hast node.
24214 */
24215 function tableCell(state, node) {
24216 /** @type {Element} */
24217 const result = {
24218 type: "element",
24219 tagName: "td",
24220 properties: {},
24221 children: state.all(node)
24222 };
24223 state.patch(node, result);
24224 return state.applyData(node, result);
24225 }
24226 var init_table_cell = __esmMin((() => {}));
24227
24228 //#endregion
24229 //#region node_modules/trim-lines/index.js
24230 /**
24231 * Remove initial and final spaces and tabs at the line breaks in `value`.
24232 * Does not trim initial and final spaces and tabs of the value itself.
24233 *
24234 * @param {string} value
24235 * Value to trim.
24236 * @returns {string}
24237 * Trimmed value.
24238 */
24239 function trimLines(value) {
24240 const source = String(value);
24241 const search = /\r?\n|\r/g;
24242 let match = search.exec(source);
24243 let last = 0;
24244 /** @type {Array<string>} */
24245 const lines = [];
24246 while (match) {
24247 lines.push(trimLine(source.slice(last, match.index), last > 0, true), match[0]);
24248 last = match.index + match[0].length;
24249 match = search.exec(source);
24250 }
24251 lines.push(trimLine(source.slice(last), last > 0, false));
24252 return lines.join("");
24253 }
24254 /**
24255 * @param {string} value
24256 * Line to trim.
24257 * @param {boolean} start
24258 * Whether to trim the start of the line.
24259 * @param {boolean} end
24260 * Whether to trim the end of the line.
24261 * @returns {string}
24262 * Trimmed line.
24263 */
24264 function trimLine(value, start, end) {
24265 let startIndex = 0;
24266 let endIndex = value.length;
24267 if (start) {
24268 let code = value.codePointAt(startIndex);
24269 while (code === tab || code === space) {
24270 startIndex++;
24271 code = value.codePointAt(startIndex);
24272 }
24273 }
24274 if (end) {
24275 let code = value.codePointAt(endIndex - 1);
24276 while (code === tab || code === space) {
24277 endIndex--;
24278 code = value.codePointAt(endIndex - 1);
24279 }
24280 }
24281 return endIndex > startIndex ? value.slice(startIndex, endIndex) : "";
24282 }
24283 var tab, space;
24284 var init_trim_lines = __esmMin((() => {
24285 tab = 9;
24286 space = 32;
24287 }));
24288
24289 //#endregion
24290 //#region node_modules/mdast-util-to-hast/lib/handlers/text.js
24291 /**
24292 * Turn an mdast `text` node into hast.
24293 *
24294 * @param {State} state
24295 * Info passed around.
24296 * @param {MdastText} node
24297 * mdast node.
24298 * @returns {HastText | HastElement}
24299 * hast node.
24300 */
24301 function text(state, node) {
24302 /** @type {HastText} */
24303 const result = {
24304 type: "text",
24305 value: trimLines(String(node.value))
24306 };
24307 state.patch(node, result);
24308 return state.applyData(node, result);
24309 }
24310 var init_text = __esmMin((() => {
24311 init_trim_lines();
24312 }));
24313
24314 //#endregion
24315 //#region node_modules/mdast-util-to-hast/lib/handlers/thematic-break.js
24316 /**
24317 * @typedef {import('hast').Element} Element
24318 * @typedef {import('mdast').ThematicBreak} ThematicBreak
24319 * @typedef {import('../state.js').State} State
24320 */
24321 /**
24322 * Turn an mdast `thematicBreak` node into hast.
24323 *
24324 * @param {State} state
24325 * Info passed around.
24326 * @param {ThematicBreak} node
24327 * mdast node.
24328 * @returns {Element}
24329 * hast node.
24330 */
24331 function thematicBreak(state, node) {
24332 /** @type {Element} */
24333 const result = {
24334 type: "element",
24335 tagName: "hr",
24336 properties: {},
24337 children: []
24338 };
24339 state.patch(node, result);
24340 return state.applyData(node, result);
24341 }
24342 var init_thematic_break = __esmMin((() => {}));
24343
24344 //#endregion
24345 //#region node_modules/mdast-util-to-hast/lib/handlers/index.js
24346 function ignore() {
24347 return null;
24348 }
24349 var handlers;
24350 var init_handlers = __esmMin((() => {
24351 init_blockquote();
24352 init_break();
24353 init_code();
24354 init_delete();
24355 init_emphasis();
24356 init_footnote_reference();
24357 init_footnote();
24358 init_heading();
24359 init_html$1();
24360 init_image_reference();
24361 init_image();
24362 init_inline_code();
24363 init_link_reference();
24364 init_link();
24365 init_list_item();
24366 init_list();
24367 init_paragraph();
24368 init_root();
24369 init_strong();
24370 init_table();
24371 init_table_row();
24372 init_table_cell();
24373 init_text();
24374 init_thematic_break();
24375 handlers = {
24376 blockquote,
24377 break: hardBreak,
24378 code,
24379 delete: strikethrough,
24380 emphasis,
24381 footnoteReference,
24382 footnote,
24383 heading,
24384 html: html$2,
24385 imageReference,
24386 image,
24387 inlineCode,
24388 linkReference,
24389 link,
24390 listItem,
24391 list,
24392 paragraph,
24393 root,
24394 strong,
24395 table,
24396 tableCell,
24397 tableRow,
24398 text,
24399 thematicBreak,
24400 toml: ignore,
24401 yaml: ignore,
24402 definition: ignore,
24403 footnoteDefinition: ignore
24404 };
24405 }));
24406
24407 //#endregion
24408 //#region node_modules/unist-util-is/lib/index.js
24409 /**
24410 * @param {Array<string | Props | TestFunctionAnything>} tests
24411 * @returns {AssertAnything}
24412 */
24413 function anyFactory(tests) {
24414 /** @type {Array<AssertAnything>} */
24415 const checks = [];
24416 let index = -1;
24417 while (++index < tests.length) checks[index] = convert(tests[index]);
24418 return castFactory(any);
24419 /**
24420 * @this {unknown}
24421 * @param {Array<unknown>} parameters
24422 * @returns {boolean}
24423 */
24424 function any(...parameters) {
24425 let index = -1;
24426 while (++index < checks.length) if (checks[index].call(this, ...parameters)) return true;
24427 return false;
24428 }
24429 }
24430 /**
24431 * Turn an object into a test for a node with a certain fields.
24432 *
24433 * @param {Props} check
24434 * @returns {AssertAnything}
24435 */
24436 function propsFactory(check) {
24437 return castFactory(all);
24438 /**
24439 * @param {Node} node
24440 * @returns {boolean}
24441 */
24442 function all(node) {
24443 /** @type {string} */
24444 let key;
24445 for (key in check) if (node[key] !== check[key]) return false;
24446 return true;
24447 }
24448 }
24449 /**
24450 * Turn a string into a test for a node with a certain type.
24451 *
24452 * @param {string} check
24453 * @returns {AssertAnything}
24454 */
24455 function typeFactory(check) {
24456 return castFactory(type);
24457 /**
24458 * @param {Node} node
24459 */
24460 function type(node) {
24461 return node && node.type === check;
24462 }
24463 }
24464 /**
24465 * Turn a custom test into a test for a node that passes that test.
24466 *
24467 * @param {TestFunctionAnything} check
24468 * @returns {AssertAnything}
24469 */
24470 function castFactory(check) {
24471 return assertion;
24472 /**
24473 * @this {unknown}
24474 * @param {unknown} node
24475 * @param {Array<unknown>} parameters
24476 * @returns {boolean}
24477 */
24478 function assertion(node, ...parameters) {
24479 return Boolean(node && typeof node === "object" && "type" in node && Boolean(check.call(this, node, ...parameters)));
24480 }
24481 }
24482 function ok() {
24483 return true;
24484 }
24485 var convert;
24486 var init_lib$6 = __esmMin((() => {
24487 convert = (
24488 /**
24489 * @param {Test} [test]
24490 * @returns {AssertAnything}
24491 */
24492 function(test) {
24493 if (test === void 0 || test === null) return ok;
24494 if (typeof test === "string") return typeFactory(test);
24495 if (typeof test === "object") return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
24496 if (typeof test === "function") return castFactory(test);
24497 throw new Error("Expected function, string, or object as test");
24498 });
24499 }));
24500
24501 //#endregion
24502 //#region node_modules/unist-util-is/index.js
24503 var init_unist_util_is = __esmMin((() => {
24504 init_lib$6();
24505 }));
24506
24507 //#endregion
24508 //#region node_modules/unist-util-visit-parents/lib/color.browser.js
24509 /**
24510 * @param {string} d
24511 * @returns {string}
24512 */
24513 function color(d) {
24514 return d;
24515 }
24516 var init_color_browser = __esmMin((() => {}));
24517
24518 //#endregion
24519 //#region node_modules/unist-util-visit-parents/lib/index.js
24520 /**
24521 * Turn a return value into a clean result.
24522 *
24523 * @param {VisitorResult} value
24524 * Valid return values from visitors.
24525 * @returns {ActionTuple}
24526 * Clean result.
24527 */
24528 function toResult(value) {
24529 if (Array.isArray(value)) return value;
24530 if (typeof value === "number") return [true, value];
24531 return [value];
24532 }
24533 var CONTINUE, EXIT, SKIP, visitParents;
24534 var init_lib$5 = __esmMin((() => {
24535 init_unist_util_is();
24536 init_color_browser();
24537 CONTINUE = true;
24538 EXIT = false;
24539 SKIP = "skip";
24540 visitParents = (
24541 /**
24542 * @param {Node} tree
24543 * @param {Test} test
24544 * @param {Visitor<Node>} visitor
24545 * @param {boolean | null | undefined} [reverse]
24546 * @returns {void}
24547 */
24548 function(tree, test, visitor, reverse) {
24549 if (typeof test === "function" && typeof visitor !== "function") {
24550 reverse = visitor;
24551 visitor = test;
24552 test = null;
24553 }
24554 const is = convert(test);
24555 const step = reverse ? -1 : 1;
24556 factory(tree, void 0, [])();
24557 /**
24558 * @param {Node} node
24559 * @param {number | undefined} index
24560 * @param {Array<Parent>} parents
24561 */
24562 function factory(node, index, parents) {
24563 /** @type {Record<string, unknown>} */
24564 const value = node && typeof node === "object" ? node : {};
24565 if (typeof value.type === "string") {
24566 const name = typeof value.tagName === "string" ? value.tagName : typeof value.name === "string" ? value.name : void 0;
24567 Object.defineProperty(visit, "name", { value: "node (" + color(node.type + (name ? "<" + name + ">" : "")) + ")" });
24568 }
24569 return visit;
24570 function visit() {
24571 /** @type {ActionTuple} */
24572 let result = [];
24573 /** @type {ActionTuple} */
24574 let subresult;
24575 /** @type {number} */
24576 let offset;
24577 /** @type {Array<Parent>} */
24578 let grandparents;
24579 if (!test || is(node, index, parents[parents.length - 1] || null)) {
24580 result = toResult(visitor(node, parents));
24581 if (result[0] === false) return result;
24582 }
24583 if (node.children && result[0] !== "skip") {
24584 offset = (reverse ? node.children.length : -1) + step;
24585 grandparents = parents.concat(node);
24586 while (offset > -1 && offset < node.children.length) {
24587 subresult = factory(node.children[offset], offset, grandparents)();
24588 if (subresult[0] === false) return subresult;
24589 offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
24590 }
24591 }
24592 return result;
24593 }
24594 }
24595 });
24596 }));
24597
24598 //#endregion
24599 //#region node_modules/unist-util-visit-parents/index.js
24600 var init_unist_util_visit_parents = __esmMin((() => {
24601 init_lib$5();
24602 }));
24603
24604 //#endregion
24605 //#region node_modules/unist-util-visit/lib/index.js
24606 var visit;
24607 var init_lib$4 = __esmMin((() => {
24608 init_unist_util_visit_parents();
24609 visit = (
24610 /**
24611 * @param {Node} tree
24612 * @param {Test} test
24613 * @param {Visitor} visitor
24614 * @param {boolean | null | undefined} [reverse]
24615 * @returns {void}
24616 */
24617 function(tree, test, visitor, reverse) {
24618 if (typeof test === "function" && typeof visitor !== "function") {
24619 reverse = visitor;
24620 visitor = test;
24621 test = null;
24622 }
24623 visitParents(tree, test, overload, reverse);
24624 /**
24625 * @param {Node} node
24626 * @param {Array<Parent>} parents
24627 */
24628 function overload(node, parents) {
24629 const parent = parents[parents.length - 1];
24630 return visitor(node, parent ? parent.children.indexOf(node) : null, parent);
24631 }
24632 });
24633 }));
24634
24635 //#endregion
24636 //#region node_modules/unist-util-visit/index.js
24637 var init_unist_util_visit = __esmMin((() => {
24638 init_lib$4();
24639 }));
24640
24641 //#endregion
24642 //#region node_modules/unist-util-generated/lib/index.js
24643 /**
24644 * @typedef PointLike
24645 * @property {number | null | undefined} [line]
24646 * @property {number | null | undefined} [column]
24647 * @property {number | null | undefined} [offset]
24648 *
24649 * @typedef PositionLike
24650 * @property {PointLike | null | undefined} [start]
24651 * @property {PointLike | null | undefined} [end]
24652 *
24653 * @typedef NodeLike
24654 * @property {PositionLike | null | undefined} [position]
24655 */
24656 /**
24657 * Check if `node` is generated.
24658 *
24659 * @param {NodeLike | null | undefined} [node]
24660 * Node to check.
24661 * @returns {boolean}
24662 * Whether `node` is generated (does not have positional info).
24663 */
24664 function generated(node) {
24665 return !node || !node.position || !node.position.start || !node.position.start.line || !node.position.start.column || !node.position.end || !node.position.end.line || !node.position.end.column;
24666 }
24667 var init_lib$3 = __esmMin((() => {}));
24668
24669 //#endregion
24670 //#region node_modules/unist-util-generated/index.js
24671 var init_unist_util_generated = __esmMin((() => {
24672 init_lib$3();
24673 }));
24674
24675 //#endregion
24676 //#region node_modules/mdast-util-definitions/lib/index.js
24677 /**
24678 * Find definitions in `tree`.
24679 *
24680 * Uses CommonMark precedence, which means that earlier definitions are
24681 * preferred over duplicate later definitions.
24682 *
24683 * @param {Node} tree
24684 * Tree to check.
24685 * @returns {GetDefinition}
24686 * Getter.
24687 */
24688 function definitions(tree) {
24689 /** @type {Record<string, Definition>} */
24690 const cache = Object.create(null);
24691 if (!tree || !tree.type) throw new Error("mdast-util-definitions expected node");
24692 visit(tree, "definition", (definition) => {
24693 const id = clean(definition.identifier);
24694 if (id && !own$4.call(cache, id)) cache[id] = definition;
24695 });
24696 return definition;
24697 /** @type {GetDefinition} */
24698 function definition(identifier) {
24699 const id = clean(identifier);
24700 return id && own$4.call(cache, id) ? cache[id] : null;
24701 }
24702 }
24703 /**
24704 * @param {string | null | undefined} [value]
24705 * @returns {string}
24706 */
24707 function clean(value) {
24708 return String(value || "").toUpperCase();
24709 }
24710 var own$4;
24711 var init_lib$2 = __esmMin((() => {
24712 init_unist_util_visit();
24713 own$4 = {}.hasOwnProperty;
24714 }));
24715
24716 //#endregion
24717 //#region node_modules/mdast-util-definitions/index.js
24718 var init_mdast_util_definitions = __esmMin((() => {
24719 init_lib$2();
24720 }));
24721
24722 //#endregion
24723 //#region node_modules/mdast-util-to-hast/lib/state.js
24724 /**
24725 * Create `state` from an mdast tree.
24726 *
24727 * @param {MdastNodes} tree
24728 * mdast node to transform.
24729 * @param {Options | null | undefined} [options]
24730 * Configuration.
24731 * @returns {State}
24732 * `state` function.
24733 */
24734 function createState(tree, options) {
24735 const settings = options || {};
24736 const dangerous = settings.allowDangerousHtml || false;
24737 /** @type {Record<string, MdastFootnoteDefinition>} */
24738 const footnoteById = {};
24739 state.dangerous = dangerous;
24740 state.clobberPrefix = settings.clobberPrefix === void 0 || settings.clobberPrefix === null ? "user-content-" : settings.clobberPrefix;
24741 state.footnoteLabel = settings.footnoteLabel || "Footnotes";
24742 state.footnoteLabelTagName = settings.footnoteLabelTagName || "h2";
24743 state.footnoteLabelProperties = settings.footnoteLabelProperties || { className: ["sr-only"] };
24744 state.footnoteBackLabel = settings.footnoteBackLabel || "Back to content";
24745 state.unknownHandler = settings.unknownHandler;
24746 state.passThrough = settings.passThrough;
24747 state.handlers = _objectSpread2(_objectSpread2({}, handlers), settings.handlers);
24748 state.definition = definitions(tree);
24749 state.footnoteById = footnoteById;
24750 /** @type {Array<string>} */
24751 state.footnoteOrder = [];
24752 /** @type {Record<string, number>} */
24753 state.footnoteCounts = {};
24754 state.patch = patch;
24755 state.applyData = applyData;
24756 state.one = oneBound;
24757 state.all = allBound;
24758 state.wrap = wrap;
24759 state.augment = augment;
24760 visit(tree, "footnoteDefinition", (definition) => {
24761 const id = String(definition.identifier).toUpperCase();
24762 if (!own$3.call(footnoteById, id)) footnoteById[id] = definition;
24763 });
24764 return state;
24765 /**
24766 * Finalise the created `right`, a hast node, from `left`, an mdast node.
24767 *
24768 * @param {MdastNodeWithData | PositionLike | null | undefined} left
24769 * @param {HastElementContent} right
24770 * @returns {HastElementContent}
24771 */
24772 /* c8 ignore start */
24773 function augment(left, right) {
24774 if (left && "data" in left && left.data) {
24775 /** @type {MdastData} */
24776 const data = left.data;
24777 if (data.hName) {
24778 if (right.type !== "element") right = {
24779 type: "element",
24780 tagName: "",
24781 properties: {},
24782 children: []
24783 };
24784 right.tagName = data.hName;
24785 }
24786 if (right.type === "element" && data.hProperties) right.properties = _objectSpread2(_objectSpread2({}, right.properties), data.hProperties);
24787 if ("children" in right && right.children && data.hChildren) right.children = data.hChildren;
24788 }
24789 if (left) {
24790 const ctx = "type" in left ? left : { position: left };
24791 if (!generated(ctx)) right.position = {
24792 start: pointStart(ctx),
24793 end: pointEnd(ctx)
24794 };
24795 }
24796 return right;
24797 }
24798 /* c8 ignore stop */
24799 /**
24800 * Create an element for `node`.
24801 *
24802 * @type {HFunctionProps}
24803 */
24804 /* c8 ignore start */
24805 function state(node, tagName, props, children) {
24806 if (Array.isArray(props)) {
24807 children = props;
24808 props = {};
24809 }
24810 return augment(node, {
24811 type: "element",
24812 tagName,
24813 properties: props || {},
24814 children: children || []
24815 });
24816 }
24817 /* c8 ignore stop */
24818 /**
24819 * Transform an mdast node into a hast node.
24820 *
24821 * @param {MdastNodes} node
24822 * mdast node.
24823 * @param {MdastParents | null | undefined} [parent]
24824 * Parent of `node`.
24825 * @returns {HastElementContent | Array<HastElementContent> | null | undefined}
24826 * Resulting hast node.
24827 */
24828 function oneBound(node, parent) {
24829 return one(state, node, parent);
24830 }
24831 /**
24832 * Transform the children of an mdast node into hast nodes.
24833 *
24834 * @param {MdastNodes} parent
24835 * mdast node to compile
24836 * @returns {Array<HastElementContent>}
24837 * Resulting hast nodes.
24838 */
24839 function allBound(parent) {
24840 return all(state, parent);
24841 }
24842 }
24843 /**
24844 * Copy a node’s positional info.
24845 *
24846 * @param {MdastNodes} from
24847 * mdast node to copy from.
24848 * @param {HastNodes} to
24849 * hast node to copy into.
24850 * @returns {void}
24851 * Nothing.
24852 */
24853 function patch(from, to) {
24854 if (from.position) to.position = position(from);
24855 }
24856 /**
24857 * Honor the `data` of `from` and maybe generate an element instead of `to`.
24858 *
24859 * @template {HastNodes} Type
24860 * Node type.
24861 * @param {MdastNodes} from
24862 * mdast node to use data from.
24863 * @param {Type} to
24864 * hast node to change.
24865 * @returns {Type | HastElement}
24866 * Nothing.
24867 */
24868 function applyData(from, to) {
24869 /** @type {Type | HastElement} */
24870 let result = to;
24871 if (from && from.data) {
24872 const hName = from.data.hName;
24873 const hChildren = from.data.hChildren;
24874 const hProperties = from.data.hProperties;
24875 if (typeof hName === "string") if (result.type === "element") result.tagName = hName;
24876 else result = {
24877 type: "element",
24878 tagName: hName,
24879 properties: {},
24880 children: []
24881 };
24882 if (result.type === "element" && hProperties) result.properties = _objectSpread2(_objectSpread2({}, result.properties), hProperties);
24883 if ("children" in result && result.children && hChildren !== null && hChildren !== void 0) result.children = hChildren;
24884 }
24885 return result;
24886 }
24887 /**
24888 * Transform an mdast node into a hast node.
24889 *
24890 * @param {State} state
24891 * Info passed around.
24892 * @param {MdastNodes} node
24893 * mdast node.
24894 * @param {MdastParents | null | undefined} [parent]
24895 * Parent of `node`.
24896 * @returns {HastElementContent | Array<HastElementContent> | null | undefined}
24897 * Resulting hast node.
24898 */
24899 function one(state, node, parent) {
24900 const type = node && node.type;
24901 if (!type) throw new Error("Expected node, got `" + node + "`");
24902 if (own$3.call(state.handlers, type)) return state.handlers[type](state, node, parent);
24903 if (state.passThrough && state.passThrough.includes(type)) return "children" in node ? _objectSpread2(_objectSpread2({}, node), {}, { children: all(state, node) }) : node;
24904 if (state.unknownHandler) return state.unknownHandler(state, node, parent);
24905 return defaultUnknownHandler(state, node);
24906 }
24907 /**
24908 * Transform the children of an mdast node into hast nodes.
24909 *
24910 * @param {State} state
24911 * Info passed around.
24912 * @param {MdastNodes} parent
24913 * mdast node to compile
24914 * @returns {Array<HastElementContent>}
24915 * Resulting hast nodes.
24916 */
24917 function all(state, parent) {
24918 /** @type {Array<HastElementContent>} */
24919 const values = [];
24920 if ("children" in parent) {
24921 const nodes = parent.children;
24922 let index = -1;
24923 while (++index < nodes.length) {
24924 const result = one(state, nodes[index], parent);
24925 if (result) {
24926 if (index && nodes[index - 1].type === "break") {
24927 if (!Array.isArray(result) && result.type === "text") result.value = result.value.replace(/^\s+/, "");
24928 if (!Array.isArray(result) && result.type === "element") {
24929 const head = result.children[0];
24930 if (head && head.type === "text") head.value = head.value.replace(/^\s+/, "");
24931 }
24932 }
24933 if (Array.isArray(result)) values.push(...result);
24934 else values.push(result);
24935 }
24936 }
24937 }
24938 return values;
24939 }
24940 /**
24941 * Transform an unknown node.
24942 *
24943 * @param {State} state
24944 * Info passed around.
24945 * @param {MdastNodes} node
24946 * Unknown mdast node.
24947 * @returns {HastText | HastElement}
24948 * Resulting hast node.
24949 */
24950 function defaultUnknownHandler(state, node) {
24951 const data = node.data || {};
24952 /** @type {HastText | HastElement} */
24953 const result = "value" in node && !(own$3.call(data, "hProperties") || own$3.call(data, "hChildren")) ? {
24954 type: "text",
24955 value: node.value
24956 } : {
24957 type: "element",
24958 tagName: "div",
24959 properties: {},
24960 children: all(state, node)
24961 };
24962 state.patch(node, result);
24963 return state.applyData(node, result);
24964 }
24965 /**
24966 * Wrap `nodes` with line endings between each node.
24967 *
24968 * @template {HastContent} Type
24969 * Node type.
24970 * @param {Array<Type>} nodes
24971 * List of nodes to wrap.
24972 * @param {boolean | null | undefined} [loose=false]
24973 * Whether to add line endings at start and end.
24974 * @returns {Array<Type | HastText>}
24975 * Wrapped nodes.
24976 */
24977 function wrap(nodes, loose) {
24978 /** @type {Array<Type | HastText>} */
24979 const result = [];
24980 let index = -1;
24981 if (loose) result.push({
24982 type: "text",
24983 value: "\n"
24984 });
24985 while (++index < nodes.length) {
24986 if (index) result.push({
24987 type: "text",
24988 value: "\n"
24989 });
24990 result.push(nodes[index]);
24991 }
24992 if (loose && nodes.length > 0) result.push({
24993 type: "text",
24994 value: "\n"
24995 });
24996 return result;
24997 }
24998 var own$3;
24999 var init_state = __esmMin((() => {
25000 init_unist_util_visit();
25001 init_unist_util_position();
25002 init_unist_util_generated();
25003 init_mdast_util_definitions();
25004 init_handlers();
25005 init_objectSpread2();
25006 own$3 = {}.hasOwnProperty;
25007 }));
25008
25009 //#endregion
25010 //#region node_modules/mdast-util-to-hast/lib/footer.js
25011 /**
25012 * Generate a hast footer for called footnote definitions.
25013 *
25014 * @param {State} state
25015 * Info passed around.
25016 * @returns {Element | undefined}
25017 * `section` element or `undefined`.
25018 */
25019 function footer(state) {
25020 /** @type {Array<ElementContent>} */
25021 const listItems = [];
25022 let index = -1;
25023 while (++index < state.footnoteOrder.length) {
25024 const def = state.footnoteById[state.footnoteOrder[index]];
25025 if (!def) continue;
25026 const content = state.all(def);
25027 const id = String(def.identifier).toUpperCase();
25028 const safeId = normalizeUri(id.toLowerCase());
25029 let referenceIndex = 0;
25030 /** @type {Array<ElementContent>} */
25031 const backReferences = [];
25032 while (++referenceIndex <= state.footnoteCounts[id]) {
25033 /** @type {Element} */
25034 const backReference = {
25035 type: "element",
25036 tagName: "a",
25037 properties: {
25038 href: "#" + state.clobberPrefix + "fnref-" + safeId + (referenceIndex > 1 ? "-" + referenceIndex : ""),
25039 dataFootnoteBackref: true,
25040 className: ["data-footnote-backref"],
25041 ariaLabel: state.footnoteBackLabel
25042 },
25043 children: [{
25044 type: "text",
25045 value: "↩"
25046 }]
25047 };
25048 if (referenceIndex > 1) backReference.children.push({
25049 type: "element",
25050 tagName: "sup",
25051 children: [{
25052 type: "text",
25053 value: String(referenceIndex)
25054 }]
25055 });
25056 if (backReferences.length > 0) backReferences.push({
25057 type: "text",
25058 value: " "
25059 });
25060 backReferences.push(backReference);
25061 }
25062 const tail = content[content.length - 1];
25063 if (tail && tail.type === "element" && tail.tagName === "p") {
25064 const tailTail = tail.children[tail.children.length - 1];
25065 if (tailTail && tailTail.type === "text") tailTail.value += " ";
25066 else tail.children.push({
25067 type: "text",
25068 value: " "
25069 });
25070 tail.children.push(...backReferences);
25071 } else content.push(...backReferences);
25072 /** @type {Element} */
25073 const listItem = {
25074 type: "element",
25075 tagName: "li",
25076 properties: { id: state.clobberPrefix + "fn-" + safeId },
25077 children: state.wrap(content, true)
25078 };
25079 state.patch(def, listItem);
25080 listItems.push(listItem);
25081 }
25082 if (listItems.length === 0) return;
25083 return {
25084 type: "element",
25085 tagName: "section",
25086 properties: {
25087 dataFootnotes: true,
25088 className: ["footnotes"]
25089 },
25090 children: [
25091 {
25092 type: "element",
25093 tagName: state.footnoteLabelTagName,
25094 properties: _objectSpread2(_objectSpread2({}, JSON.parse(JSON.stringify(state.footnoteLabelProperties))), {}, { id: "footnote-label" }),
25095 children: [{
25096 type: "text",
25097 value: state.footnoteLabel
25098 }]
25099 },
25100 {
25101 type: "text",
25102 value: "\n"
25103 },
25104 {
25105 type: "element",
25106 tagName: "ol",
25107 properties: {},
25108 children: state.wrap(listItems, true)
25109 },
25110 {
25111 type: "text",
25112 value: "\n"
25113 }
25114 ]
25115 };
25116 }
25117 var init_footer = __esmMin((() => {
25118 init_micromark_util_sanitize_uri();
25119 init_objectSpread2();
25120 }));
25121
25122 //#endregion
25123 //#region node_modules/mdast-util-to-hast/lib/index.js
25124 /**
25125 * Transform mdast to hast.
25126 *
25127 * ##### Notes
25128 *
25129 * ###### HTML
25130 *
25131 * Raw HTML is available in mdast as `html` nodes and can be embedded in hast
25132 * as semistandard `raw` nodes.
25133 * Most utilities ignore `raw` nodes but two notable ones don’t:
25134 *
25135 * * `hast-util-to-html` also has an option `allowDangerousHtml` which will
25136 * output the raw HTML.
25137 * This is typically discouraged as noted by the option name but is useful
25138 * if you completely trust authors
25139 * * `hast-util-raw` can handle the raw embedded HTML strings by parsing them
25140 * into standard hast nodes (`element`, `text`, etc).
25141 * This is a heavy task as it needs a full HTML parser, but it is the only
25142 * way to support untrusted content
25143 *
25144 * ###### Footnotes
25145 *
25146 * Many options supported here relate to footnotes.
25147 * Footnotes are not specified by CommonMark, which we follow by default.
25148 * They are supported by GitHub, so footnotes can be enabled in markdown with
25149 * `mdast-util-gfm`.
25150 *
25151 * The options `footnoteBackLabel` and `footnoteLabel` define natural language
25152 * that explains footnotes, which is hidden for sighted users but shown to
25153 * assistive technology.
25154 * When your page is not in English, you must define translated values.
25155 *
25156 * Back references use ARIA attributes, but the section label itself uses a
25157 * heading that is hidden with an `sr-only` class.
25158 * To show it to sighted users, define different attributes in
25159 * `footnoteLabelProperties`.
25160 *
25161 * ###### Clobbering
25162 *
25163 * Footnotes introduces a problem, as it links footnote calls to footnote
25164 * definitions on the page through `id` attributes generated from user content,
25165 * which results in DOM clobbering.
25166 *
25167 * DOM clobbering is this:
25168 *
25169 * ```html
25170 * <p id=x></p>
25171 * <script>alert(x) // `x` now refers to the DOM `p#x` element<\/script>
25172 * ```
25173 *
25174 * Elements by their ID are made available by browsers on the `window` object,
25175 * which is a security risk.
25176 * Using a prefix solves this problem.
25177 *
25178 * More information on how to handle clobbering and the prefix is explained in
25179 * Example: headings (DOM clobbering) in `rehype-sanitize`.
25180 *
25181 * ###### Unknown nodes
25182 *
25183 * Unknown nodes are nodes with a type that isn’t in `handlers` or `passThrough`.
25184 * The default behavior for unknown nodes is:
25185 *
25186 * * when the node has a `value` (and doesn’t have `data.hName`,
25187 * `data.hProperties`, or `data.hChildren`, see later), create a hast `text`
25188 * node
25189 * * otherwise, create a `<div>` element (which could be changed with
25190 * `data.hName`), with its children mapped from mdast to hast as well
25191 *
25192 * This behavior can be changed by passing an `unknownHandler`.
25193 *
25194 * @param {MdastNodes} tree
25195 * mdast tree.
25196 * @param {Options | null | undefined} [options]
25197 * Configuration.
25198 * @returns {HastNodes | null | undefined}
25199 * hast tree.
25200 */
25201 function toHast(tree, options) {
25202 const state = createState(tree, options);
25203 const node = state.one(tree, null);
25204 const foot = footer(state);
25205 if (foot) node.children.push({
25206 type: "text",
25207 value: "\n"
25208 }, foot);
25209 return Array.isArray(node) ? {
25210 type: "root",
25211 children: node
25212 } : node;
25213 }
25214 var init_lib$1 = __esmMin((() => {
25215 init_footer();
25216 init_state();
25217 }));
25218
25219 //#endregion
25220 //#region node_modules/mdast-util-to-hast/index.js
25221 var init_mdast_util_to_hast = __esmMin((() => {
25222 init_handlers();
25223 init_state();
25224 init_lib$1();
25225 }));
25226
25227 //#endregion
25228 //#region node_modules/remark-rehype/lib/index.js
25229 /**
25230 * Bridge-mode.
25231 * Runs the destination with the new hast tree.
25232 *
25233 * @type {import('unified').Plugin<[Processor, Options?], MdastRoot>}
25234 */
25235 function bridge(destination, options) {
25236 return (node, file, next) => {
25237 destination.run(toHast(node, options), file, (error) => {
25238 next(error);
25239 });
25240 };
25241 }
25242 /**
25243 * Mutate-mode.
25244 * Further plugins run on the hast tree.
25245 *
25246 * @type {import('unified').Plugin<[Options?]|void[], MdastRoot, HastRoot>}
25247 */
25248 function mutate(options) {
25249 return (node) => toHast(node, options);
25250 }
25251 var remarkRehype;
25252 var init_lib = __esmMin((() => {
25253 init_mdast_util_to_hast();
25254 remarkRehype = (function(destination, options) {
25255 return destination && "run" in destination ? bridge(destination, options) : mutate(destination || options);
25256 });
25257 }));
25258
25259 //#endregion
25260 //#region node_modules/remark-rehype/index.js
25261 var init_remark_rehype = __esmMin((() => {
25262 init_mdast_util_to_hast();
25263 init_lib();
25264 }));
25265
25266 //#endregion
25267 //#region node_modules/property-information/lib/util/schema.js
25268 var Schema;
25269 var init_schema = __esmMin((() => {
25270 Schema = class {
25271 /**
25272 * @constructor
25273 * @param {Properties} property
25274 * @param {Normal} normal
25275 * @param {string} [space]
25276 */
25277 constructor(property, normal, space) {
25278 this.property = property;
25279 this.normal = normal;
25280 if (space) this.space = space;
25281 }
25282 };
25283 /** @type {Properties} */
25284 Schema.prototype.property = {};
25285 /** @type {Normal} */
25286 Schema.prototype.normal = {};
25287 /** @type {string|null} */
25288 Schema.prototype.space = null;
25289 }));
25290
25291 //#endregion
25292 //#region node_modules/property-information/lib/util/merge.js
25293 /**
25294 * @param {Schema[]} definitions
25295 * @param {string} [space]
25296 * @returns {Schema}
25297 */
25298 function merge(definitions, space) {
25299 /** @type {Properties} */
25300 const property = {};
25301 /** @type {Normal} */
25302 const normal = {};
25303 let index = -1;
25304 while (++index < definitions.length) {
25305 Object.assign(property, definitions[index].property);
25306 Object.assign(normal, definitions[index].normal);
25307 }
25308 return new Schema(property, normal, space);
25309 }
25310 var init_merge = __esmMin((() => {
25311 init_schema();
25312 }));
25313
25314 //#endregion
25315 //#region node_modules/property-information/lib/normalize.js
25316 /**
25317 * @param {string} value
25318 * @returns {string}
25319 */
25320 function normalize(value) {
25321 return value.toLowerCase();
25322 }
25323 var init_normalize = __esmMin((() => {}));
25324
25325 //#endregion
25326 //#region node_modules/property-information/lib/util/info.js
25327 var Info;
25328 var init_info = __esmMin((() => {
25329 Info = class {
25330 /**
25331 * @constructor
25332 * @param {string} property
25333 * @param {string} attribute
25334 */
25335 constructor(property, attribute) {
25336 /** @type {string} */
25337 this.property = property;
25338 /** @type {string} */
25339 this.attribute = attribute;
25340 }
25341 };
25342 /** @type {string|null} */
25343 Info.prototype.space = null;
25344 Info.prototype.boolean = false;
25345 Info.prototype.booleanish = false;
25346 Info.prototype.overloadedBoolean = false;
25347 Info.prototype.number = false;
25348 Info.prototype.commaSeparated = false;
25349 Info.prototype.spaceSeparated = false;
25350 Info.prototype.commaOrSpaceSeparated = false;
25351 Info.prototype.mustUseProperty = false;
25352 Info.prototype.defined = false;
25353 }));
25354
25355 //#endregion
25356 //#region node_modules/property-information/lib/util/types.js
25357 var types_exports = /* @__PURE__ */ __exportAll({
25358 boolean: () => boolean,
25359 booleanish: () => booleanish,
25360 commaOrSpaceSeparated: () => commaOrSpaceSeparated,
25361 commaSeparated: () => commaSeparated,
25362 number: () => number,
25363 overloadedBoolean: () => overloadedBoolean,
25364 spaceSeparated: () => spaceSeparated
25365 });
25366 function increment() {
25367 return Math.pow(2, ++powers);
25368 }
25369 var powers, boolean, booleanish, overloadedBoolean, number, spaceSeparated, commaSeparated, commaOrSpaceSeparated;
25370 var init_types = __esmMin((() => {
25371 powers = 0;
25372 boolean = increment();
25373 booleanish = increment();
25374 overloadedBoolean = increment();
25375 number = increment();
25376 spaceSeparated = increment();
25377 commaSeparated = increment();
25378 commaOrSpaceSeparated = increment();
25379 }));
25380
25381 //#endregion
25382 //#region node_modules/property-information/lib/util/defined-info.js
25383 /**
25384 * @param {DefinedInfo} values
25385 * @param {string} key
25386 * @param {unknown} value
25387 */
25388 function mark(values, key, value) {
25389 if (value) values[key] = value;
25390 }
25391 var checks, DefinedInfo;
25392 var init_defined_info = __esmMin((() => {
25393 init_info();
25394 init_types();
25395 checks = Object.keys(types_exports);
25396 DefinedInfo = class extends Info {
25397 /**
25398 * @constructor
25399 * @param {string} property
25400 * @param {string} attribute
25401 * @param {number|null} [mask]
25402 * @param {string} [space]
25403 */
25404 constructor(property, attribute, mask, space) {
25405 let index = -1;
25406 super(property, attribute);
25407 mark(this, "space", space);
25408 if (typeof mask === "number") while (++index < checks.length) {
25409 const check = checks[index];
25410 mark(this, checks[index], (mask & types_exports[check]) === types_exports[check]);
25411 }
25412 }
25413 };
25414 DefinedInfo.prototype.defined = true;
25415 }));
25416
25417 //#endregion
25418 //#region node_modules/property-information/lib/util/create.js
25419 /**
25420 * @param {Definition} definition
25421 * @returns {Schema}
25422 */
25423 function create(definition) {
25424 /** @type {Properties} */
25425 const property = {};
25426 /** @type {Normal} */
25427 const normal = {};
25428 /** @type {string} */
25429 let prop;
25430 for (prop in definition.properties) if (own$2.call(definition.properties, prop)) {
25431 const value = definition.properties[prop];
25432 const info = new DefinedInfo(prop, definition.transform(definition.attributes || {}, prop), value, definition.space);
25433 if (definition.mustUseProperty && definition.mustUseProperty.includes(prop)) info.mustUseProperty = true;
25434 property[prop] = info;
25435 normal[normalize(prop)] = prop;
25436 normal[normalize(info.attribute)] = prop;
25437 }
25438 return new Schema(property, normal, definition.space);
25439 }
25440 var own$2;
25441 var init_create = __esmMin((() => {
25442 init_normalize();
25443 init_schema();
25444 init_defined_info();
25445 own$2 = {}.hasOwnProperty;
25446 }));
25447
25448 //#endregion
25449 //#region node_modules/property-information/lib/xlink.js
25450 var xlink;
25451 var init_xlink = __esmMin((() => {
25452 init_create();
25453 xlink = create({
25454 space: "xlink",
25455 transform(_, prop) {
25456 return "xlink:" + prop.slice(5).toLowerCase();
25457 },
25458 properties: {
25459 xLinkActuate: null,
25460 xLinkArcRole: null,
25461 xLinkHref: null,
25462 xLinkRole: null,
25463 xLinkShow: null,
25464 xLinkTitle: null,
25465 xLinkType: null
25466 }
25467 });
25468 }));
25469
25470 //#endregion
25471 //#region node_modules/property-information/lib/xml.js
25472 var xml;
25473 var init_xml = __esmMin((() => {
25474 init_create();
25475 xml = create({
25476 space: "xml",
25477 transform(_, prop) {
25478 return "xml:" + prop.slice(3).toLowerCase();
25479 },
25480 properties: {
25481 xmlLang: null,
25482 xmlBase: null,
25483 xmlSpace: null
25484 }
25485 });
25486 }));
25487
25488 //#endregion
25489 //#region node_modules/property-information/lib/util/case-sensitive-transform.js
25490 /**
25491 * @param {Record<string, string>} attributes
25492 * @param {string} attribute
25493 * @returns {string}
25494 */
25495 function caseSensitiveTransform(attributes, attribute) {
25496 return attribute in attributes ? attributes[attribute] : attribute;
25497 }
25498 var init_case_sensitive_transform = __esmMin((() => {}));
25499
25500 //#endregion
25501 //#region node_modules/property-information/lib/util/case-insensitive-transform.js
25502 /**
25503 * @param {Record<string, string>} attributes
25504 * @param {string} property
25505 * @returns {string}
25506 */
25507 function caseInsensitiveTransform(attributes, property) {
25508 return caseSensitiveTransform(attributes, property.toLowerCase());
25509 }
25510 var init_case_insensitive_transform = __esmMin((() => {
25511 init_case_sensitive_transform();
25512 }));
25513
25514 //#endregion
25515 //#region node_modules/property-information/lib/xmlns.js
25516 var xmlns;
25517 var init_xmlns = __esmMin((() => {
25518 init_create();
25519 init_case_insensitive_transform();
25520 xmlns = create({
25521 space: "xmlns",
25522 attributes: { xmlnsxlink: "xmlns:xlink" },
25523 transform: caseInsensitiveTransform,
25524 properties: {
25525 xmlns: null,
25526 xmlnsXLink: null
25527 }
25528 });
25529 }));
25530
25531 //#endregion
25532 //#region node_modules/property-information/lib/aria.js
25533 var aria;
25534 var init_aria = __esmMin((() => {
25535 init_types();
25536 init_create();
25537 aria = create({
25538 transform(_, prop) {
25539 return prop === "role" ? prop : "aria-" + prop.slice(4).toLowerCase();
25540 },
25541 properties: {
25542 ariaActiveDescendant: null,
25543 ariaAtomic: booleanish,
25544 ariaAutoComplete: null,
25545 ariaBusy: booleanish,
25546 ariaChecked: booleanish,
25547 ariaColCount: number,
25548 ariaColIndex: number,
25549 ariaColSpan: number,
25550 ariaControls: spaceSeparated,
25551 ariaCurrent: null,
25552 ariaDescribedBy: spaceSeparated,
25553 ariaDetails: null,
25554 ariaDisabled: booleanish,
25555 ariaDropEffect: spaceSeparated,
25556 ariaErrorMessage: null,
25557 ariaExpanded: booleanish,
25558 ariaFlowTo: spaceSeparated,
25559 ariaGrabbed: booleanish,
25560 ariaHasPopup: null,
25561 ariaHidden: booleanish,
25562 ariaInvalid: null,
25563 ariaKeyShortcuts: null,
25564 ariaLabel: null,
25565 ariaLabelledBy: spaceSeparated,
25566 ariaLevel: number,
25567 ariaLive: null,
25568 ariaModal: booleanish,
25569 ariaMultiLine: booleanish,
25570 ariaMultiSelectable: booleanish,
25571 ariaOrientation: null,
25572 ariaOwns: spaceSeparated,
25573 ariaPlaceholder: null,
25574 ariaPosInSet: number,
25575 ariaPressed: booleanish,
25576 ariaReadOnly: booleanish,
25577 ariaRelevant: null,
25578 ariaRequired: booleanish,
25579 ariaRoleDescription: spaceSeparated,
25580 ariaRowCount: number,
25581 ariaRowIndex: number,
25582 ariaRowSpan: number,
25583 ariaSelected: booleanish,
25584 ariaSetSize: number,
25585 ariaSort: null,
25586 ariaValueMax: number,
25587 ariaValueMin: number,
25588 ariaValueNow: number,
25589 ariaValueText: null,
25590 role: null
25591 }
25592 });
25593 }));
25594
25595 //#endregion
25596 //#region node_modules/property-information/lib/html.js
25597 var html$1;
25598 var init_html = __esmMin((() => {
25599 init_types();
25600 init_create();
25601 init_case_insensitive_transform();
25602 html$1 = create({
25603 space: "html",
25604 attributes: {
25605 acceptcharset: "accept-charset",
25606 classname: "class",
25607 htmlfor: "for",
25608 httpequiv: "http-equiv"
25609 },
25610 transform: caseInsensitiveTransform,
25611 mustUseProperty: [
25612 "checked",
25613 "multiple",
25614 "muted",
25615 "selected"
25616 ],
25617 properties: {
25618 abbr: null,
25619 accept: commaSeparated,
25620 acceptCharset: spaceSeparated,
25621 accessKey: spaceSeparated,
25622 action: null,
25623 allow: null,
25624 allowFullScreen: boolean,
25625 allowPaymentRequest: boolean,
25626 allowUserMedia: boolean,
25627 alt: null,
25628 as: null,
25629 async: boolean,
25630 autoCapitalize: null,
25631 autoComplete: spaceSeparated,
25632 autoFocus: boolean,
25633 autoPlay: boolean,
25634 blocking: spaceSeparated,
25635 capture: null,
25636 charSet: null,
25637 checked: boolean,
25638 cite: null,
25639 className: spaceSeparated,
25640 cols: number,
25641 colSpan: null,
25642 content: null,
25643 contentEditable: booleanish,
25644 controls: boolean,
25645 controlsList: spaceSeparated,
25646 coords: number | commaSeparated,
25647 crossOrigin: null,
25648 data: null,
25649 dateTime: null,
25650 decoding: null,
25651 default: boolean,
25652 defer: boolean,
25653 dir: null,
25654 dirName: null,
25655 disabled: boolean,
25656 download: overloadedBoolean,
25657 draggable: booleanish,
25658 encType: null,
25659 enterKeyHint: null,
25660 fetchPriority: null,
25661 form: null,
25662 formAction: null,
25663 formEncType: null,
25664 formMethod: null,
25665 formNoValidate: boolean,
25666 formTarget: null,
25667 headers: spaceSeparated,
25668 height: number,
25669 hidden: boolean,
25670 high: number,
25671 href: null,
25672 hrefLang: null,
25673 htmlFor: spaceSeparated,
25674 httpEquiv: spaceSeparated,
25675 id: null,
25676 imageSizes: null,
25677 imageSrcSet: null,
25678 inert: boolean,
25679 inputMode: null,
25680 integrity: null,
25681 is: null,
25682 isMap: boolean,
25683 itemId: null,
25684 itemProp: spaceSeparated,
25685 itemRef: spaceSeparated,
25686 itemScope: boolean,
25687 itemType: spaceSeparated,
25688 kind: null,
25689 label: null,
25690 lang: null,
25691 language: null,
25692 list: null,
25693 loading: null,
25694 loop: boolean,
25695 low: number,
25696 manifest: null,
25697 max: null,
25698 maxLength: number,
25699 media: null,
25700 method: null,
25701 min: null,
25702 minLength: number,
25703 multiple: boolean,
25704 muted: boolean,
25705 name: null,
25706 nonce: null,
25707 noModule: boolean,
25708 noValidate: boolean,
25709 onAbort: null,
25710 onAfterPrint: null,
25711 onAuxClick: null,
25712 onBeforeMatch: null,
25713 onBeforePrint: null,
25714 onBeforeToggle: null,
25715 onBeforeUnload: null,
25716 onBlur: null,
25717 onCancel: null,
25718 onCanPlay: null,
25719 onCanPlayThrough: null,
25720 onChange: null,
25721 onClick: null,
25722 onClose: null,
25723 onContextLost: null,
25724 onContextMenu: null,
25725 onContextRestored: null,
25726 onCopy: null,
25727 onCueChange: null,
25728 onCut: null,
25729 onDblClick: null,
25730 onDrag: null,
25731 onDragEnd: null,
25732 onDragEnter: null,
25733 onDragExit: null,
25734 onDragLeave: null,
25735 onDragOver: null,
25736 onDragStart: null,
25737 onDrop: null,
25738 onDurationChange: null,
25739 onEmptied: null,
25740 onEnded: null,
25741 onError: null,
25742 onFocus: null,
25743 onFormData: null,
25744 onHashChange: null,
25745 onInput: null,
25746 onInvalid: null,
25747 onKeyDown: null,
25748 onKeyPress: null,
25749 onKeyUp: null,
25750 onLanguageChange: null,
25751 onLoad: null,
25752 onLoadedData: null,
25753 onLoadedMetadata: null,
25754 onLoadEnd: null,
25755 onLoadStart: null,
25756 onMessage: null,
25757 onMessageError: null,
25758 onMouseDown: null,
25759 onMouseEnter: null,
25760 onMouseLeave: null,
25761 onMouseMove: null,
25762 onMouseOut: null,
25763 onMouseOver: null,
25764 onMouseUp: null,
25765 onOffline: null,
25766 onOnline: null,
25767 onPageHide: null,
25768 onPageShow: null,
25769 onPaste: null,
25770 onPause: null,
25771 onPlay: null,
25772 onPlaying: null,
25773 onPopState: null,
25774 onProgress: null,
25775 onRateChange: null,
25776 onRejectionHandled: null,
25777 onReset: null,
25778 onResize: null,
25779 onScroll: null,
25780 onScrollEnd: null,
25781 onSecurityPolicyViolation: null,
25782 onSeeked: null,
25783 onSeeking: null,
25784 onSelect: null,
25785 onSlotChange: null,
25786 onStalled: null,
25787 onStorage: null,
25788 onSubmit: null,
25789 onSuspend: null,
25790 onTimeUpdate: null,
25791 onToggle: null,
25792 onUnhandledRejection: null,
25793 onUnload: null,
25794 onVolumeChange: null,
25795 onWaiting: null,
25796 onWheel: null,
25797 open: boolean,
25798 optimum: number,
25799 pattern: null,
25800 ping: spaceSeparated,
25801 placeholder: null,
25802 playsInline: boolean,
25803 popover: null,
25804 popoverTarget: null,
25805 popoverTargetAction: null,
25806 poster: null,
25807 preload: null,
25808 readOnly: boolean,
25809 referrerPolicy: null,
25810 rel: spaceSeparated,
25811 required: boolean,
25812 reversed: boolean,
25813 rows: number,
25814 rowSpan: number,
25815 sandbox: spaceSeparated,
25816 scope: null,
25817 scoped: boolean,
25818 seamless: boolean,
25819 selected: boolean,
25820 shadowRootClonable: boolean,
25821 shadowRootDelegatesFocus: boolean,
25822 shadowRootMode: null,
25823 shape: null,
25824 size: number,
25825 sizes: null,
25826 slot: null,
25827 span: number,
25828 spellCheck: booleanish,
25829 src: null,
25830 srcDoc: null,
25831 srcLang: null,
25832 srcSet: null,
25833 start: number,
25834 step: null,
25835 style: null,
25836 tabIndex: number,
25837 target: null,
25838 title: null,
25839 translate: null,
25840 type: null,
25841 typeMustMatch: boolean,
25842 useMap: null,
25843 value: booleanish,
25844 width: number,
25845 wrap: null,
25846 writingSuggestions: null,
25847 align: null,
25848 aLink: null,
25849 archive: spaceSeparated,
25850 axis: null,
25851 background: null,
25852 bgColor: null,
25853 border: number,
25854 borderColor: null,
25855 bottomMargin: number,
25856 cellPadding: null,
25857 cellSpacing: null,
25858 char: null,
25859 charOff: null,
25860 classId: null,
25861 clear: null,
25862 code: null,
25863 codeBase: null,
25864 codeType: null,
25865 color: null,
25866 compact: boolean,
25867 declare: boolean,
25868 event: null,
25869 face: null,
25870 frame: null,
25871 frameBorder: null,
25872 hSpace: number,
25873 leftMargin: number,
25874 link: null,
25875 longDesc: null,
25876 lowSrc: null,
25877 marginHeight: number,
25878 marginWidth: number,
25879 noResize: boolean,
25880 noHref: boolean,
25881 noShade: boolean,
25882 noWrap: boolean,
25883 object: null,
25884 profile: null,
25885 prompt: null,
25886 rev: null,
25887 rightMargin: number,
25888 rules: null,
25889 scheme: null,
25890 scrolling: booleanish,
25891 standby: null,
25892 summary: null,
25893 text: null,
25894 topMargin: number,
25895 valueType: null,
25896 version: null,
25897 vAlign: null,
25898 vLink: null,
25899 vSpace: number,
25900 allowTransparency: null,
25901 autoCorrect: null,
25902 autoSave: null,
25903 disablePictureInPicture: boolean,
25904 disableRemotePlayback: boolean,
25905 prefix: null,
25906 property: null,
25907 results: number,
25908 security: null,
25909 unselectable: null
25910 }
25911 });
25912 }));
25913
25914 //#endregion
25915 //#region node_modules/property-information/lib/svg.js
25916 var svg$1;
25917 var init_svg = __esmMin((() => {
25918 init_types();
25919 init_create();
25920 init_case_sensitive_transform();
25921 svg$1 = create({
25922 space: "svg",
25923 attributes: {
25924 accentHeight: "accent-height",
25925 alignmentBaseline: "alignment-baseline",
25926 arabicForm: "arabic-form",
25927 baselineShift: "baseline-shift",
25928 capHeight: "cap-height",
25929 className: "class",
25930 clipPath: "clip-path",
25931 clipRule: "clip-rule",
25932 colorInterpolation: "color-interpolation",
25933 colorInterpolationFilters: "color-interpolation-filters",
25934 colorProfile: "color-profile",
25935 colorRendering: "color-rendering",
25936 crossOrigin: "crossorigin",
25937 dataType: "datatype",
25938 dominantBaseline: "dominant-baseline",
25939 enableBackground: "enable-background",
25940 fillOpacity: "fill-opacity",
25941 fillRule: "fill-rule",
25942 floodColor: "flood-color",
25943 floodOpacity: "flood-opacity",
25944 fontFamily: "font-family",
25945 fontSize: "font-size",
25946 fontSizeAdjust: "font-size-adjust",
25947 fontStretch: "font-stretch",
25948 fontStyle: "font-style",
25949 fontVariant: "font-variant",
25950 fontWeight: "font-weight",
25951 glyphName: "glyph-name",
25952 glyphOrientationHorizontal: "glyph-orientation-horizontal",
25953 glyphOrientationVertical: "glyph-orientation-vertical",
25954 hrefLang: "hreflang",
25955 horizAdvX: "horiz-adv-x",
25956 horizOriginX: "horiz-origin-x",
25957 horizOriginY: "horiz-origin-y",
25958 imageRendering: "image-rendering",
25959 letterSpacing: "letter-spacing",
25960 lightingColor: "lighting-color",
25961 markerEnd: "marker-end",
25962 markerMid: "marker-mid",
25963 markerStart: "marker-start",
25964 navDown: "nav-down",
25965 navDownLeft: "nav-down-left",
25966 navDownRight: "nav-down-right",
25967 navLeft: "nav-left",
25968 navNext: "nav-next",
25969 navPrev: "nav-prev",
25970 navRight: "nav-right",
25971 navUp: "nav-up",
25972 navUpLeft: "nav-up-left",
25973 navUpRight: "nav-up-right",
25974 onAbort: "onabort",
25975 onActivate: "onactivate",
25976 onAfterPrint: "onafterprint",
25977 onBeforePrint: "onbeforeprint",
25978 onBegin: "onbegin",
25979 onCancel: "oncancel",
25980 onCanPlay: "oncanplay",
25981 onCanPlayThrough: "oncanplaythrough",
25982 onChange: "onchange",
25983 onClick: "onclick",
25984 onClose: "onclose",
25985 onCopy: "oncopy",
25986 onCueChange: "oncuechange",
25987 onCut: "oncut",
25988 onDblClick: "ondblclick",
25989 onDrag: "ondrag",
25990 onDragEnd: "ondragend",
25991 onDragEnter: "ondragenter",
25992 onDragExit: "ondragexit",
25993 onDragLeave: "ondragleave",
25994 onDragOver: "ondragover",
25995 onDragStart: "ondragstart",
25996 onDrop: "ondrop",
25997 onDurationChange: "ondurationchange",
25998 onEmptied: "onemptied",
25999 onEnd: "onend",
26000 onEnded: "onended",
26001 onError: "onerror",
26002 onFocus: "onfocus",
26003 onFocusIn: "onfocusin",
26004 onFocusOut: "onfocusout",
26005 onHashChange: "onhashchange",
26006 onInput: "oninput",
26007 onInvalid: "oninvalid",
26008 onKeyDown: "onkeydown",
26009 onKeyPress: "onkeypress",
26010 onKeyUp: "onkeyup",
26011 onLoad: "onload",
26012 onLoadedData: "onloadeddata",
26013 onLoadedMetadata: "onloadedmetadata",
26014 onLoadStart: "onloadstart",
26015 onMessage: "onmessage",
26016 onMouseDown: "onmousedown",
26017 onMouseEnter: "onmouseenter",
26018 onMouseLeave: "onmouseleave",
26019 onMouseMove: "onmousemove",
26020 onMouseOut: "onmouseout",
26021 onMouseOver: "onmouseover",
26022 onMouseUp: "onmouseup",
26023 onMouseWheel: "onmousewheel",
26024 onOffline: "onoffline",
26025 onOnline: "ononline",
26026 onPageHide: "onpagehide",
26027 onPageShow: "onpageshow",
26028 onPaste: "onpaste",
26029 onPause: "onpause",
26030 onPlay: "onplay",
26031 onPlaying: "onplaying",
26032 onPopState: "onpopstate",
26033 onProgress: "onprogress",
26034 onRateChange: "onratechange",
26035 onRepeat: "onrepeat",
26036 onReset: "onreset",
26037 onResize: "onresize",
26038 onScroll: "onscroll",
26039 onSeeked: "onseeked",
26040 onSeeking: "onseeking",
26041 onSelect: "onselect",
26042 onShow: "onshow",
26043 onStalled: "onstalled",
26044 onStorage: "onstorage",
26045 onSubmit: "onsubmit",
26046 onSuspend: "onsuspend",
26047 onTimeUpdate: "ontimeupdate",
26048 onToggle: "ontoggle",
26049 onUnload: "onunload",
26050 onVolumeChange: "onvolumechange",
26051 onWaiting: "onwaiting",
26052 onZoom: "onzoom",
26053 overlinePosition: "overline-position",
26054 overlineThickness: "overline-thickness",
26055 paintOrder: "paint-order",
26056 panose1: "panose-1",
26057 pointerEvents: "pointer-events",
26058 referrerPolicy: "referrerpolicy",
26059 renderingIntent: "rendering-intent",
26060 shapeRendering: "shape-rendering",
26061 stopColor: "stop-color",
26062 stopOpacity: "stop-opacity",
26063 strikethroughPosition: "strikethrough-position",
26064 strikethroughThickness: "strikethrough-thickness",
26065 strokeDashArray: "stroke-dasharray",
26066 strokeDashOffset: "stroke-dashoffset",
26067 strokeLineCap: "stroke-linecap",
26068 strokeLineJoin: "stroke-linejoin",
26069 strokeMiterLimit: "stroke-miterlimit",
26070 strokeOpacity: "stroke-opacity",
26071 strokeWidth: "stroke-width",
26072 tabIndex: "tabindex",
26073 textAnchor: "text-anchor",
26074 textDecoration: "text-decoration",
26075 textRendering: "text-rendering",
26076 transformOrigin: "transform-origin",
26077 typeOf: "typeof",
26078 underlinePosition: "underline-position",
26079 underlineThickness: "underline-thickness",
26080 unicodeBidi: "unicode-bidi",
26081 unicodeRange: "unicode-range",
26082 unitsPerEm: "units-per-em",
26083 vAlphabetic: "v-alphabetic",
26084 vHanging: "v-hanging",
26085 vIdeographic: "v-ideographic",
26086 vMathematical: "v-mathematical",
26087 vectorEffect: "vector-effect",
26088 vertAdvY: "vert-adv-y",
26089 vertOriginX: "vert-origin-x",
26090 vertOriginY: "vert-origin-y",
26091 wordSpacing: "word-spacing",
26092 writingMode: "writing-mode",
26093 xHeight: "x-height",
26094 playbackOrder: "playbackorder",
26095 timelineBegin: "timelinebegin"
26096 },
26097 transform: caseSensitiveTransform,
26098 properties: {
26099 about: commaOrSpaceSeparated,
26100 accentHeight: number,
26101 accumulate: null,
26102 additive: null,
26103 alignmentBaseline: null,
26104 alphabetic: number,
26105 amplitude: number,
26106 arabicForm: null,
26107 ascent: number,
26108 attributeName: null,
26109 attributeType: null,
26110 azimuth: number,
26111 bandwidth: null,
26112 baselineShift: null,
26113 baseFrequency: null,
26114 baseProfile: null,
26115 bbox: null,
26116 begin: null,
26117 bias: number,
26118 by: null,
26119 calcMode: null,
26120 capHeight: number,
26121 className: spaceSeparated,
26122 clip: null,
26123 clipPath: null,
26124 clipPathUnits: null,
26125 clipRule: null,
26126 color: null,
26127 colorInterpolation: null,
26128 colorInterpolationFilters: null,
26129 colorProfile: null,
26130 colorRendering: null,
26131 content: null,
26132 contentScriptType: null,
26133 contentStyleType: null,
26134 crossOrigin: null,
26135 cursor: null,
26136 cx: null,
26137 cy: null,
26138 d: null,
26139 dataType: null,
26140 defaultAction: null,
26141 descent: number,
26142 diffuseConstant: number,
26143 direction: null,
26144 display: null,
26145 dur: null,
26146 divisor: number,
26147 dominantBaseline: null,
26148 download: boolean,
26149 dx: null,
26150 dy: null,
26151 edgeMode: null,
26152 editable: null,
26153 elevation: number,
26154 enableBackground: null,
26155 end: null,
26156 event: null,
26157 exponent: number,
26158 externalResourcesRequired: null,
26159 fill: null,
26160 fillOpacity: number,
26161 fillRule: null,
26162 filter: null,
26163 filterRes: null,
26164 filterUnits: null,
26165 floodColor: null,
26166 floodOpacity: null,
26167 focusable: null,
26168 focusHighlight: null,
26169 fontFamily: null,
26170 fontSize: null,
26171 fontSizeAdjust: null,
26172 fontStretch: null,
26173 fontStyle: null,
26174 fontVariant: null,
26175 fontWeight: null,
26176 format: null,
26177 fr: null,
26178 from: null,
26179 fx: null,
26180 fy: null,
26181 g1: commaSeparated,
26182 g2: commaSeparated,
26183 glyphName: commaSeparated,
26184 glyphOrientationHorizontal: null,
26185 glyphOrientationVertical: null,
26186 glyphRef: null,
26187 gradientTransform: null,
26188 gradientUnits: null,
26189 handler: null,
26190 hanging: number,
26191 hatchContentUnits: null,
26192 hatchUnits: null,
26193 height: null,
26194 href: null,
26195 hrefLang: null,
26196 horizAdvX: number,
26197 horizOriginX: number,
26198 horizOriginY: number,
26199 id: null,
26200 ideographic: number,
26201 imageRendering: null,
26202 initialVisibility: null,
26203 in: null,
26204 in2: null,
26205 intercept: number,
26206 k: number,
26207 k1: number,
26208 k2: number,
26209 k3: number,
26210 k4: number,
26211 kernelMatrix: commaOrSpaceSeparated,
26212 kernelUnitLength: null,
26213 keyPoints: null,
26214 keySplines: null,
26215 keyTimes: null,
26216 kerning: null,
26217 lang: null,
26218 lengthAdjust: null,
26219 letterSpacing: null,
26220 lightingColor: null,
26221 limitingConeAngle: number,
26222 local: null,
26223 markerEnd: null,
26224 markerMid: null,
26225 markerStart: null,
26226 markerHeight: null,
26227 markerUnits: null,
26228 markerWidth: null,
26229 mask: null,
26230 maskContentUnits: null,
26231 maskUnits: null,
26232 mathematical: null,
26233 max: null,
26234 media: null,
26235 mediaCharacterEncoding: null,
26236 mediaContentEncodings: null,
26237 mediaSize: number,
26238 mediaTime: null,
26239 method: null,
26240 min: null,
26241 mode: null,
26242 name: null,
26243 navDown: null,
26244 navDownLeft: null,
26245 navDownRight: null,
26246 navLeft: null,
26247 navNext: null,
26248 navPrev: null,
26249 navRight: null,
26250 navUp: null,
26251 navUpLeft: null,
26252 navUpRight: null,
26253 numOctaves: null,
26254 observer: null,
26255 offset: null,
26256 onAbort: null,
26257 onActivate: null,
26258 onAfterPrint: null,
26259 onBeforePrint: null,
26260 onBegin: null,
26261 onCancel: null,
26262 onCanPlay: null,
26263 onCanPlayThrough: null,
26264 onChange: null,
26265 onClick: null,
26266 onClose: null,
26267 onCopy: null,
26268 onCueChange: null,
26269 onCut: null,
26270 onDblClick: null,
26271 onDrag: null,
26272 onDragEnd: null,
26273 onDragEnter: null,
26274 onDragExit: null,
26275 onDragLeave: null,
26276 onDragOver: null,
26277 onDragStart: null,
26278 onDrop: null,
26279 onDurationChange: null,
26280 onEmptied: null,
26281 onEnd: null,
26282 onEnded: null,
26283 onError: null,
26284 onFocus: null,
26285 onFocusIn: null,
26286 onFocusOut: null,
26287 onHashChange: null,
26288 onInput: null,
26289 onInvalid: null,
26290 onKeyDown: null,
26291 onKeyPress: null,
26292 onKeyUp: null,
26293 onLoad: null,
26294 onLoadedData: null,
26295 onLoadedMetadata: null,
26296 onLoadStart: null,
26297 onMessage: null,
26298 onMouseDown: null,
26299 onMouseEnter: null,
26300 onMouseLeave: null,
26301 onMouseMove: null,
26302 onMouseOut: null,
26303 onMouseOver: null,
26304 onMouseUp: null,
26305 onMouseWheel: null,
26306 onOffline: null,
26307 onOnline: null,
26308 onPageHide: null,
26309 onPageShow: null,
26310 onPaste: null,
26311 onPause: null,
26312 onPlay: null,
26313 onPlaying: null,
26314 onPopState: null,
26315 onProgress: null,
26316 onRateChange: null,
26317 onRepeat: null,
26318 onReset: null,
26319 onResize: null,
26320 onScroll: null,
26321 onSeeked: null,
26322 onSeeking: null,
26323 onSelect: null,
26324 onShow: null,
26325 onStalled: null,
26326 onStorage: null,
26327 onSubmit: null,
26328 onSuspend: null,
26329 onTimeUpdate: null,
26330 onToggle: null,
26331 onUnload: null,
26332 onVolumeChange: null,
26333 onWaiting: null,
26334 onZoom: null,
26335 opacity: null,
26336 operator: null,
26337 order: null,
26338 orient: null,
26339 orientation: null,
26340 origin: null,
26341 overflow: null,
26342 overlay: null,
26343 overlinePosition: number,
26344 overlineThickness: number,
26345 paintOrder: null,
26346 panose1: null,
26347 path: null,
26348 pathLength: number,
26349 patternContentUnits: null,
26350 patternTransform: null,
26351 patternUnits: null,
26352 phase: null,
26353 ping: spaceSeparated,
26354 pitch: null,
26355 playbackOrder: null,
26356 pointerEvents: null,
26357 points: null,
26358 pointsAtX: number,
26359 pointsAtY: number,
26360 pointsAtZ: number,
26361 preserveAlpha: null,
26362 preserveAspectRatio: null,
26363 primitiveUnits: null,
26364 propagate: null,
26365 property: commaOrSpaceSeparated,
26366 r: null,
26367 radius: null,
26368 referrerPolicy: null,
26369 refX: null,
26370 refY: null,
26371 rel: commaOrSpaceSeparated,
26372 rev: commaOrSpaceSeparated,
26373 renderingIntent: null,
26374 repeatCount: null,
26375 repeatDur: null,
26376 requiredExtensions: commaOrSpaceSeparated,
26377 requiredFeatures: commaOrSpaceSeparated,
26378 requiredFonts: commaOrSpaceSeparated,
26379 requiredFormats: commaOrSpaceSeparated,
26380 resource: null,
26381 restart: null,
26382 result: null,
26383 rotate: null,
26384 rx: null,
26385 ry: null,
26386 scale: null,
26387 seed: null,
26388 shapeRendering: null,
26389 side: null,
26390 slope: null,
26391 snapshotTime: null,
26392 specularConstant: number,
26393 specularExponent: number,
26394 spreadMethod: null,
26395 spacing: null,
26396 startOffset: null,
26397 stdDeviation: null,
26398 stemh: null,
26399 stemv: null,
26400 stitchTiles: null,
26401 stopColor: null,
26402 stopOpacity: null,
26403 strikethroughPosition: number,
26404 strikethroughThickness: number,
26405 string: null,
26406 stroke: null,
26407 strokeDashArray: commaOrSpaceSeparated,
26408 strokeDashOffset: null,
26409 strokeLineCap: null,
26410 strokeLineJoin: null,
26411 strokeMiterLimit: number,
26412 strokeOpacity: number,
26413 strokeWidth: null,
26414 style: null,
26415 surfaceScale: number,
26416 syncBehavior: null,
26417 syncBehaviorDefault: null,
26418 syncMaster: null,
26419 syncTolerance: null,
26420 syncToleranceDefault: null,
26421 systemLanguage: commaOrSpaceSeparated,
26422 tabIndex: number,
26423 tableValues: null,
26424 target: null,
26425 targetX: number,
26426 targetY: number,
26427 textAnchor: null,
26428 textDecoration: null,
26429 textRendering: null,
26430 textLength: null,
26431 timelineBegin: null,
26432 title: null,
26433 transformBehavior: null,
26434 type: null,
26435 typeOf: commaOrSpaceSeparated,
26436 to: null,
26437 transform: null,
26438 transformOrigin: null,
26439 u1: null,
26440 u2: null,
26441 underlinePosition: number,
26442 underlineThickness: number,
26443 unicode: null,
26444 unicodeBidi: null,
26445 unicodeRange: null,
26446 unitsPerEm: number,
26447 values: null,
26448 vAlphabetic: number,
26449 vMathematical: number,
26450 vectorEffect: null,
26451 vHanging: number,
26452 vIdeographic: number,
26453 version: null,
26454 vertAdvY: number,
26455 vertOriginX: number,
26456 vertOriginY: number,
26457 viewBox: null,
26458 viewTarget: null,
26459 visibility: null,
26460 width: null,
26461 widths: null,
26462 wordSpacing: null,
26463 writingMode: null,
26464 x: null,
26465 x1: null,
26466 x2: null,
26467 xChannelSelector: null,
26468 xHeight: number,
26469 y: null,
26470 y1: null,
26471 y2: null,
26472 yChannelSelector: null,
26473 z: null,
26474 zoomAndPan: null
26475 }
26476 });
26477 }));
26478
26479 //#endregion
26480 //#region node_modules/property-information/lib/find.js
26481 /**
26482 * @param {Schema} schema
26483 * @param {string} value
26484 * @returns {Info}
26485 */
26486 function find(schema, value) {
26487 const normal = normalize(value);
26488 let prop = value;
26489 let Type = Info;
26490 if (normal in schema.normal) return schema.property[schema.normal[normal]];
26491 if (normal.length > 4 && normal.slice(0, 4) === "data" && valid.test(value)) {
26492 if (value.charAt(4) === "-") {
26493 const rest = value.slice(5).replace(dash, camelcase);
26494 prop = "data" + rest.charAt(0).toUpperCase() + rest.slice(1);
26495 } else {
26496 const rest = value.slice(4);
26497 if (!dash.test(rest)) {
26498 let dashes = rest.replace(cap, kebab);
26499 if (dashes.charAt(0) !== "-") dashes = "-" + dashes;
26500 value = "data" + dashes;
26501 }
26502 }
26503 Type = DefinedInfo;
26504 }
26505 return new Type(prop, value);
26506 }
26507 /**
26508 * @param {string} $0
26509 * @returns {string}
26510 */
26511 function kebab($0) {
26512 return "-" + $0.toLowerCase();
26513 }
26514 /**
26515 * @param {string} $0
26516 * @returns {string}
26517 */
26518 function camelcase($0) {
26519 return $0.charAt(1).toUpperCase();
26520 }
26521 var valid, dash, cap;
26522 var init_find = __esmMin((() => {
26523 init_normalize();
26524 init_defined_info();
26525 init_info();
26526 valid = /^data[-\w.:]+$/i;
26527 dash = /-[a-z]/g;
26528 cap = /[A-Z]/g;
26529 }));
26530
26531 //#endregion
26532 //#region node_modules/property-information/lib/hast-to-react.js
26533 var hastToReact;
26534 var init_hast_to_react = __esmMin((() => {
26535 hastToReact = {
26536 classId: "classID",
26537 dataType: "datatype",
26538 itemId: "itemID",
26539 strokeDashArray: "strokeDasharray",
26540 strokeDashOffset: "strokeDashoffset",
26541 strokeLineCap: "strokeLinecap",
26542 strokeLineJoin: "strokeLinejoin",
26543 strokeMiterLimit: "strokeMiterlimit",
26544 typeOf: "typeof",
26545 xLinkActuate: "xlinkActuate",
26546 xLinkArcRole: "xlinkArcrole",
26547 xLinkHref: "xlinkHref",
26548 xLinkRole: "xlinkRole",
26549 xLinkShow: "xlinkShow",
26550 xLinkTitle: "xlinkTitle",
26551 xLinkType: "xlinkType",
26552 xmlnsXLink: "xmlnsXlink"
26553 };
26554 }));
26555
26556 //#endregion
26557 //#region node_modules/property-information/index.js
26558 var html, svg;
26559 var init_property_information = __esmMin((() => {
26560 init_merge();
26561 init_xlink();
26562 init_xml();
26563 init_xmlns();
26564 init_aria();
26565 init_html();
26566 init_svg();
26567 init_find();
26568 init_hast_to_react();
26569 init_normalize();
26570 html = merge([
26571 xml,
26572 xlink,
26573 xmlns,
26574 aria,
26575 html$1
26576 ], "html");
26577 svg = merge([
26578 xml,
26579 xlink,
26580 xmlns,
26581 aria,
26582 svg$1
26583 ], "svg");
26584 }));
26585
26586 //#endregion
26587 //#region node_modules/react-markdown/lib/rehype-filter.js
26588 /**
26589 * @typedef {import('unist').Node} Node
26590 * @typedef {import('hast').Root} Root
26591 * @typedef {import('hast').Element} Element
26592 *
26593 * @callback AllowElement
26594 * @param {Element} element
26595 * @param {number} index
26596 * @param {Element|Root} parent
26597 * @returns {boolean|undefined}
26598 *
26599 * @typedef Options
26600 * @property {Array<string>} [allowedElements]
26601 * @property {Array<string>} [disallowedElements=[]]
26602 * @property {AllowElement} [allowElement]
26603 * @property {boolean} [unwrapDisallowed=false]
26604 */
26605 /**
26606 * @type {import('unified').Plugin<[Options], Root>}
26607 */
26608 function rehypeFilter(options) {
26609 if (options.allowedElements && options.disallowedElements) throw new TypeError("Only one of `allowedElements` and `disallowedElements` should be defined");
26610 if (options.allowedElements || options.disallowedElements || options.allowElement) return (tree) => {
26611 visit(tree, "element", (node, index, parent_) => {
26612 const parent = parent_;
26613 /** @type {boolean|undefined} */
26614 let remove;
26615 if (options.allowedElements) remove = !options.allowedElements.includes(node.tagName);
26616 else if (options.disallowedElements) remove = options.disallowedElements.includes(node.tagName);
26617 if (!remove && options.allowElement && typeof index === "number") remove = !options.allowElement(node, index, parent);
26618 if (remove && typeof index === "number") {
26619 if (options.unwrapDisallowed && node.children) parent.children.splice(index, 1, ...node.children);
26620 else parent.children.splice(index, 1);
26621 return index;
26622 }
26623 });
26624 };
26625 }
26626 var init_rehype_filter = __esmMin((() => {
26627 init_unist_util_visit();
26628 }));
26629
26630 //#endregion
26631 //#region node_modules/react-is/cjs/react-is.development.js
26632 /**
26633 * @license React
26634 * react-is.development.js
26635 *
26636 * Copyright (c) Facebook, Inc. and its affiliates.
26637 *
26638 * This source code is licensed under the MIT license found in the
26639 * LICENSE file in the root directory of this source tree.
26640 */
26641 var require_react_is_development = /* @__PURE__ */ __commonJSMin(((exports) => {
26642 (function() {
26643 "use strict";
26644 var REACT_ELEMENT_TYPE = Symbol.for("react.element");
26645 var REACT_PORTAL_TYPE = Symbol.for("react.portal");
26646 var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
26647 var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
26648 var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
26649 var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
26650 var REACT_CONTEXT_TYPE = Symbol.for("react.context");
26651 var REACT_SERVER_CONTEXT_TYPE = Symbol.for("react.server_context");
26652 var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
26653 var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
26654 var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
26655 var REACT_MEMO_TYPE = Symbol.for("react.memo");
26656 var REACT_LAZY_TYPE = Symbol.for("react.lazy");
26657 var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
26658 var enableScopeAPI = false;
26659 var enableCacheElement = false;
26660 var enableTransitionTracing = false;
26661 var enableLegacyHidden = false;
26662 var enableDebugTracing = false;
26663 var REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
26664 function isValidElementType(type) {
26665 if (typeof type === "string" || typeof type === "function") return true;
26666 if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) return true;
26667 if (typeof type === "object" && type !== null) {
26668 if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) return true;
26669 }
26670 return false;
26671 }
26672 function typeOf(object) {
26673 if (typeof object === "object" && object !== null) {
26674 var $$typeof = object.$$typeof;
26675 switch ($$typeof) {
26676 case REACT_ELEMENT_TYPE:
26677 var type = object.type;
26678 switch (type) {
26679 case REACT_FRAGMENT_TYPE:
26680 case REACT_PROFILER_TYPE:
26681 case REACT_STRICT_MODE_TYPE:
26682 case REACT_SUSPENSE_TYPE:
26683 case REACT_SUSPENSE_LIST_TYPE: return type;
26684 default:
26685 var $$typeofType = type && type.$$typeof;
26686 switch ($$typeofType) {
26687 case REACT_SERVER_CONTEXT_TYPE:
26688 case REACT_CONTEXT_TYPE:
26689 case REACT_FORWARD_REF_TYPE:
26690 case REACT_LAZY_TYPE:
26691 case REACT_MEMO_TYPE:
26692 case REACT_PROVIDER_TYPE: return $$typeofType;
26693 default: return $$typeof;
26694 }
26695 }
26696 case REACT_PORTAL_TYPE: return $$typeof;
26697 }
26698 }
26699 }
26700 var ContextConsumer = REACT_CONTEXT_TYPE;
26701 var ContextProvider = REACT_PROVIDER_TYPE;
26702 var Element = REACT_ELEMENT_TYPE;
26703 var ForwardRef = REACT_FORWARD_REF_TYPE;
26704 var Fragment = REACT_FRAGMENT_TYPE;
26705 var Lazy = REACT_LAZY_TYPE;
26706 var Memo = REACT_MEMO_TYPE;
26707 var Portal = REACT_PORTAL_TYPE;
26708 var Profiler = REACT_PROFILER_TYPE;
26709 var StrictMode = REACT_STRICT_MODE_TYPE;
26710 var Suspense = REACT_SUSPENSE_TYPE;
26711 var SuspenseList = REACT_SUSPENSE_LIST_TYPE;
26712 var hasWarnedAboutDeprecatedIsAsyncMode = false;
26713 var hasWarnedAboutDeprecatedIsConcurrentMode = false;
26714 function isAsyncMode(object) {
26715 if (!hasWarnedAboutDeprecatedIsAsyncMode) {
26716 hasWarnedAboutDeprecatedIsAsyncMode = true;
26717 console["warn"]("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.");
26718 }
26719 return false;
26720 }
26721 function isConcurrentMode(object) {
26722 if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
26723 hasWarnedAboutDeprecatedIsConcurrentMode = true;
26724 console["warn"]("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.");
26725 }
26726 return false;
26727 }
26728 function isContextConsumer(object) {
26729 return typeOf(object) === REACT_CONTEXT_TYPE;
26730 }
26731 function isContextProvider(object) {
26732 return typeOf(object) === REACT_PROVIDER_TYPE;
26733 }
26734 function isElement(object) {
26735 return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
26736 }
26737 function isForwardRef(object) {
26738 return typeOf(object) === REACT_FORWARD_REF_TYPE;
26739 }
26740 function isFragment(object) {
26741 return typeOf(object) === REACT_FRAGMENT_TYPE;
26742 }
26743 function isLazy(object) {
26744 return typeOf(object) === REACT_LAZY_TYPE;
26745 }
26746 function isMemo(object) {
26747 return typeOf(object) === REACT_MEMO_TYPE;
26748 }
26749 function isPortal(object) {
26750 return typeOf(object) === REACT_PORTAL_TYPE;
26751 }
26752 function isProfiler(object) {
26753 return typeOf(object) === REACT_PROFILER_TYPE;
26754 }
26755 function isStrictMode(object) {
26756 return typeOf(object) === REACT_STRICT_MODE_TYPE;
26757 }
26758 function isSuspense(object) {
26759 return typeOf(object) === REACT_SUSPENSE_TYPE;
26760 }
26761 function isSuspenseList(object) {
26762 return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
26763 }
26764 exports.ContextConsumer = ContextConsumer;
26765 exports.ContextProvider = ContextProvider;
26766 exports.Element = Element;
26767 exports.ForwardRef = ForwardRef;
26768 exports.Fragment = Fragment;
26769 exports.Lazy = Lazy;
26770 exports.Memo = Memo;
26771 exports.Portal = Portal;
26772 exports.Profiler = Profiler;
26773 exports.StrictMode = StrictMode;
26774 exports.Suspense = Suspense;
26775 exports.SuspenseList = SuspenseList;
26776 exports.isAsyncMode = isAsyncMode;
26777 exports.isConcurrentMode = isConcurrentMode;
26778 exports.isContextConsumer = isContextConsumer;
26779 exports.isContextProvider = isContextProvider;
26780 exports.isElement = isElement;
26781 exports.isForwardRef = isForwardRef;
26782 exports.isFragment = isFragment;
26783 exports.isLazy = isLazy;
26784 exports.isMemo = isMemo;
26785 exports.isPortal = isPortal;
26786 exports.isProfiler = isProfiler;
26787 exports.isStrictMode = isStrictMode;
26788 exports.isSuspense = isSuspense;
26789 exports.isSuspenseList = isSuspenseList;
26790 exports.isValidElementType = isValidElementType;
26791 exports.typeOf = typeOf;
26792 })();
26793 }));
26794
26795 //#endregion
26796 //#region node_modules/react-is/index.js
26797 var require_react_is = /* @__PURE__ */ __commonJSMin(((exports, module) => {
26798 module.exports = require_react_is_development();
26799 }));
26800
26801 //#endregion
26802 //#region node_modules/hast-util-whitespace/index.js
26803 /**
26804 * Check if the given value is *inter-element whitespace*.
26805 *
26806 * @param {unknown} thing
26807 * Thing to check (typically `Node` or `string`).
26808 * @returns {boolean}
26809 * Whether the `value` is inter-element whitespace (`boolean`): consisting of
26810 * zero or more of space, tab (`\t`), line feed (`\n`), carriage return
26811 * (`\r`), or form feed (`\f`).
26812 * If a node is passed it must be a `Text` node, whose `value` field is
26813 * checked.
26814 */
26815 function whitespace(thing) {
26816 /** @type {string} */
26817 const value = thing && typeof thing === "object" && thing.type === "text" ? thing.value || "" : thing;
26818 return typeof value === "string" && value.replace(/[ \t\n\f\r]/g, "") === "";
26819 }
26820 var init_hast_util_whitespace = __esmMin((() => {}));
26821
26822 //#endregion
26823 //#region node_modules/space-separated-tokens/index.js
26824 /**
26825 * Serialize an array of strings as space separated-tokens.
26826 *
26827 * @param {Array<string|number>} values
26828 * List of tokens.
26829 * @returns {string}
26830 * Space-separated tokens.
26831 */
26832 function stringify$1(values) {
26833 return values.join(" ").trim();
26834 }
26835 var init_space_separated_tokens = __esmMin((() => {
26836 __name(stringify$1, "stringify");
26837 }));
26838
26839 //#endregion
26840 //#region node_modules/comma-separated-tokens/index.js
26841 /**
26842 * Serialize an array of strings or numbers to comma-separated tokens.
26843 *
26844 * @param {Array<string|number>} values
26845 * List of tokens.
26846 * @param {Options} [options]
26847 * Configuration for `stringify` (optional).
26848 * @returns {string}
26849 * Comma-separated tokens.
26850 */
26851 function stringify(values, options) {
26852 const settings = options || {};
26853 return (values[values.length - 1] === "" ? [...values, ""] : values).join((settings.padRight ? " " : "") + "," + (settings.padLeft === false ? "" : " ")).trim();
26854 }
26855 var init_comma_separated_tokens = __esmMin((() => {}));
26856
26857 //#endregion
26858 //#region node_modules/inline-style-parser/index.js
26859 var require_inline_style_parser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
26860 var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
26861 var NEWLINE_REGEX = /\n/g;
26862 var WHITESPACE_REGEX = /^\s*/;
26863 var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
26864 var COLON_REGEX = /^:\s*/;
26865 var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/;
26866 var SEMICOLON_REGEX = /^[;\s]*/;
26867 var TRIM_REGEX = /^\s+|\s+$/g;
26868 var NEWLINE = "\n";
26869 var FORWARD_SLASH = "/";
26870 var ASTERISK = "*";
26871 var EMPTY_STRING = "";
26872 var TYPE_COMMENT = "comment";
26873 var TYPE_DECLARATION = "declaration";
26874 /**
26875 * @param {String} style
26876 * @param {Object} [options]
26877 * @return {Object[]}
26878 * @throws {TypeError}
26879 * @throws {Error}
26880 */
26881 module.exports = function(style, options) {
26882 if (typeof style !== "string") throw new TypeError("First argument must be a string");
26883 if (!style) return [];
26884 options = options || {};
26885 /**
26886 * Positional.
26887 */
26888 var lineno = 1;
26889 var column = 1;
26890 /**
26891 * Update lineno and column based on `str`.
26892 *
26893 * @param {String} str
26894 */
26895 function updatePosition(str) {
26896 var lines = str.match(NEWLINE_REGEX);
26897 if (lines) lineno += lines.length;
26898 var i = str.lastIndexOf(NEWLINE);
26899 column = ~i ? str.length - i : column + str.length;
26900 }
26901 /**
26902 * Mark position and patch `node.position`.
26903 *
26904 * @return {Function}
26905 */
26906 function position() {
26907 var start = {
26908 line: lineno,
26909 column
26910 };
26911 return function(node) {
26912 node.position = new Position(start);
26913 whitespace();
26914 return node;
26915 };
26916 }
26917 /**
26918 * Store position information for a node.
26919 *
26920 * @constructor
26921 * @property {Object} start
26922 * @property {Object} end
26923 * @property {undefined|String} source
26924 */
26925 function Position(start) {
26926 this.start = start;
26927 this.end = {
26928 line: lineno,
26929 column
26930 };
26931 this.source = options.source;
26932 }
26933 /**
26934 * Non-enumerable source string.
26935 */
26936 Position.prototype.content = style;
26937 var errorsList = [];
26938 /**
26939 * Error `msg`.
26940 *
26941 * @param {String} msg
26942 * @throws {Error}
26943 */
26944 function error(msg) {
26945 var err = /* @__PURE__ */ new Error(options.source + ":" + lineno + ":" + column + ": " + msg);
26946 err.reason = msg;
26947 err.filename = options.source;
26948 err.line = lineno;
26949 err.column = column;
26950 err.source = style;
26951 if (options.silent) errorsList.push(err);
26952 else throw err;
26953 }
26954 /**
26955 * Match `re` and return captures.
26956 *
26957 * @param {RegExp} re
26958 * @return {undefined|Array}
26959 */
26960 function match(re) {
26961 var m = re.exec(style);
26962 if (!m) return;
26963 var str = m[0];
26964 updatePosition(str);
26965 style = style.slice(str.length);
26966 return m;
26967 }
26968 /**
26969 * Parse whitespace.
26970 */
26971 function whitespace() {
26972 match(WHITESPACE_REGEX);
26973 }
26974 /**
26975 * Parse comments.
26976 *
26977 * @param {Object[]} [rules]
26978 * @return {Object[]}
26979 */
26980 function comments(rules) {
26981 var c;
26982 rules = rules || [];
26983 while (c = comment()) if (c !== false) rules.push(c);
26984 return rules;
26985 }
26986 /**
26987 * Parse comment.
26988 *
26989 * @return {Object}
26990 * @throws {Error}
26991 */
26992 function comment() {
26993 var pos = position();
26994 if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
26995 var i = 2;
26996 while (EMPTY_STRING != style.charAt(i) && (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))) ++i;
26997 i += 2;
26998 if (EMPTY_STRING === style.charAt(i - 1)) return error("End of comment missing");
26999 var str = style.slice(2, i - 2);
27000 column += 2;
27001 updatePosition(str);
27002 style = style.slice(i);
27003 column += 2;
27004 return pos({
27005 type: TYPE_COMMENT,
27006 comment: str
27007 });
27008 }
27009 /**
27010 * Parse declaration.
27011 *
27012 * @return {Object}
27013 * @throws {Error}
27014 */
27015 function declaration() {
27016 var pos = position();
27017 var prop = match(PROPERTY_REGEX);
27018 if (!prop) return;
27019 comment();
27020 if (!match(COLON_REGEX)) return error("property missing ':'");
27021 var val = match(VALUE_REGEX);
27022 var ret = pos({
27023 type: TYPE_DECLARATION,
27024 property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
27025 value: val ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING)) : EMPTY_STRING
27026 });
27027 match(SEMICOLON_REGEX);
27028 return ret;
27029 }
27030 /**
27031 * Parse declarations.
27032 *
27033 * @return {Object[]}
27034 */
27035 function declarations() {
27036 var decls = [];
27037 comments(decls);
27038 var decl;
27039 while (decl = declaration()) if (decl !== false) {
27040 decls.push(decl);
27041 comments(decls);
27042 }
27043 return decls;
27044 }
27045 whitespace();
27046 return declarations();
27047 };
27048 /**
27049 * Trim `str`.
27050 *
27051 * @param {String} str
27052 * @return {String}
27053 */
27054 function trim(str) {
27055 return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
27056 }
27057 }));
27058
27059 //#endregion
27060 //#region node_modules/style-to-object/index.js
27061 var require_style_to_object = /* @__PURE__ */ __commonJSMin(((exports, module) => {
27062 var parse = require_inline_style_parser();
27063 /**
27064 * Parses inline style to object.
27065 *
27066 * @example
27067 * // returns { 'line-height': '42' }
27068 * StyleToObject('line-height: 42;');
27069 *
27070 * @param {String} style - The inline style.
27071 * @param {Function} [iterator] - The iterator function.
27072 * @return {null|Object}
27073 */
27074 function StyleToObject(style, iterator) {
27075 var output = null;
27076 if (!style || typeof style !== "string") return output;
27077 var declaration;
27078 var declarations = parse(style);
27079 var hasIterator = typeof iterator === "function";
27080 var property;
27081 var value;
27082 for (var i = 0, len = declarations.length; i < len; i++) {
27083 declaration = declarations[i];
27084 property = declaration.property;
27085 value = declaration.value;
27086 if (hasIterator) iterator(property, value, declaration);
27087 else if (value) {
27088 output || (output = {});
27089 output[property] = value;
27090 }
27091 }
27092 return output;
27093 }
27094 module.exports = StyleToObject;
27095 module.exports.default = StyleToObject;
27096 }));
27097
27098 //#endregion
27099 //#region node_modules/style-to-object/index.mjs
27100 var import_style_to_object, style_to_object_default;
27101 var init_style_to_object = __esmMin((() => {
27102 import_style_to_object = /* @__PURE__ */ __toESM(require_style_to_object(), 1);
27103 style_to_object_default = import_style_to_object.default;
27104 }));
27105
27106 //#endregion
27107 //#region node_modules/react-markdown/lib/ast-to-react.js
27108 /**
27109 * @template T
27110 * @typedef {Promise.resolve(React).ComponentType<T>} ComponentType<T>
27111 */
27112 /**
27113 * @template {Promise.resolve(React).ElementType} T
27114 * @typedef {Promise.resolve(React).ComponentPropsWithoutRef<T>} ComponentPropsWithoutRef<T>
27115 */
27116 /**
27117 * @typedef {Promise.resolve(React).ReactNode} ReactNode
27118 * @typedef {import('unist').Position} Position
27119 * @typedef {import('hast').Element} Element
27120 * @typedef {import('hast').ElementContent} ElementContent
27121 * @typedef {import('hast').Root} Root
27122 * @typedef {import('hast').Text} Text
27123 * @typedef {import('hast').Comment} Comment
27124 * @typedef {import('hast').DocType} Doctype
27125 * @typedef {import('property-information').Info} Info
27126 * @typedef {import('property-information').Schema} Schema
27127 * @typedef {import('./complex-types.js').ReactMarkdownProps} ReactMarkdownProps
27128 *
27129 * @typedef Raw
27130 * @property {'raw'} type
27131 * @property {string} value
27132 *
27133 * @typedef Context
27134 * @property {Options} options
27135 * @property {Schema} schema
27136 * @property {number} listDepth
27137 *
27138 * @callback TransformLink
27139 * @param {string} href
27140 * @param {Array<ElementContent>} children
27141 * @param {string?} title
27142 * @returns {string}
27143 *
27144 * @callback TransformImage
27145 * @param {string} src
27146 * @param {string} alt
27147 * @param {string?} title
27148 * @returns {string}
27149 *
27150 * @typedef {Promise.resolve(React).HTMLAttributeAnchorTarget} TransformLinkTargetType
27151 *
27152 * @callback TransformLinkTarget
27153 * @param {string} href
27154 * @param {Array<ElementContent>} children
27155 * @param {string?} title
27156 * @returns {TransformLinkTargetType|undefined}
27157 *
27158 * @typedef {keyof JSX.IntrinsicElements} ReactMarkdownNames
27159 *
27160 * To do: is `data-sourcepos` typeable?
27161 *
27162 * @typedef {ComponentPropsWithoutRef<'code'> & ReactMarkdownProps & {inline?: boolean}} CodeProps
27163 * @typedef {ComponentPropsWithoutRef<'h1'> & ReactMarkdownProps & {level: number}} HeadingProps
27164 * @typedef {ComponentPropsWithoutRef<'li'> & ReactMarkdownProps & {checked: boolean|null, index: number, ordered: boolean}} LiProps
27165 * @typedef {ComponentPropsWithoutRef<'ol'> & ReactMarkdownProps & {depth: number, ordered: true}} OrderedListProps
27166 * @typedef {ComponentPropsWithoutRef<'td'> & ReactMarkdownProps & {style?: Record<string, unknown>, isHeader: false}} TableDataCellProps
27167 * @typedef {ComponentPropsWithoutRef<'th'> & ReactMarkdownProps & {style?: Record<string, unknown>, isHeader: true}} TableHeaderCellProps
27168 * @typedef {ComponentPropsWithoutRef<'tr'> & ReactMarkdownProps & {isHeader: boolean}} TableRowProps
27169 * @typedef {ComponentPropsWithoutRef<'ul'> & ReactMarkdownProps & {depth: number, ordered: false}} UnorderedListProps
27170 *
27171 * @typedef {ComponentType<CodeProps>} CodeComponent
27172 * @typedef {ComponentType<HeadingProps>} HeadingComponent
27173 * @typedef {ComponentType<LiProps>} LiComponent
27174 * @typedef {ComponentType<OrderedListProps>} OrderedListComponent
27175 * @typedef {ComponentType<TableDataCellProps>} TableDataCellComponent
27176 * @typedef {ComponentType<TableHeaderCellProps>} TableHeaderCellComponent
27177 * @typedef {ComponentType<TableRowProps>} TableRowComponent
27178 * @typedef {ComponentType<UnorderedListProps>} UnorderedListComponent
27179 *
27180 * @typedef SpecialComponents
27181 * @property {CodeComponent|ReactMarkdownNames} code
27182 * @property {HeadingComponent|ReactMarkdownNames} h1
27183 * @property {HeadingComponent|ReactMarkdownNames} h2
27184 * @property {HeadingComponent|ReactMarkdownNames} h3
27185 * @property {HeadingComponent|ReactMarkdownNames} h4
27186 * @property {HeadingComponent|ReactMarkdownNames} h5
27187 * @property {HeadingComponent|ReactMarkdownNames} h6
27188 * @property {LiComponent|ReactMarkdownNames} li
27189 * @property {OrderedListComponent|ReactMarkdownNames} ol
27190 * @property {TableDataCellComponent|ReactMarkdownNames} td
27191 * @property {TableHeaderCellComponent|ReactMarkdownNames} th
27192 * @property {TableRowComponent|ReactMarkdownNames} tr
27193 * @property {UnorderedListComponent|ReactMarkdownNames} ul
27194 *
27195 * @typedef {Partial<Omit<import('./complex-types.js').NormalComponents, keyof SpecialComponents> & SpecialComponents>} Components
27196 *
27197 * @typedef Options
27198 * @property {boolean} [sourcePos=false]
27199 * @property {boolean} [rawSourcePos=false]
27200 * @property {boolean} [skipHtml=false]
27201 * @property {boolean} [includeElementIndex=false]
27202 * @property {null|false|TransformLink} [transformLinkUri]
27203 * @property {TransformImage} [transformImageUri]
27204 * @property {TransformLinkTargetType|TransformLinkTarget} [linkTarget]
27205 * @property {Components} [components]
27206 */
27207 /**
27208 * @param {Context} context
27209 * @param {Element|Root} node
27210 */
27211 function childrenToReact(context, node) {
27212 /** @type {Array<ReactNode>} */
27213 const children = [];
27214 let childIndex = -1;
27215 /** @type {Comment|Doctype|Element|Raw|Text} */
27216 let child;
27217 while (++childIndex < node.children.length) {
27218 child = node.children[childIndex];
27219 if (child.type === "element") children.push(toReact(context, child, childIndex, node));
27220 else if (child.type === "text") {
27221 if (node.type !== "element" || !tableElements.has(node.tagName) || !whitespace(child)) children.push(child.value);
27222 } else if (child.type === "raw" && !context.options.skipHtml) children.push(child.value);
27223 }
27224 return children;
27225 }
27226 /**
27227 * @param {Context} context
27228 * @param {Element} node
27229 * @param {number} index
27230 * @param {Element|Root} parent
27231 */
27232 function toReact(context, node, index, parent) {
27233 const options = context.options;
27234 const transform = options.transformLinkUri === void 0 ? uriTransformer : options.transformLinkUri;
27235 const parentSchema = context.schema;
27236 /** @type {ReactMarkdownNames} */
27237 const name = node.tagName;
27238 /** @type {Record<string, unknown>} */
27239 const properties = {};
27240 let schema = parentSchema;
27241 /** @type {string} */
27242 let property;
27243 if (parentSchema.space === "html" && name === "svg") {
27244 schema = svg;
27245 context.schema = schema;
27246 }
27247 if (node.properties) {
27248 for (property in node.properties) if (own$1.call(node.properties, property)) addProperty(properties, property, node.properties[property], context);
27249 }
27250 if (name === "ol" || name === "ul") context.listDepth++;
27251 const children = childrenToReact(context, node);
27252 if (name === "ol" || name === "ul") context.listDepth--;
27253 context.schema = parentSchema;
27254 const position = node.position || {
27255 start: {
27256 line: null,
27257 column: null,
27258 offset: null
27259 },
27260 end: {
27261 line: null,
27262 column: null,
27263 offset: null
27264 }
27265 };
27266 const component = options.components && own$1.call(options.components, name) ? options.components[name] : name;
27267 const basic = typeof component === "string" || component === react$1.default.Fragment;
27268 if (!import_react_is.isValidElementType(component)) throw new TypeError(`Component for name \`${name}\` not defined or is not renderable`);
27269 properties.key = index;
27270 if (name === "a" && options.linkTarget) properties.target = typeof options.linkTarget === "function" ? options.linkTarget(String(properties.href || ""), node.children, typeof properties.title === "string" ? properties.title : null) : options.linkTarget;
27271 if (name === "a" && transform) properties.href = transform(String(properties.href || ""), node.children, typeof properties.title === "string" ? properties.title : null);
27272 if (!basic && name === "code" && parent.type === "element" && parent.tagName !== "pre") properties.inline = true;
27273 if (!basic && (name === "h1" || name === "h2" || name === "h3" || name === "h4" || name === "h5" || name === "h6")) properties.level = Number.parseInt(name.charAt(1), 10);
27274 if (name === "img" && options.transformImageUri) properties.src = options.transformImageUri(String(properties.src || ""), String(properties.alt || ""), typeof properties.title === "string" ? properties.title : null);
27275 if (!basic && name === "li" && parent.type === "element") {
27276 const input = getInputElement(node);
27277 properties.checked = input && input.properties ? Boolean(input.properties.checked) : null;
27278 properties.index = getElementsBeforeCount(parent, node);
27279 properties.ordered = parent.tagName === "ol";
27280 }
27281 if (!basic && (name === "ol" || name === "ul")) {
27282 properties.ordered = name === "ol";
27283 properties.depth = context.listDepth;
27284 }
27285 if (name === "td" || name === "th") {
27286 if (properties.align) {
27287 if (!properties.style) properties.style = {};
27288 properties.style.textAlign = properties.align;
27289 delete properties.align;
27290 }
27291 if (!basic) properties.isHeader = name === "th";
27292 }
27293 if (!basic && name === "tr" && parent.type === "element") properties.isHeader = Boolean(parent.tagName === "thead");
27294 if (options.sourcePos) properties["data-sourcepos"] = flattenPosition(position);
27295 if (!basic && options.rawSourcePos) properties.sourcePosition = node.position;
27296 if (!basic && options.includeElementIndex) {
27297 properties.index = getElementsBeforeCount(parent, node);
27298 properties.siblingCount = getElementsBeforeCount(parent);
27299 }
27300 if (!basic) properties.node = node;
27301 return children.length > 0 ? react$1.default.createElement(component, properties, children) : react$1.default.createElement(component, properties);
27302 }
27303 /**
27304 * @param {Element|Root} node
27305 * @returns {Element?}
27306 */
27307 function getInputElement(node) {
27308 let index = -1;
27309 while (++index < node.children.length) {
27310 const child = node.children[index];
27311 if (child.type === "element" && child.tagName === "input") return child;
27312 }
27313 return null;
27314 }
27315 /**
27316 * @param {Element|Root} parent
27317 * @param {Element} [node]
27318 * @returns {number}
27319 */
27320 function getElementsBeforeCount(parent, node) {
27321 let index = -1;
27322 let count = 0;
27323 while (++index < parent.children.length) {
27324 if (parent.children[index] === node) break;
27325 if (parent.children[index].type === "element") count++;
27326 }
27327 return count;
27328 }
27329 /**
27330 * @param {Record<string, unknown>} props
27331 * @param {string} prop
27332 * @param {unknown} value
27333 * @param {Context} ctx
27334 */
27335 function addProperty(props, prop, value, ctx) {
27336 const info = find(ctx.schema, prop);
27337 let result = value;
27338 if (result === null || result === void 0 || result !== result) return;
27339 if (Array.isArray(result)) result = info.commaSeparated ? stringify(result) : stringify$1(result);
27340 if (info.property === "style" && typeof result === "string") result = parseStyle(result);
27341 if (info.space && info.property) props[own$1.call(hastToReact, info.property) ? hastToReact[info.property] : info.property] = result;
27342 else if (info.attribute) props[info.attribute] = result;
27343 }
27344 /**
27345 * @param {string} value
27346 * @returns {Record<string, string>}
27347 */
27348 function parseStyle(value) {
27349 /** @type {Record<string, string>} */
27350 const result = {};
27351 try {
27352 style_to_object_default(value, iterator);
27353 } catch (_unused) {}
27354 return result;
27355 /**
27356 * @param {string} name
27357 * @param {string} v
27358 */
27359 function iterator(name, v) {
27360 const k = name.slice(0, 4) === "-ms-" ? `ms-${name.slice(4)}` : name;
27361 result[k.replace(/-([a-z])/g, styleReplacer)] = v;
27362 }
27363 }
27364 /**
27365 * @param {unknown} _
27366 * @param {string} $1
27367 */
27368 function styleReplacer(_, $1) {
27369 return $1.toUpperCase();
27370 }
27371 /**
27372 * @param {Position|{start: {line: null, column: null, offset: null}, end: {line: null, column: null, offset: null}}} pos
27373 * @returns {string}
27374 */
27375 function flattenPosition(pos) {
27376 return [
27377 pos.start.line,
27378 ":",
27379 pos.start.column,
27380 "-",
27381 pos.end.line,
27382 ":",
27383 pos.end.column
27384 ].map(String).join("");
27385 }
27386 var import_react_is, own$1, tableElements;
27387 var init_ast_to_react = __esmMin((() => {
27388 import_react_is = /* @__PURE__ */ __toESM(require_react_is(), 1);
27389 init_hast_util_whitespace();
27390 init_property_information();
27391 init_space_separated_tokens();
27392 init_comma_separated_tokens();
27393 init_style_to_object();
27394 init_uri_transformer();
27395 own$1 = {}.hasOwnProperty;
27396 tableElements = /* @__PURE__ */ new Set([
27397 "table",
27398 "thead",
27399 "tbody",
27400 "tfoot",
27401 "tr"
27402 ]);
27403 }));
27404
27405 //#endregion
27406 //#region node_modules/react-markdown/lib/react-markdown.js
27407 /**
27408 * @typedef {Promise.resolve(React).ReactNode} ReactNode
27409 * @typedef {Promise.resolve(React).ReactElement<{}>} ReactElement
27410 * @typedef {import('unified').PluggableList} PluggableList
27411 * @typedef {import('hast').Root} Root
27412 * @typedef {import('./rehype-filter.js').Options} FilterOptions
27413 * @typedef {import('./ast-to-react.js').Options} TransformOptions
27414 *
27415 * @typedef CoreOptions
27416 * @property {string} children
27417 *
27418 * @typedef PluginOptions
27419 * @property {PluggableList} [remarkPlugins=[]]
27420 * @property {PluggableList} [rehypePlugins=[]]
27421 * @property {import('remark-rehype').Options | undefined} [remarkRehypeOptions={}]
27422 *
27423 * @typedef LayoutOptions
27424 * @property {string} [className]
27425 *
27426 * @typedef {CoreOptions & PluginOptions & LayoutOptions & FilterOptions & TransformOptions} ReactMarkdownOptions
27427 *
27428 * @typedef Deprecation
27429 * @property {string} id
27430 * @property {string} [to]
27431 */
27432 /**
27433 * React component to render markdown.
27434 *
27435 * @param {ReactMarkdownOptions} options
27436 * @returns {ReactElement}
27437 */
27438 function ReactMarkdown$1(options) {
27439 for (const key in deprecated) if (own.call(deprecated, key) && own.call(options, key)) {
27440 const deprecation = deprecated[key];
27441 console.warn(`[react-markdown] Warning: please ${deprecation.to ? `use \`${deprecation.to}\` instead of` : "remove"} \`${key}\` (see <${changelog}#${deprecation.id}> for more info)`);
27442 delete deprecated[key];
27443 }
27444 const processor = unified().use(remarkParse).use(options.remarkPlugins || []).use(remarkRehype, _objectSpread2(_objectSpread2({}, options.remarkRehypeOptions), {}, { allowDangerousHtml: true })).use(options.rehypePlugins || []).use(rehypeFilter, options);
27445 const file = new VFile();
27446 if (typeof options.children === "string") file.value = options.children;
27447 else if (options.children !== void 0 && options.children !== null) console.warn(`[react-markdown] Warning: please pass a string as \`children\` (not: \`${options.children}\`)`);
27448 const hastNode = processor.runSync(processor.parse(file), file);
27449 if (hastNode.type !== "root") throw new TypeError("Expected a `root` node");
27450 /** @type {ReactElement} */
27451 let result = react$1.default.createElement(react$1.default.Fragment, {}, childrenToReact({
27452 options,
27453 schema: html,
27454 listDepth: 0
27455 }, hastNode));
27456 if (options.className) result = react$1.default.createElement("div", { className: options.className }, result);
27457 return result;
27458 }
27459 var import_prop_types$1, own, changelog, deprecated;
27460 var init_react_markdown$1 = __esmMin((() => {
27461 init_vfile();
27462 init_unified();
27463 init_remark_parse();
27464 init_remark_rehype();
27465 import_prop_types$1 = /* @__PURE__ */ __toESM(require_prop_types(), 1);
27466 init_property_information();
27467 init_rehype_filter();
27468 init_ast_to_react();
27469 init_objectSpread2();
27470 own = {}.hasOwnProperty;
27471 changelog = "https://github.com/remarkjs/react-markdown/blob/main/changelog.md";
27472 deprecated = {
27473 plugins: {
27474 to: "remarkPlugins",
27475 id: "change-plugins-to-remarkplugins"
27476 },
27477 renderers: {
27478 to: "components",
27479 id: "change-renderers-to-components"
27480 },
27481 astPlugins: { id: "remove-buggy-html-in-markdown-parser" },
27482 allowDangerousHtml: { id: "remove-buggy-html-in-markdown-parser" },
27483 escapeHtml: { id: "remove-buggy-html-in-markdown-parser" },
27484 source: {
27485 to: "children",
27486 id: "change-source-to-children"
27487 },
27488 allowNode: {
27489 to: "allowElement",
27490 id: "replace-allownode-allowedtypes-and-disallowedtypes"
27491 },
27492 allowedTypes: {
27493 to: "allowedElements",
27494 id: "replace-allownode-allowedtypes-and-disallowedtypes"
27495 },
27496 disallowedTypes: {
27497 to: "disallowedElements",
27498 id: "replace-allownode-allowedtypes-and-disallowedtypes"
27499 },
27500 includeNodeIndex: {
27501 to: "includeElementIndex",
27502 id: "change-includenodeindex-to-includeelementindex"
27503 }
27504 };
27505 __name(ReactMarkdown$1, "ReactMarkdown");
27506 ReactMarkdown$1.propTypes = {
27507 children: import_prop_types$1.default.string,
27508 className: import_prop_types$1.default.string,
27509 allowElement: import_prop_types$1.default.func,
27510 allowedElements: import_prop_types$1.default.arrayOf(import_prop_types$1.default.string),
27511 disallowedElements: import_prop_types$1.default.arrayOf(import_prop_types$1.default.string),
27512 unwrapDisallowed: import_prop_types$1.default.bool,
27513 remarkPlugins: import_prop_types$1.default.arrayOf(import_prop_types$1.default.oneOfType([
27514 import_prop_types$1.default.object,
27515 import_prop_types$1.default.func,
27516 import_prop_types$1.default.arrayOf(import_prop_types$1.default.oneOfType([
27517 import_prop_types$1.default.bool,
27518 import_prop_types$1.default.string,
27519 import_prop_types$1.default.object,
27520 import_prop_types$1.default.func,
27521 import_prop_types$1.default.arrayOf(import_prop_types$1.default.any)
27522 ]))
27523 ])),
27524 rehypePlugins: import_prop_types$1.default.arrayOf(import_prop_types$1.default.oneOfType([
27525 import_prop_types$1.default.object,
27526 import_prop_types$1.default.func,
27527 import_prop_types$1.default.arrayOf(import_prop_types$1.default.oneOfType([
27528 import_prop_types$1.default.bool,
27529 import_prop_types$1.default.string,
27530 import_prop_types$1.default.object,
27531 import_prop_types$1.default.func,
27532 import_prop_types$1.default.arrayOf(import_prop_types$1.default.any)
27533 ]))
27534 ])),
27535 sourcePos: import_prop_types$1.default.bool,
27536 rawSourcePos: import_prop_types$1.default.bool,
27537 skipHtml: import_prop_types$1.default.bool,
27538 includeElementIndex: import_prop_types$1.default.bool,
27539 transformLinkUri: import_prop_types$1.default.oneOfType([import_prop_types$1.default.func, import_prop_types$1.default.bool]),
27540 linkTarget: import_prop_types$1.default.oneOfType([import_prop_types$1.default.func, import_prop_types$1.default.string]),
27541 transformImageUri: import_prop_types$1.default.func,
27542 components: import_prop_types$1.default.object
27543 };
27544 }));
27545
27546 //#endregion
27547 //#region node_modules/react-markdown/index.js
27548 var react_markdown_exports = /* @__PURE__ */ __exportAll({
27549 default: () => ReactMarkdown$1,
27550 uriTransformer: () => uriTransformer
27551 });
27552 var init_react_markdown = __esmMin((() => {
27553 init_uri_transformer();
27554 init_react_markdown$1();
27555 }));
27556
27557 //#endregion
27558 //#region modules/ai/assets/js/editor/pages/form-code/index.js
27559 var form_code_exports = /* @__PURE__ */ __exportAll({ default: () => FormCode$1 });
27560 function ownKeys$6(e, r) {
27561 var t = Object.keys(e);
27562 if (Object.getOwnPropertySymbols) {
27563 var o = Object.getOwnPropertySymbols(e);
27564 r && (o = o.filter(function(r) {
27565 return Object.getOwnPropertyDescriptor(e, r).enumerable;
27566 })), t.push.apply(t, o);
27567 }
27568 return t;
27569 }
27570 function _objectSpread$6(e) {
27571 for (var r = 1; r < arguments.length; r++) {
27572 var t = null != arguments[r] ? arguments[r] : {};
27573 r % 2 ? ownKeys$6(Object(t), !0).forEach(function(r) {
27574 _defineProperty(e, r, t[r]);
27575 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function(r) {
27576 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
27577 });
27578 }
27579 return e;
27580 }
27581 var import_regenerator, import_prop_types, ReactMarkdown, generateUniqueId, CodeDisplayWrapper, FormCode$1;
27582 var init_form_code = __esmMin((() => {
27583 init_extends();
27584 init_asyncToGenerator();
27585 init_slicedToArray();
27586 init_defineProperty();
27587 import_regenerator = /* @__PURE__ */ __toESM(require_regenerator());
27588 import_prop_types = /* @__PURE__ */ __toESM(require_prop_types());
27589 init_actions_data();
27590 init_loader();
27591 init_prompt_search();
27592 init_prompt_suggestions();
27593 init_generate_button();
27594 init_prompt_error_message();
27595 init_code_block();
27596 init_use_code_prompt();
27597 init_prompt_history_action_context();
27598 init_prompt_library_link();
27599 init_requests_ids();
27600 init_voice_promotion_alert();
27601 init_splitTextResult();
27602 init_preload_helper();
27603 __name(ownKeys$6, "ownKeys");
27604 __name(_objectSpread$6, "_objectSpread");
27605 ReactMarkdown = (0, react.lazy)(function() {
27606 return __vitePreload(() => Promise.resolve().then(() => (init_react_markdown(), react_markdown_exports)), void 0);
27607 });
27608 generateUniqueId = function generateUniqueId() {
27609 return "custom-css-".concat(Math.random().toString(36).substr(2, 9));
27610 };
27611 CodeDisplayWrapper = (0, _elementor_ui.styled)(_elementor_ui.Box)(function() {
27612 return {
27613 "& p": {
27614 mb: "10px",
27615 fontSize: "13px",
27616 lineHeight: "1.5"
27617 },
27618 "& pre": { position: "relative" },
27619 "& textarea": {
27620 fontSize: "13px",
27621 lineHeight: "1.7"
27622 }
27623 };
27624 });
27625 FormCode$1 = function FormCode(_ref) {
27626 var onClose = _ref.onClose;
27627 var getControlValue = _ref.getControlValue;
27628 var setControlValue = _ref.setControlValue;
27629 var additionalOptions = _ref.additionalOptions;
27630 var credits = _ref.credits;
27631 var children = _ref.children;
27632 var _useCodePrompt = useCodePrompt(_objectSpread$6(_objectSpread$6({}, additionalOptions), {}, { credits }));
27633 var data = _useCodePrompt.data;
27634 var isLoading = _useCodePrompt.isLoading;
27635 var error = _useCodePrompt.error;
27636 var reset = _useCodePrompt.reset;
27637 var send = _useCodePrompt.send;
27638 var sendUsageData = _useCodePrompt.sendUsageData;
27639 var _splitText = splitText(data.result);
27640 var code = _splitText.code;
27641 var details = _splitText.details;
27642 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
27643 var prompt = _useState2[0];
27644 var setPrompt = _useState2[1];
27645 var setGenerate = useRequestIds().setGenerate;
27646 var styleTagId = (0, react.useRef)(generateUniqueId());
27647 useSubscribeOnPromptHistoryAction([{
27648 type: ACTION_TYPES.REUSE,
27649 handler: function handler(action) {
27650 reset();
27651 setPrompt(action.data);
27652 }
27653 }]);
27654 var lastRun = (0, react.useRef)(function() {});
27655 var autocompleteItems = codeHtmlAutocomplete;
27656 var promptLibraryLink = "";
27657 if ("css" === (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.codeLanguage)) {
27658 autocompleteItems = codeCssAutocomplete;
27659 promptLibraryLink = "https://go.elementor.com/ai-prompt-library-css/";
27660 } else if (additionalOptions !== null && additionalOptions !== void 0 && additionalOptions.htmlMarkup) promptLibraryLink = "https://go.elementor.com/ai-prompt-library-html/";
27661 else promptLibraryLink = "https://go.elementor.com/ai-prompt-library-custom-code/";
27662 var showSuggestions = !prompt;
27663 var handleSubmit = /*#__PURE__*/ function() {
27664 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator.default.mark(function _callee(event) {
27665 var response;
27666 return import_regenerator.default.wrap(function(_context) {
27667 while (1) switch (_context.prev = _context.next) {
27668 case 0:
27669 event.preventDefault();
27670 setGenerate();
27671 lastRun.current = function() {
27672 return send({ prompt });
27673 };
27674 _context.next = 1;
27675 return lastRun.current();
27676 case 1:
27677 response = _context.sent;
27678 if ("css" === (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.codeLanguage) && response.result) showCssPreview(splitText(response.result).code);
27679 case 2:
27680 case "end": return _context.stop();
27681 }
27682 }, _callee);
27683 }));
27684 return function handleSubmit(_x) {
27685 return _ref2.apply(this, arguments);
27686 };
27687 }();
27688 (0, react.useEffect)(function() {
27689 return function() {
27690 removeStyleTag();
27691 };
27692 }, []);
27693 var showCssPreview = function showCssPreview(cssCode) {
27694 insertStyleTag(parseCSS(cssCode));
27695 };
27696 var parseCSS = function parseCSS(cssCode) {
27697 var elementId = additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.elementId;
27698 var selector = "document" === elementId ? elementor.config.document.settings.cssWrapperSelector : ".elementor-element.elementor-element-".concat(elementId);
27699 return cssCode && cssCode.replace(/`/g, "").replace(/^css\s*/i, "").replace(/selector/g, selector);
27700 };
27701 var isElementorEditor = function isElementorEditor() {
27702 return window.elementorFrontend;
27703 };
27704 var insertStyleTag = function insertStyleTag(cssCode) {
27705 if (!isElementorEditor()) return;
27706 var style = document.createElement("style");
27707 style.id = styleTagId.current;
27708 style.appendChild(document.createTextNode(cssCode));
27709 elementorFrontend.elements.$body[0].appendChild(style);
27710 };
27711 var removeStyleTag = function removeStyleTag() {
27712 if (!isElementorEditor()) return;
27713 var styleTag = elementorFrontend.elements.$body[0].querySelector("#".concat(styleTagId.current));
27714 if (styleTag) styleTag.remove();
27715 };
27716 var applyPrompt = function applyPrompt(inputText) {
27717 sendUsageData();
27718 setControlValue(inputText);
27719 onClose();
27720 };
27721 if (isLoading) return /*#__PURE__*/ react.default.createElement(Loader, null);
27722 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, error && /*#__PURE__*/ react.default.createElement(PromptErrorMessage, {
27723 error,
27724 onRetry: lastRun.current,
27725 sx: { mb: 2.5 }
27726 }), children, !data.result && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
27727 component: "form",
27728 onSubmit: handleSubmit
27729 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: { pb: 1.5 } }, /*#__PURE__*/ react.default.createElement(PromptSearch, {
27730 placeholder: (0, _wordpress_i18n.__)("Describe the code you want to use...", "elementor"),
27731 name: "prompt",
27732 value: prompt,
27733 color: "secondary",
27734 onChange: function onChange(event) {
27735 return setPrompt(event.target.value);
27736 }
27737 })), showSuggestions && /*#__PURE__*/ react.default.createElement(PromptSuggestions, {
27738 suggestions: autocompleteItems,
27739 onSelect: setPrompt
27740 }, /*#__PURE__*/ react.default.createElement(PromptLibraryLink, { libraryLink: promptLibraryLink })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
27741 direction: "row",
27742 alignItems: "center",
27743 sx: {
27744 py: 1.5,
27745 mt: 4
27746 }
27747 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
27748 direction: "row",
27749 justifyContent: "flex-end",
27750 flexGrow: 1
27751 }, /*#__PURE__*/ react.default.createElement(GenerateButton$1, null, (0, _wordpress_i18n.__)("Generate code", "elementor"))))), data.result && /*#__PURE__*/ react.default.createElement(CodeDisplayWrapper, null, /*#__PURE__*/ react.default.createElement(react.Suspense, { fallback: /*#__PURE__*/ react.default.createElement(Loader, null) }, /*#__PURE__*/ react.default.createElement(ReactMarkdown, { components: { code: function code(props) {
27752 return /*#__PURE__*/ react.default.createElement(CodeBlock, _extends$1({}, props, {
27753 defaultValue: getControlValue(),
27754 onInsert: applyPrompt
27755 }));
27756 } } }, code)), details, /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, { introductionKey: "ai-context-code-promotion" }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
27757 direction: "row",
27758 alignItems: "center",
27759 sx: { mt: 4 }
27760 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
27761 direction: "row",
27762 gap: 1,
27763 justifyContent: "flex-end",
27764 flexGrow: 1
27765 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
27766 size: "small",
27767 color: "secondary",
27768 variant: "text",
27769 onClick: function onClick() {
27770 removeStyleTag();
27771 reset();
27772 }
27773 }, (0, _wordpress_i18n.__)("New prompt", "elementor"))))));
27774 };
27775 FormCode$1.propTypes = {
27776 onClose: import_prop_types.default.func.isRequired,
27777 getControlValue: import_prop_types.default.func.isRequired,
27778 setControlValue: import_prop_types.default.func.isRequired,
27779 additionalOptions: import_prop_types.default.shape({
27780 codeLanguage: import_prop_types.default.string,
27781 htmlMarkup: import_prop_types.default.string,
27782 elementId: import_prop_types.default.string,
27783 initialCredits: import_prop_types.default.number
27784 }),
27785 credits: import_prop_types.default.number,
27786 children: import_prop_types.default.node
27787 };
27788 }));
27789
27790 //#endregion
27791 //#region modules/ai/assets/js/editor/page-content.js
27792 init_extends();
27793 init_defineProperty();
27794 init_slicedToArray();
27795 init_history_types();
27796 init_prompt_history_action_context();
27797 init_prompt_history_context();
27798 init_loader();
27799 init_requests_ids();
27800 init_preload_helper();
27801 function ownKeys$5(e, r) {
27802 var t = Object.keys(e);
27803 if (Object.getOwnPropertySymbols) {
27804 var o = Object.getOwnPropertySymbols(e);
27805 r && (o = o.filter(function(r) {
27806 return Object.getOwnPropertyDescriptor(e, r).enumerable;
27807 })), t.push.apply(t, o);
27808 }
27809 return t;
27810 }
27811 __name(ownKeys$5, "ownKeys");
27812 function _objectSpread$5(e) {
27813 for (var r = 1; r < arguments.length; r++) {
27814 var t = null != arguments[r] ? arguments[r] : {};
27815 r % 2 ? ownKeys$5(Object(t), !0).forEach(function(r) {
27816 _defineProperty(e, r, t[r]);
27817 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function(r) {
27818 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
27819 });
27820 }
27821 return e;
27822 }
27823 __name(_objectSpread$5, "_objectSpread");
27824 var FormCode = (0, react.lazy)(function() {
27825 return __vitePreload(() => Promise.resolve().then(() => (init_form_code(), form_code_exports)), void 0);
27826 });
27827 var PageContent = function PageContent(_ref) {
27828 var type = _ref.type;
27829 var controlType = _ref.controlType;
27830 var onClose = _ref.onClose;
27831 var onConnect = _ref.onConnect;
27832 var getControlValue = _ref.getControlValue;
27833 var setControlValue = _ref.setControlValue;
27834 var additionalOptions = _ref.additionalOptions;
27835 var _ref2 = function(_additionalOptions$us) {
27836 return (_additionalOptions$us = additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.useCustomInit) !== null && _additionalOptions$us !== void 0 ? _additionalOptions$us : useUserInfo;
27837 }()();
27838 var isLoading = _ref2.isLoading;
27839 var isConnected = _ref2.isConnected;
27840 var isGetStarted = _ref2.isGetStarted;
27841 var connectUrl = _ref2.connectUrl;
27842 var fetchData = _ref2.fetchData;
27843 var hasSubscription = _ref2.hasSubscription;
27844 var credits = _ref2.credits;
27845 var initialUsagePercentage = _ref2.usagePercentage;
27846 var _useRequestIds = useRequestIds();
27847 var updateUsagePercentage = _useRequestIds.updateUsagePercentage;
27848 var usagePercentage = _useRequestIds.usagePercentage;
27849 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
27850 var isInitUsageDone = _useState2[0];
27851 var setIsInitUsageDone = _useState2[1];
27852 (0, react.useEffect)(function() {
27853 if (!isInitUsageDone && !isLoading && (initialUsagePercentage || 0 === initialUsagePercentage)) {
27854 updateUsagePercentage(initialUsagePercentage);
27855 setIsInitUsageDone(true);
27856 }
27857 }, [
27858 isLoading,
27859 initialUsagePercentage,
27860 isInitUsageDone,
27861 updateUsagePercentage
27862 ]);
27863 var showBadge = useUpgradeMessage({
27864 usagePercentage,
27865 hasSubscription
27866 }).showBadge;
27867 var _useState4 = _slicedToArray((0, react.useState)({ pointerEvents: "none" }), 2);
27868 var sxStyle = _useState4[0];
27869 var setSxStyle = _useState4[1];
27870 var timeoutRef = (0, react.useRef)(null);
27871 var _useState6 = _slicedToArray((0, react.useState)(), 2);
27872 var originalControlValue = _useState6[0];
27873 var setOriginalControlValue = _useState6[1];
27874 var promptDialogStyleProps = {
27875 sx: {
27876 zIndex: 17e4,
27877 "& .MuiDialog-container": {
27878 alignItems: "flex-start",
27879 mt: "media" === type ? "2.5vh" : "18vh"
27880 },
27881 "& .MuiDialogContent-root": {
27882 willChange: "height",
27883 transition: "height 300ms ease-in-out",
27884 position: "relative"
27885 },
27886 "& .MuiBox-root": { boxSizing: "border-box" }
27887 },
27888 PaperProps: { sx: {
27889 m: 0,
27890 maxHeight: "media" === type ? "95vh" : "76vh",
27891 minHeight: "80vh",
27892 height: "auto"
27893 } }
27894 };
27895 var codePromptDialogStyleProps = {
27896 sx: _objectSpread$5(_objectSpread$5({}, promptDialogStyleProps.sx), sxStyle),
27897 PaperProps: {
27898 onMouseEnter: function onMouseEnter() {
27899 clearTimeout(timeoutRef.current);
27900 setSxStyle({ pointerEvents: "all" });
27901 },
27902 onMouseLeave: function onMouseLeave() {
27903 clearTimeout(timeoutRef.current);
27904 timeoutRef.current = setTimeout(function() {
27905 setSxStyle({ pointerEvents: "none" });
27906 }, 200);
27907 },
27908 sx: _objectSpread$5(_objectSpread$5({}, promptDialogStyleProps.PaperProps.sx), {}, { pointerEvents: "auto" })
27909 }
27910 };
27911 var maybeRenderUpgradeChip = function maybeRenderUpgradeChip() {
27912 if (!showBadge) return;
27913 return /*#__PURE__*/ react.default.createElement(UpgradeChip, {
27914 hasSubscription,
27915 usagePercentage
27916 });
27917 };
27918 (0, react.useEffect)(function() {
27919 if (!originalControlValue) setOriginalControlValue(getControlValue());
27920 }, []);
27921 if (isLoading || !isInitUsageDone) return /*#__PURE__*/ react.default.createElement(PromptDialog, _extends$1({ onClose }, promptDialogStyleProps, { maxWidth: "media" === type ? "lg" : "sm" }), /*#__PURE__*/ react.default.createElement(PromptDialog.Header, { onClose }), /*#__PURE__*/ react.default.createElement(PromptDialog.Content, { dividers: true }, (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.loadingTitle) && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { style: {
27922 display: "flex",
27923 justifyContent: "center",
27924 alignItems: "center",
27925 width: "100%"
27926 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
27927 variant: "body1",
27928 color: "secondary"
27929 }, additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.loadingTitle)), /*#__PURE__*/ react.default.createElement(Loader, null)));
27930 if (!isConnected) return /*#__PURE__*/ react.default.createElement(WizardDialog, { onClose }, /*#__PURE__*/ react.default.createElement(WizardDialog.Header, { onClose }), /*#__PURE__*/ react.default.createElement(WizardDialog.Content, { dividers: true }, /*#__PURE__*/ react.default.createElement(Connect, {
27931 connectUrl,
27932 onSuccess: function onSuccess(data) {
27933 onConnect(data);
27934 fetchData();
27935 }
27936 })));
27937 if (!isGetStarted) return /*#__PURE__*/ react.default.createElement(WizardDialog, { onClose }, /*#__PURE__*/ react.default.createElement(WizardDialog.Header, { onClose }), /*#__PURE__*/ react.default.createElement(WizardDialog.Content, { dividers: true }, /*#__PURE__*/ react.default.createElement(GetStarted, { onSuccess: fetchData })));
27938 if ("media" === type) return /*#__PURE__*/ react.default.createElement(PromptHistoryProvider, { historyType: HISTORY_TYPES.IMAGE }, /*#__PURE__*/ react.default.createElement(PromptHistoryActionProvider, null, /*#__PURE__*/ react.default.createElement(FormMedia, {
27939 onClose,
27940 getControlValue,
27941 setControlValue,
27942 additionalOptions,
27943 credits,
27944 maybeRenderUpgradeChip,
27945 DialogProps: promptDialogStyleProps,
27946 hasSubscription,
27947 usagePercentage
27948 })));
27949 if ("code" === type) return /*#__PURE__*/ react.default.createElement(PromptDialog, _extends$1({ onClose }, codePromptDialogStyleProps), /*#__PURE__*/ react.default.createElement(PromptHistoryProvider, { historyType: HISTORY_TYPES.CODE }, /*#__PURE__*/ react.default.createElement(PromptHistoryActionProvider, null, /*#__PURE__*/ react.default.createElement(PromptDialog.Header, { onClose }, /*#__PURE__*/ react.default.createElement(PromptHistory, null), maybeRenderUpgradeChip()), /*#__PURE__*/ react.default.createElement(PromptDialog.Content, {
27950 className: "e-ai-dialog-content",
27951 dividers: true
27952 }, /*#__PURE__*/ react.default.createElement(react.Suspense, { fallback: /*#__PURE__*/ react.default.createElement(Loader, null) }, /*#__PURE__*/ react.default.createElement(FormCode, {
27953 onClose,
27954 getControlValue,
27955 setControlValue,
27956 additionalOptions,
27957 credits,
27958 usagePercentage
27959 }, /*#__PURE__*/ react.default.createElement(UsageMessages, {
27960 hasSubscription,
27961 usagePercentage,
27962 sx: { mb: 2 },
27963 feature: FREE_TRIAL_FEATURES_NAMES.CODE
27964 })))))));
27965 if ("animation" === type || "hover_animation" === type) {
27966 var onCloseAnimationDialog = function onCloseAnimationDialog() {
27967 setControlValue(originalControlValue);
27968 elementor.documents.getCurrent().history.setActive(true);
27969 onClose();
27970 };
27971 return /*#__PURE__*/ react.default.createElement(PromptDialog, _extends$1({ onClose: onCloseAnimationDialog }, codePromptDialogStyleProps), /*#__PURE__*/ react.default.createElement(PromptDialog.Header, {
27972 onClose: onCloseAnimationDialog,
27973 hideAiBetaLogo: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.hideAiBetaLogo
27974 }, maybeRenderUpgradeChip()), /*#__PURE__*/ react.default.createElement(PromptDialog.Content, {
27975 className: "e-ai-dialog-content",
27976 dividers: true
27977 }, /*#__PURE__*/ react.default.createElement(FormAnimation, {
27978 onClose,
27979 getControlValue,
27980 setControlValue,
27981 additionalOptions: _objectSpread$5(_objectSpread$5({}, additionalOptions), {}, { animationType: "hover_animation" === type ? "hover" : "other" }),
27982 credits,
27983 usagePercentage
27984 }, /*#__PURE__*/ react.default.createElement(UsageMessages, {
27985 hasSubscription,
27986 usagePercentage,
27987 sx: { mb: 2 },
27988 feature: FREE_TRIAL_FEATURES_NAMES.ANIMATION
27989 }))));
27990 }
27991 return /*#__PURE__*/ react.default.createElement(PromptDialog, _extends$1({ onClose }, promptDialogStyleProps), /*#__PURE__*/ react.default.createElement(PromptHistoryProvider, { historyType: HISTORY_TYPES.TEXT }, /*#__PURE__*/ react.default.createElement(PromptHistoryActionProvider, null, /*#__PURE__*/ react.default.createElement(PromptDialog.Header, {
27992 onClose,
27993 hideAiBetaLogo: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.hideAiBetaLogo
27994 }, !(additionalOptions !== null && additionalOptions !== void 0 && additionalOptions.withoutHistory) && /*#__PURE__*/ react.default.createElement(PromptHistory, null), maybeRenderUpgradeChip()), /*#__PURE__*/ react.default.createElement(PromptDialog.Content, {
27995 className: "e-ai-dialog-content",
27996 dividers: true
27997 }, /*#__PURE__*/ react.default.createElement(FormText, {
27998 type,
27999 controlType,
28000 onClose,
28001 getControlValue,
28002 setControlValue,
28003 additionalOptions,
28004 credits,
28005 usagePercentage
28006 }, /*#__PURE__*/ react.default.createElement(UsageMessages, {
28007 hasSubscription,
28008 usagePercentage,
28009 sx: { mb: 2 },
28010 feature: FREE_TRIAL_FEATURES_NAMES.TEXT
28011 }))))));
28012 };
28013 PageContent.propTypes = {
28014 type: import_prop_types$7.default.string,
28015 controlType: import_prop_types$7.default.string,
28016 onClose: import_prop_types$7.default.func.isRequired,
28017 onConnect: import_prop_types$7.default.func,
28018 getControlValue: import_prop_types$7.default.func.isRequired,
28019 setControlValue: import_prop_types$7.default.func.isRequired,
28020 additionalOptions: import_prop_types$7.default.object
28021 };
28022
28023 //#endregion
28024 //#region modules/ai/assets/js/editor/utils/preview-container.js
28025 /**
28026 * @typedef {import('elementor/assets/dev/js/editor/container/container')} Container
28027 */
28028 var PREFIX = "e-ai-preview-container";
28029 var CLASS_HIDDEN = PREFIX + "--hidden";
28030 var CLASS_IDLE = PREFIX + "--idle";
28031
28032 //#endregion
28033 //#region modules/ai/assets/js/editor/pages/form-layout/components/unsaved-changes-alert.js
28034 init_extends();
28035 init_objectWithoutProperties();
28036 var _excluded$4 = [
28037 "onClose",
28038 "onCancel",
28039 "title",
28040 "text"
28041 ];
28042 var UnsavedChangesAlert = function UnsavedChangesAlert(_ref) {
28043 var onClose = _ref.onClose;
28044 var onCancel = _ref.onCancel;
28045 var title = _ref.title;
28046 var text = _ref.text;
28047 var props = _objectWithoutProperties(_ref, _excluded$4);
28048 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, _extends$1({
28049 "aria-labelledby": "unsaved-changes-alert-title",
28050 "aria-describedby": "unsaved-changes-alert-description"
28051 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogTitle, { id: "unsaved-changes-alert-title" }, title), /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogContent, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogContentText, { id: "unsaved-changes-alert-description" }, text)), /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogActions, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
28052 onClick: onCancel,
28053 color: "secondary"
28054 }, (0, _wordpress_i18n.__)("Cancel", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
28055 onClick: onClose,
28056 color: "error",
28057 variant: "contained"
28058 }, (0, _wordpress_i18n.__)("Yes, leave", "elementor"))));
28059 };
28060 UnsavedChangesAlert.propTypes = {
28061 title: import_prop_types$7.default.string,
28062 text: import_prop_types$7.default.string,
28063 onCancel: import_prop_types$7.default.func,
28064 onClose: import_prop_types$7.default.func
28065 };
28066
28067 //#endregion
28068 //#region modules/ai/assets/js/editor/pages/form-layout/components/layout-dialog.js
28069 init_extends();
28070 init_defineProperty();
28071 init_slicedToArray();
28072 init_objectWithoutProperties();
28073 var _excluded$3 = ["sx", "PaperProps"];
28074 function ownKeys$4(e, r) {
28075 var t = Object.keys(e);
28076 if (Object.getOwnPropertySymbols) {
28077 var o = Object.getOwnPropertySymbols(e);
28078 r && (o = o.filter(function(r) {
28079 return Object.getOwnPropertyDescriptor(e, r).enumerable;
28080 })), t.push.apply(t, o);
28081 }
28082 return t;
28083 }
28084 __name(ownKeys$4, "ownKeys");
28085 function _objectSpread$4(e) {
28086 for (var r = 1; r < arguments.length; r++) {
28087 var t = null != arguments[r] ? arguments[r] : {};
28088 r % 2 ? ownKeys$4(Object(t), !0).forEach(function(r) {
28089 _defineProperty(e, r, t[r]);
28090 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function(r) {
28091 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
28092 });
28093 }
28094 return e;
28095 }
28096 __name(_objectSpread$4, "_objectSpread");
28097 var StyledDialog = (0, _elementor_ui.styled)(PromptDialog)(function() {
28098 return {
28099 "& .MuiDialog-container": {
28100 marginTop: 0,
28101 alignItems: "flex-end",
28102 paddingBottom: "16vh"
28103 },
28104 "& .MuiPaper-root": {
28105 margin: 0,
28106 maxHeight: "80vh"
28107 }
28108 };
28109 });
28110 var DialogHeader = function DialogHeader(_ref) {
28111 var onClose = _ref.onClose;
28112 var children = _ref.children;
28113 return /*#__PURE__*/ react.default.createElement(_elementor_ui.AppBar, {
28114 sx: { fontWeight: "normal" },
28115 color: "transparent",
28116 position: "relative"
28117 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Toolbar, { variant: "dense" }, /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { sx: { mr: 1 } }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
28118 component: "span",
28119 variant: "subtitle2",
28120 sx: {
28121 fontWeight: "bold",
28122 textTransform: "uppercase"
28123 }
28124 }, (0, _wordpress_i18n.__)("AI", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Chip, {
28125 label: (0, _wordpress_i18n.__)("Beta", "elementor"),
28126 color: "default",
28127 size: "small",
28128 sx: { ml: 1 }
28129 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
28130 direction: "row",
28131 spacing: 1,
28132 alignItems: "center",
28133 sx: { ml: "auto" }
28134 }, children, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
28135 size: "small",
28136 "aria-label": "close",
28137 onClick: onClose,
28138 sx: { "&.MuiButtonBase-root": { mr: -1 } }
28139 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.XIcon, null)))));
28140 };
28141 DialogHeader.propTypes = {
28142 children: import_prop_types$7.default.node,
28143 onClose: import_prop_types$7.default.func.isRequired
28144 };
28145 var StyledDialogContent = (0, _elementor_ui.styled)(PromptDialog.Content)(function() {
28146 return { "&.MuiDialogContent-root": { padding: 0 } };
28147 });
28148 var LayoutDialog = function LayoutDialog(_ref2) {
28149 var _ref2$sx = _ref2.sx;
28150 var sx = _ref2$sx === void 0 ? {} : _ref2$sx;
28151 var _ref2$PaperProps = _ref2.PaperProps;
28152 var PaperProps = _ref2$PaperProps === void 0 ? {} : _ref2$PaperProps;
28153 var props = _objectWithoutProperties(_ref2, _excluded$3);
28154 var _useState2 = _slicedToArray((0, react.useState)({ pointerEvents: "none" }), 2);
28155 var sxStyle = _useState2[0];
28156 var setSxStyle = _useState2[1];
28157 var timeoutRef = (0, react.useRef)(null);
28158 /**
28159 * The PromptDialog is using disableScrollLock in order to allow scrolling the page when the Dialog is opened.
28160 * When using the react-draggable library inside the editor, the background page scroll is not working smoothly.
28161 * Therefore, we need to delay the pointerEvents: none, which allowing to scroll the page content.
28162 */
28163 return /*#__PURE__*/ react.default.createElement(StyledDialog, _extends$1({
28164 maxWidth: "md",
28165 PaperProps: _objectSpread$4({
28166 sx: { pointerEvents: "auto" },
28167 onMouseEnter: function onMouseEnter() {
28168 clearTimeout(timeoutRef.current);
28169 setSxStyle({ pointerEvents: "all" });
28170 },
28171 onMouseLeave: function onMouseLeave() {
28172 clearTimeout(timeoutRef.current);
28173 timeoutRef.current = setTimeout(function() {
28174 setSxStyle({ pointerEvents: "none" });
28175 }, 200);
28176 }
28177 }, PaperProps)
28178 }, props, { sx: _objectSpread$4(_objectSpread$4({}, sxStyle), sx) }));
28179 };
28180 LayoutDialog.propTypes = {
28181 sx: import_prop_types$7.default.object,
28182 PaperProps: import_prop_types$7.default.object
28183 };
28184 LayoutDialog.Header = DialogHeader;
28185 LayoutDialog.Content = StyledDialogContent;
28186
28187 //#endregion
28188 //#region modules/ai/assets/js/editor/pages/form-layout/components/prompt-autocomplete.js
28189 init_slicedToArray();
28190 init_objectWithoutProperties();
28191 init_extends();
28192 init_defineProperty();
28193 init_prompt_library_link();
28194 var _excluded$2 = ["onSubmit"];
28195 function ownKeys$3(e, r) {
28196 var t = Object.keys(e);
28197 if (Object.getOwnPropertySymbols) {
28198 var o = Object.getOwnPropertySymbols(e);
28199 r && (o = o.filter(function(r) {
28200 return Object.getOwnPropertyDescriptor(e, r).enumerable;
28201 })), t.push.apply(t, o);
28202 }
28203 return t;
28204 }
28205 __name(ownKeys$3, "ownKeys");
28206 function _objectSpread$3(e) {
28207 for (var r = 1; r < arguments.length; r++) {
28208 var t = null != arguments[r] ? arguments[r] : {};
28209 r % 2 ? ownKeys$3(Object(t), !0).forEach(function(r) {
28210 _defineProperty(e, r, t[r]);
28211 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function(r) {
28212 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
28213 });
28214 }
28215 return e;
28216 }
28217 __name(_objectSpread$3, "_objectSpread");
28218 var TextInput = (0, react.forwardRef)(function(props, ref) {
28219 return /*#__PURE__*/ react.default.createElement(_elementor_ui.TextField, _extends$1({
28220 autoFocus: true,
28221 multiline: true,
28222 size: "small",
28223 maxRows: 3,
28224 color: "secondary",
28225 variant: "standard"
28226 }, props, {
28227 inputRef: ref,
28228 InputProps: _objectSpread$3(_objectSpread$3({}, props.InputProps), {}, {
28229 type: "search",
28230 sx: { pt: 0 }
28231 })
28232 }));
28233 });
28234 TextInput.propTypes = { InputProps: import_prop_types$7.default.object };
28235 var PaperComponent = function PaperComponent(props) {
28236 var libraryLink = "variation" === useConfig().mode ? "https://go.elementor.com/ai-prompt-library-variations/" : "https://go.elementor.com/ai-prompt-library-containers/";
28237 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Paper, _extends$1({}, props, {
28238 elevation: 8,
28239 sx: { borderRadius: 2 }
28240 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
28241 component: _elementor_ui.Box,
28242 color: function color(theme) {
28243 return theme.palette.text.tertiary;
28244 },
28245 variant: "caption",
28246 paddingX: 2,
28247 paddingY: 1
28248 }, (0, _wordpress_i18n.__)("Suggested Prompts", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Divider, null), props.children, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, { sx: { m: 2 } }, /*#__PURE__*/ react.default.createElement(PromptLibraryLink, { libraryLink })));
28249 };
28250 PaperComponent.propTypes = { children: import_prop_types$7.default.node };
28251 var PromptAutocomplete = function PromptAutocomplete(_ref) {
28252 var onSubmit = _ref.onSubmit;
28253 var props = _objectWithoutProperties(_ref, _excluded$2);
28254 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
28255 var showSuggestions = _useState2[0];
28256 var setShowSuggestions = _useState2[1];
28257 var theme = (0, _elementor_ui.useTheme)();
28258 var itemHeight = parseInt(theme.spacing(4));
28259 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Autocomplete, _extends$1({
28260 PaperComponent,
28261 ListboxProps: { sx: { maxHeight: 5 * itemHeight } },
28262 renderOption: function renderOption(optionProps, option) {
28263 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, _extends$1({}, optionProps, {
28264 title: option.text,
28265 noWrap: true,
28266 variant: "body2",
28267 component: _elementor_ui.Box,
28268 sx: { "&.MuiAutocomplete-option": {
28269 display: "block",
28270 minHeight: itemHeight
28271 } }
28272 }), option.text);
28273 },
28274 freeSolo: true,
28275 fullWidth: true,
28276 disableClearable: true,
28277 open: showSuggestions,
28278 onClose: function onClose(e) {
28279 var _e$relatedTarget;
28280 return setShowSuggestions("A" === ((_e$relatedTarget = e.relatedTarget) === null || _e$relatedTarget === void 0 ? void 0 : _e$relatedTarget.tagName));
28281 },
28282 onKeyDown: function onKeyDown(e) {
28283 if ("Enter" === e.key && !e.shiftKey && !showSuggestions) onSubmit(e);
28284 else if ("/" === e.key && "" === e.target.value) {
28285 e.preventDefault();
28286 setShowSuggestions(true);
28287 }
28288 }
28289 }, props));
28290 };
28291 PromptAutocomplete.propTypes = { onSubmit: import_prop_types$7.default.func.isRequired };
28292 PromptAutocomplete.TextInput = TextInput;
28293
28294 //#endregion
28295 //#region modules/ai/assets/js/editor/icons/arrow-left-icon.js
28296 init_extends();
28297 var ArrowLeftIcon = react.default.forwardRef(function(props, ref) {
28298 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
28299 fillRule: "evenodd",
28300 clipRule: "evenodd",
28301 d: "M9.53033 7.46967C9.82322 7.76256 9.82322 8.23744 9.53033 8.53033L6.81066 11.25H19C19.4142 11.25 19.75 11.5858 19.75 12C19.75 12.4142 19.4142 12.75 19 12.75H6.81066L9.53033 15.4697C9.82322 15.7626 9.82322 16.2374 9.53033 16.5303C9.23744 16.8232 8.76256 16.8232 8.46967 16.5303L4.46967 12.5303C4.17678 12.2374 4.17678 11.7626 4.46967 11.4697L8.46967 7.46967C8.76256 7.17678 9.23744 7.17678 9.53033 7.46967Z"
28302 }));
28303 });
28304
28305 //#endregion
28306 //#region modules/ai/assets/js/editor/icons/x-circle-icon.js
28307 init_extends();
28308 var XCircleIcon = react.default.forwardRef(function(props, ref) {
28309 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", { d: "M12 2.69231C6.8595 2.69231 2.69231 6.8595 2.69231 12C2.69231 17.1405 6.8595 21.3077 12 21.3077C17.1405 21.3077 21.3077 17.1405 21.3077 12C21.3077 6.8595 17.1405 2.69231 12 2.69231ZM1 12C1 5.92487 5.92487 1 12 1C18.0751 1 23 5.92487 23 12C23 18.0751 18.0751 23 12 23C5.92487 23 1 18.0751 1 12ZM9.14527 9.14527C9.47571 8.81483 10.0115 8.81483 10.3419 9.14527L12 10.8034L13.6581 9.14527C13.9885 8.81483 14.5243 8.81483 14.8547 9.14527C15.1852 9.47571 15.1852 10.0115 14.8547 10.3419L13.1966 12L14.8547 13.6581C15.1852 13.9885 15.1852 14.5243 14.8547 14.8547C14.5243 15.1852 13.9885 15.1852 13.6581 14.8547L12 13.1966L10.3419 14.8547C10.0115 15.1852 9.47571 15.1852 9.14527 14.8547C8.81483 14.5243 8.81483 13.9885 9.14527 13.6581L10.8034 12L9.14527 10.3419C8.81483 10.0115 8.81483 9.47571 9.14527 9.14527Z" }));
28310 });
28311
28312 //#endregion
28313 //#region modules/ai/assets/js/editor/icons/plus-circle-icon.js
28314 init_extends();
28315 var PlusCircleIcon = react.default.forwardRef(function(props, ref) {
28316 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", { d: "M12 2.69231C6.8595 2.69231 2.69231 6.8595 2.69231 12C2.69231 17.1405 6.8595 21.3077 12 21.3077C17.1405 21.3077 21.3077 17.1405 21.3077 12C21.3077 6.8595 17.1405 2.69231 12 2.69231ZM1 12C1 5.92487 5.92487 1 12 1C18.0751 1 23 5.92487 23 12C23 18.0751 18.0751 23 12 23C5.92487 23 1 18.0751 1 12ZM12 7.76923C12.4673 7.76923 12.8462 8.14807 12.8462 8.61538V11.1538H15.3846C15.8519 11.1538 16.2308 11.5327 16.2308 12C16.2308 12.4673 15.8519 12.8462 15.3846 12.8462H12.8462V15.3846C12.8462 15.8519 12.4673 16.2308 12 16.2308C11.5327 16.2308 11.1538 15.8519 11.1538 15.3846V12.8462H8.61538C8.14807 12.8462 7.76923 12.4673 7.76923 12C7.76923 11.5327 8.14807 11.1538 8.61538 11.1538H11.1538V8.61538C11.1538 8.14807 11.5327 7.76923 12 7.76923Z" }));
28317 });
28318
28319 //#endregion
28320 //#region modules/ai/assets/js/editor/components/alert-dialog.js
28321 init_slicedToArray();
28322 var AlertDialog = function AlertDialog(props) {
28323 var _useState2 = _slicedToArray((0, react.useState)(true), 2);
28324 var isShown = _useState2[0];
28325 var setIsShown = _useState2[1];
28326 if (!isShown) return null;
28327 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, {
28328 open: true,
28329 maxWidth: "lg"
28330 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogContent, { sx: { padding: 0 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { sx: {
28331 textAlign: "center",
28332 padding: 3
28333 } }, props.message), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
28334 alignItems: "center",
28335 spacing: 2,
28336 marginBottom: 2
28337 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
28338 variant: "contained",
28339 type: "button",
28340 color: "primary",
28341 onClick: function onClick() {
28342 var _props$onClose;
28343 setIsShown(false);
28344 (_props$onClose = props.onClose) === null || _props$onClose === void 0 || _props$onClose.call(props);
28345 }
28346 }, (0, _wordpress_i18n.__)("Close", "elementor")))));
28347 };
28348 AlertDialog.propTypes = {
28349 message: import_prop_types$7.default.string.isRequired,
28350 onClose: import_prop_types$7.default.func
28351 };
28352
28353 //#endregion
28354 //#region modules/ai/assets/js/editor/hooks/use-timeout.js
28355 init_slicedToArray();
28356 var useTimeout = function useTimeout(delay) {
28357 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
28358 var isTimeout = _useState2[0];
28359 var setIsTimeout = _useState2[1];
28360 var timeoutIdRef = (0, react.useRef)(null);
28361 var turnOffTimeout = function turnOffTimeout() {
28362 clearTimeout(timeoutIdRef.current);
28363 setIsTimeout(false);
28364 };
28365 (0, react.useEffect)(function() {
28366 timeoutIdRef.current = setTimeout(function() {
28367 setIsTimeout(true);
28368 }, delay);
28369 return function() {
28370 clearTimeout(timeoutIdRef.current);
28371 };
28372 }, [delay]);
28373 return [isTimeout, turnOffTimeout];
28374 };
28375
28376 //#endregion
28377 //#region modules/ai/assets/js/editor/pages/form-layout/context/remote-config.js
28378 init_asyncToGenerator();
28379 init_slicedToArray();
28380 init_api();
28381 var RemoteConfigContext = react.default.createContext({});
28382 var useRemoteConfig = function useRemoteConfig() {
28383 return react.default.useContext(RemoteConfigContext);
28384 };
28385 var CONFIG_KEYS = {
28386 WEB_BASED_BUILDER_URL: "webBasedBuilderUrl",
28387 AUTH_TOKEN: "jwt"
28388 };
28389 var RemoteConfigProvider = function RemoteConfigProvider(props) {
28390 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
28391 var isLoading = _useState2[0];
28392 var setIsLoading = _useState2[1];
28393 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
28394 var isLoaded = _useState4[0];
28395 var setIsLoaded = _useState4[1];
28396 var _useState6 = _slicedToArray((0, react.useState)(false), 2);
28397 var isError = _useState6[0];
28398 var setIsError = _useState6[1];
28399 var _useState8 = _slicedToArray((0, react.useState)({}), 2);
28400 var remoteConfig = _useState8[0];
28401 var setRemoteConfig = _useState8[1];
28402 var fetchData = /*#__PURE__*/ function() {
28403 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee() {
28404 var result;
28405 return import_regenerator$2.default.wrap(function(_context) {
28406 while (1) switch (_context.prev = _context.next) {
28407 case 0:
28408 setIsLoading(true);
28409 setIsError(false);
28410 _context.prev = 1;
28411 _context.next = 2;
28412 return getRemoteConfig().finally(function() {
28413 setIsLoaded(true);
28414 setIsLoading(false);
28415 });
28416 case 2:
28417 result = _context.sent;
28418 if (result.config) {
28419 _context.next = 3;
28420 break;
28421 }
28422 throw new Error("Invalid remote config");
28423 case 3:
28424 setRemoteConfig(result.config);
28425 _context.next = 5;
28426 break;
28427 case 4:
28428 _context.prev = 4;
28429 _context["catch"](1);
28430 setIsError(true);
28431 setIsLoaded(true);
28432 setIsLoading(false);
28433 case 5:
28434 case "end": return _context.stop();
28435 }
28436 }, _callee, null, [[1, 4]]);
28437 }));
28438 return function fetchData() {
28439 return _ref.apply(this, arguments);
28440 };
28441 }();
28442 (0, react.useEffect)(function() {
28443 window.addEventListener("elementor/connect/success", fetchData);
28444 return function() {
28445 window.removeEventListener("elementor/connect/success", fetchData);
28446 };
28447 }, []);
28448 if (!isLoaded && !isLoading) fetchData();
28449 return /*#__PURE__*/ react.default.createElement(RemoteConfigContext.Provider, { value: {
28450 isLoading,
28451 isLoaded,
28452 isError,
28453 remoteConfig
28454 } }, props.children);
28455 };
28456 RemoteConfigProvider.propTypes = {
28457 children: import_prop_types$7.default.node.isRequired,
28458 onError: import_prop_types$7.default.func.isRequired
28459 };
28460
28461 //#endregion
28462 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/url-dialog.js
28463 init_slicedToArray();
28464 init_requests_ids();
28465 var UrlDialog = function UrlDialog(props) {
28466 var _useTimeout2 = _slicedToArray(useTimeout(1e4), 2);
28467 var isTimeout = _useTimeout2[0];
28468 var turnOffTimeout = _useTimeout2[1];
28469 var _useUserInfo = useUserInfo();
28470 var isLoading = _useUserInfo.isLoading;
28471 var initialUsagePercentage = _useUserInfo.usagePercentage;
28472 var updateUsagePercentage = useRequestIds().updateUsagePercentage;
28473 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
28474 var isInitUsageDone = _useState2[0];
28475 var setIsInitUsageDone = _useState2[1];
28476 var builderUrl = useRemoteConfig().remoteConfig[CONFIG_KEYS.WEB_BASED_BUILDER_URL];
28477 var iframeOrigin = (builderUrl ? new URL(builderUrl) : {}).origin;
28478 var isOpen = (0, react.useRef)(false);
28479 (0, react.useEffect)(function() {
28480 if (!isInitUsageDone && !isLoading && (initialUsagePercentage || 0 === initialUsagePercentage)) {
28481 updateUsagePercentage(initialUsagePercentage);
28482 setIsInitUsageDone(true);
28483 }
28484 }, [
28485 isLoading,
28486 initialUsagePercentage,
28487 isInitUsageDone,
28488 updateUsagePercentage
28489 ]);
28490 (0, react.useEffect)(function() {
28491 if (!isOpen.current) try {
28492 window.$e.run("ai-integration/open-choose-element", { url: props.url });
28493 isOpen.current = true;
28494 } catch (error) {
28495 console.error(error);
28496 }
28497 }, [isOpen.current]);
28498 (0, react.useEffect)(function() {
28499 var onMessage = function onMessage(event) {
28500 if (event.origin !== iframeOrigin) return;
28501 var _event$data = event.data;
28502 var type = _event$data.type;
28503 var html = _event$data.html;
28504 var url = _event$data.url;
28505 switch (type) {
28506 case "element-selector/close":
28507 isOpen.current = false;
28508 props.onClose();
28509 break;
28510 case "element-selector/loaded":
28511 turnOffTimeout();
28512 isOpen.current = true;
28513 break;
28514 case "element-selector/attach":
28515 props.onAttach([{
28516 type: "url",
28517 previewHTML: html,
28518 content: html,
28519 label: url ? new URL(url).href : "",
28520 source: USER_URL_SOURCE
28521 }]);
28522 break;
28523 }
28524 };
28525 window.addEventListener("message", onMessage);
28526 return function() {
28527 window.removeEventListener("message", onMessage);
28528 };
28529 }, [
28530 iframeOrigin,
28531 props,
28532 turnOffTimeout
28533 ]);
28534 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, !isOpen.current && !isTimeout && /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, {
28535 open: true,
28536 maxWidth: "lg"
28537 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { sx: {
28538 textAlign: "center",
28539 padding: 3
28540 } }, (0, _wordpress_i18n.__)("Loading...", "elementor"))), isTimeout && /*#__PURE__*/ react.default.createElement(AlertDialog, {
28541 message: (0, _wordpress_i18n.__)("The app is not responding. Please try again later. (#408)", "elementor"),
28542 onClose: props.onClose
28543 }));
28544 };
28545 UrlDialog.propTypes = {
28546 onAttach: import_prop_types$7.default.func.isRequired,
28547 onClose: import_prop_types$7.default.func.isRequired,
28548 url: import_prop_types$7.default.string
28549 };
28550
28551 //#endregion
28552 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/library-dialog.js
28553 var LibraryDialog = function LibraryDialog(props) {
28554 var isApplyingTemplate = (0, react.useRef)(false);
28555 (0, react.useEffect)(function() {
28556 var onLibraryHide = function onLibraryHide() {
28557 if (isApplyingTemplate.current) return;
28558 props.onClose();
28559 };
28560 $e.components.get("library").layout.getModal().on("hide", onLibraryHide);
28561 return function() {
28562 $e.components.get("library").layout.getModal().off("hide", onLibraryHide);
28563 };
28564 }, [props]);
28565 (0, react.useEffect)(function() {
28566 var onMessage = function onMessage(event) {
28567 var _event$data = event.data;
28568 var type = _event$data.type;
28569 var json = _event$data.json;
28570 var html = _event$data.html;
28571 var label = _event$data.label;
28572 var source = _event$data.source;
28573 switch (type) {
28574 case "library/attach:start":
28575 isApplyingTemplate.current = true;
28576 break;
28577 case "library/attach":
28578 props.onAttach([{
28579 type: ATTACHMENT_TYPE_JSON,
28580 previewHTML: html,
28581 content: json,
28582 label,
28583 source
28584 }]);
28585 isApplyingTemplate.current = false;
28586 props.onClose();
28587 break;
28588 }
28589 };
28590 window.addEventListener("message", onMessage);
28591 return function() {
28592 window.removeEventListener("message", onMessage);
28593 };
28594 });
28595 $e.run("library/open", {
28596 toDefault: true,
28597 mode: "ai-attachment"
28598 });
28599 isApplyingTemplate.current = false;
28600 return null;
28601 };
28602 LibraryDialog.propTypes = {
28603 onAttach: import_prop_types$7.default.func.isRequired,
28604 onClose: import_prop_types$7.default.func.isRequired
28605 };
28606
28607 //#endregion
28608 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/attach-dialog.js
28609 var AttachDialog = function AttachDialog(props) {
28610 var type = props.type;
28611 var url = props.url;
28612 switch (type) {
28613 case "url": return /*#__PURE__*/ react.default.createElement(UrlDialog, {
28614 url,
28615 onAttach: props.onAttach,
28616 onClose: props.onClose
28617 });
28618 case MENU_TYPE_LIBRARY: return /*#__PURE__*/ react.default.createElement(LibraryDialog, {
28619 onAttach: props.onAttach,
28620 onClose: props.onClose
28621 });
28622 }
28623 return null;
28624 };
28625 AttachDialog.propTypes = {
28626 type: import_prop_types$7.default.string,
28627 onAttach: import_prop_types$7.default.func,
28628 onClose: import_prop_types$7.default.func,
28629 url: import_prop_types$7.default.string
28630 };
28631
28632 //#endregion
28633 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/menu.js
28634 init_slicedToArray();
28635 init_use_introduction();
28636 var Menu = function Menu(props) {
28637 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
28638 var isOpen = _useState2[0];
28639 var setIsOpen = _useState2[1];
28640 var _useState4 = _slicedToArray((0, react.useState)(null), 2);
28641 var selectedType = _useState4[0];
28642 var setSelectedType = _useState4[1];
28643 var direction = (0, _elementor_ui.useTheme)().direction;
28644 var anchorRef = (0, react.useRef)(null);
28645 var _useIntroduction = useIntroduction("e-ai-attachment-badge");
28646 var isViewed = _useIntroduction.isViewed;
28647 var markAsViewed = _useIntroduction.markAsViewed;
28648 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
28649 size: "small",
28650 ref: anchorRef,
28651 disabled: props.disabled,
28652 onClick: function onClick() {
28653 setIsOpen(true);
28654 if (!isViewed) markAsViewed();
28655 },
28656 color: "secondary"
28657 }, function() {
28658 if (isOpen) return /*#__PURE__*/ react.default.createElement(XCircleIcon, { fontSize: "small" });
28659 else if (isViewed) return /*#__PURE__*/ react.default.createElement(PlusCircleIcon, { fontSize: "small" });
28660 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Badge, {
28661 color: "primary",
28662 badgeContent: " ",
28663 variant: "dot"
28664 }, /*#__PURE__*/ react.default.createElement(PlusCircleIcon, { fontSize: "small" }));
28665 }()), /*#__PURE__*/ react.default.createElement(_elementor_ui.Popover, {
28666 open: isOpen,
28667 anchorEl: anchorRef.current,
28668 onClose: function onClose() {
28669 return setIsOpen(false);
28670 },
28671 anchorOrigin: {
28672 vertical: "bottom",
28673 horizontal: "rtl" === direction ? "right" : "left"
28674 },
28675 transformOrigin: {
28676 vertical: "top",
28677 horizontal: "rtl" === direction ? "right" : "left"
28678 }
28679 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, { sx: { width: 440 } }, props.items.map(function(item) {
28680 var IconComponent = item.icon;
28681 return /*#__PURE__*/ react.default.createElement(_elementor_ui.MenuItem, {
28682 key: item.type,
28683 onClick: function onClick() {
28684 setSelectedType(item.type);
28685 setIsOpen(false);
28686 }
28687 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemIcon, null, /*#__PURE__*/ react.default.createElement(IconComponent, null)), item.title);
28688 }))), /*#__PURE__*/ react.default.createElement(AttachDialog, {
28689 type: selectedType,
28690 onAttach: props.onAttach,
28691 onClose: function onClose() {
28692 setIsOpen(false);
28693 setSelectedType(null);
28694 }
28695 }));
28696 };
28697 Menu.propTypes = {
28698 items: import_prop_types$7.default.arrayOf(import_prop_types$7.default.shape({
28699 title: import_prop_types$7.default.string.isRequired,
28700 type: import_prop_types$7.default.string.isRequired,
28701 icon: import_prop_types$7.default.elementType
28702 })).isRequired,
28703 onAttach: import_prop_types$7.default.func.isRequired,
28704 disabled: import_prop_types$7.default.bool
28705 };
28706
28707 //#endregion
28708 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/thumbnail.js
28709 var _templateObject$1;
28710 var THUMBNAIL_SIZE = 64;
28711 var StyledBody = (0, _elementor_ui.styled)("body")(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n html, body {\n margin: 0;\n padding: 0;\n overflow: hidden;\n }\n\n body > * {\n width: 100% !important;\n }\n\n body > img {\n height: 100%;\n object-fit: cover;\n }\n\n body:has(> img) {\n height: ", "px\n }\n"])), 64);
28712 var Thumbnail = function Thumbnail(props) {
28713 var _props$html$match;
28714 var _props$html$match2;
28715 var dataWidth = (_props$html$match = props.html.match("data-width=\"(?<width>\\d+)\"")) === null || _props$html$match === void 0 || (_props$html$match = _props$html$match.groups) === null || _props$html$match === void 0 ? void 0 : _props$html$match.width;
28716 var dataHeight = (_props$html$match2 = props.html.match("data-height=\"(?<height>\\d+)\"")) === null || _props$html$match2 === void 0 || (_props$html$match2 = _props$html$match2.groups) === null || _props$html$match2 === void 0 ? void 0 : _props$html$match2.height;
28717 var width = dataWidth ? parseInt(dataWidth) : 64;
28718 var height = dataHeight ? parseInt(dataHeight) : 64;
28719 var scale = 64 / Math.min(height, width);
28720 var top = height > width ? (64 - 64 * (height / width)) / 2 : 0;
28721 var left = width > height ? (64 - 64 * (width / height)) / 2 : 0;
28722 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
28723 dir: "ltr",
28724 sx: {
28725 position: "relative",
28726 cursor: "default",
28727 overflow: "hidden",
28728 border: "1px solid",
28729 borderColor: "grey.300",
28730 borderRadius: 1,
28731 boxSizing: "border-box",
28732 width: 64,
28733 height: 64,
28734 opacity: props.disabled ? .5 : 1
28735 }
28736 }, /*#__PURE__*/ react.default.createElement("iframe", {
28737 title: (0, _wordpress_i18n.__)("Preview", "elementor"),
28738 sandbox: "",
28739 srcDoc: "<style>" + StyledBody.componentStyle.rules.join("") + "</style>" + props.html,
28740 style: {
28741 border: "none",
28742 overflow: "hidden",
28743 width,
28744 height,
28745 transform: "scale(".concat(scale, ")"),
28746 transformOrigin: "".concat(left, "px ").concat(top, "px")
28747 }
28748 }));
28749 };
28750 Thumbnail.propTypes = {
28751 html: import_prop_types$7.default.string.isRequired,
28752 disabled: import_prop_types$7.default.bool
28753 };
28754
28755 //#endregion
28756 //#region modules/ai/assets/js/editor/types/attachment.js
28757 var AttachmentPropType = import_prop_types$7.default.shape({
28758 type: import_prop_types$7.default.string,
28759 previewHTML: import_prop_types$7.default.string,
28760 content: import_prop_types$7.default.string,
28761 label: import_prop_types$7.default.string,
28762 source: import_prop_types$7.default.string
28763 });
28764 var AttachmentsTypesPropType = import_prop_types$7.default.shape({ type: import_prop_types$7.default.shape({
28765 promptPlaceholder: import_prop_types$7.default.string,
28766 promptSuggestions: import_prop_types$7.default.arrayOf(import_prop_types$7.default.shape({ text: import_prop_types$7.default.string.isRequired })),
28767 previewGenerator: import_prop_types$7.default.func
28768 }) });
28769
28770 //#endregion
28771 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/thumbnail-json.js
28772 var ThumbnailJson = function ThumbnailJson(props) {
28773 var _props$attachments;
28774 var attachment = (_props$attachments = props.attachments) === null || _props$attachments === void 0 ? void 0 : _props$attachments.find(function(item) {
28775 return "json" === item.type;
28776 });
28777 if (!attachment) return null;
28778 if (!attachment.previewHTML) return /*#__PURE__*/ react.default.createElement(_elementor_ui.Skeleton, {
28779 animation: "wave",
28780 variant: "rounded",
28781 width: 60,
28782 height: 60
28783 });
28784 return /*#__PURE__*/ react.default.createElement(Thumbnail, {
28785 html: attachment.previewHTML,
28786 disabled: props.disabled
28787 });
28788 };
28789 ThumbnailJson.propTypes = {
28790 attachments: import_prop_types$7.default.arrayOf(AttachmentPropType).isRequired,
28791 disabled: import_prop_types$7.default.bool
28792 };
28793
28794 //#endregion
28795 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/thumbnail-url.js
28796 var ThumbnailUrl = function ThumbnailUrl(props) {
28797 var _props$attachments;
28798 var attachment = (_props$attachments = props.attachments) === null || _props$attachments === void 0 ? void 0 : _props$attachments.find(function(item) {
28799 return "url" === item.type;
28800 });
28801 if (!attachment) return null;
28802 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
28803 position: "relative",
28804 "&:hover::before": {
28805 content: "\"\"",
28806 position: "absolute",
28807 userSelect: "none",
28808 inset: 0,
28809 backgroundColor: "rgba(0,0,0,0.6)",
28810 borderRadius: 1,
28811 zIndex: 1
28812 },
28813 "&:hover .remove-attachment": { display: "flex" }
28814 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
28815 className: "remove-attachment",
28816 size: "small",
28817 "aria-label": (0, _wordpress_i18n.__)("Remove", "elementor"),
28818 disabled: props.disabled,
28819 onClick: function onClick(event) {
28820 event.stopPropagation();
28821 props.onDetach();
28822 },
28823 sx: {
28824 display: "none",
28825 position: "absolute",
28826 insetInlineEnd: 4,
28827 insetBlockStart: 4,
28828 backgroundColor: "secondary.main",
28829 zIndex: 1,
28830 borderRadius: 1,
28831 p: "3px",
28832 "&:hover": { backgroundColor: "secondary.dark" }
28833 }
28834 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.TrashIcon, { sx: {
28835 fontSize: "1.125rem",
28836 color: "common.white"
28837 } })), /*#__PURE__*/ react.default.createElement(Thumbnail, {
28838 disabled: props.disabled,
28839 html: attachment.previewHTML
28840 }));
28841 };
28842 ThumbnailUrl.propTypes = {
28843 attachments: import_prop_types$7.default.arrayOf(AttachmentPropType).isRequired,
28844 disabled: import_prop_types$7.default.bool,
28845 onDetach: import_prop_types$7.default.func
28846 };
28847
28848 //#endregion
28849 //#region modules/ai/assets/js/editor/icons/website-icon.js
28850 init_extends();
28851 var WebsiteIcon = react.default.forwardRef(function(props, ref) {
28852 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
28853 fillRule: "evenodd",
28854 clipRule: "evenodd",
28855 d: "M4.16707 3.95837C4.11182 3.95837 4.05883 3.98032 4.01976 4.01939C3.98069 4.05846 3.95874 4.11145 3.95874 4.16671V6.04171H6.04207V3.95837H4.16707ZM4.16707 2.70837C3.7803 2.70837 3.40937 2.86202 3.13588 3.13551C2.86239 3.409 2.70874 3.77993 2.70874 4.16671V15.8334C2.70874 16.2201 2.86239 16.5911 3.13588 16.8646C3.40937 17.1381 3.7803 17.2917 4.16707 17.2917H15.8337C16.2205 17.2917 16.5914 17.1381 16.8649 16.8646C17.1384 16.5911 17.2921 16.2201 17.2921 15.8334V4.16671C17.2921 3.77993 17.1384 3.409 16.8649 3.13551C16.5914 2.86202 16.2205 2.70837 15.8337 2.70837H4.16707ZM7.29207 3.95837V6.04171H16.0421V4.16671C16.0421 4.11145 16.0201 4.05846 15.9811 4.01939C15.942 3.98032 15.889 3.95837 15.8337 3.95837H7.29207ZM16.0421 7.29171H3.95874V15.8334C3.95874 15.8886 3.98069 15.9416 4.01976 15.9807C4.05883 16.0198 4.11182 16.0417 4.16707 16.0417H15.8337C15.889 16.0417 15.942 16.0198 15.9811 15.9807C16.0201 15.9416 16.0421 15.8886 16.0421 15.8334V7.29171Z"
28856 }));
28857 });
28858
28859 //#endregion
28860 //#region modules/ai/assets/js/editor/icons/copy-page-icon.js
28861 init_extends();
28862 var CopyPageIcon = react.default.forwardRef(function(props, ref) {
28863 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
28864 fillRule: "evenodd",
28865 clipRule: "evenodd",
28866 d: "M16.6667 0.208496C17.0534 0.208496 17.4244 0.362142 17.6979 0.635632C17.9714 0.909123 18.125 1.28006 18.125 1.66683V11.6668C18.125 12.0536 17.9714 12.4245 17.6979 12.698C17.4244 12.9715 17.0534 13.1252 16.6667 13.1252H14.7917V16.6668C14.7917 17.0536 14.638 17.4245 14.3645 17.698C14.091 17.9715 13.7201 18.1252 13.3333 18.1252H3.33333C2.94656 18.1252 2.57563 17.9715 2.30214 17.698C2.02865 17.4245 1.875 17.0536 1.875 16.6668V6.66683C1.875 6.28005 2.02865 5.90912 2.30214 5.63563C2.57563 5.36214 2.94656 5.2085 3.33333 5.2085H5.20833V1.66683C5.20833 1.28005 5.36198 0.909122 5.63547 0.635632C5.90896 0.362142 6.27989 0.208496 6.66667 0.208496H16.6667ZM6.66667 1.4585C6.61141 1.4585 6.55842 1.48045 6.51935 1.51952C6.48028 1.55859 6.45833 1.61158 6.45833 1.66683V3.54183H8.54167V1.4585H6.66667ZM3.125 9.79183V16.6668C3.125 16.7221 3.14695 16.7751 3.18602 16.8141C3.22509 16.8532 3.27808 16.8752 3.33333 16.8752H13.3333C13.3886 16.8752 13.4416 16.8532 13.4806 16.8141C13.5197 16.7751 13.5417 16.7221 13.5417 16.6668V13.1252H6.66667C6.27989 13.1252 5.90896 12.9715 5.63547 12.698C5.36198 12.4245 5.20833 12.0536 5.20833 11.6668V9.79183H3.125ZM5.20833 8.54183H3.125V6.66683C3.125 6.61158 3.14695 6.55859 3.18602 6.51952C3.22509 6.48045 3.27808 6.4585 3.33333 6.4585H5.20833V8.54183ZM6.45833 11.6668C6.45833 11.7221 6.48028 11.7751 6.51935 11.8141C6.55842 11.8532 6.61141 11.8752 6.66667 11.8752H16.6667C16.7219 11.8752 16.7749 11.8532 16.814 11.8141C16.853 11.7751 16.875 11.7221 16.875 11.6668V4.79183H6.45833V11.6668ZM9.79167 1.4585V3.54183H16.875V1.66683C16.875 1.61157 16.853 1.55858 16.814 1.51952C16.7749 1.48045 16.7219 1.4585 16.6667 1.4585H9.79167Z"
28867 }));
28868 });
28869
28870 //#endregion
28871 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments.js
28872 init_extends();
28873 var ATTACHMENT_TYPE_JSON = "json";
28874 var ATTACHMENT_TYPE_URL = "url";
28875 var MENU_TYPE_LIBRARY = "library";
28876 var USER_URL_SOURCE = "user-url";
28877 var Attachments = function Attachments(props) {
28878 if (!props.attachments.length) return /*#__PURE__*/ react.default.createElement(Menu, {
28879 disabled: props.disabled,
28880 onAttach: props.onAttach,
28881 items: [{
28882 title: (0, _wordpress_i18n.__)("Reference a website", "elementor"),
28883 icon: WebsiteIcon,
28884 type: "url"
28885 }, {
28886 title: (0, _wordpress_i18n.__)("Create variations from Template Library", "elementor"),
28887 icon: CopyPageIcon,
28888 type: MENU_TYPE_LIBRARY
28889 }]
28890 });
28891 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
28892 direction: "row",
28893 spacing: 1
28894 }, props.attachments.map(function(attachment, index) {
28895 switch (attachment.type) {
28896 case ATTACHMENT_TYPE_JSON: return /*#__PURE__*/ react.default.createElement(ThumbnailJson, _extends$1({ key: index }, props));
28897 case "url": return /*#__PURE__*/ react.default.createElement(ThumbnailUrl, _extends$1({ key: index }, props));
28898 default: return null;
28899 }
28900 }));
28901 };
28902 Attachments.propTypes = {
28903 attachments: import_prop_types$7.default.arrayOf(AttachmentPropType).isRequired,
28904 onAttach: import_prop_types$7.default.func.isRequired,
28905 onDetach: import_prop_types$7.default.func,
28906 disabled: import_prop_types$7.default.bool
28907 };
28908
28909 //#endregion
28910 //#region modules/ai/assets/js/editor/pages/form-layout/components/prompt-form.js
28911 init_slicedToArray();
28912 init_extends();
28913 init_objectWithoutProperties();
28914 var _excluded$1 = ["tooltip"];
28915 var PROMPT_SUGGESTIONS = Object.freeze([
28916 { text: (0, _wordpress_i18n.__)("Hero section on [topic] with heading, text, buttons on the right, and an image on the left", "elementor.com") },
28917 { text: (0, _wordpress_i18n.__)("About Us section on [topic] with heading, text, and big image below", "elementor.com") },
28918 { text: (0, _wordpress_i18n.__)("Team section with four image boxes showcasing team members", "elementor.com") },
28919 { text: (0, _wordpress_i18n.__)("FAQ section with a toggle widget showcasing FAQs about [topic]", "elementor.com") },
28920 { text: (0, _wordpress_i18n.__)("Gallery section with a carousel displaying three images at once", "elementor.com") },
28921 { text: (0, _wordpress_i18n.__)("Contact section with a form for [topic]", "elementor.com") },
28922 { text: (0, _wordpress_i18n.__)("Client section featuring companies' logos", "elementor.com") },
28923 { text: (0, _wordpress_i18n.__)("Testimonial section with testimonials, each featuring a star rating and an image", "elementor.com") },
28924 { text: (0, _wordpress_i18n.__)("Service section about [topic], showcasing four services with buttons", "elementor.com") },
28925 { text: (0, _wordpress_i18n.__)("Stats section with counters displaying data about [topic]", "elementor.com") },
28926 { text: (0, _wordpress_i18n.__)("Quote section with colored background, featuring a centered quote", "elementor.com") },
28927 { text: (0, _wordpress_i18n.__)("Pricing section for [topic] with a pricing list", "elementor.com") },
28928 { text: (0, _wordpress_i18n.__)("Subscribe section featuring a simple email form, inviting users to stay informed on [topic]", "elementor.com") }
28929 ]);
28930 var IconButtonWithTooltip = function IconButtonWithTooltip(_ref) {
28931 var tooltip = _ref.tooltip;
28932 var props = _objectWithoutProperties(_ref, _excluded$1);
28933 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: tooltip }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
28934 component: "span",
28935 sx: { cursor: props.disabled ? "default" : "pointer" }
28936 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, props)));
28937 };
28938 IconButtonWithTooltip.propTypes = {
28939 tooltip: import_prop_types$7.default.string,
28940 disabled: import_prop_types$7.default.bool
28941 };
28942 var BackButton = function BackButton(props) {
28943 return /*#__PURE__*/ react.default.createElement(IconButtonWithTooltip, _extends$1({
28944 size: "small",
28945 color: "secondary",
28946 tooltip: (0, _wordpress_i18n.__)("Back to results", "elementor")
28947 }, props), /*#__PURE__*/ react.default.createElement(ArrowLeftIcon, null));
28948 };
28949 var EditButton = function EditButton(props) {
28950 return /*#__PURE__*/ react.default.createElement(IconButtonWithTooltip, _extends$1({
28951 size: "small",
28952 color: "primary",
28953 tooltip: (0, _wordpress_i18n.__)("Edit prompt", "elementor")
28954 }, props), /*#__PURE__*/ react.default.createElement(EditIcon$1, null));
28955 };
28956 var GenerateButton = function GenerateButton(props) {
28957 return /*#__PURE__*/ react.default.createElement(GenerateSubmit, _extends$1({
28958 size: "small",
28959 fullWidth: false
28960 }, props), (0, _wordpress_i18n.__)("Generate", "elementor"));
28961 };
28962 var PromptForm = (0, react.forwardRef)(function(_ref2, ref) {
28963 var _attachments$;
28964 var attachments = _ref2.attachments;
28965 var isActive = _ref2.isActive;
28966 var isLoading = _ref2.isLoading;
28967 var _ref2$showActions = _ref2.showActions;
28968 var showActions = _ref2$showActions === void 0 ? false : _ref2$showActions;
28969 var onAttach = _ref2.onAttach;
28970 var onDetach = _ref2.onDetach;
28971 var _onSubmit = _ref2.onSubmit;
28972 var onBack = _ref2.onBack;
28973 var onEdit = _ref2.onEdit;
28974 var _ref2$shouldResetProm = _ref2.shouldResetPrompt;
28975 var shouldResetPrompt = _ref2$shouldResetProm === void 0 ? false : _ref2$shouldResetProm;
28976 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
28977 var prompt = _useState2[0];
28978 var setPrompt = _useState2[1];
28979 (0, react.useEffect)(function() {
28980 if (shouldResetPrompt) setPrompt("");
28981 }, [shouldResetPrompt]);
28982 var _usePromptEnhancer = usePromptEnhancer(prompt, "layout");
28983 var isEnhancing = _usePromptEnhancer.isEnhancing;
28984 var enhance = _usePromptEnhancer.enhance;
28985 var previousPrompt = (0, react.useRef)("");
28986 var attachmentsTypes = useConfig().attachmentsTypes;
28987 var isInputDisabled = isLoading || isEnhancing || !isActive;
28988 var isInputEmpty = "" === prompt && !attachments.length;
28989 var isGenerateDisabled = isInputDisabled || isInputEmpty;
28990 var attachmentsConfig = attachmentsTypes[((_attachments$ = attachments[0]) === null || _attachments$ === void 0 ? void 0 : _attachments$.type) || ""];
28991 var promptSuggestions = (attachmentsConfig === null || attachmentsConfig === void 0 ? void 0 : attachmentsConfig.promptSuggestions) || PROMPT_SUGGESTIONS;
28992 var promptPlaceholder = (attachmentsConfig === null || attachmentsConfig === void 0 ? void 0 : attachmentsConfig.promptPlaceholder) || (0, _wordpress_i18n.__)("Press '/' for suggested prompts or describe the layout you want to create", "elementor");
28993 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
28994 component: "form",
28995 onSubmit: function onSubmit(e) {
28996 return _onSubmit(e, prompt);
28997 },
28998 direction: "row",
28999 sx: { p: 3 },
29000 alignItems: "start",
29001 gap: 1
29002 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
29003 direction: "row",
29004 alignItems: "start",
29005 flexGrow: 1,
29006 spacing: 2
29007 }, showActions && (isActive ? /*#__PURE__*/ react.default.createElement(BackButton, {
29008 disabled: isLoading || isEnhancing,
29009 onClick: function handleBack() {
29010 setPrompt(previousPrompt.current);
29011 onBack();
29012 }
29013 }) : /*#__PURE__*/ react.default.createElement(EditButton, {
29014 disabled: isLoading,
29015 onClick: function handleEdit() {
29016 previousPrompt.current = prompt;
29017 onEdit();
29018 }
29019 })), /*#__PURE__*/ react.default.createElement(Attachments, {
29020 attachments,
29021 onAttach,
29022 onDetach,
29023 disabled: isInputDisabled
29024 }), /*#__PURE__*/ react.default.createElement(PromptAutocomplete, {
29025 value: prompt,
29026 disabled: isInputDisabled,
29027 onSubmit: function onSubmit(e) {
29028 return _onSubmit(e, prompt);
29029 },
29030 options: promptSuggestions,
29031 onChange: function onChange(_, selectedValue) {
29032 return setPrompt(selectedValue.text + " ");
29033 },
29034 renderInput: function renderInput(params) {
29035 return /*#__PURE__*/ react.default.createElement(PromptAutocomplete.TextInput, _extends$1({}, params, {
29036 ref,
29037 onChange: function onChange(e) {
29038 return setPrompt(e.target.value);
29039 },
29040 placeholder: promptPlaceholder
29041 }));
29042 }
29043 })), /*#__PURE__*/ react.default.createElement(EnhanceButton, {
29044 size: "small",
29045 disabled: isGenerateDisabled || "" === prompt,
29046 isLoading: isEnhancing,
29047 onClick: function onClick() {
29048 return enhance().then(function(_ref3) {
29049 var result = _ref3.result;
29050 return setPrompt(result);
29051 });
29052 }
29053 }), /*#__PURE__*/ react.default.createElement(GenerateButton, { disabled: isGenerateDisabled }));
29054 });
29055 PromptForm.propTypes = {
29056 isActive: import_prop_types$7.default.bool,
29057 onAttach: import_prop_types$7.default.func,
29058 onDetach: import_prop_types$7.default.func,
29059 isLoading: import_prop_types$7.default.bool,
29060 showActions: import_prop_types$7.default.bool,
29061 onSubmit: import_prop_types$7.default.func.isRequired,
29062 onBack: import_prop_types$7.default.func.isRequired,
29063 onEdit: import_prop_types$7.default.func.isRequired,
29064 attachments: import_prop_types$7.default.arrayOf(AttachmentPropType),
29065 shouldResetPrompt: import_prop_types$7.default.bool
29066 };
29067
29068 //#endregion
29069 //#region modules/ai/assets/js/editor/pages/form-layout/components/screenshot-container.js
29070 var ScreenshotContainer = (0, _elementor_ui.styled)(_elementor_ui.Box, { shouldForwardProp: function shouldForwardProp(prop) {
29071 return prop !== "outlineOffset";
29072 } })(function(_ref) {
29073 var theme = _ref.theme;
29074 var selected = _ref.selected;
29075 var height = _ref.height;
29076 var disabled = _ref.disabled;
29077 var _ref$outlineOffset = _ref.outlineOffset;
29078 var outlineOffset = _ref$outlineOffset === void 0 ? "0px" : _ref$outlineOffset;
29079 var outlineColor = selected ? theme.palette.text.primary : theme.palette.text.disabled;
29080 var outline = "2px solid ".concat(outlineColor);
29081 return {
29082 height,
29083 cursor: disabled ? "default" : "pointer",
29084 overflow: "hidden",
29085 boxSizing: "border-box",
29086 backgroundPosition: "top center",
29087 backgroundSize: "100% auto",
29088 backgroundRepeat: "no-repeat",
29089 backgroundColor: theme.palette.common.white,
29090 borderRadius: theme.shape.borderRadius * .5,
29091 outlineOffset,
29092 outline,
29093 opacity: disabled ? "0.4" : "1",
29094 transition: "all 50ms linear",
29095 "&:hover": disabled ? {} : { outlineColor: theme.palette.text.primary }
29096 };
29097 });
29098
29099 //#endregion
29100 //#region modules/ai/assets/js/editor/pages/form-layout/components/screenshot-unavailable.js
29101 init_extends();
29102 init_defineProperty();
29103 function ownKeys$2(e, r) {
29104 var t = Object.keys(e);
29105 if (Object.getOwnPropertySymbols) {
29106 var o = Object.getOwnPropertySymbols(e);
29107 r && (o = o.filter(function(r) {
29108 return Object.getOwnPropertyDescriptor(e, r).enumerable;
29109 })), t.push.apply(t, o);
29110 }
29111 return t;
29112 }
29113 __name(ownKeys$2, "ownKeys");
29114 function _objectSpread$2(e) {
29115 for (var r = 1; r < arguments.length; r++) {
29116 var t = null != arguments[r] ? arguments[r] : {};
29117 r % 2 ? ownKeys$2(Object(t), !0).forEach(function(r) {
29118 _defineProperty(e, r, t[r]);
29119 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function(r) {
29120 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
29121 });
29122 }
29123 return e;
29124 }
29125 __name(_objectSpread$2, "_objectSpread");
29126 function ScreenshotUnavailable(props) {
29127 return /*#__PURE__*/ react.default.createElement(ScreenshotContainer, _extends$1({}, props, { sx: _objectSpread$2(_objectSpread$2({}, props.sx || {}), {}, {
29128 display: "flex",
29129 alignItems: "center",
29130 justifyContent: "center",
29131 backgroundColor: "background.paper",
29132 color: "text.tertiary",
29133 fontStyle: "italic",
29134 fontSize: "12px",
29135 paddingInline: 12,
29136 textAlign: "center",
29137 lineHeight: 1.5
29138 }) }), (0, _wordpress_i18n.__)("Preview unavailable", "elementor"));
29139 }
29140 ScreenshotUnavailable.propTypes = { sx: import_prop_types$7.default.object };
29141
29142 //#endregion
29143 //#region modules/ai/assets/js/editor/icons/lock-icon.js
29144 init_extends();
29145 var LockIcon = react.default.forwardRef(function(props, ref) {
29146 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
29147 fillRule: "evenodd",
29148 clipRule: "evenodd",
29149 d: "M7.8125 11.9996C7.29473 11.9996 6.875 12.4473 6.875 12.9996V18.9996C6.875 19.5519 7.29473 19.9996 7.8125 19.9996H17.1875C17.7053 19.9996 18.125 19.5519 18.125 18.9996V12.9996C18.125 12.4473 17.7053 11.9996 17.1875 11.9996H7.8125ZM5 12.9996C5 11.3428 6.2592 9.99963 7.8125 9.99963H17.1875C18.7408 9.99963 20 11.3428 20 12.9996V18.9996C20 20.6565 18.7408 21.9996 17.1875 21.9996H7.8125C6.2592 21.9996 5 20.6565 5 18.9996V12.9996Z"
29150 }), /*#__PURE__*/ react.default.createElement("path", {
29151 fillRule: "evenodd",
29152 clipRule: "evenodd",
29153 d: "M12.5 3.90527C11.7044 3.90527 10.9413 4.22134 10.3787 4.78395C9.81607 5.34656 9.5 6.10962 9.5 6.90527V10.9053C9.5 11.4576 9.05228 11.9053 8.5 11.9053C7.94772 11.9053 7.5 11.4576 7.5 10.9053V6.90527C7.5 5.57919 8.02678 4.30742 8.96447 3.36974C9.90215 2.43206 11.1739 1.90527 12.5 1.90527C13.8261 1.90527 15.0979 2.43206 16.0355 3.36974C16.9732 4.30742 17.5 5.57919 17.5 6.90527V10.9053C17.5 11.4576 17.0523 11.9053 16.5 11.9053C15.9477 11.9053 15.5 11.4576 15.5 10.9053V6.90527C15.5 6.10962 15.1839 5.34656 14.6213 4.78395C14.0587 4.22134 13.2956 3.90527 12.5 3.90527Z"
29154 }), /*#__PURE__*/ react.default.createElement("path", { d: "M6 12H19V20H6V12Z" }));
29155 });
29156
29157 //#endregion
29158 //#region modules/ai/assets/js/editor/pages/form-layout/components/pro-template-indicator.js
29159 init_slicedToArray();
29160 var popoverId = "e-pro-upgrade-popover";
29161 var StyledContent = (0, _elementor_ui.styled)(_elementor_ui.Paper)(function(_ref) {
29162 var theme = _ref.theme;
29163 return {
29164 position: "relative",
29165 padding: theme.spacing(3),
29166 boxShadow: theme.shadows[4],
29167 zIndex: "9999"
29168 };
29169 });
29170 var StyledArrow = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref2) {
29171 var theme = _ref2.theme;
29172 return {
29173 position: "absolute",
29174 width: theme.spacing(5),
29175 height: theme.spacing(5),
29176 overflow: "hidden",
29177 left: "100% !important",
29178 transform: "translateX(-50%) translateY(-50%) rotate(var(--rotate, 0deg)) !important",
29179 "&::after": {
29180 backgroundColor: theme.palette.background.paper,
29181 content: "\"\"",
29182 display: "block",
29183 position: "absolute",
29184 width: theme.spacing(2.5),
29185 height: theme.spacing(2.5),
29186 top: "50%",
29187 left: "50%",
29188 transform: "translateX(-50%) translateY(-50%) rotate(45deg)",
29189 boxShadow: "5px -5px 5px 0px rgba(0, 0, 0, 0.2)",
29190 backgroundImage: "linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"
29191 }
29192 };
29193 });
29194 var ProTemplateIndicator = function ProTemplateIndicator() {
29195 var actionUrl = "https://go.elementor.com/go-pro-ai/";
29196 var actionLabel = (0, _wordpress_i18n.__)("Go Pro", "elementor");
29197 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
29198 var isPopoverOpen = _useState2[0];
29199 var setIsPopoverOpen = _useState2[1];
29200 var anchorEl = (0, react.useRef)(null);
29201 var arrowEl = (0, react.useRef)(null);
29202 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
29203 flexDirection: "row-reverse",
29204 component: "span",
29205 display: "flex",
29206 onMouseLeave: function hidePopover() {
29207 return setIsPopoverOpen(false);
29208 },
29209 alignItems: "center"
29210 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
29211 ref: anchorEl,
29212 onMouseEnter: function showPopover() {
29213 return setIsPopoverOpen(true);
29214 },
29215 onClick: function onClick(e) {
29216 return e.stopPropagation();
29217 },
29218 "aria-owns": isPopoverOpen ? popoverId : void 0,
29219 "aria-haspopup": "true",
29220 sx: {
29221 m: 1,
29222 "&:hover": { backgroundColor: "action.selected" }
29223 }
29224 }, /*#__PURE__*/ react.default.createElement(LockIcon, { sx: { color: "text.primary" } })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Popper, {
29225 open: isPopoverOpen,
29226 popperOptions: {
29227 placement: "left-start",
29228 modifiers: [{
29229 name: "arrow",
29230 enabled: true,
29231 options: {
29232 element: arrowEl.current,
29233 padding: 5
29234 }
29235 }, {
29236 name: "offset",
29237 options: { offset: [0, 10] }
29238 }]
29239 },
29240 anchorEl: anchorEl.current,
29241 sx: {
29242 zIndex: "9999",
29243 maxWidth: 300
29244 }
29245 }, /*#__PURE__*/ react.default.createElement(StyledContent, null, /*#__PURE__*/ react.default.createElement(StyledArrow, { ref: arrowEl }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
29246 alignItems: "start",
29247 spacing: 2
29248 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Chip, {
29249 color: "promotion",
29250 variant: "outlined",
29251 size: "small",
29252 label: (0, _wordpress_i18n.__)("Pro", "elementor"),
29253 icon: /*#__PURE__*/ react.default.createElement(LockIcon, null)
29254 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "body2" }, (0, _wordpress_i18n.__)("This result includes an Elementor Pro widget that's not available with your current plan. Upgrade to use all the widgets in this result.", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
29255 variant: "contained",
29256 color: "promotion",
29257 size: "small",
29258 href: actionUrl,
29259 target: "_blank",
29260 sx: { alignSelf: "flex-end" }
29261 }, actionLabel)))));
29262 };
29263
29264 //#endregion
29265 //#region modules/ai/assets/js/editor/pages/form-layout/components/template-badge.js
29266 var TemplateBadge = function TemplateBadge(props) {
29267 var hasPro = useConfig().hasPro;
29268 if ("Pro" === props.type && !hasPro) return /*#__PURE__*/ react.default.createElement(ProTemplateIndicator, null);
29269 return null;
29270 };
29271 TemplateBadge.propTypes = { type: import_prop_types$7.default.string };
29272
29273 //#endregion
29274 //#region modules/ai/assets/js/editor/pages/form-layout/components/screenshot.js
29275 init_defineProperty();
29276 function ownKeys$1(e, r) {
29277 var t = Object.keys(e);
29278 if (Object.getOwnPropertySymbols) {
29279 var o = Object.getOwnPropertySymbols(e);
29280 r && (o = o.filter(function(r) {
29281 return Object.getOwnPropertyDescriptor(e, r).enumerable;
29282 })), t.push.apply(t, o);
29283 }
29284 return t;
29285 }
29286 __name(ownKeys$1, "ownKeys");
29287 function _objectSpread$1(e) {
29288 for (var r = 1; r < arguments.length; r++) {
29289 var t = null != arguments[r] ? arguments[r] : {};
29290 r % 2 ? ownKeys$1(Object(t), !0).forEach(function(r) {
29291 _defineProperty(e, r, t[r]);
29292 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function(r) {
29293 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
29294 });
29295 }
29296 return e;
29297 }
29298 __name(_objectSpread$1, "_objectSpread");
29299 var SCREENSHOT_HEIGHT = "138px";
29300 var Screenshot = function Screenshot(_ref) {
29301 var url = _ref.url;
29302 var type = _ref.type;
29303 var _ref$isLoading = _ref.isLoading;
29304 var isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading;
29305 var _ref$isSelected = _ref.isSelected;
29306 var isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected;
29307 var isPlaceholder = _ref.isPlaceholder;
29308 var disabled = _ref.disabled;
29309 var onClick = _ref.onClick;
29310 var _ref$sx = _ref.sx;
29311 var sx = _ref$sx === void 0 ? {} : _ref$sx;
29312 var outlineOffset = _ref.outlineOffset;
29313 if (isPlaceholder) return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: _objectSpread$1({ height: SCREENSHOT_HEIGHT }, sx) });
29314 if (isLoading) return /*#__PURE__*/ react.default.createElement(_elementor_ui.Skeleton, {
29315 width: "100%",
29316 animation: "wave",
29317 variant: "rounded",
29318 height: SCREENSHOT_HEIGHT,
29319 sx
29320 });
29321 if (!url) return /*#__PURE__*/ react.default.createElement(ScreenshotUnavailable, {
29322 selected: isSelected,
29323 disabled,
29324 sx,
29325 onClick,
29326 height: SCREENSHOT_HEIGHT,
29327 outlineOffset
29328 });
29329 return /*#__PURE__*/ react.default.createElement(ScreenshotContainer, {
29330 selected: isSelected,
29331 disabled,
29332 sx: _objectSpread$1({ backgroundImage: "url('".concat(url, "')") }, sx),
29333 onClick,
29334 height: SCREENSHOT_HEIGHT,
29335 outlineOffset
29336 }, /*#__PURE__*/ react.default.createElement(TemplateBadge, { type }));
29337 };
29338 Screenshot.propTypes = {
29339 isSelected: import_prop_types$7.default.bool,
29340 isLoading: import_prop_types$7.default.bool,
29341 isPlaceholder: import_prop_types$7.default.bool,
29342 disabled: import_prop_types$7.default.bool,
29343 onClick: import_prop_types$7.default.func.isRequired,
29344 url: import_prop_types$7.default.string,
29345 type: import_prop_types$7.default.string,
29346 sx: import_prop_types$7.default.object,
29347 outlineOffset: import_prop_types$7.default.string
29348 };
29349
29350 //#endregion
29351 //#region modules/ai/assets/js/editor/pages/form-layout/hooks/use-layout-prompt.js
29352 init_api();
29353 init_use_prompt();
29354 var useLayoutPrompt = function useLayoutPrompt(type, initialValue) {
29355 return usePrompt(function(requestBody, signal) {
29356 requestBody.variationType = type;
29357 return generateLayout(requestBody, signal);
29358 }, initialValue);
29359 };
29360
29361 //#endregion
29362 //#region modules/ai/assets/js/editor/pages/form-layout/hooks/use-screenshot.js
29363 init_asyncToGenerator();
29364 init_slicedToArray();
29365 var ERROR_INITIAL_VALUE = "";
29366 var useScreenshot = function useScreenshot(type, onData) {
29367 var _useState2 = _slicedToArray((0, react.useState)(ERROR_INITIAL_VALUE), 2);
29368 var error = _useState2[0];
29369 var setError = _useState2[1];
29370 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
29371 var isLoading = _useState4[0];
29372 var setIsLoading = _useState4[1];
29373 var layoutData = useLayoutPrompt(type, null);
29374 return {
29375 generate: function generate(requestBody, signal) {
29376 setIsLoading(true);
29377 setError(ERROR_INITIAL_VALUE);
29378 return layoutData.send(requestBody, signal).then(/*#__PURE__*/ function() {
29379 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(data) {
29380 var createdScreenshot;
29381 return import_regenerator$2.default.wrap(function(_context) {
29382 while (1) switch (_context.prev = _context.next) {
29383 case 0:
29384 _context.next = 1;
29385 return onData(data.result);
29386 case 1:
29387 createdScreenshot = _context.sent;
29388 createdScreenshot.sendUsageData = function() {
29389 return layoutData.sendUsageData(data);
29390 };
29391 createdScreenshot.baseTemplateId = data.baseTemplateId;
29392 createdScreenshot.type = data.type;
29393 return _context.abrupt("return", createdScreenshot);
29394 case 2:
29395 case "end": return _context.stop();
29396 }
29397 }, _callee);
29398 }));
29399 return function(_x) {
29400 return _ref.apply(this, arguments);
29401 };
29402 }()).catch(function(err) {
29403 setError(err.extra_data ? err : err.message || err);
29404 throw err;
29405 }).finally(function() {
29406 return setIsLoading(false);
29407 });
29408 },
29409 error,
29410 isLoading
29411 };
29412 };
29413
29414 //#endregion
29415 //#region modules/ai/assets/js/editor/pages/form-layout/hooks/use-screenshots.js
29416 init_asyncToGenerator();
29417 init_slicedToArray();
29418 init_requests_ids();
29419 var PENDING_VALUE = { isPending: true };
29420 var useScreenshots = function useScreenshots(_ref) {
29421 var onData = _ref.onData;
29422 var _useState2 = _slicedToArray((0, react.useState)([]), 2);
29423 var screenshots = _useState2[0];
29424 var setScreenshots = _useState2[1];
29425 /**
29426 * The ids for each request are:
29427 * - editorSessionId: a unique id for each editor opening
29428 * - sessionId: a unique id for each session. (open the AI builder)
29429 * - generateId: a unique id for each generate request. (prompt change)
29430 * - batchId: a unique id for each batch of generate requests. (generate, regenerate)
29431 * - requestId: a unique id for each generate request.
29432 */
29433 var currentContext = useConfig().currentContext;
29434 var _useRequestIds = useRequestIds();
29435 var editorSessionId = _useRequestIds.editorSessionId;
29436 var sessionId = _useRequestIds.sessionId;
29437 var setRequest = _useRequestIds.setRequest;
29438 var setBatch = _useRequestIds.setBatch;
29439 var setGenerate = _useRequestIds.setGenerate;
29440 var generateIdRef = (0, react.useRef)("");
29441 var batchId = setBatch();
29442 var screenshotsData = [
29443 useScreenshot(0, onData),
29444 useScreenshot(1, onData),
29445 useScreenshot(2, onData)
29446 ];
29447 var screenshotsGroupCount = screenshotsData.length;
29448 var error = screenshotsData.every(function(s) {
29449 return s === null || s === void 0 ? void 0 : s.error;
29450 }) ? screenshotsData[0].error : "";
29451 var isLoading = screenshotsData.some(function(s) {
29452 return s === null || s === void 0 ? void 0 : s.isLoading;
29453 });
29454 var abortController = (0, react.useRef)(null);
29455 var abort = function abort() {
29456 var _abortController$curr;
29457 return (_abortController$curr = abortController.current) === null || _abortController$curr === void 0 ? void 0 : _abortController$curr.abort();
29458 };
29459 var createScreenshots = /*#__PURE__*/ function() {
29460 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(prompt, attachments) {
29461 var onGenerate;
29462 var onError;
29463 var promises;
29464 var results;
29465 var isAllFailed;
29466 return import_regenerator$2.default.wrap(function(_context) {
29467 while (1) switch (_context.prev = _context.next) {
29468 case 0:
29469 abortController.current = new AbortController();
29470 onGenerate = function onGenerate(screenshot) {
29471 setScreenshots(function(prev) {
29472 var updatedData = _toConsumableArray(prev);
29473 var pendingIndex = updatedData.indexOf(PENDING_VALUE);
29474 updatedData[pendingIndex] = screenshot;
29475 return updatedData;
29476 });
29477 return true;
29478 };
29479 onError = function onError() {
29480 setScreenshots(function(prev) {
29481 var updatedData = _toConsumableArray(prev);
29482 var pendingIndex = updatedData.lastIndexOf(PENDING_VALUE);
29483 updatedData[pendingIndex] = { isError: true };
29484 return updatedData;
29485 });
29486 return false;
29487 };
29488 promises = screenshotsData.map(function(_ref3) {
29489 var generate = _ref3.generate;
29490 return generate({
29491 prompt,
29492 prevGeneratedIds: screenshots.map(function(screenshot) {
29493 return screenshot.baseTemplateId || "";
29494 }),
29495 currentContext,
29496 ids: {
29497 editorSessionId: editorSessionId.current,
29498 sessionId: sessionId.current,
29499 generateId: generateIdRef.current,
29500 batchId: batchId.current,
29501 requestId: setRequest().current
29502 },
29503 attachments: attachments.map(function(_ref4) {
29504 return {
29505 type: _ref4.type,
29506 content: _ref4.content,
29507 label: _ref4.label,
29508 source: _ref4.source
29509 };
29510 })
29511 }, abortController.current.signal).then(onGenerate).catch(onError);
29512 });
29513 _context.next = 1;
29514 return Promise.all(promises);
29515 case 1:
29516 results = _context.sent;
29517 isAllFailed = results.every(function(value) {
29518 return false === value;
29519 });
29520 if (isAllFailed) setScreenshots(function(prev) {
29521 var updatedData = _toConsumableArray(prev);
29522 updatedData.splice(screenshotsGroupCount * -1);
29523 return updatedData;
29524 });
29525 case 2:
29526 case "end": return _context.stop();
29527 }
29528 }, _callee);
29529 }));
29530 return function createScreenshots(_x, _x2) {
29531 return _ref2.apply(this, arguments);
29532 };
29533 }();
29534 return {
29535 generate: function generate(prompt, attachments) {
29536 var placeholders = Array(screenshotsGroupCount).fill(PENDING_VALUE);
29537 generateIdRef.current = setGenerate().current;
29538 setScreenshots(placeholders);
29539 createScreenshots(prompt, attachments);
29540 },
29541 regenerate: function regenerate(prompt, attachments) {
29542 var placeholders = Array(screenshotsGroupCount).fill(PENDING_VALUE);
29543 setScreenshots(function(prev) {
29544 return [].concat(_toConsumableArray(prev), _toConsumableArray(placeholders));
29545 });
29546 createScreenshots(prompt, attachments);
29547 },
29548 screenshots,
29549 isLoading,
29550 error,
29551 abort
29552 };
29553 };
29554
29555 //#endregion
29556 //#region modules/ai/assets/js/editor/pages/form-layout/hooks/use-slider.js
29557 init_slicedToArray();
29558 var SCREENSHOTS_PER_PAGE = 3;
29559 var useSlider = function useSlider() {
29560 var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
29561 var _ref$slidesCount = _ref.slidesCount;
29562 var slidesCount = _ref$slidesCount === void 0 ? 0 : _ref$slidesCount;
29563 var _ref$slidesPerPage = _ref.slidesPerPage;
29564 var slidesPerPage = _ref$slidesPerPage === void 0 ? 3 : _ref$slidesPerPage;
29565 var _ref$gapPercentage = _ref.gapPercentage;
29566 var gapPercentage = _ref$gapPercentage === void 0 ? 2 : _ref$gapPercentage;
29567 var _useState2 = _slicedToArray((0, react.useState)(1), 2);
29568 var currentPage = _useState2[0];
29569 var setCurrentPage = _useState2[1];
29570 var slideWidthPercentage = (100 - gapPercentage * (slidesPerPage - 1)) / slidesPerPage;
29571 var offsetXPercentage = (slideWidthPercentage + gapPercentage) * slidesPerPage * (currentPage - 1) * -1;
29572 var pagesCount = Math.ceil(slidesCount / slidesPerPage);
29573 (0, react.useEffect)(function() {
29574 if (currentPage > 1 && currentPage > pagesCount) setCurrentPage(pagesCount);
29575 }, [pagesCount]);
29576 return {
29577 currentPage,
29578 setCurrentPage,
29579 pagesCount,
29580 slidesPerPage,
29581 gapPercentage,
29582 offsetXPercentage,
29583 slideWidthPercentage
29584 };
29585 };
29586
29587 //#endregion
29588 //#region modules/ai/assets/js/editor/icons/minimize-diagonal-icon.js
29589 init_extends();
29590 var MinimizeDiagonalIcon = react.default.forwardRef(function(props, ref) {
29591 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
29592 fillRule: "evenodd",
29593 clipRule: "evenodd",
29594 d: "M3.46967 3.46967C3.76256 3.17678 4.23744 3.17678 4.53033 3.46967L9.25 8.18934V6C9.25 5.58579 9.58579 5.25 10 5.25C10.4142 5.25 10.75 5.58579 10.75 6V10C10.75 10.4142 10.4142 10.75 10 10.75H6C5.58579 10.75 5.25 10.4142 5.25 10C5.25 9.58579 5.58579 9.25 6 9.25H8.18934L3.46967 4.53033C3.17678 4.23744 3.17678 3.76256 3.46967 3.46967ZM14 13.25H18C18.4142 13.25 18.75 13.5858 18.75 14C18.75 14.4142 18.4142 14.75 18 14.75H15.8107L20.5303 19.4697C20.8232 19.7626 20.8232 20.2374 20.5303 20.5303C20.2374 20.8232 19.7626 20.8232 19.4697 20.5303L14.75 15.8107V18C14.75 18.4142 14.4142 18.75 14 18.75C13.5858 18.75 13.25 18.4142 13.25 18V14C13.25 13.5858 13.5858 13.25 14 13.25Z"
29595 }));
29596 });
29597
29598 //#endregion
29599 //#region modules/ai/assets/js/editor/icons/expand-diagonal-icon.js
29600 init_extends();
29601 var ExpandDiagonalIcon = react.default.forwardRef(function(props, ref) {
29602 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
29603 fillRule: "evenodd",
29604 clipRule: "evenodd",
29605 d: "M4 3.25H8C8.41421 3.25 8.75 3.58579 8.75 4C8.75 4.41421 8.41421 4.75 8 4.75H5.81066L10.5303 9.46967C10.8232 9.76256 10.8232 10.2374 10.5303 10.5303C10.2374 10.8232 9.76256 10.8232 9.46967 10.5303L4.75 5.81066V8C4.75 8.41421 4.41421 8.75 4 8.75C3.58579 8.75 3.25 8.41421 3.25 8V4C3.25 3.58579 3.58579 3.25 4 3.25ZM13.4697 13.4697C13.7626 13.1768 14.2374 13.1768 14.5303 13.4697L19.25 18.1893V16C19.25 15.5858 19.5858 15.25 20 15.25C20.4142 15.25 20.75 15.5858 20.75 16V20C20.75 20.4142 20.4142 20.75 20 20.75H16C15.5858 20.75 15.25 20.4142 15.25 20C15.25 19.5858 15.5858 19.25 16 19.25H18.1893L13.4697 14.5303C13.1768 14.2374 13.1768 13.7626 13.4697 13.4697Z"
29606 }));
29607 });
29608
29609 //#endregion
29610 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/prompt-power-notice.js
29611 init_use_introduction();
29612 var PromptPowerNotice = function PromptPowerNotice() {
29613 var _useIntroduction = useIntroduction("e-ai-builder-attachments-power");
29614 var isViewed = _useIntroduction.isViewed;
29615 var markAsViewed = _useIntroduction.markAsViewed;
29616 if (isViewed) return null;
29617 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
29618 pt: 2,
29619 px: 2,
29620 pb: 0
29621 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Alert, {
29622 severity: "info",
29623 onClose: function onClose() {
29624 return markAsViewed();
29625 }
29626 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
29627 variant: "body2",
29628 display: "inline-block",
29629 sx: { paddingInlineEnd: 1 }
29630 }, (0, _wordpress_i18n.__)("You’ve got the power.", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
29631 variant: "body2",
29632 display: "inline-block"
29633 }, (0, _wordpress_i18n.__)("Craft your prompt to affect content, images and/or colors - whichever you decide.", "elementor"))));
29634 };
29635
29636 //#endregion
29637 //#region node_modules/validator/lib/util/assertString.js
29638 var require_assertString = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29639 Object.defineProperty(exports, "__esModule", { value: true });
29640 exports.default = assertString;
29641 function assertString(input) {
29642 if (input === void 0 || input === null) throw new TypeError("Expected a string but received a ".concat(input));
29643 if (input.constructor.name !== "String") throw new TypeError("Expected a string but received a ".concat(input.constructor.name));
29644 }
29645 module.exports = exports.default;
29646 module.exports.default = exports.default;
29647 }));
29648
29649 //#endregion
29650 //#region node_modules/validator/lib/util/checkHost.js
29651 var require_checkHost = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29652 Object.defineProperty(exports, "__esModule", { value: true });
29653 exports.default = checkHost;
29654 function isRegExp(obj) {
29655 return Object.prototype.toString.call(obj) === "[object RegExp]";
29656 }
29657 function checkHost(host, matches) {
29658 for (var i = 0; i < matches.length; i++) {
29659 var match = matches[i];
29660 if (host === match || isRegExp(match) && match.test(host)) return true;
29661 }
29662 return false;
29663 }
29664 module.exports = exports.default;
29665 module.exports.default = exports.default;
29666 }));
29667
29668 //#endregion
29669 //#region node_modules/validator/lib/util/includesString.js
29670 var require_includesString = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29671 Object.defineProperty(exports, "__esModule", { value: true });
29672 exports.default = void 0;
29673 var includes = function includes(str, val) {
29674 return str.indexOf(val) !== -1;
29675 };
29676 exports.default = includes;
29677 module.exports = exports.default;
29678 module.exports.default = exports.default;
29679 }));
29680
29681 //#endregion
29682 //#region node_modules/validator/lib/util/merge.js
29683 var require_merge = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29684 Object.defineProperty(exports, "__esModule", { value: true });
29685 exports.default = merge;
29686 function merge() {
29687 var obj = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
29688 var defaults = arguments.length > 1 ? arguments[1] : void 0;
29689 for (var key in defaults) if (typeof obj[key] === "undefined") obj[key] = defaults[key];
29690 return obj;
29691 }
29692 module.exports = exports.default;
29693 module.exports.default = exports.default;
29694 }));
29695
29696 //#endregion
29697 //#region node_modules/validator/lib/isFQDN.js
29698 var require_isFQDN = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29699 Object.defineProperty(exports, "__esModule", { value: true });
29700 exports.default = isFQDN;
29701 var _assertString = _interopRequireDefault(require_assertString());
29702 var _merge = _interopRequireDefault(require_merge());
29703 function _interopRequireDefault(e) {
29704 return e && e.__esModule ? e : { default: e };
29705 }
29706 var default_fqdn_options = {
29707 require_tld: true,
29708 allow_underscores: false,
29709 allow_trailing_dot: false,
29710 allow_numeric_tld: false,
29711 allow_wildcard: false,
29712 ignore_max_length: false
29713 };
29714 function isFQDN(str, options) {
29715 (0, _assertString.default)(str);
29716 options = (0, _merge.default)(options, default_fqdn_options);
29717 if (options.allow_trailing_dot && str[str.length - 1] === ".") str = str.substring(0, str.length - 1);
29718 if (options.allow_wildcard === true && str.indexOf("*.") === 0) str = str.substring(2);
29719 var parts = str.split(".");
29720 var tld = parts[parts.length - 1];
29721 if (options.require_tld) {
29722 if (parts.length < 2) return false;
29723 if (!options.allow_numeric_tld && !/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) return false;
29724 if (/\s/.test(tld)) return false;
29725 }
29726 if (!options.allow_numeric_tld && /^\d+$/.test(tld)) return false;
29727 return parts.every(function(part) {
29728 if (part.length > 63 && !options.ignore_max_length) return false;
29729 if (!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(part)) return false;
29730 if (/[\uff01-\uff5e]/.test(part)) return false;
29731 if (/^-|-$/.test(part)) return false;
29732 if (!options.allow_underscores && /_/.test(part)) return false;
29733 return true;
29734 });
29735 }
29736 module.exports = exports.default;
29737 module.exports.default = exports.default;
29738 }));
29739
29740 //#endregion
29741 //#region node_modules/validator/lib/isIP.js
29742 var require_isIP = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29743 Object.defineProperty(exports, "__esModule", { value: true });
29744 exports.default = isIP;
29745 var _assertString = _interopRequireDefault(require_assertString());
29746 function _interopRequireDefault(e) {
29747 return e && e.__esModule ? e : { default: e };
29748 }
29749 function _typeof(o) {
29750 "@babel/helpers - typeof";
29751 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
29752 return typeof o;
29753 } : function(o) {
29754 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
29755 }, _typeof(o);
29756 }
29757 /**
29758 11.3. Examples
29759
29760 The following addresses
29761
29762 fe80::1234 (on the 1st link of the node)
29763 ff02::5678 (on the 5th link of the node)
29764 ff08::9abc (on the 10th organization of the node)
29765
29766 would be represented as follows:
29767
29768 fe80::1234%1
29769 ff02::5678%5
29770 ff08::9abc%10
29771
29772 (Here we assume a natural translation from a zone index to the
29773 <zone_id> part, where the Nth zone of any scope is translated into
29774 "N".)
29775
29776 If we use interface names as <zone_id>, those addresses could also be
29777 represented as follows:
29778
29779 fe80::1234%ne0
29780 ff02::5678%pvc1.3
29781 ff08::9abc%interface10
29782
29783 where the interface "ne0" belongs to the 1st link, "pvc1.3" belongs
29784 to the 5th link, and "interface10" belongs to the 10th organization.
29785 * * */
29786 var IPv4SegmentFormat = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])";
29787 var IPv4AddressFormat = "(".concat(IPv4SegmentFormat, "[.]){3}").concat(IPv4SegmentFormat);
29788 var IPv4AddressRegExp = new RegExp("^".concat(IPv4AddressFormat, "$"));
29789 var IPv6SegmentFormat = "(?:[0-9a-fA-F]{1,4})";
29790 var IPv6AddressRegExp = new RegExp("^(" + "(?:".concat(IPv6SegmentFormat, ":){7}(?:").concat(IPv6SegmentFormat, "|:)|") + "(?:".concat(IPv6SegmentFormat, ":){6}(?:").concat(IPv4AddressFormat, "|:").concat(IPv6SegmentFormat, "|:)|") + "(?:".concat(IPv6SegmentFormat, ":){5}(?::").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,2}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){4}(?:(:").concat(IPv6SegmentFormat, "){0,1}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,3}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){3}(?:(:").concat(IPv6SegmentFormat, "){0,2}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,4}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){2}(?:(:").concat(IPv6SegmentFormat, "){0,3}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,5}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){1}(?:(:").concat(IPv6SegmentFormat, "){0,4}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,6}|:)|") + "(?::((?::".concat(IPv6SegmentFormat, "){0,5}:").concat(IPv4AddressFormat, "|(?::").concat(IPv6SegmentFormat, "){1,7}|:))") + ")(%[0-9a-zA-Z.]{1,})?$");
29791 function isIP(ipAddress) {
29792 var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
29793 (0, _assertString.default)(ipAddress);
29794 var version = (_typeof(options) === "object" ? options.version : arguments[1]) || "";
29795 if (!version) return isIP(ipAddress, { version: 4 }) || isIP(ipAddress, { version: 6 });
29796 if (version.toString() === "4") return IPv4AddressRegExp.test(ipAddress);
29797 if (version.toString() === "6") return IPv6AddressRegExp.test(ipAddress);
29798 return false;
29799 }
29800 module.exports = exports.default;
29801 module.exports.default = exports.default;
29802 }));
29803
29804 //#endregion
29805 //#region node_modules/validator/lib/isURL.js
29806 var require_isURL = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29807 Object.defineProperty(exports, "__esModule", { value: true });
29808 exports.default = isURL;
29809 var _assertString = _interopRequireDefault(require_assertString());
29810 var _checkHost = _interopRequireDefault(require_checkHost());
29811 var _includesString = _interopRequireDefault(require_includesString());
29812 var _isFQDN = _interopRequireDefault(require_isFQDN());
29813 var _isIP = _interopRequireDefault(require_isIP());
29814 var _merge = _interopRequireDefault(require_merge());
29815 function _interopRequireDefault(e) {
29816 return e && e.__esModule ? e : { default: e };
29817 }
29818 function _slicedToArray(r, e) {
29819 return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
29820 }
29821 function _nonIterableRest() {
29822 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
29823 }
29824 function _unsupportedIterableToArray(r, a) {
29825 if (r) {
29826 if ("string" == typeof r) return _arrayLikeToArray(r, a);
29827 var t = {}.toString.call(r).slice(8, -1);
29828 return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
29829 }
29830 }
29831 function _arrayLikeToArray(r, a) {
29832 (null == a || a > r.length) && (a = r.length);
29833 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
29834 return n;
29835 }
29836 function _iterableToArrayLimit(r, l) {
29837 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
29838 if (null != t) {
29839 var e;
29840 var n;
29841 var i;
29842 var u;
29843 var a = [];
29844 var f = !0;
29845 var o = !1;
29846 try {
29847 if (i = (t = t.call(r)).next, 0 === l) {
29848 if (Object(t) !== t) return;
29849 f = !1;
29850 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
29851 } catch (r) {
29852 o = !0, n = r;
29853 } finally {
29854 try {
29855 if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
29856 } finally {
29857 if (o) throw n;
29858 }
29859 }
29860 return a;
29861 }
29862 }
29863 function _arrayWithHoles(r) {
29864 if (Array.isArray(r)) return r;
29865 }
29866 var default_url_options = {
29867 protocols: [
29868 "http",
29869 "https",
29870 "ftp"
29871 ],
29872 require_tld: true,
29873 require_protocol: false,
29874 require_host: true,
29875 require_port: false,
29876 require_valid_protocol: true,
29877 allow_underscores: false,
29878 allow_trailing_dot: false,
29879 allow_protocol_relative_urls: false,
29880 allow_fragments: true,
29881 allow_query_components: true,
29882 validate_length: true,
29883 max_allowed_length: 2084
29884 };
29885 var wrapped_ipv6 = /^\[([^\]]+)\](?::([0-9]+))?$/;
29886 function isURL(url, options) {
29887 (0, _assertString.default)(url);
29888 if (!url || /[\s<>]/.test(url)) return false;
29889 if (url.indexOf("mailto:") === 0) return false;
29890 options = (0, _merge.default)(options, default_url_options);
29891 if (options.validate_length && url.length > options.max_allowed_length) return false;
29892 if (!options.allow_fragments && (0, _includesString.default)(url, "#")) return false;
29893 if (!options.allow_query_components && ((0, _includesString.default)(url, "?") || (0, _includesString.default)(url, "&"))) return false;
29894 var protocol;
29895 var auth;
29896 var host;
29897 var hostname;
29898 var port;
29899 var port_str;
29900 var split = url.split("#");
29901 var ipv6;
29902 url = split.shift();
29903 split = url.split("?");
29904 url = split.shift();
29905 var protocol_match = url.match(/^([a-z][a-z0-9+\-.]*):/i);
29906 var had_explicit_protocol = false;
29907 var cleanUpProtocol = function cleanUpProtocol(potential_protocol) {
29908 had_explicit_protocol = true;
29909 protocol = potential_protocol.toLowerCase();
29910 if (options.require_valid_protocol && options.protocols.indexOf(protocol) === -1) return false;
29911 return url.substring(protocol_match[0].length);
29912 };
29913 if (protocol_match) {
29914 var potential_protocol = protocol_match[1];
29915 var after_colon = url.substring(protocol_match[0].length);
29916 if (!(after_colon.slice(0, 2) === "//")) {
29917 var first_slash_position = after_colon.indexOf("/");
29918 var before_slash = first_slash_position === -1 ? after_colon : after_colon.substring(0, first_slash_position);
29919 var at_position = before_slash.indexOf("@");
29920 if (at_position !== -1) {
29921 var before_at = before_slash.substring(0, at_position);
29922 if (/^[a-zA-Z0-9\-_.%:]*$/.test(before_at)) {
29923 if (options.require_protocol) return false;
29924 } else {
29925 url = cleanUpProtocol(potential_protocol);
29926 if (url === false) return false;
29927 }
29928 } else if (/^[0-9]/.test(after_colon)) {
29929 if (options.require_protocol) return false;
29930 } else {
29931 url = cleanUpProtocol(potential_protocol);
29932 if (url === false) return false;
29933 }
29934 } else {
29935 url = cleanUpProtocol(potential_protocol);
29936 if (url === false) return false;
29937 }
29938 } else if (options.require_protocol) return false;
29939 if (url.slice(0, 2) === "//") {
29940 if (!had_explicit_protocol && !options.allow_protocol_relative_urls) return false;
29941 url = url.slice(2);
29942 }
29943 if (url === "") return false;
29944 split = url.split("/");
29945 url = split.shift();
29946 if (url === "" && !options.require_host) return true;
29947 split = url.split("@");
29948 if (split.length > 1) {
29949 if (options.disallow_auth) return false;
29950 if (split[0] === "") return false;
29951 auth = split.shift();
29952 if (auth.indexOf(":") >= 0 && auth.split(":").length > 2) return false;
29953 var _auth$split2 = _slicedToArray(auth.split(":"), 2);
29954 var user = _auth$split2[0];
29955 var password = _auth$split2[1];
29956 if (user === "" && password === "") return false;
29957 }
29958 hostname = split.join("@");
29959 port_str = null;
29960 ipv6 = null;
29961 var ipv6_match = hostname.match(wrapped_ipv6);
29962 if (ipv6_match) {
29963 host = "";
29964 ipv6 = ipv6_match[1];
29965 port_str = ipv6_match[2] || null;
29966 } else {
29967 split = hostname.split(":");
29968 host = split.shift();
29969 if (split.length) port_str = split.join(":");
29970 }
29971 if (port_str !== null && port_str.length > 0) {
29972 port = parseInt(port_str, 10);
29973 if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) return false;
29974 } else if (options.require_port) return false;
29975 if (options.host_whitelist) return (0, _checkHost.default)(host, options.host_whitelist);
29976 if (host === "" && !options.require_host) return true;
29977 if (!(0, _isIP.default)(host) && !(0, _isFQDN.default)(host, options) && (!ipv6 || !(0, _isIP.default)(ipv6, 6))) return false;
29978 host = host || ipv6;
29979 if (options.host_blacklist && (0, _checkHost.default)(host, options.host_blacklist)) return false;
29980 return true;
29981 }
29982 module.exports = exports.default;
29983 module.exports.default = exports.default;
29984 }));
29985
29986 //#endregion
29987 //#region modules/ai/assets/js/editor/pages/form-layout/index.js
29988 init_objectWithoutProperties();
29989 init_slicedToArray();
29990 init_extends();
29991 init_prompt_error_message();
29992 var import_isURL = /* @__PURE__ */ __toESM(require_isURL());
29993 init_voice_promotion_alert();
29994 var _excluded = ["children"];
29995 var DirectionalMinimizeDiagonalIcon = (0, _elementor_ui.withDirection)(MinimizeDiagonalIcon);
29996 var DirectionalExpandDiagonalIcon = (0, _elementor_ui.withDirection)(ExpandDiagonalIcon);
29997 /**
29998 * @typedef {Object} Attachment
29999 * @property {('json')} type - The type of the attachment, currently only `json` is supported.
30000 * @property {string} previewHTML - HTML content as a string, representing a preview.
30001 * @property {string} content - Actual content of the attachment as a string.
30002 * @property {string} label - Label for the attachment.
30003 */
30004 var RegenerateButton = function RegenerateButton(props) {
30005 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
30006 size: "small",
30007 color: "secondary",
30008 startIcon: /*#__PURE__*/ react.default.createElement(RefreshIcon, null)
30009 }, props), (0, _wordpress_i18n.__)("Regenerate", "elementor"));
30010 };
30011 var UseLayoutButton = function UseLayoutButton(props) {
30012 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
30013 size: "small",
30014 variant: "contained"
30015 }, props), (0, _wordpress_i18n.__)("Use Layout", "elementor"));
30016 };
30017 UseLayoutButton.propTypes = { sx: import_prop_types$7.default.object };
30018 var isRegenerateButtonDisabled = function isRegenerateButtonDisabled(screenshots, isLoading, isPromptFormActive) {
30019 if (isLoading || isPromptFormActive) return true;
30020 return screenshots.length >= 3 * 5;
30021 };
30022 var FormLayout = function FormLayout(_ref) {
30023 var _screenshots$selected;
30024 var _screenshots$2;
30025 var _ref$DialogHeaderProp = _ref.DialogHeaderProps;
30026 var DialogHeaderProps = _ref$DialogHeaderProp === void 0 ? {} : _ref$DialogHeaderProp;
30027 var _ref$DialogContentPro = _ref.DialogContentProps;
30028 var DialogContentProps = _ref$DialogContentPro === void 0 ? {} : _ref$DialogContentPro;
30029 var initialAttachments = _ref.attachments;
30030 var _useConfig = useConfig();
30031 var attachmentsTypes = _useConfig.attachmentsTypes;
30032 var onData = _useConfig.onData;
30033 var onInsert = _useConfig.onInsert;
30034 var onSelect = _useConfig.onSelect;
30035 var onClose = _useConfig.onClose;
30036 var onGenerate = _useConfig.onGenerate;
30037 var _useScreenshots = useScreenshots({ onData });
30038 var screenshots = _useScreenshots.screenshots;
30039 var generate = _useScreenshots.generate;
30040 var regenerate = _useScreenshots.regenerate;
30041 var isLoading = _useScreenshots.isLoading;
30042 var error = _useScreenshots.error;
30043 var abort = _useScreenshots.abort;
30044 var screenshotOutlineOffset = "2px";
30045 var _useSlider = useSlider({ slidesCount: screenshots.length });
30046 var currentPage = _useSlider.currentPage;
30047 var setCurrentPage = _useSlider.setCurrentPage;
30048 var pagesCount = _useSlider.pagesCount;
30049 var gapPercentage = _useSlider.gapPercentage;
30050 var slidesPerPage = _useSlider.slidesPerPage;
30051 var offsetXPercentage = _useSlider.offsetXPercentage;
30052 var slideWidthPercentage = _useSlider.slideWidthPercentage;
30053 var _useState2 = _slicedToArray((0, react.useState)(-1), 2);
30054 var selectedScreenshotIndex = _useState2[0];
30055 var setSelectedScreenshotIndex = _useState2[1];
30056 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
30057 var showUnsavedChangesAlert = _useState4[0];
30058 var setShowUnsavedChangesAlert = _useState4[1];
30059 var _useState6 = _slicedToArray((0, react.useState)(true), 2);
30060 var isPromptEditable = _useState6[0];
30061 var setIsPromptEditable = _useState6[1];
30062 var _useState8 = _slicedToArray((0, react.useState)([]), 2);
30063 var attachments = _useState8[0];
30064 var setAttachments = _useState8[1];
30065 var _useState0 = _slicedToArray((0, react.useState)(false), 2);
30066 var shouldRenderWebApp = _useState0[0];
30067 var setShouldRenderWebApp = _useState0[1];
30068 var _useState10 = _slicedToArray((0, react.useState)(false), 2);
30069 var isMinimized = _useState10[0];
30070 var setIsMinimized = _useState10[1];
30071 var lastRun = (0, react.useRef)(function() {});
30072 var promptInputRef = (0, react.useRef)(null);
30073 var selectedTemplate = (_screenshots$selected = screenshots[selectedScreenshotIndex]) === null || _screenshots$selected === void 0 ? void 0 : _screenshots$selected.template;
30074 var dialogContentChildren = DialogContentProps.children;
30075 var dialogContentProps = _objectWithoutProperties(DialogContentProps, _excluded);
30076 var shouldFallbackToEditPrompt = !!(error && 0 === screenshots.length);
30077 var isPromptFormActive = isPromptEditable || shouldFallbackToEditPrompt;
30078 var abortAndClose = function abortAndClose() {
30079 abort();
30080 onClose();
30081 };
30082 var onCloseIntent = function onCloseIntent() {
30083 if (promptInputRef.current.value.trim() !== "" || screenshots.length > 0) return setShowUnsavedChangesAlert(true);
30084 abortAndClose();
30085 };
30086 var handleGenerate = function handleGenerate(event, prompt) {
30087 event.preventDefault();
30088 if ("" === prompt.trim() && 0 === attachments.length) return;
30089 if ((0, import_isURL.default)(prompt)) {
30090 setShouldRenderWebApp(true);
30091 return;
30092 }
30093 onGenerate();
30094 lastRun.current = function() {
30095 setSelectedScreenshotIndex(-1);
30096 generate(prompt, attachments);
30097 };
30098 lastRun.current();
30099 setIsPromptEditable(false);
30100 setCurrentPage(1);
30101 };
30102 var handleRegenerate = function handleRegenerate() {
30103 lastRun.current = function() {
30104 regenerate(promptInputRef.current.value, attachments);
30105 setCurrentPage(pagesCount + 1);
30106 };
30107 lastRun.current();
30108 };
30109 var applyTemplate = function applyTemplate() {
30110 onInsert(selectedTemplate);
30111 screenshots[selectedScreenshotIndex].sendUsageData();
30112 abortAndClose();
30113 };
30114 var handleScreenshotClick = function handleScreenshotClick(index, template) {
30115 return function() {
30116 if (isPromptFormActive) return;
30117 setSelectedScreenshotIndex(index);
30118 onSelect(template);
30119 };
30120 };
30121 /**
30122 * @param {Attachment[]} items
30123 */
30124 var onAttach = function onAttach(items) {
30125 items.forEach(function(item) {
30126 if (!attachmentsTypes[item.type]) throw new Error("Invalid attachment type: ".concat(item.type));
30127 var typeConfig = attachmentsTypes[item.type];
30128 if (!item.previewHTML && typeConfig.previewGenerator) typeConfig.previewGenerator(item.content).then(function(html) {
30129 item.previewHTML = html;
30130 setAttachments(function(prev) {
30131 return prev.map(function(attachment) {
30132 if (attachment.content === item.content) return item;
30133 return attachment;
30134 });
30135 });
30136 });
30137 });
30138 setAttachments(items);
30139 setShouldRenderWebApp(false);
30140 setIsPromptEditable(true);
30141 };
30142 (0, react.useEffect)(function() {
30143 var _screenshots$;
30144 if ((_screenshots$ = screenshots[0]) === null || _screenshots$ === void 0 ? void 0 : _screenshots$.template) {
30145 onSelect(screenshots[0].template);
30146 setSelectedScreenshotIndex(0);
30147 }
30148 }, [(_screenshots$2 = screenshots[0]) === null || _screenshots$2 === void 0 ? void 0 : _screenshots$2.template]);
30149 (0, react.useEffect)(function() {
30150 if (initialAttachments !== null && initialAttachments !== void 0 && initialAttachments.length) onAttach(initialAttachments);
30151 }, []);
30152 return /*#__PURE__*/ react.default.createElement(LayoutDialog, { onClose: onCloseIntent }, /*#__PURE__*/ react.default.createElement(LayoutDialog.Header, _extends$1({ onClose: onCloseIntent }, DialogHeaderProps), DialogHeaderProps.children, /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: isMinimized ? (0, _wordpress_i18n.__)("Expand", "elementor") : (0, _wordpress_i18n.__)("Minimize", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
30153 size: "small",
30154 "aria-label": "minimize",
30155 onClick: function onClick() {
30156 return setIsMinimized(function(prev) {
30157 return !prev;
30158 });
30159 }
30160 }, isMinimized ? /*#__PURE__*/ react.default.createElement(DirectionalExpandDiagonalIcon, null) : /*#__PURE__*/ react.default.createElement(DirectionalMinimizeDiagonalIcon, null)))), /*#__PURE__*/ react.default.createElement(LayoutDialog.Content, _extends$1({ dividers: true }, dialogContentProps), /*#__PURE__*/ react.default.createElement(_elementor_ui.Collapse, { in: !isMinimized }, dialogContentChildren && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
30161 pt: 2,
30162 px: 2,
30163 pb: 0
30164 } }, dialogContentChildren), attachments.length > 0 && /*#__PURE__*/ react.default.createElement(PromptPowerNotice, null), error && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
30165 pt: 2,
30166 px: 2,
30167 pb: 0
30168 } }, /*#__PURE__*/ react.default.createElement(PromptErrorMessage, {
30169 error,
30170 onRetry: lastRun.current
30171 })), showUnsavedChangesAlert && /*#__PURE__*/ react.default.createElement(UnsavedChangesAlert, {
30172 open: showUnsavedChangesAlert,
30173 title: (0, _wordpress_i18n.__)("Leave Elementor AI?", "elementor"),
30174 text: (0, _wordpress_i18n.__)("Your progress will be deleted, and can't be recovered.", "elementor"),
30175 onClose: abortAndClose,
30176 onCancel: function onCancel() {
30177 return setShowUnsavedChangesAlert(false);
30178 }
30179 }), shouldRenderWebApp && /*#__PURE__*/ react.default.createElement(AttachDialog, {
30180 type: "url",
30181 url: promptInputRef.current.value,
30182 onAttach,
30183 onClose: function onClose() {
30184 setShouldRenderWebApp(false);
30185 }
30186 }), /*#__PURE__*/ react.default.createElement(PromptForm, {
30187 shouldResetPrompt: shouldRenderWebApp,
30188 ref: promptInputRef,
30189 isActive: isPromptFormActive,
30190 isLoading,
30191 showActions: screenshots.length > 0 || isLoading,
30192 attachmentsTypes,
30193 attachments,
30194 onAttach,
30195 onDetach: function onDetach(index) {
30196 setAttachments(function(prev) {
30197 var newAttachments = _toConsumableArray(prev);
30198 newAttachments.splice(index, 1);
30199 return newAttachments;
30200 });
30201 setIsPromptEditable(true);
30202 },
30203 onSubmit: handleGenerate,
30204 onBack: function onBack() {
30205 return setIsPromptEditable(false);
30206 },
30207 onEdit: function onEdit() {
30208 return setIsPromptEditable(true);
30209 }
30210 }), (screenshots.length > 0 || isLoading) && /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Divider, null), /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: { p: 1.5 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
30211 overflow: "hidden",
30212 p: .5
30213 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
30214 display: "flex",
30215 transition: "all 0.4s ease",
30216 gap: "".concat(gapPercentage, "%"),
30217 transform: "translateX(".concat(offsetXPercentage, "%)")
30218 } }, screenshots.map(function(_ref2, index) {
30219 var screenshot = _ref2.screenshot;
30220 var type = _ref2.type;
30221 var template = _ref2.template;
30222 var isError = _ref2.isError;
30223 var isPending = _ref2.isPending;
30224 return /*#__PURE__*/ react.default.createElement(Screenshot, {
30225 key: index,
30226 url: screenshot,
30227 type,
30228 disabled: isPromptFormActive,
30229 isPlaceholder: isError,
30230 isLoading: isPending,
30231 isSelected: selectedScreenshotIndex === index,
30232 onClick: handleScreenshotClick(index, template),
30233 outlineOffset: screenshotOutlineOffset,
30234 sx: { flex: "0 0 ".concat(slideWidthPercentage, "%") }
30235 });
30236 }))), /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, { introductionKey: "ai-context-layout-promotion" })), screenshots.length > 0 && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
30237 sx: {
30238 pt: 0,
30239 px: 2,
30240 pb: 2
30241 },
30242 display: "grid",
30243 gridTemplateColumns: "repeat(3, 1fr)",
30244 justifyItems: "center"
30245 }, /*#__PURE__*/ react.default.createElement(RegenerateButton, {
30246 onClick: handleRegenerate,
30247 disabled: isRegenerateButtonDisabled(screenshots, isLoading, isPromptFormActive),
30248 sx: { justifySelf: "start" }
30249 }), screenshots.length > slidesPerPage && /*#__PURE__*/ react.default.createElement(_elementor_ui.Pagination, {
30250 page: currentPage,
30251 count: pagesCount,
30252 disabled: isPromptFormActive,
30253 onChange: function onChange(_, page) {
30254 return setCurrentPage(page);
30255 }
30256 }), /*#__PURE__*/ react.default.createElement(UseLayoutButton, {
30257 onClick: applyTemplate,
30258 disabled: isPromptFormActive || -1 === selectedScreenshotIndex,
30259 sx: {
30260 justifySelf: "end",
30261 gridColumn: 3
30262 }
30263 }))))));
30264 };
30265 FormLayout.propTypes = {
30266 DialogHeaderProps: import_prop_types$7.default.object,
30267 DialogContentProps: import_prop_types$7.default.object,
30268 attachments: import_prop_types$7.default.arrayOf(AttachmentPropType)
30269 };
30270
30271 //#endregion
30272 //#region modules/ai/assets/js/editor/layout-content.js
30273 init_slicedToArray();
30274 init_loader();
30275 init_requests_ids();
30276 var LayoutContent = function LayoutContent(props) {
30277 var _useUserInfo = useUserInfo();
30278 var isLoading = _useUserInfo.isLoading;
30279 var isConnected = _useUserInfo.isConnected;
30280 var isGetStarted = _useUserInfo.isGetStarted;
30281 var connectUrl = _useUserInfo.connectUrl;
30282 var fetchData = _useUserInfo.fetchData;
30283 var hasSubscription = _useUserInfo.hasSubscription;
30284 var initialUsagePercentage = _useUserInfo.usagePercentage;
30285 var _useConfig = useConfig();
30286 var onClose = _useConfig.onClose;
30287 var onConnect = _useConfig.onConnect;
30288 var _useRequestIds = useRequestIds();
30289 var updateUsagePercentage = _useRequestIds.updateUsagePercentage;
30290 var usagePercentage = _useRequestIds.usagePercentage;
30291 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
30292 var isInitUsageDone = _useState2[0];
30293 var setIsInitUsageDone = _useState2[1];
30294 (0, react.useEffect)(function() {
30295 if (!isInitUsageDone && !isLoading && (initialUsagePercentage || 0 === initialUsagePercentage)) {
30296 updateUsagePercentage(initialUsagePercentage);
30297 setIsInitUsageDone(true);
30298 }
30299 }, [
30300 isLoading,
30301 initialUsagePercentage,
30302 isInitUsageDone,
30303 updateUsagePercentage
30304 ]);
30305 if (isLoading || !isInitUsageDone) return /*#__PURE__*/ react.default.createElement(LayoutDialog, { onClose }, /*#__PURE__*/ react.default.createElement(LayoutDialog.Header, { onClose }), /*#__PURE__*/ react.default.createElement(LayoutDialog.Content, { dividers: true }, /*#__PURE__*/ react.default.createElement(Loader, { BoxProps: { sx: { px: 3 } } })));
30306 if (!isConnected) return /*#__PURE__*/ react.default.createElement(WizardDialog, { onClose }, /*#__PURE__*/ react.default.createElement(LayoutDialog, { onClose }), /*#__PURE__*/ react.default.createElement(WizardDialog.Content, { dividers: true }, /*#__PURE__*/ react.default.createElement(Connect, {
30307 connectUrl,
30308 onSuccess: function onSuccess(data) {
30309 onConnect(data);
30310 fetchData();
30311 }
30312 })));
30313 if (!isGetStarted) return /*#__PURE__*/ react.default.createElement(WizardDialog, { onClose }, /*#__PURE__*/ react.default.createElement(LayoutDialog, { onClose }), /*#__PURE__*/ react.default.createElement(WizardDialog.Content, { dividers: true }, /*#__PURE__*/ react.default.createElement(GetStarted, { onSuccess: fetchData })));
30314 var showUpgradeChip = !hasSubscription || 80 <= usagePercentage;
30315 return /*#__PURE__*/ react.default.createElement(FormLayout, {
30316 attachments: props.attachments,
30317 DialogHeaderProps: { children: showUpgradeChip && /*#__PURE__*/ react.default.createElement(UpgradeChip, {
30318 hasSubscription,
30319 usagePercentage
30320 }) }
30321 });
30322 };
30323 LayoutContent.propTypes = { attachments: import_prop_types$7.default.arrayOf(AttachmentPropType) };
30324
30325 //#endregion
30326 //#region modules/ai/assets/js/editor/layout-app.js
30327 init_requests_ids();
30328 var LayoutApp = function LayoutApp(props) {
30329 return /*#__PURE__*/ react.default.createElement(RemoteConfigProvider, { onError: props.onClose }, /*#__PURE__*/ react.default.createElement(RequestIdsProvider, null, /*#__PURE__*/ react.default.createElement(ConfigProvider, {
30330 mode: props.mode,
30331 attachmentsTypes: props.attachmentsTypes,
30332 onClose: props.onClose,
30333 onConnect: props.onConnect,
30334 onData: props.onData,
30335 onInsert: props.onInsert,
30336 onSelect: props.onSelect,
30337 onGenerate: props.onGenerate,
30338 currentContext: props.currentContext,
30339 hasPro: props.hasPro
30340 }, /*#__PURE__*/ react.default.createElement(LayoutContent, { attachments: props.attachments }))));
30341 };
30342 LayoutApp.propTypes = {
30343 mode: import_prop_types$7.default.oneOf(LAYOUT_APP_MODES).isRequired,
30344 attachmentsTypes: AttachmentsTypesPropType,
30345 attachments: import_prop_types$7.default.arrayOf(AttachmentPropType),
30346 onClose: import_prop_types$7.default.func.isRequired,
30347 onConnect: import_prop_types$7.default.func.isRequired,
30348 onData: import_prop_types$7.default.func.isRequired,
30349 onInsert: import_prop_types$7.default.func.isRequired,
30350 onSelect: import_prop_types$7.default.func.isRequired,
30351 onGenerate: import_prop_types$7.default.func.isRequired,
30352 currentContext: import_prop_types$7.default.object,
30353 hasPro: import_prop_types$7.default.bool
30354 };
30355
30356 //#endregion
30357 //#region modules/ai/assets/js/editor/utils/screenshot.js
30358 init_requests_ids();
30359
30360 //#endregion
30361 //#region modules/ai/assets/js/editor/layout-app-wrapper.js
30362 var LayoutAppWrapper = function LayoutAppWrapper(props) {
30363 return /*#__PURE__*/ react.default.createElement(_elementor_ui.DirectionProvider, { rtl: props.isRTL }, /*#__PURE__*/ react.default.createElement(_elementor_ui.ThemeProvider, { colorScheme: props.colorScheme }, props.children));
30364 };
30365 LayoutAppWrapper.propTypes = {
30366 children: import_prop_types$7.default.node,
30367 isRTL: import_prop_types$7.default.bool,
30368 colorScheme: import_prop_types$7.default.oneOf([
30369 "auto",
30370 "light",
30371 "dark"
30372 ])
30373 };
30374
30375 //#endregion
30376 //#region modules/ai/assets/js/editor/utils/editor-integration.js
30377 init_requests_ids();
30378 var onConnect = function onConnect(data) {
30379 elementorCommon.config.library_connect.is_connected = true;
30380 elementorCommon.config.library_connect.current_access_level = data.kits_access_level || data.access_level || 0;
30381 elementorCommon.config.library_connect.current_access_tier = data.access_tier;
30382 elementorCommon.config.library_connect.plan_type = data.plan_type;
30383 };
30384 var VARIATIONS_PROMPTS = [
30385 { text: (0, _wordpress_i18n.__)("Minimalist design with bold typography about", "elementor") },
30386 { text: (0, _wordpress_i18n.__)("Elegant style with serif fonts discussing", "elementor") },
30387 { text: (0, _wordpress_i18n.__)("Retro vibe with muted colors and classic fonts about", "elementor") },
30388 { text: (0, _wordpress_i18n.__)("Futuristic design with neon accents about", "elementor") },
30389 { text: (0, _wordpress_i18n.__)("Professional look with clean lines for", "elementor") },
30390 { text: (0, _wordpress_i18n.__)("Earthy tones and organic shapes featuring", "elementor") },
30391 { text: (0, _wordpress_i18n.__)("Luxurious theme with rich colors discussing", "elementor") },
30392 { text: (0, _wordpress_i18n.__)("Tech-inspired style with modern fonts about", "elementor") },
30393 { text: (0, _wordpress_i18n.__)("Warm hues with comforting visuals about", "elementor") }
30394 ];
30395 var WEB_BASED_PROMPTS = [
30396 { text: (0, _wordpress_i18n.__)("Change the content to be about [topic]", "elementor") },
30397 { text: (0, _wordpress_i18n.__)("Generate lorem ipsum placeholder text for all paragraphs", "elementor") },
30398 { text: (0, _wordpress_i18n.__)("Revise the content to focus on [topic] and then translate it into Spanish", "elementor") },
30399 { text: (0, _wordpress_i18n.__)("Shift the focus of the content to [topic] in order to showcase our company's mission and values", "elementor") },
30400 { text: (0, _wordpress_i18n.__)("Alter the content to provide helpful tips related to [topic]", "elementor") },
30401 { text: (0, _wordpress_i18n.__)("Adjust the content to include FAQs and answers for common inquiries about [topic]", "elementor") }
30402 ];
30403 var PROMPT_PLACEHOLDER = (0, _wordpress_i18n.__)("Press '/' for suggestions or describe the changes you want to apply (optional)...", "elementor");
30404
30405 //#endregion
30406 //#region modules/ai/assets/js/editor/app.js
30407 init_requests_ids();
30408 var App = function App(props) {
30409 return /*#__PURE__*/ react.default.createElement(_elementor_ui.DirectionProvider, { rtl: props.isRTL }, /*#__PURE__*/ react.default.createElement(_elementor_ui.ThemeProvider, { colorScheme: props.colorScheme }, /*#__PURE__*/ react.default.createElement(RequestIdsProvider, null, /*#__PURE__*/ react.default.createElement(PageContent, {
30410 type: props.type,
30411 controlType: props.controlType,
30412 onClose: props.onClose,
30413 onConnect,
30414 getControlValue: props.getControlValue,
30415 setControlValue: props.setControlValue,
30416 additionalOptions: props.additionalOptions
30417 }))));
30418 };
30419 App.propTypes = {
30420 colorScheme: import_prop_types$7.default.oneOf([
30421 "auto",
30422 "light",
30423 "dark"
30424 ]),
30425 type: import_prop_types$7.default.string,
30426 controlType: import_prop_types$7.default.string,
30427 onClose: import_prop_types$7.default.func,
30428 getControlValue: import_prop_types$7.default.func,
30429 setControlValue: import_prop_types$7.default.func,
30430 additionalOptions: import_prop_types$7.default.object,
30431 isRTL: import_prop_types$7.default.bool
30432 };
30433
30434 //#endregion
30435 //#region modules/ai/assets/js/woocommerce/unify-product-images.js
30436 init_asyncToGenerator();
30437 init_slicedToArray();
30438 var UnifyProductImages = function UnifyProductImages(_ref) {
30439 var productsImages = _ref.productsImages;
30440 var setProductImages = _ref.setProductImages;
30441 var onClose = _ref.onClose;
30442 var _useState2 = _slicedToArray((0, react.useState)(true), 2);
30443 var isOpen = _useState2[0];
30444 var setIsOpen = _useState2[1];
30445 return /*#__PURE__*/ react.default.createElement("div", null, isOpen && /*#__PURE__*/ react.default.createElement(App, {
30446 type: "media",
30447 getControlValue: function getControlValue() {
30448 return { images: productsImages };
30449 },
30450 setControlValue: /*#__PURE__*/ function() {
30451 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(productImage) {
30452 return import_regenerator$2.default.wrap(function(_context) {
30453 while (1) switch (_context.prev = _context.next) {
30454 case 0:
30455 _context.next = 1;
30456 return setProductImages(productImage.url, productImage.image.productId, productImage.id);
30457 case 1: return _context.abrupt("return", _context.sent);
30458 case 2:
30459 case "end": return _context.stop();
30460 }
30461 }, _callee);
30462 }));
30463 return function(_x) {
30464 return _ref2.apply(this, arguments);
30465 };
30466 }(),
30467 onClose: function handleClose() {
30468 setIsOpen(false);
30469 if (onClose) onClose();
30470 },
30471 isRTL: elementorCommon.config.isRTL,
30472 additionalOptions: {
30473 location: LOCATIONS.PRODUCT_IMAGE_UNIFICATION,
30474 withoutHistory: true
30475 }
30476 }));
30477 };
30478 UnifyProductImages.propTypes = {
30479 productsImages: import_prop_types$7.default.arrayOf(import_prop_types$7.default.object),
30480 setProductImages: import_prop_types$7.default.func,
30481 onClose: import_prop_types$7.default.func
30482 };
30483
30484 //#endregion
30485 //#region modules/ai/assets/js/gutenberg/styles.js
30486 var _templateObject;
30487 var _templateObject2;
30488 var Icon = (0, _elementor_ui.styled)("i")(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding-inline-end: 0.5em;\n cursor: pointer;\n color: #C00BB9;\n"])));
30489 var AiLink = (0, _elementor_ui.styled)("a")(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: #C00BB9;\n cursor: pointer;\n font-family: inherit;\n font-size: inherit;\n &:hover {\n text-decoration: underline;\n color: #C00BB9;\n }\n"])));
30490
30491 //#endregion
30492 //#region modules/ai/assets/js/woocommerce/unify-single-product-images.js
30493 init_asyncToGenerator();
30494 init_defineProperty();
30495 init_slicedToArray();
30496 function ownKeys(e, r) {
30497 var t = Object.keys(e);
30498 if (Object.getOwnPropertySymbols) {
30499 var o = Object.getOwnPropertySymbols(e);
30500 r && (o = o.filter(function(r) {
30501 return Object.getOwnPropertyDescriptor(e, r).enumerable;
30502 })), t.push.apply(t, o);
30503 }
30504 return t;
30505 }
30506 function _objectSpread(e) {
30507 for (var r = 1; r < arguments.length; r++) {
30508 var t = null != arguments[r] ? arguments[r] : {};
30509 r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
30510 _defineProperty(e, r, t[r]);
30511 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
30512 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
30513 });
30514 }
30515 return e;
30516 }
30517 var PRODUCT_ID_SEPARATOR = "-img_id-";
30518 var extractImgIds = function extractImgIds(imageIdsStr) {
30519 var parts = imageIdsStr.split(PRODUCT_ID_SEPARATOR);
30520 return 2 === parts.length ? {
30521 productId: parts[0],
30522 imageId: parts[1]
30523 } : {
30524 productId: imageIdsStr,
30525 imageId: null
30526 };
30527 };
30528 var UnifySingleProductImages = function UnifySingleProductImages(_ref) {
30529 var productsImages = _ref.productsImages;
30530 var setProductImages = _ref.setProductImages;
30531 var _onClose = _ref.onClose;
30532 var _ref$isProductGallery = _ref.isProductGallery;
30533 var isProductGallery = _ref$isProductGallery === void 0 ? false : _ref$isProductGallery;
30534 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
30535 var isOpen = _useState2[0];
30536 var setIsOpen = _useState2[1];
30537 var productsImagesDigested = productsImages.map(function(productImage, idx) {
30538 return _objectSpread(_objectSpread({}, productImage), {}, {
30539 productId: "".concat(productImage.productId).concat(PRODUCT_ID_SEPARATOR).concat(productImage.id),
30540 sleepTime: (idx ? idx + 10 : idx) * 10
30541 });
30542 });
30543 return /*#__PURE__*/ react.default.createElement("div", { style: {
30544 padding: "0.6em",
30545 float: "right"
30546 } }, /*#__PURE__*/ react.default.createElement(Icon, { className: "eicon-ai" }), /*#__PURE__*/ react.default.createElement(AiLink, { onClick: function handleButtonClick() {
30547 setIsOpen(true);
30548 } }, (0, _wordpress_i18n.__)("Unify with Elementor AI", "elementor")), isOpen && /*#__PURE__*/ react.default.createElement(UnifyProductImages, {
30549 productsImages: productsImagesDigested,
30550 setProductImages: /*#__PURE__*/ function() {
30551 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(url, currentImageIdsStr, newImage) {
30552 var _extractImgIds;
30553 var productId;
30554 var currentImage;
30555 var product;
30556 return import_regenerator$2.default.wrap(function(_context) {
30557 while (1) switch (_context.prev = _context.next) {
30558 case 0:
30559 _extractImgIds = extractImgIds(currentImageIdsStr), productId = _extractImgIds.productId, currentImage = _extractImgIds.imageId;
30560 product = productsImagesDigested.find(function(productImage) {
30561 return productImage.productId === currentImageIdsStr;
30562 });
30563 _context.next = 1;
30564 return new Promise(function(resolve) {
30565 return setTimeout(resolve, product.sleepTime);
30566 });
30567 case 1:
30568 _context.next = 2;
30569 return setProductImages(url, productId, currentImage, newImage, isProductGallery);
30570 case 2:
30571 case "end": return _context.stop();
30572 }
30573 }, _callee);
30574 }));
30575 return function(_x, _x2, _x3) {
30576 return _ref2.apply(this, arguments);
30577 };
30578 }(),
30579 onClose: function onClose() {
30580 setIsOpen(false);
30581 _onClose();
30582 }
30583 }));
30584 };
30585 UnifySingleProductImages.propTypes = {
30586 productsImages: import_prop_types$7.default.arrayOf(import_prop_types$7.default.object),
30587 setProductImages: import_prop_types$7.default.func,
30588 onClose: import_prop_types$7.default.func,
30589 isProductGallery: import_prop_types$7.default.bool
30590 };
30591
30592 //#endregion
30593 //#region modules/ai/assets/js/woocommerce/index.js
30594 init_asyncToGenerator();
30595 init_requests_ids();
30596 (function() {
30597 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee2($) {
30598 "use strict";
30599 var setProductImages;
30600 var _setProductImages;
30601 var setConfig;
30602 var productThumbnail;
30603 var _response$data2;
30604 var urlParams;
30605 var postId;
30606 var response;
30607 var container;
30608 var wpContentContainer;
30609 var root;
30610 var productGallery;
30611 var _response$data3;
30612 var _urlParams;
30613 var _postId;
30614 var _response;
30615 var _container;
30616 var _wpContentContainer;
30617 var _root;
30618 return import_regenerator$2.default.wrap(function(_context2) {
30619 while (1) switch (_context2.prev = _context2.next) {
30620 case 0:
30621 setConfig = function _setConfig() {
30622 var _window$ElementorAiCo;
30623 window.ElementorAiConfig = (_window$ElementorAiCo = window.ElementorAiConfig) !== null && _window$ElementorAiCo !== void 0 ? _window$ElementorAiCo : {};
30624 window.ElementorAiConfig.is_get_started = window.UnifyProductImagesConfig.is_get_started;
30625 window.ElementorAiConfig.connect_url = window.UnifyProductImagesConfig.connect_url;
30626 };
30627 _setProductImages = function _setProductImages3() {
30628 _setProductImages = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(url, productId) {
30629 var currentImage;
30630 var newImage;
30631 var isProductGallery;
30632 var _args = arguments;
30633 return import_regenerator$2.default.wrap(function(_context) {
30634 while (1) switch (_context.prev = _context.next) {
30635 case 0:
30636 currentImage = _args.length > 2 && _args[2] !== void 0 ? _args[2] : null;
30637 newImage = _args.length > 3 && _args[3] !== void 0 ? _args[3] : null;
30638 isProductGallery = _args.length > 4 && _args[4] !== void 0 ? _args[4] : false;
30639 _context.next = 1;
30640 return $.post(window.UnifyProductImagesConfig.set_product_images_url, {
30641 action: "elementor-ai-set-product-images",
30642 nonce: window.UnifyProductImagesConfig.nonce,
30643 productId,
30644 image_url: url,
30645 image_to_add: newImage,
30646 image_to_remove: currentImage,
30647 is_product_gallery: isProductGallery
30648 }, function(response) {
30649 if (response.success && response.data.refresh) location.reload();
30650 });
30651 case 1:
30652 case "end": return _context.stop();
30653 }
30654 }, _callee);
30655 }));
30656 return _setProductImages.apply(this, arguments);
30657 };
30658 setProductImages = function _setProductImages2(_x2, _x3) {
30659 return _setProductImages.apply(this, arguments);
30660 };
30661 $("#bulk-action-selector-top, #bulk-action-selector-bottom").on("change", function() {
30662 if ("elementor-ai-unify-product-images" === $(this).val()) {
30663 setConfig();
30664 $("#doaction, #doaction2").on("click", function(e) {
30665 try {
30666 e.preventDefault();
30667 var postIds = [];
30668 $("input[name=\"post[]\"]:checked").each(function() {
30669 postIds.push($(this).val());
30670 });
30671 if (!postIds.length) return;
30672 $.post(window.UnifyProductImagesConfig.get_product_images_url, {
30673 action: "elementor-ai-get-product-images",
30674 nonce: window.UnifyProductImagesConfig.nonce,
30675 post_ids: postIds
30676 }, function(response) {
30677 var _response$data;
30678 if (response.success && (_response$data = response.data) !== null && _response$data !== void 0 && (_response$data = _response$data.product_images) !== null && _response$data !== void 0 && _response$data.length) {
30679 window.EDITOR_SESSION_ID = getUniqueId("woocommerce-unify-product-images");
30680 var container = document.createElement("div");
30681 container.id = "e-ai-woocommerce-unify-product-images";
30682 document.querySelector("#wpbody-content").appendChild(container);
30683 (0, import_client.createRoot)(container).render(/*#__PURE__*/ react.default.createElement(UnifyProductImages, {
30684 productsImages: response.data.product_images,
30685 setProductImages,
30686 onClose: function onClose() {
30687 return window.location.reload();
30688 }
30689 }));
30690 }
30691 });
30692 } catch (_) {
30693 $(this).off("click");
30694 }
30695 });
30696 }
30697 });
30698 productThumbnail = $("#postimagediv > .inside");
30699 if (!productThumbnail.length) {
30700 _context2.next = 2;
30701 break;
30702 }
30703 setConfig();
30704 urlParams = new URLSearchParams(window.location.search);
30705 postId = urlParams.get("post");
30706 _context2.next = 1;
30707 return $.post(window.UnifyProductImagesConfig.get_product_images_url, {
30708 action: "elementor-ai-get-product-images",
30709 nonce: window.UnifyProductImagesConfig.nonce,
30710 post_ids: [postId]
30711 });
30712 case 1:
30713 response = _context2.sent;
30714 if (response.success && (_response$data2 = response.data) !== null && _response$data2 !== void 0 && (_response$data2 = _response$data2.product_images) !== null && _response$data2 !== void 0 && _response$data2.length) {
30715 window.EDITOR_SESSION_ID = getUniqueId("woocommerce-unify-single-product-image");
30716 container = document.createElement("div");
30717 container.id = "e-ai-woocommerce-unify-single-product-image";
30718 container.style.width = "100%";
30719 container.style.height = "auto";
30720 container.style.overflow = "hidden";
30721 wpContentContainer = productThumbnail[0];
30722 wpContentContainer.insertBefore(container, wpContentContainer.firstChild);
30723 root = (0, import_client.createRoot)(container);
30724 root.render(/*#__PURE__*/ react.default.createElement(UnifySingleProductImages, {
30725 productsImages: response.data.product_images,
30726 setProductImages,
30727 onClose: function onClose() {
30728 return window.location.reload();
30729 }
30730 }));
30731 }
30732 case 2:
30733 productGallery = $("#woocommerce-product-images > .inside");
30734 if (!productGallery.length) {
30735 _context2.next = 4;
30736 break;
30737 }
30738 setConfig();
30739 _urlParams = new URLSearchParams(window.location.search);
30740 _postId = _urlParams.get("post");
30741 _context2.next = 3;
30742 return $.post(window.UnifyProductImagesConfig.get_product_images_url, {
30743 action: "elementor-ai-get-product-images",
30744 nonce: window.UnifyProductImagesConfig.nonce,
30745 post_ids: [_postId],
30746 is_galley_only: true
30747 });
30748 case 3:
30749 _response = _context2.sent;
30750 if (_response.success && (_response$data3 = _response.data) !== null && _response$data3 !== void 0 && (_response$data3 = _response$data3.product_images) !== null && _response$data3 !== void 0 && _response$data3.length) {
30751 window.EDITOR_SESSION_ID = getUniqueId("woocommerce-unify-single-product-images");
30752 _container = document.createElement("div");
30753 _container.id = "e-ai-woocommerce-unify-single-product-images";
30754 _container.style.width = "100%";
30755 _container.style.height = "auto";
30756 _container.style.overflow = "hidden";
30757 _wpContentContainer = productGallery[0];
30758 _wpContentContainer.insertBefore(_container, _wpContentContainer.firstChild);
30759 _root = (0, import_client.createRoot)(_container);
30760 _root.render(/*#__PURE__*/ react.default.createElement(UnifySingleProductImages, {
30761 productsImages: _response.data.product_images,
30762 setProductImages,
30763 onClose: function onClose() {
30764 return window.location.reload();
30765 },
30766 isProductGallery: true
30767 }));
30768 }
30769 case 4:
30770 case "end": return _context2.stop();
30771 }
30772 }, _callee2);
30773 }));
30774 return function(_x) {
30775 return _ref.apply(this, arguments);
30776 };
30777 })()(jQuery);
30778
30779 //#endregion
30780 })(React, elementorV2.ui, wp.i18n, elementorV2.icons, elementorV2.ui['TextField']);
30781 //# sourceMappingURL=ai-unify-product-images.js.map