PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0
Elementor Website Builder – more than just a page builder v4.3.0
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 4.0.8 4.1.0-beta1 All 453 releases
elementor / assets / js / ai-gutenberg.js

ai-gutenberg.js in Elementor Website Builder – more than just a page builder 4.3.0, at assets/js/ai-gutenberg.js

31,064 lines 1.0 MB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function(react, _wordpress_i18n, _elementor_ui, _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/extends.js
61 function _extends$1() {
62 return _extends$1 = Object.assign ? Object.assign.bind() : function(n) {
63 for (var e = 1; e < arguments.length; e++) {
64 var t = arguments[e];
65 for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
66 }
67 return n;
68 }, _extends$1.apply(null, arguments);
69 }
70 var init_extends = __esmMin((() => {
71 __name(_extends$1, "_extends");
72 }));
73
74 //#endregion
75 //#region \0@[email protected]/helpers/esm/objectWithoutPropertiesLoose.js
76 function _objectWithoutPropertiesLoose$1(r, e) {
77 if (null == r) return {};
78 var t = {};
79 for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
80 if (e.includes(n)) continue;
81 t[n] = r[n];
82 }
83 return t;
84 }
85 var init_objectWithoutPropertiesLoose$1 = __esmMin((() => {
86 __name(_objectWithoutPropertiesLoose$1, "_objectWithoutPropertiesLoose");
87 }));
88
89 //#endregion
90 //#region \0@[email protected]/helpers/esm/objectWithoutProperties.js
91 function _objectWithoutProperties$1(e, t) {
92 if (null == e) return {};
93 var o;
94 var r;
95 var i = _objectWithoutPropertiesLoose$1(e, t);
96 if (Object.getOwnPropertySymbols) {
97 var s = Object.getOwnPropertySymbols(e);
98 for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
99 }
100 return i;
101 }
102 var init_objectWithoutProperties$1 = __esmMin((() => {
103 init_objectWithoutPropertiesLoose$1();
104 __name(_objectWithoutProperties$1, "_objectWithoutProperties");
105 }));
106
107 //#endregion
108 //#region \0@[email protected]/helpers/esm/typeof.js
109 function _typeof$1(o) {
110 "@babel/helpers - typeof";
111 return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
112 return typeof o;
113 } : function(o) {
114 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
115 }, _typeof$1(o);
116 }
117 var init_typeof$1 = __esmMin((() => {
118 __name(_typeof$1, "_typeof");
119 }));
120
121 //#endregion
122 //#region \0@[email protected]/helpers/esm/toPrimitive.js
123 function toPrimitive$1(t, r) {
124 if ("object" != _typeof$1(t) || !t) return t;
125 var e = t[Symbol.toPrimitive];
126 if (void 0 !== e) {
127 var i = e.call(t, r || "default");
128 if ("object" != _typeof$1(i)) return i;
129 throw new TypeError("@@toPrimitive must return a primitive value.");
130 }
131 return ("string" === r ? String : Number)(t);
132 }
133 var init_toPrimitive$1 = __esmMin((() => {
134 init_typeof$1();
135 __name(toPrimitive$1, "toPrimitive");
136 }));
137
138 //#endregion
139 //#region \0@[email protected]/helpers/esm/toPropertyKey.js
140 function toPropertyKey$1(t) {
141 var i = toPrimitive$1(t, "string");
142 return "symbol" == _typeof$1(i) ? i : i + "";
143 }
144 var init_toPropertyKey$1 = __esmMin((() => {
145 init_typeof$1();
146 init_toPrimitive$1();
147 __name(toPropertyKey$1, "toPropertyKey");
148 }));
149
150 //#endregion
151 //#region \0@[email protected]/helpers/esm/defineProperty.js
152 function _defineProperty$1(e, r, t) {
153 return (r = toPropertyKey$1(r)) in e ? Object.defineProperty(e, r, {
154 value: t,
155 enumerable: !0,
156 configurable: !0,
157 writable: !0
158 }) : e[r] = t, e;
159 }
160 var init_defineProperty$1 = __esmMin((() => {
161 init_toPropertyKey$1();
162 __name(_defineProperty$1, "_defineProperty");
163 }));
164
165 //#endregion
166 //#region \0@[email protected]/helpers/esm/objectSpread2.js
167 function ownKeys$33(e, r) {
168 var t = Object.keys(e);
169 if (Object.getOwnPropertySymbols) {
170 var o = Object.getOwnPropertySymbols(e);
171 r && (o = o.filter(function(r) {
172 return Object.getOwnPropertyDescriptor(e, r).enumerable;
173 })), t.push.apply(t, o);
174 }
175 return t;
176 }
177 function _objectSpread2(e) {
178 for (var r = 1; r < arguments.length; r++) {
179 var t = null != arguments[r] ? arguments[r] : {};
180 r % 2 ? ownKeys$33(Object(t), !0).forEach(function(r) {
181 _defineProperty$1(e, r, t[r]);
182 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$33(Object(t)).forEach(function(r) {
183 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
184 });
185 }
186 return e;
187 }
188 var init_objectSpread2 = __esmMin((() => {
189 init_defineProperty$1();
190 __name(ownKeys$33, "ownKeys");
191 }));
192
193 //#endregion
194 //#region node_modules/react-dom/client.js
195 var require_client = /* @__PURE__ */ __commonJSMin(((exports) => {
196 var m$1 = (globalThis.ReactDOM);
197 var i = m$1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
198 exports.createRoot = function(c, o) {
199 i.usingClientEntryPoint = true;
200 try {
201 return m$1.createRoot(c, o);
202 } finally {
203 i.usingClientEntryPoint = false;
204 }
205 };
206 }));
207
208 //#endregion
209 //#region node_modules/@wordpress/element/build-module/react-platform.js
210 /**
211 * External dependencies
212 */
213 var import_client = require_client();
214
215 //#endregion
216 //#region node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
217 function _arrayWithHoles(r) {
218 if (Array.isArray(r)) return r;
219 }
220 var init_arrayWithHoles = __esmMin((() => {}));
221
222 //#endregion
223 //#region node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
224 function _iterableToArrayLimit(r, l) {
225 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
226 if (null != t) {
227 var e;
228 var n;
229 var i;
230 var u;
231 var a = [];
232 var f = !0;
233 var o = !1;
234 try {
235 if (i = (t = t.call(r)).next, 0 === l) {
236 if (Object(t) !== t) return;
237 f = !1;
238 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
239 } catch (r) {
240 o = !0, n = r;
241 } finally {
242 try {
243 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
244 } finally {
245 if (o) throw n;
246 }
247 }
248 return a;
249 }
250 }
251 var init_iterableToArrayLimit = __esmMin((() => {}));
252
253 //#endregion
254 //#region node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
255 function _arrayLikeToArray$3(r, a) {
256 (null == a || a > r.length) && (a = r.length);
257 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
258 return n;
259 }
260 var init_arrayLikeToArray = __esmMin((() => {
261 __name(_arrayLikeToArray$3, "_arrayLikeToArray");
262 }));
263
264 //#endregion
265 //#region node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
266 function _unsupportedIterableToArray$3(r, a) {
267 if (r) {
268 if ("string" == typeof r) return _arrayLikeToArray$3(r, a);
269 var t = {}.toString.call(r).slice(8, -1);
270 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$3(r, a) : void 0;
271 }
272 }
273 var init_unsupportedIterableToArray = __esmMin((() => {
274 init_arrayLikeToArray();
275 __name(_unsupportedIterableToArray$3, "_unsupportedIterableToArray");
276 }));
277
278 //#endregion
279 //#region node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
280 function _nonIterableRest() {
281 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
282 }
283 var init_nonIterableRest = __esmMin((() => {}));
284
285 //#endregion
286 //#region node_modules/@babel/runtime/helpers/esm/slicedToArray.js
287 function _slicedToArray(r, e) {
288 return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$3(r, e) || _nonIterableRest();
289 }
290 var init_slicedToArray = __esmMin((() => {
291 init_arrayWithHoles();
292 init_iterableToArrayLimit();
293 init_unsupportedIterableToArray();
294 init_nonIterableRest();
295 }));
296
297 //#endregion
298 //#region node_modules/prop-types/node_modules/react-is/cjs/react-is.development.js
299 /** @license React v16.13.1
300 * react-is.development.js
301 *
302 * Copyright (c) Facebook, Inc. and its affiliates.
303 *
304 * This source code is licensed under the MIT license found in the
305 * LICENSE file in the root directory of this source tree.
306 */
307 var require_react_is_development$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
308 (function() {
309 "use strict";
310 var hasSymbol = typeof Symbol === "function" && Symbol.for;
311 var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103;
312 var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106;
313 var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107;
314 var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108;
315 var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114;
316 var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109;
317 var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110;
318 var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for("react.async_mode") : 60111;
319 var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for("react.concurrent_mode") : 60111;
320 var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112;
321 var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113;
322 var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for("react.suspense_list") : 60120;
323 var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115;
324 var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116;
325 var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121;
326 var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for("react.fundamental") : 60117;
327 var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for("react.responder") : 60118;
328 var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for("react.scope") : 60119;
329 function isValidElementType(type) {
330 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);
331 }
332 function typeOf(object) {
333 if (typeof object === "object" && object !== null) {
334 var $$typeof = object.$$typeof;
335 switch ($$typeof) {
336 case REACT_ELEMENT_TYPE:
337 var type = object.type;
338 switch (type) {
339 case REACT_ASYNC_MODE_TYPE:
340 case REACT_CONCURRENT_MODE_TYPE:
341 case REACT_FRAGMENT_TYPE:
342 case REACT_PROFILER_TYPE:
343 case REACT_STRICT_MODE_TYPE:
344 case REACT_SUSPENSE_TYPE: return type;
345 default:
346 var $$typeofType = type && type.$$typeof;
347 switch ($$typeofType) {
348 case REACT_CONTEXT_TYPE:
349 case REACT_FORWARD_REF_TYPE:
350 case REACT_LAZY_TYPE:
351 case REACT_MEMO_TYPE:
352 case REACT_PROVIDER_TYPE: return $$typeofType;
353 default: return $$typeof;
354 }
355 }
356 case REACT_PORTAL_TYPE: return $$typeof;
357 }
358 }
359 }
360 var AsyncMode = REACT_ASYNC_MODE_TYPE;
361 var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
362 var ContextConsumer = REACT_CONTEXT_TYPE;
363 var ContextProvider = REACT_PROVIDER_TYPE;
364 var Element = REACT_ELEMENT_TYPE;
365 var ForwardRef = REACT_FORWARD_REF_TYPE;
366 var Fragment = REACT_FRAGMENT_TYPE;
367 var Lazy = REACT_LAZY_TYPE;
368 var Memo = REACT_MEMO_TYPE;
369 var Portal = REACT_PORTAL_TYPE;
370 var Profiler = REACT_PROFILER_TYPE;
371 var StrictMode = REACT_STRICT_MODE_TYPE;
372 var Suspense = REACT_SUSPENSE_TYPE;
373 var hasWarnedAboutDeprecatedIsAsyncMode = false;
374 function isAsyncMode(object) {
375 if (!hasWarnedAboutDeprecatedIsAsyncMode) {
376 hasWarnedAboutDeprecatedIsAsyncMode = true;
377 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.");
378 }
379 return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
380 }
381 function isConcurrentMode(object) {
382 return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
383 }
384 function isContextConsumer(object) {
385 return typeOf(object) === REACT_CONTEXT_TYPE;
386 }
387 function isContextProvider(object) {
388 return typeOf(object) === REACT_PROVIDER_TYPE;
389 }
390 function isElement(object) {
391 return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
392 }
393 function isForwardRef(object) {
394 return typeOf(object) === REACT_FORWARD_REF_TYPE;
395 }
396 function isFragment(object) {
397 return typeOf(object) === REACT_FRAGMENT_TYPE;
398 }
399 function isLazy(object) {
400 return typeOf(object) === REACT_LAZY_TYPE;
401 }
402 function isMemo(object) {
403 return typeOf(object) === REACT_MEMO_TYPE;
404 }
405 function isPortal(object) {
406 return typeOf(object) === REACT_PORTAL_TYPE;
407 }
408 function isProfiler(object) {
409 return typeOf(object) === REACT_PROFILER_TYPE;
410 }
411 function isStrictMode(object) {
412 return typeOf(object) === REACT_STRICT_MODE_TYPE;
413 }
414 function isSuspense(object) {
415 return typeOf(object) === REACT_SUSPENSE_TYPE;
416 }
417 exports.AsyncMode = AsyncMode;
418 exports.ConcurrentMode = ConcurrentMode;
419 exports.ContextConsumer = ContextConsumer;
420 exports.ContextProvider = ContextProvider;
421 exports.Element = Element;
422 exports.ForwardRef = ForwardRef;
423 exports.Fragment = Fragment;
424 exports.Lazy = Lazy;
425 exports.Memo = Memo;
426 exports.Portal = Portal;
427 exports.Profiler = Profiler;
428 exports.StrictMode = StrictMode;
429 exports.Suspense = Suspense;
430 exports.isAsyncMode = isAsyncMode;
431 exports.isConcurrentMode = isConcurrentMode;
432 exports.isContextConsumer = isContextConsumer;
433 exports.isContextProvider = isContextProvider;
434 exports.isElement = isElement;
435 exports.isForwardRef = isForwardRef;
436 exports.isFragment = isFragment;
437 exports.isLazy = isLazy;
438 exports.isMemo = isMemo;
439 exports.isPortal = isPortal;
440 exports.isProfiler = isProfiler;
441 exports.isStrictMode = isStrictMode;
442 exports.isSuspense = isSuspense;
443 exports.isValidElementType = isValidElementType;
444 exports.typeOf = typeOf;
445 })();
446 }));
447
448 //#endregion
449 //#region node_modules/prop-types/node_modules/react-is/index.js
450 var require_react_is$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
451 module.exports = require_react_is_development$1();
452 }));
453
454 //#endregion
455 //#region node_modules/object-assign/index.js
456 /*
457 object-assign
458 (c) Sindre Sorhus
459 @license MIT
460 */
461 var require_object_assign = /* @__PURE__ */ __commonJSMin(((exports, module) => {
462 var getOwnPropertySymbols = Object.getOwnPropertySymbols;
463 var hasOwnProperty = Object.prototype.hasOwnProperty;
464 var propIsEnumerable = Object.prototype.propertyIsEnumerable;
465 function toObject(val) {
466 if (val === null || val === void 0) throw new TypeError("Object.assign cannot be called with null or undefined");
467 return Object(val);
468 }
469 function shouldUseNative() {
470 try {
471 if (!Object.assign) return false;
472 var test1 = /* @__PURE__ */ new String("abc");
473 test1[5] = "de";
474 if (Object.getOwnPropertyNames(test1)[0] === "5") return false;
475 var test2 = {};
476 for (var i = 0; i < 10; i++) test2["_" + String.fromCharCode(i)] = i;
477 if (Object.getOwnPropertyNames(test2).map(function(n) {
478 return test2[n];
479 }).join("") !== "0123456789") return false;
480 var test3 = {};
481 "abcdefghijklmnopqrst".split("").forEach(function(letter) {
482 test3[letter] = letter;
483 });
484 if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") return false;
485 return true;
486 } catch (err) {
487 return false;
488 }
489 }
490 module.exports = shouldUseNative() ? Object.assign : function(target, source) {
491 var from;
492 var to = toObject(target);
493 var symbols;
494 for (var s = 1; s < arguments.length; s++) {
495 from = Object(arguments[s]);
496 for (var key in from) if (hasOwnProperty.call(from, key)) to[key] = from[key];
497 if (getOwnPropertySymbols) {
498 symbols = getOwnPropertySymbols(from);
499 for (var i = 0; i < symbols.length; i++) if (propIsEnumerable.call(from, symbols[i])) to[symbols[i]] = from[symbols[i]];
500 }
501 }
502 return to;
503 };
504 }));
505
506 //#endregion
507 //#region node_modules/prop-types/lib/ReactPropTypesSecret.js
508 /**
509 * Copyright (c) 2013-present, Facebook, Inc.
510 *
511 * This source code is licensed under the MIT license found in the
512 * LICENSE file in the root directory of this source tree.
513 */
514 var require_ReactPropTypesSecret = /* @__PURE__ */ __commonJSMin(((exports, module) => {
515 var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
516 module.exports = ReactPropTypesSecret;
517 }));
518
519 //#endregion
520 //#region node_modules/prop-types/lib/has.js
521 var require_has = /* @__PURE__ */ __commonJSMin(((exports, module) => {
522 module.exports = Function.call.bind(Object.prototype.hasOwnProperty);
523 }));
524
525 //#endregion
526 //#region node_modules/prop-types/checkPropTypes.js
527 /**
528 * Copyright (c) 2013-present, Facebook, Inc.
529 *
530 * This source code is licensed under the MIT license found in the
531 * LICENSE file in the root directory of this source tree.
532 */
533 var require_checkPropTypes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
534 var printWarning = function() {};
535 var ReactPropTypesSecret = require_ReactPropTypesSecret();
536 var loggedTypeFailures = {};
537 var has = require_has();
538 printWarning = function(text) {
539 var message = "Warning: " + text;
540 if (typeof console !== "undefined") console.error(message);
541 try {
542 throw new Error(message);
543 } catch (x) {}
544 };
545 /**
546 * Assert that the values match with the type specs.
547 * Error messages are memorized and will only be shown once.
548 *
549 * @param {object} typeSpecs Map of name to a ReactPropType
550 * @param {object} values Runtime values that need to be type-checked
551 * @param {string} location e.g. "prop", "context", "child context"
552 * @param {string} componentName Name of the component for error messages.
553 * @param {?Function} getStack Returns the component stack.
554 * @private
555 */
556 function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
557 for (var typeSpecName in typeSpecs) if (has(typeSpecs, typeSpecName)) {
558 var error;
559 try {
560 if (typeof typeSpecs[typeSpecName] !== "function") {
561 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`.");
562 err.name = "Invariant Violation";
563 throw err;
564 }
565 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
566 } catch (ex) {
567 error = ex;
568 }
569 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).");
570 if (error instanceof Error && !(error.message in loggedTypeFailures)) {
571 loggedTypeFailures[error.message] = true;
572 var stack = getStack ? getStack() : "";
573 printWarning("Failed " + location + " type: " + error.message + (stack != null ? stack : ""));
574 }
575 }
576 }
577 /**
578 * Resets warning cache when testing.
579 *
580 * @private
581 */
582 checkPropTypes.resetWarningCache = function() {
583 loggedTypeFailures = {};
584 };
585 module.exports = checkPropTypes;
586 }));
587
588 //#endregion
589 //#region node_modules/prop-types/factoryWithTypeCheckers.js
590 /**
591 * Copyright (c) 2013-present, Facebook, Inc.
592 *
593 * This source code is licensed under the MIT license found in the
594 * LICENSE file in the root directory of this source tree.
595 */
596 var require_factoryWithTypeCheckers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
597 var ReactIs = require_react_is$1();
598 var assign = require_object_assign();
599 var ReactPropTypesSecret = require_ReactPropTypesSecret();
600 var has = require_has();
601 var checkPropTypes = require_checkPropTypes();
602 var printWarning = function() {};
603 printWarning = function(text) {
604 var message = "Warning: " + text;
605 if (typeof console !== "undefined") console.error(message);
606 try {
607 throw new Error(message);
608 } catch (x) {}
609 };
610 function emptyFunctionThatReturnsNull() {
611 return null;
612 }
613 module.exports = function(isValidElement, throwOnDirectAccess) {
614 var ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
615 var FAUX_ITERATOR_SYMBOL = "@@iterator";
616 /**
617 * Returns the iterator method function contained on the iterable object.
618 *
619 * Be sure to invoke the function with the iterable as context:
620 *
621 * var iteratorFn = getIteratorFn(myIterable);
622 * if (iteratorFn) {
623 * var iterator = iteratorFn.call(myIterable);
624 * ...
625 * }
626 *
627 * @param {?object} maybeIterable
628 * @return {?function}
629 */
630 function getIteratorFn(maybeIterable) {
631 var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
632 if (typeof iteratorFn === "function") return iteratorFn;
633 }
634 /**
635 * Collection of methods that allow declaration and validation of props that are
636 * supplied to React components. Example usage:
637 *
638 * var Props = require('ReactPropTypes');
639 * var MyArticle = React.createClass({
640 * propTypes: {
641 * // An optional string prop named "description".
642 * description: Props.string,
643 *
644 * // A required enum prop named "category".
645 * category: Props.oneOf(['News','Photos']).isRequired,
646 *
647 * // A prop named "dialog" that requires an instance of Dialog.
648 * dialog: Props.instanceOf(Dialog).isRequired
649 * },
650 * render: function() { ... }
651 * });
652 *
653 * A more formal specification of how these methods are used:
654 *
655 * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
656 * decl := ReactPropTypes.{type}(.isRequired)?
657 *
658 * Each and every declaration produces a function with the same signature. This
659 * allows the creation of custom validation functions. For example:
660 *
661 * var MyLink = React.createClass({
662 * propTypes: {
663 * // An optional string or URI prop named "href".
664 * href: function(props, propName, componentName) {
665 * var propValue = props[propName];
666 * if (propValue != null && typeof propValue !== 'string' &&
667 * !(propValue instanceof URI)) {
668 * return new Error(
669 * 'Expected a string or an URI for ' + propName + ' in ' +
670 * componentName
671 * );
672 * }
673 * }
674 * },
675 * render: function() {...}
676 * });
677 *
678 * @internal
679 */
680 var ANONYMOUS = "<<anonymous>>";
681 var ReactPropTypes = {
682 array: createPrimitiveTypeChecker("array"),
683 bigint: createPrimitiveTypeChecker("bigint"),
684 bool: createPrimitiveTypeChecker("boolean"),
685 func: createPrimitiveTypeChecker("function"),
686 number: createPrimitiveTypeChecker("number"),
687 object: createPrimitiveTypeChecker("object"),
688 string: createPrimitiveTypeChecker("string"),
689 symbol: createPrimitiveTypeChecker("symbol"),
690 any: createAnyTypeChecker(),
691 arrayOf: createArrayOfTypeChecker,
692 element: createElementTypeChecker(),
693 elementType: createElementTypeTypeChecker(),
694 instanceOf: createInstanceTypeChecker,
695 node: createNodeChecker(),
696 objectOf: createObjectOfTypeChecker,
697 oneOf: createEnumTypeChecker,
698 oneOfType: createUnionTypeChecker,
699 shape: createShapeTypeChecker,
700 exact: createStrictShapeTypeChecker
701 };
702 /**
703 * inlined Object.is polyfill to avoid requiring consumers ship their own
704 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
705 */
706 function is(x, y) {
707 if (x === y) return x !== 0 || 1 / x === 1 / y;
708 else return x !== x && y !== y;
709 }
710 /**
711 * We use an Error-like object for backward compatibility as people may call
712 * PropTypes directly and inspect their output. However, we don't use real
713 * Errors anymore. We don't inspect their stack anyway, and creating them
714 * is prohibitively expensive if they are created too often, such as what
715 * happens in oneOfType() for any type before the one that matched.
716 */
717 function PropTypeError(message, data) {
718 this.message = message;
719 this.data = data && typeof data === "object" ? data : {};
720 this.stack = "";
721 }
722 PropTypeError.prototype = Error.prototype;
723 function createChainableTypeChecker(validate) {
724 var manualPropTypeCallCache = {};
725 var manualPropTypeWarningCount = 0;
726 function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
727 componentName = componentName || ANONYMOUS;
728 propFullName = propFullName || propName;
729 if (secret !== ReactPropTypesSecret) {
730 if (throwOnDirectAccess) {
731 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");
732 err.name = "Invariant Violation";
733 throw err;
734 } else if (typeof console !== "undefined") {
735 var cacheKey = componentName + ":" + propName;
736 if (!manualPropTypeCallCache[cacheKey] && manualPropTypeWarningCount < 3) {
737 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.");
738 manualPropTypeCallCache[cacheKey] = true;
739 manualPropTypeWarningCount++;
740 }
741 }
742 }
743 if (props[propName] == null) {
744 if (isRequired) {
745 if (props[propName] === null) return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required " + ("in `" + componentName + "`, but its value is `null`."));
746 return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required in " + ("`" + componentName + "`, but its value is `undefined`."));
747 }
748 return null;
749 } else return validate(props, propName, componentName, location, propFullName);
750 }
751 var chainedCheckType = checkType.bind(null, false);
752 chainedCheckType.isRequired = checkType.bind(null, true);
753 return chainedCheckType;
754 }
755 function createPrimitiveTypeChecker(expectedType) {
756 function validate(props, propName, componentName, location, propFullName, secret) {
757 var propValue = props[propName];
758 if (getPropType(propValue) !== expectedType) {
759 var preciseType = getPreciseType(propValue);
760 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + preciseType + "` supplied to `" + componentName + "`, expected ") + ("`" + expectedType + "`."), { expectedType });
761 }
762 return null;
763 }
764 return createChainableTypeChecker(validate);
765 }
766 function createAnyTypeChecker() {
767 return createChainableTypeChecker(emptyFunctionThatReturnsNull);
768 }
769 function createArrayOfTypeChecker(typeChecker) {
770 function validate(props, propName, componentName, location, propFullName) {
771 if (typeof typeChecker !== "function") return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside arrayOf.");
772 var propValue = props[propName];
773 if (!Array.isArray(propValue)) {
774 var propType = getPropType(propValue);
775 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an array."));
776 }
777 for (var i = 0; i < propValue.length; i++) {
778 var error = typeChecker(propValue, i, componentName, location, propFullName + "[" + i + "]", ReactPropTypesSecret);
779 if (error instanceof Error) return error;
780 }
781 return null;
782 }
783 return createChainableTypeChecker(validate);
784 }
785 function createElementTypeChecker() {
786 function validate(props, propName, componentName, location, propFullName) {
787 var propValue = props[propName];
788 if (!isValidElement(propValue)) {
789 var propType = getPropType(propValue);
790 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement."));
791 }
792 return null;
793 }
794 return createChainableTypeChecker(validate);
795 }
796 function createElementTypeTypeChecker() {
797 function validate(props, propName, componentName, location, propFullName) {
798 var propValue = props[propName];
799 if (!ReactIs.isValidElementType(propValue)) {
800 var propType = getPropType(propValue);
801 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement type."));
802 }
803 return null;
804 }
805 return createChainableTypeChecker(validate);
806 }
807 function createInstanceTypeChecker(expectedClass) {
808 function validate(props, propName, componentName, location, propFullName) {
809 if (!(props[propName] instanceof expectedClass)) {
810 var expectedClassName = expectedClass.name || ANONYMOUS;
811 var actualClassName = getClassName(props[propName]);
812 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + actualClassName + "` supplied to `" + componentName + "`, expected ") + ("instance of `" + expectedClassName + "`."));
813 }
814 return null;
815 }
816 return createChainableTypeChecker(validate);
817 }
818 function createEnumTypeChecker(expectedValues) {
819 if (!Array.isArray(expectedValues)) {
820 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]).");
821 else printWarning("Invalid argument supplied to oneOf, expected an array.");
822 return emptyFunctionThatReturnsNull;
823 }
824 function validate(props, propName, componentName, location, propFullName) {
825 var propValue = props[propName];
826 for (var i = 0; i < expectedValues.length; i++) if (is(propValue, expectedValues[i])) return null;
827 var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
828 if (getPreciseType(value) === "symbol") return String(value);
829 return value;
830 });
831 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of value `" + String(propValue) + "` " + ("supplied to `" + componentName + "`, expected one of " + valuesString + "."));
832 }
833 return createChainableTypeChecker(validate);
834 }
835 function createObjectOfTypeChecker(typeChecker) {
836 function validate(props, propName, componentName, location, propFullName) {
837 if (typeof typeChecker !== "function") return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside objectOf.");
838 var propValue = props[propName];
839 var propType = getPropType(propValue);
840 if (propType !== "object") return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an object."));
841 for (var key in propValue) if (has(propValue, key)) {
842 var error = typeChecker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
843 if (error instanceof Error) return error;
844 }
845 return null;
846 }
847 return createChainableTypeChecker(validate);
848 }
849 function createUnionTypeChecker(arrayOfTypeCheckers) {
850 if (!Array.isArray(arrayOfTypeCheckers)) {
851 printWarning("Invalid argument supplied to oneOfType, expected an instance of array.");
852 return emptyFunctionThatReturnsNull;
853 }
854 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
855 var checker = arrayOfTypeCheckers[i];
856 if (typeof checker !== "function") {
857 printWarning("Invalid argument supplied to oneOfType. Expected an array of check functions, but received " + getPostfixForTypeWarning(checker) + " at index " + i + ".");
858 return emptyFunctionThatReturnsNull;
859 }
860 }
861 function validate(props, propName, componentName, location, propFullName) {
862 var expectedTypes = [];
863 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
864 var checker = arrayOfTypeCheckers[i];
865 var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
866 if (checkerResult == null) return null;
867 if (checkerResult.data && has(checkerResult.data, "expectedType")) expectedTypes.push(checkerResult.data.expectedType);
868 }
869 var expectedTypesMessage = expectedTypes.length > 0 ? ", expected one of type [" + expectedTypes.join(", ") + "]" : "";
870 return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`" + expectedTypesMessage + "."));
871 }
872 return createChainableTypeChecker(validate);
873 }
874 function createNodeChecker() {
875 function validate(props, propName, componentName, location, propFullName) {
876 if (!isNode(props[propName])) return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`, expected a ReactNode."));
877 return null;
878 }
879 return createChainableTypeChecker(validate);
880 }
881 function invalidValidatorError(componentName, location, propFullName, key, type) {
882 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 + "`.");
883 }
884 function createShapeTypeChecker(shapeTypes) {
885 function validate(props, propName, componentName, location, propFullName) {
886 var propValue = props[propName];
887 var propType = getPropType(propValue);
888 if (propType !== "object") return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
889 for (var key in shapeTypes) {
890 var checker = shapeTypes[key];
891 if (typeof checker !== "function") return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
892 var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
893 if (error) return error;
894 }
895 return null;
896 }
897 return createChainableTypeChecker(validate);
898 }
899 function createStrictShapeTypeChecker(shapeTypes) {
900 function validate(props, propName, componentName, location, propFullName) {
901 var propValue = props[propName];
902 var propType = getPropType(propValue);
903 if (propType !== "object") return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
904 for (var key in assign({}, props[propName], shapeTypes)) {
905 var checker = shapeTypes[key];
906 if (has(shapeTypes, key) && typeof checker !== "function") return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
907 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, " "));
908 var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
909 if (error) return error;
910 }
911 return null;
912 }
913 return createChainableTypeChecker(validate);
914 }
915 function isNode(propValue) {
916 switch (typeof propValue) {
917 case "number":
918 case "string":
919 case "undefined": return true;
920 case "boolean": return !propValue;
921 case "object":
922 if (Array.isArray(propValue)) return propValue.every(isNode);
923 if (propValue === null || isValidElement(propValue)) return true;
924 var iteratorFn = getIteratorFn(propValue);
925 if (iteratorFn) {
926 var iterator = iteratorFn.call(propValue);
927 var step;
928 if (iteratorFn !== propValue.entries) {
929 while (!(step = iterator.next()).done) if (!isNode(step.value)) return false;
930 } else while (!(step = iterator.next()).done) {
931 var entry = step.value;
932 if (entry) {
933 if (!isNode(entry[1])) return false;
934 }
935 }
936 } else return false;
937 return true;
938 default: return false;
939 }
940 }
941 function isSymbol(propType, propValue) {
942 if (propType === "symbol") return true;
943 if (!propValue) return false;
944 if (propValue["@@toStringTag"] === "Symbol") return true;
945 if (typeof Symbol === "function" && propValue instanceof Symbol) return true;
946 return false;
947 }
948 function getPropType(propValue) {
949 var propType = typeof propValue;
950 if (Array.isArray(propValue)) return "array";
951 if (propValue instanceof RegExp) return "object";
952 if (isSymbol(propType, propValue)) return "symbol";
953 return propType;
954 }
955 function getPreciseType(propValue) {
956 if (typeof propValue === "undefined" || propValue === null) return "" + propValue;
957 var propType = getPropType(propValue);
958 if (propType === "object") {
959 if (propValue instanceof Date) return "date";
960 else if (propValue instanceof RegExp) return "regexp";
961 }
962 return propType;
963 }
964 function getPostfixForTypeWarning(value) {
965 var type = getPreciseType(value);
966 switch (type) {
967 case "array":
968 case "object": return "an " + type;
969 case "boolean":
970 case "date":
971 case "regexp": return "a " + type;
972 default: return type;
973 }
974 }
975 function getClassName(propValue) {
976 if (!propValue.constructor || !propValue.constructor.name) return ANONYMOUS;
977 return propValue.constructor.name;
978 }
979 ReactPropTypes.checkPropTypes = checkPropTypes;
980 ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
981 ReactPropTypes.PropTypes = ReactPropTypes;
982 return ReactPropTypes;
983 };
984 }));
985
986 //#endregion
987 //#region node_modules/prop-types/index.js
988 var require_prop_types = /* @__PURE__ */ __commonJSMin(((exports, module) => {
989 var ReactIs = require_react_is$1();
990 var throwOnDirectAccess = true;
991 module.exports = require_factoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
992 }));
993
994 //#endregion
995 //#region modules/ai/assets/js/editor/context/requests-ids.js
996 var import_prop_types$13, Context, useRequestIds, getUniqueId, RequestIdsProvider;
997 var init_requests_ids = __esmMin((() => {
998 init_slicedToArray();
999 import_prop_types$13 = /* @__PURE__ */ __toESM(require_prop_types());
1000 Context = (0, react.createContext)({});
1001 useRequestIds = function useRequestIds() {
1002 var context = (0, react.useContext)(Context);
1003 if (!context) throw new Error("useRequestIds must be used within a RequestIdsProvider");
1004 return context;
1005 };
1006 getUniqueId = function getUniqueId(prefix) {
1007 return prefix + "-" + Math.random().toString(16).substr(2, 7);
1008 };
1009 window.EDITOR_SESSION_ID = window.EDITOR_SESSION_ID || getUniqueId("editor-session");
1010 RequestIdsProvider = function RequestIdsProvider(props) {
1011 var editorSessionId = (0, react.useRef)(window.EDITOR_SESSION_ID);
1012 var sessionId = (0, react.useRef)("");
1013 var generateId = (0, react.useRef)("");
1014 var batchId = (0, react.useRef)("");
1015 var requestId = (0, react.useRef)("");
1016 sessionId.current = getUniqueId("session");
1017 var setGenerate = function setGenerate() {
1018 generateId.current = getUniqueId("generate");
1019 return generateId;
1020 };
1021 var setBatch = function setBatch() {
1022 batchId.current = getUniqueId("batch");
1023 return batchId;
1024 };
1025 var setRequest = function setRequest() {
1026 requestId.current = getUniqueId("request");
1027 return requestId;
1028 };
1029 var _useState2 = _slicedToArray((0, react.useState)(0), 2);
1030 var usagePercentage = _useState2[0];
1031 var setUsagePercentage = _useState2[1];
1032 return /*#__PURE__*/ react.default.createElement(Context.Provider, { value: {
1033 editorSessionId,
1034 sessionId,
1035 generateId,
1036 batchId,
1037 requestId,
1038 setGenerate,
1039 setBatch,
1040 setRequest,
1041 usagePercentage,
1042 updateUsagePercentage: function updateUsagePercentage(newPercentage) {
1043 setUsagePercentage(newPercentage);
1044 }
1045 } }, props.children);
1046 };
1047 RequestIdsProvider.propTypes = { children: import_prop_types$13.default.node.isRequired };
1048 }));
1049
1050 //#endregion
1051 //#region node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteral.js
1052 init_extends();
1053 init_requests_ids();
1054 function _taggedTemplateLiteral(e, t) {
1055 return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } }));
1056 }
1057
1058 //#endregion
1059 //#region modules/ai/assets/js/gutenberg/styles.js
1060 var _templateObject$6;
1061 var _templateObject2$2;
1062 var Icon = (0, _elementor_ui.styled)("i")(_templateObject$6 || (_templateObject$6 = _taggedTemplateLiteral(["\n padding-inline-end: 0.5em;\n cursor: pointer;\n color: #C00BB9;\n"])));
1063 var AiLink = (0, _elementor_ui.styled)("a")(_templateObject2$2 || (_templateObject2$2 = _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"])));
1064
1065 //#endregion
1066 //#region node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
1067 function asyncGeneratorStep$1(n, t, e, r, o, a, c) {
1068 try {
1069 var i = n[a](c);
1070 var u = i.value;
1071 } catch (n) {
1072 e(n);
1073 return;
1074 }
1075 i.done ? t(u) : Promise.resolve(u).then(r, o);
1076 }
1077 function _asyncToGenerator$1(n) {
1078 return function() {
1079 var t = this;
1080 var e = arguments;
1081 return new Promise(function(r, o) {
1082 var a = n.apply(t, e);
1083 function _next(n) {
1084 asyncGeneratorStep$1(a, r, o, _next, _throw, "next", n);
1085 }
1086 function _throw(n) {
1087 asyncGeneratorStep$1(a, r, o, _next, _throw, "throw", n);
1088 }
1089 _next(void 0);
1090 });
1091 };
1092 }
1093 var init_asyncToGenerator = __esmMin((() => {
1094 __name(asyncGeneratorStep$1, "asyncGeneratorStep");
1095 __name(_asyncToGenerator$1, "_asyncToGenerator");
1096 }));
1097
1098 //#endregion
1099 //#region node_modules/@babel/runtime/helpers/OverloadYield.js
1100 var require_OverloadYield = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1101 function _OverloadYield(e, d) {
1102 this.v = e, this.k = d;
1103 }
1104 module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
1105 }));
1106
1107 //#endregion
1108 //#region node_modules/@babel/runtime/helpers/regeneratorDefine.js
1109 var require_regeneratorDefine = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1110 function _regeneratorDefine(e, r, n, t) {
1111 var i = Object.defineProperty;
1112 try {
1113 i({}, "", {});
1114 } catch (e) {
1115 i = 0;
1116 }
1117 module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
1118 function o(r, n) {
1119 _regeneratorDefine(e, r, function(e) {
1120 return this._invoke(r, n, e);
1121 });
1122 }
1123 r ? i ? i(e, r, {
1124 value: n,
1125 enumerable: !t,
1126 configurable: !t,
1127 writable: !t
1128 }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
1129 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
1130 }
1131 module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
1132 }));
1133
1134 //#endregion
1135 //#region node_modules/@babel/runtime/helpers/regenerator.js
1136 var require_regenerator$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1137 var regeneratorDefine = require_regeneratorDefine();
1138 function _regenerator() {
1139 /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
1140 var e;
1141 var t;
1142 var r = "function" == typeof Symbol ? Symbol : {};
1143 var n = r.iterator || "@@iterator";
1144 var o = r.toStringTag || "@@toStringTag";
1145 function i(r, n, o, i) {
1146 var c = n && n.prototype instanceof Generator ? n : Generator;
1147 var u = Object.create(c.prototype);
1148 return regeneratorDefine(u, "_invoke", function(r, n, o) {
1149 var i;
1150 var c;
1151 var u;
1152 var f = 0;
1153 var p = o || [];
1154 var y = !1;
1155 var G = {
1156 p: 0,
1157 n: 0,
1158 v: e,
1159 a: d,
1160 f: d.bind(e, 4),
1161 d: function d(t, r) {
1162 return i = t, c = 0, u = e, G.n = r, a;
1163 }
1164 };
1165 function d(r, n) {
1166 for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
1167 var o;
1168 var i = p[t];
1169 var d = G.p;
1170 var l = i[2];
1171 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));
1172 }
1173 if (o || r > 1) return a;
1174 throw y = !0, n;
1175 }
1176 return function(o, p, l) {
1177 if (f > 1) throw TypeError("Generator is already running");
1178 for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
1179 i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
1180 try {
1181 if (f = 2, i) {
1182 if (c || (o = "next"), t = i[o]) {
1183 if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
1184 if (!t.done) return t;
1185 u = t.value, c < 2 && (c = 0);
1186 } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
1187 i = e;
1188 } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
1189 } catch (t) {
1190 i = e, c = 1, u = t;
1191 } finally {
1192 f = 1;
1193 }
1194 }
1195 return {
1196 value: t,
1197 done: y
1198 };
1199 };
1200 }(r, o, i), !0), u;
1201 }
1202 var a = {};
1203 function Generator() {}
1204 function GeneratorFunction() {}
1205 function GeneratorFunctionPrototype() {}
1206 t = Object.getPrototypeOf;
1207 var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function() {
1208 return this;
1209 }), t);
1210 var u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
1211 function f(e) {
1212 return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
1213 }
1214 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() {
1215 return this;
1216 }), regeneratorDefine(u, "toString", function() {
1217 return "[object Generator]";
1218 }), (module.exports = _regenerator = function _regenerator() {
1219 return {
1220 w: i,
1221 m: f
1222 };
1223 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
1224 }
1225 module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
1226 }));
1227
1228 //#endregion
1229 //#region node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js
1230 var require_regeneratorAsyncIterator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1231 var OverloadYield = require_OverloadYield();
1232 var regeneratorDefine = require_regeneratorDefine();
1233 function AsyncIterator(t, e) {
1234 function n(r, o, i, f) {
1235 try {
1236 var c = t[r](o);
1237 var u = c.value;
1238 return u instanceof OverloadYield ? e.resolve(u.v).then(function(t) {
1239 n("next", t, i, f);
1240 }, function(t) {
1241 n("throw", t, i, f);
1242 }) : e.resolve(u).then(function(t) {
1243 c.value = t, i(c);
1244 }, function(t) {
1245 return n("throw", t, i, f);
1246 });
1247 } catch (t) {
1248 f(t);
1249 }
1250 }
1251 var r;
1252 this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function() {
1253 return this;
1254 })), regeneratorDefine(this, "_invoke", function(t, o, i) {
1255 function f() {
1256 return new e(function(e, r) {
1257 n(t, i, e, r);
1258 });
1259 }
1260 return r = r ? r.then(f, f) : f();
1261 }, !0);
1262 }
1263 module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
1264 }));
1265
1266 //#endregion
1267 //#region node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js
1268 var require_regeneratorAsyncGen = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1269 var regenerator = require_regenerator$1();
1270 var regeneratorAsyncIterator = require_regeneratorAsyncIterator();
1271 function _regeneratorAsyncGen(r, e, t, o, n) {
1272 return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
1273 }
1274 module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
1275 }));
1276
1277 //#endregion
1278 //#region node_modules/@babel/runtime/helpers/regeneratorAsync.js
1279 var require_regeneratorAsync = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1280 var regeneratorAsyncGen = require_regeneratorAsyncGen();
1281 function _regeneratorAsync(n, e, r, t, o) {
1282 var a = regeneratorAsyncGen(n, e, r, t, o);
1283 return a.next().then(function(n) {
1284 return n.done ? n.value : a.next();
1285 });
1286 }
1287 module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
1288 }));
1289
1290 //#endregion
1291 //#region node_modules/@babel/runtime/helpers/regeneratorKeys.js
1292 var require_regeneratorKeys = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1293 function _regeneratorKeys(e) {
1294 var n = Object(e);
1295 var r = [];
1296 for (var t in n) r.unshift(t);
1297 return function e() {
1298 for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
1299 return e.done = !0, e;
1300 };
1301 }
1302 module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
1303 }));
1304
1305 //#endregion
1306 //#region node_modules/@babel/runtime/helpers/typeof.js
1307 var require_typeof = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1308 function _typeof(o) {
1309 "@babel/helpers - typeof";
1310 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
1311 return typeof o;
1312 } : function(o) {
1313 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
1314 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
1315 }
1316 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
1317 }));
1318
1319 //#endregion
1320 //#region node_modules/@babel/runtime/helpers/regeneratorValues.js
1321 var require_regeneratorValues = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1322 var _typeof = require_typeof()["default"];
1323 function _regeneratorValues(e) {
1324 if (null != e) {
1325 var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"];
1326 var r = 0;
1327 if (t) return t.call(e);
1328 if ("function" == typeof e.next) return e;
1329 if (!isNaN(e.length)) return { next: function next() {
1330 return e && r >= e.length && (e = void 0), {
1331 value: e && e[r++],
1332 done: !e
1333 };
1334 } };
1335 }
1336 throw new TypeError(_typeof(e) + " is not iterable");
1337 }
1338 module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
1339 }));
1340
1341 //#endregion
1342 //#region node_modules/@babel/runtime/helpers/regeneratorRuntime.js
1343 var require_regeneratorRuntime = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1344 var OverloadYield = require_OverloadYield();
1345 var regenerator = require_regenerator$1();
1346 var regeneratorAsync = require_regeneratorAsync();
1347 var regeneratorAsyncGen = require_regeneratorAsyncGen();
1348 var regeneratorAsyncIterator = require_regeneratorAsyncIterator();
1349 var regeneratorKeys = require_regeneratorKeys();
1350 var regeneratorValues = require_regeneratorValues();
1351 function _regeneratorRuntime() {
1352 "use strict";
1353 var r = regenerator();
1354 var e = r.m(_regeneratorRuntime);
1355 var t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
1356 function n(r) {
1357 var e = "function" == typeof r && r.constructor;
1358 return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
1359 }
1360 var o = {
1361 "throw": 1,
1362 "return": 2,
1363 "break": 3,
1364 "continue": 3
1365 };
1366 function a(r) {
1367 var e;
1368 var t;
1369 return function(n) {
1370 e || (e = {
1371 stop: function stop() {
1372 return t(n.a, 2);
1373 },
1374 "catch": function _catch() {
1375 return n.v;
1376 },
1377 abrupt: function abrupt(r, e) {
1378 return t(n.a, o[r], e);
1379 },
1380 delegateYield: function delegateYield(r, o, a) {
1381 return e.resultName = o, t(n.d, regeneratorValues(r), a);
1382 },
1383 finish: function finish(r) {
1384 return t(n.f, r);
1385 }
1386 }, t = function t(r, _t, o) {
1387 n.p = e.prev, n.n = e.next;
1388 try {
1389 return r(_t, o);
1390 } finally {
1391 e.next = n.n;
1392 }
1393 }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
1394 try {
1395 return r.call(this, e);
1396 } finally {
1397 n.p = e.prev, n.n = e.next;
1398 }
1399 };
1400 }
1401 return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
1402 return {
1403 wrap: function wrap(e, t, n, o) {
1404 return r.w(a(e), t, n, o && o.reverse());
1405 },
1406 isGeneratorFunction: n,
1407 mark: r.m,
1408 awrap: function awrap(r, e) {
1409 return new OverloadYield(r, e);
1410 },
1411 AsyncIterator: regeneratorAsyncIterator,
1412 async: function async(r, e, t, o, u) {
1413 return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
1414 },
1415 keys: regeneratorKeys,
1416 values: regeneratorValues
1417 };
1418 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
1419 }
1420 module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
1421 }));
1422
1423 //#endregion
1424 //#region node_modules/@babel/runtime/regenerator/index.js
1425 var require_regenerator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1426 var runtime = require_regeneratorRuntime()();
1427 module.exports = runtime;
1428 try {
1429 regeneratorRuntime = runtime;
1430 } catch (accidentalStrictMode) {
1431 if (typeof globalThis === "object") globalThis.regeneratorRuntime = runtime;
1432 else Function("r", "regeneratorRuntime = r")(runtime);
1433 }
1434 }));
1435
1436 //#endregion
1437 //#region node_modules/@babel/runtime/helpers/esm/typeof.js
1438 function _typeof(o) {
1439 "@babel/helpers - typeof";
1440 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
1441 return typeof o;
1442 } : function(o) {
1443 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
1444 }, _typeof(o);
1445 }
1446 var init_typeof = __esmMin((() => {}));
1447
1448 //#endregion
1449 //#region node_modules/@babel/runtime/helpers/esm/toPrimitive.js
1450 function toPrimitive(t, r) {
1451 if ("object" != _typeof(t) || !t) return t;
1452 var e = t[Symbol.toPrimitive];
1453 if (void 0 !== e) {
1454 var i = e.call(t, r || "default");
1455 if ("object" != _typeof(i)) return i;
1456 throw new TypeError("@@toPrimitive must return a primitive value.");
1457 }
1458 return ("string" === r ? String : Number)(t);
1459 }
1460 var init_toPrimitive = __esmMin((() => {
1461 init_typeof();
1462 }));
1463
1464 //#endregion
1465 //#region node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
1466 function toPropertyKey(t) {
1467 var i = toPrimitive(t, "string");
1468 return "symbol" == _typeof(i) ? i : i + "";
1469 }
1470 var init_toPropertyKey = __esmMin((() => {
1471 init_typeof();
1472 init_toPrimitive();
1473 }));
1474
1475 //#endregion
1476 //#region node_modules/@babel/runtime/helpers/esm/defineProperty.js
1477 function _defineProperty(e, r, t) {
1478 return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
1479 value: t,
1480 enumerable: !0,
1481 configurable: !0,
1482 writable: !0
1483 }) : e[r] = t, e;
1484 }
1485 var init_defineProperty = __esmMin((() => {
1486 init_toPropertyKey();
1487 }));
1488
1489 //#endregion
1490 //#region modules/ai/assets/js/editor/api/index.js
1491 function ownKeys$32(e, r) {
1492 var t = Object.keys(e);
1493 if (Object.getOwnPropertySymbols) {
1494 var o = Object.getOwnPropertySymbols(e);
1495 r && (o = o.filter(function(r) {
1496 return Object.getOwnPropertyDescriptor(e, r).enumerable;
1497 })), t.push.apply(t, o);
1498 }
1499 return t;
1500 }
1501 function _objectSpread$32(e) {
1502 for (var r = 1; r < arguments.length; r++) {
1503 var t = null != arguments[r] ? arguments[r] : {};
1504 r % 2 ? ownKeys$32(Object(t), !0).forEach(function(r) {
1505 _defineProperty(e, r, t[r]);
1506 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$32(Object(t)).forEach(function(r) {
1507 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
1508 });
1509 }
1510 return e;
1511 }
1512 var request, getUserInformation, getRemoteConfig, getCompletionText, getExcerpt, getFeaturedImage, getEditText, getCustomCode, getCustomCSS, setGetStarted, setStatusFeedback, getTextToImageGeneration, getImageToImageGeneration, getImageToImageMaskCleanup, getImageToImageMaskGeneration, getImageToImageOutPainting, getImageToImageUpscale, getImageToImageRemoveBackground, getImageToImageIsolateObjects, getImageToImageReplaceBackground, getImagePromptEnhanced, getProductImageUnification, getAnimation, uploadImage, generateLayout, getLayoutPromptEnhanced, getHistory, deleteHistoryItem;
1513 var init_api = __esmMin((() => {
1514 init_defineProperty();
1515 __name(ownKeys$32, "ownKeys");
1516 __name(_objectSpread$32, "_objectSpread");
1517 request = function request(endpoint) {
1518 var data = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1519 var immediately = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
1520 var signal = arguments.length > 3 ? arguments[3] : void 0;
1521 if (Object.keys(data).length) if (window.elementorAiCurrentContext) data.context = window.elementorAiCurrentContext;
1522 else data.context = window.elementorWpAiCurrentContext;
1523 return new Promise(function(resolve, reject) {
1524 var ajaxData = elementorCommon.ajax.addRequest(endpoint, {
1525 success: resolve,
1526 error: reject,
1527 data,
1528 unique_id: data.unique_id
1529 }, immediately);
1530 if (signal && ajaxData.jqXhr) signal.addEventListener("abort", ajaxData.jqXhr.abort);
1531 });
1532 };
1533 getUserInformation = function getUserInformation(immediately) {
1534 return request("ai_get_user_information", void 0, immediately);
1535 };
1536 getRemoteConfig = function getRemoteConfig() {
1537 return request("ai_get_remote_config");
1538 };
1539 getCompletionText = function getCompletionText(payload) {
1540 return request("ai_get_completion_text", { payload });
1541 };
1542 getExcerpt = function getExcerpt(payload) {
1543 return request("ai_get_excerpt", { payload });
1544 };
1545 getFeaturedImage = function getFeaturedImage(payload) {
1546 return request("ai_get_featured_image", { payload });
1547 };
1548 getEditText = function getEditText(payload) {
1549 return request("ai_get_edit_text", { payload });
1550 };
1551 getCustomCode = function getCustomCode(payload) {
1552 return request("ai_get_custom_code", { payload });
1553 };
1554 getCustomCSS = function getCustomCSS(payload) {
1555 return request("ai_get_custom_css", { payload });
1556 };
1557 setGetStarted = function setGetStarted() {
1558 return request("ai_set_get_started");
1559 };
1560 setStatusFeedback = function setStatusFeedback(responseId) {
1561 return request("ai_set_status_feedback", { response_id: responseId }, true);
1562 };
1563 getTextToImageGeneration = function getTextToImageGeneration(payload) {
1564 return request("ai_get_text_to_image", { payload });
1565 };
1566 getImageToImageGeneration = function getImageToImageGeneration(payload) {
1567 return request("ai_get_image_to_image", { payload });
1568 };
1569 getImageToImageMaskCleanup = function getImageToImageMaskCleanup(payload) {
1570 return request("ai_get_image_to_image_mask_cleanup", { payload });
1571 };
1572 getImageToImageMaskGeneration = function getImageToImageMaskGeneration(payload) {
1573 return request("ai_get_image_to_image_mask", { payload });
1574 };
1575 getImageToImageOutPainting = function getImageToImageOutPainting(payload) {
1576 return request("ai_get_image_to_image_outpainting", { payload });
1577 };
1578 getImageToImageUpscale = function getImageToImageUpscale(payload) {
1579 return request("ai_get_image_to_image_upscale", { payload });
1580 };
1581 getImageToImageRemoveBackground = function getImageToImageRemoveBackground(payload) {
1582 return request("ai_get_image_to_image_remove_background", { payload });
1583 };
1584 getImageToImageIsolateObjects = function getImageToImageIsolateObjects(payload) {
1585 return request("ai_get_image_to_image_isolate_objects", { payload });
1586 };
1587 getImageToImageReplaceBackground = function getImageToImageReplaceBackground(payload) {
1588 return request("ai_get_image_to_image_replace_background", { payload });
1589 };
1590 getImagePromptEnhanced = function getImagePromptEnhanced(prompt) {
1591 return request("ai_get_image_prompt_enhancer", { prompt });
1592 };
1593 getProductImageUnification = function getProductImageUnification(payload, immediately) {
1594 return request("ai_get_product_image_unification", { payload }, immediately);
1595 };
1596 getAnimation = function getAnimation(payload) {
1597 return request("ai_get_animation", { payload });
1598 };
1599 uploadImage = function uploadImage(image) {
1600 return request("ai_upload_image", _objectSpread$32(_objectSpread$32({}, image), {}, {
1601 editor_post_id: image.image.editor_post_id,
1602 unique_id: image.image.unique_id
1603 }));
1604 };
1605 generateLayout = function generateLayout(requestBody, signal) {
1606 return request("ai_generate_layout", requestBody, true, signal);
1607 };
1608 getLayoutPromptEnhanced = function getLayoutPromptEnhanced(prompt, enhanceType) {
1609 return request("ai_get_layout_prompt_enhancer", {
1610 prompt,
1611 enhance_type: enhanceType
1612 });
1613 };
1614 getHistory = function getHistory(type, page, limit) {
1615 return request("ai_get_history", {
1616 type,
1617 page,
1618 limit
1619 });
1620 };
1621 deleteHistoryItem = function deleteHistoryItem(id) {
1622 return request("ai_delete_history_item", { id });
1623 };
1624 }));
1625
1626 //#endregion
1627 //#region modules/ai/assets/js/editor/hooks/use-user-info.js
1628 init_defineProperty();
1629 init_asyncToGenerator();
1630 init_slicedToArray();
1631 var import_regenerator$3 = /* @__PURE__ */ __toESM(require_regenerator());
1632 init_api();
1633 var import_prop_types$12 = /* @__PURE__ */ __toESM(require_prop_types());
1634 function ownKeys$31(e, r) {
1635 var t = Object.keys(e);
1636 if (Object.getOwnPropertySymbols) {
1637 var o = Object.getOwnPropertySymbols(e);
1638 r && (o = o.filter(function(r) {
1639 return Object.getOwnPropertyDescriptor(e, r).enumerable;
1640 })), t.push.apply(t, o);
1641 }
1642 return t;
1643 }
1644 __name(ownKeys$31, "ownKeys");
1645 function _objectSpread$31(e) {
1646 for (var r = 1; r < arguments.length; r++) {
1647 var t = null != arguments[r] ? arguments[r] : {};
1648 r % 2 ? ownKeys$31(Object(t), !0).forEach(function(r) {
1649 _defineProperty(e, r, t[r]);
1650 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$31(Object(t)).forEach(function(r) {
1651 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
1652 });
1653 }
1654 return e;
1655 }
1656 __name(_objectSpread$31, "_objectSpread");
1657 var useUserInfo = function useUserInfo() {
1658 var immediately = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
1659 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
1660 var isLoaded = _useState2[0];
1661 var setIsLoaded = _useState2[1];
1662 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
1663 var isLoading = _useState4[0];
1664 var setIsLoading = _useState4[1];
1665 var _useState6 = _slicedToArray((0, react.useState)({
1666 is_connected: false,
1667 is_get_started: false,
1668 connect_url: "",
1669 usage: {
1670 hasAiSubscription: false,
1671 quota: 0,
1672 usedQuota: 0
1673 }
1674 }), 2);
1675 var userInfo = _useState6[0];
1676 var setUserInfo = _useState6[1];
1677 var credits = userInfo.usage.quota - userInfo.usage.usedQuota;
1678 var usagePercentage = userInfo.usage.quota ? userInfo.usage.usedQuota / userInfo.usage.quota * 100 : 0;
1679 var fetchData = /*#__PURE__*/ function() {
1680 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee() {
1681 var userInfoResult;
1682 return import_regenerator$3.default.wrap(function(_context) {
1683 while (1) switch (_context.prev = _context.next) {
1684 case 0:
1685 setIsLoading(true);
1686 _context.next = 1;
1687 return getUserInformation(immediately);
1688 case 1:
1689 userInfoResult = _context.sent;
1690 setUserInfo(function(prevState) {
1691 return _objectSpread$31(_objectSpread$31({}, prevState), userInfoResult);
1692 });
1693 setIsLoaded(true);
1694 setIsLoading(false);
1695 case 2:
1696 case "end": return _context.stop();
1697 }
1698 }, _callee);
1699 }));
1700 return function fetchData() {
1701 return _ref.apply(this, arguments);
1702 };
1703 }();
1704 if (!isLoaded && !isLoading) fetchData();
1705 return {
1706 isLoading,
1707 isLoaded,
1708 isConnected: userInfo.is_connected,
1709 isGetStarted: userInfo.is_get_started,
1710 connectUrl: userInfo.connect_url,
1711 builderUrl: userInfo.usage.builderUrl,
1712 hasSubscription: userInfo.usage.hasAiSubscription,
1713 credits: credits < 0 ? 0 : credits,
1714 usagePercentage: Math.round(usagePercentage),
1715 fetchData
1716 };
1717 };
1718 useUserInfo.propTypes = { immediately: import_prop_types$12.default.bool };
1719
1720 //#endregion
1721 //#region node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js
1722 function _objectWithoutPropertiesLoose(r, e) {
1723 if (null == r) return {};
1724 var t = {};
1725 for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
1726 if (-1 !== e.indexOf(n)) continue;
1727 t[n] = r[n];
1728 }
1729 return t;
1730 }
1731 var init_objectWithoutPropertiesLoose = __esmMin((() => {}));
1732
1733 //#endregion
1734 //#region node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js
1735 function _objectWithoutProperties(e, t) {
1736 if (null == e) return {};
1737 var o;
1738 var r;
1739 var i = _objectWithoutPropertiesLoose(e, t);
1740 if (Object.getOwnPropertySymbols) {
1741 var n = Object.getOwnPropertySymbols(e);
1742 for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
1743 }
1744 return i;
1745 }
1746 var init_objectWithoutProperties = __esmMin((() => {
1747 init_objectWithoutPropertiesLoose();
1748 }));
1749
1750 //#endregion
1751 //#region modules/ai/assets/js/editor/hooks/use-prompt.js
1752 function ownKeys$30(e, r) {
1753 var t = Object.keys(e);
1754 if (Object.getOwnPropertySymbols) {
1755 var o = Object.getOwnPropertySymbols(e);
1756 r && (o = o.filter(function(r) {
1757 return Object.getOwnPropertyDescriptor(e, r).enumerable;
1758 })), t.push.apply(t, o);
1759 }
1760 return t;
1761 }
1762 function _objectSpread$30(e) {
1763 for (var r = 1; r < arguments.length; r++) {
1764 var t = null != arguments[r] ? arguments[r] : {};
1765 r % 2 ? ownKeys$30(Object(t), !0).forEach(function(r) {
1766 _defineProperty(e, r, t[r]);
1767 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$30(Object(t)).forEach(function(r) {
1768 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
1769 });
1770 }
1771 return e;
1772 }
1773 var import_regenerator$2, _excluded$33, normalizeResponse, usePrompt;
1774 var init_use_prompt = __esmMin((() => {
1775 init_defineProperty();
1776 init_asyncToGenerator();
1777 init_slicedToArray();
1778 init_objectWithoutProperties();
1779 import_regenerator$2 = /* @__PURE__ */ __toESM(require_regenerator());
1780 init_api();
1781 _excluded$33 = [
1782 "text",
1783 "response_id",
1784 "usage",
1785 "images"
1786 ];
1787 __name(ownKeys$30, "ownKeys");
1788 __name(_objectSpread$30, "_objectSpread");
1789 normalizeResponse = function normalizeResponse(_ref) {
1790 var text = _ref.text;
1791 var responseId = _ref.response_id;
1792 var usage = _ref.usage;
1793 var images = _ref.images;
1794 var optional = _objectWithoutProperties(_ref, _excluded$33);
1795 var creditsData = usage ? usage.quota - usage.usedQuota : 0;
1796 var normalized = {
1797 result: text || images,
1798 responseId,
1799 credits: Math.max(creditsData, 0),
1800 usagePercentage: usage === null || usage === void 0 ? void 0 : usage.usagePercentage
1801 };
1802 if (optional.base_template_id) normalized.baseTemplateId = optional.base_template_id;
1803 normalized.type = optional.template_type;
1804 return normalized;
1805 };
1806 usePrompt = function usePrompt(fetchData, initialState) {
1807 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
1808 var isLoading = _useState2[0];
1809 var setIsLoading = _useState2[1];
1810 var _useState4 = _slicedToArray((0, react.useState)(""), 2);
1811 var error = _useState4[0];
1812 var setError = _useState4[1];
1813 var _useState6 = _slicedToArray((0, react.useState)(initialState), 2);
1814 var data = _useState6[0];
1815 var setData = _useState6[1];
1816 var _useRequestIds = useRequestIds();
1817 var updateUsagePercentage = _useRequestIds.updateUsagePercentage;
1818 var usagePercentage = _useRequestIds.usagePercentage;
1819 var send = (0, react.useRef)(/*#__PURE__*/ function() {
1820 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(payload) {
1821 return import_regenerator$2.default.wrap(function(_context) {
1822 while (1) switch (_context.prev = _context.next) {
1823 case 0: return _context.abrupt("return", payload);
1824 case 1:
1825 case "end": return _context.stop();
1826 }
1827 }, _callee);
1828 }));
1829 return function(_x) {
1830 return _ref2.apply(this, arguments);
1831 };
1832 }());
1833 var sendUsageData = (0, react.useRef)(function() {});
1834 (0, react.useEffect)(function() {
1835 var newUsageValue = data === null || data === void 0 ? void 0 : data.usagePercentage;
1836 if (newUsageValue && newUsageValue !== usagePercentage) updateUsagePercentage(newUsageValue);
1837 }, [
1838 data,
1839 usagePercentage,
1840 updateUsagePercentage
1841 ]);
1842 var _useRequestIds2 = useRequestIds();
1843 var setRequest = _useRequestIds2.setRequest;
1844 var editorSessionId = _useRequestIds2.editorSessionId;
1845 var sessionId = _useRequestIds2.sessionId;
1846 var generateId = _useRequestIds2.generateId;
1847 var batchId = _useRequestIds2.batchId;
1848 send.current = (0, react.useCallback)(/*#__PURE__*/ function() {
1849 var _ref3 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee2(payload) {
1850 return import_regenerator$2.default.wrap(function(_context2) {
1851 while (1) switch (_context2.prev = _context2.next) {
1852 case 0: return _context2.abrupt("return", new Promise(function(resolve, reject) {
1853 setError("");
1854 setIsLoading(true);
1855 var requestId = setRequest();
1856 var requestIds = {
1857 editorSessionId: editorSessionId.current,
1858 sessionId: sessionId.current,
1859 generateId: generateId.current,
1860 batchId: batchId.current,
1861 requestId: requestId.current
1862 };
1863 payload = _objectSpread$30(_objectSpread$30({}, payload), {}, { requestIds });
1864 fetchData(payload).then(function(result) {
1865 var normalizedData = normalizeResponse(result);
1866 setData(normalizedData);
1867 resolve(normalizedData);
1868 }).catch(function(err) {
1869 var finalError = (err === null || err === void 0 ? void 0 : err.responseText) || err;
1870 setError(finalError);
1871 reject(finalError);
1872 }).finally(function() {
1873 return setIsLoading(false);
1874 });
1875 }));
1876 case 1:
1877 case "end": return _context2.stop();
1878 }
1879 }, _callee2);
1880 }));
1881 return function(_x2) {
1882 return _ref3.apply(this, arguments);
1883 };
1884 }(), [
1885 batchId,
1886 editorSessionId,
1887 fetchData,
1888 generateId,
1889 sessionId,
1890 setRequest
1891 ]);
1892 sendUsageData.current = (0, react.useCallback)(function() {
1893 var usageData = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : data;
1894 return usageData.responseId && setStatusFeedback(usageData.responseId);
1895 }, [data]);
1896 return {
1897 isLoading,
1898 error,
1899 data,
1900 setResult: function setResult(result) {
1901 var responseId = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
1902 var updatedResult = _objectSpread$30({}, data);
1903 updatedResult.result = result;
1904 if (responseId) updatedResult.responseId = responseId;
1905 setData(updatedResult);
1906 },
1907 reset: function reset() {
1908 setData(function(_ref4) {
1909 return {
1910 credits: _ref4.credits,
1911 result: "",
1912 responseId: ""
1913 };
1914 });
1915 setError("");
1916 setIsLoading(false);
1917 },
1918 send: send.current,
1919 sendUsageData: sendUsageData.current
1920 };
1921 };
1922 }));
1923
1924 //#endregion
1925 //#region modules/ai/assets/js/editor/hooks/use-excerpt-prompt.js
1926 init_asyncToGenerator();
1927 init_api();
1928 init_use_prompt();
1929 var useExcerptPrompt = function useExcerptPrompt(initialValue) {
1930 return usePrompt(/*#__PURE__*/ function() {
1931 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee(payload) {
1932 return import_regenerator$3.default.wrap(function(_context) {
1933 while (1) switch (_context.prev = _context.next) {
1934 case 0: return _context.abrupt("return", getExcerpt(payload));
1935 case 1:
1936 case "end": return _context.stop();
1937 }
1938 }, _callee);
1939 }));
1940 return function(_x) {
1941 return _ref.apply(this, arguments);
1942 };
1943 }(), initialValue);
1944 };
1945
1946 //#endregion
1947 //#region modules/ai/assets/js/editor/components/loader.js
1948 function ownKeys$29(e, r) {
1949 var t = Object.keys(e);
1950 if (Object.getOwnPropertySymbols) {
1951 var o = Object.getOwnPropertySymbols(e);
1952 r && (o = o.filter(function(r) {
1953 return Object.getOwnPropertyDescriptor(e, r).enumerable;
1954 })), t.push.apply(t, o);
1955 }
1956 return t;
1957 }
1958 function _objectSpread$29(e) {
1959 for (var r = 1; r < arguments.length; r++) {
1960 var t = null != arguments[r] ? arguments[r] : {};
1961 r % 2 ? ownKeys$29(Object(t), !0).forEach(function(r) {
1962 _defineProperty(e, r, t[r]);
1963 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$29(Object(t)).forEach(function(r) {
1964 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
1965 });
1966 }
1967 return e;
1968 }
1969 var import_prop_types$11, _excluded$32, Loader;
1970 var init_loader = __esmMin((() => {
1971 init_defineProperty();
1972 init_objectWithoutProperties();
1973 import_prop_types$11 = /* @__PURE__ */ __toESM(require_prop_types());
1974 _excluded$32 = ["sx", "BoxProps"];
1975 __name(ownKeys$29, "ownKeys");
1976 __name(_objectSpread$29, "_objectSpread");
1977 Loader = function Loader(_ref) {
1978 var _ref$sx = _ref.sx;
1979 var sx = _ref$sx === void 0 ? {} : _ref$sx;
1980 var _ref$BoxProps = _ref.BoxProps;
1981 var BoxProps = _ref$BoxProps === void 0 ? {} : _ref$BoxProps;
1982 var props = _objectWithoutProperties(_ref, _excluded$32);
1983 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
1984 width: "100%",
1985 display: "flex",
1986 alignItems: "center"
1987 }, BoxProps, { sx: _objectSpread$29({
1988 px: 1.5,
1989 minHeight: function minHeight(theme) {
1990 return theme.spacing(5);
1991 }
1992 }, BoxProps.sx || {}) }), /*#__PURE__*/ react.default.createElement(_elementor_ui.LinearProgress, _extends$1({ color: "secondary" }, props, { sx: _objectSpread$29({ width: "100%" }, sx) })));
1993 };
1994 Loader.propTypes = {
1995 sx: import_prop_types$11.default.object,
1996 BoxProps: import_prop_types$11.default.object
1997 };
1998 }));
1999
2000 //#endregion
2001 //#region modules/ai/assets/js/editor/components/ui/search-field.js
2002 var import_prop_types$10, StyledTextField$1, SearchField;
2003 var init_search_field = __esmMin((() => {
2004 init_extends();
2005 import_prop_types$10 = /* @__PURE__ */ __toESM(require_prop_types());
2006 StyledTextField$1 = (0, _elementor_ui.styled)(_elementor_ui.TextField)(function() {
2007 return { ".wp-admin & .MuiInputBase-input, & .MuiInputBase-input:focus": {
2008 backgroundColor: "initial",
2009 boxShadow: "none",
2010 border: 0,
2011 color: "inherit",
2012 outline: 0,
2013 /**
2014 * TODO:
2015 * Find a better solution to get the component padding value dynamically or fix the global CSS override.
2016 * These values are taken from Material UI's source code (the left padding reset was added to match the component style).
2017 */
2018 padding: "16.5px 14px 16.5px 0",
2019 "&.MuiInputBase-inputSizeSmall": { padding: "8.5px 14px 8.5px 0" }
2020 } };
2021 });
2022 SearchField = (0, react.forwardRef)(function(props, ref) {
2023 return /*#__PURE__*/ react.default.createElement(StyledTextField$1, _extends$1({
2024 autoFocus: true,
2025 fullWidth: true,
2026 required: true,
2027 size: "small",
2028 color: "secondary",
2029 InputProps: {
2030 autoComplete: "off",
2031 startAdornment: /*#__PURE__*/ react.default.createElement(_elementor_ui.InputAdornment, { position: "start" }, /*#__PURE__*/ react.default.createElement(_elementor_icons.SearchIcon, null))
2032 },
2033 placeholder: props.placeholder,
2034 name: props.name,
2035 value: props.value,
2036 onChange: props.onChange
2037 }, props, { inputRef: ref }));
2038 });
2039 SearchField.propTypes = {
2040 placeholder: import_prop_types$10.default.string,
2041 name: import_prop_types$10.default.string,
2042 value: import_prop_types$10.default.string,
2043 onChange: import_prop_types$10.default.func
2044 };
2045 }));
2046
2047 //#endregion
2048 //#region modules/ai/assets/js/editor/components/prompt-search.js
2049 var PromptSearch;
2050 var init_prompt_search = __esmMin((() => {
2051 init_extends();
2052 init_search_field();
2053 PromptSearch = (0, react.forwardRef)(function(props, ref) {
2054 return /*#__PURE__*/ react.default.createElement(SearchField, _extends$1({
2055 name: "prompt",
2056 placeholder: (0, _wordpress_i18n.__)("Describe the text and tone you want to use", "elementor") + "..."
2057 }, props, { ref }));
2058 });
2059 }));
2060
2061 //#endregion
2062 //#region modules/ai/assets/js/editor/components/textarea.js
2063 var import_prop_types$9, Textarea;
2064 var init_textarea = __esmMin((() => {
2065 init_extends();
2066 import_prop_types$9 = /* @__PURE__ */ __toESM(require_prop_types());
2067 Textarea = (0, react.forwardRef)(function(props, ref) {
2068 return /*#__PURE__*/ react.default.createElement(_elementor_ui.TextField, _extends$1({
2069 inputRef: ref,
2070 multiline: true,
2071 minRows: 4,
2072 maxRows: 20,
2073 color: "secondary"
2074 }, props));
2075 });
2076 Textarea.propTypes = {
2077 value: import_prop_types$9.default.string,
2078 onChange: import_prop_types$9.default.func,
2079 helperText: import_prop_types$9.default.string
2080 };
2081 }));
2082
2083 //#endregion
2084 //#region modules/ai/assets/js/editor/components/prompt-suggestions.js
2085 var import_prop_types$8, PromptSuggestions;
2086 var init_prompt_suggestions = __esmMin((() => {
2087 import_prop_types$8 = /* @__PURE__ */ __toESM(require_prop_types());
2088 PromptSuggestions = function PromptSuggestions(props) {
2089 var _props$suggestions;
2090 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
2091 variant: "subtitle1",
2092 color: "text.secondary"
2093 }, (0, _wordpress_i18n.__)("Suggested prompts", "elementor") + ":"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
2094 direction: "column",
2095 alignItems: "flex-start",
2096 gap: 1,
2097 sx: { my: 1 }
2098 }, (_props$suggestions = props.suggestions) === null || _props$suggestions === void 0 ? void 0 : _props$suggestions.map(function(option, index) {
2099 var _props$suggestionFilt;
2100 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Chip, {
2101 key: index,
2102 variant: "outlined",
2103 size: "large",
2104 color: "secondary",
2105 label: ((_props$suggestionFilt = props.suggestionFilter) === null || _props$suggestionFilt === void 0 ? void 0 : _props$suggestionFilt.call(props, option)) || option,
2106 onClick: function onClick() {
2107 return props.onSelect(option);
2108 }
2109 });
2110 })), props.children);
2111 };
2112 PromptSuggestions.propTypes = {
2113 suggestions: import_prop_types$8.default.arrayOf(import_prop_types$8.default.string),
2114 onSelect: import_prop_types$8.default.func.isRequired,
2115 suggestionFilter: import_prop_types$8.default.func,
2116 children: import_prop_types$8.default.node
2117 };
2118 }));
2119
2120 //#endregion
2121 //#region modules/ai/assets/js/editor/components/prompt-library-link.js
2122 var import_prop_types$7, PromptLibraryLink;
2123 var init_prompt_library_link = __esmMin((() => {
2124 import_prop_types$7 = /* @__PURE__ */ __toESM(require_prop_types());
2125 PromptLibraryLink = function PromptLibraryLink(props) {
2126 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
2127 variant: "body2",
2128 color: "text.secondary"
2129 }, (0, _wordpress_i18n.__)("For more suggestions, explore our"), " ", /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
2130 href: props.libraryLink,
2131 className: "elementor-clickable",
2132 target: "_blank"
2133 }, (0, _wordpress_i18n.__)("prompt library")));
2134 };
2135 PromptLibraryLink.propTypes = { libraryLink: import_prop_types$7.default.string };
2136 }));
2137
2138 //#endregion
2139 //#region modules/ai/assets/js/editor/components/prompt-action-selection.js
2140 init_loader();
2141 init_prompt_search();
2142 init_textarea();
2143 init_prompt_suggestions();
2144 init_prompt_library_link();
2145 var labelToDashCash = function labelToDashCash(str) {
2146 return str.toLowerCase().replace(/ /g, "-");
2147 };
2148 var PromptActionSelection = function PromptActionSelection(props) {
2149 var actionId = labelToDashCash(props.label);
2150 var _props$wrapperStyle = props.wrapperStyle;
2151 var wrapperStyle = _props$wrapperStyle === void 0 ? { maxWidth: 138 } : _props$wrapperStyle;
2152 return /*#__PURE__*/ react.default.createElement(_elementor_ui.FormControl, {
2153 size: "small",
2154 color: "secondary",
2155 fullWidth: true,
2156 sx: wrapperStyle
2157 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.InputLabel, { id: actionId }, props.label), /*#__PURE__*/ react.default.createElement(_elementor_ui.Select, {
2158 id: actionId,
2159 labelId: actionId,
2160 label: props.label,
2161 value: props.value || "",
2162 onChange: props.onChange,
2163 disabled: props.disabled,
2164 sx: { "&.Mui-disabled .MuiSelect-nativeInput": {
2165 backgroundColor: "initial",
2166 opacity: 0
2167 } }
2168 }, props.options.map(function(option) {
2169 var _option$value;
2170 return /*#__PURE__*/ react.default.createElement(_elementor_ui.MenuItem, {
2171 dense: true,
2172 key: option.label,
2173 value: (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option.label
2174 }, option.label);
2175 })));
2176 };
2177 PromptActionSelection.propTypes = {
2178 label: import_prop_types$12.default.string.isRequired,
2179 options: import_prop_types$12.default.arrayOf(import_prop_types$12.default.shape({
2180 label: import_prop_types$12.default.string.isRequired,
2181 value: import_prop_types$12.default.string
2182 })).isRequired,
2183 onChange: import_prop_types$12.default.func.isRequired,
2184 value: import_prop_types$12.default.string,
2185 wrapperStyle: import_prop_types$12.default.object,
2186 disabled: import_prop_types$12.default.bool
2187 };
2188
2189 //#endregion
2190 //#region modules/ai/assets/js/editor/components/generate-button.js
2191 var GenerateButton$1;
2192 var init_generate_button = __esmMin((() => {
2193 init_extends();
2194 GenerateButton$1 = function GenerateButton(props) {
2195 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
2196 variant: "contained",
2197 endIcon: /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { fontSize: "small" }),
2198 disabled: !prompt,
2199 "aria-label": (0, _wordpress_i18n.__)("search", "elementor"),
2200 type: "submit",
2201 size: "small"
2202 }, props));
2203 };
2204 }));
2205
2206 //#endregion
2207 //#region modules/ai/assets/js/editor/components/prompt-action.js
2208 init_generate_button();
2209 init_extends();
2210 var PromptAction = function PromptAction(props) {
2211 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Chip, _extends$1({
2212 size: "large",
2213 color: "secondary",
2214 variant: "outlined"
2215 }, props));
2216 };
2217
2218 //#endregion
2219 //#region modules/ai/assets/js/editor/components/prompt-error-message.js
2220 var import_prop_types$6, _excluded$31, PromptErrorMessage;
2221 var init_prompt_error_message = __esmMin((() => {
2222 init_extends();
2223 init_objectWithoutProperties();
2224 import_prop_types$6 = /* @__PURE__ */ __toESM(require_prop_types());
2225 _excluded$31 = [
2226 "error",
2227 "onRetry",
2228 "actionPosition"
2229 ];
2230 PromptErrorMessage = function PromptErrorMessage(_ref) {
2231 var error = _ref.error;
2232 var _ref$onRetry = _ref.onRetry;
2233 var onRetry = _ref$onRetry === void 0 ? function() {} : _ref$onRetry;
2234 var _ref$actionPosition = _ref.actionPosition;
2235 var actionPosition = _ref$actionPosition === void 0 ? "default" : _ref$actionPosition;
2236 var props = _objectWithoutProperties(_ref, _excluded$31);
2237 function getQuotaReachedTrailMessage(featureName) {
2238 if (!featureName) return {
2239 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("It's time to upgrade.", "elementor")),
2240 description: (0, _wordpress_i18n.__)("Enjoy the free trial? Upgrade now for unlimited access to built-in image, text and custom code generators.", "elementor"),
2241 buttonText: (0, _wordpress_i18n.__)("Upgrade", "elementor"),
2242 buttonAction: function buttonAction() {
2243 return window.open("https://go.elementor.com/ai-popup-purchase-limit-reached/", "_blank");
2244 }
2245 };
2246 return {
2247 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())),
2248 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"),
2249 buttonText: (0, _wordpress_i18n.__)("Upgrade now", "elementor"),
2250 buttonAction: function buttonAction() {
2251 return window.open("https://go.elementor.com/ai-popup-purchase-limit-reached/", "_blank");
2252 }
2253 };
2254 }
2255 function getErrorMessage() {
2256 var _error$extra_data;
2257 var errMsg = error.message || error;
2258 var featureName = (_error$extra_data = error.extra_data) === null || _error$extra_data === void 0 ? void 0 : _error$extra_data.featureName;
2259 var messages = {
2260 default: {
2261 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("There was a glitch.", "elementor")),
2262 description: (0, _wordpress_i18n.__)("Wait a moment and give it another go, or try tweaking the prompt.", "elementor"),
2263 buttonText: (0, _wordpress_i18n.__)("Try again", "elementor"),
2264 buttonAction: onRetry
2265 },
2266 service_outage_internal: {
2267 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("There was a glitch.", "elementor")),
2268 description: (0, _wordpress_i18n.__)("Wait a moment and give it another go.", "elementor"),
2269 buttonText: (0, _wordpress_i18n.__)("Try again", "elementor"),
2270 buttonAction: onRetry
2271 },
2272 invalid_connect_data: {
2273 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("There was a glitch.", "elementor")),
2274 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", {
2275 href: "https://elementor.com/help/disconnecting-reconnecting-your-elementor-account/",
2276 target: "_blank",
2277 rel: "noreferrer"
2278 }, (0, _wordpress_i18n.__)("Show me how", "elementor"))),
2279 buttonText: (0, _wordpress_i18n.__)("Reconnect", "elementor"),
2280 buttonAction: function buttonAction() {
2281 return window.open(window.ElementorAiConfig.connect_url);
2282 }
2283 },
2284 not_connected: {
2285 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("You aren't connected to Elementor AI.", "elementor")),
2286 description: (0, _wordpress_i18n.__)("Elementor AI is just a few clicks away. Connect your account to instantly create texts and custom code.", "elementor"),
2287 buttonText: (0, _wordpress_i18n.__)("Connect", "elementor"),
2288 buttonAction: function buttonAction() {
2289 return window.open(window.ElementorAiConfig.connect_url);
2290 }
2291 },
2292 quota_reached_trail: getQuotaReachedTrailMessage(featureName),
2293 quota_reached_subscription: {
2294 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("Looks like you're out of credits.", "elementor")),
2295 description: (0, _wordpress_i18n.__)("Ready to take it to the next level?", "elementor"),
2296 buttonText: (0, _wordpress_i18n.__)("Upgrade now", "elementor"),
2297 buttonAction: function buttonAction() {
2298 return window.open("https://go.elementor.com/ai-popup-purchase-limit-reached/", "_blank");
2299 }
2300 },
2301 rate_limit_network: {
2302 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("Whoa! Slow down there.", "elementor")),
2303 description: (0, _wordpress_i18n.__)("We can’t process that many requests so fast. Try again in 15 minutes.", "elementor")
2304 },
2305 invalid_prompts: {
2306 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("We were unable to generate that prompt.", "elementor")),
2307 description: (0, _wordpress_i18n.__)("Seems like the prompt contains words that could generate harmful content. Write a different prompt to continue.", "elementor")
2308 },
2309 service_unavailable: {
2310 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("There was a glitch.", "elementor")),
2311 description: (0, _wordpress_i18n.__)("Wait a moment and give it another go, or try tweaking the prompt.", "elementor"),
2312 buttonText: (0, _wordpress_i18n.__)("Try again", "elementor"),
2313 buttonAction: onRetry
2314 },
2315 request_timeout_error: {
2316 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("There was a glitch.", "elementor")),
2317 description: (0, _wordpress_i18n.__)("Wait a moment and give it another go, or try tweaking the prompt.", "elementor"),
2318 buttonText: (0, _wordpress_i18n.__)("Try again", "elementor"),
2319 buttonAction: onRetry
2320 },
2321 invalid_token: {
2322 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("Try again", "elementor")),
2323 description: (0, _wordpress_i18n.__)("Try exiting Elementor and sign in again.", "elementor"),
2324 buttonText: (0, _wordpress_i18n.__)("Reconnect", "elementor"),
2325 buttonAction: onRetry
2326 },
2327 file_too_large: {
2328 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("The file is too large.", "elementor")),
2329 description: (0, _wordpress_i18n.__)("Please upload a file that is less than 4MB.", "elementor")
2330 },
2331 image_resolution_maximum_exceeded: {
2332 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("The image resolution exceeds the maximum allowed size.", "elementor")),
2333 description: (0, _wordpress_i18n.__)("Please upload a file with dimensions less than 2048x2048 pixels.", "elementor")
2334 },
2335 external_service_unavailable: {
2336 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("Temporary external service issue", "elementor")),
2337 description: (0, _wordpress_i18n.__)("It seems that one of our partner services is temporarily unavailable. Please try again in a few minutes.", "elementor"),
2338 buttonText: (0, _wordpress_i18n.__)("Try Again", "elementor"),
2339 buttonAction: onRetry
2340 }
2341 };
2342 return messages[errMsg] || messages.default;
2343 }
2344 var message = getErrorMessage();
2345 var action = (message === null || message === void 0 ? void 0 : message.buttonText) && /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
2346 color: "inherit",
2347 size: "small",
2348 variant: "outlined",
2349 onClick: message.buttonAction
2350 }, message.buttonText);
2351 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Alert, _extends$1({
2352 severity: message.severity || "error",
2353 action: "default" === actionPosition && action
2354 }, props), message.text, message.description, "bottom" === actionPosition && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: { mt: 1 } }, action));
2355 };
2356 PromptErrorMessage.propTypes = {
2357 error: import_prop_types$6.default.oneOfType([import_prop_types$6.default.object, import_prop_types$6.default.string]),
2358 onRetry: import_prop_types$6.default.func,
2359 actionPosition: import_prop_types$6.default.oneOf(["default", "bottom"])
2360 };
2361 }));
2362
2363 //#endregion
2364 //#region modules/ai/assets/js/editor/hooks/use-text-prompt.js
2365 init_prompt_error_message();
2366 init_asyncToGenerator();
2367 init_api();
2368 init_use_prompt();
2369 var getTextResult = /*#__PURE__*/ function() {
2370 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee(payload) {
2371 return import_regenerator$3.default.wrap(function(_context) {
2372 while (1) switch (_context.prev = _context.next) {
2373 case 0:
2374 if (!(payload !== null && payload !== void 0 && payload.instruction)) {
2375 _context.next = 1;
2376 break;
2377 }
2378 return _context.abrupt("return", getEditText(payload));
2379 case 1: return _context.abrupt("return", getCompletionText(payload));
2380 case 2:
2381 case "end": return _context.stop();
2382 }
2383 }, _callee);
2384 }));
2385 return function getTextResult(_x) {
2386 return _ref.apply(this, arguments);
2387 };
2388 }();
2389 var useTextPrompt = function useTextPrompt(initialValue) {
2390 return usePrompt(getTextResult, initialValue);
2391 };
2392
2393 //#endregion
2394 //#region modules/ai/assets/js/editor/actions-data.js
2395 var textAutocomplete, textareaAutocomplete, codeHtmlAutocomplete, codeCssAutocomplete, vocalTones, translateLanguages, motionEffectAutocomplete, hoverEffectAutocomplete;
2396 var init_actions_data = __esmMin((() => {
2397 textAutocomplete = [
2398 (0, _wordpress_i18n.__)("Craft a catchy slogan for", "elementor"),
2399 (0, _wordpress_i18n.__)("Write a strong section header for", "elementor"),
2400 (0, _wordpress_i18n.__)("Create a blog title for", "elementor"),
2401 (0, _wordpress_i18n.__)("Suggest a 4 word headline for", "elementor"),
2402 (0, _wordpress_i18n.__)("Write an attention grabbing title for", "elementor")
2403 ];
2404 textareaAutocomplete = [
2405 (0, _wordpress_i18n.__)("Write a product description for", "elementor"),
2406 (0, _wordpress_i18n.__)("Create a blog post for", "elementor"),
2407 (0, _wordpress_i18n.__)("Craft an about us section for", "elementor"),
2408 (0, _wordpress_i18n.__)("Offer a few sentences to invite visitors to", "elementor"),
2409 (0, _wordpress_i18n.__)("Write microcopy for a submission form that includes", "elementor")
2410 ];
2411 codeHtmlAutocomplete = [
2412 (0, _wordpress_i18n.__)("GA event fired on every button element click (assume GA was loaded)", "elementor"),
2413 (0, _wordpress_i18n.__)("Iframe code to embed a Spotify widget on my web page. My ID is 1234567890", "elementor"),
2414 (0, _wordpress_i18n.__)("Write an embed code of Google Analytics", "elementor"),
2415 (0, _wordpress_i18n.__)("Write an embed code of Facebook Pixel", "elementor"),
2416 (0, _wordpress_i18n.__)("HTML code that embeds the following PDF into a webpage: link to PDF", "elementor")
2417 ];
2418 codeCssAutocomplete = [
2419 (0, _wordpress_i18n.__)("On hover, animate 20% bigger, rotate 10 deg CCW", "elementor"),
2420 (0, _wordpress_i18n.__)("Add a circle-shaped clip mask, semi transparent on hover", "elementor"),
2421 (0, _wordpress_i18n.__)("Rainbow colored animated text gradient", "elementor"),
2422 (0, _wordpress_i18n.__)("Add a 3D shadow to the text", "elementor")
2423 ];
2424 vocalTones = [
2425 { label: (0, _wordpress_i18n.__)("Casual", "elementor") },
2426 { label: (0, _wordpress_i18n.__)("Confidence", "elementor") },
2427 { label: (0, _wordpress_i18n.__)("Formal", "elementor") },
2428 { label: (0, _wordpress_i18n.__)("Friendly", "elementor") },
2429 { label: (0, _wordpress_i18n.__)("Inspirational", "elementor") },
2430 { label: (0, _wordpress_i18n.__)("Motivational", "elementor") },
2431 { label: (0, _wordpress_i18n.__)("Nostalgic", "elementor") },
2432 { label: (0, _wordpress_i18n.__)("Playful", "elementor") },
2433 { label: (0, _wordpress_i18n.__)("Professional", "elementor") },
2434 { label: (0, _wordpress_i18n.__)("Scientific", "elementor") },
2435 { label: (0, _wordpress_i18n.__)("Straightforward", "elementor") },
2436 { label: (0, _wordpress_i18n.__)("Witty", "elementor") }
2437 ];
2438 translateLanguages = [
2439 {
2440 label: (0, _wordpress_i18n.__)("Arabic", "elementor"),
2441 value: "ar-SA"
2442 },
2443 {
2444 label: (0, _wordpress_i18n.__)("Chinese", "elementor"),
2445 value: "zh-CN"
2446 },
2447 {
2448 label: (0, _wordpress_i18n.__)("Czech", "elementor"),
2449 value: "cs-CZ"
2450 },
2451 {
2452 label: (0, _wordpress_i18n.__)("Danish", "elementor"),
2453 value: "da-DK"
2454 },
2455 {
2456 label: (0, _wordpress_i18n.__)("Dutch", "elementor"),
2457 value: "nl-NL"
2458 },
2459 {
2460 label: (0, _wordpress_i18n.__)("English", "elementor"),
2461 value: "en-US"
2462 },
2463 {
2464 label: (0, _wordpress_i18n.__)("Finnish", "elementor"),
2465 value: "fi-FI"
2466 },
2467 {
2468 label: (0, _wordpress_i18n.__)("French", "elementor"),
2469 value: "fr-FR"
2470 },
2471 {
2472 label: (0, _wordpress_i18n.__)("German", "elementor"),
2473 value: "de-DE"
2474 },
2475 {
2476 label: (0, _wordpress_i18n.__)("Greek", "elementor"),
2477 value: "el-GR"
2478 },
2479 {
2480 label: (0, _wordpress_i18n.__)("Hebrew", "elementor"),
2481 value: "he-IL"
2482 },
2483 {
2484 label: (0, _wordpress_i18n.__)("Hungarian", "elementor"),
2485 value: "hu-HU"
2486 },
2487 {
2488 label: (0, _wordpress_i18n.__)("Indonesian", "elementor"),
2489 value: "id-ID"
2490 },
2491 {
2492 label: (0, _wordpress_i18n.__)("Italian", "elementor"),
2493 value: "it-IT"
2494 },
2495 {
2496 label: (0, _wordpress_i18n.__)("Japanese", "elementor"),
2497 value: "ja-JP"
2498 },
2499 {
2500 label: (0, _wordpress_i18n.__)("Korean", "elementor"),
2501 value: "ko-KR"
2502 },
2503 {
2504 label: (0, _wordpress_i18n.__)("Persian", "elementor"),
2505 value: "fa-IR"
2506 },
2507 {
2508 label: (0, _wordpress_i18n.__)("Polish", "elementor"),
2509 value: "pl-PL"
2510 },
2511 {
2512 label: (0, _wordpress_i18n.__)("Portuguese", "elementor"),
2513 value: "pt-PT"
2514 },
2515 {
2516 label: (0, _wordpress_i18n.__)("Russian", "elementor"),
2517 value: "ru-RU"
2518 },
2519 {
2520 label: (0, _wordpress_i18n.__)("Spanish", "elementor"),
2521 value: "es-ES"
2522 },
2523 {
2524 label: (0, _wordpress_i18n.__)("Swedish", "elementor"),
2525 value: "sv-SE"
2526 },
2527 {
2528 label: (0, _wordpress_i18n.__)("Thai", "elementor"),
2529 value: "th-TH"
2530 },
2531 {
2532 label: (0, _wordpress_i18n.__)("Turkish", "elementor"),
2533 value: "tr-TR"
2534 },
2535 {
2536 label: (0, _wordpress_i18n.__)("Vietnamese", "elementor"),
2537 value: "vi-VN"
2538 }
2539 ];
2540 motionEffectAutocomplete = [
2541 (0, _wordpress_i18n.__)("Create Fade out animation on scroll", "elementor"),
2542 (0, _wordpress_i18n.__)("Create a Parallax effect on scroll", "elementor"),
2543 (0, _wordpress_i18n.__)("On scroll, fade in with slight scaling up", "elementor"),
2544 (0, _wordpress_i18n.__)("Move and tilt opposite to mouse position", "elementor"),
2545 (0, _wordpress_i18n.__)("Slide in from the left on load", "elementor")
2546 ];
2547 hoverEffectAutocomplete = [
2548 (0, _wordpress_i18n.__)("Move down on hover", "elementor"),
2549 (0, _wordpress_i18n.__)("Slightly shift right on hover", "elementor"),
2550 (0, _wordpress_i18n.__)("Apply a subtle 3D tilt", "elementor"),
2551 (0, _wordpress_i18n.__)("Rotate gently clockwise on hover", "elementor"),
2552 (0, _wordpress_i18n.__)("Scale down and move up on hover", "elementor")
2553 ];
2554 }));
2555
2556 //#endregion
2557 //#region modules/ai/assets/js/editor/components/prompt-history/history-types.js
2558 var HISTORY_TYPES, TRANSLATED_HISTORY_TYPES_FALLBACK, TRANSLATED_HISTORY_TYPES, getTranslatedPromptHistoryType;
2559 var init_history_types = __esmMin((() => {
2560 init_defineProperty();
2561 HISTORY_TYPES = Object.freeze({
2562 ALL: "all",
2563 TEXT: "text",
2564 CODE: "code",
2565 IMAGE: "images",
2566 BLOCK: "blocks"
2567 });
2568 TRANSLATED_HISTORY_TYPES_FALLBACK = (0, _wordpress_i18n.__)("things", "elementor");
2569 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")));
2570 getTranslatedPromptHistoryType = function getTranslatedPromptHistoryType(historyType) {
2571 if (TRANSLATED_HISTORY_TYPES[historyType]) return TRANSLATED_HISTORY_TYPES[historyType];
2572 return TRANSLATED_HISTORY_TYPES_FALLBACK;
2573 };
2574 }));
2575
2576 //#endregion
2577 //#region modules/ai/assets/js/editor/helpers/index.js
2578 var vh;
2579 var init_helpers = __esmMin((() => {
2580 vh = function vh(value) {
2581 return value * Math.max(document.documentElement.clientHeight, window.innerHeight || 0) / 100;
2582 };
2583 }));
2584
2585 //#endregion
2586 //#region modules/ai/assets/js/editor/components/prompt-history/context/prompt-history-context.js
2587 var import_prop_types$5, PromptHistoryContext, DIALOG_CONTAINER_SELECTOR, getContainer, getContainerHeight, getContentHeight, setContentHeight, PromptHistoryProvider, usePromptHistoryContext;
2588 var init_prompt_history_context = __esmMin((() => {
2589 init_slicedToArray();
2590 import_prop_types$5 = /* @__PURE__ */ __toESM(require_prop_types());
2591 init_history_types();
2592 init_helpers();
2593 PromptHistoryContext = (0, react.createContext)({});
2594 DIALOG_CONTAINER_SELECTOR = ".e-ai-dialog-content";
2595 getContainer = function getContainer() {
2596 return document.querySelector(DIALOG_CONTAINER_SELECTOR);
2597 };
2598 getContainerHeight = function getContainerHeight() {
2599 var contentContainer = document.querySelector(DIALOG_CONTAINER_SELECTOR);
2600 return contentContainer === null || contentContainer === void 0 ? void 0 : contentContainer.clientHeight;
2601 };
2602 getContentHeight = function getContentHeight() {
2603 return document.querySelector(DIALOG_CONTAINER_SELECTOR).children[0].clientHeight + 50;
2604 };
2605 setContentHeight = function setContentHeight(height) {
2606 var contentContainer = document.querySelector(DIALOG_CONTAINER_SELECTOR);
2607 if ("auto" === height) {
2608 contentContainer.style.height = "auto";
2609 return;
2610 }
2611 contentContainer.style.height = "".concat(height, "px");
2612 };
2613 PromptHistoryProvider = function PromptHistoryProvider(_ref) {
2614 var historyType = _ref.historyType;
2615 var children = _ref.children;
2616 var showHistoryState = (0, react.useState)(false);
2617 return /*#__PURE__*/ react.default.createElement(PromptHistoryContext.Provider, { value: {
2618 historyType,
2619 showHistoryState
2620 } }, children);
2621 };
2622 PromptHistoryProvider.propTypes = {
2623 historyType: import_prop_types$5.default.oneOf(Object.values(HISTORY_TYPES)).isRequired,
2624 children: import_prop_types$5.default.node
2625 };
2626 usePromptHistoryContext = function usePromptHistoryContext() {
2627 var _useContext = (0, react.useContext)(PromptHistoryContext);
2628 var historyType = _useContext.historyType;
2629 var showHistoryState = _useContext.showHistoryState;
2630 var _showHistoryState = _slicedToArray(showHistoryState, 2);
2631 var showHistory = _showHistoryState[0];
2632 var setShowHistory = _showHistoryState[1];
2633 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
2634 var showModalWrapper = _useState2[0];
2635 var setShowModalWrapper = _useState2[1];
2636 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
2637 var showPromptHistory = _useState4[0];
2638 var setShowPromptHistory = _useState4[1];
2639 var handleFullScreenHistoryState = function handleFullScreenHistoryState() {
2640 if (showHistory) {
2641 setShowModalWrapper(true);
2642 setTimeout(function() {
2643 return setShowPromptHistory(true);
2644 }, 200);
2645 return;
2646 }
2647 setShowPromptHistory(false);
2648 setTimeout(function() {
2649 return setShowModalWrapper(false);
2650 }, 500);
2651 };
2652 var handleDefaultHistoryState = function handleDefaultHistoryState() {
2653 if (showHistory) {
2654 var currentHeight = getContentHeight();
2655 setContentHeight(currentHeight);
2656 setTimeout(function() {
2657 if (currentHeight < vh(61)) {
2658 setContentHeight(vh(61));
2659 setTimeout(function() {
2660 return setShowModalWrapper(true);
2661 }, 200);
2662 setTimeout(function() {
2663 return setShowPromptHistory(true);
2664 }, 300);
2665 return;
2666 }
2667 setShowModalWrapper(true);
2668 setShowPromptHistory(true);
2669 }, 20);
2670 return;
2671 }
2672 setShowPromptHistory(false);
2673 setTimeout(function() {
2674 setShowModalWrapper(false);
2675 setContentHeight(getContentHeight());
2676 setTimeout(function() {
2677 return setContentHeight("auto");
2678 }, 300);
2679 }, 500);
2680 };
2681 (0, react.useEffect)(function() {
2682 if (showHistory === showModalWrapper && showHistory === showPromptHistory) return;
2683 if (historyType === HISTORY_TYPES.IMAGE) return handleFullScreenHistoryState();
2684 handleDefaultHistoryState();
2685 }, [showHistory]);
2686 return {
2687 historyType,
2688 isOpen: showPromptHistory,
2689 isModalOpen: showModalWrapper,
2690 showHistory,
2691 onOpen: function onOpen() {
2692 setShowHistory(true);
2693 },
2694 onClose: function onClose() {
2695 setShowHistory(false);
2696 },
2697 getContainer,
2698 getContainerHeight
2699 };
2700 };
2701 }));
2702
2703 //#endregion
2704 //#region modules/ai/assets/js/editor/components/prompt-history/context/prompt-history-action-context.js
2705 function _createForOfIteratorHelper$2(r, e) {
2706 var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
2707 if (!t) {
2708 if (Array.isArray(r) || (t = _unsupportedIterableToArray$2(r)) || e && r && "number" == typeof r.length) {
2709 t && (r = t);
2710 var _n = 0;
2711 var F = function F() {};
2712 return {
2713 s: F,
2714 n: function n() {
2715 return _n >= r.length ? { done: !0 } : {
2716 done: !1,
2717 value: r[_n++]
2718 };
2719 },
2720 e: function e(r) {
2721 throw r;
2722 },
2723 f: F
2724 };
2725 }
2726 throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2727 }
2728 var o;
2729 var a = !0;
2730 var u = !1;
2731 return {
2732 s: function s() {
2733 t = t.call(r);
2734 },
2735 n: function n() {
2736 var r = t.next();
2737 return a = r.done, r;
2738 },
2739 e: function e(r) {
2740 u = !0, o = r;
2741 },
2742 f: function f() {
2743 try {
2744 a || null == t.return || t.return();
2745 } finally {
2746 if (u) throw o;
2747 }
2748 }
2749 };
2750 }
2751 function _unsupportedIterableToArray$2(r, a) {
2752 if (r) {
2753 if ("string" == typeof r) return _arrayLikeToArray$2(r, a);
2754 var t = {}.toString.call(r).slice(8, -1);
2755 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;
2756 }
2757 }
2758 function _arrayLikeToArray$2(r, a) {
2759 (null == a || a > r.length) && (a = r.length);
2760 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
2761 return n;
2762 }
2763 var import_prop_types$4, PromptHistoryActionContext, initialActionValue, ACTION_TYPES, ENABLED_ACTIONS_BY_TYPE, PromptHistoryActionProvider, usePromptHistoryAction, useSubscribeOnPromptHistoryAction;
2764 var init_prompt_history_action_context = __esmMin((() => {
2765 init_slicedToArray();
2766 init_defineProperty();
2767 import_prop_types$4 = /* @__PURE__ */ __toESM(require_prop_types());
2768 init_history_types();
2769 init_prompt_history_context();
2770 __name(_createForOfIteratorHelper$2, "_createForOfIteratorHelper");
2771 __name(_unsupportedIterableToArray$2, "_unsupportedIterableToArray");
2772 __name(_arrayLikeToArray$2, "_arrayLikeToArray");
2773 PromptHistoryActionContext = (0, react.createContext)({});
2774 initialActionValue = {
2775 type: "",
2776 id: "",
2777 data: null
2778 };
2779 ACTION_TYPES = Object.freeze({
2780 REUSE: "reuse",
2781 EDIT: "edit",
2782 RESTORE: "restore",
2783 REMOVE: "remove"
2784 });
2785 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));
2786 PromptHistoryActionProvider = function PromptHistoryActionProvider(_ref) {
2787 var children = _ref.children;
2788 var _useState2 = _slicedToArray((0, react.useState)(initialActionValue), 2);
2789 var state = _useState2[0];
2790 var dispatch = _useState2[1];
2791 return /*#__PURE__*/ react.default.createElement(PromptHistoryActionContext.Provider, { value: {
2792 state,
2793 dispatch
2794 } }, children);
2795 };
2796 PromptHistoryActionProvider.propTypes = { children: import_prop_types$4.default.node };
2797 usePromptHistoryAction = function usePromptHistoryAction() {
2798 var _useContext = (0, react.useContext)(PromptHistoryActionContext);
2799 var state = _useContext.state;
2800 var dispatch = _useContext.dispatch;
2801 var _usePromptHistoryCont = usePromptHistoryContext();
2802 var historyType = _usePromptHistoryCont.historyType;
2803 var onClose = _usePromptHistoryCont.onClose;
2804 var closeModalAfterAction = function closeModalAfterAction(action) {
2805 return function() {
2806 action.apply(void 0, arguments);
2807 onClose();
2808 };
2809 };
2810 return {
2811 promptHistoryAction: state,
2812 onPromptReuse: closeModalAfterAction(function onPromptReuse(id, data) {
2813 return dispatch({
2814 type: ACTION_TYPES.REUSE,
2815 id,
2816 data
2817 });
2818 }),
2819 onResultEdit: closeModalAfterAction(function onResultEdit(id, data) {
2820 return dispatch({
2821 type: ACTION_TYPES.EDIT,
2822 id,
2823 data
2824 });
2825 }),
2826 onImagesRestore: closeModalAfterAction(function onImagesRestore(id, data) {
2827 return dispatch({
2828 type: ACTION_TYPES.RESTORE,
2829 id,
2830 data
2831 });
2832 }),
2833 getAllowedActions: function getAllowedActions() {
2834 return ENABLED_ACTIONS_BY_TYPE[historyType] || {};
2835 }
2836 };
2837 };
2838 useSubscribeOnPromptHistoryAction = function useSubscribeOnPromptHistoryAction(actions) {
2839 var state = (0, react.useContext)(PromptHistoryActionContext).state;
2840 (0, react.useEffect)(function() {
2841 if (!state.type) return;
2842 var _iterator = _createForOfIteratorHelper$2(actions);
2843 var _step;
2844 try {
2845 for (_iterator.s(); !(_step = _iterator.n()).done;) {
2846 var action = _step.value;
2847 if (state.type === (action === null || action === void 0 ? void 0 : action.type)) action === null || action === void 0 || action.handler(state);
2848 }
2849 } catch (err) {
2850 _iterator.e(err);
2851 } finally {
2852 _iterator.f();
2853 }
2854 }, [state]);
2855 };
2856 }));
2857
2858 //#endregion
2859 //#region modules/ai/assets/js/editor/icons/bulb-icon.js
2860 var BulbIcon;
2861 var init_bulb_icon = __esmMin((() => {
2862 init_extends();
2863 BulbIcon = react.default.forwardRef(function(props, ref) {
2864 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({}, props, { ref }), /*#__PURE__*/ react.default.createElement("svg", {
2865 width: "22",
2866 height: "22",
2867 viewBox: "0 0 22 22",
2868 fill: "none",
2869 xmlns: "http://www.w3.org/2000/svg"
2870 }, /*#__PURE__*/ react.default.createElement("g", { clipPath: "url(#clip0_10743_8902)" }, /*#__PURE__*/ react.default.createElement("path", {
2871 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",
2872 stroke: "#2563EB",
2873 strokeWidth: "1.5",
2874 strokeLinecap: "round",
2875 strokeLinejoin: "round"
2876 }), /*#__PURE__*/ react.default.createElement("path", {
2877 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",
2878 stroke: "#2563EB",
2879 strokeWidth: "1.5",
2880 strokeLinecap: "round",
2881 strokeLinejoin: "round"
2882 }), /*#__PURE__*/ react.default.createElement("path", {
2883 d: "M10.0833 16.5H11.9166",
2884 stroke: "#2563EB",
2885 strokeWidth: "1.5",
2886 strokeLinecap: "round",
2887 strokeLinejoin: "round"
2888 })), /*#__PURE__*/ react.default.createElement("defs", null, /*#__PURE__*/ react.default.createElement("clipPath", { id: "clip0_10743_8902" }, /*#__PURE__*/ react.default.createElement("rect", {
2889 width: "22",
2890 height: "22",
2891 fill: "white"
2892 })))));
2893 });
2894 }));
2895
2896 //#endregion
2897 //#region modules/ai/assets/js/editor/hooks/use-introduction.js
2898 function useIntroduction(key) {
2899 var _window$elementor$con;
2900 var _window$elementorAdmi;
2901 var _globalConfig$introdu;
2902 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;
2903 var _useState2 = _slicedToArray((0, react.useState)(!!(globalConfig !== null && globalConfig !== void 0 && (_globalConfig$introdu = globalConfig.introduction) !== null && _globalConfig$introdu !== void 0 && _globalConfig$introdu[key])), 2);
2904 var isViewed = _useState2[0];
2905 var setIsViewed = _useState2[1];
2906 function markAsViewed() {
2907 if (!key) return Promise.reject();
2908 return new Promise(function(resolve, reject) {
2909 if (isViewed) reject();
2910 setIsViewed(true);
2911 elementorCommon.ajax.addRequest("introduction_viewed", {
2912 data: { introductionKey: key },
2913 error: function error() {
2914 setIsViewed(false);
2915 reject();
2916 },
2917 success: function success() {
2918 setIsViewed(true);
2919 if (globalConfig !== null && globalConfig !== void 0 && globalConfig.introduction) globalConfig.introduction[key] = true;
2920 resolve();
2921 }
2922 });
2923 });
2924 }
2925 return {
2926 isViewed,
2927 markAsViewed
2928 };
2929 }
2930 var init_use_introduction = __esmMin((() => {
2931 init_slicedToArray();
2932 }));
2933
2934 //#endregion
2935 //#region modules/ai/assets/js/editor/components/voice-promotion-alert.js
2936 function ownKeys$28(e, r) {
2937 var t = Object.keys(e);
2938 if (Object.getOwnPropertySymbols) {
2939 var o = Object.getOwnPropertySymbols(e);
2940 r && (o = o.filter(function(r) {
2941 return Object.getOwnPropertyDescriptor(e, r).enumerable;
2942 })), t.push.apply(t, o);
2943 }
2944 return t;
2945 }
2946 function _objectSpread$28(e) {
2947 for (var r = 1; r < arguments.length; r++) {
2948 var t = null != arguments[r] ? arguments[r] : {};
2949 r % 2 ? ownKeys$28(Object(t), !0).forEach(function(r) {
2950 _defineProperty(e, r, t[r]);
2951 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$28(Object(t)).forEach(function(r) {
2952 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
2953 });
2954 }
2955 return e;
2956 }
2957 var import_prop_types$3, VoicePromotionAlert;
2958 var init_voice_promotion_alert = __esmMin((() => {
2959 init_defineProperty();
2960 init_bulb_icon();
2961 init_use_introduction();
2962 import_prop_types$3 = /* @__PURE__ */ __toESM(require_prop_types());
2963 __name(ownKeys$28, "ownKeys");
2964 __name(_objectSpread$28, "_objectSpread");
2965 VoicePromotionAlert = function VoicePromotionAlert(props) {
2966 var _useIntroduction = useIntroduction(props.introductionKey);
2967 var isViewed = _useIntroduction.isViewed;
2968 var markAsViewed = _useIntroduction.markAsViewed;
2969 if (isViewed) return null;
2970 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
2971 sx: _objectSpread$28({ mt: 2 }, props.sx),
2972 alignItems: "top"
2973 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Alert, {
2974 severity: "info",
2975 variant: "standard",
2976 icon: /*#__PURE__*/ react.default.createElement(BulbIcon, { sx: { alignSelf: "flex-start" } }),
2977 onClose: markAsViewed
2978 }, (0, _wordpress_i18n.__)("Get improved results from AI by adding personal context.", "elementor"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
2979 onClick: function onClick() {
2980 return $e.route("panel/global/menu");
2981 },
2982 className: "elementor-clickable",
2983 style: { textDecoration: "none" },
2984 color: "info.main",
2985 href: "#"
2986 }, (0, _wordpress_i18n.__)("Let’s do it", "elementor"))));
2987 };
2988 VoicePromotionAlert.propTypes = {
2989 sx: import_prop_types$3.default.object,
2990 introductionKey: import_prop_types$3.default.string
2991 };
2992 }));
2993
2994 //#endregion
2995 //#region modules/ai/assets/js/editor/pages/form-text/index.js
2996 init_asyncToGenerator();
2997 init_slicedToArray();
2998 init_actions_data();
2999 init_prompt_history_action_context();
3000 init_requests_ids();
3001 init_voice_promotion_alert();
3002 var promptActions = [
3003 {
3004 label: (0, _wordpress_i18n.__)("Simplify language", "elementor"),
3005 icon: /*#__PURE__*/ react.default.createElement(_elementor_icons.MessageIcon, { fontSize: "small" }),
3006 value: "Simplify the language of the following message"
3007 },
3008 {
3009 label: (0, _wordpress_i18n.__)("Make it longer", "elementor"),
3010 icon: /*#__PURE__*/ react.default.createElement(_elementor_icons.ExpandIcon, { fontSize: "small" }),
3011 value: "Make the following message longer"
3012 },
3013 {
3014 label: (0, _wordpress_i18n.__)("Make it shorter", "elementor"),
3015 icon: /*#__PURE__*/ react.default.createElement(_elementor_icons.ShrinkIcon, { fontSize: "small" }),
3016 value: "Make the following message shorter"
3017 },
3018 {
3019 label: (0, _wordpress_i18n.__)("Fix spelling & grammar", "elementor"),
3020 icon: /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { fontSize: "small" }),
3021 value: "Fix the spelling and grammar of the following message"
3022 }
3023 ];
3024 var promptInstructions = [{
3025 label: (0, _wordpress_i18n.__)("Change tone", "elementor"),
3026 options: vocalTones,
3027 getInstruction: function getInstruction(value) {
3028 return "Change the tone of the following message to ".concat(value);
3029 }
3030 }, {
3031 label: (0, _wordpress_i18n.__)("Translate to", "elementor"),
3032 options: translateLanguages,
3033 getInstruction: function getInstruction(value) {
3034 return "Translate the following message to ".concat(value);
3035 }
3036 }];
3037 var FormText = function FormText(_ref) {
3038 var _initialValue$result;
3039 var _initialValue$credits;
3040 var _additionalOptions$in;
3041 var type = _ref.type;
3042 var onClose = _ref.onClose;
3043 var getControlValue = _ref.getControlValue;
3044 var setControlValue = _ref.setControlValue;
3045 var additionalOptions = _ref.additionalOptions;
3046 var credits = _ref.credits;
3047 var children = _ref.children;
3048 var initialValue = getControlValue() === (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.defaultValue) ? "" : getControlValue();
3049 var _useTextPrompt = useTextPrompt({
3050 result: (_initialValue$result = initialValue === null || initialValue === void 0 ? void 0 : initialValue.result) !== null && _initialValue$result !== void 0 ? _initialValue$result : initialValue,
3051 credits: (_initialValue$credits = initialValue === null || initialValue === void 0 ? void 0 : initialValue.credits) !== null && _initialValue$credits !== void 0 ? _initialValue$credits : credits,
3052 responseId: initialValue === null || initialValue === void 0 ? void 0 : initialValue.responseId
3053 });
3054 var data = _useTextPrompt.data;
3055 var isLoading = _useTextPrompt.isLoading;
3056 var txtGenErr = _useTextPrompt.error;
3057 var setResult = _useTextPrompt.setResult;
3058 var reset = _useTextPrompt.reset;
3059 var send = _useTextPrompt.send;
3060 var sendUsageData = _useTextPrompt.sendUsageData;
3061 var error = txtGenErr || (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.initError);
3062 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
3063 var prompt = _useState2[0];
3064 var setPrompt = _useState2[1];
3065 var setGenerate = useRequestIds().setGenerate;
3066 useSubscribeOnPromptHistoryAction([{
3067 type: ACTION_TYPES.REUSE,
3068 handler: function handler(action) {
3069 reset();
3070 setPrompt(action.data);
3071 }
3072 }, {
3073 type: ACTION_TYPES.EDIT,
3074 handler: function handler(action) {
3075 setResult(action.data);
3076 }
3077 }]);
3078 var searchField = (0, react.useRef)(null);
3079 var resultField = (0, react.useRef)(null);
3080 var lastRun = (0, react.useRef)((_additionalOptions$in = additionalOptions.initRetry) !== null && _additionalOptions$in !== void 0 ? _additionalOptions$in : function() {});
3081 var autocompleteItems = "textarea" === type ? textareaAutocomplete : textAutocomplete;
3082 var showSuggestions = !prompt;
3083 var handleSubmit = function handleSubmit(event) {
3084 event.preventDefault();
3085 setGenerate();
3086 lastRun.current = function() {
3087 return send({ prompt });
3088 };
3089 lastRun.current();
3090 };
3091 var handleCustomInstruction = /*#__PURE__*/ function() {
3092 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee(instruction) {
3093 return import_regenerator$3.default.wrap(function(_context) {
3094 while (1) switch (_context.prev = _context.next) {
3095 case 0:
3096 setGenerate();
3097 lastRun.current = function() {
3098 return send({
3099 input: resultField.current.value,
3100 instruction
3101 });
3102 };
3103 lastRun.current();
3104 case 1:
3105 case "end": return _context.stop();
3106 }
3107 }, _callee);
3108 }));
3109 return function handleCustomInstruction(_x) {
3110 return _ref2.apply(this, arguments);
3111 };
3112 }();
3113 var handleSuggestion = function handleSuggestion(suggestion) {
3114 setPrompt(suggestion + " ");
3115 searchField.current.focus();
3116 };
3117 var applyPrompt = function applyPrompt() {
3118 sendUsageData();
3119 setControlValue(resultField.current.value);
3120 onClose();
3121 };
3122 if (isLoading) return /*#__PURE__*/ react.default.createElement(Loader, null);
3123 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, error && /*#__PURE__*/ react.default.createElement(PromptErrorMessage, {
3124 error,
3125 onRetry: lastRun.current,
3126 sx: { mb: 2.5 }
3127 }), children, !data.result && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
3128 component: "form",
3129 onSubmit: handleSubmit
3130 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: { mb: 2.5 } }, /*#__PURE__*/ react.default.createElement(PromptSearch, {
3131 ref: searchField,
3132 placeholder: (0, _wordpress_i18n.__)("Describe the text and tone you want to use...", "elementor"),
3133 name: "prompt",
3134 value: prompt,
3135 onChange: function onChange(event) {
3136 return setPrompt(event.target.value);
3137 }
3138 })), showSuggestions && /*#__PURE__*/ react.default.createElement(PromptSuggestions, {
3139 suggestions: autocompleteItems,
3140 onSelect: handleSuggestion,
3141 suggestionFilter: function suggestionFilter(suggestion) {
3142 return suggestion + "...";
3143 }
3144 }, /*#__PURE__*/ react.default.createElement(PromptLibraryLink, { libraryLink: "https://go.elementor.com/ai-prompt-library-text/" })), additionalOptions.hideAiContext ? null : /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, {
3145 introductionKey: "ai-context-text-promotion",
3146 sx: { mb: 2 }
3147 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3148 direction: "row",
3149 alignItems: "center",
3150 sx: {
3151 pb: 1.5,
3152 mt: 2
3153 }
3154 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3155 direction: "row",
3156 justifyContent: "flex-end",
3157 flexGrow: 1
3158 }, /*#__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, {
3159 fullWidth: true,
3160 ref: resultField,
3161 value: data.result,
3162 helperText: (0, _wordpress_i18n.__)("Text generated by AI may be inaccurate or offensive.", "elementor"),
3163 onChange: function onChange(event) {
3164 return setResult(event.target.value);
3165 }
3166 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Grid, {
3167 container: true,
3168 spacing: 1,
3169 sx: { mt: 2.5 }
3170 }, promptActions.map(function(_ref3) {
3171 var label = _ref3.label;
3172 var icon = _ref3.icon;
3173 var value = _ref3.value;
3174 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Grid, {
3175 item: true,
3176 key: label
3177 }, /*#__PURE__*/ react.default.createElement(PromptAction, {
3178 label,
3179 icon,
3180 onClick: function onClick() {
3181 return handleCustomInstruction(value);
3182 }
3183 }));
3184 })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3185 direction: "row",
3186 alignItems: "center",
3187 spacing: 1,
3188 sx: { mt: 2.5 }
3189 }, promptInstructions.map(function(_ref4) {
3190 var label = _ref4.label;
3191 var options = _ref4.options;
3192 var getInstruction = _ref4.getInstruction;
3193 return /*#__PURE__*/ react.default.createElement(PromptActionSelection, {
3194 key: label,
3195 label,
3196 options,
3197 onChange: function onChange(event) {
3198 return handleCustomInstruction(getInstruction(event.target.value));
3199 }
3200 });
3201 })), additionalOptions.hideAiContext ? null : /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, {
3202 introductionKey: "ai-context-text-promotion",
3203 sx: { mb: 2 }
3204 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3205 direction: "row",
3206 alignItems: "center",
3207 sx: { my: 1 }
3208 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3209 direction: "row",
3210 gap: 1,
3211 justifyContent: "flex-end",
3212 flexGrow: 1
3213 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
3214 size: "small",
3215 color: "secondary",
3216 variant: "text",
3217 onClick: reset
3218 }, (0, _wordpress_i18n.__)("New prompt", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
3219 size: "small",
3220 variant: "contained",
3221 color: "primary",
3222 onClick: applyPrompt
3223 }, (0, _wordpress_i18n.__)("Use text", "elementor"))))));
3224 };
3225 FormText.propTypes = {
3226 type: import_prop_types$12.default.string.isRequired,
3227 controlType: import_prop_types$12.default.string,
3228 onClose: import_prop_types$12.default.func.isRequired,
3229 getControlValue: import_prop_types$12.default.func.isRequired,
3230 setControlValue: import_prop_types$12.default.func.isRequired,
3231 additionalOptions: import_prop_types$12.default.object,
3232 credits: import_prop_types$12.default.number,
3233 usagePercentage: import_prop_types$12.default.number,
3234 children: import_prop_types$12.default.node
3235 };
3236
3237 //#endregion
3238 //#region modules/ai/assets/js/editor/pages/connect/index.js
3239 var Connect = function Connect(_ref) {
3240 var connectUrl = _ref.connectUrl;
3241 var onSuccess = _ref.onSuccess;
3242 var approveButtonRef = (0, react.useRef)();
3243 (0, react.useEffect)(function() {
3244 if (!jQuery.fn.elementorConnect) return;
3245 jQuery(approveButtonRef.current).elementorConnect({
3246 success: function success(_, data) {
3247 return onSuccess(data);
3248 },
3249 error: function error() {
3250 throw new Error("Elementor AI: Failed to connect.");
3251 }
3252 });
3253 }, []);
3254 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3255 alignItems: "center",
3256 gap: 2
3257 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { sx: {
3258 color: "text.primary",
3259 fontSize: "60px",
3260 mb: 1
3261 } }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
3262 variant: "h4",
3263 sx: { color: "text.primary" }
3264 }, (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, {
3265 variant: "caption",
3266 sx: {
3267 maxWidth: 520,
3268 textAlign: "center"
3269 }
3270 }, " ", (0, _wordpress_i18n.__)("By clicking \"Connect\", I approve the ", "elementor"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
3271 href: "https://go.elementor.com/ai-terms/",
3272 target: "_blank",
3273 color: "info.main"
3274 }, (0, _wordpress_i18n.__)("Terms of Service", "elementor")), " & ", /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
3275 href: "https://go.elementor.com/ai-privacy-policy/",
3276 target: "_blank",
3277 color: "info.main"
3278 }, (0, _wordpress_i18n.__)("Privacy Policy", "elementor")), (0, _wordpress_i18n.__)(" of the Elementor AI service.", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
3279 ref: approveButtonRef,
3280 href: connectUrl,
3281 variant: "contained",
3282 sx: {
3283 mt: 1,
3284 "&:hover": { color: "primary.contrastText" }
3285 }
3286 }, (0, _wordpress_i18n.__)("Connect", "elementor")));
3287 };
3288 Connect.propTypes = {
3289 connectUrl: import_prop_types$12.default.string.isRequired,
3290 onSuccess: import_prop_types$12.default.func.isRequired
3291 };
3292
3293 //#endregion
3294 //#region modules/ai/assets/js/editor/pages/get-started/index.js
3295 init_asyncToGenerator();
3296 init_slicedToArray();
3297 init_api();
3298 var GetStarted = function GetStarted(_ref) {
3299 var onSuccess = _ref.onSuccess;
3300 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
3301 var isTermsChecked = _useState2[0];
3302 var setIsTermsChecked = _useState2[1];
3303 var onGetStartedClick = /*#__PURE__*/ function() {
3304 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee() {
3305 return import_regenerator$3.default.wrap(function(_context) {
3306 while (1) switch (_context.prev = _context.next) {
3307 case 0:
3308 _context.next = 1;
3309 return setGetStarted();
3310 case 1: onSuccess();
3311 case 2:
3312 case "end": return _context.stop();
3313 }
3314 }, _callee);
3315 }));
3316 return function onGetStartedClick() {
3317 return _ref2.apply(this, arguments);
3318 };
3319 }();
3320 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3321 alignItems: "center",
3322 gap: 1.5
3323 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { sx: {
3324 color: "text.primary",
3325 fontSize: "60px",
3326 mb: 1
3327 } }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
3328 variant: "h4",
3329 sx: { color: "text.primary" }
3330 }, (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, {
3331 direction: "row",
3332 gap: 1.5,
3333 alignItems: "flex-start"
3334 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Checkbox, {
3335 id: "e-ai-terms-approval",
3336 color: "secondary",
3337 checked: isTermsChecked,
3338 onClick: function onClick() {
3339 return setIsTermsChecked(function(prevState) {
3340 return !prevState;
3341 });
3342 }
3343 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
3344 variant: "caption",
3345 sx: { maxWidth: 520 },
3346 component: "label",
3347 htmlFor: "e-ai-terms-approval"
3348 }, " ", (0, _wordpress_i18n.__)("I approve the ", "elementor"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
3349 href: "https://go.elementor.com/ai-terms/",
3350 target: "_blank",
3351 color: "info.main"
3352 }, (0, _wordpress_i18n.__)("Terms of Service", "elementor")), " & ", /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
3353 href: "https://go.elementor.com/ai-privacy-policy/",
3354 target: "_blank",
3355 color: "info.main"
3356 }, (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, {
3357 disabled: !isTermsChecked,
3358 variant: "contained",
3359 onClick: onGetStartedClick,
3360 sx: {
3361 mt: 1,
3362 "&:hover": { color: "primary.contrastText" }
3363 }
3364 }, (0, _wordpress_i18n.__)("Get Started", "elementor")));
3365 };
3366 GetStarted.propTypes = { onSuccess: import_prop_types$12.default.func.isRequired };
3367
3368 //#endregion
3369 //#region modules/ai/assets/js/editor/components/dialog-header.js
3370 init_extends();
3371 var StyledElementorLogo = (0, _elementor_ui.styled)(function ElementorLogo(props) {
3372 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 32 32" }, props), /*#__PURE__*/ react.default.createElement("path", {
3373 fillRule: "evenodd",
3374 clipRule: "evenodd",
3375 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"
3376 }));
3377 })(function(_ref) {
3378 var theme = _ref.theme;
3379 return {
3380 width: theme.spacing(3),
3381 height: theme.spacing(3),
3382 "& path": { fill: theme.palette.text.primary }
3383 };
3384 });
3385 var DialogHeader$1 = function DialogHeader(props) {
3386 var hideAiBetaLogo = props.hideAiBetaLogo;
3387 var onClose = props.onClose;
3388 var children = props.children;
3389 return /*#__PURE__*/ react.default.createElement(_elementor_ui.AppBar, {
3390 sx: { fontWeight: "normal" },
3391 color: "transparent",
3392 position: "relative"
3393 }, /*#__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, {
3394 component: "span",
3395 variant: "subtitle2",
3396 sx: {
3397 fontWeight: "bold",
3398 textTransform: "uppercase"
3399 }
3400 }, (0, _wordpress_i18n.__)("AI", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Chip, {
3401 label: (0, _wordpress_i18n.__)("Beta", "elementor"),
3402 color: "default",
3403 size: "small",
3404 sx: { ml: 1 }
3405 })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3406 direction: "row",
3407 spacing: 1,
3408 alignItems: "center",
3409 sx: { ml: hideAiBetaLogo ? 0 : "auto" }
3410 }, children, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
3411 size: "small",
3412 "aria-label": "close",
3413 onClick: onClose,
3414 sx: { "&.MuiButtonBase-root": { mr: -1 } }
3415 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.XIcon, null)))));
3416 };
3417 DialogHeader$1.propTypes = {
3418 onClose: import_prop_types$12.default.func.isRequired,
3419 hideAiBetaLogo: import_prop_types$12.default.bool,
3420 children: import_prop_types$12.default.oneOfType([import_prop_types$12.default.arrayOf(import_prop_types$12.default.node), import_prop_types$12.default.node])
3421 };
3422
3423 //#endregion
3424 //#region modules/ai/assets/js/editor/components/wizard-dialog.js
3425 init_extends();
3426 init_defineProperty();
3427 init_objectWithoutProperties();
3428 var _excluded$30 = ["sx"];
3429 function ownKeys$27(e, r) {
3430 var t = Object.keys(e);
3431 if (Object.getOwnPropertySymbols) {
3432 var o = Object.getOwnPropertySymbols(e);
3433 r && (o = o.filter(function(r) {
3434 return Object.getOwnPropertyDescriptor(e, r).enumerable;
3435 })), t.push.apply(t, o);
3436 }
3437 return t;
3438 }
3439 __name(ownKeys$27, "ownKeys");
3440 function _objectSpread$27(e) {
3441 for (var r = 1; r < arguments.length; r++) {
3442 var t = null != arguments[r] ? arguments[r] : {};
3443 r % 2 ? ownKeys$27(Object(t), !0).forEach(function(r) {
3444 _defineProperty(e, r, t[r]);
3445 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$27(Object(t)).forEach(function(r) {
3446 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
3447 });
3448 }
3449 return e;
3450 }
3451 __name(_objectSpread$27, "_objectSpread");
3452 var WizardDialog = function WizardDialog(props) {
3453 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, {
3454 open: true,
3455 onClose: props.onClose,
3456 fullWidth: true,
3457 hideBackdrop: true,
3458 maxWidth: "lg",
3459 PaperProps: { sx: { height: "88vh" } },
3460 sx: { zIndex: 9999 }
3461 }, props.children);
3462 };
3463 WizardDialog.propTypes = {
3464 onClose: import_prop_types$12.default.func.isRequired,
3465 children: import_prop_types$12.default.node.isRequired
3466 };
3467 var WizardDialogContent = function WizardDialogContent(_ref) {
3468 var _ref$sx = _ref.sx;
3469 var sx = _ref$sx === void 0 ? {} : _ref$sx;
3470 var props = _objectWithoutProperties(_ref, _excluded$30);
3471 return /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogContent, _extends$1({}, props, { sx: _objectSpread$27({
3472 display: "flex",
3473 flexDirection: "column",
3474 justifyContent: "center"
3475 }, sx) }));
3476 };
3477 WizardDialogContent.propTypes = { sx: import_prop_types$12.default.object };
3478 WizardDialog.Header = DialogHeader$1;
3479 WizardDialog.Content = WizardDialogContent;
3480
3481 //#endregion
3482 //#region node_modules/react-draggable/node_modules/clsx/dist/clsx.js
3483 var require_clsx = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3484 function r(e) {
3485 var o;
3486 var t;
3487 var f = "";
3488 if ("string" == typeof e || "number" == typeof e) f += e;
3489 else if ("object" == typeof e) if (Array.isArray(e)) {
3490 var n = e.length;
3491 for (o = 0; o < n; o++) e[o] && (t = r(e[o])) && (f && (f += " "), f += t);
3492 } else for (t in e) e[t] && (f && (f += " "), f += t);
3493 return f;
3494 }
3495 function e() {
3496 for (var e, o, t = 0, f = "", n = arguments.length; t < n; t++) (e = arguments[t]) && (o = r(e)) && (f && (f += " "), f += o);
3497 return f;
3498 }
3499 module.exports = e, module.exports.clsx = e;
3500 }));
3501
3502 //#endregion
3503 //#region node_modules/react-draggable/build/cjs/utils/shims.js
3504 var require_shims = /* @__PURE__ */ __commonJSMin(((exports) => {
3505 Object.defineProperty(exports, "__esModule", { value: true });
3506 exports.dontSetMe = dontSetMe;
3507 exports.findInArray = findInArray;
3508 exports.int = int;
3509 exports.isFunction = isFunction;
3510 exports.isNum = isNum;
3511 function findInArray(array, callback) {
3512 for (let i = 0, length = array.length; i < length; i++) if (callback.apply(callback, [
3513 array[i],
3514 i,
3515 array
3516 ])) return array[i];
3517 }
3518 function isFunction(func) {
3519 return typeof func === "function" || Object.prototype.toString.call(func) === "[object Function]";
3520 }
3521 function isNum(num) {
3522 return typeof num === "number" && !isNaN(num);
3523 }
3524 function int(a) {
3525 return parseInt(a, 10);
3526 }
3527 function dontSetMe(props, propName, componentName) {
3528 if (props[propName]) return /* @__PURE__ */ new Error(`Invalid prop ${propName} passed to ${componentName} - do not set this, set it on the child.`);
3529 }
3530 }));
3531
3532 //#endregion
3533 //#region node_modules/react-draggable/build/cjs/utils/getPrefix.js
3534 var require_getPrefix = /* @__PURE__ */ __commonJSMin(((exports) => {
3535 Object.defineProperty(exports, "__esModule", { value: true });
3536 exports.browserPrefixToKey = browserPrefixToKey;
3537 exports.browserPrefixToStyle = browserPrefixToStyle;
3538 exports.default = void 0;
3539 exports.getPrefix = getPrefix;
3540 var prefixes = [
3541 "Moz",
3542 "Webkit",
3543 "O",
3544 "ms"
3545 ];
3546 function getPrefix() {
3547 var _window$document;
3548 let prop = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "transform";
3549 if (typeof window === "undefined") return "";
3550 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;
3551 if (!style) return "";
3552 if (prop in style) return "";
3553 for (let i = 0; i < prefixes.length; i++) if (browserPrefixToKey(prop, prefixes[i]) in style) return prefixes[i];
3554 return "";
3555 }
3556 function browserPrefixToKey(prop, prefix) {
3557 return prefix ? `${prefix}${kebabToTitleCase(prop)}` : prop;
3558 }
3559 function browserPrefixToStyle(prop, prefix) {
3560 return prefix ? `-${prefix.toLowerCase()}-${prop}` : prop;
3561 }
3562 function kebabToTitleCase(str) {
3563 let out = "";
3564 let shouldCapitalize = true;
3565 for (let i = 0; i < str.length; i++) if (shouldCapitalize) {
3566 out += str[i].toUpperCase();
3567 shouldCapitalize = false;
3568 } else if (str[i] === "-") shouldCapitalize = true;
3569 else out += str[i];
3570 return out;
3571 }
3572 exports.default = getPrefix();
3573 }));
3574
3575 //#endregion
3576 //#region node_modules/react-draggable/build/cjs/utils/domFns.js
3577 var require_domFns = /* @__PURE__ */ __commonJSMin(((exports) => {
3578 init_objectSpread2();
3579 Object.defineProperty(exports, "__esModule", { value: true });
3580 exports.addClassName = addClassName;
3581 exports.addEvent = addEvent;
3582 exports.addUserSelectStyles = addUserSelectStyles;
3583 exports.createCSSTransform = createCSSTransform;
3584 exports.createSVGTransform = createSVGTransform;
3585 exports.getTouch = getTouch;
3586 exports.getTouchIdentifier = getTouchIdentifier;
3587 exports.getTranslation = getTranslation;
3588 exports.innerHeight = innerHeight;
3589 exports.innerWidth = innerWidth;
3590 exports.matchesSelector = matchesSelector;
3591 exports.matchesSelectorAndParentsTo = matchesSelectorAndParentsTo;
3592 exports.offsetXYFromParent = offsetXYFromParent;
3593 exports.outerHeight = outerHeight;
3594 exports.outerWidth = outerWidth;
3595 exports.removeClassName = removeClassName;
3596 exports.removeEvent = removeEvent;
3597 exports.scheduleRemoveUserSelectStyles = scheduleRemoveUserSelectStyles;
3598 var _shims = require_shims();
3599 var _getPrefix = _interopRequireWildcard(require_getPrefix());
3600 function _interopRequireWildcard(e, t) {
3601 if ("function" == typeof WeakMap) {
3602 var r = /* @__PURE__ */ new WeakMap();
3603 var n = /* @__PURE__ */ new WeakMap();
3604 }
3605 return (_interopRequireWildcard = function(e, t) {
3606 if (!t && e && e.__esModule) return e;
3607 var o;
3608 var i;
3609 var f = {
3610 __proto__: null,
3611 default: e
3612 };
3613 if (null === e || "object" != typeof e && "function" != typeof e) return f;
3614 if (o = t ? n : r) {
3615 if (o.has(e)) return o.get(e);
3616 o.set(e, f);
3617 }
3618 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]);
3619 return f;
3620 })(e, t);
3621 }
3622 var matchesSelectorFunc = "";
3623 function matchesSelector(el, selector) {
3624 if (!matchesSelectorFunc) matchesSelectorFunc = (0, _shims.findInArray)([
3625 "matches",
3626 "webkitMatchesSelector",
3627 "mozMatchesSelector",
3628 "msMatchesSelector",
3629 "oMatchesSelector"
3630 ], function(method) {
3631 return (0, _shims.isFunction)(el[method]);
3632 });
3633 if (!(0, _shims.isFunction)(el[matchesSelectorFunc])) return false;
3634 return el[matchesSelectorFunc](selector);
3635 }
3636 function matchesSelectorAndParentsTo(el, selector, baseNode) {
3637 let node = el;
3638 do {
3639 if (matchesSelector(node, selector)) return true;
3640 if (node === baseNode) return false;
3641 node = node.parentNode;
3642 } while (node);
3643 return false;
3644 }
3645 function addEvent(el, event, handler, inputOptions) {
3646 if (!el) return;
3647 const options = _objectSpread2({ capture: true }, inputOptions);
3648 if (el.addEventListener) el.addEventListener(event, handler, options);
3649 else if (el.attachEvent) el.attachEvent("on" + event, handler);
3650 else el["on" + event] = handler;
3651 }
3652 function removeEvent(el, event, handler, inputOptions) {
3653 if (!el) return;
3654 const options = _objectSpread2({ capture: true }, inputOptions);
3655 if (el.removeEventListener) el.removeEventListener(event, handler, options);
3656 else if (el.detachEvent) el.detachEvent("on" + event, handler);
3657 else el["on" + event] = null;
3658 }
3659 function outerHeight(node) {
3660 let height = node.clientHeight;
3661 const computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
3662 height += (0, _shims.int)(computedStyle.borderTopWidth);
3663 height += (0, _shims.int)(computedStyle.borderBottomWidth);
3664 return height;
3665 }
3666 function outerWidth(node) {
3667 let width = node.clientWidth;
3668 const computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
3669 width += (0, _shims.int)(computedStyle.borderLeftWidth);
3670 width += (0, _shims.int)(computedStyle.borderRightWidth);
3671 return width;
3672 }
3673 function innerHeight(node) {
3674 let height = node.clientHeight;
3675 const computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
3676 height -= (0, _shims.int)(computedStyle.paddingTop);
3677 height -= (0, _shims.int)(computedStyle.paddingBottom);
3678 return height;
3679 }
3680 function innerWidth(node) {
3681 let width = node.clientWidth;
3682 const computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
3683 width -= (0, _shims.int)(computedStyle.paddingLeft);
3684 width -= (0, _shims.int)(computedStyle.paddingRight);
3685 return width;
3686 }
3687 function offsetXYFromParent(evt, offsetParent, scale) {
3688 const offsetParentRect = offsetParent === offsetParent.ownerDocument.body ? {
3689 left: 0,
3690 top: 0
3691 } : offsetParent.getBoundingClientRect();
3692 return {
3693 x: (evt.clientX + offsetParent.scrollLeft - offsetParentRect.left) / scale,
3694 y: (evt.clientY + offsetParent.scrollTop - offsetParentRect.top) / scale
3695 };
3696 }
3697 function createCSSTransform(controlPos, positionOffset) {
3698 const translation = getTranslation(controlPos, positionOffset, "px");
3699 return { [(0, _getPrefix.browserPrefixToKey)("transform", _getPrefix.default)]: translation };
3700 }
3701 function createSVGTransform(controlPos, positionOffset) {
3702 return getTranslation(controlPos, positionOffset, "");
3703 }
3704 function getTranslation(_ref, positionOffset, unitSuffix) {
3705 let { x, y } = _ref;
3706 let translation = `translate(${x}${unitSuffix},${y}${unitSuffix})`;
3707 if (positionOffset) translation = `translate(${`${typeof positionOffset.x === "string" ? positionOffset.x : positionOffset.x + unitSuffix}`}, ${`${typeof positionOffset.y === "string" ? positionOffset.y : positionOffset.y + unitSuffix}`})` + translation;
3708 return translation;
3709 }
3710 function getTouch(e, identifier) {
3711 return e.targetTouches && (0, _shims.findInArray)(e.targetTouches, (t) => identifier === t.identifier) || e.changedTouches && (0, _shims.findInArray)(e.changedTouches, (t) => identifier === t.identifier);
3712 }
3713 function getTouchIdentifier(e) {
3714 if (e.targetTouches && e.targetTouches[0]) return e.targetTouches[0].identifier;
3715 if (e.changedTouches && e.changedTouches[0]) return e.changedTouches[0].identifier;
3716 }
3717 function addUserSelectStyles(doc) {
3718 if (!doc) return;
3719 let styleEl = doc.getElementById("react-draggable-style-el");
3720 if (!styleEl) {
3721 styleEl = doc.createElement("style");
3722 styleEl.type = "text/css";
3723 styleEl.id = "react-draggable-style-el";
3724 styleEl.innerHTML = ".react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n";
3725 styleEl.innerHTML += ".react-draggable-transparent-selection *::selection {all: inherit;}\n";
3726 doc.getElementsByTagName("head")[0].appendChild(styleEl);
3727 }
3728 if (doc.body) addClassName(doc.body, "react-draggable-transparent-selection");
3729 }
3730 function scheduleRemoveUserSelectStyles(doc) {
3731 if (window.requestAnimationFrame) window.requestAnimationFrame(() => {
3732 removeUserSelectStyles(doc);
3733 });
3734 else removeUserSelectStyles(doc);
3735 }
3736 function removeUserSelectStyles(doc) {
3737 if (!doc) return;
3738 try {
3739 if (doc.body) removeClassName(doc.body, "react-draggable-transparent-selection");
3740 if (doc.selection) doc.selection.empty();
3741 else {
3742 const selection = (doc.defaultView || window).getSelection();
3743 if (selection && selection.type !== "Caret") selection.removeAllRanges();
3744 }
3745 } catch (e) {}
3746 }
3747 function addClassName(el, className) {
3748 if (el.classList) el.classList.add(className);
3749 else if (!el.className.match(new RegExp(`(?:^|\\s)${className}(?!\\S)`))) el.className += ` ${className}`;
3750 }
3751 function removeClassName(el, className) {
3752 if (el.classList) el.classList.remove(className);
3753 else el.className = el.className.replace(new RegExp(`(?:^|\\s)${className}(?!\\S)`, "g"), "");
3754 }
3755 }));
3756
3757 //#endregion
3758 //#region node_modules/react-draggable/build/cjs/utils/positionFns.js
3759 var require_positionFns = /* @__PURE__ */ __commonJSMin(((exports) => {
3760 Object.defineProperty(exports, "__esModule", { value: true });
3761 exports.canDragX = canDragX;
3762 exports.canDragY = canDragY;
3763 exports.createCoreData = createCoreData;
3764 exports.createDraggableData = createDraggableData;
3765 exports.getBoundPosition = getBoundPosition;
3766 exports.getControlPosition = getControlPosition;
3767 exports.snapToGrid = snapToGrid;
3768 var _shims = require_shims();
3769 var _domFns = require_domFns();
3770 function getBoundPosition(draggable, x, y) {
3771 if (!draggable.props.bounds) return [x, y];
3772 let { bounds } = draggable.props;
3773 bounds = typeof bounds === "string" ? bounds : cloneBounds(bounds);
3774 const node = findDOMNode(draggable);
3775 if (typeof bounds === "string") {
3776 const { ownerDocument } = node;
3777 const ownerWindow = ownerDocument.defaultView;
3778 let boundNode;
3779 if (bounds === "parent") boundNode = node.parentNode;
3780 else boundNode = node.getRootNode().querySelector(bounds);
3781 if (!(boundNode instanceof ownerWindow.HTMLElement)) throw new Error("Bounds selector \"" + bounds + "\" could not find an element.");
3782 const boundNodeEl = boundNode;
3783 const nodeStyle = ownerWindow.getComputedStyle(node);
3784 const boundNodeStyle = ownerWindow.getComputedStyle(boundNodeEl);
3785 bounds = {
3786 left: -node.offsetLeft + (0, _shims.int)(boundNodeStyle.paddingLeft) + (0, _shims.int)(nodeStyle.marginLeft),
3787 top: -node.offsetTop + (0, _shims.int)(boundNodeStyle.paddingTop) + (0, _shims.int)(nodeStyle.marginTop),
3788 right: (0, _domFns.innerWidth)(boundNodeEl) - (0, _domFns.outerWidth)(node) - node.offsetLeft + (0, _shims.int)(boundNodeStyle.paddingRight) - (0, _shims.int)(nodeStyle.marginRight),
3789 bottom: (0, _domFns.innerHeight)(boundNodeEl) - (0, _domFns.outerHeight)(node) - node.offsetTop + (0, _shims.int)(boundNodeStyle.paddingBottom) - (0, _shims.int)(nodeStyle.marginBottom)
3790 };
3791 }
3792 if ((0, _shims.isNum)(bounds.right)) x = Math.min(x, bounds.right);
3793 if ((0, _shims.isNum)(bounds.bottom)) y = Math.min(y, bounds.bottom);
3794 if ((0, _shims.isNum)(bounds.left)) x = Math.max(x, bounds.left);
3795 if ((0, _shims.isNum)(bounds.top)) y = Math.max(y, bounds.top);
3796 return [x, y];
3797 }
3798 function snapToGrid(grid, pendingX, pendingY) {
3799 return [Math.round(pendingX / grid[0]) * grid[0], Math.round(pendingY / grid[1]) * grid[1]];
3800 }
3801 function canDragX(draggable) {
3802 return draggable.props.axis === "both" || draggable.props.axis === "x";
3803 }
3804 function canDragY(draggable) {
3805 return draggable.props.axis === "both" || draggable.props.axis === "y";
3806 }
3807 function getControlPosition(e, touchIdentifier, draggableCore) {
3808 const touchObj = typeof touchIdentifier === "number" ? (0, _domFns.getTouch)(e, touchIdentifier) : null;
3809 if (typeof touchIdentifier === "number" && !touchObj) return null;
3810 const node = findDOMNode(draggableCore);
3811 const offsetParent = draggableCore.props.offsetParent || node.offsetParent || node.ownerDocument.body;
3812 return (0, _domFns.offsetXYFromParent)(touchObj || e, offsetParent, draggableCore.props.scale);
3813 }
3814 function createCoreData(draggable, x, y) {
3815 const isStart = !(0, _shims.isNum)(draggable.lastX);
3816 const node = findDOMNode(draggable);
3817 if (isStart) return {
3818 node,
3819 deltaX: 0,
3820 deltaY: 0,
3821 lastX: x,
3822 lastY: y,
3823 x,
3824 y
3825 };
3826 else return {
3827 node,
3828 deltaX: x - draggable.lastX,
3829 deltaY: y - draggable.lastY,
3830 lastX: draggable.lastX,
3831 lastY: draggable.lastY,
3832 x,
3833 y
3834 };
3835 }
3836 function createDraggableData(draggable, coreData) {
3837 const scale = draggable.props.scale;
3838 return {
3839 node: coreData.node,
3840 x: draggable.state.x + coreData.deltaX / scale,
3841 y: draggable.state.y + coreData.deltaY / scale,
3842 deltaX: coreData.deltaX / scale,
3843 deltaY: coreData.deltaY / scale,
3844 lastX: draggable.state.x,
3845 lastY: draggable.state.y
3846 };
3847 }
3848 function cloneBounds(bounds) {
3849 return {
3850 left: bounds.left,
3851 top: bounds.top,
3852 right: bounds.right,
3853 bottom: bounds.bottom
3854 };
3855 }
3856 function findDOMNode(draggable) {
3857 const node = draggable.findDOMNode();
3858 if (!node) throw new Error("<DraggableCore>: Unmounted during event!");
3859 return node;
3860 }
3861 }));
3862
3863 //#endregion
3864 //#region node_modules/react-draggable/build/cjs/utils/log.js
3865 var require_log = /* @__PURE__ */ __commonJSMin(((exports) => {
3866 Object.defineProperty(exports, "__esModule", { value: true });
3867 exports.default = log;
3868 function log() {}
3869 }));
3870
3871 //#endregion
3872 //#region node_modules/react-draggable/build/cjs/DraggableCore.js
3873 var require_DraggableCore = /* @__PURE__ */ __commonJSMin(((exports) => {
3874 Object.defineProperty(exports, "__esModule", { value: true });
3875 exports.default = void 0;
3876 var React$135 = _interopRequireWildcard((globalThis.React));
3877 var _propTypes = _interopRequireDefault(require_prop_types());
3878 var _reactDom$1 = _interopRequireDefault((globalThis.ReactDOM));
3879 var _domFns = require_domFns();
3880 var _positionFns = require_positionFns();
3881 var _shims = require_shims();
3882 var _log = _interopRequireDefault(require_log());
3883 function _interopRequireDefault(e) {
3884 return e && e.__esModule ? e : { default: e };
3885 }
3886 function _interopRequireWildcard(e, t) {
3887 if ("function" == typeof WeakMap) {
3888 var r = /* @__PURE__ */ new WeakMap();
3889 var n = /* @__PURE__ */ new WeakMap();
3890 }
3891 return (_interopRequireWildcard = function(e, t) {
3892 if (!t && e && e.__esModule) return e;
3893 var o;
3894 var i;
3895 var f = {
3896 __proto__: null,
3897 default: e
3898 };
3899 if (null === e || "object" != typeof e && "function" != typeof e) return f;
3900 if (o = t ? n : r) {
3901 if (o.has(e)) return o.get(e);
3902 o.set(e, f);
3903 }
3904 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]);
3905 return f;
3906 })(e, t);
3907 }
3908 function _defineProperty(e, r, t) {
3909 return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
3910 value: t,
3911 enumerable: !0,
3912 configurable: !0,
3913 writable: !0
3914 }) : e[r] = t, e;
3915 }
3916 function _toPropertyKey(t) {
3917 var i = _toPrimitive(t, "string");
3918 return "symbol" == typeof i ? i : i + "";
3919 }
3920 function _toPrimitive(t, r) {
3921 if ("object" != typeof t || !t) return t;
3922 var e = t[Symbol.toPrimitive];
3923 if (void 0 !== e) {
3924 var i = e.call(t, r || "default");
3925 if ("object" != typeof i) return i;
3926 throw new TypeError("@@toPrimitive must return a primitive value.");
3927 }
3928 return ("string" === r ? String : Number)(t);
3929 }
3930 var eventsFor = {
3931 touch: {
3932 start: "touchstart",
3933 move: "touchmove",
3934 stop: "touchend"
3935 },
3936 mouse: {
3937 start: "mousedown",
3938 move: "mousemove",
3939 stop: "mouseup"
3940 }
3941 };
3942 var dragEventFor = eventsFor.mouse;
3943 var DraggableCore = class extends React$135.Component {
3944 constructor() {
3945 super(...arguments);
3946 _defineProperty(this, "dragging", false);
3947 _defineProperty(this, "lastX", NaN);
3948 _defineProperty(this, "lastY", NaN);
3949 _defineProperty(this, "touchIdentifier", null);
3950 _defineProperty(this, "mounted", false);
3951 _defineProperty(this, "handleDragStart", (e) => {
3952 this.props.onMouseDown(e);
3953 if (!this.props.allowAnyClick && typeof e.button === "number" && e.button !== 0) return false;
3954 const thisNode = this.findDOMNode();
3955 if (!thisNode || !thisNode.ownerDocument || !thisNode.ownerDocument.body) throw new Error("<DraggableCore> not mounted on DragStart!");
3956 const { ownerDocument } = thisNode;
3957 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;
3958 if (e.type === "touchstart" && !this.props.allowMobileScroll) e.preventDefault();
3959 const touchIdentifier = (0, _domFns.getTouchIdentifier)(e);
3960 this.touchIdentifier = touchIdentifier;
3961 const position = (0, _positionFns.getControlPosition)(e, touchIdentifier, this);
3962 if (position == null) return;
3963 const { x, y } = position;
3964 const coreEvent = (0, _positionFns.createCoreData)(this, x, y);
3965 (0, _log.default)("DraggableCore: handleDragStart: %j", coreEvent);
3966 (0, _log.default)("calling", this.props.onStart);
3967 if (this.props.onStart(e, coreEvent) === false || this.mounted === false) return;
3968 if (this.props.enableUserSelectHack) (0, _domFns.addUserSelectStyles)(ownerDocument);
3969 this.dragging = true;
3970 this.lastX = x;
3971 this.lastY = y;
3972 (0, _domFns.addEvent)(ownerDocument, dragEventFor.move, this.handleDrag);
3973 (0, _domFns.addEvent)(ownerDocument, dragEventFor.stop, this.handleDragStop);
3974 });
3975 _defineProperty(this, "handleDrag", (e) => {
3976 const position = (0, _positionFns.getControlPosition)(e, this.touchIdentifier, this);
3977 if (position == null) return;
3978 let { x, y } = position;
3979 if (Array.isArray(this.props.grid)) {
3980 let deltaX = x - this.lastX;
3981 let deltaY = y - this.lastY;
3982 [deltaX, deltaY] = (0, _positionFns.snapToGrid)(this.props.grid, deltaX, deltaY);
3983 if (!deltaX && !deltaY) return;
3984 x = this.lastX + deltaX, y = this.lastY + deltaY;
3985 }
3986 const coreEvent = (0, _positionFns.createCoreData)(this, x, y);
3987 (0, _log.default)("DraggableCore: handleDrag: %j", coreEvent);
3988 if (this.props.onDrag(e, coreEvent) === false || this.mounted === false) {
3989 try {
3990 this.handleDragStop(new MouseEvent("mouseup"));
3991 } catch (err) {
3992 const event = document.createEvent("MouseEvents");
3993 event.initMouseEvent("mouseup", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
3994 this.handleDragStop(event);
3995 }
3996 return;
3997 }
3998 this.lastX = x;
3999 this.lastY = y;
4000 });
4001 _defineProperty(this, "handleDragStop", (e) => {
4002 if (!this.dragging) return;
4003 const position = (0, _positionFns.getControlPosition)(e, this.touchIdentifier, this);
4004 if (position == null) return;
4005 let { x, y } = position;
4006 if (Array.isArray(this.props.grid)) {
4007 let deltaX = x - this.lastX || 0;
4008 let deltaY = y - this.lastY || 0;
4009 [deltaX, deltaY] = (0, _positionFns.snapToGrid)(this.props.grid, deltaX, deltaY);
4010 x = this.lastX + deltaX, y = this.lastY + deltaY;
4011 }
4012 const coreEvent = (0, _positionFns.createCoreData)(this, x, y);
4013 if (this.props.onStop(e, coreEvent) === false || this.mounted === false) return false;
4014 const thisNode = this.findDOMNode();
4015 if (thisNode) {
4016 if (this.props.enableUserSelectHack) (0, _domFns.scheduleRemoveUserSelectStyles)(thisNode.ownerDocument);
4017 }
4018 (0, _log.default)("DraggableCore: handleDragStop: %j", coreEvent);
4019 this.dragging = false;
4020 this.lastX = NaN;
4021 this.lastY = NaN;
4022 if (thisNode) {
4023 (0, _log.default)("DraggableCore: Removing handlers");
4024 (0, _domFns.removeEvent)(thisNode.ownerDocument, dragEventFor.move, this.handleDrag);
4025 (0, _domFns.removeEvent)(thisNode.ownerDocument, dragEventFor.stop, this.handleDragStop);
4026 }
4027 });
4028 _defineProperty(this, "onMouseDown", (e) => {
4029 dragEventFor = eventsFor.mouse;
4030 return this.handleDragStart(e);
4031 });
4032 _defineProperty(this, "onMouseUp", (e) => {
4033 dragEventFor = eventsFor.mouse;
4034 return this.handleDragStop(e);
4035 });
4036 _defineProperty(this, "onTouchStart", (e) => {
4037 dragEventFor = eventsFor.touch;
4038 return this.handleDragStart(e);
4039 });
4040 _defineProperty(this, "onTouchEnd", (e) => {
4041 dragEventFor = eventsFor.touch;
4042 return this.handleDragStop(e);
4043 });
4044 }
4045 componentDidMount() {
4046 this.mounted = true;
4047 const thisNode = this.findDOMNode();
4048 if (thisNode) (0, _domFns.addEvent)(thisNode, eventsFor.touch.start, this.onTouchStart, { passive: false });
4049 }
4050 componentWillUnmount() {
4051 this.mounted = false;
4052 const thisNode = this.findDOMNode();
4053 if (thisNode) {
4054 const { ownerDocument } = thisNode;
4055 (0, _domFns.removeEvent)(ownerDocument, eventsFor.mouse.move, this.handleDrag);
4056 (0, _domFns.removeEvent)(ownerDocument, eventsFor.touch.move, this.handleDrag);
4057 (0, _domFns.removeEvent)(ownerDocument, eventsFor.mouse.stop, this.handleDragStop);
4058 (0, _domFns.removeEvent)(ownerDocument, eventsFor.touch.stop, this.handleDragStop);
4059 (0, _domFns.removeEvent)(thisNode, eventsFor.touch.start, this.onTouchStart, { passive: false });
4060 if (this.props.enableUserSelectHack) (0, _domFns.scheduleRemoveUserSelectStyles)(ownerDocument);
4061 }
4062 }
4063 findDOMNode() {
4064 var _this$props;
4065 var _this$props2;
4066 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);
4067 }
4068 render() {
4069 return /*#__PURE__*/ React$135.cloneElement(React$135.Children.only(this.props.children), {
4070 onMouseDown: this.onMouseDown,
4071 onMouseUp: this.onMouseUp,
4072 onTouchEnd: this.onTouchEnd
4073 });
4074 }
4075 };
4076 exports.default = DraggableCore;
4077 _defineProperty(DraggableCore, "displayName", "DraggableCore");
4078 _defineProperty(DraggableCore, "propTypes", {
4079 /**
4080 * `allowAnyClick` allows dragging using any mouse button.
4081 * By default, we only accept the left button.
4082 *
4083 * Defaults to `false`.
4084 */
4085 allowAnyClick: _propTypes.default.bool,
4086 /**
4087 * `allowMobileScroll` turns off cancellation of the 'touchstart' event
4088 * on mobile devices. Only enable this if you are having trouble with click
4089 * events. Prefer using 'handle' / 'cancel' instead.
4090 *
4091 * Defaults to `false`.
4092 */
4093 allowMobileScroll: _propTypes.default.bool,
4094 children: _propTypes.default.node.isRequired,
4095 /**
4096 * `disabled`, if true, stops the <Draggable> from dragging. All handlers,
4097 * with the exception of `onMouseDown`, will not fire.
4098 */
4099 disabled: _propTypes.default.bool,
4100 /**
4101 * By default, we add 'user-select:none' attributes to the document body
4102 * to prevent ugly text selection during drag. If this is causing problems
4103 * for your app, set this to `false`.
4104 */
4105 enableUserSelectHack: _propTypes.default.bool,
4106 /**
4107 * `offsetParent`, if set, uses the passed DOM node to compute drag offsets
4108 * instead of using the parent node.
4109 */
4110 offsetParent: function(props, propName) {
4111 if (props[propName] && props[propName].nodeType !== 1) throw new Error("Draggable's offsetParent must be a DOM Node.");
4112 },
4113 /**
4114 * `grid` specifies the x and y that dragging should snap to.
4115 */
4116 grid: _propTypes.default.arrayOf(_propTypes.default.number),
4117 /**
4118 * `handle` specifies a selector to be used as the handle that initiates drag.
4119 *
4120 * Example:
4121 *
4122 * ```jsx
4123 * let App = React.createClass({
4124 * render: function () {
4125 * return (
4126 * <Draggable handle=".handle">
4127 * <div>
4128 * <div className="handle">Click me to drag</div>
4129 * <div>This is some other content</div>
4130 * </div>
4131 * </Draggable>
4132 * );
4133 * }
4134 * });
4135 * ```
4136 */
4137 handle: _propTypes.default.string,
4138 /**
4139 * `cancel` specifies a selector to be used to prevent drag initialization.
4140 *
4141 * Example:
4142 *
4143 * ```jsx
4144 * let App = React.createClass({
4145 * render: function () {
4146 * return(
4147 * <Draggable cancel=".cancel">
4148 * <div>
4149 * <div className="cancel">You can't drag from here</div>
4150 * <div>Dragging here works fine</div>
4151 * </div>
4152 * </Draggable>
4153 * );
4154 * }
4155 * });
4156 * ```
4157 */
4158 cancel: _propTypes.default.string,
4159 nodeRef: _propTypes.default.object,
4160 /**
4161 * Called when dragging starts.
4162 * If this function returns the boolean false, dragging will be canceled.
4163 */
4164 onStart: _propTypes.default.func,
4165 /**
4166 * Called while dragging.
4167 * If this function returns the boolean false, dragging will be canceled.
4168 */
4169 onDrag: _propTypes.default.func,
4170 /**
4171 * Called when dragging stops.
4172 * If this function returns the boolean false, the drag will remain active.
4173 */
4174 onStop: _propTypes.default.func,
4175 /**
4176 * A workaround option which can be passed if onMouseDown needs to be accessed,
4177 * since it'll always be blocked (as there is internal use of onMouseDown)
4178 */
4179 onMouseDown: _propTypes.default.func,
4180 /**
4181 * `scale`, if set, applies scaling while dragging an element
4182 */
4183 scale: _propTypes.default.number,
4184 /**
4185 * These properties should be defined on the child, not here.
4186 */
4187 className: _shims.dontSetMe,
4188 style: _shims.dontSetMe,
4189 transform: _shims.dontSetMe
4190 });
4191 _defineProperty(DraggableCore, "defaultProps", {
4192 allowAnyClick: false,
4193 allowMobileScroll: false,
4194 disabled: false,
4195 enableUserSelectHack: true,
4196 onStart: function() {},
4197 onDrag: function() {},
4198 onStop: function() {},
4199 onMouseDown: function() {},
4200 scale: 1
4201 });
4202 }));
4203
4204 //#endregion
4205 //#region node_modules/react-draggable/build/cjs/Draggable.js
4206 var require_Draggable = /* @__PURE__ */ __commonJSMin(((exports) => {
4207 init_objectSpread2();
4208 init_objectWithoutProperties$1();
4209 var _excluded = [
4210 "axis",
4211 "bounds",
4212 "children",
4213 "defaultPosition",
4214 "defaultClassName",
4215 "defaultClassNameDragging",
4216 "defaultClassNameDragged",
4217 "position",
4218 "positionOffset",
4219 "scale"
4220 ];
4221 Object.defineProperty(exports, "__esModule", { value: true });
4222 Object.defineProperty(exports, "DraggableCore", {
4223 enumerable: true,
4224 get: function() {
4225 return _DraggableCore.default;
4226 }
4227 });
4228 exports.default = void 0;
4229 var React$134 = _interopRequireWildcard((globalThis.React));
4230 var _propTypes = _interopRequireDefault(require_prop_types());
4231 var _reactDom = _interopRequireDefault((globalThis.ReactDOM));
4232 var _clsx = require_clsx();
4233 var _domFns = require_domFns();
4234 var _positionFns = require_positionFns();
4235 var _shims = require_shims();
4236 var _DraggableCore = _interopRequireDefault(require_DraggableCore());
4237 var _log = _interopRequireDefault(require_log());
4238 function _interopRequireDefault(e) {
4239 return e && e.__esModule ? e : { default: e };
4240 }
4241 function _interopRequireWildcard(e, t) {
4242 if ("function" == typeof WeakMap) {
4243 var r = /* @__PURE__ */ new WeakMap();
4244 var n = /* @__PURE__ */ new WeakMap();
4245 }
4246 return (_interopRequireWildcard = function(e, t) {
4247 if (!t && e && e.__esModule) return e;
4248 var o;
4249 var i;
4250 var f = {
4251 __proto__: null,
4252 default: e
4253 };
4254 if (null === e || "object" != typeof e && "function" != typeof e) return f;
4255 if (o = t ? n : r) {
4256 if (o.has(e)) return o.get(e);
4257 o.set(e, f);
4258 }
4259 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]);
4260 return f;
4261 })(e, t);
4262 }
4263 function _extends() {
4264 return _extends = Object.assign ? Object.assign.bind() : function(n) {
4265 for (var e = 1; e < arguments.length; e++) {
4266 var t = arguments[e];
4267 for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
4268 }
4269 return n;
4270 }, _extends.apply(null, arguments);
4271 }
4272 function _defineProperty(e, r, t) {
4273 return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
4274 value: t,
4275 enumerable: !0,
4276 configurable: !0,
4277 writable: !0
4278 }) : e[r] = t, e;
4279 }
4280 function _toPropertyKey(t) {
4281 var i = _toPrimitive(t, "string");
4282 return "symbol" == typeof i ? i : i + "";
4283 }
4284 function _toPrimitive(t, r) {
4285 if ("object" != typeof t || !t) return t;
4286 var e = t[Symbol.toPrimitive];
4287 if (void 0 !== e) {
4288 var i = e.call(t, r || "default");
4289 if ("object" != typeof i) return i;
4290 throw new TypeError("@@toPrimitive must return a primitive value.");
4291 }
4292 return ("string" === r ? String : Number)(t);
4293 }
4294 var Draggable = class extends React$134.Component {
4295 static getDerivedStateFromProps(_ref, _ref2) {
4296 let { position } = _ref;
4297 let { prevPropsPosition } = _ref2;
4298 if (position && (!prevPropsPosition || position.x !== prevPropsPosition.x || position.y !== prevPropsPosition.y)) {
4299 (0, _log.default)("Draggable: getDerivedStateFromProps %j", {
4300 position,
4301 prevPropsPosition
4302 });
4303 return {
4304 x: position.x,
4305 y: position.y,
4306 prevPropsPosition: _objectSpread2({}, position)
4307 };
4308 }
4309 return null;
4310 }
4311 constructor(props) {
4312 super(props);
4313 _defineProperty(this, "onDragStart", (e, coreData) => {
4314 (0, _log.default)("Draggable: onDragStart: %j", coreData);
4315 if (this.props.onStart(e, (0, _positionFns.createDraggableData)(this, coreData)) === false) return false;
4316 this.setState({
4317 dragging: true,
4318 dragged: true
4319 });
4320 });
4321 _defineProperty(this, "onDrag", (e, coreData) => {
4322 if (!this.state.dragging) return false;
4323 (0, _log.default)("Draggable: onDrag: %j", coreData);
4324 const uiData = (0, _positionFns.createDraggableData)(this, coreData);
4325 const newState = {
4326 x: uiData.x,
4327 y: uiData.y,
4328 slackX: 0,
4329 slackY: 0
4330 };
4331 if (this.props.bounds) {
4332 const { x, y } = newState;
4333 newState.x += this.state.slackX;
4334 newState.y += this.state.slackY;
4335 const [newStateX, newStateY] = (0, _positionFns.getBoundPosition)(this, newState.x, newState.y);
4336 newState.x = newStateX;
4337 newState.y = newStateY;
4338 newState.slackX = this.state.slackX + (x - newState.x);
4339 newState.slackY = this.state.slackY + (y - newState.y);
4340 uiData.x = newState.x;
4341 uiData.y = newState.y;
4342 uiData.deltaX = newState.x - this.state.x;
4343 uiData.deltaY = newState.y - this.state.y;
4344 }
4345 if (this.props.onDrag(e, uiData) === false) return false;
4346 this.setState(newState);
4347 });
4348 _defineProperty(this, "onDragStop", (e, coreData) => {
4349 if (!this.state.dragging) return false;
4350 if (this.props.onStop(e, (0, _positionFns.createDraggableData)(this, coreData)) === false) return false;
4351 (0, _log.default)("Draggable: onDragStop: %j", coreData);
4352 const newState = {
4353 dragging: false,
4354 slackX: 0,
4355 slackY: 0
4356 };
4357 if (Boolean(this.props.position)) {
4358 const { x, y } = this.props.position;
4359 newState.x = x;
4360 newState.y = y;
4361 }
4362 this.setState(newState);
4363 });
4364 this.state = {
4365 dragging: false,
4366 dragged: false,
4367 x: props.position ? props.position.x : props.defaultPosition.x,
4368 y: props.position ? props.position.y : props.defaultPosition.y,
4369 prevPropsPosition: _objectSpread2({}, props.position),
4370 slackX: 0,
4371 slackY: 0,
4372 isElementSVG: false
4373 };
4374 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.");
4375 }
4376 componentDidMount() {
4377 if (typeof window.SVGElement !== "undefined" && this.findDOMNode() instanceof window.SVGElement) this.setState({ isElementSVG: true });
4378 }
4379 componentWillUnmount() {
4380 if (this.state.dragging) this.setState({ dragging: false });
4381 }
4382 findDOMNode() {
4383 var _this$props$nodeRef$c;
4384 var _this$props;
4385 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);
4386 }
4387 render() {
4388 const _this$props2 = this.props, { axis, bounds, children, defaultPosition, defaultClassName, defaultClassNameDragging, defaultClassNameDragged, position, positionOffset, scale } = _this$props2, draggableCoreProps = _objectWithoutProperties$1(_this$props2, _excluded);
4389 let style = {};
4390 let svgTransform = null;
4391 const draggable = !Boolean(position) || this.state.dragging;
4392 const validPosition = position || defaultPosition;
4393 const transformOpts = {
4394 x: (0, _positionFns.canDragX)(this) && draggable ? this.state.x : validPosition.x,
4395 y: (0, _positionFns.canDragY)(this) && draggable ? this.state.y : validPosition.y
4396 };
4397 if (this.state.isElementSVG) svgTransform = (0, _domFns.createSVGTransform)(transformOpts, positionOffset);
4398 else style = (0, _domFns.createCSSTransform)(transformOpts, positionOffset);
4399 const className = (0, _clsx.clsx)(children.props.className || "", defaultClassName, {
4400 [defaultClassNameDragging]: this.state.dragging,
4401 [defaultClassNameDragged]: this.state.dragged
4402 });
4403 return /*#__PURE__*/ React$134.createElement(_DraggableCore.default, _extends({}, draggableCoreProps, {
4404 onStart: this.onDragStart,
4405 onDrag: this.onDrag,
4406 onStop: this.onDragStop
4407 }), /*#__PURE__*/ React$134.cloneElement(React$134.Children.only(children), {
4408 className,
4409 style: _objectSpread2(_objectSpread2({}, children.props.style), style),
4410 transform: svgTransform
4411 }));
4412 }
4413 };
4414 exports.default = Draggable;
4415 _defineProperty(Draggable, "displayName", "Draggable");
4416 _defineProperty(Draggable, "propTypes", _objectSpread2(_objectSpread2({}, _DraggableCore.default.propTypes), {}, {
4417 /**
4418 * `axis` determines which axis the draggable can move.
4419 *
4420 * Note that all callbacks will still return data as normal. This only
4421 * controls flushing to the DOM.
4422 *
4423 * 'both' allows movement horizontally and vertically.
4424 * 'x' limits movement to horizontal axis.
4425 * 'y' limits movement to vertical axis.
4426 * 'none' limits all movement.
4427 *
4428 * Defaults to 'both'.
4429 */
4430 axis: _propTypes.default.oneOf([
4431 "both",
4432 "x",
4433 "y",
4434 "none"
4435 ]),
4436 /**
4437 * `bounds` determines the range of movement available to the element.
4438 * Available values are:
4439 *
4440 * 'parent' restricts movement within the Draggable's parent node.
4441 *
4442 * Alternatively, pass an object with the following properties, all of which are optional:
4443 *
4444 * {left: LEFT_BOUND, right: RIGHT_BOUND, bottom: BOTTOM_BOUND, top: TOP_BOUND}
4445 *
4446 * All values are in px.
4447 *
4448 * Example:
4449 *
4450 * ```jsx
4451 * let App = React.createClass({
4452 * render: function () {
4453 * return (
4454 * <Draggable bounds={{right: 300, bottom: 300}}>
4455 * <div>Content</div>
4456 * </Draggable>
4457 * );
4458 * }
4459 * });
4460 * ```
4461 */
4462 bounds: _propTypes.default.oneOfType([
4463 _propTypes.default.shape({
4464 left: _propTypes.default.number,
4465 right: _propTypes.default.number,
4466 top: _propTypes.default.number,
4467 bottom: _propTypes.default.number
4468 }),
4469 _propTypes.default.string,
4470 _propTypes.default.oneOf([false])
4471 ]),
4472 defaultClassName: _propTypes.default.string,
4473 defaultClassNameDragging: _propTypes.default.string,
4474 defaultClassNameDragged: _propTypes.default.string,
4475 /**
4476 * `defaultPosition` specifies the x and y that the dragged item should start at
4477 *
4478 * Example:
4479 *
4480 * ```jsx
4481 * let App = React.createClass({
4482 * render: function () {
4483 * return (
4484 * <Draggable defaultPosition={{x: 25, y: 25}}>
4485 * <div>I start with transformX: 25px and transformY: 25px;</div>
4486 * </Draggable>
4487 * );
4488 * }
4489 * });
4490 * ```
4491 */
4492 defaultPosition: _propTypes.default.shape({
4493 x: _propTypes.default.number,
4494 y: _propTypes.default.number
4495 }),
4496 positionOffset: _propTypes.default.shape({
4497 x: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
4498 y: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
4499 }),
4500 /**
4501 * `position`, if present, defines the current position of the element.
4502 *
4503 * This is similar to how form elements in React work - if no `position` is supplied, the component
4504 * is uncontrolled.
4505 *
4506 * Example:
4507 *
4508 * ```jsx
4509 * let App = React.createClass({
4510 * render: function () {
4511 * return (
4512 * <Draggable position={{x: 25, y: 25}}>
4513 * <div>I start with transformX: 25px and transformY: 25px;</div>
4514 * </Draggable>
4515 * );
4516 * }
4517 * });
4518 * ```
4519 */
4520 position: _propTypes.default.shape({
4521 x: _propTypes.default.number,
4522 y: _propTypes.default.number
4523 }),
4524 /**
4525 * These properties should be defined on the child, not here.
4526 */
4527 className: _shims.dontSetMe,
4528 style: _shims.dontSetMe,
4529 transform: _shims.dontSetMe
4530 }));
4531 _defineProperty(Draggable, "defaultProps", _objectSpread2(_objectSpread2({}, _DraggableCore.default.defaultProps), {}, {
4532 axis: "both",
4533 bounds: false,
4534 defaultClassName: "react-draggable",
4535 defaultClassNameDragging: "react-draggable-dragging",
4536 defaultClassNameDragged: "react-draggable-dragged",
4537 defaultPosition: {
4538 x: 0,
4539 y: 0
4540 },
4541 scale: 1
4542 }));
4543 }));
4544
4545 //#endregion
4546 //#region node_modules/react-draggable/build/cjs/cjs.js
4547 var require_cjs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4548 var { default: Draggable, DraggableCore } = require_Draggable();
4549 module.exports = Draggable;
4550 module.exports.default = Draggable;
4551 module.exports.DraggableCore = DraggableCore;
4552 }));
4553
4554 //#endregion
4555 //#region modules/ai/assets/js/editor/components/prompt-dialog.js
4556 init_extends();
4557 init_defineProperty();
4558 init_slicedToArray();
4559 var import_cjs = /* @__PURE__ */ __toESM(require_cjs());
4560 function ownKeys$26(e, r) {
4561 var t = Object.keys(e);
4562 if (Object.getOwnPropertySymbols) {
4563 var o = Object.getOwnPropertySymbols(e);
4564 r && (o = o.filter(function(r) {
4565 return Object.getOwnPropertyDescriptor(e, r).enumerable;
4566 })), t.push.apply(t, o);
4567 }
4568 return t;
4569 }
4570 __name(ownKeys$26, "ownKeys");
4571 function _objectSpread$26(e) {
4572 for (var r = 1; r < arguments.length; r++) {
4573 var t = null != arguments[r] ? arguments[r] : {};
4574 r % 2 ? ownKeys$26(Object(t), !0).forEach(function(r) {
4575 _defineProperty(e, r, t[r]);
4576 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$26(Object(t)).forEach(function(r) {
4577 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
4578 });
4579 }
4580 return e;
4581 }
4582 __name(_objectSpread$26, "_objectSpread");
4583 var DraggablePaper = function DraggablePaper(props) {
4584 var _useState2 = _slicedToArray((0, react.useState)({
4585 x: 0,
4586 y: 0
4587 }), 2);
4588 var position = _useState2[0];
4589 var setPosition = _useState2[1];
4590 var paperRef = (0, react.useRef)(null);
4591 var timeout = (0, react.useRef)(null);
4592 var onDrag = function onDrag(_e, _ref) {
4593 var x = _ref.x;
4594 var y = _ref.y;
4595 return setPosition({
4596 x,
4597 y
4598 });
4599 };
4600 var handlePositionBoundaries = function handlePositionBoundaries() {
4601 clearTimeout(timeout.current);
4602 timeout.current = setTimeout(function() {
4603 var _paperRef$current;
4604 var dialogTop = (_paperRef$current = paperRef.current) === null || _paperRef$current === void 0 ? void 0 : _paperRef$current.getBoundingClientRect().top;
4605 if (dialogTop < 0) setPosition(function(prev) {
4606 return _objectSpread$26(_objectSpread$26({}, prev), {}, { y: prev.y - dialogTop });
4607 });
4608 }, 50);
4609 };
4610 (0, react.useEffect)(function() {
4611 var resizeObserver = new ResizeObserver(handlePositionBoundaries);
4612 resizeObserver.observe(paperRef.current);
4613 return function() {
4614 resizeObserver.disconnect();
4615 };
4616 }, []);
4617 return /*#__PURE__*/ react.default.createElement(import_cjs.default, {
4618 position,
4619 onDrag,
4620 handle: ".MuiAppBar-root",
4621 cancel: "[class*=\"MuiDialogContent-root\"]",
4622 bounds: "parent"
4623 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Paper, _extends$1({}, props, { ref: paperRef })));
4624 };
4625 var PromptDialog = function PromptDialog(props) {
4626 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, _extends$1({
4627 scroll: "paper",
4628 open: true,
4629 fullWidth: true,
4630 hideBackdrop: true,
4631 PaperComponent: DraggablePaper,
4632 disableScrollLock: true,
4633 sx: { "& .MuiDialog-container": {
4634 alignItems: "flex-start",
4635 mt: "18vh"
4636 } },
4637 PaperProps: { sx: {
4638 m: 0,
4639 maxHeight: "76vh"
4640 } }
4641 }, props), props.children);
4642 };
4643 PromptDialog.propTypes = {
4644 onClose: import_prop_types$12.default.func.isRequired,
4645 children: import_prop_types$12.default.node,
4646 maxWidth: import_prop_types$12.default.oneOf([
4647 "xs",
4648 "sm",
4649 "md",
4650 "lg",
4651 "xl",
4652 false
4653 ])
4654 };
4655 PromptDialog.Header = DialogHeader$1;
4656 PromptDialog.Content = _elementor_ui.DialogContent;
4657
4658 //#endregion
4659 //#region modules/ai/assets/js/editor/components/upgrade-chip.js
4660 init_slicedToArray();
4661 var popoverId$1 = "e-ai-upgrade-popover";
4662 var StyledContent$3 = (0, _elementor_ui.styled)(_elementor_ui.Paper)(function(_ref) {
4663 var theme = _ref.theme;
4664 return {
4665 position: "relative",
4666 "[data-popper-placement=\"top\"] &": { marginBottom: theme.spacing(2.5) },
4667 "[data-popper-placement=\"bottom\"] &": { marginTop: theme.spacing(2.5) },
4668 padding: theme.spacing(3),
4669 boxShadow: theme.shadows[4],
4670 zIndex: "9999"
4671 };
4672 });
4673 var StyledArrow$1 = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref2) {
4674 var theme = _ref2.theme;
4675 return {
4676 width: theme.spacing(5),
4677 height: theme.spacing(2.5),
4678 position: "absolute",
4679 overflow: "hidden",
4680 left: "50% !important",
4681 transform: "translateX(-50%) rotate(var(--rotate, 0deg)) !important",
4682 "[data-popper-placement=\"top\"] &": { top: "100%" },
4683 "[data-popper-placement=\"bottom\"] &": {
4684 "--rotate": "180deg",
4685 top: "calc(".concat(theme.spacing(2.5), " * -1)")
4686 },
4687 "&::after": {
4688 backgroundColor: theme.palette.background.paper,
4689 content: "\"\"",
4690 display: "block",
4691 position: "absolute",
4692 width: theme.spacing(2.5),
4693 height: theme.spacing(2.5),
4694 top: 0,
4695 left: "50%",
4696 transform: "translateX(-50%) translateY(-50%) rotate(45deg)",
4697 boxShadow: "1px 1px 5px 0px rgba(0, 0, 0, 0.2)",
4698 backgroundImage: "linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"
4699 }
4700 };
4701 });
4702 var upgradeBullets = [
4703 (0, _wordpress_i18n.__)("Get spot-on suggestions from AI Copilot and AI Context with appropriate designs, layouts, and content for your business.", "elementor"),
4704 (0, _wordpress_i18n.__)("Generate professional texts about any topic, in any tone.", "elementor"),
4705 (0, _wordpress_i18n.__)("Effortlessly create or enhance stunning images and bring your ideas to life.", "elementor"),
4706 (0, _wordpress_i18n.__)("Unleash infinite possibilities with the custom code generator.", "elementor"),
4707 (0, _wordpress_i18n.__)("Access 30-days of AI History with the AI Starter plan and 90-days with the Power plan.", "elementor")
4708 ];
4709 var Chip$2 = (0, _elementor_ui.styled)(_elementor_ui.Chip)(function() {
4710 return {
4711 "& .MuiChip-label": { lineHeight: 1.5 },
4712 "& .MuiSvgIcon-root.MuiChip-icon": { fontSize: "1.25rem" }
4713 };
4714 });
4715 var UpgradeChip = function UpgradeChip(_ref3) {
4716 var _ref3$hasSubscription = _ref3.hasSubscription;
4717 var hasSubscription = _ref3$hasSubscription === void 0 ? false : _ref3$hasSubscription;
4718 var _ref3$usagePercentage = _ref3.usagePercentage;
4719 var usagePercentage = _ref3$usagePercentage === void 0 ? 0 : _ref3$usagePercentage;
4720 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
4721 var isPopoverOpen = _useState2[0];
4722 var setIsPopoverOpen = _useState2[1];
4723 var anchorEl = (0, react.useRef)(null);
4724 var arrowEl = (0, react.useRef)(null);
4725 var showPopover = function showPopover() {
4726 return setIsPopoverOpen(true);
4727 };
4728 var hidePopover = function hidePopover() {
4729 return setIsPopoverOpen(false);
4730 };
4731 var actionUrl = "https://go.elementor.com/ai-popup-purchase-dropdown/";
4732 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/";
4733 var actionLabel = hasSubscription ? (0, _wordpress_i18n.__)("Upgrade Elementor AI", "elementor") : (0, _wordpress_i18n.__)("Get Elementor AI", "elementor");
4734 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
4735 component: "span",
4736 "aria-owns": isPopoverOpen ? popoverId$1 : void 0,
4737 "aria-haspopup": "true",
4738 onMouseEnter: showPopover,
4739 onMouseLeave: hidePopover,
4740 ref: anchorEl,
4741 display: "flex",
4742 alignItems: "center"
4743 }, /*#__PURE__*/ react.default.createElement(Chip$2, {
4744 color: "promotion",
4745 label: (0, _wordpress_i18n.__)("Upgrade", "elementor"),
4746 icon: /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, null),
4747 size: "small"
4748 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Popper, {
4749 open: isPopoverOpen,
4750 anchorEl: anchorEl.current,
4751 sx: {
4752 zIndex: "170001",
4753 maxWidth: 300
4754 },
4755 modifiers: [{
4756 name: "arrow",
4757 enabled: true,
4758 options: { element: arrowEl.current }
4759 }]
4760 }, /*#__PURE__*/ react.default.createElement(StyledContent$3, null, /*#__PURE__*/ react.default.createElement(StyledArrow$1, { ref: arrowEl }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
4761 variant: "h5",
4762 color: "text.primary"
4763 }, (0, _wordpress_i18n.__)("Unlimited access to Elementor AI", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.List, { sx: { mb: 1 } }, upgradeBullets.map(function(bullet, index) {
4764 return /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItem, {
4765 key: index,
4766 disableGutters: true,
4767 sx: { alignItems: "flex-start" }
4768 }, /*#__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)));
4769 })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
4770 variant: "contained",
4771 color: "promotion",
4772 size: "small",
4773 href: actionUrl,
4774 target: "_blank",
4775 startIcon: /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, null),
4776 sx: { "&:hover": { color: "promotion.contrastText" } }
4777 }, actionLabel))));
4778 };
4779 UpgradeChip.propTypes = {
4780 hasSubscription: import_prop_types$12.default.bool,
4781 usagePercentage: import_prop_types$12.default.number
4782 };
4783
4784 //#endregion
4785 //#region node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
4786 init_arrayLikeToArray();
4787 function _arrayWithoutHoles(r) {
4788 if (Array.isArray(r)) return _arrayLikeToArray$3(r);
4789 }
4790
4791 //#endregion
4792 //#region node_modules/@babel/runtime/helpers/esm/iterableToArray.js
4793 function _iterableToArray(r) {
4794 if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
4795 }
4796
4797 //#endregion
4798 //#region node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
4799 function _nonIterableSpread() {
4800 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4801 }
4802
4803 //#endregion
4804 //#region node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
4805 init_unsupportedIterableToArray();
4806 function _toConsumableArray(r) {
4807 return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray$3(r) || _nonIterableSpread();
4808 }
4809
4810 //#endregion
4811 //#region modules/ai/assets/js/editor/pages/form-media/context/location-context.js
4812 init_slicedToArray();
4813 init_defineProperty();
4814 function ownKeys$25(e, r) {
4815 var t = Object.keys(e);
4816 if (Object.getOwnPropertySymbols) {
4817 var o = Object.getOwnPropertySymbols(e);
4818 r && (o = o.filter(function(r) {
4819 return Object.getOwnPropertyDescriptor(e, r).enumerable;
4820 })), t.push.apply(t, o);
4821 }
4822 return t;
4823 }
4824 __name(ownKeys$25, "ownKeys");
4825 function _objectSpread$25(e) {
4826 for (var r = 1; r < arguments.length; r++) {
4827 var t = null != arguments[r] ? arguments[r] : {};
4828 r % 2 ? ownKeys$25(Object(t), !0).forEach(function(r) {
4829 _defineProperty(e, r, t[r]);
4830 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$25(Object(t)).forEach(function(r) {
4831 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
4832 });
4833 }
4834 return e;
4835 }
4836 __name(_objectSpread$25, "_objectSpread");
4837 var RoutesContext = (0, react.createContext)(null);
4838 var NAVIGATE = "NAVIGATE";
4839 var BACK = "BACK";
4840 var initialValue$1 = {
4841 current: "",
4842 history: []
4843 };
4844 var reducer$2 = function reducer(state, _ref) {
4845 var type = _ref.type;
4846 var payload = _ref.payload;
4847 switch (type) {
4848 case NAVIGATE: return _objectSpread$25(_objectSpread$25({}, state), {}, {
4849 current: payload,
4850 history: [].concat(_toConsumableArray(state.history), [payload])
4851 });
4852 case BACK: return _objectSpread$25(_objectSpread$25({}, state), {}, {
4853 current: state.history[state.history.length - 2],
4854 history: state.history.slice(0, state.history.length - 1)
4855 });
4856 default: return state;
4857 }
4858 };
4859 var LocationProvider = function LocationProvider(_ref2) {
4860 var children = _ref2.children;
4861 var _useReducer2 = _slicedToArray((0, react.useReducer)(reducer$2, initialValue$1), 2);
4862 var state = _useReducer2[0];
4863 var dispatch = _useReducer2[1];
4864 return /*#__PURE__*/ react.default.createElement(RoutesContext.Provider, { value: {
4865 state,
4866 dispatch
4867 } }, children);
4868 };
4869 LocationProvider.propTypes = { children: import_prop_types$12.default.node };
4870 var useLocation = function useLocation() {
4871 var current = (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}).current;
4872 var _useContext = (0, react.useContext)(RoutesContext);
4873 var state = _useContext.state;
4874 var dispatch = _useContext.dispatch;
4875 var navigate = function navigate(location) {
4876 dispatch({
4877 type: NAVIGATE,
4878 payload: location
4879 });
4880 };
4881 var back = function back() {
4882 dispatch({ type: BACK });
4883 };
4884 (0, react.useEffect)(function() {
4885 if (current) navigate(current);
4886 }, []);
4887 return {
4888 current: state.current,
4889 history: state.history,
4890 navigate,
4891 back
4892 };
4893 };
4894
4895 //#endregion
4896 //#region modules/ai/assets/js/editor/components/ui/panel.js
4897 init_extends();
4898 init_defineProperty();
4899 init_objectWithoutProperties();
4900 var _excluded$29 = ["sx"];
4901 function ownKeys$24(e, r) {
4902 var t = Object.keys(e);
4903 if (Object.getOwnPropertySymbols) {
4904 var o = Object.getOwnPropertySymbols(e);
4905 r && (o = o.filter(function(r) {
4906 return Object.getOwnPropertyDescriptor(e, r).enumerable;
4907 })), t.push.apply(t, o);
4908 }
4909 return t;
4910 }
4911 __name(ownKeys$24, "ownKeys");
4912 function _objectSpread$24(e) {
4913 for (var r = 1; r < arguments.length; r++) {
4914 var t = null != arguments[r] ? arguments[r] : {};
4915 r % 2 ? ownKeys$24(Object(t), !0).forEach(function(r) {
4916 _defineProperty(e, r, t[r]);
4917 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$24(Object(t)).forEach(function(r) {
4918 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
4919 });
4920 }
4921 return e;
4922 }
4923 __name(_objectSpread$24, "_objectSpread");
4924 var Panel = function Panel(_ref) {
4925 var _ref$sx = _ref.sx;
4926 var sx = _ref$sx === void 0 ? {} : _ref$sx;
4927 var props = _objectWithoutProperties(_ref, _excluded$29);
4928 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({ sx: _objectSpread$24({
4929 p: 4,
4930 width: 360,
4931 flexShrink: 0,
4932 height: "100%",
4933 overflowY: "auto"
4934 }, sx) }, props), props.children), /*#__PURE__*/ react.default.createElement(_elementor_ui.Divider, { orientation: "vertical" }));
4935 };
4936 Panel.propTypes = {
4937 children: import_prop_types$12.default.node,
4938 sx: import_prop_types$12.default.object
4939 };
4940
4941 //#endregion
4942 //#region modules/ai/assets/js/editor/pages/form-media/components/generate-loader.js
4943 var GenerateLoader = function GenerateLoader() {
4944 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
4945 alignItems: "center",
4946 justifyContent: "center",
4947 gap: 2,
4948 width: "100%"
4949 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { sx: {
4950 color: "text.primary",
4951 fontSize: "60px",
4952 mb: 1
4953 } }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
4954 variant: "h5",
4955 sx: { color: "text.primary" }
4956 }, (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: {
4957 px: 1.5,
4958 py: 2.5,
4959 width: "100%",
4960 maxWidth: 600
4961 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.LinearProgress, { color: "inherit" })));
4962 };
4963
4964 //#endregion
4965 //#region modules/ai/assets/js/editor/icons/chevron-left-icon.js
4966 init_extends();
4967 var ChevronLeftIcon = react.default.forwardRef(function(props, ref) {
4968 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
4969 fillRule: "evenodd",
4970 clipRule: "evenodd",
4971 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"
4972 }));
4973 });
4974
4975 //#endregion
4976 //#region modules/ai/assets/js/editor/pages/form-media/components/back-button.js
4977 init_extends();
4978 init_objectWithoutProperties();
4979 var _excluded$28 = ["children"];
4980 var StyledChevronLeftIcon$1 = (0, _elementor_ui.withDirection)(ChevronLeftIcon);
4981 var BackButton$1 = function BackButton(_ref) {
4982 var children = _ref.children;
4983 var props = _objectWithoutProperties(_ref, _excluded$28);
4984 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
4985 size: "small",
4986 variant: "text",
4987 color: "secondary",
4988 startIcon: /*#__PURE__*/ react.default.createElement(StyledChevronLeftIcon$1, null)
4989 }, props), children || (0, _wordpress_i18n.__)("Back", "elementor"));
4990 };
4991 BackButton$1.propTypes = { children: import_prop_types$12.default.node };
4992
4993 //#endregion
4994 //#region modules/ai/assets/js/editor/pages/form-media/context/global-settings-context.js
4995 var GlobalSettingsContext = (0, react.createContext)({});
4996 var GlobalSettingsProvider = function GlobalSettingsProvider(_ref) {
4997 var settings = _ref.settings;
4998 var children = _ref.children;
4999 return /*#__PURE__*/ react.default.createElement(GlobalSettingsContext.Provider, { value: settings }, children);
5000 };
5001 GlobalSettingsProvider.propTypes = {
5002 settings: import_prop_types$12.default.object,
5003 children: import_prop_types$12.default.node
5004 };
5005 var useGlobalSettings = function useGlobalSettings() {
5006 return (0, react.useContext)(GlobalSettingsContext);
5007 };
5008
5009 //#endregion
5010 //#region modules/ai/assets/js/editor/components/upgrade-banner.js
5011 init_extends();
5012 init_objectWithoutProperties();
5013 var _excluded$27 = ["onClose"];
5014 var UpgradeBanner = function UpgradeBanner(_ref) {
5015 var onClose = _ref.onClose;
5016 var props = _objectWithoutProperties(_ref, _excluded$27);
5017 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Alert, _extends$1({
5018 icon: false,
5019 action: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertAction, { onClick: function onClick() {
5020 return window.open("https://go.elementor.com/ai-banner-free-upgrade/", "_blank");
5021 } }, (0, _wordpress_i18n.__)("Upgrade", "elementor")),
5022 variant: "filled",
5023 color: "promotion",
5024 onClose
5025 }, props), (0, _wordpress_i18n.__)("You’re using a limited license. Get maximum access to Elementor AI.", "elementor"));
5026 };
5027 UpgradeBanner.propTypes = {
5028 onClose: import_prop_types$12.default.func,
5029 sx: import_prop_types$12.default.object
5030 };
5031
5032 //#endregion
5033 //#region modules/ai/assets/js/editor/helpers/features-enum.js
5034 var FREE_TRIAL_FEATURES_NAMES = {
5035 TEXT: (0, _wordpress_i18n.__)("Text", "elementor"),
5036 IMAGES: (0, _wordpress_i18n.__)("Images", "elementor"),
5037 CODE: (0, _wordpress_i18n.__)("Code", "elementor"),
5038 CONTAINERS: (0, _wordpress_i18n.__)("Containers", "elementor"),
5039 ANIMATION: (0, _wordpress_i18n.__)("Animation", "elementor")
5040 };
5041
5042 //#endregion
5043 //#region modules/ai/assets/js/editor/components/usage-limit-alert.js
5044 init_objectWithoutProperties();
5045 init_extends();
5046 init_defineProperty();
5047 var _excluded$26 = [
5048 "onClose",
5049 "usagePercentage",
5050 "hasSubscription",
5051 "feature"
5052 ];
5053 var KEY_SUBSCRIPTION = "subscription";
5054 var KEY_NO_SUBSCRIPTION = "noSubscription";
5055 var getUsageTitle = function getUsageTitle(percentage) {
5056 return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("You’ve used %s of credits for this AI feature.", "elementor"), percentage);
5057 };
5058 var CREDITS_95_USAGE_TITLE = getUsageTitle("95%");
5059 var CREDITS_80_USAGE_TITLE = getUsageTitle("80%");
5060 var CREDITS_75_USAGE_TITLE = getUsageTitle("75%");
5061 var DESCRIPTION_SUBSCRIPTION = (0, _wordpress_i18n.__)("Get maximum access.", "elementor");
5062 var FEATURES = Object.keys(FREE_TRIAL_FEATURES_NAMES);
5063 var getDescriptionNoSubscription = function getDescriptionNoSubscription(excludedFeature) {
5064 var featuresList = FEATURES.filter(function(feature) {
5065 return feature !== excludedFeature;
5066 }).map(function(feature) {
5067 return FREE_TRIAL_FEATURES_NAMES[feature];
5068 }).join(", ");
5069 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);
5070 };
5071 var alertConfigs = [
5072 {
5073 threshold: 95,
5074 title: _defineProperty(_defineProperty({}, KEY_SUBSCRIPTION, CREDITS_95_USAGE_TITLE), KEY_NO_SUBSCRIPTION, CREDITS_95_USAGE_TITLE),
5075 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/"),
5076 color: "error"
5077 },
5078 {
5079 threshold: 80,
5080 title: _defineProperty(_defineProperty({}, KEY_SUBSCRIPTION, CREDITS_80_USAGE_TITLE), KEY_NO_SUBSCRIPTION, CREDITS_80_USAGE_TITLE),
5081 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/"),
5082 color: "warning"
5083 },
5084 {
5085 threshold: 75,
5086 title: _defineProperty(_defineProperty({}, KEY_SUBSCRIPTION, CREDITS_75_USAGE_TITLE), KEY_NO_SUBSCRIPTION, CREDITS_75_USAGE_TITLE),
5087 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/"),
5088 color: "warning"
5089 }
5090 ];
5091 var UpgradeButton = function UpgradeButton(props) {
5092 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
5093 color: "inherit",
5094 variant: "outlined",
5095 sx: { border: "2px solid" }
5096 }, props), (0, _wordpress_i18n.__)("Upgrade now", "elementor"));
5097 };
5098 var UsageLimitAlert = function UsageLimitAlert(_ref) {
5099 _ref.onClose;
5100 var usagePercentage = _ref.usagePercentage;
5101 var hasSubscription = _ref.hasSubscription;
5102 var feature = _ref.feature;
5103 var props = _objectWithoutProperties(_ref, _excluded$26);
5104 var config = alertConfigs.find(function(_ref2) {
5105 return usagePercentage >= _ref2.threshold;
5106 });
5107 if (!config) return null;
5108 var subscriptionType = hasSubscription ? KEY_SUBSCRIPTION : KEY_NO_SUBSCRIPTION;
5109 var description = _defineProperty(_defineProperty({}, KEY_SUBSCRIPTION, DESCRIPTION_SUBSCRIPTION), KEY_NO_SUBSCRIPTION, getDescriptionNoSubscription(feature));
5110 var title = config.title;
5111 var url = config.url;
5112 var color = config.color;
5113 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Alert, _extends$1({
5114 severity: "warning",
5115 action: /*#__PURE__*/ react.default.createElement(UpgradeButton, { onClick: function handleUpgradeClick() {
5116 return window.open(url[subscriptionType], "_blank");
5117 } }),
5118 color
5119 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, title[subscriptionType]), description[subscriptionType]);
5120 };
5121 UsageLimitAlert.propTypes = {
5122 onClose: import_prop_types$12.default.func,
5123 usagePercentage: import_prop_types$12.default.number,
5124 hasSubscription: import_prop_types$12.default.bool,
5125 feature: import_prop_types$12.default.string
5126 };
5127
5128 //#endregion
5129 //#region modules/ai/assets/js/editor/hooks/use-upgrade-message.js
5130 init_use_introduction();
5131 var USAGE_PERCENTAGE_THRESHOLD = 75;
5132 var useUpgradeMessage = function useUpgradeMessage(_ref) {
5133 var usagePercentage = _ref.usagePercentage;
5134 var hasSubscription = _ref.hasSubscription;
5135 var _useIntroduction = useIntroduction("e-ai-upgrade-message");
5136 var isBannerViewed = _useIntroduction.isViewed;
5137 var markBannerAsViewed = _useIntroduction.markAsViewed;
5138 var isFreeUser = !hasSubscription;
5139 return {
5140 showBadge: usagePercentage >= 75 || isFreeUser,
5141 showBanner: !isBannerViewed && isFreeUser && usagePercentage < 75,
5142 markBannerAsViewed
5143 };
5144 };
5145
5146 //#endregion
5147 //#region modules/ai/assets/js/editor/components/usage-messages.js
5148 var UsageMessages = function UsageMessages(_ref) {
5149 var hasSubscription = _ref.hasSubscription;
5150 var usagePercentage = _ref.usagePercentage;
5151 var sx = _ref.sx;
5152 var feature = _ref.feature;
5153 var _useUpgradeMessage = useUpgradeMessage({
5154 usagePercentage,
5155 hasSubscription
5156 });
5157 var showBanner = _useUpgradeMessage.showBanner;
5158 var markBannerAsViewed = _useUpgradeMessage.markBannerAsViewed;
5159 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, showBanner && /*#__PURE__*/ react.default.createElement(UpgradeBanner, {
5160 onClose: markBannerAsViewed,
5161 sx
5162 }), /*#__PURE__*/ react.default.createElement(UsageLimitAlert, {
5163 hasSubscription,
5164 usagePercentage,
5165 sx,
5166 feature
5167 }));
5168 };
5169 UsageMessages.propTypes = {
5170 hasSubscription: import_prop_types$12.default.bool,
5171 usagePercentage: import_prop_types$12.default.number,
5172 sx: import_prop_types$12.default.object,
5173 feature: import_prop_types$12.default.string
5174 };
5175
5176 //#endregion
5177 //#region modules/ai/assets/js/editor/pages/form-media/components/view.js
5178 init_extends();
5179 init_defineProperty();
5180 init_objectWithoutProperties();
5181 init_loader();
5182 init_prompt_error_message();
5183 var _excluded$25 = ["sx"];
5184 var _excluded2$4 = ["primary", "secondary"];
5185 var _excluded3$2 = ["primary", "secondary"];
5186 var _excluded4$1 = ["children"];
5187 var _excluded5$1 = [
5188 "isLoading",
5189 "isGenerating",
5190 "children"
5191 ];
5192 var _excluded6 = ["sx"];
5193 function ownKeys$23(e, r) {
5194 var t = Object.keys(e);
5195 if (Object.getOwnPropertySymbols) {
5196 var o = Object.getOwnPropertySymbols(e);
5197 r && (o = o.filter(function(r) {
5198 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5199 })), t.push.apply(t, o);
5200 }
5201 return t;
5202 }
5203 __name(ownKeys$23, "ownKeys");
5204 function _objectSpread$23(e) {
5205 for (var r = 1; r < arguments.length; r++) {
5206 var t = null != arguments[r] ? arguments[r] : {};
5207 r % 2 ? ownKeys$23(Object(t), !0).forEach(function(r) {
5208 _defineProperty(e, r, t[r]);
5209 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$23(Object(t)).forEach(function(r) {
5210 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5211 });
5212 }
5213 return e;
5214 }
5215 __name(_objectSpread$23, "_objectSpread");
5216 var ViewBackButton = function ViewBackButton(_ref) {
5217 var _ref$sx = _ref.sx;
5218 var sx = _ref$sx === void 0 ? {} : _ref$sx;
5219 var props = _objectWithoutProperties(_ref, _excluded$25);
5220 var back = useLocation().back;
5221 if (useGlobalSettings().hideBackButton) return null;
5222 return /*#__PURE__*/ react.default.createElement(BackButton$1, _extends$1({ onClick: function onClick(e) {
5223 e.preventDefault();
5224 back();
5225 } }, props, { sx: _objectSpread$23({
5226 mb: 1,
5227 alignSelf: "flex-start"
5228 }, sx) }));
5229 };
5230 ViewBackButton.propTypes = { sx: import_prop_types$12.default.object };
5231 var PanelHeading = function PanelHeading(_ref2) {
5232 var primary = _ref2.primary;
5233 var secondary = _ref2.secondary;
5234 var props = _objectWithoutProperties(_ref2, _excluded2$4);
5235 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, _extends$1({
5236 spacing: 1,
5237 sx: { mb: 3 }
5238 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "h4" }, primary), secondary && /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
5239 variant: "body1",
5240 color: "secondary"
5241 }, secondary));
5242 };
5243 PanelHeading.propTypes = {
5244 primary: import_prop_types$12.default.string.isRequired,
5245 secondary: import_prop_types$12.default.string
5246 };
5247 var ContentHeading = function ContentHeading(_ref3) {
5248 var primary = _ref3.primary;
5249 var secondary = _ref3.secondary;
5250 var props = _objectWithoutProperties(_ref3, _excluded3$2);
5251 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, _extends$1({
5252 gap: 1.5,
5253 sx: { mb: 3 }
5254 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "h6" }, primary), secondary && /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
5255 variant: "subtitle1",
5256 color: "secondary"
5257 }, secondary));
5258 };
5259 ContentHeading.propTypes = {
5260 primary: import_prop_types$12.default.string.isRequired,
5261 secondary: import_prop_types$12.default.string
5262 };
5263 var View = function View(_ref4) {
5264 var children = _ref4.children;
5265 var props = _objectWithoutProperties(_ref4, _excluded4$1);
5266 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
5267 className: "e-ai-dialog-content",
5268 display: "flex",
5269 sx: {
5270 overflowY: "auto",
5271 position: "relative"
5272 },
5273 height: "100%"
5274 }, props), children);
5275 };
5276 var Content = function Content(_ref5) {
5277 var _ref5$isLoading = _ref5.isLoading;
5278 var isLoading = _ref5$isLoading === void 0 ? false : _ref5$isLoading;
5279 var _ref5$isGenerating = _ref5.isGenerating;
5280 var isGenerating = _ref5$isGenerating === void 0 ? false : _ref5$isGenerating;
5281 var children = _ref5.children;
5282 var props = _objectWithoutProperties(_ref5, _excluded5$1);
5283 if (isGenerating) return /*#__PURE__*/ react.default.createElement(GenerateLoader, null);
5284 if (isLoading) return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
5285 width: "100%",
5286 maxWidth: 600,
5287 margin: "0 auto",
5288 alignSelf: "center"
5289 } }, /*#__PURE__*/ react.default.createElement(Loader, { color: "inherit" }));
5290 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
5291 sx: {
5292 overflowY: "auto",
5293 p: 4
5294 },
5295 flexGrow: 1
5296 }, props), children);
5297 };
5298 Content.propTypes = {
5299 children: import_prop_types$12.default.node,
5300 isLoading: import_prop_types$12.default.bool,
5301 isGenerating: import_prop_types$12.default.bool
5302 };
5303 var ErrorMessage = function ErrorMessage(_ref6) {
5304 var _ref6$sx = _ref6.sx;
5305 var sx = _ref6$sx === void 0 ? {} : _ref6$sx;
5306 var props = _objectWithoutProperties(_ref6, _excluded6);
5307 return /*#__PURE__*/ react.default.createElement(PromptErrorMessage, _extends$1({ actionPosition: "bottom" }, props, { sx: _objectSpread$23({ mb: 2.5 }, sx) }));
5308 };
5309 ErrorMessage.propTypes = { sx: import_prop_types$12.default.object };
5310 var ViewPanel = function ViewPanel(props) {
5311 var _useGlobalSettings2 = useGlobalSettings();
5312 var hasSubscription = _useGlobalSettings2.hasSubscription;
5313 var usagePercentage = _useGlobalSettings2.usagePercentage;
5314 return /*#__PURE__*/ react.default.createElement(Panel, null, /*#__PURE__*/ react.default.createElement(UsageMessages, {
5315 hasSubscription,
5316 usagePercentage,
5317 sx: { mb: 4 },
5318 feature: FREE_TRIAL_FEATURES_NAMES.IMAGES
5319 }), props.children);
5320 };
5321 ViewPanel.propTypes = { children: import_prop_types$12.default.node };
5322 View.Panel = ViewPanel;
5323 View.Content = Content;
5324 View.BackButton = ViewBackButton;
5325 View.ErrorMessage = ErrorMessage;
5326 View.PanelHeading = PanelHeading;
5327 View.ContentHeading = ContentHeading;
5328 View.propTypes = { children: import_prop_types$12.default.node };
5329
5330 //#endregion
5331 //#region modules/ai/assets/js/editor/pages/form-media/constants/index.js
5332 var LOCATIONS = {
5333 RESIZE: "resize",
5334 GENERATE: "generate",
5335 VARIATIONS: "variations",
5336 IMAGE_TOOLS: "image-tools",
5337 IN_PAINTING: "in-painting",
5338 OUT_PAINTING: "out-painting",
5339 REMOVE_BACKGROUND: "remove-background",
5340 REPLACE_BACKGROUND: "replace-background",
5341 REMOVE_TEXT: "remove-text",
5342 CLEANUP: "cleanup",
5343 PRODUCT_IMAGE_UNIFICATION: "product-image-unification",
5344 ISOLATE_OBJECT: "isolate-objects"
5345 };
5346 var IMAGE_PROMPT_SETTINGS = {
5347 IMAGE_TYPE: "image_type",
5348 IMAGE_STYLE: "style_preset",
5349 IMAGE_STRENGTH: "image_strength",
5350 IMAGE_RATIO: "ratio",
5351 IMAGE_ZOOM: "zoom",
5352 IMAGE_UPSCALE: "upscale_to",
5353 IMAGE_BACKGROUND_COLOR: "background_color"
5354 };
5355 var FEATURE_IDENTIFIER = { ISOLATE_OBJECT: "isolate-object" };
5356 var IMAGE_PROMPT_CATEGORIES = {
5357 "": {
5358 label: (0, _wordpress_i18n.__)("None", "elementor"),
5359 subCategories: {}
5360 },
5361 photographic: {
5362 label: (0, _wordpress_i18n.__)("Photographic", "elementor"),
5363 subCategories: {
5364 "": (0, _wordpress_i18n.__)("None", "elementor"),
5365 landscape: (0, _wordpress_i18n.__)("Landscape", "elementor"),
5366 macro: (0, _wordpress_i18n.__)("Macro", "elementor"),
5367 portrait: (0, _wordpress_i18n.__)("Portrait", "elementor"),
5368 "long-exposure": (0, _wordpress_i18n.__)("Long Exposure", "elementor"),
5369 product: (0, _wordpress_i18n.__)("Product", "elementor"),
5370 photorealistic: (0, _wordpress_i18n.__)("Photorealistic", "elementor")
5371 }
5372 },
5373 vector: {
5374 label: (0, _wordpress_i18n.__)("Vector / Logo", "elementor"),
5375 subCategories: {
5376 "": (0, _wordpress_i18n.__)("None", "elementor"),
5377 "typographic-logo": (0, _wordpress_i18n.__)("Typographic Logo", "elementor"),
5378 "shape-logo": (0, _wordpress_i18n.__)("Shape Logo", "elementor"),
5379 "handwritten-logo": (0, _wordpress_i18n.__)("Handwritten Logo", "elementor"),
5380 "line-art-logo": (0, _wordpress_i18n.__)("Line Art Logo", "elementor"),
5381 "old-school-logo": (0, _wordpress_i18n.__)("Old School Logo", "elementor")
5382 }
5383 },
5384 background: {
5385 label: (0, _wordpress_i18n.__)("Background", "elementor"),
5386 subCategories: {
5387 "": (0, _wordpress_i18n.__)("None", "elementor"),
5388 floral: (0, _wordpress_i18n.__)("Floral", "elementor"),
5389 gradient: (0, _wordpress_i18n.__)("Gradient", "elementor"),
5390 mosaic: (0, _wordpress_i18n.__)("Mosaic", "elementor"),
5391 neon: (0, _wordpress_i18n.__)("Neon", "elementor"),
5392 bokeh: (0, _wordpress_i18n.__)("Bokeh", "elementor")
5393 }
5394 },
5395 handmade: {
5396 label: (0, _wordpress_i18n.__)("Handmade", "elementor"),
5397 subCategories: {
5398 "": (0, _wordpress_i18n.__)("None", "elementor"),
5399 doodle: (0, _wordpress_i18n.__)("Doodle", "elementor"),
5400 "line-art": (0, _wordpress_i18n.__)("Line Art", "elementor"),
5401 "oil-painting": (0, _wordpress_i18n.__)("Oil Painting", "elementor"),
5402 "pencil-drawing": (0, _wordpress_i18n.__)("Pencil Drawing", "elementor"),
5403 watercolor: (0, _wordpress_i18n.__)("Watercolor", "elementor")
5404 }
5405 },
5406 "digital-art": {
5407 label: (0, _wordpress_i18n.__)("Digital Art", "elementor"),
5408 subCategories: {
5409 "": (0, _wordpress_i18n.__)("None", "elementor"),
5410 amine: (0, _wordpress_i18n.__)("Anime", "elementor"),
5411 cartoon: (0, _wordpress_i18n.__)("Cartoon", "elementor"),
5412 cinematic: (0, _wordpress_i18n.__)("Cinematic", "elementor"),
5413 "comic-book": (0, _wordpress_i18n.__)("Comic Book", "elementor"),
5414 "fantasy-art": (0, _wordpress_i18n.__)("Fantasy Art", "elementor"),
5415 isometric: (0, _wordpress_i18n.__)("Isometric", "elementor"),
5416 vector: (0, _wordpress_i18n.__)("Vector", "elementor"),
5417 "pixel-art": (0, _wordpress_i18n.__)("Pixel Art", "elementor"),
5418 "low-poly": (0, _wordpress_i18n.__)("Low Poly", "elementor"),
5419 "neon-punk": (0, _wordpress_i18n.__)("Neon Punk", "elementor")
5420 }
5421 },
5422 "3d": {
5423 label: (0, _wordpress_i18n.__)("3D", "elementor"),
5424 subCategories: {
5425 "": (0, _wordpress_i18n.__)("None", "elementor"),
5426 clay: (0, _wordpress_i18n.__)("Clay", "elementor"),
5427 digital: (0, _wordpress_i18n.__)("Digital", "elementor"),
5428 origami: (0, _wordpress_i18n.__)("Origami", "elementor"),
5429 stone: (0, _wordpress_i18n.__)("Stone", "elementor"),
5430 wood: (0, _wordpress_i18n.__)("Wood", "elementor")
5431 }
5432 }
5433 };
5434 var IMAGE_ASPECT_RATIO = {
5435 "1:1": {
5436 width: 512,
5437 height: 512,
5438 label: (0, _wordpress_i18n.__)("Square", "elementor") + " (1:1)"
5439 },
5440 "3:2": {
5441 width: 640,
5442 height: 448,
5443 label: (0, _wordpress_i18n.__)("Landscape", "elementor") + " (3:2)"
5444 },
5445 "4:3": {
5446 width: 640,
5447 height: 448,
5448 label: (0, _wordpress_i18n.__)("Landscape", "elementor") + " (4:3)"
5449 },
5450 "16:9": {
5451 width: 704,
5452 height: 384,
5453 label: (0, _wordpress_i18n.__)("Landscape", "elementor") + " (16:9)"
5454 },
5455 "2:3": {
5456 width: 448,
5457 height: 640,
5458 label: (0, _wordpress_i18n.__)("Portrait", "elementor") + " (2:3)"
5459 },
5460 "3:4": {
5461 width: 448,
5462 height: 640,
5463 label: (0, _wordpress_i18n.__)("Portrait", "elementor") + " (3:4)"
5464 },
5465 "9:16": {
5466 width: 384,
5467 height: 704,
5468 label: (0, _wordpress_i18n.__)("Portrait", "elementor") + " (9:16)"
5469 }
5470 };
5471 var IMAGE_PLACEHOLDERS_HOSTS = { WIREFRAME: "gene-\\d+\\.live\\.strattic\\.io" };
5472
5473 //#endregion
5474 //#region modules/ai/assets/js/editor/components/ui/overlay.js
5475 var Overlay = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref) {
5476 var theme = _ref.theme;
5477 return {
5478 width: "100%",
5479 height: "100%",
5480 position: "absolute",
5481 backgroundColor: "rgba(0,0,0,0.5)",
5482 transition: "opacity ".concat(theme.transitions.duration.short, "ms ").concat(theme.transitions.easing.easeInOut),
5483 opacity: 0,
5484 "&:hover": { opacity: 1 }
5485 };
5486 });
5487
5488 //#endregion
5489 //#region modules/ai/assets/js/editor/components/ui/overlay-bar.js
5490 var OverlayBar = (0, _elementor_ui.styled)(_elementor_ui.Stack)(function(_ref) {
5491 var theme = _ref.theme;
5492 var position = _ref.position;
5493 var style = {
5494 width: "100%",
5495 position: "absolute",
5496 left: 0,
5497 padding: theme.spacing(2.5)
5498 };
5499 if ("top" === position) style.top = 0;
5500 else if ("bottom" === position) style.bottom = 0;
5501 return style;
5502 });
5503
5504 //#endregion
5505 //#region modules/ai/assets/js/editor/components/ui/overlay-bar-text.js
5506 init_extends();
5507 init_objectWithoutProperties();
5508 var _excluded$24 = ["children"];
5509 var OverlayBarText = function OverlayBarText(_ref) {
5510 var children = _ref.children;
5511 var props = _objectWithoutProperties(_ref, _excluded$24);
5512 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, _extends$1({
5513 variant: "caption",
5514 color: "common.white"
5515 }, props), children);
5516 };
5517 OverlayBarText.propTypes = { children: import_prop_types$12.default.node };
5518
5519 //#endregion
5520 //#region modules/ai/assets/js/editor/pages/form-media/components/gallery.js
5521 init_defineProperty();
5522 init_slicedToArray();
5523 init_extends();
5524 init_objectWithoutProperties();
5525 var _excluded$23 = ["children"];
5526 var _excluded2$3 = [
5527 "alt",
5528 "src",
5529 "text",
5530 "children",
5531 "aspectRatio",
5532 "variant",
5533 "OverlayBarProps",
5534 "numImagesInRow",
5535 "overlay",
5536 "onSelectChange",
5537 "checkboxColor",
5538 "isLoading",
5539 "initialChecked"
5540 ];
5541 function ownKeys$22(e, r) {
5542 var t = Object.keys(e);
5543 if (Object.getOwnPropertySymbols) {
5544 var o = Object.getOwnPropertySymbols(e);
5545 r && (o = o.filter(function(r) {
5546 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5547 })), t.push.apply(t, o);
5548 }
5549 return t;
5550 }
5551 __name(ownKeys$22, "ownKeys");
5552 function _objectSpread$22(e) {
5553 for (var r = 1; r < arguments.length; r++) {
5554 var t = null != arguments[r] ? arguments[r] : {};
5555 r % 2 ? ownKeys$22(Object(t), !0).forEach(function(r) {
5556 _defineProperty(e, r, t[r]);
5557 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$22(Object(t)).forEach(function(r) {
5558 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5559 });
5560 }
5561 return e;
5562 }
5563 __name(_objectSpread$22, "_objectSpread");
5564 var aspectRatios = Object.keys(IMAGE_ASPECT_RATIO);
5565 var Gallery = function Gallery(_ref) {
5566 var children = _ref.children;
5567 var props = _objectWithoutProperties(_ref, _excluded$23);
5568 return /*#__PURE__*/ react.default.createElement(_elementor_ui.ImageList, _extends$1({
5569 width: "100%",
5570 cols: 2,
5571 gap: 24
5572 }, props), children);
5573 };
5574 Gallery.propTypes = { children: import_prop_types$12.default.node };
5575 var GalleryImage = function GalleryImage(_ref2) {
5576 var _elementorCommon$conf;
5577 var _elementorCommon;
5578 var alt = _ref2.alt;
5579 var src = _ref2.src;
5580 var text = _ref2.text;
5581 var children = _ref2.children;
5582 var _ref2$aspectRatio = _ref2.aspectRatio;
5583 var aspectRatio = _ref2$aspectRatio === void 0 ? "1:1" : _ref2$aspectRatio;
5584 var _ref2$variant = _ref2.variant;
5585 var variant = _ref2$variant === void 0 ? "contained" : _ref2$variant;
5586 var _ref2$OverlayBarProps = _ref2.OverlayBarProps;
5587 var OverlayBarProps = _ref2$OverlayBarProps === void 0 ? {} : _ref2$OverlayBarProps;
5588 var _ref2$numImagesInRow = _ref2.numImagesInRow;
5589 var numImagesInRow = _ref2$numImagesInRow === void 0 ? 2 : _ref2$numImagesInRow;
5590 var _ref2$overlay = _ref2.overlay;
5591 var overlay = _ref2$overlay === void 0 ? true : _ref2$overlay;
5592 var _ref2$onSelectChange = _ref2.onSelectChange;
5593 var onSelectChange = _ref2$onSelectChange === void 0 ? null : _ref2$onSelectChange;
5594 var _ref2$checkboxColor = _ref2.checkboxColor;
5595 var checkboxColor = _ref2$checkboxColor === void 0 ? "rgba(0, 0, 0, 0.54)" : _ref2$checkboxColor;
5596 var _ref2$isLoading = _ref2.isLoading;
5597 var isLoading = _ref2$isLoading === void 0 ? false : _ref2$isLoading;
5598 var _ref2$initialChecked = _ref2.initialChecked;
5599 var initialChecked = _ref2$initialChecked === void 0 ? false : _ref2$initialChecked;
5600 var props = _objectWithoutProperties(_ref2, _excluded2$3);
5601 var _useState2 = _slicedToArray((0, react.useState)(initialChecked), 2);
5602 var isChecked = _useState2[0];
5603 var setIsChecked = _useState2[1];
5604 var style = {};
5605 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;
5606 (0, react.useEffect)(function() {
5607 setIsChecked(initialChecked);
5608 }, [initialChecked]);
5609 if ("thumbnail" === variant) {
5610 style.width = "100%";
5611 style.maxHeight = "238px";
5612 style.minWidth = "230px";
5613 } else {
5614 style.width = "auto";
5615 style.height = "auto";
5616 style.maxWidth = "100%";
5617 style.maxHeight = "1:1" === aspectRatio ? "initial" : "100%";
5618 style.objectFit = "contain";
5619 style.aspectRatio = aspectRatio.replace(":", " / ");
5620 }
5621 return /*#__PURE__*/ react.default.createElement(_elementor_ui.ImageListItem, props, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
5622 display: "flex",
5623 justifyContent: "center",
5624 alignItems: "center",
5625 sx: {
5626 bgcolor: "action.selected",
5627 height: "contained" === variant && numImagesInRow <= 2 ? 336 : "auto",
5628 position: "relative",
5629 overflow: "hidden"
5630 }
5631 }, /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, isLoading ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Skeleton, {
5632 sx: _objectSpread$22(_objectSpread$22({}, style), {}, {
5633 width: "100%",
5634 height: "100% "
5635 }),
5636 animation: "wave",
5637 variant: "rounded"
5638 }, /*#__PURE__*/ react.default.createElement("img", {
5639 alt,
5640 src,
5641 style: _objectSpread$22(_objectSpread$22({}, style), {}, { visibility: "hidden" })
5642 })) : /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, onSelectChange && /*#__PURE__*/ react.default.createElement(_elementor_ui.Checkbox, {
5643 onClick: function onClick() {
5644 var newVal = !isChecked;
5645 setIsChecked(newVal);
5646 onSelectChange(newVal);
5647 },
5648 checked: isChecked,
5649 sx: {
5650 position: "absolute",
5651 top: 0,
5652 left: isRTL ? void 0 : 0,
5653 right: isRTL ? 0 : void 0,
5654 "& .MuiSvgIcon-root": { color: checkboxColor }
5655 }
5656 }), /*#__PURE__*/ react.default.createElement("img", {
5657 alt,
5658 src,
5659 style
5660 })))), overlay && children && /*#__PURE__*/ react.default.createElement(Overlay, null, /*#__PURE__*/ react.default.createElement(OverlayBar, _extends$1({
5661 gap: 1,
5662 position: "bottom"
5663 }, OverlayBarProps), text && /*#__PURE__*/ react.default.createElement(OverlayBarText, null, text), children)));
5664 };
5665 GalleryImage.propTypes = {
5666 alt: import_prop_types$12.default.string,
5667 src: import_prop_types$12.default.string,
5668 text: import_prop_types$12.default.string,
5669 children: import_prop_types$12.default.node,
5670 BoxProps: import_prop_types$12.default.object,
5671 OverlayBarProps: import_prop_types$12.default.object,
5672 aspectRatio: import_prop_types$12.default.oneOf(aspectRatios),
5673 variant: import_prop_types$12.default.oneOf(["contained", "thumbnail"]),
5674 numImagesInRow: import_prop_types$12.default.number,
5675 overlay: import_prop_types$12.default.bool,
5676 onSelectChange: import_prop_types$12.default.func,
5677 checkboxColor: import_prop_types$12.default.string,
5678 initialChecked: import_prop_types$12.default.bool,
5679 isLoading: import_prop_types$12.default.bool
5680 };
5681 Gallery.Image = GalleryImage;
5682
5683 //#endregion
5684 //#region modules/ai/assets/js/editor/pages/form-media/components/image-form.js
5685 init_extends();
5686 init_objectWithoutProperties();
5687 var _excluded$22 = ["children"];
5688 var ImageForm = function ImageForm(_ref) {
5689 var children = _ref.children;
5690 var props = _objectWithoutProperties(_ref, _excluded$22);
5691 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({ component: "form" }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, { spacing: 2.5 }, children));
5692 };
5693 ImageForm.propTypes = { children: import_prop_types$12.default.node };
5694
5695 //#endregion
5696 //#region modules/ai/assets/js/editor/icons/wand-icon.js
5697 init_extends();
5698 var WandIcon = react.default.forwardRef(function(props, ref) {
5699 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
5700 fillRule: "evenodd",
5701 clipRule: "evenodd",
5702 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"
5703 }), /*#__PURE__*/ react.default.createElement("path", {
5704 fillRule: "evenodd",
5705 clipRule: "evenodd",
5706 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"
5707 }), /*#__PURE__*/ react.default.createElement("path", {
5708 fillRule: "evenodd",
5709 clipRule: "evenodd",
5710 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"
5711 }));
5712 });
5713
5714 //#endregion
5715 //#region modules/ai/assets/js/editor/pages/form-media/components/enhance-button.js
5716 init_extends();
5717 init_objectWithoutProperties();
5718 var _excluded$21 = ["isLoading"];
5719 var StyledWandIcon = (0, _elementor_ui.withDirection)(WandIcon);
5720 var EnhanceButton = function EnhanceButton(_ref) {
5721 var isLoading = _ref.isLoading;
5722 var props = _objectWithoutProperties(_ref, _excluded$21);
5723 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: (0, _wordpress_i18n.__)("Enhance prompt", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
5724 component: "span",
5725 sx: { cursor: props.disabled ? "default" : "pointer" }
5726 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, _extends$1({
5727 size: "small",
5728 color: "secondary"
5729 }, props), isLoading ? /*#__PURE__*/ react.default.createElement(_elementor_ui.CircularProgress, {
5730 color: "secondary",
5731 size: 20
5732 }) : /*#__PURE__*/ react.default.createElement(StyledWandIcon, { fontSize: "small" }))));
5733 };
5734 EnhanceButton.propTypes = {
5735 disabled: import_prop_types$12.default.bool,
5736 isLoading: import_prop_types$12.default.bool
5737 };
5738
5739 //#endregion
5740 //#region modules/ai/assets/js/editor/pages/form-layout/context/config.js
5741 var MODE_LAYOUT = "layout";
5742 var MODE_VARIATION = "variation";
5743 var LAYOUT_APP_MODES = [MODE_LAYOUT, MODE_VARIATION];
5744 var ConfigContext = react.default.createContext({});
5745 var useConfig = function useConfig() {
5746 return react.default.useContext(ConfigContext);
5747 };
5748 var ConfigProvider = function ConfigProvider(props) {
5749 return /*#__PURE__*/ react.default.createElement(ConfigContext.Provider, { value: {
5750 mode: props.mode,
5751 attachmentsTypes: props.attachmentsTypes,
5752 onClose: props.onClose,
5753 onConnect: props.onConnect,
5754 onData: props.onData,
5755 onInsert: props.onInsert,
5756 onSelect: props.onSelect,
5757 onGenerate: props.onGenerate,
5758 currentContext: props.currentContext,
5759 hasPro: props.hasPro
5760 } }, props.children);
5761 };
5762 ConfigProvider.propTypes = {
5763 mode: import_prop_types$12.default.oneOf(LAYOUT_APP_MODES).isRequired,
5764 children: import_prop_types$12.default.node.isRequired,
5765 attachmentsTypes: import_prop_types$12.default.object.isRequired,
5766 onClose: import_prop_types$12.default.func.isRequired,
5767 onConnect: import_prop_types$12.default.func.isRequired,
5768 onData: import_prop_types$12.default.func.isRequired,
5769 onInsert: import_prop_types$12.default.func.isRequired,
5770 onSelect: import_prop_types$12.default.func.isRequired,
5771 onGenerate: import_prop_types$12.default.func.isRequired,
5772 currentContext: import_prop_types$12.default.object,
5773 hasPro: import_prop_types$12.default.bool
5774 };
5775
5776 //#endregion
5777 //#region modules/ai/assets/js/editor/hooks/use-prompt-enhancer.js
5778 init_api();
5779 init_use_prompt();
5780 var enhancePromptMap = /* @__PURE__ */ new Map([["media", getImagePromptEnhanced], ["layout", getLayoutPromptEnhanced]]);
5781 var getResult = function getResult(prompt, type, enhanceType) {
5782 if (!enhancePromptMap.has(type)) throw new Error("Invalid prompt type: ".concat(type));
5783 return enhancePromptMap.get(type)(prompt, enhanceType);
5784 };
5785 /**
5786 * Hook to enhance a prompt.
5787 *
5788 * @param {string} prompt
5789 * @param {'media' | 'layout'} type
5790 * @return {{enhancedPrompt: string | undefined, isEnhancing: boolean, enhance: (function(...[*]): Promise)}}
5791 */
5792 var usePromptEnhancer = function usePromptEnhancer(prompt, type) {
5793 var mode = useConfig().mode;
5794 var _usePrompt = usePrompt(function() {
5795 return getResult(prompt, type, mode);
5796 }, prompt);
5797 var enhancedData = _usePrompt.data;
5798 var isEnhancing = _usePrompt.isLoading;
5799 return {
5800 enhance: _usePrompt.send,
5801 isEnhancing,
5802 enhancedPrompt: enhancedData === null || enhancedData === void 0 ? void 0 : enhancedData.result
5803 };
5804 };
5805
5806 //#endregion
5807 //#region modules/ai/assets/js/editor/pages/form-media/components/prompt-field.js
5808 init_extends();
5809 init_objectWithoutProperties();
5810 init_textarea();
5811 var _excluded$20 = ["disabled", "onChange"];
5812 var PromptField = function PromptField(_ref) {
5813 var disabled = _ref.disabled;
5814 var _onChange = _ref.onChange;
5815 var props = _objectWithoutProperties(_ref, _excluded$20);
5816 var _usePromptEnhancer = usePromptEnhancer(props.value, "media");
5817 var enhance = _usePromptEnhancer.enhance;
5818 var isEnhancing = _usePromptEnhancer.isEnhancing;
5819 return /*#__PURE__*/ react.default.createElement(Textarea, _extends$1({
5820 minRows: 3,
5821 maxRows: 6,
5822 InputProps: { endAdornment: /*#__PURE__*/ react.default.createElement(_elementor_ui.InputAdornment, {
5823 position: "end",
5824 sx: {
5825 position: "absolute",
5826 bottom: "24px",
5827 right: "8px"
5828 }
5829 }, /*#__PURE__*/ react.default.createElement(EnhanceButton, {
5830 isLoading: isEnhancing,
5831 disabled: disabled || isEnhancing || !props.value,
5832 onClick: function onClick() {
5833 enhance(prompt).then(function(_ref2) {
5834 var result = _ref2.result;
5835 return _onChange(result);
5836 });
5837 }
5838 })) },
5839 sx: { "& .MuiInputBase-input.MuiOutlinedInput-input.MuiInputBase-inputMultiline": {
5840 pb: 5,
5841 width: "89%"
5842 } },
5843 onKeyDown: function onKeyDown(event) {
5844 if ("Tab" === event.key) {
5845 event.preventDefault();
5846 _onChange(props.placeholder);
5847 }
5848 }
5849 }, props, {
5850 onChange: function onChange(event) {
5851 return _onChange(event.target.value);
5852 },
5853 disabled: disabled || isEnhancing
5854 }));
5855 };
5856 PromptField.propTypes = {
5857 value: import_prop_types$12.default.string,
5858 disabled: import_prop_types$12.default.bool,
5859 placeholder: import_prop_types$12.default.string,
5860 onChange: import_prop_types$12.default.func.isRequired
5861 };
5862
5863 //#endregion
5864 //#region modules/ai/assets/js/editor/pages/form-media/components/image-type-select.js
5865 init_extends();
5866 init_slicedToArray();
5867 init_use_introduction();
5868 var StyledNewChip = (0, _elementor_ui.styled)(_elementor_ui.Chip)(function() {
5869 return { "& .MuiChip-label": {
5870 fontSize: "0.75rem",
5871 fontWeight: "normal"
5872 } };
5873 });
5874 var showLabel = function showLabel(label, key, isViewed, markAsViewed) {
5875 if (isViewed) return {
5876 label,
5877 value: key
5878 };
5879 return {
5880 label: /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
5881 direction: "row",
5882 width: "100%",
5883 justifyContent: "space-between",
5884 alignItems: "center"
5885 }, label, /*#__PURE__*/ react.default.createElement(StyledNewChip, {
5886 label: "New",
5887 color: "info",
5888 variant: "standard",
5889 size: "tiny"
5890 })),
5891 value: key,
5892 onClick: function onClick() {
5893 return markAsViewed();
5894 }
5895 };
5896 };
5897 var changeImageType = function changeImageType(e, props, markVectorAsViewed) {
5898 if ("vector" === e.target.value) markVectorAsViewed();
5899 if (props.onChange) props.onChange(e);
5900 };
5901 var ImageTypeSelect = function ImageTypeSelect(props) {
5902 var _useIntroduction = useIntroduction("e-ai-image-vector-option");
5903 var isVectorViewed = _useIntroduction.isViewed;
5904 var markVectorAsViewed = _useIntroduction.markAsViewed;
5905 var imageTypesWithNewChip = Object.entries(IMAGE_PROMPT_CATEGORIES).map(function(_ref) {
5906 var _ref2 = _slicedToArray(_ref, 2);
5907 var key = _ref2[0];
5908 var label = _ref2[1].label;
5909 if ("vector" === key) return showLabel(label, key, isVectorViewed, markVectorAsViewed);
5910 return {
5911 label,
5912 value: key
5913 };
5914 });
5915 return /*#__PURE__*/ react.default.createElement(PromptActionSelection, _extends$1({
5916 options: imageTypesWithNewChip,
5917 wrapperStyle: { width: "100%" },
5918 label: (0, _wordpress_i18n.__)("Image type", "elementor")
5919 }, props, { onChange: function onChange(e) {
5920 changeImageType(e, props, markVectorAsViewed);
5921 } }));
5922 };
5923 ImageTypeSelect.propTypes = {
5924 onChange: import_prop_types$12.default.func,
5925 value: import_prop_types$12.default.string,
5926 disabled: import_prop_types$12.default.bool
5927 };
5928
5929 //#endregion
5930 //#region modules/ai/assets/js/editor/pages/form-media/components/image-style-select.js
5931 init_extends();
5932 init_slicedToArray();
5933 init_objectWithoutProperties();
5934 var _excluded$19 = ["type"];
5935 var ImageStyleSelect = function ImageStyleSelect(_ref) {
5936 var _IMAGE_PROMPT_CATEGOR;
5937 var _ref$type = _ref.type;
5938 var type = _ref$type === void 0 ? "" : _ref$type;
5939 var props = _objectWithoutProperties(_ref, _excluded$19);
5940 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) {
5941 var _ref3 = _slicedToArray(_ref2, 2);
5942 var value = _ref3[0];
5943 return {
5944 label: _ref3[1],
5945 value
5946 };
5947 });
5948 return /*#__PURE__*/ react.default.createElement(PromptActionSelection, _extends$1({
5949 options: imageStyles,
5950 wrapperStyle: { width: "100%" },
5951 label: (0, _wordpress_i18n.__)("Style", "elementor")
5952 }, props));
5953 };
5954 ImageStyleSelect.propTypes = { type: import_prop_types$12.default.string.isRequired };
5955
5956 //#endregion
5957 //#region modules/ai/assets/js/editor/pages/form-media/components/image-ratio-select.js
5958 init_extends();
5959 init_slicedToArray();
5960 var imageRatios = Object.entries(IMAGE_ASPECT_RATIO).map(function(_ref) {
5961 var _ref2 = _slicedToArray(_ref, 2);
5962 var value = _ref2[0];
5963 return {
5964 label: _ref2[1].label,
5965 value
5966 };
5967 });
5968 var ImageRatioSelect = function ImageRatioSelect(props) {
5969 return /*#__PURE__*/ react.default.createElement(PromptActionSelection, _extends$1({
5970 options: imageRatios,
5971 wrapperStyle: { width: "100%" },
5972 label: (0, _wordpress_i18n.__)("Aspect ratio", "elementor")
5973 }, props));
5974 };
5975
5976 //#endregion
5977 //#region modules/ai/assets/js/editor/icons/refresh-icon.js
5978 init_extends();
5979 var RefreshIcon = react.default.forwardRef(function(props, ref) {
5980 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
5981 fillRule: "evenodd",
5982 clipRule: "evenodd",
5983 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"
5984 }), /*#__PURE__*/ react.default.createElement("path", {
5985 fillRule: "evenodd",
5986 clipRule: "evenodd",
5987 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"
5988 }));
5989 });
5990
5991 //#endregion
5992 //#region modules/ai/assets/js/editor/pages/form-media/components/generate-again-submit.js
5993 init_extends();
5994 var GenerateAgainSubmit = function GenerateAgainSubmit(props) {
5995 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
5996 fullWidth: true,
5997 type: "submit",
5998 variant: "contained",
5999 color: "secondary",
6000 startIcon: /*#__PURE__*/ react.default.createElement(RefreshIcon, null),
6001 sx: { color: "background.paper" }
6002 }, props), (0, _wordpress_i18n.__)("Generate again", "elementor"));
6003 };
6004
6005 //#endregion
6006 //#region modules/ai/assets/js/editor/pages/form-media/components/new-prompt-button.js
6007 init_extends();
6008 var NewPromptButton = function NewPromptButton(props) {
6009 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
6010 fullWidth: true,
6011 variant: "text",
6012 color: "secondary"
6013 }, props), (0, _wordpress_i18n.__)("New prompt", "elementor"));
6014 };
6015
6016 //#endregion
6017 //#region modules/ai/assets/js/editor/pages/form-media/components/generate-images-submit.js
6018 init_extends();
6019 init_generate_button();
6020 init_voice_promotion_alert();
6021 var GenerateImagesSubmit = function GenerateImagesSubmit(props) {
6022 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(GenerateButton$1, _extends$1({
6023 size: "medium",
6024 fullWidth: true
6025 }, props), (0, _wordpress_i18n.__)("Generate images", "elementor")), /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, { introductionKey: "ai-context-media-promotion" }));
6026 };
6027
6028 //#endregion
6029 //#region modules/ai/assets/js/editor/pages/form-media/hooks/use-image-size.js
6030 var useImageSize = function useImageSize(aspectRatio) {
6031 var _IMAGE_ASPECT_RATIO$a = IMAGE_ASPECT_RATIO[aspectRatio];
6032 return {
6033 width: _IMAGE_ASPECT_RATIO$a.width,
6034 height: _IMAGE_ASPECT_RATIO$a.height
6035 };
6036 };
6037
6038 //#endregion
6039 //#region modules/ai/assets/js/editor/hooks/use-image-navigation.js
6040 init_slicedToArray();
6041 var initialIndex = -1;
6042 var useImageNavigation = function useImageNavigation(images) {
6043 var _useState2 = _slicedToArray((0, react.useState)(initialIndex), 2);
6044 var zoomIndex = _useState2[0];
6045 var setZoomIndex = _useState2[1];
6046 return {
6047 zoomIndex,
6048 setZoomIndex,
6049 actions: {
6050 reset: function reset() {
6051 return setZoomIndex(initialIndex);
6052 },
6053 prev: function prev() {
6054 var prevImage = zoomIndex + 1;
6055 if (prevImage >= images.length) prevImage = 0;
6056 setZoomIndex(prevImage);
6057 },
6058 next: function next() {
6059 var nextImage = zoomIndex - 1;
6060 if (nextImage < 0) nextImage = images.length - 1;
6061 setZoomIndex(nextImage);
6062 }
6063 }
6064 };
6065 };
6066
6067 //#endregion
6068 //#region modules/ai/assets/js/editor/icons/chevron-right-icon.js
6069 init_extends();
6070 var ChevronRightIcon = react.default.forwardRef(function(props, ref) {
6071 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
6072 fillRule: "evenodd",
6073 clipRule: "evenodd",
6074 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"
6075 }));
6076 });
6077
6078 //#endregion
6079 //#region modules/ai/assets/js/editor/pages/form-media/components/image-slider.js
6080 init_defineProperty();
6081 init_extends();
6082 init_objectWithoutProperties();
6083 var _excluded$18 = [
6084 "onPrev",
6085 "onNext",
6086 "children"
6087 ];
6088 var _excluded2$2 = [
6089 "children",
6090 "startAction",
6091 "sx"
6092 ];
6093 var _excluded3$1 = ["src", "alt"];
6094 function ownKeys$21(e, r) {
6095 var t = Object.keys(e);
6096 if (Object.getOwnPropertySymbols) {
6097 var o = Object.getOwnPropertySymbols(e);
6098 r && (o = o.filter(function(r) {
6099 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6100 })), t.push.apply(t, o);
6101 }
6102 return t;
6103 }
6104 __name(ownKeys$21, "ownKeys");
6105 function _objectSpread$21(e) {
6106 for (var r = 1; r < arguments.length; r++) {
6107 var t = null != arguments[r] ? arguments[r] : {};
6108 r % 2 ? ownKeys$21(Object(t), !0).forEach(function(r) {
6109 _defineProperty(e, r, t[r]);
6110 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$21(Object(t)).forEach(function(r) {
6111 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6112 });
6113 }
6114 return e;
6115 }
6116 __name(_objectSpread$21, "_objectSpread");
6117 var StyledChevronLeftIcon = (0, _elementor_ui.withDirection)(ChevronLeftIcon);
6118 var StyledChevronRightIcon = (0, _elementor_ui.withDirection)(ChevronRightIcon);
6119 var ImageSlider = function ImageSlider(_ref) {
6120 var onPrev = _ref.onPrev;
6121 var onNext = _ref.onNext;
6122 var children = _ref.children;
6123 var props = _objectWithoutProperties(_ref, _excluded$18);
6124 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, _extends$1({
6125 alignItems: "flex-start",
6126 spacing: .5
6127 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
6128 direction: "row",
6129 spacing: 2.5,
6130 alignSelf: "center",
6131 alignItems: "center"
6132 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
6133 onClick: onPrev,
6134 size: "large",
6135 color: "secondary"
6136 }, /*#__PURE__*/ react.default.createElement(StyledChevronLeftIcon, null)), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
6137 spacing: .5,
6138 justifyContent: "space-around",
6139 alignItems: "center"
6140 }, children), /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
6141 onClick: onNext,
6142 size: "large",
6143 color: "secondary"
6144 }, /*#__PURE__*/ react.default.createElement(StyledChevronRightIcon, null))));
6145 };
6146 ImageSlider.propTypes = {
6147 onPrev: import_prop_types$12.default.func.isRequired,
6148 onNext: import_prop_types$12.default.func.isRequired,
6149 children: import_prop_types$12.default.node.isRequired
6150 };
6151 var Actions$1 = function Actions(_ref2) {
6152 var children = _ref2.children;
6153 var startAction = _ref2.startAction;
6154 var _ref2$sx = _ref2.sx;
6155 var sx = _ref2$sx === void 0 ? {} : _ref2$sx;
6156 var props = _objectWithoutProperties(_ref2, _excluded2$2);
6157 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
6158 display: "flex",
6159 justifyContent: "flex-end",
6160 alignItems: "center",
6161 width: "100%"
6162 }, props, { sx: _objectSpread$21({ mb: 1.5 }, sx) }), startAction, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
6163 direction: "row",
6164 spacing: 2,
6165 justifyContent: "flex-end",
6166 flexGrow: 1,
6167 width: "100%"
6168 }, children));
6169 };
6170 Actions$1.propTypes = {
6171 sx: import_prop_types$12.default.object,
6172 startAction: import_prop_types$12.default.node,
6173 children: import_prop_types$12.default.node.isRequired
6174 };
6175 var Image$2 = function Image(_ref3) {
6176 var src = _ref3.src;
6177 var _ref3$alt = _ref3.alt;
6178 var alt = _ref3$alt === void 0 ? "" : _ref3$alt;
6179 var props = _objectWithoutProperties(_ref3, _excluded3$1);
6180 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
6181 display: "flex",
6182 justifyContent: "center",
6183 alignItems: "center"
6184 }, /*#__PURE__*/ react.default.createElement("img", _extends$1({
6185 src,
6186 alt
6187 }, props)));
6188 };
6189 Image$2.propTypes = {
6190 alt: import_prop_types$12.default.string,
6191 src: import_prop_types$12.default.string.isRequired
6192 };
6193 ImageSlider.Actions = Actions$1;
6194 ImageSlider.Image = Image$2;
6195
6196 //#endregion
6197 //#region modules/ai/assets/js/editor/icons/copy-icon.js
6198 init_extends();
6199 var CopyIcon$1 = react.default.forwardRef(function(props, ref) {
6200 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
6201 fillRule: "evenodd",
6202 clipRule: "evenodd",
6203 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"
6204 }), /*#__PURE__*/ react.default.createElement("path", {
6205 fillRule: "evenodd",
6206 clipRule: "evenodd",
6207 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"
6208 }));
6209 });
6210
6211 //#endregion
6212 //#region modules/ai/assets/js/editor/icons/edit-icon.js
6213 init_extends();
6214 var EditIcon$1 = react.default.forwardRef(function(props, ref) {
6215 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
6216 fillRule: "evenodd",
6217 clipRule: "evenodd",
6218 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"
6219 }), /*#__PURE__*/ react.default.createElement("path", {
6220 fillRule: "evenodd",
6221 clipRule: "evenodd",
6222 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"
6223 }));
6224 });
6225
6226 //#endregion
6227 //#region modules/ai/assets/js/editor/icons/download-icon.js
6228 init_extends();
6229 var DownloadIcon = react.default.forwardRef(function(props, ref) {
6230 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
6231 fillRule: "evenodd",
6232 clipRule: "evenodd",
6233 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"
6234 }), /*#__PURE__*/ react.default.createElement("path", {
6235 fillRule: "evenodd",
6236 clipRule: "evenodd",
6237 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"
6238 }), /*#__PURE__*/ react.default.createElement("path", {
6239 fillRule: "evenodd",
6240 clipRule: "evenodd",
6241 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"
6242 }));
6243 });
6244
6245 //#endregion
6246 //#region modules/ai/assets/js/editor/icons/zoom-in-icon.js
6247 init_extends();
6248 var ZoomInIcon = react.default.forwardRef(function(props, ref) {
6249 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
6250 fillRule: "evenodd",
6251 clipRule: "evenodd",
6252 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"
6253 }), /*#__PURE__*/ react.default.createElement("path", {
6254 fillRule: "evenodd",
6255 clipRule: "evenodd",
6256 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"
6257 }), /*#__PURE__*/ react.default.createElement("path", {
6258 fillRule: "evenodd",
6259 clipRule: "evenodd",
6260 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"
6261 }), /*#__PURE__*/ react.default.createElement("path", {
6262 fillRule: "evenodd",
6263 clipRule: "evenodd",
6264 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"
6265 }));
6266 });
6267
6268 //#endregion
6269 //#region modules/ai/assets/js/editor/pages/form-media/components/image-actions.js
6270 init_defineProperty();
6271 init_objectWithoutProperties();
6272 init_extends();
6273 var _excluded$17 = ["children"];
6274 var _excluded2$1 = ["sx"];
6275 var _excluded3 = ["sx"];
6276 var _excluded4 = ["sx"];
6277 var _excluded5 = ["sx"];
6278 function ownKeys$20(e, r) {
6279 var t = Object.keys(e);
6280 if (Object.getOwnPropertySymbols) {
6281 var o = Object.getOwnPropertySymbols(e);
6282 r && (o = o.filter(function(r) {
6283 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6284 })), t.push.apply(t, o);
6285 }
6286 return t;
6287 }
6288 __name(ownKeys$20, "ownKeys");
6289 function _objectSpread$20(e) {
6290 for (var r = 1; r < arguments.length; r++) {
6291 var t = null != arguments[r] ? arguments[r] : {};
6292 r % 2 ? ownKeys$20(Object(t), !0).forEach(function(r) {
6293 _defineProperty(e, r, t[r]);
6294 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$20(Object(t)).forEach(function(r) {
6295 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6296 });
6297 }
6298 return e;
6299 }
6300 __name(_objectSpread$20, "_objectSpread");
6301 var StyledEditSvgIcon = (0, _elementor_ui.withDirection)(EditIcon$1);
6302 var StyledCopySvgIcon = (0, _elementor_ui.withDirection)(CopyIcon$1);
6303 var StyledZoomInIcon = (0, _elementor_ui.withDirection)(ZoomInIcon);
6304 var Tooltip$5 = function Tooltip(props) {
6305 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, _extends$1({ PopperProps: { sx: { "&.MuiTooltip-popper .MuiTooltip-tooltip.MuiTooltip-tooltipPlacementBottom": { mt: 1 } } } }, props));
6306 };
6307 var ImageActions = function ImageActions(_ref) {
6308 var children = _ref.children;
6309 var props = _objectWithoutProperties(_ref, _excluded$17);
6310 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
6311 display: "flex",
6312 justifyContent: "space-between",
6313 alignItems: "center",
6314 width: "100%",
6315 gap: 1
6316 }, props), children);
6317 };
6318 ImageActions.propTypes = { children: import_prop_types$12.default.node };
6319 var UseImage = function UseImage(_ref2) {
6320 var sx = _ref2.sx;
6321 var props = _objectWithoutProperties(_ref2, _excluded2$1);
6322 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
6323 size: "small",
6324 variant: "contained",
6325 startIcon: /*#__PURE__*/ react.default.createElement(DownloadIcon, null),
6326 sx
6327 }, props), (0, _wordpress_i18n.__)("Use Image", "elementor"));
6328 };
6329 UseImage.propTypes = { sx: import_prop_types$12.default.object };
6330 var EditImage = function EditImage(props) {
6331 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
6332 size: "small",
6333 color: "secondary",
6334 startIcon: /*#__PURE__*/ react.default.createElement(StyledEditSvgIcon, null)
6335 }, props), (0, _wordpress_i18n.__)("Edit", "elementor"));
6336 };
6337 var EditIcon = function EditIcon(_ref3) {
6338 var _ref3$sx = _ref3.sx;
6339 var sx = _ref3$sx === void 0 ? {} : _ref3$sx;
6340 var props = _objectWithoutProperties(_ref3, _excluded3);
6341 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({
6342 mr: -1.5,
6343 ml: .5,
6344 color: "common.white",
6345 "&:hover": { color: "common.white" }
6346 }, sx) }, props), /*#__PURE__*/ react.default.createElement(StyledEditSvgIcon, null)));
6347 };
6348 EditIcon.propTypes = { sx: import_prop_types$12.default.object };
6349 var ZoomIcon = function ZoomIcon(_ref4) {
6350 var _ref4$sx = _ref4.sx;
6351 var sx = _ref4$sx === void 0 ? {} : _ref4$sx;
6352 var props = _objectWithoutProperties(_ref4, _excluded4);
6353 return /*#__PURE__*/ react.default.createElement(Tooltip$5, { title: (0, _wordpress_i18n.__)("Zoom", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, _extends$1({
6354 color: "secondary",
6355 "aria-label": (0, _wordpress_i18n.__)("Zoom", "elementor"),
6356 sx: _objectSpread$20({
6357 color: "common.white",
6358 "&:hover": { color: "common.white" }
6359 }, sx)
6360 }, props), /*#__PURE__*/ react.default.createElement(StyledZoomInIcon, null)));
6361 };
6362 ZoomIcon.propTypes = { sx: import_prop_types$12.default.object };
6363 var CopyIcon = function CopyIcon(_ref5) {
6364 var _ref5$sx = _ref5.sx;
6365 var sx = _ref5$sx === void 0 ? {} : _ref5$sx;
6366 var props = _objectWithoutProperties(_ref5, _excluded5);
6367 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({
6368 mr: -1.5,
6369 ml: .5,
6370 color: "common.white",
6371 "&:hover": { color: "common.white" }
6372 }, sx) }, props), /*#__PURE__*/ react.default.createElement(StyledCopySvgIcon, null)));
6373 };
6374 CopyIcon.propTypes = { sx: import_prop_types$12.default.object };
6375 ImageActions.UseImage = UseImage;
6376 ImageActions.EditImage = EditImage;
6377 ImageActions.EditIcon = EditIcon;
6378 ImageActions.ZoomIcon = ZoomIcon;
6379 ImageActions.CopyIcon = CopyIcon;
6380
6381 //#endregion
6382 //#region modules/ai/assets/js/editor/pages/form-media/components/single-image-preview.js
6383 init_defineProperty();
6384 init_extends();
6385 init_objectWithoutProperties();
6386 var _excluded$16 = ["children"];
6387 var _excluded2 = ["children", "sx"];
6388 function ownKeys$19(e, r) {
6389 var t = Object.keys(e);
6390 if (Object.getOwnPropertySymbols) {
6391 var o = Object.getOwnPropertySymbols(e);
6392 r && (o = o.filter(function(r) {
6393 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6394 })), t.push.apply(t, o);
6395 }
6396 return t;
6397 }
6398 __name(ownKeys$19, "ownKeys");
6399 function _objectSpread$19(e) {
6400 for (var r = 1; r < arguments.length; r++) {
6401 var t = null != arguments[r] ? arguments[r] : {};
6402 r % 2 ? ownKeys$19(Object(t), !0).forEach(function(r) {
6403 _defineProperty(e, r, t[r]);
6404 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$19(Object(t)).forEach(function(r) {
6405 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6406 });
6407 }
6408 return e;
6409 }
6410 __name(_objectSpread$19, "_objectSpread");
6411 var SingleImagePreview = function SingleImagePreview(_ref) {
6412 var children = _ref.children;
6413 var props = _objectWithoutProperties(_ref, _excluded$16);
6414 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({ display: "flex" }, props), children);
6415 };
6416 SingleImagePreview.propTypes = { children: import_prop_types$12.default.node.isRequired };
6417 var Actions = function Actions(_ref2) {
6418 var children = _ref2.children;
6419 var _ref2$sx = _ref2.sx;
6420 var sx = _ref2$sx === void 0 ? {} : _ref2$sx;
6421 var props = _objectWithoutProperties(_ref2, _excluded2);
6422 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
6423 display: "flex",
6424 width: "100%",
6425 justifyContent: "flex-end",
6426 alignItems: "center"
6427 }, props, { sx: _objectSpread$19({ mb: 1.5 }, sx) }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
6428 direction: "row",
6429 spacing: 2,
6430 justifyContent: "flex-end",
6431 width: "100%"
6432 }, children));
6433 };
6434 Actions.propTypes = {
6435 sx: import_prop_types$12.default.object,
6436 children: import_prop_types$12.default.node.isRequired
6437 };
6438 var Image$1 = function Image(_ref3) {
6439 var src = _ref3.src;
6440 var alt = _ref3.alt;
6441 var _ref3$style = _ref3.style;
6442 var style = _ref3$style === void 0 ? {} : _ref3$style;
6443 var _ref3$isLoading = _ref3.isLoading;
6444 var isLoading = _ref3$isLoading === void 0 ? false : _ref3$isLoading;
6445 var children = _ref3.children;
6446 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { margin: "0 auto" }, children, isLoading ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Skeleton, {
6447 sx: _objectSpread$19({
6448 maxWidth: "100%",
6449 width: "auto",
6450 maxHeight: "100%"
6451 }, style),
6452 animation: "wave",
6453 variant: "rounded"
6454 }) : /*#__PURE__*/ react.default.createElement("img", {
6455 src,
6456 alt,
6457 style: _objectSpread$19({
6458 maxWidth: "100%",
6459 width: "auto",
6460 maxHeight: "100%"
6461 }, style)
6462 }));
6463 };
6464 Image$1.propTypes = {
6465 style: import_prop_types$12.default.object,
6466 children: import_prop_types$12.default.node,
6467 src: import_prop_types$12.default.string.isRequired,
6468 alt: import_prop_types$12.default.string.isRequired,
6469 isLoading: import_prop_types$12.default.bool
6470 };
6471 SingleImagePreview.Actions = Actions;
6472 SingleImagePreview.Image = Image$1;
6473
6474 //#endregion
6475 //#region modules/ai/assets/js/editor/pages/form-media/components/images-display.js
6476 init_extends();
6477 init_defineProperty();
6478 init_objectWithoutProperties();
6479 var _excluded$15 = ["children", "sx"];
6480 function ownKeys$18(e, r) {
6481 var t = Object.keys(e);
6482 if (Object.getOwnPropertySymbols) {
6483 var o = Object.getOwnPropertySymbols(e);
6484 r && (o = o.filter(function(r) {
6485 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6486 })), t.push.apply(t, o);
6487 }
6488 return t;
6489 }
6490 __name(ownKeys$18, "ownKeys");
6491 function _objectSpread$18(e) {
6492 for (var r = 1; r < arguments.length; r++) {
6493 var t = null != arguments[r] ? arguments[r] : {};
6494 r % 2 ? ownKeys$18(Object(t), !0).forEach(function(r) {
6495 _defineProperty(e, r, t[r]);
6496 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$18(Object(t)).forEach(function(r) {
6497 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6498 });
6499 }
6500 return e;
6501 }
6502 __name(_objectSpread$18, "_objectSpread");
6503 var Container = function Container(_ref) {
6504 var children = _ref.children;
6505 var _ref$sx = _ref.sx;
6506 var sx = _ref$sx === void 0 ? {} : _ref$sx;
6507 var props = _objectWithoutProperties(_ref, _excluded$15);
6508 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({ flexGrow: 1 }, props, { sx: _objectSpread$18({ overflowY: "auto" }, sx) }), children);
6509 };
6510 Container.propTypes = {
6511 sx: import_prop_types$12.default.object,
6512 children: import_prop_types$12.default.node
6513 };
6514 var ImagesDisplay = function ImagesDisplay(_ref2) {
6515 var images = _ref2.images;
6516 var _ref2$aspectRatio = _ref2.aspectRatio;
6517 var aspectRatio = _ref2$aspectRatio === void 0 ? "1:1" : _ref2$aspectRatio;
6518 var _ref2$onUseImage = _ref2.onUseImage;
6519 var onUseImage = _ref2$onUseImage === void 0 ? null : _ref2$onUseImage;
6520 var _ref2$onEditImage = _ref2.onEditImage;
6521 var onEditImage = _ref2$onEditImage === void 0 ? null : _ref2$onEditImage;
6522 var _ref2$transparentCont = _ref2.transparentContainer;
6523 var transparentContainer = _ref2$transparentCont === void 0 ? false : _ref2$transparentCont;
6524 var _ref2$cols = _ref2.cols;
6525 var cols = _ref2$cols === void 0 ? 2 : _ref2$cols;
6526 var _ref2$overlay = _ref2.overlay;
6527 var overlay = _ref2$overlay === void 0 ? true : _ref2$overlay;
6528 var _ref2$onSelectChange = _ref2.onSelectChange;
6529 var onSelectChange = _ref2$onSelectChange === void 0 ? null : _ref2$onSelectChange;
6530 var _useImageNavigation = useImageNavigation(images);
6531 var zoomIndex = _useImageNavigation.zoomIndex;
6532 var setZoomIndex = _useImageNavigation.setZoomIndex;
6533 var actions = _useImageNavigation.actions;
6534 var _useImageSize = useImageSize(aspectRatio);
6535 var width = _useImageSize.width;
6536 var height = _useImageSize.height;
6537 if (zoomIndex > -1) {
6538 var currentImage = images[zoomIndex];
6539 return /*#__PURE__*/ react.default.createElement(Container, null, /*#__PURE__*/ react.default.createElement(ImageSlider, {
6540 onPrev: actions.prev,
6541 onNext: actions.next
6542 }, /*#__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() {
6543 return onEditImage(currentImage);
6544 } }), onUseImage && /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, { onClick: function onClick() {
6545 return onUseImage(currentImage);
6546 } })), /*#__PURE__*/ react.default.createElement(ImageSlider.Image, {
6547 src: currentImage.image_url,
6548 style: {
6549 maxWidth: "630px",
6550 width: "100%",
6551 height: "auto"
6552 }
6553 })));
6554 }
6555 if (1 === images.length) {
6556 var image = images[0];
6557 var singleImageStyle = {
6558 width,
6559 height
6560 };
6561 if (transparentContainer) {
6562 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%)";
6563 singleImageStyle.backgroundSize = "20px 20px";
6564 singleImageStyle.backgroundPosition = "0 0, 0 10px, 10px -10px, -10px 0px";
6565 }
6566 return /*#__PURE__*/ react.default.createElement(Container, { flexDirection: "column" }, /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
6567 src: image.image_url || image.url,
6568 style: singleImageStyle,
6569 alt: "generated-image",
6570 isLoading: image.isLoading
6571 }, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Actions, null, onEditImage && /*#__PURE__*/ react.default.createElement(ImageActions.EditImage, { onClick: function onClick() {
6572 return onEditImage(image);
6573 } }), onUseImage && /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, { onClick: function onClick() {
6574 return onUseImage(image);
6575 } })))));
6576 }
6577 return /*#__PURE__*/ react.default.createElement(Container, null, /*#__PURE__*/ react.default.createElement(Gallery, { cols }, images.map(function(image, index) {
6578 return /*#__PURE__*/ react.default.createElement(Gallery.Image, {
6579 key: "result-".concat(image.seed),
6580 alt: "generated-".concat(index),
6581 src: image.image_url,
6582 aspectRatio,
6583 "data-testid": "e-gallery-image",
6584 numImagesInRow: cols,
6585 overlay,
6586 onSelectChange: onSelectChange ? function(isChecked) {
6587 return onSelectChange(image.productId, isChecked);
6588 } : null,
6589 checkboxColor: image.checkboxColor,
6590 initialChecked: image.isChecked,
6591 isLoading: image.isLoading
6592 }, /*#__PURE__*/ react.default.createElement(ImageActions, null, onUseImage && /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, {
6593 onClick: function onClick() {
6594 return onUseImage(image);
6595 },
6596 size: "medium",
6597 fullWidth: true
6598 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
6599 direction: "row",
6600 spacing: .25,
6601 alignItems: "center"
6602 }, /*#__PURE__*/ react.default.createElement(ImageActions.ZoomIcon, {
6603 onClick: function onClick() {
6604 return setZoomIndex(index);
6605 },
6606 size: "medium"
6607 }), onEditImage && /*#__PURE__*/ react.default.createElement(ImageActions.EditIcon, {
6608 onClick: function onClick() {
6609 return onEditImage(image);
6610 },
6611 size: "medium"
6612 }))));
6613 })));
6614 };
6615 ImagesDisplay.propTypes = {
6616 images: import_prop_types$12.default.array,
6617 aspectRatio: import_prop_types$12.default.string,
6618 onUseImage: import_prop_types$12.default.func,
6619 onEditImage: import_prop_types$12.default.func,
6620 transparentContainer: import_prop_types$12.default.bool,
6621 cols: import_prop_types$12.default.number,
6622 overlay: import_prop_types$12.default.bool,
6623 onSelectChange: import_prop_types$12.default.func
6624 };
6625 ImagesDisplay.Container = Container;
6626
6627 //#endregion
6628 //#region modules/ai/assets/js/editor/pages/form-media/hooks/use-prompt-settings.js
6629 init_defineProperty();
6630 init_slicedToArray();
6631 function ownKeys$17(e, r) {
6632 var t = Object.keys(e);
6633 if (Object.getOwnPropertySymbols) {
6634 var o = Object.getOwnPropertySymbols(e);
6635 r && (o = o.filter(function(r) {
6636 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6637 })), t.push.apply(t, o);
6638 }
6639 return t;
6640 }
6641 __name(ownKeys$17, "ownKeys");
6642 function _objectSpread$17(e) {
6643 for (var r = 1; r < arguments.length; r++) {
6644 var t = null != arguments[r] ? arguments[r] : {};
6645 r % 2 ? ownKeys$17(Object(t), !0).forEach(function(r) {
6646 _defineProperty(e, r, t[r]);
6647 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$17(Object(t)).forEach(function(r) {
6648 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6649 });
6650 }
6651 return e;
6652 }
6653 __name(_objectSpread$17, "_objectSpread");
6654 var IMAGE_TYPE = IMAGE_PROMPT_SETTINGS.IMAGE_TYPE;
6655 var IMAGE_STYLE = IMAGE_PROMPT_SETTINGS.IMAGE_STYLE;
6656 var IMAGE_STRENGTH = IMAGE_PROMPT_SETTINGS.IMAGE_STRENGTH;
6657 var IMAGE_RATIO = IMAGE_PROMPT_SETTINGS.IMAGE_RATIO;
6658 var IMAGE_ZOOM = IMAGE_PROMPT_SETTINGS.IMAGE_ZOOM;
6659 var IMAGE_UPSCALE = IMAGE_PROMPT_SETTINGS.IMAGE_UPSCALE;
6660 var IMAGE_BACKGROUND_COLOR = IMAGE_PROMPT_SETTINGS.IMAGE_BACKGROUND_COLOR;
6661 var DEFAULT_TYPE = "";
6662 var DEFAULT_STYLE = "";
6663 var DEFAULT_STRENGTH = 0;
6664 var DEFAULT_RATIO = "1:1";
6665 var DEFAULT_ZOOM = "1";
6666 var DEFAULT_UPSCALE = "512";
6667 var DEFAULT_COLOR = "#FFFFFF";
6668 var usePromptSettings = function usePromptSettings() {
6669 var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
6670 var _ref$type = _ref.type;
6671 var type = _ref$type === void 0 ? DEFAULT_TYPE : _ref$type;
6672 var _ref$style = _ref.style;
6673 var style = _ref$style === void 0 ? DEFAULT_STYLE : _ref$style;
6674 var _ref$imageWeight = _ref.imageWeight;
6675 var imageWeight = _ref$imageWeight === void 0 ? DEFAULT_STRENGTH : _ref$imageWeight;
6676 var _ref$aspectRatio = _ref.aspectRatio;
6677 var aspectRatio = _ref$aspectRatio === void 0 ? DEFAULT_RATIO : _ref$aspectRatio;
6678 var _ref$zoom = _ref.zoom;
6679 var zoom = _ref$zoom === void 0 ? DEFAULT_ZOOM : _ref$zoom;
6680 var _ref$upScaleTo = _ref.upScaleTo;
6681 var upScaleTo = _ref$upScaleTo === void 0 ? DEFAULT_UPSCALE : _ref$upScaleTo;
6682 var _ref$bgColor = _ref.bgColor;
6683 var bgColor = _ref$bgColor === void 0 ? DEFAULT_COLOR : _ref$bgColor;
6684 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);
6685 var settings = _useState2[0];
6686 var setSettings = _useState2[1];
6687 return {
6688 settings,
6689 updateSettings: function updateSettings(updated) {
6690 return setSettings(function(prev) {
6691 return _objectSpread$17(_objectSpread$17({}, prev), updated);
6692 });
6693 },
6694 resetSettings: function resetSettings() {
6695 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));
6696 }
6697 };
6698 };
6699
6700 //#endregion
6701 //#region modules/ai/assets/js/editor/hooks/use-images-preload.js
6702 init_slicedToArray();
6703 var loadImage$1 = function loadImage(url) {
6704 return new Promise(function(resolve, reject) {
6705 var loadImg = new Image();
6706 loadImg.src = url;
6707 loadImg.onload = function() {
6708 return resolve(url);
6709 };
6710 loadImg.onerror = function(err) {
6711 return reject(err);
6712 };
6713 });
6714 };
6715 var useImagesPreload = function useImagesPreload() {
6716 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
6717 var ready = _useState2[0];
6718 var setReady = _useState2[1];
6719 return {
6720 ready,
6721 preloadImages: function preloadImages(images) {
6722 setReady(false);
6723 Promise.all(images.map(function(url) {
6724 return loadImage$1(url);
6725 })).then(function() {
6726 return setReady(true);
6727 }).catch(function(err) {
6728 return console.log("Failed to load images", err);
6729 });
6730 }
6731 };
6732 };
6733
6734 //#endregion
6735 //#region modules/ai/assets/js/editor/pages/form-media/views/generate/hooks/use-suggested-images.js
6736 init_slicedToArray();
6737 var shuffleImages = function shuffleImages(images) {
6738 return images.map(function(image) {
6739 return [Math.random(), image];
6740 }).sort(function(_ref, _ref2) {
6741 return _slicedToArray(_ref, 1)[0] - _slicedToArray(_ref2, 1)[0];
6742 }).map(function(_ref5) {
6743 return _slicedToArray(_ref5, 2)[1];
6744 });
6745 };
6746 var checkImageTypeIgnoreStyle = function checkImageTypeIgnoreStyle(imageType, selectedType) {
6747 return _slicedToArray(imageType.split("/"), 1)[0] === selectedType;
6748 };
6749 var useSuggestedImages = function useSuggestedImages(_ref7) {
6750 var selectedType = _ref7.selectedType;
6751 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
6752 var isLoading = _useState2[0];
6753 var setIsLoading = _useState2[1];
6754 var _useState4 = _slicedToArray((0, react.useState)({ images: [] }), 2);
6755 var data = _useState4[0];
6756 var setImagesState = _useState4[1];
6757 var _useImagesPreload = useImagesPreload();
6758 var ready = _useImagesPreload.ready;
6759 var preloadImages = _useImagesPreload.preloadImages;
6760 var imagesData = (0, react.useMemo)(function() {
6761 var shuffledImages = shuffleImages(data.images);
6762 if (!selectedType) return shuffledImages;
6763 var categoryImages = shuffledImages.filter(function(_ref8) {
6764 var imageType = _ref8.imageType;
6765 return checkImageTypeIgnoreStyle(imageType, selectedType);
6766 });
6767 return categoryImages.length ? categoryImages : shuffledImages;
6768 }, [selectedType, data]);
6769 var fetchImages = function fetchImages() {
6770 setIsLoading(true);
6771 fetch("https://my.elementor.com/ai/images-prompt-gallery/ai-gallery.json").then(function(response) {
6772 return response.json();
6773 }).then(function(json) {
6774 return setImagesState(json);
6775 }).catch(function(e) {
6776 return console.log(e.message);
6777 }).finally(function() {
6778 return setIsLoading(false);
6779 });
6780 };
6781 (0, react.useEffect)(function() {
6782 if (0 === (data === null || data === void 0 ? void 0 : data.images.length)) {
6783 fetchImages();
6784 return;
6785 }
6786 preloadImages(data.images.map(function(_ref9) {
6787 return _ref9.thumbnailUrl;
6788 }));
6789 }, [data]);
6790 return {
6791 imagesData,
6792 isLoading: !ready || isLoading
6793 };
6794 };
6795
6796 //#endregion
6797 //#region modules/ai/assets/js/editor/pages/form-media/utils/index.js
6798 init_asyncToGenerator();
6799 init_defineProperty();
6800 init_slicedToArray();
6801 function ownKeys$16(e, r) {
6802 var t = Object.keys(e);
6803 if (Object.getOwnPropertySymbols) {
6804 var o = Object.getOwnPropertySymbols(e);
6805 r && (o = o.filter(function(r) {
6806 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6807 })), t.push.apply(t, o);
6808 }
6809 return t;
6810 }
6811 __name(ownKeys$16, "ownKeys");
6812 function _objectSpread$16(e) {
6813 for (var r = 1; r < arguments.length; r++) {
6814 var t = null != arguments[r] ? arguments[r] : {};
6815 r % 2 ? ownKeys$16(Object(t), !0).forEach(function(r) {
6816 _defineProperty(e, r, t[r]);
6817 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$16(Object(t)).forEach(function(r) {
6818 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6819 });
6820 }
6821 return e;
6822 }
6823 __name(_objectSpread$16, "_objectSpread");
6824 var getAspectRatioSizes = function getAspectRatioSizes(width, height) {
6825 var aspectRatios = Object.keys(IMAGE_ASPECT_RATIO);
6826 var targetRatio = width / height;
6827 var closestRatio = aspectRatios[0];
6828 var minDiff = Infinity;
6829 aspectRatios.forEach(function(ratio) {
6830 var _ratio$split$map2 = _slicedToArray(ratio.split(":").map(Number), 2);
6831 var w = _ratio$split$map2[0];
6832 var h = _ratio$split$map2[1];
6833 var diff = Math.abs(targetRatio - w / h);
6834 if (diff < minDiff) {
6835 minDiff = diff;
6836 closestRatio = ratio;
6837 }
6838 });
6839 return _objectSpread$16({ ratio: closestRatio }, IMAGE_ASPECT_RATIO[closestRatio]);
6840 };
6841 var fetchImageAsBase64 = /*#__PURE__*/ function() {
6842 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee(url) {
6843 var response;
6844 var blob;
6845 var reader;
6846 var _t;
6847 return import_regenerator$3.default.wrap(function(_context) {
6848 while (1) switch (_context.prev = _context.next) {
6849 case 0:
6850 _context.prev = 0;
6851 _context.next = 1;
6852 return fetch(url);
6853 case 1:
6854 response = _context.sent;
6855 _context.next = 2;
6856 return response.blob();
6857 case 2:
6858 blob = _context.sent;
6859 reader = new FileReader();
6860 return _context.abrupt("return", new Promise(function(resolve, reject) {
6861 reader.onloadend = function() {
6862 resolve(reader.result);
6863 };
6864 reader.onerror = reject;
6865 reader.readAsDataURL(blob);
6866 }));
6867 case 3:
6868 _context.prev = 3;
6869 _t = _context["catch"](0);
6870 throw _t;
6871 case 4:
6872 case "end": return _context.stop();
6873 }
6874 }, _callee, null, [[0, 3]]);
6875 }));
6876 return function fetchImageAsBase64(_x) {
6877 return _ref.apply(this, arguments);
6878 };
6879 }();
6880
6881 //#endregion
6882 //#region modules/ai/assets/js/editor/pages/form-media/context/edit-image-context.js
6883 init_slicedToArray();
6884 init_defineProperty();
6885 function ownKeys$15(e, r) {
6886 var t = Object.keys(e);
6887 if (Object.getOwnPropertySymbols) {
6888 var o = Object.getOwnPropertySymbols(e);
6889 r && (o = o.filter(function(r) {
6890 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6891 })), t.push.apply(t, o);
6892 }
6893 return t;
6894 }
6895 __name(ownKeys$15, "ownKeys");
6896 function _objectSpread$15(e) {
6897 for (var r = 1; r < arguments.length; r++) {
6898 var t = null != arguments[r] ? arguments[r] : {};
6899 r % 2 ? ownKeys$15(Object(t), !0).forEach(function(r) {
6900 _defineProperty(e, r, t[r]);
6901 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$15(Object(t)).forEach(function(r) {
6902 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6903 });
6904 }
6905 return e;
6906 }
6907 __name(_objectSpread$15, "_objectSpread");
6908 var EditImageContext = (0, react.createContext)({});
6909 var SET_STATE = "SET_STATE";
6910 var SET_ASPECT_RATIO = "SET_ASPECT_RATIO";
6911 var SET_LOADING = "SET_LOADING";
6912 var RESET = "RESET";
6913 var initialValue = {
6914 id: "",
6915 url: "",
6916 isLoading: false,
6917 aspectRatio: "1:1"
6918 };
6919 var reducer$1 = function reducer(state, _ref) {
6920 var type = _ref.type;
6921 var payload = _ref.payload;
6922 switch (type) {
6923 case SET_STATE: return _objectSpread$15(_objectSpread$15({}, state), payload);
6924 case SET_ASPECT_RATIO: return _objectSpread$15(_objectSpread$15({}, state), {}, { aspectRatio: payload });
6925 case SET_LOADING: return _objectSpread$15(_objectSpread$15({}, state), {}, { isLoading: payload });
6926 case RESET: return initialValue;
6927 default: throw Error("Unknown action.");
6928 }
6929 };
6930 var EditImageProvider = function EditImageProvider(_ref2) {
6931 var children = _ref2.children;
6932 var imageData = _ref2.imageData;
6933 var _useReducer2 = _slicedToArray((0, react.useReducer)(reducer$1, _objectSpread$15(_objectSpread$15({}, initialValue), imageData)), 2);
6934 var state = _useReducer2[0];
6935 var dispatch = _useReducer2[1];
6936 return /*#__PURE__*/ react.default.createElement(EditImageContext.Provider, { value: {
6937 state,
6938 dispatch
6939 } }, children);
6940 };
6941 EditImageProvider.propTypes = {
6942 children: import_prop_types$12.default.node,
6943 imageData: import_prop_types$12.default.object
6944 };
6945 var useEditImage = function useEditImage() {
6946 var _useContext = (0, react.useContext)(EditImageContext);
6947 var state = _useContext.state;
6948 var dispatch = _useContext.dispatch;
6949 var id = state.id;
6950 var url = state.url;
6951 var aspectRatio = state.aspectRatio;
6952 var isLoading = state.isLoading;
6953 var _useImageSize = useImageSize(aspectRatio);
6954 var width = _useImageSize.width;
6955 var height = _useImageSize.height;
6956 var setEditImage = function setEditImage(payload) {
6957 return dispatch({
6958 type: SET_STATE,
6959 payload
6960 });
6961 };
6962 var setAspectRatio = function setAspectRatio(payload) {
6963 return dispatch({
6964 type: SET_ASPECT_RATIO,
6965 payload
6966 });
6967 };
6968 var reset = function reset() {
6969 return dispatch({ type: RESET });
6970 };
6971 (0, react.useEffect)(function() {
6972 if (!id) return;
6973 dispatch({
6974 type: SET_LOADING,
6975 payload: true
6976 });
6977 var img = new Image();
6978 img.src = url;
6979 img.onload = function() {
6980 var ratio = getAspectRatioSizes(img.width, img.height).ratio;
6981 dispatch({
6982 type: SET_STATE,
6983 payload: {
6984 aspectRatio: ratio,
6985 isLoading: false
6986 }
6987 });
6988 };
6989 }, [id]);
6990 return {
6991 editImage: state,
6992 isLoading,
6993 aspectRatio,
6994 width,
6995 height,
6996 setEditImage,
6997 setAspectRatio,
6998 reset
6999 };
7000 };
7001
7002 //#endregion
7003 //#region modules/ai/assets/js/editor/pages/form-media/hooks/use-image-upload.js
7004 init_slicedToArray();
7005 init_api();
7006 var useImageUpload = function useImageUpload() {
7007 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
7008 var isUploading = _useState2[0];
7009 var setIsUploading = _useState2[1];
7010 var _useState4 = _slicedToArray((0, react.useState)(""), 2);
7011 var uploadError = _useState4[0];
7012 var setUploadError = _useState4[1];
7013 var _useState6 = _slicedToArray((0, react.useState)({}), 2);
7014 var attachmentData = _useState6[0];
7015 var setAttachmentData = _useState6[1];
7016 return {
7017 upload: function upload(_ref) {
7018 var image = _ref.image;
7019 var prompt = _ref.prompt;
7020 return new Promise(function(resolve, reject) {
7021 setUploadError("");
7022 setAttachmentData({});
7023 setIsUploading(true);
7024 uploadImage({
7025 image,
7026 prompt
7027 }).then(function(result) {
7028 setAttachmentData(result);
7029 resolve(result);
7030 }).catch(function(err) {
7031 var error = (err === null || err === void 0 ? void 0 : err.responseText) || err;
7032 setUploadError(error);
7033 reject(error);
7034 }).finally(function() {
7035 return setIsUploading(false);
7036 });
7037 });
7038 },
7039 resetUpload: function resetUpload() {
7040 setUploadError("");
7041 setAttachmentData({});
7042 setIsUploading(false);
7043 },
7044 isUploading,
7045 uploadError,
7046 attachmentData
7047 };
7048 };
7049
7050 //#endregion
7051 //#region modules/ai/assets/js/editor/pages/form-media/context/global-actions-context.js
7052 var GlobalActionsContext = (0, react.createContext)({});
7053 var GlobalActionsProvider = function GlobalActionsProvider(_ref) {
7054 var actions = _ref.actions;
7055 var children = _ref.children;
7056 return /*#__PURE__*/ react.default.createElement(GlobalActionsContext.Provider, { value: actions }, children);
7057 };
7058 GlobalActionsProvider.propTypes = {
7059 actions: import_prop_types$12.default.object,
7060 children: import_prop_types$12.default.node
7061 };
7062 var useGlobalActions = function useGlobalActions() {
7063 return (0, react.useContext)(GlobalActionsContext);
7064 };
7065
7066 //#endregion
7067 //#region node_modules/@babel/runtime/helpers/esm/classCallCheck.js
7068 function _classCallCheck(a, n) {
7069 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
7070 }
7071
7072 //#endregion
7073 //#region node_modules/@babel/runtime/helpers/esm/createClass.js
7074 init_toPropertyKey();
7075 function _defineProperties(e, r) {
7076 for (var t = 0; t < r.length; t++) {
7077 var o = r[t];
7078 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
7079 }
7080 }
7081 function _createClass(e, r, t) {
7082 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e;
7083 }
7084
7085 //#endregion
7086 //#region assets/dev/js/editor/utils/files-upload-handler.js
7087 var FilesUploadHandler = /*#__PURE__*/ function() {
7088 function FilesUploadHandler() {
7089 _classCallCheck(this, FilesUploadHandler);
7090 }
7091 return _createClass(FilesUploadHandler, null, [
7092 {
7093 key: "isUploadEnabled",
7094 value: function isUploadEnabled(mediaType) {
7095 if (!["svg", "application/json"].includes(mediaType)) return true;
7096 return elementorCommon.config.filesUpload.unfilteredFiles;
7097 }
7098 },
7099 {
7100 key: "setUploadTypeCaller",
7101 value: function setUploadTypeCaller(frame) {
7102 frame.uploader.uploader.param("uploadTypeCaller", "elementor-wp-media-upload");
7103 }
7104 },
7105 {
7106 key: "getUnfilteredFilesNonAdminDialog",
7107 value: function getUnfilteredFilesNonAdminDialog() {
7108 return elementorCommon.dialogsManager.createWidget("alert", {
7109 id: "e-unfiltered-files-disabled-dialog",
7110 headerMessage: (0, _wordpress_i18n.__)("Sorry, you can't upload that file yet", "elementor"),
7111 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"),
7112 strings: { confirm: (0, _wordpress_i18n.__)("Got it", "elementor") }
7113 });
7114 }
7115 },
7116 {
7117 key: "getUnfilteredFilesNotEnabledDialog",
7118 value: function getUnfilteredFilesNotEnabledDialog(callback) {
7119 var elementorInstance = window.elementorAdmin || window.elementor;
7120 if (!elementorInstance.config.user.is_administrator) return this.getUnfilteredFilesNonAdminDialog();
7121 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() {
7122 elementorCommon.ajax.addRequest("enable_unfiltered_files_upload", {}, true);
7123 elementorCommon.config.filesUpload.unfilteredFiles = true;
7124 callback();
7125 });
7126 }
7127 },
7128 {
7129 key: "getUnfilteredFilesNotEnabledImportTemplateDialog",
7130 value: function getUnfilteredFilesNotEnabledImportTemplateDialog(callback) {
7131 if (!(window.elementorAdmin || window.elementor).config.user.is_administrator) return this.getUnfilteredFilesNonAdminDialog();
7132 return elementorCommon.dialogsManager.createWidget("confirm", {
7133 id: "e-enable-unfiltered-files-dialog-import-template",
7134 headerMessage: (0, _wordpress_i18n.__)("Enable Unfiltered File Uploads", "elementor"),
7135 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"),
7136 position: {
7137 my: "center center",
7138 at: "center center"
7139 },
7140 strings: {
7141 confirm: (0, _wordpress_i18n.__)("Enable and Import", "elementor"),
7142 cancel: (0, _wordpress_i18n.__)("Import Without Enabling", "elementor")
7143 },
7144 onConfirm: function onConfirm() {
7145 elementorCommon.ajax.addRequest("enable_unfiltered_files_upload", { success: function success() {
7146 elementorCommon.config.filesUpload.unfilteredFiles = true;
7147 callback();
7148 } }, true);
7149 },
7150 onCancel: function onCancel() {
7151 return callback();
7152 }
7153 });
7154 }
7155 }
7156 ]);
7157 }();
7158
7159 //#endregion
7160 //#region modules/ai/assets/js/editor/pages/form-media/hooks/use-image-actions.js
7161 init_objectWithoutProperties();
7162 init_asyncToGenerator();
7163 init_defineProperty();
7164 var _excluded$14 = ["image"];
7165 function ownKeys$14(e, r) {
7166 var t = Object.keys(e);
7167 if (Object.getOwnPropertySymbols) {
7168 var o = Object.getOwnPropertySymbols(e);
7169 r && (o = o.filter(function(r) {
7170 return Object.getOwnPropertyDescriptor(e, r).enumerable;
7171 })), t.push.apply(t, o);
7172 }
7173 return t;
7174 }
7175 __name(ownKeys$14, "ownKeys");
7176 function _objectSpread$14(e) {
7177 for (var r = 1; r < arguments.length; r++) {
7178 var t = null != arguments[r] ? arguments[r] : {};
7179 r % 2 ? ownKeys$14(Object(t), !0).forEach(function(r) {
7180 _defineProperty(e, r, t[r]);
7181 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$14(Object(t)).forEach(function(r) {
7182 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
7183 });
7184 }
7185 return e;
7186 }
7187 __name(_objectSpread$14, "_objectSpread");
7188 var normalizeImageData = function normalizeImageData(imageToUpload) {
7189 if (!(imageToUpload !== null && imageToUpload !== void 0 && imageToUpload.imageUrl)) return imageToUpload;
7190 return _objectSpread$14(_objectSpread$14({}, imageToUpload), {}, {
7191 image_url: imageToUpload.imageUrl,
7192 use_gallery_image: true
7193 });
7194 };
7195 var useImageActions = function useImageActions() {
7196 var _useEditImage = useEditImage();
7197 var editImage = _useEditImage.editImage;
7198 var setEditImage = _useEditImage.setEditImage;
7199 var _useGlobalActions = useGlobalActions();
7200 var setControlValue = _useGlobalActions.setControlValue;
7201 var saveAndClose = _useGlobalActions.saveAndClose;
7202 var _useImageUpload = useImageUpload();
7203 var attachmentData = _useImageUpload.attachmentData;
7204 var isUploading = _useImageUpload.isUploading;
7205 var uploadError = _useImageUpload.uploadError;
7206 var uploadImage = _useImageUpload.upload;
7207 var resetUpload = _useImageUpload.resetUpload;
7208 var ensureSVGUploading = function ensureSVGUploading(imageUrl) {
7209 if (!imageUrl) return true;
7210 var imageExtension = new URL(imageUrl).pathname.split(".").pop();
7211 var isUploadAllowed = window._wpPluploadSettings.defaults.filters.mime_types[0].extensions.split(",").includes(imageExtension) || elementorCommon.config.filesUpload.unfilteredFiles;
7212 if (!isUploadAllowed) {
7213 var dialog = FilesUploadHandler.getUnfilteredFilesNotEnabledDialog(function() {});
7214 dialog.getElements("widget").css("z-index", "170001");
7215 dialog.show();
7216 }
7217 return isUploadAllowed;
7218 };
7219 var upload = function upload(imageToUpload, prompt) {
7220 if (!ensureSVGUploading(imageToUpload.image_url)) return Promise.reject(/* @__PURE__ */ new Error("SVG Uploading is not allowed"));
7221 return uploadImage({
7222 image: normalizeImageData(imageToUpload),
7223 prompt: prompt || imageToUpload.prompt
7224 });
7225 };
7226 var getFinalImage = /*#__PURE__*/ function() {
7227 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee(imageToUpload, prompt) {
7228 var isImageAlreadyUploaded;
7229 var _result;
7230 var result;
7231 return import_regenerator$3.default.wrap(function(_context) {
7232 while (1) switch (_context.prev = _context.next) {
7233 case 0:
7234 isImageAlreadyUploaded = editImage.url === imageToUpload.url;
7235 if (!isImageAlreadyUploaded) {
7236 _context.next = 1;
7237 break;
7238 }
7239 editImage.image, _result = _objectWithoutProperties(editImage, _excluded$14);
7240 return _context.abrupt("return", _result);
7241 case 1:
7242 _context.next = 2;
7243 return upload(imageToUpload, prompt);
7244 case 2:
7245 result = _context.sent;
7246 return _context.abrupt("return", result === null || result === void 0 ? void 0 : result.image);
7247 case 3:
7248 case "end": return _context.stop();
7249 }
7250 }, _callee);
7251 }));
7252 return function getFinalImage(_x, _x2) {
7253 return _ref.apply(this, arguments);
7254 };
7255 }();
7256 return {
7257 use: /* @__PURE__ */ function() {
7258 var _ref3 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee3(imageToUpload, prompt) {
7259 var result;
7260 return import_regenerator$3.default.wrap(function(_context3) {
7261 while (1) switch (_context3.prev = _context3.next) {
7262 case 0:
7263 _context3.next = 1;
7264 return getFinalImage(imageToUpload, prompt);
7265 case 1:
7266 result = _context3.sent;
7267 setControlValue(result);
7268 saveAndClose();
7269 case 2:
7270 case "end": return _context3.stop();
7271 }
7272 }, _callee3);
7273 }));
7274 return function use(_x5, _x6) {
7275 return _ref3.apply(this, arguments);
7276 };
7277 }(),
7278 edit: /* @__PURE__ */ function() {
7279 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee2(imageToUpload, prompt) {
7280 var result;
7281 return import_regenerator$3.default.wrap(function(_context2) {
7282 while (1) switch (_context2.prev = _context2.next) {
7283 case 0:
7284 _context2.next = 1;
7285 return upload(imageToUpload, prompt);
7286 case 1:
7287 result = _context2.sent;
7288 setEditImage(result.image);
7289 case 2:
7290 case "end": return _context2.stop();
7291 }
7292 }, _callee2);
7293 }));
7294 return function edit(_x3, _x4) {
7295 return _ref2.apply(this, arguments);
7296 };
7297 }(),
7298 reset: resetUpload,
7299 error: uploadError,
7300 data: attachmentData,
7301 isLoading: isUploading,
7302 useMultipleImages: /* @__PURE__ */ function() {
7303 var _ref4 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee6(imagesToUpload) {
7304 var results;
7305 return import_regenerator$3.default.wrap(function(_context6) {
7306 while (1) switch (_context6.prev = _context6.next) {
7307 case 0:
7308 _context6.next = 1;
7309 return Promise.all(imagesToUpload.map(/*#__PURE__*/ function() {
7310 var _ref5 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee4(img) {
7311 return import_regenerator$3.default.wrap(function(_context4) {
7312 while (1) switch (_context4.prev = _context4.next) {
7313 case 0:
7314 _context4.next = 1;
7315 return getFinalImage(img, null).catch(function(_) {
7316 return null;
7317 });
7318 case 1: return _context4.abrupt("return", _context4.sent);
7319 case 2:
7320 case "end": return _context4.stop();
7321 }
7322 }, _callee4);
7323 }));
7324 return function(_x8) {
7325 return _ref5.apply(this, arguments);
7326 };
7327 }()));
7328 case 1:
7329 results = _context6.sent;
7330 _context6.next = 2;
7331 return Promise.all(results.filter(function(result) {
7332 return result;
7333 }).map(/*#__PURE__*/ function() {
7334 var _ref6 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee5(result) {
7335 return import_regenerator$3.default.wrap(function(_context5) {
7336 while (1) switch (_context5.prev = _context5.next) {
7337 case 0:
7338 _context5.next = 1;
7339 return setControlValue(result);
7340 case 1: return _context5.abrupt("return", _context5.sent);
7341 case 2:
7342 case "end": return _context5.stop();
7343 }
7344 }, _callee5);
7345 }));
7346 return function(_x9) {
7347 return _ref6.apply(this, arguments);
7348 };
7349 }()));
7350 case 2:
7351 case "end": return _context6.stop();
7352 }
7353 }, _callee6);
7354 }));
7355 return function useMultipleImages(_x7) {
7356 return _ref4.apply(this, arguments);
7357 };
7358 }()
7359 };
7360 };
7361
7362 //#endregion
7363 //#region modules/ai/assets/js/editor/pages/form-media/views/variations/components/images-placeholder.js
7364 var ImagesPlaceholder = function ImagesPlaceholder() {
7365 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7366 sx: { overflowY: "scroll" },
7367 flexGrow: 1
7368 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7369 display: "grid",
7370 gridTemplateColumns: "repeat(2, 1fr)",
7371 gap: 3
7372 }, Array(4).fill(true).map(function(_, index) {
7373 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7374 key: "placeholder-".concat(index),
7375 display: "flex",
7376 justifyContent: "center",
7377 alignItems: "center",
7378 sx: {
7379 bgcolor: "action.selected",
7380 height: 336
7381 }
7382 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, {
7383 color: "secondary",
7384 sx: { fontSize: 36 }
7385 }));
7386 })));
7387 };
7388 ImagesPlaceholder.propTypes = {};
7389
7390 //#endregion
7391 //#region modules/ai/assets/js/editor/pages/form-media/views/generate/index.js
7392 init_defineProperty();
7393 init_slicedToArray();
7394 init_prompt_history_action_context();
7395 init_prompt_library_link();
7396 init_requests_ids();
7397 function ownKeys$13(e, r) {
7398 var t = Object.keys(e);
7399 if (Object.getOwnPropertySymbols) {
7400 var o = Object.getOwnPropertySymbols(e);
7401 r && (o = o.filter(function(r) {
7402 return Object.getOwnPropertyDescriptor(e, r).enumerable;
7403 })), t.push.apply(t, o);
7404 }
7405 return t;
7406 }
7407 __name(ownKeys$13, "ownKeys");
7408 function _objectSpread$13(e) {
7409 for (var r = 1; r < arguments.length; r++) {
7410 var t = null != arguments[r] ? arguments[r] : {};
7411 r % 2 ? ownKeys$13(Object(t), !0).forEach(function(r) {
7412 _defineProperty(e, r, t[r]);
7413 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$13(Object(t)).forEach(function(r) {
7414 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
7415 });
7416 }
7417 return e;
7418 }
7419 __name(_objectSpread$13, "_objectSpread");
7420 var getPromptPlaceholder = function getPromptPlaceholder(images) {
7421 if (!(images !== null && images !== void 0 && images.length)) return (0, _wordpress_i18n.__)("describe your image", "elementor");
7422 return images[Math.floor(Math.random() * images.length)].prompt;
7423 };
7424 var Generate = function Generate(_ref) {
7425 var textToImageHook = _ref.textToImageHook;
7426 var _ref$predefinedPrompt = _ref.predefinedPrompt;
7427 var predefinedPrompt = _ref$predefinedPrompt === void 0 ? "" : _ref$predefinedPrompt;
7428 var _ref$initialSettings = _ref.initialSettings;
7429 var initialSettings = _ref$initialSettings === void 0 ? {} : _ref$initialSettings;
7430 var _useState2 = _slicedToArray((0, react.useState)(predefinedPrompt), 2);
7431 var prompt = _useState2[0];
7432 var setPrompt = _useState2[1];
7433 var setGenerate = useRequestIds().setGenerate;
7434 var initialImageType = useGlobalSettings().initialImageType;
7435 var _usePromptSettings = usePromptSettings(_objectSpread$13({ type: initialImageType }, initialSettings));
7436 var settings = _usePromptSettings.settings;
7437 var updateSettings = _usePromptSettings.updateSettings;
7438 var resetSettings = _usePromptSettings.resetSettings;
7439 var _useSuggestedImages = useSuggestedImages({ selectedType: settings[IMAGE_TYPE] });
7440 var suggestedImages = _useSuggestedImages.imagesData;
7441 var isPreloading = _useSuggestedImages.isLoading;
7442 var promptPlaceholder = getPromptPlaceholder(suggestedImages);
7443 var _textToImageHook = textToImageHook({});
7444 var generatedImages = _textToImageHook.data;
7445 var setResult = _textToImageHook.setResult;
7446 var send = _textToImageHook.send;
7447 var isGenerating = _textToImageHook.isLoading;
7448 var error = _textToImageHook.error;
7449 var reset = _textToImageHook.reset;
7450 var _useImageActions = useImageActions();
7451 var use = _useImageActions.use;
7452 var edit = _useImageActions.edit;
7453 var isUploading = _useImageActions.isLoading;
7454 var isLoading = isPreloading || isGenerating || isUploading;
7455 var generateAspectRatio = (0, react.useMemo)(function() {
7456 return settings[IMAGE_RATIO];
7457 }, [generatedImages === null || generatedImages === void 0 ? void 0 : generatedImages.result]);
7458 var handleSubmit = function handleSubmit(event) {
7459 event.preventDefault();
7460 setGenerate();
7461 if (!settings[IMAGE_STYLE]) settings[IMAGE_STYLE] = "general";
7462 send({
7463 prompt,
7464 settings
7465 });
7466 };
7467 var handleCopyPrompt = function handleCopyPrompt(_ref2) {
7468 var selectedPrompt = _ref2.prompt;
7469 var imageType = _ref2.imageType;
7470 setPrompt(selectedPrompt);
7471 var _imageType$split2 = _slicedToArray(imageType.split("/"), 2);
7472 var type = _imageType$split2[0];
7473 var style = _imageType$split2[1];
7474 updateSettings(_defineProperty(_defineProperty({}, IMAGE_TYPE, type), IMAGE_STYLE, style));
7475 };
7476 useSubscribeOnPromptHistoryAction([{
7477 type: ACTION_TYPES.RESTORE,
7478 handler: function handler(action) {
7479 var _action$data;
7480 var _action$data2;
7481 var _action$data3;
7482 var _action$data4;
7483 handleCopyPrompt({
7484 prompt: (_action$data = action.data) === null || _action$data === void 0 ? void 0 : _action$data.prompt,
7485 imageType: ((_action$data2 = action.data) === null || _action$data2 === void 0 ? void 0 : _action$data2.imageType) || ""
7486 });
7487 updateSettings(_defineProperty({}, IMAGE_RATIO, (_action$data3 = action.data) === null || _action$data3 === void 0 ? void 0 : _action$data3.ratio));
7488 setResult((_action$data4 = action.data) === null || _action$data4 === void 0 ? void 0 : _action$data4.images, action.id);
7489 }
7490 }]);
7491 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
7492 primary: (0, _wordpress_i18n.__)("Imagine anything create everything", "elementor"),
7493 secondary: (0, _wordpress_i18n.__)("Generate images by selecting the desired type and style, and entering a prompt.", "elementor")
7494 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
7495 error,
7496 onRetry: handleSubmit
7497 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(PromptField, {
7498 "data-testid": "e-image-prompt",
7499 value: prompt,
7500 disabled: isLoading,
7501 placeholder: promptPlaceholder,
7502 onChange: setPrompt
7503 }), /*#__PURE__*/ react.default.createElement(ImageTypeSelect, {
7504 disabled: isLoading,
7505 value: settings[IMAGE_TYPE],
7506 onChange: function onChange(event) {
7507 return updateSettings(_defineProperty({}, IMAGE_TYPE, event.target.value));
7508 }
7509 }), /*#__PURE__*/ react.default.createElement(ImageStyleSelect, {
7510 type: settings[IMAGE_TYPE],
7511 value: settings[IMAGE_STYLE],
7512 disabled: isLoading || !settings[IMAGE_TYPE] || false,
7513 onChange: function onChange(event) {
7514 return updateSettings(_defineProperty({}, IMAGE_STYLE, event.target.value));
7515 }
7516 }), /*#__PURE__*/ react.default.createElement(ImageRatioSelect, {
7517 disabled: isLoading,
7518 value: settings[IMAGE_RATIO],
7519 onChange: function onChange(event) {
7520 return updateSettings(_defineProperty({}, IMAGE_RATIO, event.target.value));
7521 }
7522 }), generatedImages !== null && generatedImages !== void 0 && generatedImages.result ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
7523 gap: 2,
7524 sx: { my: 2.5 }
7525 }, /*#__PURE__*/ react.default.createElement(GenerateAgainSubmit, { disabled: isLoading || "" === prompt }), /*#__PURE__*/ react.default.createElement(NewPromptButton, {
7526 disabled: isLoading,
7527 onClick: function onClick() {
7528 resetSettings();
7529 setPrompt("");
7530 reset();
7531 }
7532 })) : /*#__PURE__*/ react.default.createElement(GenerateImagesSubmit, { disabled: isLoading || "" === prompt }))), /*#__PURE__*/ react.default.createElement(View.Content, {
7533 isLoading: isPreloading || isUploading,
7534 isGenerating
7535 }, generatedImages !== null && generatedImages !== void 0 && generatedImages.result ? /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
7536 images: generatedImages === null || generatedImages === void 0 ? void 0 : generatedImages.result,
7537 aspectRatio: generateAspectRatio,
7538 onUseImage: use,
7539 onEditImage: edit
7540 }) : /*#__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) {
7541 return /*#__PURE__*/ react.default.createElement(Gallery.Image, {
7542 variant: "thumbnail",
7543 key: suggestedPrompt.prompt,
7544 alt: suggestedPrompt.prompt,
7545 text: suggestedPrompt.prompt,
7546 src: suggestedPrompt.thumbnailUrl
7547 }, /*#__PURE__*/ react.default.createElement(ImageActions, null, /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, {
7548 onClick: function onClick() {
7549 return use(suggestedPrompt);
7550 },
7551 fullWidth: true
7552 }), /*#__PURE__*/ react.default.createElement(ImageActions.CopyIcon, { onClick: function onClick() {
7553 return handleCopyPrompt(suggestedPrompt);
7554 } }), /*#__PURE__*/ react.default.createElement(ImageActions.EditIcon, { onClick: function onClick() {
7555 return edit(suggestedPrompt);
7556 } })));
7557 }))))));
7558 };
7559 Generate.propTypes = {
7560 predefinedPrompt: import_prop_types$12.default.string,
7561 textToImageHook: import_prop_types$12.default.func,
7562 initialSettings: import_prop_types$12.default.object
7563 };
7564
7565 //#endregion
7566 //#region modules/ai/assets/js/editor/icons/expand-icon.js
7567 init_extends();
7568 var ExpandIcon$1 = react.default.forwardRef(function(props, ref) {
7569 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7570 fillRule: "evenodd",
7571 clipRule: "evenodd",
7572 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"
7573 }));
7574 });
7575
7576 //#endregion
7577 //#region modules/ai/assets/js/editor/icons/brush-icon.js
7578 init_extends();
7579 var BrushIcon = react.default.forwardRef(function(props, ref) {
7580 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7581 fillRule: "evenodd",
7582 clipRule: "evenodd",
7583 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"
7584 }));
7585 });
7586
7587 //#endregion
7588 //#region modules/ai/assets/js/editor/icons/evolve-icon.js
7589 init_extends();
7590 var EvolveIcon = react.default.forwardRef(function(props, ref) {
7591 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7592 fillRule: "evenodd",
7593 clipRule: "evenodd",
7594 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"
7595 }));
7596 });
7597
7598 //#endregion
7599 //#region modules/ai/assets/js/editor/icons/enlarger-icon.js
7600 init_extends();
7601 var ExpandIcon = react.default.forwardRef(function(props, ref) {
7602 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7603 fillRule: "evenodd",
7604 clipRule: "evenodd",
7605 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"
7606 }));
7607 });
7608
7609 //#endregion
7610 //#region modules/ai/assets/js/editor/icons/remove-bg.js
7611 init_extends();
7612 var RemoveBackgroundIcon = react.default.forwardRef(function(props, ref) {
7613 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" }));
7614 });
7615
7616 //#endregion
7617 //#region modules/ai/assets/js/editor/icons/replace-bg.js
7618 init_extends();
7619 var ReplaceBackgroundIcon = react.default.forwardRef(function(props, ref) {
7620 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" }));
7621 });
7622
7623 //#endregion
7624 //#region modules/ai/assets/js/editor/icons/cleanup-icon.js
7625 init_extends();
7626 var Cleanup$1 = react.default.forwardRef(function(props, ref) {
7627 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 16 16" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7628 fillRule: "evenodd",
7629 clipRule: "evenodd",
7630 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"
7631 }));
7632 });
7633
7634 //#endregion
7635 //#region modules/ai/assets/js/editor/icons/isolate-object-icon.js
7636 init_extends();
7637 var IsolateObjectIcon = react.default.forwardRef(function(props, ref) {
7638 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 16 16" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7639 fillRule: "evenodd",
7640 clipRule: "evenodd",
7641 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"
7642 }));
7643 });
7644
7645 //#endregion
7646 //#region modules/ai/assets/js/editor/pages/form-media/views/image-tools/image-tools-panel.js
7647 init_use_introduction();
7648 var TeaserDrawing = function TeaserDrawing() {
7649 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, {
7650 viewBox: "0 0 184 80",
7651 sx: {
7652 width: 184,
7653 height: 80
7654 }
7655 }, /*#__PURE__*/ react.default.createElement("g", { clipPath: "url(#clip0_3127_96542)" }, /*#__PURE__*/ react.default.createElement("path", {
7656 fillRule: "evenodd",
7657 clipRule: "evenodd",
7658 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",
7659 fill: "#69727D"
7660 }), /*#__PURE__*/ react.default.createElement("path", {
7661 fillRule: "evenodd",
7662 clipRule: "evenodd",
7663 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",
7664 fill: "#69727D"
7665 }), /*#__PURE__*/ react.default.createElement("path", {
7666 d: "M53.9717 12L57.2198 17.0456L3.24796 51.4731L-0.000164873 46.4275L53.9717 12Z",
7667 fill: "#69727D"
7668 }), /*#__PURE__*/ react.default.createElement("path", {
7669 d: "M64.9761 5L68.2242 10.0456L57.2612 17.0387L54.013 11.9931L64.9761 5Z",
7670 fill: "#E6E8EA"
7671 }), /*#__PURE__*/ react.default.createElement("path", {
7672 fillRule: "evenodd",
7673 clipRule: "evenodd",
7674 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",
7675 fill: "#69727D"
7676 }), /*#__PURE__*/ react.default.createElement("path", {
7677 fillRule: "evenodd",
7678 clipRule: "evenodd",
7679 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",
7680 fill: "#69727D"
7681 }), /*#__PURE__*/ react.default.createElement("path", {
7682 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",
7683 fill: "#E6E8EA"
7684 }), /*#__PURE__*/ react.default.createElement("path", {
7685 fillRule: "evenodd",
7686 clipRule: "evenodd",
7687 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",
7688 fill: "#69727D"
7689 }), /*#__PURE__*/ react.default.createElement("path", {
7690 fillRule: "evenodd",
7691 clipRule: "evenodd",
7692 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",
7693 fill: "#69727D"
7694 }), /*#__PURE__*/ react.default.createElement("path", {
7695 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",
7696 fill: "#E6E8EA"
7697 }), /*#__PURE__*/ react.default.createElement("path", {
7698 fillRule: "evenodd",
7699 clipRule: "evenodd",
7700 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",
7701 fill: "#69727D"
7702 }), /*#__PURE__*/ react.default.createElement("path", {
7703 fillRule: "evenodd",
7704 clipRule: "evenodd",
7705 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",
7706 fill: "#69727D"
7707 })), /*#__PURE__*/ react.default.createElement("defs", null, /*#__PURE__*/ react.default.createElement("clipPath", { id: "clip0_3127_96542" }, /*#__PURE__*/ react.default.createElement("rect", {
7708 width: "184",
7709 height: "80",
7710 fill: "white"
7711 }))));
7712 };
7713 var ImageToolsContainer = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref) {
7714 var theme = _ref.theme;
7715 return { height: "calc(100% - ".concat(theme.spacing(13), ")") };
7716 });
7717 var ToolsTeaserContainer = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref2) {
7718 return {
7719 position: "sticky",
7720 top: "100%",
7721 padding: _ref2.theme.spacing(4, 0, 1)
7722 };
7723 });
7724 var StyledChip = (0, _elementor_ui.styled)(_elementor_ui.Chip)(function() {
7725 return {
7726 position: "absolute",
7727 top: 8,
7728 right: 8,
7729 "& .MuiChip-label": {
7730 fontSize: "0.75rem",
7731 fontWeight: "normal"
7732 }
7733 };
7734 });
7735 var ImageToolsPanel = function ImageToolsPanel() {
7736 var navigate = useLocation().navigate;
7737 var _useIntroduction = useIntroduction("e-ai-image-isolate-tool");
7738 var isIsolateViewed = _useIntroduction.isViewed;
7739 var markIsolateAsViewed = _useIntroduction.markAsViewed;
7740 var tools = [
7741 {
7742 label: (0, _wordpress_i18n.__)("Expand Image", "elementor"),
7743 Icon: ExpandIcon$1,
7744 onClick: function onClick() {
7745 return navigate(LOCATIONS.OUT_PAINTING);
7746 }
7747 },
7748 {
7749 label: (0, _wordpress_i18n.__)("Generative Fill", "elementor"),
7750 Icon: BrushIcon,
7751 onClick: function onClick() {
7752 return navigate(LOCATIONS.IN_PAINTING);
7753 }
7754 },
7755 {
7756 label: (0, _wordpress_i18n.__)("Resize", "elementor"),
7757 Icon: ExpandIcon,
7758 onClick: function onClick() {
7759 return navigate(LOCATIONS.RESIZE);
7760 }
7761 },
7762 {
7763 label: (0, _wordpress_i18n.__)("Variations", "elementor"),
7764 Icon: EvolveIcon,
7765 onClick: function onClick() {
7766 return navigate(LOCATIONS.VARIATIONS);
7767 }
7768 },
7769 {
7770 label: (0, _wordpress_i18n.__)("Remove Background", "elementor"),
7771 Icon: RemoveBackgroundIcon,
7772 onClick: function onClick() {
7773 return navigate(LOCATIONS.REMOVE_BACKGROUND);
7774 }
7775 },
7776 {
7777 label: (0, _wordpress_i18n.__)("Replace Background", "elementor"),
7778 Icon: ReplaceBackgroundIcon,
7779 onClick: function onClick() {
7780 return navigate(LOCATIONS.REPLACE_BACKGROUND);
7781 }
7782 },
7783 {
7784 label: (0, _wordpress_i18n.__)("Cleanup", "elementor"),
7785 Icon: Cleanup$1,
7786 onClick: function onClick() {
7787 return navigate(LOCATIONS.CLEANUP);
7788 }
7789 },
7790 {
7791 label: (0, _wordpress_i18n.__)("Isolate object", "elementor"),
7792 Icon: IsolateObjectIcon,
7793 ChipParam: !isIsolateViewed ? /*#__PURE__*/ react.default.createElement(StyledChip, {
7794 label: "New",
7795 color: "info",
7796 variant: "standard",
7797 size: "tiny"
7798 }) : null,
7799 onClick: function onClick() {
7800 markIsolateAsViewed();
7801 navigate(LOCATIONS.ISOLATE_OBJECT);
7802 }
7803 }
7804 ];
7805 return /*#__PURE__*/ react.default.createElement(ImageToolsContainer, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7806 display: "grid",
7807 gridTemplateColumns: "repeat(2, 1fr)",
7808 gap: 1,
7809 justifyContent: "center"
7810 }, tools.map(function(_ref3) {
7811 var label = _ref3.label;
7812 var Icon = _ref3.Icon;
7813 var ChipParam = _ref3.ChipParam;
7814 var onClick = _ref3.onClick;
7815 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
7816 onClick,
7817 key: label,
7818 variant: "outlined",
7819 color: "secondary",
7820 disabled: false,
7821 sx: {
7822 py: 3,
7823 fontSize: "12px",
7824 height: "auto",
7825 borderRadius: "4px"
7826 }
7827 }, ChipParam, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7828 display: "flex",
7829 justifyContent: "center",
7830 alignItems: "center",
7831 flexDirection: "column"
7832 }, /*#__PURE__*/ react.default.createElement(Icon, { sx: { mb: .5 } }), label));
7833 })), /*#__PURE__*/ react.default.createElement(ToolsTeaserContainer, {
7834 display: "flex",
7835 flexDirection: "column",
7836 alignItems: "center"
7837 }, /*#__PURE__*/ react.default.createElement(TeaserDrawing, null), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
7838 variant: "body2",
7839 align: "center",
7840 color: "secondary",
7841 sx: { mt: 2 }
7842 }, (0, _wordpress_i18n.__)("Stay tuned! More incredible AI tools are coming your way soon.", "elementor"))));
7843 };
7844 ImageToolsPanel.propTypes = {
7845 generateNewPrompt: import_prop_types$12.default.func,
7846 panelActive: import_prop_types$12.default.bool
7847 };
7848
7849 //#endregion
7850 //#region modules/ai/assets/js/editor/pages/form-media/views/image-tools/image-tools-content.js
7851 var ImageToolsContent = function ImageToolsContent() {
7852 var _useEditImage = useEditImage();
7853 var editImage = _useEditImage.editImage;
7854 var width = _useEditImage.width;
7855 var height = _useEditImage.height;
7856 var use = useImageActions().use;
7857 return /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
7858 src: editImage.url,
7859 style: {
7860 width,
7861 height
7862 },
7863 alt: editImage.alt || (0, _wordpress_i18n.__)("Image preview", "elementor")
7864 }, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Actions, null, /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, { onClick: function onClick() {
7865 return use(editImage);
7866 } }))));
7867 };
7868
7869 //#endregion
7870 //#region modules/ai/assets/js/editor/pages/form-media/views/image-tools/index.js
7871 var ImageTools = function ImageTools() {
7872 var navigate = useLocation().navigate;
7873 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, { onClick: function onClick() {
7874 return navigate(LOCATIONS.GENERATE);
7875 } }, (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)));
7876 };
7877
7878 //#endregion
7879 //#region modules/ai/assets/js/editor/pages/form-media/components/generate-submit.js
7880 init_extends();
7881 var GenerateSubmit = function GenerateSubmit(props) {
7882 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
7883 fullWidth: true,
7884 size: "medium",
7885 type: "submit",
7886 variant: "contained"
7887 }, props), props.children || (0, _wordpress_i18n.__)("Generate", "elementor"));
7888 };
7889 GenerateSubmit.propTypes = { children: import_prop_types$12.default.node };
7890
7891 //#endregion
7892 //#region modules/ai/assets/js/editor/pages/form-media/hooks/use-image-prompt.js
7893 init_use_prompt();
7894 var useImagePrompt = function useImagePrompt() {
7895 var promptData = usePrompt.apply(void 0, arguments);
7896 var _useGlobalActions = useGlobalActions();
7897 var setHasUnsavedChanges = _useGlobalActions.setHasUnsavedChanges;
7898 var state = _useGlobalActions.state;
7899 (0, react.useEffect)(function() {
7900 var _promptData$data;
7901 if ((_promptData$data = promptData.data) !== null && _promptData$data !== void 0 && _promptData$data.result) setHasUnsavedChanges(true);
7902 }, [promptData.data]);
7903 (0, react.useEffect)(function() {
7904 if (state.isAllSaved) promptData.sendUsageData();
7905 }, [state.isAllSaved]);
7906 return promptData;
7907 };
7908
7909 //#endregion
7910 //#region modules/ai/assets/js/editor/pages/form-media/views/resize/hooks/use-resize.js
7911 init_api();
7912 var useResize = function useResize(initialValue) {
7913 return useImagePrompt(function fetchAction(payload) {
7914 return getImageToImageUpscale(payload);
7915 }, initialValue);
7916 };
7917
7918 //#endregion
7919 //#region modules/ai/assets/js/editor/pages/form-media/views/resize/index.js
7920 init_defineProperty();
7921 init_requests_ids();
7922 var Resize = function Resize() {
7923 var _useEditImage = useEditImage();
7924 var editImage = _useEditImage.editImage;
7925 var initialEditImageWidth = _useEditImage.width;
7926 var setGenerate = useRequestIds().setGenerate;
7927 var _useImageActions = useImageActions();
7928 var use = _useImageActions.use;
7929 var edit = _useImageActions.edit;
7930 var isUploading = _useImageActions.isLoading;
7931 var _usePromptSettings = usePromptSettings();
7932 var settings = _usePromptSettings.settings;
7933 var updateSettings = _usePromptSettings.updateSettings;
7934 var _useResize = useResize();
7935 var data = _useResize.data;
7936 var send = _useResize.send;
7937 var isGenerating = _useResize.isLoading;
7938 var error = _useResize.error;
7939 var isLoading = isGenerating || isUploading;
7940 var handleSubmit = function handleSubmit(event) {
7941 event.preventDefault();
7942 setGenerate();
7943 send({
7944 promptSettings: settings,
7945 image: editImage
7946 });
7947 };
7948 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, {
7949 primary: (0, _wordpress_i18n.__)("Resize", "elementor"),
7950 secondary: (0, _wordpress_i18n.__)("Make an image larger and improve it’s resolution.", "elementor")
7951 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
7952 error,
7953 onRetry: handleSubmit
7954 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, { spacing: .2 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7955 display: "flex",
7956 justifyContent: "space-between",
7957 alignItems: "center"
7958 }, /*#__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, {
7959 marks: true,
7960 step: 64,
7961 min: 512,
7962 max: 2048,
7963 id: "upscale_to",
7964 color: "secondary",
7965 name: "upscale_to",
7966 disabled: isLoading,
7967 defaultValue: initialEditImageWidth,
7968 valueLabelDisplay: "auto",
7969 "aria-label": (0, _wordpress_i18n.__)("Upscale to", "elementor"),
7970 onChange: function onChange(_, value) {
7971 return updateSettings(_defineProperty({}, IMAGE_UPSCALE, value));
7972 }
7973 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7974 display: "flex",
7975 justifyContent: "space-between",
7976 alignItems: "center"
7977 }, /*#__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, {
7978 onUseImage: use,
7979 onEditImage: edit,
7980 images: data.result,
7981 aspectRatio: editImage.aspectRatio
7982 }) : /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
7983 src: editImage.url,
7984 alt: editImage.alt,
7985 style: {
7986 width: editImage.width,
7987 height: editImage.height
7988 }
7989 }))));
7990 };
7991
7992 //#endregion
7993 //#region node_modules/react-sketch-canvas/dist/react-sketch-canvas.esm.js
7994 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
7995 try {
7996 var info = gen[key](arg);
7997 var value = info.value;
7998 } catch (error) {
7999 reject(error);
8000 return;
8001 }
8002 if (info.done) resolve(value);
8003 else Promise.resolve(value).then(_next, _throw);
8004 }
8005 function _asyncToGenerator(fn) {
8006 return function() {
8007 var self = this;
8008 var args = arguments;
8009 return new Promise(function(resolve, reject) {
8010 var gen = fn.apply(self, args);
8011 function _next(value) {
8012 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
8013 }
8014 function _throw(err) {
8015 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
8016 }
8017 _next(void 0);
8018 });
8019 };
8020 }
8021 function _extends() {
8022 _extends = Object.assign || function(target) {
8023 for (var i = 1; i < arguments.length; i++) {
8024 var source = arguments[i];
8025 for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
8026 }
8027 return target;
8028 };
8029 return _extends.apply(this, arguments);
8030 }
8031 var runtime = { exports: {} };
8032 /**
8033 * Copyright (c) 2014-present, Facebook, Inc.
8034 *
8035 * This source code is licensed under the MIT license found in the
8036 * LICENSE file in the root directory of this source tree.
8037 */
8038 (function(module) {
8039 var runtime = function(exports) {
8040 var Op = Object.prototype;
8041 var hasOwn = Op.hasOwnProperty;
8042 var undefined$1;
8043 var $Symbol = typeof Symbol === "function" ? Symbol : {};
8044 var iteratorSymbol = $Symbol.iterator || "@@iterator";
8045 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
8046 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
8047 function define(obj, key, value) {
8048 Object.defineProperty(obj, key, {
8049 value,
8050 enumerable: true,
8051 configurable: true,
8052 writable: true
8053 });
8054 return obj[key];
8055 }
8056 try {
8057 define({}, "");
8058 } catch (err) {
8059 define = function(obj, key, value) {
8060 return obj[key] = value;
8061 };
8062 }
8063 function wrap(innerFn, outerFn, self, tryLocsList) {
8064 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
8065 var generator = Object.create(protoGenerator.prototype);
8066 generator._invoke = makeInvokeMethod(innerFn, self, new Context(tryLocsList || []));
8067 return generator;
8068 }
8069 exports.wrap = wrap;
8070 function tryCatch(fn, obj, arg) {
8071 try {
8072 return {
8073 type: "normal",
8074 arg: fn.call(obj, arg)
8075 };
8076 } catch (err) {
8077 return {
8078 type: "throw",
8079 arg: err
8080 };
8081 }
8082 }
8083 var GenStateSuspendedStart = "suspendedStart";
8084 var GenStateSuspendedYield = "suspendedYield";
8085 var GenStateExecuting = "executing";
8086 var GenStateCompleted = "completed";
8087 var ContinueSentinel = {};
8088 function Generator() {}
8089 function GeneratorFunction() {}
8090 function GeneratorFunctionPrototype() {}
8091 var IteratorPrototype = {};
8092 define(IteratorPrototype, iteratorSymbol, function() {
8093 return this;
8094 });
8095 var getProto = Object.getPrototypeOf;
8096 var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
8097 if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) IteratorPrototype = NativeIteratorPrototype;
8098 var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
8099 GeneratorFunction.prototype = GeneratorFunctionPrototype;
8100 define(Gp, "constructor", GeneratorFunctionPrototype);
8101 define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
8102 GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
8103 function defineIteratorMethods(prototype) {
8104 [
8105 "next",
8106 "throw",
8107 "return"
8108 ].forEach(function(method) {
8109 define(prototype, method, function(arg) {
8110 return this._invoke(method, arg);
8111 });
8112 });
8113 }
8114 exports.isGeneratorFunction = function(genFun) {
8115 var ctor = typeof genFun === "function" && genFun.constructor;
8116 return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
8117 };
8118 exports.mark = function(genFun) {
8119 if (Object.setPrototypeOf) Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
8120 else {
8121 genFun.__proto__ = GeneratorFunctionPrototype;
8122 define(genFun, toStringTagSymbol, "GeneratorFunction");
8123 }
8124 genFun.prototype = Object.create(Gp);
8125 return genFun;
8126 };
8127 exports.awrap = function(arg) {
8128 return { __await: arg };
8129 };
8130 function AsyncIterator(generator, PromiseImpl) {
8131 function invoke(method, arg, resolve, reject) {
8132 var record = tryCatch(generator[method], generator, arg);
8133 if (record.type === "throw") reject(record.arg);
8134 else {
8135 var result = record.arg;
8136 var value = result.value;
8137 if (value && typeof value === "object" && hasOwn.call(value, "__await")) return PromiseImpl.resolve(value.__await).then(function(value) {
8138 invoke("next", value, resolve, reject);
8139 }, function(err) {
8140 invoke("throw", err, resolve, reject);
8141 });
8142 return PromiseImpl.resolve(value).then(function(unwrapped) {
8143 result.value = unwrapped;
8144 resolve(result);
8145 }, function(error) {
8146 return invoke("throw", error, resolve, reject);
8147 });
8148 }
8149 }
8150 var previousPromise;
8151 function enqueue(method, arg) {
8152 function callInvokeWithMethodAndArg() {
8153 return new PromiseImpl(function(resolve, reject) {
8154 invoke(method, arg, resolve, reject);
8155 });
8156 }
8157 return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
8158 }
8159 this._invoke = enqueue;
8160 }
8161 defineIteratorMethods(AsyncIterator.prototype);
8162 define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
8163 return this;
8164 });
8165 exports.AsyncIterator = AsyncIterator;
8166 exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
8167 if (PromiseImpl === void 0) PromiseImpl = Promise;
8168 var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
8169 return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
8170 return result.done ? result.value : iter.next();
8171 });
8172 };
8173 function makeInvokeMethod(innerFn, self, context) {
8174 var state = GenStateSuspendedStart;
8175 return function invoke(method, arg) {
8176 if (state === GenStateExecuting) throw new Error("Generator is already running");
8177 if (state === GenStateCompleted) {
8178 if (method === "throw") throw arg;
8179 return doneResult();
8180 }
8181 context.method = method;
8182 context.arg = arg;
8183 while (true) {
8184 var delegate = context.delegate;
8185 if (delegate) {
8186 var delegateResult = maybeInvokeDelegate(delegate, context);
8187 if (delegateResult) {
8188 if (delegateResult === ContinueSentinel) continue;
8189 return delegateResult;
8190 }
8191 }
8192 if (context.method === "next") context.sent = context._sent = context.arg;
8193 else if (context.method === "throw") {
8194 if (state === GenStateSuspendedStart) {
8195 state = GenStateCompleted;
8196 throw context.arg;
8197 }
8198 context.dispatchException(context.arg);
8199 } else if (context.method === "return") context.abrupt("return", context.arg);
8200 state = GenStateExecuting;
8201 var record = tryCatch(innerFn, self, context);
8202 if (record.type === "normal") {
8203 state = context.done ? GenStateCompleted : GenStateSuspendedYield;
8204 if (record.arg === ContinueSentinel) continue;
8205 return {
8206 value: record.arg,
8207 done: context.done
8208 };
8209 } else if (record.type === "throw") {
8210 state = GenStateCompleted;
8211 context.method = "throw";
8212 context.arg = record.arg;
8213 }
8214 }
8215 };
8216 }
8217 function maybeInvokeDelegate(delegate, context) {
8218 var method = delegate.iterator[context.method];
8219 if (method === undefined$1) {
8220 context.delegate = null;
8221 if (context.method === "throw") {
8222 if (delegate.iterator["return"]) {
8223 context.method = "return";
8224 context.arg = undefined$1;
8225 maybeInvokeDelegate(delegate, context);
8226 if (context.method === "throw") return ContinueSentinel;
8227 }
8228 context.method = "throw";
8229 context.arg = /* @__PURE__ */ new TypeError("The iterator does not provide a 'throw' method");
8230 }
8231 return ContinueSentinel;
8232 }
8233 var record = tryCatch(method, delegate.iterator, context.arg);
8234 if (record.type === "throw") {
8235 context.method = "throw";
8236 context.arg = record.arg;
8237 context.delegate = null;
8238 return ContinueSentinel;
8239 }
8240 var info = record.arg;
8241 if (!info) {
8242 context.method = "throw";
8243 context.arg = /* @__PURE__ */ new TypeError("iterator result is not an object");
8244 context.delegate = null;
8245 return ContinueSentinel;
8246 }
8247 if (info.done) {
8248 context[delegate.resultName] = info.value;
8249 context.next = delegate.nextLoc;
8250 if (context.method !== "return") {
8251 context.method = "next";
8252 context.arg = undefined$1;
8253 }
8254 } else return info;
8255 context.delegate = null;
8256 return ContinueSentinel;
8257 }
8258 defineIteratorMethods(Gp);
8259 define(Gp, toStringTagSymbol, "Generator");
8260 define(Gp, iteratorSymbol, function() {
8261 return this;
8262 });
8263 define(Gp, "toString", function() {
8264 return "[object Generator]";
8265 });
8266 function pushTryEntry(locs) {
8267 var entry = { tryLoc: locs[0] };
8268 if (1 in locs) entry.catchLoc = locs[1];
8269 if (2 in locs) {
8270 entry.finallyLoc = locs[2];
8271 entry.afterLoc = locs[3];
8272 }
8273 this.tryEntries.push(entry);
8274 }
8275 function resetTryEntry(entry) {
8276 var record = entry.completion || {};
8277 record.type = "normal";
8278 delete record.arg;
8279 entry.completion = record;
8280 }
8281 function Context(tryLocsList) {
8282 this.tryEntries = [{ tryLoc: "root" }];
8283 tryLocsList.forEach(pushTryEntry, this);
8284 this.reset(true);
8285 }
8286 exports.keys = function(object) {
8287 var keys = [];
8288 for (var key in object) keys.push(key);
8289 keys.reverse();
8290 return function next() {
8291 while (keys.length) {
8292 var key = keys.pop();
8293 if (key in object) {
8294 next.value = key;
8295 next.done = false;
8296 return next;
8297 }
8298 }
8299 next.done = true;
8300 return next;
8301 };
8302 };
8303 function values(iterable) {
8304 if (iterable) {
8305 var iteratorMethod = iterable[iteratorSymbol];
8306 if (iteratorMethod) return iteratorMethod.call(iterable);
8307 if (typeof iterable.next === "function") return iterable;
8308 if (!isNaN(iterable.length)) {
8309 var i = -1;
8310 var next = function next() {
8311 while (++i < iterable.length) if (hasOwn.call(iterable, i)) {
8312 next.value = iterable[i];
8313 next.done = false;
8314 return next;
8315 }
8316 next.value = undefined$1;
8317 next.done = true;
8318 return next;
8319 };
8320 return next.next = next;
8321 }
8322 }
8323 return { next: doneResult };
8324 }
8325 exports.values = values;
8326 function doneResult() {
8327 return {
8328 value: undefined$1,
8329 done: true
8330 };
8331 }
8332 Context.prototype = {
8333 constructor: Context,
8334 reset: function(skipTempReset) {
8335 this.prev = 0;
8336 this.next = 0;
8337 this.sent = this._sent = undefined$1;
8338 this.done = false;
8339 this.delegate = null;
8340 this.method = "next";
8341 this.arg = undefined$1;
8342 this.tryEntries.forEach(resetTryEntry);
8343 if (!skipTempReset) {
8344 for (var name in this) if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) this[name] = undefined$1;
8345 }
8346 },
8347 stop: function() {
8348 this.done = true;
8349 var rootRecord = this.tryEntries[0].completion;
8350 if (rootRecord.type === "throw") throw rootRecord.arg;
8351 return this.rval;
8352 },
8353 dispatchException: function(exception) {
8354 if (this.done) throw exception;
8355 var context = this;
8356 function handle(loc, caught) {
8357 record.type = "throw";
8358 record.arg = exception;
8359 context.next = loc;
8360 if (caught) {
8361 context.method = "next";
8362 context.arg = undefined$1;
8363 }
8364 return !!caught;
8365 }
8366 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
8367 var entry = this.tryEntries[i];
8368 var record = entry.completion;
8369 if (entry.tryLoc === "root") return handle("end");
8370 if (entry.tryLoc <= this.prev) {
8371 var hasCatch = hasOwn.call(entry, "catchLoc");
8372 var hasFinally = hasOwn.call(entry, "finallyLoc");
8373 if (hasCatch && hasFinally) {
8374 if (this.prev < entry.catchLoc) return handle(entry.catchLoc, true);
8375 else if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
8376 } else if (hasCatch) {
8377 if (this.prev < entry.catchLoc) return handle(entry.catchLoc, true);
8378 } else if (hasFinally) {
8379 if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
8380 } else throw new Error("try statement without catch or finally");
8381 }
8382 }
8383 },
8384 abrupt: function(type, arg) {
8385 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
8386 var entry = this.tryEntries[i];
8387 if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
8388 var finallyEntry = entry;
8389 break;
8390 }
8391 }
8392 if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) finallyEntry = null;
8393 var record = finallyEntry ? finallyEntry.completion : {};
8394 record.type = type;
8395 record.arg = arg;
8396 if (finallyEntry) {
8397 this.method = "next";
8398 this.next = finallyEntry.finallyLoc;
8399 return ContinueSentinel;
8400 }
8401 return this.complete(record);
8402 },
8403 complete: function(record, afterLoc) {
8404 if (record.type === "throw") throw record.arg;
8405 if (record.type === "break" || record.type === "continue") this.next = record.arg;
8406 else if (record.type === "return") {
8407 this.rval = this.arg = record.arg;
8408 this.method = "return";
8409 this.next = "end";
8410 } else if (record.type === "normal" && afterLoc) this.next = afterLoc;
8411 return ContinueSentinel;
8412 },
8413 finish: function(finallyLoc) {
8414 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
8415 var entry = this.tryEntries[i];
8416 if (entry.finallyLoc === finallyLoc) {
8417 this.complete(entry.completion, entry.afterLoc);
8418 resetTryEntry(entry);
8419 return ContinueSentinel;
8420 }
8421 }
8422 },
8423 "catch": function(tryLoc) {
8424 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
8425 var entry = this.tryEntries[i];
8426 if (entry.tryLoc === tryLoc) {
8427 var record = entry.completion;
8428 if (record.type === "throw") {
8429 var thrown = record.arg;
8430 resetTryEntry(entry);
8431 }
8432 return thrown;
8433 }
8434 }
8435 throw new Error("illegal catch attempt");
8436 },
8437 delegateYield: function(iterable, resultName, nextLoc) {
8438 this.delegate = {
8439 iterator: values(iterable),
8440 resultName,
8441 nextLoc
8442 };
8443 if (this.method === "next") this.arg = undefined$1;
8444 return ContinueSentinel;
8445 }
8446 };
8447 return exports;
8448 }(module.exports);
8449 try {
8450 regeneratorRuntime = runtime;
8451 } catch (accidentalStrictMode) {
8452 if (typeof globalThis === "object") globalThis.regeneratorRuntime = runtime;
8453 else Function("r", "regeneratorRuntime = r")(runtime);
8454 }
8455 })(runtime);
8456 var _regeneratorRuntime$21 = runtime.exports;
8457 /**
8458 * Generate SVG Path tag from the given points
8459 */
8460 var SvgPath = function SvgPath(_ref) {
8461 var paths = _ref.paths;
8462 var id = _ref.id;
8463 var strokeWidth = _ref.strokeWidth;
8464 var strokeColor = _ref.strokeColor;
8465 var _ref$command = _ref.command;
8466 var command = _ref$command === void 0 ? bezierCommand : _ref$command;
8467 if (paths.length === 1) {
8468 var _paths$ = paths[0];
8469 var x = _paths$.x;
8470 var y = _paths$.y;
8471 var radius = strokeWidth / 2;
8472 return react.createElement("circle", {
8473 key: id,
8474 id,
8475 cx: x,
8476 cy: y,
8477 r: radius,
8478 stroke: strokeColor,
8479 fill: strokeColor
8480 });
8481 }
8482 var d = paths.reduce(function(acc, point, i, a) {
8483 return i === 0 ? "M " + point.x + "," + point.y : acc + " " + command(point, i, a);
8484 }, "");
8485 return react.createElement("path", {
8486 key: id,
8487 id,
8488 d,
8489 fill: "none",
8490 strokeLinecap: "round",
8491 stroke: strokeColor,
8492 strokeWidth
8493 });
8494 };
8495 var line = function line(pointA, pointB) {
8496 var lengthX = pointB.x - pointA.x;
8497 var lengthY = pointB.y - pointA.y;
8498 return {
8499 length: Math.sqrt(Math.pow(lengthX, 2) + Math.pow(lengthY, 2)),
8500 angle: Math.atan2(lengthY, lengthX)
8501 };
8502 };
8503 var controlPoint = function controlPoint(controlPoints) {
8504 var current = controlPoints.current;
8505 var next = controlPoints.next;
8506 var previous = controlPoints.previous;
8507 var reverse = controlPoints.reverse;
8508 var p = previous || current;
8509 var n = next || current;
8510 var smoothing = .2;
8511 var o = line(p, n);
8512 var angle = o.angle + (reverse ? Math.PI : 0);
8513 var length = o.length * smoothing;
8514 return [current.x + Math.cos(angle) * length, current.y + Math.sin(angle) * length];
8515 };
8516 var bezierCommand = function bezierCommand(point, i, a) {
8517 var cpsX = null;
8518 var cpsY = null;
8519 switch (i) {
8520 case 0:
8521 var _controlPoint = controlPoint({ current: point });
8522 cpsX = _controlPoint[0];
8523 cpsY = _controlPoint[1];
8524 break;
8525 case 1:
8526 var _controlPoint2 = controlPoint({
8527 current: a[i - 1],
8528 next: point
8529 });
8530 cpsX = _controlPoint2[0];
8531 cpsY = _controlPoint2[1];
8532 break;
8533 default:
8534 var _controlPoint3 = controlPoint({
8535 current: a[i - 1],
8536 previous: a[i - 2],
8537 next: point
8538 });
8539 cpsX = _controlPoint3[0];
8540 cpsY = _controlPoint3[1];
8541 break;
8542 }
8543 var _controlPoint4 = controlPoint({
8544 current: point,
8545 previous: a[i - 1],
8546 next: a[i + 1],
8547 reverse: true
8548 });
8549 var cpeX = _controlPoint4[0];
8550 var cpeY = _controlPoint4[1];
8551 return "C " + cpsX + "," + cpsY + " " + cpeX + "," + cpeY + " " + point.x + ", " + point.y;
8552 };
8553 var Paths = function Paths(_ref2) {
8554 var id = _ref2.id;
8555 var paths = _ref2.paths;
8556 return react.createElement(react.Fragment, null, paths.map(function(path, index) {
8557 return react.createElement(SvgPath, {
8558 key: id + "__" + index,
8559 paths: path.paths,
8560 id: id + "__" + index,
8561 strokeWidth: path.strokeWidth,
8562 strokeColor: path.strokeColor,
8563 command: bezierCommand
8564 });
8565 }));
8566 };
8567 var loadImage = function loadImage(url) {
8568 return new Promise(function(resolve, reject) {
8569 var img = new Image();
8570 img.addEventListener("load", function() {
8571 if (img.width > 0) resolve(img);
8572 reject("Image not found");
8573 });
8574 img.addEventListener("error", function(err) {
8575 return reject(err);
8576 });
8577 img.src = url;
8578 img.setAttribute("crossorigin", "anonymous");
8579 });
8580 };
8581 function getCanvasWithViewBox(canvas) {
8582 var _canvas$firstChild;
8583 var svgCanvas = (_canvas$firstChild = canvas.firstChild) == null ? void 0 : _canvas$firstChild.cloneNode(true);
8584 var width = canvas.offsetWidth;
8585 var height = canvas.offsetHeight;
8586 svgCanvas.setAttribute("viewBox", "0 0 " + width + " " + height);
8587 svgCanvas.setAttribute("width", width.toString());
8588 svgCanvas.setAttribute("height", height.toString());
8589 return {
8590 svgCanvas,
8591 width,
8592 height
8593 };
8594 }
8595 var Canvas = /*#__PURE__*/ react.forwardRef(function(props, ref) {
8596 var paths = props.paths;
8597 var isDrawing = props.isDrawing;
8598 var onPointerDown = props.onPointerDown;
8599 var onPointerMove = props.onPointerMove;
8600 var onPointerUp = props.onPointerUp;
8601 var _props$id = props.id;
8602 var id = _props$id === void 0 ? "react-sketch-canvas" : _props$id;
8603 var _props$width = props.width;
8604 var width = _props$width === void 0 ? "100%" : _props$width;
8605 var _props$height = props.height;
8606 var height = _props$height === void 0 ? "100%" : _props$height;
8607 var _props$className = props.className;
8608 var className = _props$className === void 0 ? "react-sketch-canvas" : _props$className;
8609 var _props$canvasColor = props.canvasColor;
8610 var canvasColor = _props$canvasColor === void 0 ? "red" : _props$canvasColor;
8611 var _props$backgroundImag = props.backgroundImage;
8612 var backgroundImage = _props$backgroundImag === void 0 ? "" : _props$backgroundImag;
8613 var _props$exportWithBack = props.exportWithBackgroundImage;
8614 var exportWithBackgroundImage = _props$exportWithBack === void 0 ? false : _props$exportWithBack;
8615 var _props$preserveBackgr = props.preserveBackgroundImageAspectRatio;
8616 var preserveBackgroundImageAspectRatio = _props$preserveBackgr === void 0 ? "none" : _props$preserveBackgr;
8617 var _props$allowOnlyPoint = props.allowOnlyPointerType;
8618 var allowOnlyPointerType = _props$allowOnlyPoint === void 0 ? "all" : _props$allowOnlyPoint;
8619 var _props$style = props.style;
8620 var style = _props$style === void 0 ? {
8621 border: "0.0625rem solid #9c9c9c",
8622 borderRadius: "0.25rem"
8623 } : _props$style;
8624 var _props$svgStyle = props.svgStyle;
8625 var svgStyle = _props$svgStyle === void 0 ? {} : _props$svgStyle;
8626 var canvasRef = react.useRef(null);
8627 var getCoordinates = function getCoordinates(pointerEvent) {
8628 var _canvasRef$current;
8629 var _window$scrollX;
8630 var _window$scrollY;
8631 var boundingArea = (_canvasRef$current = canvasRef.current) == null ? void 0 : _canvasRef$current.getBoundingClientRect();
8632 var scrollLeft = (_window$scrollX = window.scrollX) != null ? _window$scrollX : 0;
8633 var scrollTop = (_window$scrollY = window.scrollY) != null ? _window$scrollY : 0;
8634 if (!boundingArea) return {
8635 x: 0,
8636 y: 0
8637 };
8638 return {
8639 x: pointerEvent.pageX - boundingArea.left - scrollLeft,
8640 y: pointerEvent.pageY - boundingArea.top - scrollTop
8641 };
8642 };
8643 var handlePointerDown = function handlePointerDown(event) {
8644 if (allowOnlyPointerType !== "all" && event.pointerType !== allowOnlyPointerType) return;
8645 if (event.pointerType === "mouse" && event.button !== 0) return;
8646 onPointerDown(getCoordinates(event));
8647 };
8648 var handlePointerMove = function handlePointerMove(event) {
8649 if (!isDrawing) return;
8650 if (allowOnlyPointerType !== "all" && event.pointerType !== allowOnlyPointerType) return;
8651 onPointerMove(getCoordinates(event));
8652 };
8653 var handlePointerUp = function handlePointerUp(event) {
8654 if (event.pointerType === "mouse" && event.button !== 0) return;
8655 if (allowOnlyPointerType !== "all" && event.pointerType !== allowOnlyPointerType) return;
8656 onPointerUp();
8657 };
8658 react.useImperativeHandle(ref, function() {
8659 return {
8660 exportImage: function exportImage(imageType) {
8661 return new Promise(/*#__PURE__*/ function() {
8662 var _ref = _asyncToGenerator(/*#__PURE__*/ _regeneratorRuntime$21.mark(function _callee(resolve, reject) {
8663 var canvas;
8664 var _getCanvasWithViewBox;
8665 var svgCanvas;
8666 var _width;
8667 var _height;
8668 var canvasSketch;
8669 var loadImagePromises;
8670 var img;
8671 return _regeneratorRuntime$21.wrap(function _callee$(_context) {
8672 while (1) switch (_context.prev = _context.next) {
8673 case 0:
8674 _context.prev = 0;
8675 canvas = canvasRef.current;
8676 if (canvas) {
8677 _context.next = 4;
8678 break;
8679 }
8680 throw Error("Canvas not rendered yet");
8681 case 4:
8682 _getCanvasWithViewBox = getCanvasWithViewBox(canvas), svgCanvas = _getCanvasWithViewBox.svgCanvas, _width = _getCanvasWithViewBox.width, _height = _getCanvasWithViewBox.height;
8683 canvasSketch = "data:image/svg+xml;base64," + btoa(svgCanvas.outerHTML);
8684 _context.next = 8;
8685 return loadImage(canvasSketch);
8686 case 8:
8687 _context.t0 = _context.sent;
8688 loadImagePromises = [_context.t0];
8689 if (!exportWithBackgroundImage) {
8690 _context.next = 21;
8691 break;
8692 }
8693 _context.prev = 11;
8694 _context.next = 14;
8695 return loadImage(backgroundImage);
8696 case 14:
8697 img = _context.sent;
8698 loadImagePromises.push(img);
8699 _context.next = 21;
8700 break;
8701 case 18:
8702 _context.prev = 18;
8703 _context.t1 = _context["catch"](11);
8704 console.warn("exportWithBackgroundImage props is set without a valid background image URL. This option is ignored");
8705 case 21:
8706 Promise.all(loadImagePromises).then(function(images) {
8707 var renderCanvas = document.createElement("canvas");
8708 renderCanvas.setAttribute("width", _width.toString());
8709 renderCanvas.setAttribute("height", _height.toString());
8710 var context = renderCanvas.getContext("2d");
8711 if (!context) throw Error("Canvas not rendered yet");
8712 images.reverse().forEach(function(image) {
8713 context.drawImage(image, 0, 0);
8714 });
8715 resolve(renderCanvas.toDataURL("image/" + imageType));
8716 })["catch"](function(e) {
8717 throw e;
8718 });
8719 _context.next = 27;
8720 break;
8721 case 24:
8722 _context.prev = 24;
8723 _context.t2 = _context["catch"](0);
8724 reject(_context.t2);
8725 case 27:
8726 case "end": return _context.stop();
8727 }
8728 }, _callee, null, [[0, 24], [11, 18]]);
8729 }));
8730 return function(_x, _x2) {
8731 return _ref.apply(this, arguments);
8732 };
8733 }());
8734 },
8735 exportSvg: function exportSvg() {
8736 return new Promise(function(resolve, reject) {
8737 try {
8738 var _canvasRef$current2;
8739 var canvas = (_canvasRef$current2 = canvasRef.current) != null ? _canvasRef$current2 : null;
8740 if (canvas !== null) {
8741 var _svgCanvas$querySelec;
8742 var _svgCanvas$querySelec2;
8743 var svgCanvas = getCanvasWithViewBox(canvas).svgCanvas;
8744 if (exportWithBackgroundImage) {
8745 resolve(svgCanvas.outerHTML);
8746 return;
8747 }
8748 (_svgCanvas$querySelec = svgCanvas.querySelector("#" + id + "__background")) == null || _svgCanvas$querySelec.remove();
8749 (_svgCanvas$querySelec2 = svgCanvas.querySelector("#" + id + "__canvas-background")) == null || _svgCanvas$querySelec2.setAttribute("fill", canvasColor);
8750 resolve(svgCanvas.outerHTML);
8751 }
8752 reject(/* @__PURE__ */ new Error("Canvas not loaded"));
8753 } catch (e) {
8754 reject(e);
8755 }
8756 });
8757 }
8758 };
8759 });
8760 react.useEffect(function() {
8761 document.addEventListener("pointerup", handlePointerUp);
8762 return function() {
8763 document.removeEventListener("pointerup", handlePointerUp);
8764 };
8765 }, [handlePointerUp]);
8766 var eraserPaths = paths.filter(function(path) {
8767 return !path.drawMode;
8768 });
8769 var currentGroup = 0;
8770 var pathGroups = paths.reduce(function(arrayGroup, path) {
8771 if (!path.drawMode) {
8772 currentGroup += 1;
8773 return arrayGroup;
8774 }
8775 if (arrayGroup[currentGroup] === void 0) arrayGroup[currentGroup] = [];
8776 arrayGroup[currentGroup].push(path);
8777 return arrayGroup;
8778 }, [[]]);
8779 return react.createElement("div", {
8780 role: "presentation",
8781 ref: canvasRef,
8782 className,
8783 style: _extends({
8784 touchAction: "none",
8785 width,
8786 height
8787 }, style),
8788 "touch-action": "none",
8789 onPointerDown: handlePointerDown,
8790 onPointerMove: handlePointerMove,
8791 onPointerUp: handlePointerUp
8792 }, react.createElement("svg", {
8793 version: "1.1",
8794 baseProfile: "full",
8795 xmlns: "http://www.w3.org/2000/svg",
8796 xmlnsXlink: "http://www.w3.org/1999/xlink",
8797 style: _extends({
8798 width: "100%",
8799 height: "100%"
8800 }, svgStyle),
8801 id
8802 }, react.createElement("g", {
8803 id: id + "__eraser-stroke-group",
8804 display: "none"
8805 }, react.createElement("rect", {
8806 id: id + "__mask-background",
8807 x: "0",
8808 y: "0",
8809 width: "100%",
8810 height: "100%",
8811 fill: "white"
8812 }), eraserPaths.map(function(eraserPath, i) {
8813 return react.createElement(SvgPath, {
8814 key: id + "__eraser-" + i,
8815 id: id + "__eraser-" + i,
8816 paths: eraserPath.paths,
8817 strokeColor: "#000000",
8818 strokeWidth: eraserPath.strokeWidth
8819 });
8820 })), react.createElement("defs", null, backgroundImage && react.createElement("pattern", {
8821 id: id + "__background",
8822 x: "0",
8823 y: "0",
8824 width: "100%",
8825 height: "100%",
8826 patternUnits: "userSpaceOnUse"
8827 }, react.createElement("image", {
8828 x: "0",
8829 y: "0",
8830 width: "100%",
8831 height: "100%",
8832 xlinkHref: backgroundImage,
8833 preserveAspectRatio: preserveBackgroundImageAspectRatio
8834 })), eraserPaths.map(function(_, i) {
8835 return react.createElement("mask", {
8836 id: id + "__eraser-mask-" + i,
8837 key: id + "__eraser-mask-" + i,
8838 maskUnits: "userSpaceOnUse"
8839 }, react.createElement("use", { href: "#" + id + "__mask-background" }), Array.from({ length: eraserPaths.length - i }, function(_, j) {
8840 return j + i;
8841 }).map(function(k) {
8842 return react.createElement("use", {
8843 key: k.toString(),
8844 href: "#" + id + "__eraser-" + k.toString()
8845 });
8846 }));
8847 })), react.createElement("g", { id: id + "__canvas-background-group" }, react.createElement("rect", {
8848 id: id + "__canvas-background",
8849 x: "0",
8850 y: "0",
8851 width: "100%",
8852 height: "100%",
8853 fill: backgroundImage ? "url(#" + id + "__background)" : canvasColor
8854 })), pathGroups.map(function(pathGroup, i) {
8855 return react.createElement("g", {
8856 id: id + "__stroke-group-" + i,
8857 key: id + "__stroke-group-" + i,
8858 mask: "url(#" + id + "__eraser-mask-" + i + ")"
8859 }, react.createElement(Paths, {
8860 id,
8861 paths: pathGroup
8862 }));
8863 })));
8864 });
8865 var ReactSketchCanvas = /*#__PURE__*/ react.forwardRef(function(props, ref) {
8866 var _props$id = props.id;
8867 var id = _props$id === void 0 ? "react-sketch-canvas" : _props$id;
8868 var _props$width = props.width;
8869 var width = _props$width === void 0 ? "100%" : _props$width;
8870 var _props$height = props.height;
8871 var height = _props$height === void 0 ? "100%" : _props$height;
8872 var _props$className = props.className;
8873 var className = _props$className === void 0 ? "" : _props$className;
8874 var _props$canvasColor = props.canvasColor;
8875 var canvasColor = _props$canvasColor === void 0 ? "white" : _props$canvasColor;
8876 var _props$strokeColor = props.strokeColor;
8877 var strokeColor = _props$strokeColor === void 0 ? "red" : _props$strokeColor;
8878 var _props$backgroundImag = props.backgroundImage;
8879 var backgroundImage = _props$backgroundImag === void 0 ? "" : _props$backgroundImag;
8880 var _props$exportWithBack = props.exportWithBackgroundImage;
8881 var exportWithBackgroundImage = _props$exportWithBack === void 0 ? false : _props$exportWithBack;
8882 var _props$preserveBackgr = props.preserveBackgroundImageAspectRatio;
8883 var preserveBackgroundImageAspectRatio = _props$preserveBackgr === void 0 ? "none" : _props$preserveBackgr;
8884 var _props$strokeWidth = props.strokeWidth;
8885 var strokeWidth = _props$strokeWidth === void 0 ? 4 : _props$strokeWidth;
8886 var _props$eraserWidth = props.eraserWidth;
8887 var eraserWidth = _props$eraserWidth === void 0 ? 8 : _props$eraserWidth;
8888 var _props$allowOnlyPoint = props.allowOnlyPointerType;
8889 var allowOnlyPointerType = _props$allowOnlyPoint === void 0 ? "all" : _props$allowOnlyPoint;
8890 var _props$style = props.style;
8891 var style = _props$style === void 0 ? {
8892 border: "0.0625rem solid #9c9c9c",
8893 borderRadius: "0.25rem"
8894 } : _props$style;
8895 var _props$svgStyle = props.svgStyle;
8896 var svgStyle = _props$svgStyle === void 0 ? {} : _props$svgStyle;
8897 var _props$onChange = props.onChange;
8898 var onChange = _props$onChange === void 0 ? function(_paths) {} : _props$onChange;
8899 var _props$onStroke = props.onStroke;
8900 var onStroke = _props$onStroke === void 0 ? function(_path, _isEraser) {} : _props$onStroke;
8901 var _props$withTimestamp = props.withTimestamp;
8902 var withTimestamp = _props$withTimestamp === void 0 ? false : _props$withTimestamp;
8903 var svgCanvas = react.createRef();
8904 var _React$useState = react.useState(true);
8905 var drawMode = _React$useState[0];
8906 var setDrawMode = _React$useState[1];
8907 var _React$useState2 = react.useState(false);
8908 var isDrawing = _React$useState2[0];
8909 var setIsDrawing = _React$useState2[1];
8910 var _React$useState3 = react.useState([]);
8911 var resetStack = _React$useState3[0];
8912 var setResetStack = _React$useState3[1];
8913 var _React$useState4 = react.useState([]);
8914 var undoStack = _React$useState4[0];
8915 var setUndoStack = _React$useState4[1];
8916 var _React$useState5 = react.useState([]);
8917 var currentPaths = _React$useState5[0];
8918 var setCurrentPaths = _React$useState5[1];
8919 var liftStrokeUp = react.useCallback(function() {
8920 var _currentPaths$slice$;
8921 var _currentPaths$slice;
8922 var lastStroke = (_currentPaths$slice$ = (_currentPaths$slice = currentPaths.slice(-1)) == null ? void 0 : _currentPaths$slice[0]) != null ? _currentPaths$slice$ : null;
8923 if (lastStroke === null) {
8924 console.warn("No stroke found!");
8925 return;
8926 }
8927 onStroke(lastStroke, !lastStroke.drawMode);
8928 }, [isDrawing]);
8929 react.useEffect(function() {
8930 liftStrokeUp();
8931 }, [isDrawing]);
8932 react.useEffect(function() {
8933 onChange(currentPaths);
8934 }, [currentPaths]);
8935 react.useImperativeHandle(ref, function() {
8936 return {
8937 eraseMode: function eraseMode(erase) {
8938 setDrawMode(!erase);
8939 },
8940 clearCanvas: function clearCanvas() {
8941 setResetStack([].concat(currentPaths));
8942 setCurrentPaths([]);
8943 },
8944 undo: function undo() {
8945 if (resetStack.length !== 0) {
8946 setCurrentPaths([].concat(resetStack));
8947 setResetStack([]);
8948 return;
8949 }
8950 setUndoStack(function(undoStack) {
8951 return [].concat(undoStack, currentPaths.slice(-1));
8952 });
8953 setCurrentPaths(function(currentPaths) {
8954 return currentPaths.slice(0, -1);
8955 });
8956 },
8957 redo: function redo() {
8958 if (undoStack.length === 0) return;
8959 setCurrentPaths(function(currentPaths) {
8960 return [].concat(currentPaths, undoStack.slice(-1));
8961 });
8962 setUndoStack(function(undoStack) {
8963 return undoStack.slice(0, -1);
8964 });
8965 },
8966 exportImage: function exportImage(imageType) {
8967 var _svgCanvas$current;
8968 var exportImage = (_svgCanvas$current = svgCanvas.current) == null ? void 0 : _svgCanvas$current.exportImage;
8969 if (!exportImage) throw Error("Export function called before canvas loaded");
8970 else return exportImage(imageType);
8971 },
8972 exportSvg: function exportSvg() {
8973 return new Promise(function(resolve, reject) {
8974 var _svgCanvas$current2;
8975 var exportSvg = (_svgCanvas$current2 = svgCanvas.current) == null ? void 0 : _svgCanvas$current2.exportSvg;
8976 if (!exportSvg) reject(Error("Export function called before canvas loaded"));
8977 else exportSvg().then(function(data) {
8978 resolve(data);
8979 })["catch"](function(e) {
8980 reject(e);
8981 });
8982 });
8983 },
8984 exportPaths: function exportPaths() {
8985 return new Promise(function(resolve, reject) {
8986 try {
8987 resolve(currentPaths);
8988 } catch (e) {
8989 reject(e);
8990 }
8991 });
8992 },
8993 loadPaths: function loadPaths(paths) {
8994 setCurrentPaths(function(currentPaths) {
8995 return [].concat(currentPaths, paths);
8996 });
8997 },
8998 getSketchingTime: function getSketchingTime() {
8999 return new Promise(function(resolve, reject) {
9000 if (!withTimestamp) reject(/* @__PURE__ */ new Error("Set 'withTimestamp' prop to get sketching time"));
9001 try {
9002 resolve(currentPaths.reduce(function(totalSketchingTime, path) {
9003 var _path$startTimestamp;
9004 var _path$endTimestamp;
9005 var startTimestamp = (_path$startTimestamp = path.startTimestamp) != null ? _path$startTimestamp : 0;
9006 return totalSketchingTime + (((_path$endTimestamp = path.endTimestamp) != null ? _path$endTimestamp : 0) - startTimestamp);
9007 }, 0));
9008 } catch (e) {
9009 reject(e);
9010 }
9011 });
9012 },
9013 resetCanvas: function resetCanvas() {
9014 setResetStack([]);
9015 setUndoStack([]);
9016 setCurrentPaths([]);
9017 }
9018 };
9019 });
9020 return react.createElement(Canvas, {
9021 ref: svgCanvas,
9022 id,
9023 width,
9024 height,
9025 className,
9026 canvasColor,
9027 backgroundImage,
9028 exportWithBackgroundImage,
9029 preserveBackgroundImageAspectRatio,
9030 allowOnlyPointerType,
9031 style,
9032 svgStyle,
9033 paths: currentPaths,
9034 isDrawing,
9035 onPointerDown: function handlePointerDown(point) {
9036 setIsDrawing(true);
9037 setUndoStack([]);
9038 var stroke = {
9039 drawMode,
9040 strokeColor: drawMode ? strokeColor : "#000000",
9041 strokeWidth: drawMode ? strokeWidth : eraserWidth,
9042 paths: [point]
9043 };
9044 if (withTimestamp) stroke = _extends({}, stroke, {
9045 startTimestamp: Date.now(),
9046 endTimestamp: 0
9047 });
9048 setCurrentPaths(function(currentPaths) {
9049 return [].concat(currentPaths, [stroke]);
9050 });
9051 },
9052 onPointerMove: function handlePointerMove(point) {
9053 if (!isDrawing) return;
9054 var currentStroke = currentPaths.slice(-1)[0];
9055 var updatedStroke = _extends({}, currentStroke, { paths: [].concat(currentStroke.paths, [point]) });
9056 setCurrentPaths(function(currentPaths) {
9057 return [].concat(currentPaths.slice(0, -1), [updatedStroke]);
9058 });
9059 },
9060 onPointerUp: function handlePointerUp() {
9061 var _currentPaths$slice$2;
9062 var _currentPaths$slice2;
9063 if (!isDrawing) return;
9064 setIsDrawing(false);
9065 if (!withTimestamp) return;
9066 var currentStroke = (_currentPaths$slice$2 = (_currentPaths$slice2 = currentPaths.slice(-1)) == null ? void 0 : _currentPaths$slice2[0]) != null ? _currentPaths$slice$2 : null;
9067 if (currentStroke === null) return;
9068 var updatedStroke = _extends({}, currentStroke, { endTimestamp: Date.now() });
9069 setCurrentPaths(function(currentPaths) {
9070 return [].concat(currentPaths.slice(0, -1), [updatedStroke]);
9071 });
9072 }
9073 });
9074 });
9075
9076 //#endregion
9077 //#region modules/ai/assets/js/editor/icons/undo-icon.js
9078 init_extends();
9079 var UndoIcon = react.default.forwardRef(function(props, ref) {
9080 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" }));
9081 });
9082
9083 //#endregion
9084 //#region modules/ai/assets/js/editor/icons/redo-icon.js
9085 init_extends();
9086 var RedoIcon = react.default.forwardRef(function(props, ref) {
9087 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" }));
9088 });
9089
9090 //#endregion
9091 //#region modules/ai/assets/js/editor/pages/form-media/views/in-painting/in-painting-content.js
9092 init_asyncToGenerator();
9093 init_slicedToArray();
9094 var STROKE_SELECT_WIDTH$1 = 120;
9095 var BRUSH_COLOR$1 = "rgba(255, 255, 255)";
9096 var CANVAS_COLOR$1 = "rgba(0, 0, 0)";
9097 var StyledUndoIcon$1 = (0, _elementor_ui.withDirection)(UndoIcon);
9098 var StyledRedoIcon$1 = (0, _elementor_ui.withDirection)(RedoIcon);
9099 var BrushCursor$1 = (0, _elementor_ui.styled)(_elementor_ui.Box, { shouldForwardProp: function shouldForwardProp(prop) {
9100 return "size" === prop;
9101 } })(function(_ref) {
9102 var theme = _ref.theme;
9103 var size = _ref.size;
9104 return {
9105 position: "absolute",
9106 width: size,
9107 height: size,
9108 borderRadius: "50%",
9109 backgroundColor: BRUSH_COLOR$1,
9110 pointerEvents: "none",
9111 transform: "translate(".concat("rtl" === theme.direction ? "50%" : "-50%", ", -50%)"),
9112 border: "1px solid #fff"
9113 };
9114 });
9115 var BrishSizeIcon$1 = (0, _elementor_ui.styled)(_elementor_ui.Box, { shouldForwardProp: function shouldForwardProp(prop) {
9116 return "size" === prop;
9117 } })(function(_ref2) {
9118 var theme = _ref2.theme;
9119 var size = _ref2.size;
9120 return {
9121 width: size / 2,
9122 height: size / 2,
9123 borderRadius: "50%",
9124 backgroundColor: theme.palette.secondary.main
9125 };
9126 });
9127 var InPaintingContent = function InPaintingContent(_ref3) {
9128 var editImage = _ref3.editImage;
9129 var setMask = _ref3.setMask;
9130 var setIsCanvasChanged = _ref3.setIsCanvasChanged;
9131 var canvasWidth = _ref3.width;
9132 var canvasHeight = _ref3.height;
9133 var sketchRef = (0, react.useRef)();
9134 var _useState2 = _slicedToArray((0, react.useState)(30), 2);
9135 var stroke = _useState2[0];
9136 var setStroke = _useState2[1];
9137 var brushCursorRef = (0, react.useRef)();
9138 (0, react.useEffect)(function() {
9139 var canvas = document.querySelector(".eui-in-painting-canvas");
9140 var positionElement = function positionElement(e) {
9141 var _canvas$getBoundingCl = canvas.getBoundingClientRect();
9142 var left = _canvas$getBoundingCl.left;
9143 var top = _canvas$getBoundingCl.top;
9144 var width = _canvas$getBoundingCl.width;
9145 var height = _canvas$getBoundingCl.height;
9146 var x = e.clientX - left;
9147 var y = e.clientY - top;
9148 if (x > 0 && x < width && y > 0 && y < height) {
9149 brushCursorRef.current.style.left = "".concat(x, "px");
9150 brushCursorRef.current.style.top = "".concat(y, "px");
9151 }
9152 };
9153 window.addEventListener("mousemove", positionElement);
9154 return function() {
9155 window.removeEventListener("mousemove", positionElement);
9156 };
9157 }, [stroke]);
9158 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
9159 alignItems: "flex-start",
9160 spacing: .5,
9161 flexGrow: 1
9162 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
9163 width: "100%",
9164 direction: "row",
9165 spacing: 3,
9166 alignSelf: "center",
9167 justifyContent: "center",
9168 sx: { marginBottom: "20px !important" }
9169 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
9170 direction: "row",
9171 gap: 1
9172 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: (0, _wordpress_i18n.__)("Undo", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
9173 variant: "outlined",
9174 color: "secondary",
9175 onClick: function onClick() {
9176 return sketchRef.current.undo();
9177 },
9178 sx: { px: 0 }
9179 }, /*#__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, {
9180 variant: "outlined",
9181 color: "secondary",
9182 onClick: function onClick() {
9183 return sketchRef.current.redo();
9184 },
9185 sx: { px: 0 }
9186 }, /*#__PURE__*/ react.default.createElement(StyledRedoIcon$1, null)))), /*#__PURE__*/ react.default.createElement(_elementor_ui.FormControl, {
9187 size: "small",
9188 color: "secondary",
9189 sx: { minWidth: STROKE_SELECT_WIDTH$1 }
9190 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.InputLabel, { id: "stroke" }, "Stroke"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Select, {
9191 autoWidth: true,
9192 label: "Stroke",
9193 value: stroke,
9194 id: "demo-simple-select",
9195 labelId: "demo-simple-select-label",
9196 onChange: function onChange(e) {
9197 return setStroke(e.target.value);
9198 },
9199 MenuProps: {
9200 PaperProps: { sx: { maxWidth: STROKE_SELECT_WIDTH$1 } },
9201 MenuListProps: { sx: { minWidth: STROKE_SELECT_WIDTH$1 } }
9202 },
9203 sx: { "& .MuiSelect-select .MuiListItemIcon-root": {
9204 mr: .25,
9205 width: "initial",
9206 minWidth: "initial",
9207 justifyContent: "flex-start"
9208 } }
9209 }, [
9210 10,
9211 20,
9212 30,
9213 40,
9214 50
9215 ].map(function(value) {
9216 return /*#__PURE__*/ react.default.createElement(_elementor_ui.MenuItem, {
9217 key: "stroke-width-option-" + value,
9218 value
9219 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
9220 direction: "row",
9221 alignItems: "center",
9222 gap: 1
9223 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemIcon, { sx: {
9224 width: 30,
9225 display: "flex",
9226 justifyContent: "center"
9227 } }, /*#__PURE__*/ react.default.createElement(BrishSizeIcon$1, { size: value })), /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemText, null, value)));
9228 })))), /*#__PURE__*/ react.default.createElement("div", { style: {
9229 margin: "0 auto",
9230 position: "relative",
9231 cursor: "none",
9232 overflow: "hidden"
9233 } }, /*#__PURE__*/ react.default.createElement(BrushCursor$1, {
9234 ref: brushCursorRef,
9235 size: stroke
9236 }), /*#__PURE__*/ react.default.createElement(ReactSketchCanvas, {
9237 className: "eui-in-painting-canvas",
9238 withViewBox: true,
9239 ref: sketchRef,
9240 height: canvasHeight + "px",
9241 width: canvasWidth + "px",
9242 strokeWidth: stroke,
9243 strokeColor: BRUSH_COLOR$1,
9244 canvasColor: CANVAS_COLOR$1,
9245 backgroundImage: editImage.url,
9246 onStroke: function onStroke() {
9247 return setIsCanvasChanged(true);
9248 },
9249 onChange: /*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee() {
9250 var svg;
9251 return import_regenerator$3.default.wrap(function(_context) {
9252 while (1) switch (_context.prev = _context.next) {
9253 case 0:
9254 _context.next = 1;
9255 return sketchRef.current.exportSvg();
9256 case 1:
9257 svg = _context.sent;
9258 setMask(svg);
9259 case 2:
9260 case "end": return _context.stop();
9261 }
9262 }, _callee);
9263 }))
9264 })));
9265 };
9266 InPaintingContent.propTypes = {
9267 setMask: import_prop_types$12.default.func.isRequired,
9268 setIsCanvasChanged: import_prop_types$12.default.func.isRequired,
9269 width: import_prop_types$12.default.number.isRequired,
9270 height: import_prop_types$12.default.number.isRequired,
9271 editImage: import_prop_types$12.default.object.isRequired
9272 };
9273
9274 //#endregion
9275 //#region modules/ai/assets/js/editor/pages/form-media/views/in-painting/hooks/use-in-painting.js
9276 init_api();
9277 var useInPainting = function useInPainting(initialValue) {
9278 return useImagePrompt(function fetchAction(payload) {
9279 return getImageToImageMaskGeneration(payload);
9280 }, initialValue);
9281 };
9282
9283 //#endregion
9284 //#region modules/ai/assets/js/editor/pages/form-media/views/in-painting/index.js
9285 init_asyncToGenerator();
9286 init_slicedToArray();
9287 init_requests_ids();
9288 var InPainting = function InPainting() {
9289 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
9290 var prompt = _useState2[0];
9291 var setPrompt = _useState2[1];
9292 var setGenerate = useRequestIds().setGenerate;
9293 var _useState4 = _slicedToArray((0, react.useState)(""), 2);
9294 var mask = _useState4[0];
9295 var setMask = _useState4[1];
9296 var _useState6 = _slicedToArray((0, react.useState)(false), 2);
9297 var isCanvasChanged = _useState6[0];
9298 var setIsCanvasChanged = _useState6[1];
9299 var _usePromptSettings = usePromptSettings();
9300 var settings = _usePromptSettings.settings;
9301 var resetSettings = _usePromptSettings.resetSettings;
9302 var _useEditImage = useEditImage();
9303 var editImage = _useEditImage.editImage;
9304 var width = _useEditImage.width;
9305 var height = _useEditImage.height;
9306 var _useImageActions = useImageActions();
9307 var use = _useImageActions.use;
9308 var edit = _useImageActions.edit;
9309 var isUploading = _useImageActions.isLoading;
9310 var _useInPainting = useInPainting();
9311 var data = _useInPainting.data;
9312 var send = _useInPainting.send;
9313 var isGenerating = _useInPainting.isLoading;
9314 var error = _useInPainting.error;
9315 var reset = _useInPainting.reset;
9316 var isLoading = isGenerating || isUploading;
9317 var handleSubmit = /*#__PURE__*/ function() {
9318 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee(event) {
9319 var finalPrompt;
9320 return import_regenerator$3.default.wrap(function(_context) {
9321 while (1) switch (_context.prev = _context.next) {
9322 case 0:
9323 event.preventDefault();
9324 finalPrompt = prompt || "Remove object and fill based on the surroundings";
9325 setGenerate();
9326 send({
9327 prompt: finalPrompt,
9328 settings,
9329 image: editImage,
9330 mask
9331 });
9332 case 1:
9333 case "end": return _context.stop();
9334 }
9335 }, _callee);
9336 }));
9337 return function handleSubmit(_x) {
9338 return _ref.apply(this, arguments);
9339 };
9340 }();
9341 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, {
9342 primary: (0, _wordpress_i18n.__)("Generative Fill", "elementor"),
9343 secondary: (0, _wordpress_i18n.__)("Mark an area and edit it with a prompt.", "elementor")
9344 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
9345 error,
9346 onRetry: handleSubmit
9347 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(PromptField, {
9348 value: prompt,
9349 disabled: isLoading,
9350 onChange: setPrompt,
9351 placeholder: (0, _wordpress_i18n.__)("Describe what you want to generate in the marked area (English only)", "elementor")
9352 }), data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
9353 gap: 2,
9354 sx: { my: 2.5 }
9355 }, /*#__PURE__*/ react.default.createElement(GenerateAgainSubmit, { disabled: isLoading }), /*#__PURE__*/ react.default.createElement(NewPromptButton, {
9356 disabled: isLoading,
9357 onClick: function onClick() {
9358 resetSettings();
9359 setPrompt("");
9360 reset();
9361 }
9362 })) : /*#__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, {
9363 images: data.result,
9364 aspectRatio: editImage.aspectRatio,
9365 onUseImage: use,
9366 onEditImage: edit
9367 }) : /*#__PURE__*/ react.default.createElement(InPaintingContent, {
9368 editImage,
9369 width,
9370 height,
9371 setMask,
9372 setIsCanvasChanged
9373 })));
9374 };
9375
9376 //#endregion
9377 //#region node_modules/react-avatar-editor/dist/index.js
9378 var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9379 (function(e, t) {
9380 "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);
9381 })(exports, function(e, t) {
9382 "use strict";
9383 function o(e) {
9384 return e && "object" == typeof e && "default" in e ? e : { default: e };
9385 }
9386 var n = o(e);
9387 var i = o(t);
9388 function r(e, t) {
9389 for (var o = 0; o < t.length; o++) {
9390 var n = t[o];
9391 n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, n.key, n);
9392 }
9393 }
9394 function s(e, t, o) {
9395 return t in e ? Object.defineProperty(e, t, {
9396 value: o,
9397 enumerable: !0,
9398 configurable: !0,
9399 writable: !0
9400 }) : e[t] = o, e;
9401 }
9402 function u() {
9403 return (u = Object.assign || function(e) {
9404 for (var t = 1; t < arguments.length; t++) {
9405 var o = arguments[t];
9406 for (var n in o) Object.prototype.hasOwnProperty.call(o, n) && (e[n] = o[n]);
9407 }
9408 return e;
9409 }).apply(this, arguments);
9410 }
9411 function a(t, e) {
9412 var o;
9413 var n = Object.keys(t);
9414 return Object.getOwnPropertySymbols && (o = Object.getOwnPropertySymbols(t), e && (o = o.filter(function(e) {
9415 return Object.getOwnPropertyDescriptor(t, e).enumerable;
9416 })), n.push.apply(n, o)), n;
9417 }
9418 function y(t) {
9419 for (var e = 1; e < arguments.length; e++) {
9420 var o = null != arguments[e] ? arguments[e] : {};
9421 e % 2 ? a(Object(o), !0).forEach(function(e) {
9422 s(t, e, o[e]);
9423 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(o)) : a(Object(o)).forEach(function(e) {
9424 Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(o, e));
9425 });
9426 }
9427 return t;
9428 }
9429 function h(e) {
9430 return (h = Object.setPrototypeOf ? Object.getPrototypeOf : function(e) {
9431 return e.__proto__ || Object.getPrototypeOf(e);
9432 })(e);
9433 }
9434 function c(e, t) {
9435 return (c = Object.setPrototypeOf || function(e, t) {
9436 return e.__proto__ = t, e;
9437 })(e, t);
9438 }
9439 function l(e, t) {
9440 if (null == e) return {};
9441 var o;
9442 var n = function(e, t) {
9443 if (null == e) return {};
9444 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]);
9445 return n;
9446 }(e, t);
9447 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]);
9448 return n;
9449 }
9450 function d(e) {
9451 if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
9452 return e;
9453 }
9454 function p(r) {
9455 var i = function() {
9456 if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
9457 if (Reflect.construct.sham) return !1;
9458 if ("function" == typeof Proxy) return !0;
9459 try {
9460 return Date.prototype.toString.call(Reflect.construct(Date, [], function() {})), !0;
9461 } catch (e) {
9462 return !1;
9463 }
9464 }();
9465 return function() {
9466 var e;
9467 var t;
9468 var o;
9469 var n;
9470 var a = h(r);
9471 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;
9472 };
9473 }
9474 function m(e, t) {
9475 return function(e) {
9476 if (Array.isArray(e)) return e;
9477 }(e) || function(e, t) {
9478 if ("undefined" == typeof Symbol || !(Symbol.iterator in Object(e))) return;
9479 var o = [];
9480 var n = !0;
9481 var a = !1;
9482 var r = void 0;
9483 try {
9484 for (var i, s = e[Symbol.iterator](); !(n = (i = s.next()).done) && (o.push(i.value), !t || o.length !== t); n = !0);
9485 } catch (e) {
9486 a = !0, r = e;
9487 } finally {
9488 try {
9489 n || null == s.return || s.return();
9490 } finally {
9491 if (a) throw r;
9492 }
9493 }
9494 return o;
9495 }(e, t) || g(e, t) || function() {
9496 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9497 }();
9498 }
9499 function g(e, t) {
9500 if (e) {
9501 if ("string" == typeof e) return f(e, t);
9502 var o = Object.prototype.toString.call(e).slice(8, -1);
9503 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;
9504 }
9505 }
9506 function f(e, t) {
9507 (null == t || t > e.length) && (t = e.length);
9508 for (var o = 0, n = new Array(t); o < t; o++) n[o] = e[o];
9509 return n;
9510 }
9511 function v(a, r) {
9512 return new Promise(function(e, t) {
9513 var o;
9514 var n = new Image();
9515 n.onload = function() {
9516 return e(n);
9517 }, 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;
9518 });
9519 }
9520 var b;
9521 var w = !("undefined" == typeof window || "undefined" == typeof navigator || !("ontouchstart" in window || 0 < navigator.msMaxTouchPoints));
9522 var M = "undefined" != typeof File;
9523 var O = {
9524 touch: {
9525 react: {
9526 down: "onTouchStart",
9527 mouseDown: "onMouseDown",
9528 drag: "onTouchMove",
9529 move: "onTouchMove",
9530 mouseMove: "onMouseMove",
9531 up: "onTouchEnd",
9532 mouseUp: "onMouseUp"
9533 },
9534 native: {
9535 down: "touchstart",
9536 mouseDown: "mousedown",
9537 drag: "touchmove",
9538 move: "touchmove",
9539 mouseMove: "mousemove",
9540 up: "touchend",
9541 mouseUp: "mouseup"
9542 }
9543 },
9544 desktop: {
9545 react: {
9546 down: "onMouseDown",
9547 drag: "onDragOver",
9548 move: "onMouseMove",
9549 up: "onMouseUp"
9550 },
9551 native: {
9552 down: "mousedown",
9553 drag: "dragStart",
9554 move: "mousemove",
9555 up: "mouseup"
9556 }
9557 }
9558 };
9559 var I = w ? O.touch : O.desktop;
9560 var P = "undefined" != typeof window && window.devicePixelRatio ? window.devicePixelRatio : 1;
9561 var C = {
9562 x: .5,
9563 y: .5
9564 };
9565 var x = function() {
9566 (function(e, t) {
9567 if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
9568 e.prototype = Object.create(t && t.prototype, { constructor: {
9569 value: e,
9570 writable: !0,
9571 configurable: !0
9572 } }), t && c(e, t);
9573 })(a, i["default"].Component);
9574 var e;
9575 var t;
9576 var o;
9577 var n = p(a);
9578 function a(e) {
9579 var v;
9580 return function(e, t) {
9581 if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
9582 }(this, a), s(d(v = n.call(this, e)), "state", {
9583 drag: !1,
9584 my: null,
9585 mx: null,
9586 image: C
9587 }), s(d(v), "handleImageReady", function(e) {
9588 var t = v.getInitialSize(e.width, e.height);
9589 t.resource = e, t.x = .5, t.y = .5, t.backgroundColor = v.props.backgroundColor, v.setState({
9590 drag: !1,
9591 image: t
9592 }, v.props.onImageReady), v.props.onLoadSuccess(t);
9593 }), s(d(v), "clearImage", function() {
9594 v.canvas.getContext("2d").clearRect(0, 0, v.canvas.width, v.canvas.height), v.setState({ image: C });
9595 }), s(d(v), "handleMouseDown", function(e) {
9596 (e = e || window.event).preventDefault(), v.setState({
9597 drag: !0,
9598 mx: null,
9599 my: null
9600 });
9601 }), s(d(v), "handleMouseUp", function() {
9602 v.state.drag && (v.setState({ drag: !1 }), v.props.onMouseUp());
9603 }), s(d(v), "handleMouseMove", function(e) {
9604 var t;
9605 var o;
9606 var n;
9607 var a;
9608 var r;
9609 var i;
9610 var s;
9611 var u;
9612 var h;
9613 var c;
9614 var l;
9615 var d;
9616 var p;
9617 var g;
9618 var f;
9619 var m;
9620 e = e || window.event, !1 !== v.state.drag && (e.preventDefault(), n = {
9621 mx: t = e.targetTouches ? e.targetTouches[0].pageX : e.clientX,
9622 my: o = e.targetTouches ? e.targetTouches[0].pageY : e.clientY
9623 }, 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) {
9624 return e * (Math.PI / 180);
9625 }, d = Math.cos(l(m)), g = c + -a * (p = Math.sin(l(m))) + r * d, f = {
9626 x: (h + a * d + r * p) / i + 1 / v.props.scale * v.getXScale() / 2,
9627 y: g / s + 1 / v.props.scale * v.getYScale() / 2
9628 }, v.props.onPositionChange(f), n.image = y(y({}, v.state.image), f)), v.setState(n), v.props.onMouseMove(e));
9629 }), s(d(v), "setCanvas", function(e) {
9630 v.canvas = e;
9631 }), v.canvas = null, v;
9632 }
9633 return e = a, (t = [
9634 {
9635 key: "componentDidMount",
9636 value: function() {
9637 this.props.disableHiDPIScaling && (P = 1);
9638 var e;
9639 var t;
9640 var o = this.canvas.getContext("2d");
9641 this.props.image && this.loadImage(this.props.image), this.paint(o), document && (e = !!function() {
9642 var t = !1;
9643 try {
9644 var e = Object.defineProperty({}, "passive", { get: function() {
9645 t = !0;
9646 } });
9647 window.addEventListener("test", e, e), window.removeEventListener("test", e, e);
9648 } catch (e) {
9649 t = !1;
9650 }
9651 return t;
9652 }() && { 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)));
9653 }
9654 },
9655 {
9656 key: "componentDidUpdate",
9657 value: function(e, t) {
9658 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();
9659 var o = this.canvas.getContext("2d");
9660 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();
9661 }
9662 },
9663 {
9664 key: "componentWillUnmount",
9665 value: function() {
9666 var e;
9667 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)));
9668 }
9669 },
9670 {
9671 key: "isVertical",
9672 value: function() {
9673 return !this.props.disableCanvasRotation && this.props.rotate % 180 != 0;
9674 }
9675 },
9676 {
9677 key: "getBorders",
9678 value: function(e) {
9679 var t = 0 < arguments.length && void 0 !== e ? e : this.props.border;
9680 return Array.isArray(t) ? t : [t, t];
9681 }
9682 },
9683 {
9684 key: "getDimensions",
9685 value: function() {
9686 var e = this.props;
9687 var t = e.width;
9688 var o = e.height;
9689 var n = e.rotate;
9690 var a = e.border;
9691 var r = {};
9692 var i = m(this.getBorders(a), 2);
9693 var s = i[0];
9694 var u = i[1];
9695 var h = t;
9696 var c = o;
9697 return this.isVertical() ? (r.width = c, r.height = h) : (r.width = h, r.height = c), r.width += 2 * s, r.height += 2 * u, {
9698 canvas: r,
9699 rotate: n,
9700 width: t,
9701 height: o,
9702 border: a
9703 };
9704 }
9705 },
9706 {
9707 key: "getImage",
9708 value: function() {
9709 var e = this.getCroppingRect();
9710 var t = this.state.image;
9711 e.x *= t.resource.width, e.y *= t.resource.height, e.width *= t.resource.width, e.height *= t.resource.height;
9712 var o = document.createElement("canvas");
9713 this.isVertical() ? (o.width = e.height, o.height = e.width) : (o.width = e.width, o.height = e.height);
9714 var n = o.getContext("2d");
9715 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;
9716 }
9717 },
9718 {
9719 key: "getImageScaledToCanvas",
9720 value: function() {
9721 var e = this.getDimensions();
9722 var t = e.width;
9723 var o = e.height;
9724 var n = document.createElement("canvas");
9725 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;
9726 }
9727 },
9728 {
9729 key: "getXScale",
9730 value: function() {
9731 var e = this.props.width / this.props.height;
9732 var t = this.state.image.width / this.state.image.height;
9733 return Math.min(1, e / t);
9734 }
9735 },
9736 {
9737 key: "getYScale",
9738 value: function() {
9739 var e = this.props.height / this.props.width;
9740 var t = this.state.image.height / this.state.image.width;
9741 return Math.min(1, e / t);
9742 }
9743 },
9744 {
9745 key: "getCroppingRect",
9746 value: function() {
9747 var e = this.props.position || {
9748 x: this.state.image.x,
9749 y: this.state.image.y
9750 };
9751 var t = 1 / this.props.scale * this.getXScale();
9752 var o = 1 / this.props.scale * this.getYScale();
9753 var n = {
9754 x: e.x - t / 2,
9755 y: e.y - o / 2,
9756 width: t,
9757 height: o
9758 };
9759 var a = 0;
9760 var r = 1 - n.width;
9761 var i = 0;
9762 var s = 1 - n.height;
9763 return (this.props.disableBoundaryChecks || 1 < t || 1 < o) && (a = -n.width, i = -n.height, s = r = 1), y(y({}, n), {}, {
9764 x: Math.max(a, Math.min(n.x, r)),
9765 y: Math.max(i, Math.min(n.y, s))
9766 });
9767 }
9768 },
9769 {
9770 key: "loadImage",
9771 value: function(e) {
9772 var t;
9773 M && e instanceof File ? this.loadingImage = (t = e, new Promise(function(o, n) {
9774 var e = new FileReader();
9775 e.onload = function(e) {
9776 try {
9777 o(v(e.target.result));
9778 } catch (e) {
9779 n(e);
9780 }
9781 }, e.readAsDataURL(t);
9782 }).then(this.handleImageReady).catch(this.props.onLoadFailure)) : "string" == typeof e && (this.loadingImage = v(e, this.props.crossOrigin).then(this.handleImageReady).catch(this.props.onLoadFailure));
9783 }
9784 },
9785 {
9786 key: "getInitialSize",
9787 value: function(e, t) {
9788 var o;
9789 var n;
9790 var a = this.getDimensions();
9791 return t / e < a.height / a.width ? n = e * ((o = this.getDimensions().height) / t) : o = t * ((n = this.getDimensions().width) / e), {
9792 height: o,
9793 width: n
9794 };
9795 }
9796 },
9797 {
9798 key: "paintImage",
9799 value: function(e, t, o, n) {
9800 var a;
9801 var r = 3 < arguments.length && void 0 !== n ? n : P;
9802 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());
9803 }
9804 },
9805 {
9806 key: "calculatePosition",
9807 value: function(e, t) {
9808 e = e || this.state.image;
9809 var o = m(this.getBorders(t), 2);
9810 var n = o[0];
9811 var a = o[1];
9812 var r = this.getCroppingRect();
9813 var i = e.width * this.props.scale;
9814 var s = e.height * this.props.scale;
9815 var u = -r.x * i;
9816 var h = -r.y * s;
9817 return this.isVertical() ? (u += a, h += n) : (u += n, h += a), {
9818 x: u,
9819 y: h,
9820 height: s,
9821 width: i
9822 };
9823 }
9824 },
9825 {
9826 key: "paint",
9827 value: function(e) {
9828 e.save(), e.scale(P, P), e.translate(0, 0), e.fillStyle = "rgba(" + this.props.color.slice(0, 4).join(",") + ")";
9829 var t;
9830 var o;
9831 var n;
9832 var a;
9833 var r;
9834 var i;
9835 var s;
9836 var u;
9837 var h = this.props.borderRadius;
9838 var c = this.getDimensions();
9839 var l = m(this.getBorders(c.border), 2);
9840 var d = l[0];
9841 var p = l[1];
9842 var g = c.canvas.height;
9843 var f = c.canvas.width;
9844 var h = Math.max(h, 0);
9845 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();
9846 }
9847 },
9848 {
9849 key: "render",
9850 value: function() {
9851 var e = this.props;
9852 var t = (e.scale, e.rotate, e.image, e.border, e.borderRadius, e.width, e.height, e.position, e.color, e.backgroundColor, e.style);
9853 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, [
9854 "scale",
9855 "rotate",
9856 "image",
9857 "border",
9858 "borderRadius",
9859 "width",
9860 "height",
9861 "position",
9862 "color",
9863 "backgroundColor",
9864 "style",
9865 "crossOrigin",
9866 "onLoadFailure",
9867 "onLoadSuccess",
9868 "onImageReady",
9869 "onImageChange",
9870 "onMouseUp",
9871 "onMouseMove",
9872 "onPositionChange",
9873 "disableBoundaryChecks",
9874 "disableHiDPIScaling",
9875 "disableCanvasRotation"
9876 ]));
9877 var n = this.getDimensions();
9878 var a = {
9879 width: n.canvas.width,
9880 height: n.canvas.height,
9881 cursor: this.state.drag ? "grabbing" : "grab",
9882 touchAction: "none"
9883 };
9884 var r = {
9885 width: n.canvas.width * P,
9886 height: n.canvas.height * P,
9887 style: y(y({}, a), t)
9888 };
9889 return r[I.react.down] = this.handleMouseDown, w && (r[I.react.mouseDown] = this.handleMouseDown), i.default.createElement("canvas", u({ ref: this.setCanvas }, r, o));
9890 }
9891 }
9892 ]) && r(e.prototype, t), o && r(e, o), a;
9893 }();
9894 return s(x, "propTypes", {
9895 scale: n.default.number,
9896 rotate: n.default.number,
9897 image: n.default.oneOfType([n.default.string].concat(function(e) {
9898 if (Array.isArray(e)) return f(e);
9899 }(b = M ? [n.default.instanceOf(File)] : []) || function(e) {
9900 if ("undefined" != typeof Symbol && Symbol.iterator in Object(e)) return Array.from(e);
9901 }(b) || g(b) || function() {
9902 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9903 }())),
9904 border: n.default.oneOfType([n.default.number, n.default.arrayOf(n.default.number)]),
9905 borderRadius: n.default.number,
9906 width: n.default.number,
9907 height: n.default.number,
9908 position: n.default.shape({
9909 x: n.default.number,
9910 y: n.default.number
9911 }),
9912 color: n.default.arrayOf(n.default.number),
9913 backgroundColor: n.default.string,
9914 crossOrigin: n.default.oneOf([
9915 "",
9916 "anonymous",
9917 "use-credentials"
9918 ]),
9919 onLoadFailure: n.default.func,
9920 onLoadSuccess: n.default.func,
9921 onImageReady: n.default.func,
9922 onImageChange: n.default.func,
9923 onMouseUp: n.default.func,
9924 onMouseMove: n.default.func,
9925 onPositionChange: n.default.func,
9926 disableBoundaryChecks: n.default.bool,
9927 disableHiDPIScaling: n.default.bool,
9928 disableCanvasRotation: n.default.bool
9929 }), s(x, "defaultProps", {
9930 scale: 1,
9931 rotate: 0,
9932 border: 25,
9933 borderRadius: 0,
9934 width: 200,
9935 height: 200,
9936 color: [
9937 0,
9938 0,
9939 0,
9940 .5
9941 ],
9942 onLoadFailure: function() {},
9943 onLoadSuccess: function() {},
9944 onImageReady: function() {},
9945 onImageChange: function() {},
9946 onMouseUp: function() {},
9947 onMouseMove: function() {},
9948 onPositionChange: function() {},
9949 disableBoundaryChecks: !1,
9950 disableHiDPIScaling: !1,
9951 disableCanvasRotation: !0
9952 }), x;
9953 });
9954 }));
9955
9956 //#endregion
9957 //#region modules/ai/assets/js/editor/pages/form-media/views/out-painting/out-painting-content.js
9958 init_asyncToGenerator();
9959 var import_dist = /* @__PURE__ */ __toESM(require_dist());
9960 var OutPaintingContent = function OutPaintingContent(_ref) {
9961 var scale = _ref.scale;
9962 var setMask = _ref.setMask;
9963 var editImage = _ref.editImage;
9964 var aspectRatio = _ref.aspectRatio;
9965 var setImageSize = _ref.setImageSize;
9966 var setPosition = _ref.setPosition;
9967 var cropperRef = (0, react.useRef)();
9968 var position = (0, react.useRef)({
9969 x: .5,
9970 y: .5
9971 });
9972 var _useImageSize = useImageSize(aspectRatio);
9973 var width = _useImageSize.width;
9974 var height = _useImageSize.height;
9975 var imageSize = {
9976 width,
9977 height
9978 };
9979 var updateMask = /*#__PURE__*/ function() {
9980 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee() {
9981 var imageDataURL;
9982 return import_regenerator$3.default.wrap(function(_context) {
9983 while (1) switch (_context.prev = _context.next) {
9984 case 0:
9985 _context.next = 1;
9986 return cropperRef.current.getImageScaledToCanvas().toDataURL();
9987 case 1:
9988 imageDataURL = _context.sent;
9989 setMask(imageDataURL);
9990 case 2:
9991 case "end": return _context.stop();
9992 }
9993 }, _callee);
9994 }));
9995 return function updateMask() {
9996 return _ref2.apply(this, arguments);
9997 };
9998 }();
9999 var _onPositionChange = /*#__PURE__*/ function() {
10000 var _ref3 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee2(args) {
10001 return import_regenerator$3.default.wrap(function(_context2) {
10002 while (1) switch (_context2.prev = _context2.next) {
10003 case 0:
10004 position.current = {
10005 x: args.x,
10006 y: args.y
10007 };
10008 _context2.next = 1;
10009 return updateMask();
10010 case 1: setPosition(position.current);
10011 case 2:
10012 case "end": return _context2.stop();
10013 }
10014 }, _callee2);
10015 }));
10016 return function onPositionChange(_x) {
10017 return _ref3.apply(this, arguments);
10018 };
10019 }();
10020 var onImageChange = /*#__PURE__*/ function() {
10021 var _ref4 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee3() {
10022 return import_regenerator$3.default.wrap(function(_context3) {
10023 while (1) switch (_context3.prev = _context3.next) {
10024 case 0:
10025 imageSize = {
10026 width: imageSize.width * scale,
10027 height: imageSize.height * scale
10028 };
10029 _context3.next = 1;
10030 return updateMask();
10031 case 1: setImageSize(imageSize);
10032 case 2:
10033 case "end": return _context3.stop();
10034 }
10035 }, _callee3);
10036 }));
10037 return function onImageChange() {
10038 return _ref4.apply(this, arguments);
10039 };
10040 }();
10041 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10042 alignItems: "center",
10043 spacing: .5,
10044 flexGrow: 1
10045 }, /*#__PURE__*/ react.default.createElement(import_dist.default, {
10046 ref: cropperRef,
10047 image: editImage.url,
10048 style: {
10049 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%)",
10050 backgroundSize: "20px 20px",
10051 backgroundPosition: "0 0, 0 10px, 10px -10px, -10px 0px",
10052 outline: "2px dashed #000",
10053 marginTop: "12px"
10054 },
10055 color: [
10056 0,
10057 0,
10058 0,
10059 .9
10060 ],
10061 rotate: 0,
10062 border: 0,
10063 allowZoomOut: true,
10064 backgroundColor: "transparent",
10065 showGrid: true,
10066 onImageChange,
10067 onPositionChange: function onPositionChange(args) {
10068 return _onPositionChange(args);
10069 },
10070 width,
10071 height,
10072 scale
10073 }));
10074 };
10075 OutPaintingContent.propTypes = {
10076 scale: import_prop_types$12.default.number.isRequired,
10077 setMask: import_prop_types$12.default.func.isRequired,
10078 editImage: import_prop_types$12.default.object.isRequired,
10079 aspectRatio: import_prop_types$12.default.string.isRequired,
10080 setImageSize: import_prop_types$12.default.func.isRequired,
10081 setPosition: import_prop_types$12.default.func.isRequired
10082 };
10083
10084 //#endregion
10085 //#region modules/ai/assets/js/editor/pages/form-media/views/out-painting/hooks/use-out-painting.js
10086 init_api();
10087 var useOutPainting = function useOutPainting(initialValue) {
10088 return useImagePrompt(function fetchAction(payload) {
10089 return getImageToImageOutPainting(payload);
10090 }, initialValue);
10091 };
10092
10093 //#endregion
10094 //#region modules/ai/assets/js/editor/pages/form-media/views/out-painting/index.js
10095 init_defineProperty();
10096 init_asyncToGenerator();
10097 init_slicedToArray();
10098 init_requests_ids();
10099 var OutPainting = function OutPainting() {
10100 var _useState2 = _slicedToArray((0, react.useState)({
10101 width: 0,
10102 height: 0
10103 }), 2);
10104 var imageSize = _useState2[0];
10105 var setImageSize = _useState2[1];
10106 var _useState4 = _slicedToArray((0, react.useState)({
10107 x: .5,
10108 y: .5
10109 }), 2);
10110 var position = _useState4[0];
10111 var setPosition = _useState4[1];
10112 var _useState6 = _slicedToArray((0, react.useState)(""), 2);
10113 var mask = _useState6[0];
10114 var setMask = _useState6[1];
10115 var setGenerate = useRequestIds().setGenerate;
10116 var _useEditImage = useEditImage();
10117 var editImage = _useEditImage.editImage;
10118 var initialAspectRatio = _useEditImage.aspectRatio;
10119 var _usePromptSettings = usePromptSettings({ aspectRatio: initialAspectRatio });
10120 var settings = _usePromptSettings.settings;
10121 var updateSettings = _usePromptSettings.updateSettings;
10122 var _useImageActions = useImageActions();
10123 var use = _useImageActions.use;
10124 var edit = _useImageActions.edit;
10125 var isUploading = _useImageActions.isLoading;
10126 var _useOutPainting = useOutPainting();
10127 var data = _useOutPainting.data;
10128 var send = _useOutPainting.send;
10129 var isGenerating = _useOutPainting.isLoading;
10130 var error = _useOutPainting.error;
10131 var isLoading = isGenerating || isUploading;
10132 var generatedAspectRatio = (0, react.useMemo)(function() {
10133 return settings[IMAGE_RATIO];
10134 }, [data === null || data === void 0 ? void 0 : data.result]);
10135 var hasGeneratedResult = !!(data !== null && data !== void 0 && data.result);
10136 var handleSubmit = /*#__PURE__*/ function() {
10137 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee(event) {
10138 var imageBase64;
10139 return import_regenerator$3.default.wrap(function(_context) {
10140 while (1) switch (_context.prev = _context.next) {
10141 case 0:
10142 event.preventDefault();
10143 setGenerate();
10144 _context.next = 1;
10145 return fetchImageAsBase64(editImage.url);
10146 case 1:
10147 imageBase64 = _context.sent;
10148 send({
10149 settings,
10150 image: editImage,
10151 mask,
10152 size: imageSize,
10153 position,
10154 image_base64: imageBase64
10155 });
10156 case 2:
10157 case "end": return _context.stop();
10158 }
10159 }, _callee);
10160 }));
10161 return function handleSubmit(_x) {
10162 return _ref.apply(this, arguments);
10163 };
10164 }();
10165 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, {
10166 primary: (0, _wordpress_i18n.__)("Expand Image", "elementor"),
10167 secondary: (0, _wordpress_i18n.__)("Position image in it’s new size to generate content around the edges.", "elementor")
10168 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
10169 error,
10170 onRetry: handleSubmit
10171 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(ImageRatioSelect, {
10172 disabled: isLoading || hasGeneratedResult,
10173 value: settings[IMAGE_RATIO],
10174 onChange: function onChange(event) {
10175 return updateSettings(_defineProperty({}, IMAGE_RATIO, event.target.value));
10176 }
10177 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.FormControl, { sx: {
10178 width: "100%",
10179 mb: 2.5
10180 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Slider, {
10181 marks: true,
10182 id: "zoom",
10183 name: "zoom",
10184 max: 1,
10185 min: .1,
10186 step: .1,
10187 color: "secondary",
10188 defaultValue: 1,
10189 disabled: isLoading || hasGeneratedResult,
10190 valueLabelDisplay: "auto",
10191 "aria-labelledby": "image-size-slider",
10192 "aria-label": (0, _wordpress_i18n.__)("Reference strength", "elementor"),
10193 onChange: function onChange(_, value) {
10194 return updateSettings(_defineProperty({}, IMAGE_ZOOM, value));
10195 }
10196 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
10197 id: "image-size-slider",
10198 variant: "caption",
10199 gutterBottom: true
10200 }, (0, _wordpress_i18n.__)("Original image size", "elementor"))), data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10201 gap: 2,
10202 sx: { my: 2.5 }
10203 }, /*#__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, {
10204 onUseImage: use,
10205 onEditImage: edit,
10206 images: data.result,
10207 aspectRatio: generatedAspectRatio
10208 }) : /*#__PURE__*/ react.default.createElement(OutPaintingContent, {
10209 setMask,
10210 editImage,
10211 scale: settings[IMAGE_ZOOM],
10212 aspectRatio: settings[IMAGE_RATIO],
10213 setImageSize,
10214 setPosition
10215 })));
10216 };
10217
10218 //#endregion
10219 //#region modules/ai/assets/js/editor/pages/form-media/views/variations/hooks/use-image-to-image.js
10220 init_api();
10221 var useImageToImage = function useImageToImage(initialValue) {
10222 return useImagePrompt(function fetchAction(payload) {
10223 return getImageToImageGeneration(payload);
10224 }, initialValue);
10225 };
10226
10227 //#endregion
10228 //#region modules/ai/assets/js/editor/pages/form-media/views/variations/index.js
10229 init_slicedToArray();
10230 init_requests_ids();
10231 var IMAGE_WEIGHT_DEFAULT = 45;
10232 var Variations = function Variations() {
10233 var _data$result;
10234 var prompt = _slicedToArray((0, react.useState)(""), 1)[0];
10235 var setGenerate = useRequestIds().setGenerate;
10236 var _useEditImage = useEditImage();
10237 var editImage = _useEditImage.editImage;
10238 var initialAspectRatio = _useEditImage.aspectRatio;
10239 var settings = usePromptSettings({
10240 aspectRatio: initialAspectRatio,
10241 imageWeight: IMAGE_WEIGHT_DEFAULT
10242 }).settings;
10243 var _useImageToImage = useImageToImage();
10244 var data = _useImageToImage.data;
10245 var send = _useImageToImage.send;
10246 var isGenerating = _useImageToImage.isLoading;
10247 var error = _useImageToImage.error;
10248 var _useImageActions = useImageActions();
10249 var use = _useImageActions.use;
10250 var edit = _useImageActions.edit;
10251 var isUploading = _useImageActions.isLoading;
10252 var isLoading = isGenerating || isUploading;
10253 var generatedAspectRatio = (0, react.useMemo)(function() {
10254 return settings[IMAGE_RATIO];
10255 }, [data === null || data === void 0 ? void 0 : data.result]);
10256 var handleSubmit = function handleSubmit(event) {
10257 event.preventDefault();
10258 setGenerate();
10259 send({
10260 prompt,
10261 settings,
10262 image: editImage
10263 });
10264 };
10265 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, {
10266 primary: (0, _wordpress_i18n.__)("Variations", "elementor"),
10267 secondary: (0, _wordpress_i18n.__)("Create new versions of the original image.", "elementor")
10268 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
10269 error,
10270 onRetry: handleSubmit
10271 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
10272 display: "flex",
10273 alignItems: "center",
10274 justifyContent: "center",
10275 bgcolor: "action.selected"
10276 } }, /*#__PURE__*/ react.default.createElement("img", {
10277 src: (editImage === null || editImage === void 0 ? void 0 : editImage.image_url) || (editImage === null || editImage === void 0 ? void 0 : editImage.url),
10278 alt: prompt,
10279 style: {
10280 width: "auto",
10281 height: "auto",
10282 maxWidth: "100%",
10283 maxHeight: 166,
10284 objectFit: "contained"
10285 }
10286 })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10287 gap: 2,
10288 sx: { my: 2.5 }
10289 }, (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, {
10290 images: data.result,
10291 aspectRatio: generatedAspectRatio,
10292 onUseImage: use,
10293 onEditImage: edit
10294 }) : /*#__PURE__*/ react.default.createElement(ImagesPlaceholder, null)));
10295 };
10296 Variations.propTypes = {};
10297
10298 //#endregion
10299 //#region modules/ai/assets/js/editor/pages/form-media/views/replace-background/hooks/use-replace-background.js
10300 init_api();
10301 var useReplaceBackground = function useReplaceBackground(initialValue) {
10302 return useImagePrompt(function fetchAction(payload) {
10303 return getImageToImageReplaceBackground(payload);
10304 }, initialValue);
10305 };
10306
10307 //#endregion
10308 //#region modules/ai/assets/js/editor/pages/form-media/views/replace-background/index.js
10309 init_slicedToArray();
10310 init_requests_ids();
10311 var ReplaceBackground = function ReplaceBackground() {
10312 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
10313 var prompt = _useState2[0];
10314 var setPrompt = _useState2[1];
10315 var setGenerate = useRequestIds().setGenerate;
10316 var editImage = useEditImage().editImage;
10317 var _useImageActions = useImageActions();
10318 var use = _useImageActions.use;
10319 var edit = _useImageActions.edit;
10320 var isUploading = _useImageActions.isLoading;
10321 var _useReplaceBackground = useReplaceBackground();
10322 var data = _useReplaceBackground.data;
10323 var send = _useReplaceBackground.send;
10324 var isGenerating = _useReplaceBackground.isLoading;
10325 var error = _useReplaceBackground.error;
10326 var navigate = useLocation().navigate;
10327 var isLoading = isGenerating || isUploading;
10328 var handleSubmit = function handleSubmit(event) {
10329 event.preventDefault();
10330 setGenerate();
10331 send({
10332 prompt,
10333 image: editImage
10334 });
10335 };
10336 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, {
10337 primary: (0, _wordpress_i18n.__)("Replace Background", "elementor"),
10338 secondary: (0, _wordpress_i18n.__)("Generate a new background with a prompt.", "elementor")
10339 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
10340 error,
10341 onRetry: handleSubmit
10342 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(PromptField, {
10343 value: prompt,
10344 disabled: isLoading,
10345 onChange: setPrompt,
10346 placeholder: (0, _wordpress_i18n.__)("Describe what you want to generate in the background (English only)", "elementor")
10347 }), /*#__PURE__*/ react.default.createElement(GenerateSubmit, {
10348 disabled: isLoading || "" === prompt,
10349 color: data !== null && data !== void 0 && data.result ? "secondary" : "primary"
10350 }, 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, {
10351 disabled: isLoading,
10352 onClick: function onClick() {
10353 return navigate(LOCATIONS.GENERATE);
10354 }
10355 }))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isLoading }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
10356 onUseImage: use,
10357 onEditImage: edit,
10358 images: data.result,
10359 aspectRatio: editImage.aspectRatio
10360 }) : /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
10361 src: editImage.url,
10362 alt: editImage.alt,
10363 style: {
10364 width: editImage.width,
10365 height: editImage.height
10366 }
10367 }))));
10368 };
10369
10370 //#endregion
10371 //#region modules/ai/assets/js/editor/pages/form-media/views/remove-background/hooks/use-remove-background.js
10372 init_api();
10373 var useRemoveBackground = function useRemoveBackground(initialValue) {
10374 return useImagePrompt(function fetchAction(payload) {
10375 return getImageToImageRemoveBackground(payload);
10376 }, initialValue);
10377 };
10378
10379 //#endregion
10380 //#region modules/ai/assets/js/editor/pages/form-media/views/remove-background/index.js
10381 init_requests_ids();
10382 var RemoveBackground = function RemoveBackground() {
10383 var editImage = useEditImage().editImage;
10384 var setGenerate = useRequestIds().setGenerate;
10385 var _useImageActions = useImageActions();
10386 var use = _useImageActions.use;
10387 var edit = _useImageActions.edit;
10388 var isUploading = _useImageActions.isLoading;
10389 var _useRemoveBackground = useRemoveBackground();
10390 var data = _useRemoveBackground.data;
10391 var send = _useRemoveBackground.send;
10392 var isGenerating = _useRemoveBackground.isLoading;
10393 var error = _useRemoveBackground.error;
10394 var navigate = useLocation().navigate;
10395 var isLoading = isGenerating || isUploading;
10396 var _useImageSize = useImageSize(editImage.aspectRatio);
10397 var width = _useImageSize.width;
10398 var height = _useImageSize.height;
10399 var handleSubmit = function handleSubmit(event) {
10400 event.preventDefault();
10401 setGenerate();
10402 send({ image: editImage });
10403 };
10404 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, {
10405 primary: (0, _wordpress_i18n.__)("Remove Background", "elementor"),
10406 secondary: (0, _wordpress_i18n.__)("Create an image of the subject with a transparent background", "elementor")
10407 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
10408 error,
10409 onRetry: handleSubmit
10410 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(NewPromptButton, {
10411 variant: "contained",
10412 disabled: isLoading,
10413 onClick: function onClick() {
10414 return navigate(LOCATIONS.GENERATE);
10415 }
10416 }) : /*#__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, {
10417 transparentContainer: true,
10418 onUseImage: use,
10419 onEditImage: edit,
10420 images: data.result,
10421 aspectRatio: editImage.aspectRatio
10422 })) : /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
10423 src: editImage.url,
10424 alt: editImage.alt,
10425 style: {
10426 width,
10427 height
10428 }
10429 })))));
10430 };
10431
10432 //#endregion
10433 //#region modules/ai/assets/js/editor/pages/form-media/views/cleanup/cleanup-content.js
10434 init_asyncToGenerator();
10435 init_slicedToArray();
10436 var STROKE_SELECT_WIDTH = 120;
10437 var BRUSH_COLOR = "rgba(255, 255, 255)";
10438 var CANVAS_COLOR = "rgba(0, 0, 0)";
10439 var StyledUndoIcon = (0, _elementor_ui.withDirection)(UndoIcon);
10440 var StyledRedoIcon = (0, _elementor_ui.withDirection)(RedoIcon);
10441 var BrushCursor = (0, _elementor_ui.styled)(_elementor_ui.Box, { shouldForwardProp: function shouldForwardProp(prop) {
10442 return "size" === prop;
10443 } })(function(_ref) {
10444 var theme = _ref.theme;
10445 var size = _ref.size;
10446 return {
10447 position: "absolute",
10448 width: size,
10449 height: size,
10450 borderRadius: "50%",
10451 backgroundColor: BRUSH_COLOR,
10452 pointerEvents: "none",
10453 transform: "translate(".concat("rtl" === theme.direction ? "50%" : "-50%", ", -50%)"),
10454 border: "1px solid #fff"
10455 };
10456 });
10457 var BrishSizeIcon = (0, _elementor_ui.styled)(_elementor_ui.Box, { shouldForwardProp: function shouldForwardProp(prop) {
10458 return "size" === prop;
10459 } })(function(_ref2) {
10460 var theme = _ref2.theme;
10461 var size = _ref2.size;
10462 return {
10463 width: size / 2,
10464 height: size / 2,
10465 borderRadius: "50%",
10466 backgroundColor: theme.palette.secondary.main
10467 };
10468 });
10469 var CleanupContent = function CleanupContent(_ref3) {
10470 var editImage = _ref3.editImage;
10471 var setMask = _ref3.setMask;
10472 var setIsCanvasChanged = _ref3.setIsCanvasChanged;
10473 var canvasWidth = _ref3.width;
10474 var canvasHeight = _ref3.height;
10475 var sketchRef = (0, react.useRef)();
10476 var _useState2 = _slicedToArray((0, react.useState)(30), 2);
10477 var stroke = _useState2[0];
10478 var setStroke = _useState2[1];
10479 var brushCursorRef = (0, react.useRef)();
10480 (0, react.useEffect)(function() {
10481 var canvas = document.querySelector(".eui-in-painting-canvas");
10482 var positionElement = function positionElement(e) {
10483 var _canvas$getBoundingCl = canvas.getBoundingClientRect();
10484 var left = _canvas$getBoundingCl.left;
10485 var top = _canvas$getBoundingCl.top;
10486 var width = _canvas$getBoundingCl.width;
10487 var height = _canvas$getBoundingCl.height;
10488 var x = e.clientX - left;
10489 var y = e.clientY - top;
10490 if (x > 0 && x < width && y > 0 && y < height) {
10491 brushCursorRef.current.style.left = "".concat(x, "px");
10492 brushCursorRef.current.style.top = "".concat(y, "px");
10493 }
10494 };
10495 window.addEventListener("mousemove", positionElement);
10496 return function() {
10497 window.removeEventListener("mousemove", positionElement);
10498 };
10499 }, [stroke]);
10500 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10501 alignItems: "flex-start",
10502 spacing: .5,
10503 flexGrow: 1
10504 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10505 width: "100%",
10506 direction: "row",
10507 spacing: 3,
10508 alignSelf: "center",
10509 justifyContent: "center",
10510 sx: { mb: 2.5 }
10511 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10512 direction: "row",
10513 gap: 1
10514 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: (0, _wordpress_i18n.__)("Undo", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
10515 variant: "outlined",
10516 color: "secondary",
10517 onClick: function onClick() {
10518 return sketchRef.current.undo();
10519 },
10520 sx: { px: 0 }
10521 }, /*#__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, {
10522 variant: "outlined",
10523 color: "secondary",
10524 onClick: function onClick() {
10525 return sketchRef.current.redo();
10526 },
10527 sx: { px: 0 }
10528 }, /*#__PURE__*/ react.default.createElement(StyledRedoIcon, null)))), /*#__PURE__*/ react.default.createElement(_elementor_ui.FormControl, {
10529 size: "small",
10530 color: "secondary",
10531 sx: { minWidth: STROKE_SELECT_WIDTH }
10532 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.InputLabel, { id: "stroke" }, "Stroke"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Select, {
10533 autoWidth: true,
10534 label: "Stroke",
10535 value: stroke,
10536 id: "demo-simple-select",
10537 labelId: "demo-simple-select-label",
10538 onChange: function onChange(e) {
10539 return setStroke(e.target.value);
10540 },
10541 MenuProps: {
10542 PaperProps: { sx: { maxWidth: STROKE_SELECT_WIDTH } },
10543 MenuListProps: { sx: { minWidth: STROKE_SELECT_WIDTH } }
10544 },
10545 sx: { "& .MuiSelect-select .MuiListItemIcon-root": {
10546 mr: .25,
10547 width: "initial",
10548 minWidth: "initial",
10549 justifyContent: "flex-start"
10550 } }
10551 }, [
10552 10,
10553 20,
10554 30,
10555 40,
10556 50
10557 ].map(function(value) {
10558 return /*#__PURE__*/ react.default.createElement(_elementor_ui.MenuItem, {
10559 key: "stroke-width-option-" + value,
10560 value
10561 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10562 direction: "row",
10563 alignItems: "center",
10564 gap: 1
10565 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemIcon, { sx: {
10566 width: 30,
10567 display: "flex",
10568 justifyContent: "center"
10569 } }, /*#__PURE__*/ react.default.createElement(BrishSizeIcon, { size: value })), /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemText, null, value)));
10570 })))), /*#__PURE__*/ react.default.createElement("div", { style: {
10571 margin: "0 auto",
10572 position: "relative",
10573 cursor: "none",
10574 overflow: "hidden"
10575 } }, /*#__PURE__*/ react.default.createElement(BrushCursor, {
10576 ref: brushCursorRef,
10577 size: stroke
10578 }), /*#__PURE__*/ react.default.createElement(ReactSketchCanvas, {
10579 className: "eui-in-painting-canvas",
10580 withViewBox: true,
10581 ref: sketchRef,
10582 height: canvasHeight + "px",
10583 width: canvasWidth + "px",
10584 strokeWidth: stroke,
10585 strokeColor: BRUSH_COLOR,
10586 canvasColor: CANVAS_COLOR,
10587 backgroundImage: editImage.url,
10588 onStroke: function onStroke() {
10589 return setIsCanvasChanged(true);
10590 },
10591 onChange: /*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee() {
10592 var svg;
10593 return import_regenerator$3.default.wrap(function(_context) {
10594 while (1) switch (_context.prev = _context.next) {
10595 case 0:
10596 _context.next = 1;
10597 return sketchRef.current.exportSvg();
10598 case 1:
10599 svg = _context.sent;
10600 setMask(svg);
10601 case 2:
10602 case "end": return _context.stop();
10603 }
10604 }, _callee);
10605 }))
10606 })));
10607 };
10608 CleanupContent.propTypes = {
10609 setMask: import_prop_types$12.default.func.isRequired,
10610 setIsCanvasChanged: import_prop_types$12.default.func.isRequired,
10611 width: import_prop_types$12.default.number.isRequired,
10612 height: import_prop_types$12.default.number.isRequired,
10613 editImage: import_prop_types$12.default.object.isRequired
10614 };
10615
10616 //#endregion
10617 //#region modules/ai/assets/js/editor/pages/form-media/views/cleanup/hooks/use-cleanup.js
10618 init_api();
10619 var useCleanup = function useCleanup(initialValue) {
10620 return useImagePrompt(function fetchAction(payload) {
10621 return getImageToImageMaskCleanup(payload);
10622 }, initialValue);
10623 };
10624
10625 //#endregion
10626 //#region modules/ai/assets/js/editor/pages/form-media/views/cleanup/index.js
10627 init_asyncToGenerator();
10628 init_slicedToArray();
10629 init_requests_ids();
10630 var Cleanup = function Cleanup() {
10631 var setGenerate = useRequestIds().setGenerate;
10632 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
10633 var mask = _useState2[0];
10634 var setMask = _useState2[1];
10635 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
10636 var isCanvasChanged = _useState4[0];
10637 var setIsCanvasChanged = _useState4[1];
10638 var _usePromptSettings = usePromptSettings();
10639 var settings = _usePromptSettings.settings;
10640 var resetSettings = _usePromptSettings.resetSettings;
10641 var _useEditImage = useEditImage();
10642 var editImage = _useEditImage.editImage;
10643 var width = _useEditImage.width;
10644 var height = _useEditImage.height;
10645 var _useImageActions = useImageActions();
10646 var use = _useImageActions.use;
10647 var edit = _useImageActions.edit;
10648 var isUploading = _useImageActions.isLoading;
10649 var _useCleanup = useCleanup();
10650 var data = _useCleanup.data;
10651 var send = _useCleanup.send;
10652 var isGenerating = _useCleanup.isLoading;
10653 var error = _useCleanup.error;
10654 var reset = _useCleanup.reset;
10655 var isLoading = isGenerating || isUploading;
10656 var handleSubmit = /*#__PURE__*/ function() {
10657 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee(event) {
10658 return import_regenerator$3.default.wrap(function(_context) {
10659 while (1) switch (_context.prev = _context.next) {
10660 case 0:
10661 event.preventDefault();
10662 setGenerate();
10663 send({
10664 settings,
10665 image: editImage,
10666 mask
10667 });
10668 case 1:
10669 case "end": return _context.stop();
10670 }
10671 }, _callee);
10672 }));
10673 return function handleSubmit(_x) {
10674 return _ref.apply(this, arguments);
10675 };
10676 }();
10677 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, {
10678 primary: (0, _wordpress_i18n.__)("Cleanup", "elementor"),
10679 secondary: (0, _wordpress_i18n.__)("Remove unwanted area from your image.", "elementor")
10680 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
10681 error,
10682 onRetry: handleSubmit
10683 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10684 gap: 2,
10685 sx: { my: 2.5 }
10686 }, /*#__PURE__*/ react.default.createElement(GenerateAgainSubmit, { disabled: isLoading }), /*#__PURE__*/ react.default.createElement(NewPromptButton, {
10687 disabled: isLoading,
10688 onClick: function onClick() {
10689 resetSettings();
10690 reset();
10691 }
10692 })) : /*#__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, {
10693 images: data.result,
10694 aspectRatio: editImage.aspectRatio,
10695 onUseImage: use,
10696 onEditImage: edit
10697 }) : /*#__PURE__*/ react.default.createElement(CleanupContent, {
10698 editImage,
10699 width,
10700 height,
10701 setMask,
10702 setIsCanvasChanged
10703 })));
10704 };
10705
10706 //#endregion
10707 //#region modules/ai/assets/js/editor/pages/form-media/views/generate/hooks/use-text-to-image.js
10708 init_api();
10709 var useTextToImage = function useTextToImage(initialValue) {
10710 return useImagePrompt(getTextToImageGeneration, initialValue);
10711 };
10712
10713 //#endregion
10714 //#region node_modules/react-colorful/dist/index.mjs
10715 function u() {
10716 return (u = Object.assign || function(e) {
10717 for (var r = 1; r < arguments.length; r++) {
10718 var t = arguments[r];
10719 for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
10720 }
10721 return e;
10722 }).apply(this, arguments);
10723 }
10724 function c(e, r) {
10725 if (null == e) return {};
10726 var t;
10727 var n;
10728 var o = {};
10729 var a = Object.keys(e);
10730 for (n = 0; n < a.length; n++) r.indexOf(t = a[n]) >= 0 || (o[t] = e[t]);
10731 return o;
10732 }
10733 function i(e) {
10734 var t = (0, react$1.useRef)(e);
10735 var n = (0, react$1.useRef)(function(e) {
10736 t.current && t.current(e);
10737 });
10738 return t.current = e, n.current;
10739 }
10740 var s = function(e, r, t) {
10741 return void 0 === r && (r = 0), void 0 === t && (t = 1), e > t ? t : e < r ? r : e;
10742 };
10743 var f = function(e) {
10744 return "touches" in e;
10745 };
10746 var v = function(e) {
10747 return e && e.ownerDocument.defaultView || self;
10748 };
10749 var d = function(e, r, t) {
10750 var n = e.getBoundingClientRect();
10751 var o = f(r) ? function(e, r) {
10752 for (var t = 0; t < e.length; t++) if (e[t].identifier === r) return e[t];
10753 return e[0];
10754 }(r.touches, t) : r;
10755 return {
10756 left: s((o.pageX - (n.left + v(e).pageXOffset)) / n.width),
10757 top: s((o.pageY - (n.top + v(e).pageYOffset)) / n.height)
10758 };
10759 };
10760 var h = function(e) {
10761 !f(e) && e.preventDefault();
10762 };
10763 var m = react$1.default.memo(function(o) {
10764 var a = o.onMove;
10765 var l = o.onKey;
10766 var s = c(o, ["onMove", "onKey"]);
10767 var m = (0, react$1.useRef)(null);
10768 var g = i(a);
10769 var p = i(l);
10770 var b = (0, react$1.useRef)(null);
10771 var _ = (0, react$1.useRef)(!1);
10772 var x = (0, react$1.useMemo)(function() {
10773 var e = function(e) {
10774 h(e), (f(e) ? e.touches.length > 0 : e.buttons > 0) && m.current ? g(d(m.current, e, b.current)) : t(!1);
10775 };
10776 var r = function() {
10777 return t(!1);
10778 };
10779 function t(t) {
10780 var n = _.current;
10781 var o = v(m.current);
10782 var a = t ? o.addEventListener : o.removeEventListener;
10783 a(n ? "touchmove" : "mousemove", e), a(n ? "touchend" : "mouseup", r);
10784 }
10785 return [
10786 function(e) {
10787 var r = e.nativeEvent;
10788 var n = m.current;
10789 if (n && (h(r), !function(e, r) {
10790 return r && !f(e);
10791 }(r, _.current) && n)) {
10792 if (f(r)) {
10793 _.current = !0;
10794 var o = r.changedTouches || [];
10795 o.length && (b.current = o[0].identifier);
10796 }
10797 n.focus(), g(d(n, r, b.current)), t(!0);
10798 }
10799 },
10800 function(e) {
10801 var r = e.which || e.keyCode;
10802 r < 37 || r > 40 || (e.preventDefault(), p({
10803 left: 39 === r ? .05 : 37 === r ? -.05 : 0,
10804 top: 40 === r ? .05 : 38 === r ? -.05 : 0
10805 }));
10806 },
10807 t
10808 ];
10809 }, [p, g]);
10810 var C = x[0];
10811 var E = x[1];
10812 var H = x[2];
10813 return (0, react$1.useEffect)(function() {
10814 return H;
10815 }, [H]), react$1.default.createElement("div", u({}, s, {
10816 onTouchStart: C,
10817 onMouseDown: C,
10818 className: "react-colorful__interactive",
10819 ref: m,
10820 onKeyDown: E,
10821 tabIndex: 0,
10822 role: "slider"
10823 }));
10824 });
10825 var g = function(e) {
10826 return e.filter(Boolean).join(" ");
10827 };
10828 var p = function(r) {
10829 var t = r.color;
10830 var n = r.left;
10831 var o = r.top;
10832 var a = void 0 === o ? .5 : o;
10833 var l = g(["react-colorful__pointer", r.className]);
10834 return react$1.default.createElement("div", {
10835 className: l,
10836 style: {
10837 top: 100 * a + "%",
10838 left: 100 * n + "%"
10839 }
10840 }, react$1.default.createElement("div", {
10841 className: "react-colorful__pointer-fill",
10842 style: { backgroundColor: t }
10843 }));
10844 };
10845 var b = function(e, r, t) {
10846 return void 0 === r && (r = 0), void 0 === t && (t = Math.pow(10, r)), Math.round(t * e) / t;
10847 };
10848 var _ = {
10849 grad: .9,
10850 turn: 360,
10851 rad: 360 / (2 * Math.PI)
10852 };
10853 var x = function(e) {
10854 return L(C(e));
10855 };
10856 var C = function(e) {
10857 return "#" === e[0] && (e = e.substring(1)), e.length < 6 ? {
10858 r: parseInt(e[0] + e[0], 16),
10859 g: parseInt(e[1] + e[1], 16),
10860 b: parseInt(e[2] + e[2], 16),
10861 a: 4 === e.length ? b(parseInt(e[3] + e[3], 16) / 255, 2) : 1
10862 } : {
10863 r: parseInt(e.substring(0, 2), 16),
10864 g: parseInt(e.substring(2, 4), 16),
10865 b: parseInt(e.substring(4, 6), 16),
10866 a: 8 === e.length ? b(parseInt(e.substring(6, 8), 16) / 255, 2) : 1
10867 };
10868 };
10869 var w = function(e) {
10870 return K(I(e));
10871 };
10872 var y = function(e) {
10873 var r = e.s;
10874 var t = e.v;
10875 var n = e.a;
10876 var o = (200 - r) * t / 100;
10877 return {
10878 h: b(e.h),
10879 s: b(o > 0 && o < 200 ? r * t / 100 / (o <= 100 ? o : 200 - o) * 100 : 0),
10880 l: b(o / 2),
10881 a: b(n, 2)
10882 };
10883 };
10884 var q = function(e) {
10885 var r = y(e);
10886 return "hsl(" + r.h + ", " + r.s + "%, " + r.l + "%)";
10887 };
10888 var I = function(e) {
10889 var r = e.h;
10890 var t = e.s;
10891 var n = e.v;
10892 var o = e.a;
10893 r = r / 360 * 6, t /= 100, n /= 100;
10894 var a = Math.floor(r);
10895 var l = n * (1 - t);
10896 var u = n * (1 - (r - a) * t);
10897 var c = n * (1 - (1 - r + a) * t);
10898 var i = a % 6;
10899 return {
10900 r: b(255 * [
10901 n,
10902 u,
10903 l,
10904 l,
10905 c,
10906 n
10907 ][i]),
10908 g: b(255 * [
10909 c,
10910 n,
10911 n,
10912 u,
10913 l,
10914 l
10915 ][i]),
10916 b: b(255 * [
10917 l,
10918 l,
10919 c,
10920 n,
10921 n,
10922 u
10923 ][i]),
10924 a: b(o, 2)
10925 };
10926 };
10927 var D = function(e) {
10928 var r = e.toString(16);
10929 return r.length < 2 ? "0" + r : r;
10930 };
10931 var K = function(e) {
10932 var r = e.r;
10933 var t = e.g;
10934 var n = e.b;
10935 var o = e.a;
10936 var a = o < 1 ? D(b(255 * o)) : "";
10937 return "#" + D(r) + D(t) + D(n) + a;
10938 };
10939 var L = function(e) {
10940 var r = e.r;
10941 var t = e.g;
10942 var n = e.b;
10943 var o = e.a;
10944 var a = Math.max(r, t, n);
10945 var l = a - Math.min(r, t, n);
10946 var u = l ? a === r ? (t - n) / l : a === t ? 2 + (n - r) / l : 4 + (r - t) / l : 0;
10947 return {
10948 h: b(60 * (u < 0 ? u + 6 : u)),
10949 s: b(a ? l / a * 100 : 0),
10950 v: b(a / 255 * 100),
10951 a: o
10952 };
10953 };
10954 var S = react$1.default.memo(function(r) {
10955 var t = r.hue;
10956 var n = r.onChange;
10957 var o = g(["react-colorful__hue", r.className]);
10958 return react$1.default.createElement("div", { className: o }, react$1.default.createElement(m, {
10959 onMove: function(e) {
10960 n({ h: 360 * e.left });
10961 },
10962 onKey: function(e) {
10963 n({ h: s(t + 360 * e.left, 0, 360) });
10964 },
10965 "aria-label": "Hue",
10966 "aria-valuenow": b(t),
10967 "aria-valuemax": "360",
10968 "aria-valuemin": "0"
10969 }, react$1.default.createElement(p, {
10970 className: "react-colorful__hue-pointer",
10971 left: t / 360,
10972 color: q({
10973 h: t,
10974 s: 100,
10975 v: 100,
10976 a: 1
10977 })
10978 })));
10979 });
10980 var T = react$1.default.memo(function(r) {
10981 var t = r.hsva;
10982 var n = r.onChange;
10983 var o = { backgroundColor: q({
10984 h: t.h,
10985 s: 100,
10986 v: 100,
10987 a: 1
10988 }) };
10989 return react$1.default.createElement("div", {
10990 className: "react-colorful__saturation",
10991 style: o
10992 }, react$1.default.createElement(m, {
10993 onMove: function(e) {
10994 n({
10995 s: 100 * e.left,
10996 v: 100 - 100 * e.top
10997 });
10998 },
10999 onKey: function(e) {
11000 n({
11001 s: s(t.s + 100 * e.left, 0, 100),
11002 v: s(t.v - 100 * e.top, 0, 100)
11003 });
11004 },
11005 "aria-label": "Color",
11006 "aria-valuetext": "Saturation " + b(t.s) + "%, Brightness " + b(t.v) + "%"
11007 }, react$1.default.createElement(p, {
11008 className: "react-colorful__saturation-pointer",
11009 top: 1 - t.v / 100,
11010 left: t.s / 100,
11011 color: q(t)
11012 })));
11013 });
11014 var F = function(e, r) {
11015 if (e === r) return !0;
11016 for (var t in e) if (e[t] !== r[t]) return !1;
11017 return !0;
11018 };
11019 var X = function(e, r) {
11020 return e.toLowerCase() === r.toLowerCase() || F(C(e), C(r));
11021 };
11022 function Y(e, t, l) {
11023 var u = i(l);
11024 var c = (0, react$1.useState)(function() {
11025 return e.toHsva(t);
11026 });
11027 var s = c[0];
11028 var f = c[1];
11029 var v = (0, react$1.useRef)({
11030 color: t,
11031 hsva: s
11032 });
11033 (0, react$1.useEffect)(function() {
11034 if (!e.equal(t, v.current.color)) {
11035 var r = e.toHsva(t);
11036 v.current = {
11037 hsva: r,
11038 color: t
11039 }, f(r);
11040 }
11041 }, [t, e]), (0, react$1.useEffect)(function() {
11042 var r;
11043 F(s, v.current.hsva) || e.equal(r = e.fromHsva(s), v.current.color) || (v.current = {
11044 hsva: s,
11045 color: r
11046 }, u(r));
11047 }, [
11048 s,
11049 e,
11050 u
11051 ]);
11052 return [s, (0, react$1.useCallback)(function(e) {
11053 f(function(r) {
11054 return Object.assign({}, r, e);
11055 });
11056 }, [])];
11057 }
11058 var R;
11059 var V = "undefined" != typeof window ? react$1.useLayoutEffect : react$1.useEffect;
11060 var $ = function() {
11061 return R || ("undefined" != typeof __webpack_nonce__ ? __webpack_nonce__ : void 0);
11062 };
11063 var J = /* @__PURE__ */ new Map();
11064 var Q = function(e) {
11065 V(function() {
11066 var r = e.current ? e.current.ownerDocument : document;
11067 if (void 0 !== r && !J.has(r)) {
11068 var t = r.createElement("style");
11069 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);
11070 var n = $();
11071 n && t.setAttribute("nonce", n), r.head.appendChild(t);
11072 }
11073 }, []);
11074 };
11075 var U = function(t) {
11076 var n = t.className;
11077 var o = t.colorModel;
11078 var a = t.color;
11079 var l = void 0 === a ? o.defaultColor : a;
11080 var i = t.onChange;
11081 var s = c(t, [
11082 "className",
11083 "colorModel",
11084 "color",
11085 "onChange"
11086 ]);
11087 var f = (0, react$1.useRef)(null);
11088 Q(f);
11089 var v = Y(o, l, i);
11090 var d = v[0];
11091 var h = v[1];
11092 var m = g(["react-colorful", n]);
11093 return react$1.default.createElement("div", u({}, s, {
11094 ref: f,
11095 className: m
11096 }), react$1.default.createElement(T, {
11097 hsva: d,
11098 onChange: h
11099 }), react$1.default.createElement(S, {
11100 hue: d.h,
11101 onChange: h,
11102 className: "react-colorful__last-control"
11103 }));
11104 };
11105 var W = {
11106 defaultColor: "000",
11107 toHsva: x,
11108 fromHsva: function(e) {
11109 return w({
11110 h: e.h,
11111 s: e.s,
11112 v: e.v,
11113 a: 1
11114 });
11115 },
11116 equal: X
11117 };
11118 var Z = function(r) {
11119 return react$1.default.createElement(U, u({}, r, { colorModel: W }));
11120 };
11121
11122 //#endregion
11123 //#region modules/ai/assets/js/editor/pages/form-media/components/color-picker.js
11124 init_defineProperty();
11125 init_slicedToArray();
11126 function ownKeys$12(e, r) {
11127 var t = Object.keys(e);
11128 if (Object.getOwnPropertySymbols) {
11129 var o = Object.getOwnPropertySymbols(e);
11130 r && (o = o.filter(function(r) {
11131 return Object.getOwnPropertyDescriptor(e, r).enumerable;
11132 })), t.push.apply(t, o);
11133 }
11134 return t;
11135 }
11136 __name(ownKeys$12, "ownKeys");
11137 function _objectSpread$12(e) {
11138 for (var r = 1; r < arguments.length; r++) {
11139 var t = null != arguments[r] ? arguments[r] : {};
11140 r % 2 ? ownKeys$12(Object(t), !0).forEach(function(r) {
11141 _defineProperty(e, r, t[r]);
11142 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$12(Object(t)).forEach(function(r) {
11143 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
11144 });
11145 }
11146 return e;
11147 }
11148 __name(_objectSpread$12, "_objectSpread");
11149 var ColorInput = function ColorInput(_ref) {
11150 var _elementorCommon$conf;
11151 var _elementorCommon;
11152 var label = _ref.label;
11153 var color = _ref.color;
11154 var onChange = _ref.onChange;
11155 var disabled = _ref.disabled;
11156 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
11157 var isOpened = _useState2[0];
11158 var setIsOpened = _useState2[1];
11159 var anchorEl = (0, react.useRef)();
11160 var _useState4 = _slicedToArray((0, react.useState)(170001), 2);
11161 var zIndex = _useState4[0];
11162 var setZIndex = _useState4[1];
11163 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;
11164 (0, react.useEffect)(function() {
11165 if (anchorEl.current) {
11166 var element = anchorEl.current;
11167 var currentZIndex = 0;
11168 while (element && element !== document.body) {
11169 var computedZIndex = window.getComputedStyle(element).zIndex;
11170 if (computedZIndex !== "auto") {
11171 currentZIndex = parseInt(computedZIndex, 10) || 0;
11172 break;
11173 }
11174 element = element.parentElement;
11175 }
11176 setZIndex(currentZIndex > 0 ? currentZIndex + 1 : 170001);
11177 }
11178 }, [isOpened]);
11179 var handleClick = function handleClick() {
11180 return setIsOpened(true);
11181 };
11182 var handleClose = function handleClose() {
11183 setIsOpened(false);
11184 };
11185 var handleKeyDown = function handleKeyDown(event) {
11186 if ("Enter" === event.key || " " === event.key) {
11187 event.preventDefault();
11188 handleClick();
11189 }
11190 };
11191 var handleTextFieldChange = function handleTextFieldChange(event) {
11192 onChange("#".concat(event.target.value));
11193 };
11194 var handleColorPickerChange = function handleColorPickerChange(colorValue) {
11195 onChange(colorValue);
11196 };
11197 var id = isOpened ? "simple-popover" : void 0;
11198 return /*#__PURE__*/ react.default.createElement("div", {
11199 className: "el-ai-color-input-wrapper",
11200 style: _objectSpread$12({
11201 display: "flex",
11202 alignItems: "center"
11203 }, disabled ? {
11204 pointerEvents: "none",
11205 opacity: .5
11206 } : {})
11207 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.FormLabel, { sx: {
11208 whiteSpace: "nowrap",
11209 flex: 4
11210 } }, label), /*#__PURE__*/ react.default.createElement("button", {
11211 type: "button",
11212 onClick: handleClick,
11213 onKeyDown: handleKeyDown,
11214 style: {
11215 cursor: "pointer",
11216 borderRadius: "4px",
11217 marginRight: "8px",
11218 marginLeft: "8px",
11219 background: color,
11220 width: "100%",
11221 height: "auto",
11222 borderColor: "rgba(0, 0, 0, 0.23)",
11223 borderWidth: "1px",
11224 borderStyle: "solid",
11225 aspectRatio: "1 / 1",
11226 flex: 1.1
11227 },
11228 "aria-describedby": id,
11229 ref: anchorEl
11230 }), /*#__PURE__*/ react.default.createElement(StyledTextField, {
11231 value: color.substring(1, 7),
11232 color: "secondary",
11233 fullWidth: true,
11234 InputProps: {
11235 autoComplete: "off",
11236 color: "secondary",
11237 sx: { height: "100%" },
11238 startAdornment: /*#__PURE__*/ react.default.createElement(_elementor_ui.InputAdornment, { position: "start" }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
11239 variant: "body1",
11240 color: "secondary"
11241 }, "#"))
11242 },
11243 onChange: handleTextFieldChange,
11244 sx: {
11245 flex: 3,
11246 height: "40px"
11247 }
11248 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Popover, {
11249 id,
11250 anchorOrigin: {
11251 vertical: "bottom",
11252 horizontal: isRTL ? "right" : "left"
11253 },
11254 transformOrigin: {
11255 vertical: "top",
11256 horizontal: isRTL ? "right" : "left"
11257 },
11258 onClose: handleClose,
11259 open: isOpened,
11260 anchorEl: anchorEl.current,
11261 style: {
11262 zIndex,
11263 overflow: "hidden"
11264 }
11265 }, /*#__PURE__*/ react.default.createElement("div", {
11266 className: "el-ai-custom-color-picker",
11267 style: {
11268 height: "min-content",
11269 overflow: "hidden"
11270 }
11271 }, /*#__PURE__*/ react.default.createElement(Z, {
11272 color,
11273 onChange: handleColorPickerChange
11274 }))));
11275 };
11276 var StyledTextField = (0, _elementor_ui.styled)(_elementor_ui_TextField.default)(function() {
11277 return { ".wp-admin & .MuiInputBase-input, & .MuiInputBase-input:focus": {
11278 backgroundColor: "initial",
11279 boxShadow: "none",
11280 border: 0,
11281 color: "inherit",
11282 outline: 0,
11283 padding: 0,
11284 fontFamily: "inherit",
11285 minHeight: "2.4375em"
11286 } };
11287 });
11288 ColorInput.propTypes = {
11289 label: import_prop_types$12.default.string,
11290 color: import_prop_types$12.default.string,
11291 onChange: import_prop_types$12.default.func.isRequired,
11292 disabled: import_prop_types$12.default.bool
11293 };
11294
11295 //#endregion
11296 //#region modules/ai/assets/js/editor/pages/form-media/views/product-image-unification/hooks/use-product-image-unification.js
11297 init_api();
11298 var useProductImageUnification = function useProductImageUnification(initialValue) {
11299 return useImagePrompt((0, react.useRef)(function(payload) {
11300 return getProductImageUnification(payload, true);
11301 }).current, initialValue);
11302 };
11303
11304 //#endregion
11305 //#region modules/ai/assets/js/editor/pages/form-media/views/product-image-unification/components/product-image.js
11306 init_defineProperty();
11307 var ProductImage = function ProductImage(_ref) {
11308 var productId = _ref.productId;
11309 var ratio = _ref.ratio;
11310 var bgColor = _ref.bgColor;
11311 var image = _ref.image;
11312 var onUpdate = _ref.onUpdate;
11313 var isUploading = useImageActions().isLoading;
11314 var _useProductImageUnifi = useProductImageUnification(_defineProperty(_defineProperty(_defineProperty({ productId }, IMAGE_RATIO, ratio), IMAGE_BACKGROUND_COLOR, bgColor), "image", image));
11315 var data = _useProductImageUnifi.data;
11316 var isGenerating = _useProductImageUnifi.isLoading;
11317 var error = _useProductImageUnifi.error;
11318 var send = _useProductImageUnifi.send;
11319 var sendUsageData = _useProductImageUnifi.sendUsageData;
11320 (0, react.useEffect)(function() {
11321 if (onUpdate) onUpdate(data, isGenerating || isUploading, error, send, productId, ratio, bgColor, image, sendUsageData);
11322 }, [
11323 data,
11324 isGenerating,
11325 error,
11326 send,
11327 productId,
11328 ratio,
11329 bgColor,
11330 image,
11331 isUploading,
11332 onUpdate,
11333 sendUsageData
11334 ]);
11335 return /*#__PURE__*/ react.default.createElement("div", { style: { visibility: "hidden" } });
11336 };
11337 ProductImage.propTypes = {
11338 productId: import_prop_types$12.default.number,
11339 ratio: import_prop_types$12.default.string,
11340 bgColor: import_prop_types$12.default.string,
11341 image: import_prop_types$12.default.object,
11342 onUpdate: import_prop_types$12.default.func
11343 };
11344
11345 //#endregion
11346 //#region modules/ai/assets/js/editor/pages/form-media/views/product-image-unification/index.js
11347 init_defineProperty();
11348 init_asyncToGenerator();
11349 init_slicedToArray();
11350 init_requests_ids();
11351 function ownKeys$11(e, r) {
11352 var t = Object.keys(e);
11353 if (Object.getOwnPropertySymbols) {
11354 var o = Object.getOwnPropertySymbols(e);
11355 r && (o = o.filter(function(r) {
11356 return Object.getOwnPropertyDescriptor(e, r).enumerable;
11357 })), t.push.apply(t, o);
11358 }
11359 return t;
11360 }
11361 __name(ownKeys$11, "ownKeys");
11362 function _objectSpread$11(e) {
11363 for (var r = 1; r < arguments.length; r++) {
11364 var t = null != arguments[r] ? arguments[r] : {};
11365 r % 2 ? ownKeys$11(Object(t), !0).forEach(function(r) {
11366 _defineProperty(e, r, t[r]);
11367 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$11(Object(t)).forEach(function(r) {
11368 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
11369 });
11370 }
11371 return e;
11372 }
11373 __name(_objectSpread$11, "_objectSpread");
11374 var ProductImageUnification = function ProductImageUnification(_ref) {
11375 var _products$images$leng;
11376 var _products$images;
11377 var _Object$values;
11378 var _products$images$leng2;
11379 var _products$images2;
11380 var _products$images$leng3;
11381 var _products$images3;
11382 var _errorlessProducts$le;
11383 var _products$images4;
11384 var onClose = _ref.onClose;
11385 var setGenerate = useRequestIds().setGenerate;
11386 var products = useEditImage().editImage;
11387 var _usePromptSettings = usePromptSettings();
11388 var settings = _usePromptSettings.settings;
11389 var updateSettings = _usePromptSettings.updateSettings;
11390 var _useState2 = _slicedToArray((0, react.useState)({}), 2);
11391 var productsData = _useState2[0];
11392 var setProductsData = _useState2[1];
11393 var _useState4 = _slicedToArray((0, react.useState)({}), 2);
11394 var loadingMap = _useState4[0];
11395 var setLoadingMap = _useState4[1];
11396 var _useState6 = _slicedToArray((0, react.useState)({}), 2);
11397 var errorMap = _useState6[0];
11398 var setErrorMap = _useState6[1];
11399 var _useState8 = _slicedToArray((0, react.useState)({}), 2);
11400 var checkboxColorMap = _useState8[0];
11401 var setCheckboxColorMap = _useState8[1];
11402 var _useState0 = _slicedToArray((0, react.useState)(false), 2);
11403 var wasGeneratedOnce = _useState0[0];
11404 var setWasGeneratedOnce = _useState0[1];
11405 var useMultipleImages = useImageActions().useMultipleImages;
11406 var _useState10 = _slicedToArray((0, react.useState)(false), 2);
11407 var isSavingImages = _useState10[0];
11408 var setIsSavingImages = _useState10[1];
11409 var errorlessProducts = Object.values(productsData).filter(function(_ref2) {
11410 var _errorMap$productId;
11411 return !((_errorMap$productId = errorMap[_ref2.productId]) !== null && _errorMap$productId !== void 0 && _errorMap$productId.errorGenerating);
11412 });
11413 var use = (0, react.useCallback)(/*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee() {
11414 var generatedImages;
11415 var imagesToSave;
11416 return import_regenerator$3.default.wrap(function(_context) {
11417 while (1) switch (_context.prev = _context.next) {
11418 case 0:
11419 setIsSavingImages(true);
11420 generatedImages = errorlessProducts.filter(function(_ref4) {
11421 var data = _ref4.data;
11422 return _ref4.wasGenerated && (data === null || data === void 0 ? void 0 : data.isChecked) && (data === null || data === void 0 ? void 0 : data.productId) !== void 0;
11423 });
11424 imagesToSave = generatedImages.map(function(_ref5) {
11425 var data = _ref5.data;
11426 return _objectSpread$11(_objectSpread$11({}, data), {}, {
11427 editor_post_id: data.productId,
11428 unique_id: "ai-product-unification-".concat(data.productId)
11429 });
11430 });
11431 _context.next = 1;
11432 return useMultipleImages(imagesToSave);
11433 case 1:
11434 generatedImages.forEach(function(_ref6) {
11435 var sendUsageData = _ref6.sendUsageData;
11436 sendUsageData();
11437 });
11438 onClose();
11439 case 2:
11440 case "end": return _context.stop();
11441 }
11442 }, _callee);
11443 })), [
11444 onClose,
11445 errorlessProducts,
11446 useMultipleImages
11447 ]);
11448 var generatedAspectRatio = (0, react.useMemo)(function() {
11449 return settings[IMAGE_RATIO];
11450 }, [settings]);
11451 var generatedBgColor = (0, react.useMemo)(function() {
11452 return settings[IMAGE_BACKGROUND_COLOR];
11453 }, [settings]);
11454 var onProductUpdate = (0, react.useCallback)(function(res, isLoadingResult, errorGenerating, _req, productId, ratio, bgColor, image, sendUsageData) {
11455 setLoadingMap(function(prevState) {
11456 return _objectSpread$11(_objectSpread$11({}, prevState), {}, _defineProperty({}, productId, !!isLoadingResult));
11457 });
11458 setErrorMap(function(prevState) {
11459 return _objectSpread$11(_objectSpread$11({}, prevState), {}, _defineProperty({}, productId, { errorGenerating }));
11460 });
11461 setProductsData(function(prevState) {
11462 var _res$result;
11463 var _ref7;
11464 var _res$result$;
11465 var _res$result2;
11466 var _prevState$productId;
11467 var _prevState$productId$;
11468 var _prevState$productId2;
11469 var _checkboxColorMap$pro;
11470 return _objectSpread$11(_objectSpread$11({}, prevState), {}, _defineProperty({}, productId, _objectSpread$11(_objectSpread$11({}, prevState[productId]), {}, {
11471 productId,
11472 res,
11473 req: function req() {
11474 return _req({
11475 postId: productId,
11476 settings: _defineProperty(_defineProperty({}, IMAGE_RATIO, ratio), IMAGE_BACKGROUND_COLOR, bgColor),
11477 image
11478 });
11479 },
11480 sendUsageData,
11481 wasGenerated: (res === null || res === void 0 || (_res$result = res.result) === null || _res$result === void 0 ? void 0 : _res$result[0]) !== void 0,
11482 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 : {}), {}, {
11483 seed: productId,
11484 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,
11485 isLoading: isLoadingResult,
11486 checkboxColor: (_checkboxColorMap$pro = checkboxColorMap[productId]) !== null && _checkboxColorMap$pro !== void 0 ? _checkboxColorMap$pro : "rgba(0, 0, 0, 0.54)"
11487 })
11488 })));
11489 });
11490 }, [checkboxColorMap]);
11491 var isLoading = errorlessProducts.some(function(_ref8) {
11492 return loadingMap[_ref8.productId];
11493 });
11494 var isError = Object.values(errorMap).length && Object.values(errorMap).every(function(_ref9) {
11495 return _ref9.errorGenerating;
11496 });
11497 var thumbnailThreshold = 10;
11498 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;
11499 var selectedProducts = errorlessProducts.filter(function(_ref0) {
11500 var data = _ref0.data;
11501 return data.isChecked && !data.isLoading;
11502 });
11503 var handleSubmit = (0, react.useCallback)(function(event) {
11504 event.preventDefault();
11505 setGenerate();
11506 setWasGeneratedOnce(true);
11507 var isLightColor = function isLightColor(color) {
11508 var rgb = parseInt(color.slice(1), 16);
11509 var r = rgb >> 16 & 255;
11510 var g = rgb >> 8 & 255;
11511 var b = rgb >> 0 & 255;
11512 return .299 * r + .587 * g + .114 * b > 128;
11513 };
11514 var productsToUnify = (errorlessProducts.length ? errorlessProducts : Object.values(productsData)).filter(function(product) {
11515 var _product$data;
11516 return ((_product$data = product.data) === null || _product$data === void 0 ? void 0 : _product$data.isChecked) && product.req;
11517 });
11518 var newCheckboxColor = isLightColor(generatedBgColor) ? "rgba(0, 0, 0, 0.54)" : "rgba( 255, 255, 255, 0.7 )";
11519 if (productsToUnify.find(function(product) {
11520 return checkboxColorMap[product.productId] !== newCheckboxColor;
11521 })) setCheckboxColorMap(function(prevState) {
11522 var newColorMap = _objectSpread$11({}, prevState);
11523 productsToUnify.forEach(function(product) {
11524 newColorMap[product.productId] = newCheckboxColor;
11525 });
11526 return newColorMap;
11527 });
11528 productsToUnify.forEach(function(product) {
11529 return product.req().catch(function() {});
11530 });
11531 }, [
11532 checkboxColorMap,
11533 errorlessProducts,
11534 generatedBgColor,
11535 productsData,
11536 setGenerate
11537 ]);
11538 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
11539 primary: (0, _wordpress_i18n.__)("Unify images", "elementor"),
11540 secondary: (0, _wordpress_i18n.__)("Select a set of parameters and AI will automate your adjustments:", "elementor")
11541 }), isError && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
11542 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,
11543 onRetry: handleSubmit
11544 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, { gap: 2 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
11545 display: "flex",
11546 flexWrap: "wrap",
11547 width: "100%",
11548 "& .MuiAvatar-root": { margin: .5 }
11549 } }, products === null || products === void 0 ? void 0 : products.images.slice(0, exceedThumbnailThreshold ? thumbnailThreshold - 1 : thumbnailThreshold).map(function(img) {
11550 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Avatar, {
11551 key: img.productId,
11552 alt: img.productId + "",
11553 src: img.image_url,
11554 variant: "square",
11555 sx: {
11556 width: 50,
11557 height: 50
11558 }
11559 });
11560 }), exceedThumbnailThreshold && /*#__PURE__*/ react.default.createElement(_elementor_ui.Avatar, {
11561 variant: "square",
11562 sx: {
11563 bgcolor: "lightgray",
11564 width: 50,
11565 height: 50
11566 }
11567 }, ((_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, {
11568 gap: 2,
11569 sx: { my: 2.5 }
11570 }, /*#__PURE__*/ react.default.createElement(ColorInput, {
11571 label: (0, _wordpress_i18n.__)("Background Color", "elementor"),
11572 color: generatedBgColor,
11573 onChange: function onChange(color) {
11574 return updateSettings(_defineProperty({}, IMAGE_BACKGROUND_COLOR, color));
11575 },
11576 disabled: isLoading
11577 }), /*#__PURE__*/ react.default.createElement(ImageRatioSelect, {
11578 disabled: true,
11579 value: generatedAspectRatio,
11580 onChange: function onChange(event) {
11581 return updateSettings(_defineProperty({}, IMAGE_RATIO, event.target.value));
11582 }
11583 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
11584 gap: 2,
11585 sx: { my: 2.5 }
11586 }, 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: {
11587 display: "flex",
11588 flexDirection: "column",
11589 height: "100%",
11590 alignItems: "center",
11591 justifyContent: "center",
11592 minHeight: "76vh"
11593 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
11594 flex: 1,
11595 overflowY: "auto",
11596 display: "flex",
11597 flexDirection: "column",
11598 height: "100%",
11599 alignItems: "center",
11600 justifyContent: "center",
11601 overflowX: "hidden"
11602 } }, wasGeneratedOnce ? /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, errorlessProducts.length > 1 && errorlessProducts.some(function(_ref1) {
11603 return !_ref1.data.isLoading;
11604 }) && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
11605 display: "flex",
11606 flexDirection: "row",
11607 alignItems: "inherit",
11608 justifyContent: "space-between",
11609 width: "100%"
11610 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
11611 variant: "body2",
11612 color: "secondary"
11613 }, (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, {
11614 variant: "text",
11615 color: "secondary",
11616 onClick: function onClick() {
11617 var isChecked = !selectedProducts.some(function(product) {
11618 var _product$data2;
11619 return (_product$data2 = product.data) === null || _product$data2 === void 0 ? void 0 : _product$data2.isChecked;
11620 });
11621 setProductsData(function(prevState) {
11622 var newState = _objectSpread$11({}, prevState);
11623 Object.values(newState).forEach(function(product) {
11624 var _product$data3;
11625 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 }) });
11626 });
11627 return newState;
11628 });
11629 }
11630 }, selectedProducts.some(function(product) {
11631 var _product$data4;
11632 return (_product$data4 = product.data) === null || _product$data4 === void 0 ? void 0 : _product$data4.isChecked;
11633 }) ? (0, _wordpress_i18n.__)("Clear all", "elementor") : (0, _wordpress_i18n.__)("Select all", "elementor"))), /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
11634 images: errorlessProducts.map(function(product) {
11635 return product.data;
11636 }),
11637 cols: function getCols() {
11638 var dataLength = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1;
11639 return Math.min(Math.ceil(Math.sqrt(dataLength !== null && dataLength !== void 0 ? dataLength : 1)), 4);
11640 }((_errorlessProducts$le = errorlessProducts.length) !== null && _errorlessProducts$le !== void 0 ? _errorlessProducts$le : 1),
11641 overlay: false,
11642 onSelectChange: function onSelectChange(productId, isChecked) {
11643 return setProductsData(function(prevState) {
11644 var _prevState$productId3;
11645 if ((_prevState$productId3 = prevState[productId]) !== null && _prevState$productId3 !== void 0 && _prevState$productId3.data) prevState[productId].data.isChecked = isChecked;
11646 return _objectSpread$11({}, prevState);
11647 });
11648 }
11649 })) : /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
11650 component: "img",
11651 src: window.UnifyProductImagesConfig.placeholder,
11652 alt: (0, _wordpress_i18n.__)("Example GIF", "elementor")
11653 })), wasGeneratedOnce && !isError && errorlessProducts.length && errorlessProducts.some(function(_ref10) {
11654 var data = _ref10.data;
11655 var errorGenerating = _ref10.errorGenerating;
11656 var wasGenerated = _ref10.wasGenerated;
11657 return (data === null || data === void 0 ? void 0 : data.isChecked) && !(data !== null && data !== void 0 && data.isLoadingResult) && !errorGenerating && wasGenerated;
11658 }) && /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, {
11659 onClick: use,
11660 sx: {
11661 alignSelf: "flex-end",
11662 mt: 2
11663 }
11664 }))), (_products$images4 = products.images) === null || _products$images4 === void 0 ? void 0 : _products$images4.filter(function(img) {
11665 return img.productId;
11666 }).map(function(img) {
11667 return /*#__PURE__*/ react.default.createElement(ProductImage, {
11668 key: "product-".concat(img.productId),
11669 productId: img.productId,
11670 ratio: settings[IMAGE_RATIO],
11671 bgColor: settings[IMAGE_BACKGROUND_COLOR],
11672 image: img,
11673 onUpdate: onProductUpdate
11674 });
11675 }));
11676 };
11677 ProductImageUnification.propTypes = { onClose: import_prop_types$12.default.func };
11678
11679 //#endregion
11680 //#region modules/ai/assets/js/editor/pages/form-media/views/isolate-objects/hooks/use-isolate-objects.js
11681 init_api();
11682 var useIsolateObject = function useIsolateObject(initialValue) {
11683 return useImagePrompt(function fetchAction(payload) {
11684 return getImageToImageIsolateObjects(payload);
11685 }, initialValue);
11686 };
11687
11688 //#endregion
11689 //#region modules/ai/assets/js/editor/pages/form-media/views/isolate-objects/index.js
11690 init_defineProperty();
11691 init_requests_ids();
11692 var IsolateObject = function IsolateObject() {
11693 var editImage = useEditImage().editImage;
11694 var setGenerate = useRequestIds().setGenerate;
11695 var _useImageActions = useImageActions();
11696 var use = _useImageActions.use;
11697 var edit = _useImageActions.edit;
11698 var isUploading = _useImageActions.isLoading;
11699 var _usePromptSettings = usePromptSettings();
11700 var settings = _usePromptSettings.settings;
11701 var updateSettings = _usePromptSettings.updateSettings;
11702 var _useIsolateObject = useIsolateObject();
11703 var data = _useIsolateObject.data;
11704 var send = _useIsolateObject.send;
11705 var isGenerating = _useIsolateObject.isLoading;
11706 var error = _useIsolateObject.error;
11707 var isLoading = isGenerating || isUploading;
11708 var _useImageSize = useImageSize(editImage.aspectRatio);
11709 var width = _useImageSize.width;
11710 var height = _useImageSize.height;
11711 var generatedAspectRatio = (0, react.useMemo)(function() {
11712 return settings[IMAGE_RATIO];
11713 }, [settings]);
11714 var generatedBgColor = (0, react.useMemo)(function() {
11715 return settings[IMAGE_BACKGROUND_COLOR];
11716 }, [settings]);
11717 var handleSubmit = function handleSubmit(event) {
11718 event.preventDefault();
11719 setGenerate();
11720 send({
11721 image: editImage,
11722 settings: _defineProperty(_defineProperty({}, IMAGE_RATIO, generatedAspectRatio), IMAGE_BACKGROUND_COLOR, generatedBgColor),
11723 featureIdentifier: FEATURE_IDENTIFIER.ISOLATE_OBJECT
11724 });
11725 };
11726 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, {
11727 primary: (0, _wordpress_i18n.__)("Isolate Object", "elementor"),
11728 secondary: (0, _wordpress_i18n.__)("Remove the background, center your object, and add a drop shadow for a clean look.", "elementor")
11729 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
11730 error,
11731 onRetry: handleSubmit
11732 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
11733 gap: 2,
11734 sx: { my: 2.5 }
11735 }, /*#__PURE__*/ react.default.createElement(ColorInput, {
11736 label: (0, _wordpress_i18n.__)("Background Color", "elementor"),
11737 color: generatedBgColor,
11738 onChange: function onChange(color) {
11739 return updateSettings(_defineProperty({}, IMAGE_BACKGROUND_COLOR, color));
11740 },
11741 disabled: isLoading
11742 }), /*#__PURE__*/ react.default.createElement(GenerateSubmit, {
11743 disabled: isLoading,
11744 loading: isLoading
11745 }, (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, {
11746 transparentContainer: true,
11747 onUseImage: use,
11748 onEditImage: edit,
11749 images: data.result,
11750 aspectRatio: editImage.aspectRatio
11751 })) : /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
11752 src: editImage.url,
11753 alt: editImage.alt,
11754 style: {
11755 width,
11756 height
11757 }
11758 })))));
11759 };
11760
11761 //#endregion
11762 //#region modules/ai/assets/js/editor/pages/form-media/media-outlet.js
11763 init_loader();
11764 init_prompt_history_action_context();
11765 var MediaOutlet = function MediaOutlet(_ref) {
11766 var _ref$additionalOption = _ref.additionalOptions;
11767 var additionalOptions = _ref$additionalOption === void 0 ? null : _ref$additionalOption;
11768 var _ref$onClose = _ref.onClose;
11769 var onClose = _ref$onClose === void 0 ? null : _ref$onClose;
11770 var editImage = useEditImage().editImage;
11771 var _useLocation = useLocation({ current: (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.location) || LOCATIONS.GENERATE });
11772 var current = _useLocation.current;
11773 var navigate = _useLocation.navigate;
11774 (0, react.useEffect)(function() {
11775 if ((additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.location) && additionalOptions.location !== LOCATIONS.GENERATE) {
11776 navigate(additionalOptions.location);
11777 return;
11778 }
11779 if (editImage.url) if (new RegExp(IMAGE_PLACEHOLDERS_HOSTS.WIREFRAME).test(new URL(editImage.url).host)) navigate(LOCATIONS.GENERATE);
11780 else if ("url" === editImage.source || editImage.id) navigate(LOCATIONS.IMAGE_TOOLS);
11781 else navigate(LOCATIONS.GENERATE);
11782 }, [
11783 editImage.id,
11784 editImage.url,
11785 editImage.source,
11786 additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.location
11787 ]);
11788 useSubscribeOnPromptHistoryAction([{
11789 type: ACTION_TYPES.RESTORE,
11790 handler: function handler() {
11791 if (current !== LOCATIONS.GENERATE) navigate(LOCATIONS.GENERATE);
11792 }
11793 }]);
11794 if (!current) return /*#__PURE__*/ react.default.createElement(View, { alignItems: "center" }, /*#__PURE__*/ react.default.createElement(Loader, null));
11795 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, current === LOCATIONS.GENERATE && /*#__PURE__*/ react.default.createElement(Generate, {
11796 textToImageHook: additionalOptions !== null && additionalOptions !== void 0 && additionalOptions.textToImageHook ? additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.textToImageHook : useTextToImage,
11797 predefinedPrompt: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.predefinedPrompt,
11798 initialSettings: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.initialSettings
11799 }), 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));
11800 };
11801 MediaOutlet.propTypes = {
11802 additionalOptions: import_prop_types$12.default.object,
11803 onClose: import_prop_types$12.default.func
11804 };
11805
11806 //#endregion
11807 //#region modules/ai/assets/js/editor/pages/form-media/components/unsaved-changes-alert.js
11808 init_extends();
11809 init_objectWithoutProperties();
11810 var _excluded$13 = ["onClose", "onCancel"];
11811 var UnsavedChangesAlert$1 = function UnsavedChangesAlert(_ref) {
11812 var onClose = _ref.onClose;
11813 var onCancel = _ref.onCancel;
11814 var props = _objectWithoutProperties(_ref, _excluded$13);
11815 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, _extends$1({
11816 sx: { zIndex: 2e5 },
11817 "aria-labelledby": "unsaved-changes-alert-title",
11818 "aria-describedby": "unsaved-changes-alert-description"
11819 }, 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, {
11820 onClick: onCancel,
11821 color: "secondary"
11822 }, (0, _wordpress_i18n.__)("Cancel", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
11823 onClick: onClose,
11824 color: "error",
11825 variant: "contained"
11826 }, (0, _wordpress_i18n.__)("Yes, leave", "elementor"))));
11827 };
11828 UnsavedChangesAlert$1.propTypes = {
11829 onClose: import_prop_types$12.default.func,
11830 onCancel: import_prop_types$12.default.func
11831 };
11832
11833 //#endregion
11834 //#region modules/ai/assets/js/editor/components/prompt-history/history-button.js
11835 init_extends();
11836 init_objectWithoutProperties();
11837 var _excluded$12 = ["isActive"];
11838 var _templateObject$5;
11839 var StyledHistoryButton = (0, _elementor_ui.styled)(_elementor_ui.IconButton)(_templateObject$5 || (_templateObject$5 = _taggedTemplateLiteral([
11840 "\n margin-right: ",
11841 ";\n\n ",
11842 "\n"
11843 ])), function(_ref) {
11844 return _ref.theme.spacing(2);
11845 }, function(_ref2) {
11846 var isActive = _ref2.isActive;
11847 var theme = _ref2.theme;
11848 return isActive && "\n background-color: ".concat(theme.palette.action.hover, ";\n color: ").concat(theme.palette.text.tertiary, ";\n ");
11849 });
11850 var PromptHistoryButton = function PromptHistoryButton(_ref3) {
11851 var isActive = _ref3.isActive;
11852 var props = _objectWithoutProperties(_ref3, _excluded$12);
11853 return /*#__PURE__*/ react.default.createElement(StyledHistoryButton, _extends$1({
11854 "aria-label": (0, _wordpress_i18n.__)("Show prompt history", "elementor"),
11855 type: "button",
11856 size: "small",
11857 isActive
11858 }, props), /*#__PURE__*/ react.default.createElement(_elementor_icons.HistoryIcon, null));
11859 };
11860 PromptHistoryButton.propTypes = { isActive: import_prop_types$12.default.bool.isRequired };
11861
11862 //#endregion
11863 //#region modules/ai/assets/js/editor/hooks/use-prompt-history.js
11864 init_asyncToGenerator();
11865 init_slicedToArray();
11866 init_defineProperty();
11867 init_api();
11868 function ownKeys$10(e, r) {
11869 var t = Object.keys(e);
11870 if (Object.getOwnPropertySymbols) {
11871 var o = Object.getOwnPropertySymbols(e);
11872 r && (o = o.filter(function(r) {
11873 return Object.getOwnPropertyDescriptor(e, r).enumerable;
11874 })), t.push.apply(t, o);
11875 }
11876 return t;
11877 }
11878 __name(ownKeys$10, "ownKeys");
11879 function _objectSpread$10(e) {
11880 for (var r = 1; r < arguments.length; r++) {
11881 var t = null != arguments[r] ? arguments[r] : {};
11882 r % 2 ? ownKeys$10(Object(t), !0).forEach(function(r) {
11883 _defineProperty(e, r, t[r]);
11884 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$10(Object(t)).forEach(function(r) {
11885 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
11886 });
11887 }
11888 return e;
11889 }
11890 __name(_objectSpread$10, "_objectSpread");
11891 var getImageThumbnailURL = function getImageThumbnailURL(base, imageURL) {
11892 if (!base) return imageURL;
11893 return "".concat(base, "/?o=").concat(btoa(imageURL, false));
11894 };
11895 var normalizeItems = function normalizeItems(response) {
11896 var meta = response.meta;
11897 var items = response.items;
11898 return items === null || items === void 0 ? void 0 : items.map(function(item) {
11899 var _item$request;
11900 var _item$request2;
11901 var _item$request3;
11902 var _item$response;
11903 var _item$response2;
11904 var _item$response3;
11905 return {
11906 id: item === null || item === void 0 ? void 0 : item.elementorApiId,
11907 date: item === null || item === void 0 ? void 0 : item.createdAt,
11908 action: item === null || item === void 0 ? void 0 : item.action,
11909 prompt: item === null || item === void 0 || (_item$request = item.request) === null || _item$request === void 0 ? void 0 : _item$request.prompt,
11910 imageType: item === null || item === void 0 || (_item$request2 = item.request) === null || _item$request2 === void 0 ? void 0 : _item$request2.image_type,
11911 ratio: item === null || item === void 0 || (_item$request3 = item.request) === null || _item$request3 === void 0 ? void 0 : _item$request3.ratio,
11912 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,
11913 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,
11914 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) {
11915 return _objectSpread$10(_objectSpread$10({}, image), {}, { image_url: getImageThumbnailURL(meta.thumbnailUrl, image.image_url) });
11916 })
11917 };
11918 });
11919 };
11920 var usePromptHistory = function usePromptHistory(historyType) {
11921 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
11922 var isLoading = _useState2[0];
11923 var setIsLoading = _useState2[1];
11924 var _useState4 = _slicedToArray((0, react.useState)({}), 2);
11925 var data = _useState4[0];
11926 var setData = _useState4[1];
11927 var _useState6 = _slicedToArray((0, react.useState)(""), 2);
11928 var error = _useState6[0];
11929 var setError = _useState6[1];
11930 var fetchData = /*#__PURE__*/ function() {
11931 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee(_ref) {
11932 var page;
11933 var limit;
11934 return import_regenerator$3.default.wrap(function(_context) {
11935 while (1) switch (_context.prev = _context.next) {
11936 case 0:
11937 page = _ref.page, limit = _ref.limit;
11938 return _context.abrupt("return", new Promise(function(resolve, reject) {
11939 setIsLoading(true);
11940 getHistory(historyType, page, limit).then(function(response) {
11941 var clone = JSON.parse(JSON.stringify(data));
11942 clone.meta = response.meta;
11943 clone.items = [].concat(_toConsumableArray((clone === null || clone === void 0 ? void 0 : clone.items) || []), _toConsumableArray(normalizeItems(response)));
11944 setData(clone);
11945 resolve(true);
11946 }).catch(function(err) {
11947 var finalError = (err === null || err === void 0 ? void 0 : err.responseText) || err;
11948 setError(finalError);
11949 reject(finalError);
11950 }).finally(function() {
11951 return setIsLoading(false);
11952 });
11953 }));
11954 case 1:
11955 case "end": return _context.stop();
11956 }
11957 }, _callee);
11958 }));
11959 return function fetchData(_x) {
11960 return _ref2.apply(this, arguments);
11961 };
11962 }();
11963 return {
11964 isLoading,
11965 error,
11966 items: data.items,
11967 meta: data.meta,
11968 fetchData,
11969 deleteItemById: function deleteItemById(id) {
11970 var itemIndex = data.items.findIndex(function(item) {
11971 return item.id === id;
11972 });
11973 if (-1 === itemIndex) return false;
11974 var clone = JSON.parse(JSON.stringify(data));
11975 clone.items.splice(itemIndex, 1);
11976 setData(clone);
11977 return true;
11978 }
11979 };
11980 };
11981
11982 //#endregion
11983 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-header.js
11984 var StyledContent$2 = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref) {
11985 var theme = _ref.theme;
11986 return {
11987 marginTop: 0,
11988 padding: theme.spacing(1.5),
11989 borderBottom: "1px solid ".concat(theme.palette.action.focus),
11990 display: "flex",
11991 alignItems: "center",
11992 justifyContent: "space-between"
11993 };
11994 });
11995 var PromptHistoryModalHeader = function PromptHistoryModalHeader(_ref2) {
11996 var onClose = _ref2.onClose;
11997 return /*#__PURE__*/ react.default.createElement(StyledContent$2, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
11998 fontWeight: "bolder",
11999 variant: "h6",
12000 sx: { userSelect: "none" }
12001 }, (0, _wordpress_i18n.__)("History", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
12002 size: "small",
12003 "aria-label": (0, _wordpress_i18n.__)("Hide prompt history", "elementor"),
12004 onClick: onClose
12005 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.XIcon, { fontSize: "small" })));
12006 };
12007 PromptHistoryModalHeader.propTypes = { onClose: import_prop_types$12.default.func.isRequired };
12008
12009 //#endregion
12010 //#region modules/ai/assets/js/editor/hooks/use-delete-prompt-history-item.js
12011 init_asyncToGenerator();
12012 init_slicedToArray();
12013 init_api();
12014 var useDeletePromptHistoryItem = function useDeletePromptHistoryItem() {
12015 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
12016 var isLoading = _useState2[0];
12017 var setIsLoading = _useState2[1];
12018 var _useState4 = _slicedToArray((0, react.useState)(""), 2);
12019 var error = _useState4[0];
12020 var setError = _useState4[1];
12021 return {
12022 isLoading,
12023 error,
12024 deleteItem: /* @__PURE__ */ function() {
12025 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee(id) {
12026 return import_regenerator$3.default.wrap(function(_context) {
12027 while (1) switch (_context.prev = _context.next) {
12028 case 0: return _context.abrupt("return", new Promise(function(resolve, reject) {
12029 setError("");
12030 setIsLoading(true);
12031 deleteHistoryItem(id).then(function() {
12032 resolve(true);
12033 }).catch(function(err) {
12034 var finalError = (err === null || err === void 0 ? void 0 : err.responseText) || err;
12035 setError(finalError);
12036 reject(finalError);
12037 }).finally(function() {
12038 return setIsLoading(false);
12039 });
12040 }));
12041 case 1:
12042 case "end": return _context.stop();
12043 }
12044 }, _callee);
12045 }));
12046 return function deleteItem(_x) {
12047 return _ref.apply(this, arguments);
12048 };
12049 }()
12050 };
12051 };
12052
12053 //#endregion
12054 //#region modules/ai/assets/js/editor/helpers/date-helpers.js
12055 /**
12056 * Formats a date (like wp_date() in PHP), translating it into site's locale.
12057 *
12058 * @param {string} format PHP-style formatting string.
12059 * @param {Date | string | undefined} date Date object
12060 * @param {string | number | undefined=} timezone Timezone to output result in or a UTC offset. Defaults to timezone from site.
12061 * @return {string}
12062 */
12063 var translateDate = function translateDate(format, date, timezone) {
12064 var _window$wp;
12065 if ((_window$wp = window.wp) !== null && _window$wp !== void 0 && _window$wp.date) {
12066 var _window$wp2;
12067 var dateI18n = ((_window$wp2 = window.wp) === null || _window$wp2 === void 0 ? void 0 : _window$wp2.date).dateI18n;
12068 return dateI18n(format, date, timezone);
12069 }
12070 return date;
12071 };
12072 /**
12073 * Returns difference in days between two dates
12074 *
12075 * @param {Date} firstDate
12076 * @param {Date} secondDate
12077 * @return {number} Positive or negative number in days
12078 */
12079 var daysDiff = function daysDiff(firstDate, secondDate) {
12080 var MS_PER_DAY = 1e3 * 60 * 60 * 24;
12081 var firstUTC = Date.UTC(firstDate.getFullYear(), firstDate.getMonth(), firstDate.getDate());
12082 var secondUTC = Date.UTC(secondDate.getFullYear(), secondDate.getMonth(), secondDate.getDate());
12083 return Math.floor((secondUTC - firstUTC) / MS_PER_DAY);
12084 };
12085
12086 //#endregion
12087 //#region modules/ai/assets/js/editor/icons/restore-icon.js
12088 init_extends();
12089 var RestoreIcon = react.default.forwardRef(function(props, ref) {
12090 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
12091 fillRule: "evenodd",
12092 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",
12093 clipRule: "evenodd"
12094 }));
12095 });
12096
12097 //#endregion
12098 //#region modules/ai/assets/js/editor/components/tooltip.js
12099 init_extends();
12100 init_objectWithoutProperties();
12101 var _excluded$11 = ["children"];
12102 var Tooltip$2 = function Tooltip(_ref) {
12103 var children = _ref.children;
12104 var props = _objectWithoutProperties(_ref, _excluded$11);
12105 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, _extends$1({ componentsProps: { tooltip: { sx: {
12106 "&.MuiTooltip-tooltip[class*=\"MuiTooltip-tooltipPlacement\"]": {
12107 m: 0,
12108 fontSize: "10px",
12109 fontWeight: 500,
12110 lineHeight: "1.4em"
12111 },
12112 py: .5,
12113 px: 1
12114 } } } }, props), children);
12115 };
12116 Tooltip$2.propTypes = { children: import_prop_types$12.default.oneOfType([import_prop_types$12.default.arrayOf(import_prop_types$12.default.node), import_prop_types$12.default.node]) };
12117
12118 //#endregion
12119 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-item-action-button.js
12120 init_extends();
12121 init_objectWithoutProperties();
12122 var _excluded$10 = ["tooltipTitle"];
12123 var ActionButton = function ActionButton(_ref) {
12124 var tooltipTitle = _ref.tooltipTitle;
12125 var props = _objectWithoutProperties(_ref, _excluded$10);
12126 return /*#__PURE__*/ react.default.createElement(Tooltip$2, {
12127 title: tooltipTitle,
12128 placement: "top"
12129 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, _extends$1({
12130 type: "button",
12131 size: "small",
12132 disableRipple: true,
12133 disableFocusRipple: true,
12134 disableTouchRipple: true
12135 }, props)));
12136 };
12137 ActionButton.propTypes = { tooltipTitle: import_prop_types$12.default.string.isRequired };
12138
12139 //#endregion
12140 //#region modules/ai/assets/js/editor/icons/text-icon.js
12141 init_extends();
12142 var TextIcon = react.default.forwardRef(function(props, ref) {
12143 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
12144 fillRule: "evenodd",
12145 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",
12146 clipRule: "evenodd"
12147 }), /*#__PURE__*/ react.default.createElement("path", {
12148 fillRule: "evenodd",
12149 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",
12150 clipRule: "evenodd"
12151 }), /*#__PURE__*/ react.default.createElement("path", {
12152 fillRule: "evenodd",
12153 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",
12154 clipRule: "evenodd"
12155 }));
12156 });
12157
12158 //#endregion
12159 //#region modules/ai/assets/js/editor/icons/code-icon.js
12160 init_extends();
12161 var CodeIcon = react.default.forwardRef(function(props, ref) {
12162 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
12163 fillRule: "evenodd",
12164 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",
12165 clipRule: "evenodd"
12166 }));
12167 });
12168
12169 //#endregion
12170 //#region modules/ai/assets/js/editor/components/prompt-history/parts/action-icon.js
12171 var FALLBACK_ICON = /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { "data-testid": "e-ph-fi" });
12172 var ICONS_BY_ACTIONS = Object.freeze({
12173 "enhance-image-prompt": /*#__PURE__*/ react.default.createElement(TextIcon, null),
12174 "get-text": /*#__PURE__*/ react.default.createElement(TextIcon, null),
12175 "edit-text": /*#__PURE__*/ react.default.createElement(TextIcon, null),
12176 "custom-css": /*#__PURE__*/ react.default.createElement(CodeIcon, null),
12177 "custom-code": /*#__PURE__*/ react.default.createElement(CodeIcon, null)
12178 });
12179 var PromptHistoryActionIcon = function PromptHistoryActionIcon(_ref) {
12180 var action = _ref.action;
12181 if (ICONS_BY_ACTIONS[action]) return ICONS_BY_ACTIONS[action];
12182 return FALLBACK_ICON;
12183 };
12184 PromptHistoryActionIcon.propTypes = { action: import_prop_types$12.default.string.isRequired };
12185
12186 //#endregion
12187 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-item-title.js
12188 var _templateObject$4;
12189 var StyledTitle = (0, _elementor_ui.styled)(_elementor_ui.Typography)(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteral(["\n margin-bottom: ", ";\n"])), function(_ref) {
12190 return _ref.theme.spacing(.5);
12191 });
12192 var PromptHistoryItemTitle = function PromptHistoryItemTitle(_ref2) {
12193 var prompt = _ref2.prompt;
12194 return /*#__PURE__*/ react.default.createElement(Tooltip$2, {
12195 title: prompt,
12196 arrow: false,
12197 placement: "bottom-start"
12198 }, /*#__PURE__*/ react.default.createElement(StyledTitle, {
12199 variant: "body2",
12200 noWrap: true,
12201 paragraph: true
12202 }, prompt));
12203 };
12204 PromptHistoryItemTitle.propTypes = { prompt: import_prop_types$12.default.string.isRequired };
12205
12206 //#endregion
12207 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-item-secondary-content.js
12208 var _templateObject$3;
12209 var _templateObject2$1;
12210 var StyledDateSubtitle = (0, _elementor_ui.styled)(_elementor_ui.Typography)(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteral(["\n color: ", ";\n"])), function(_ref) {
12211 return _ref.theme.palette.secondary.light;
12212 });
12213 var StyledImage = (0, _elementor_ui.styled)("img")(_templateObject2$1 || (_templateObject2$1 = _taggedTemplateLiteral(["\n height: 72px;\n width: 72px;\n object-fit: cover;\n margin-right: ", ";\n"])), function(_ref2) {
12214 return _ref2.theme.spacing(.5);
12215 });
12216 var PromptHistoryItemSecondaryContent = function PromptHistoryItemSecondaryContent(_ref3) {
12217 var date = _ref3.date;
12218 var thumbnails = _ref3.thumbnails;
12219 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
12220 direction: "column",
12221 width: "90%"
12222 }, /*#__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, {
12223 flexDirection: "row",
12224 mt: 1
12225 }, thumbnails.map(
12226 /**
12227 * @param {Object} thumb
12228 * @return {React.ReactNode}
12229 */
12230 function(thumb) {
12231 return /*#__PURE__*/ react.default.createElement(StyledImage, {
12232 key: "thumbnail-".concat(thumb.seed),
12233 alt: "",
12234 src: thumb.image_url
12235 });
12236 }
12237 )));
12238 };
12239 PromptHistoryItemSecondaryContent.propTypes = {
12240 date: import_prop_types$12.default.string.isRequired,
12241 thumbnails: import_prop_types$12.default.array
12242 };
12243
12244 //#endregion
12245 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-item.js
12246 init_objectWithoutProperties();
12247 init_prompt_history_action_context();
12248 var _excluded$9 = [
12249 "id",
12250 "date",
12251 "onHistoryItemDelete"
12252 ];
12253 var _templateObject$2;
12254 var _templateObject2;
12255 var _templateObject3;
12256 var _templateObject4;
12257 var StyledListItem = (0, _elementor_ui.styled)(_elementor_ui.ListItem)(_templateObject$2 || (_templateObject$2 = _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) {
12258 var actionsCount = _ref.actionsCount;
12259 return "calc(100% - ".concat(actionsCount, " * 26px)");
12260 });
12261 var StyledListItemButton = (0, _elementor_ui.styled)(_elementor_ui.ListItemButton)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding: ", ";\n align-items: flex-start;\n cursor: inherit;\n"])), function(_ref2) {
12262 return _ref2.theme.spacing(.5, 2);
12263 });
12264 var StyledListItemIcon = (0, _elementor_ui.styled)(_elementor_ui.ListItemIcon)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral([
12265 "\n min-width: auto;\n\n & > .MuiSvgIcon-root {\n margin-right: ",
12266 ";\n font-size: 1rem;\n position: relative;\n top: ",
12267 ";\n }\n"
12268 ])), function(_ref3) {
12269 return _ref3.theme.spacing(1.5);
12270 }, function(_ref4) {
12271 return _ref4.theme.spacing(.5);
12272 });
12273 var StyledButtonsWrapper = (0, _elementor_ui.styled)(_elementor_ui.Box)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n & .MuiSvgIcon-root {\n font-size: 1rem;\n }\n"])));
12274 var PromptHistoryItem = function PromptHistoryItem(_ref5) {
12275 var id = _ref5.id;
12276 var date = _ref5.date;
12277 var onHistoryItemDelete = _ref5.onHistoryItemDelete;
12278 var props = _objectWithoutProperties(_ref5, _excluded$9);
12279 var _usePromptHistoryActi = usePromptHistoryAction();
12280 var getAllowedActions = _usePromptHistoryActi.getAllowedActions;
12281 var onPromptReuse = _usePromptHistoryActi.onPromptReuse;
12282 var onResultEdit = _usePromptHistoryActi.onResultEdit;
12283 var onImagesRestore = _usePromptHistoryActi.onImagesRestore;
12284 var action = props.action;
12285 var prompt = props.prompt;
12286 var text = props.text;
12287 var images = props.images;
12288 var thumbnails = props.thumbnails;
12289 var imageType = props.imageType;
12290 var ratio = props.ratio;
12291 var allowedActions = getAllowedActions();
12292 return /*#__PURE__*/ react.default.createElement(StyledListItem, {
12293 tabIndex: "0",
12294 "data-testid": "e-ph-i",
12295 disableGutters: true,
12296 disablePadding: true,
12297 actionsCount: Object.keys(allowedActions).length
12298 }, /*#__PURE__*/ react.default.createElement(StyledListItemButton, {
12299 component: "div",
12300 role: void 0
12301 }, /*#__PURE__*/ react.default.createElement(StyledListItemIcon, null, /*#__PURE__*/ react.default.createElement(PromptHistoryActionIcon, { action })), /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemText, {
12302 disableTypography: true,
12303 primary: /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
12304 direction: "row",
12305 justifyContent: "space-between",
12306 alignItems: "center",
12307 height: "16px"
12308 }, /*#__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, {
12309 onClick: function onClick() {
12310 return onHistoryItemDelete(id);
12311 },
12312 "aria-label": (0, _wordpress_i18n.__)("Remove item", "elementor"),
12313 tooltipTitle: (0, _wordpress_i18n.__)("Remove", "elementor")
12314 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.TrashIcon, null)), allowedActions[ACTION_TYPES.REUSE] && /*#__PURE__*/ react.default.createElement(ActionButton, {
12315 onClick: function onClick() {
12316 return onPromptReuse(id, prompt);
12317 },
12318 "aria-label": (0, _wordpress_i18n.__)("Reuse prompt", "elementor"),
12319 tooltipTitle: (0, _wordpress_i18n.__)("Reuse prompt", "elementor")
12320 }, /*#__PURE__*/ react.default.createElement(RefreshIcon, null)), allowedActions[ACTION_TYPES.RESTORE] && /*#__PURE__*/ react.default.createElement(ActionButton, {
12321 onClick: function onClick() {
12322 return onImagesRestore(id, {
12323 prompt,
12324 images,
12325 imageType,
12326 ratio
12327 });
12328 },
12329 "aria-label": (0, _wordpress_i18n.__)("Restore", "elementor"),
12330 tooltipTitle: (0, _wordpress_i18n.__)("Restore", "elementor")
12331 }, /*#__PURE__*/ react.default.createElement(RestoreIcon, null)), allowedActions[ACTION_TYPES.EDIT] && /*#__PURE__*/ react.default.createElement(ActionButton, {
12332 onClick: function onClick() {
12333 return onResultEdit(id, text);
12334 },
12335 "aria-label": (0, _wordpress_i18n.__)("Edit result", "elementor"),
12336 tooltipTitle: (0, _wordpress_i18n.__)("Edit", "elementor")
12337 }, /*#__PURE__*/ react.default.createElement(EditIcon$1, null)))),
12338 secondary: /*#__PURE__*/ react.default.createElement(PromptHistoryItemSecondaryContent, {
12339 date,
12340 thumbnails
12341 })
12342 })));
12343 };
12344 PromptHistoryItem.propTypes = {
12345 id: import_prop_types$12.default.string.isRequired,
12346 action: import_prop_types$12.default.string.isRequired,
12347 prompt: import_prop_types$12.default.string.isRequired,
12348 date: import_prop_types$12.default.string.isRequired,
12349 onHistoryItemDelete: import_prop_types$12.default.func.isRequired,
12350 text: import_prop_types$12.default.string,
12351 images: import_prop_types$12.default.array,
12352 thumbnails: import_prop_types$12.default.array,
12353 imageType: import_prop_types$12.default.string,
12354 ratio: import_prop_types$12.default.string
12355 };
12356
12357 //#endregion
12358 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-period.js
12359 init_extends();
12360 init_objectWithoutProperties();
12361 var _excluded$8 = ["id", "date"];
12362 var StyledPeriodList = (0, _elementor_ui.styled)(_elementor_ui.List)(function(_ref) {
12363 var theme = _ref.theme;
12364 return { borderBottom: "1px solid ".concat(theme.palette.action.focus) };
12365 });
12366 var StyledPeriodTitle = (0, _elementor_ui.styled)(_elementor_ui.Typography)(function(_ref2) {
12367 var theme = _ref2.theme;
12368 return {
12369 padding: theme.spacing(1.5, 2),
12370 color: theme.palette.secondary.light
12371 };
12372 });
12373 var DATE_FORMAT = (0, _wordpress_i18n.__)("F j, g:i A", "elementor");
12374 var PromptHistoryPeriod = function PromptHistoryPeriod(_ref3) {
12375 var periodTitle = _ref3.periodTitle;
12376 var historyItems = _ref3.historyItems;
12377 var _onHistoryItemDelete = _ref3.onHistoryItemDelete;
12378 return /*#__PURE__*/ react.default.createElement(StyledPeriodList, {
12379 "data-testid": "e-ph-p",
12380 subheader: /*#__PURE__*/ react.default.createElement(_elementor_ui.ListSubheader, {
12381 disableSticky: true,
12382 disableGutters: true
12383 }, /*#__PURE__*/ react.default.createElement(StyledPeriodTitle, {
12384 variant: "body2",
12385 role: "heading",
12386 "aria-level": "6"
12387 }, periodTitle))
12388 }, historyItems.map(function(_ref4) {
12389 var id = _ref4.id;
12390 var date = _ref4.date;
12391 var props = _objectWithoutProperties(_ref4, _excluded$8);
12392 return /*#__PURE__*/ react.default.createElement(PromptHistoryItem, _extends$1({
12393 key: id,
12394 date: translateDate(DATE_FORMAT, date),
12395 onHistoryItemDelete: function onHistoryItemDelete() {
12396 return _onHistoryItemDelete(id);
12397 },
12398 id
12399 }, props));
12400 }));
12401 };
12402 PromptHistoryPeriod.propTypes = {
12403 periodTitle: import_prop_types$12.default.string.isRequired,
12404 historyItems: import_prop_types$12.default.array.isRequired,
12405 onHistoryItemDelete: import_prop_types$12.default.func.isRequired
12406 };
12407
12408 //#endregion
12409 //#region modules/ai/assets/js/editor/components/prompt-history/helpers/history-period-helpers.js
12410 init_defineProperty();
12411 function _createForOfIteratorHelper$1(r, e) {
12412 var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
12413 if (!t) {
12414 if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e && r && "number" == typeof r.length) {
12415 t && (r = t);
12416 var _n = 0;
12417 var F = function F() {};
12418 return {
12419 s: F,
12420 n: function n() {
12421 return _n >= r.length ? { done: !0 } : {
12422 done: !1,
12423 value: r[_n++]
12424 };
12425 },
12426 e: function e(r) {
12427 throw r;
12428 },
12429 f: F
12430 };
12431 }
12432 throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
12433 }
12434 var o;
12435 var a = !0;
12436 var u = !1;
12437 return {
12438 s: function s() {
12439 t = t.call(r);
12440 },
12441 n: function n() {
12442 var r = t.next();
12443 return a = r.done, r;
12444 },
12445 e: function e(r) {
12446 u = !0, o = r;
12447 },
12448 f: function f() {
12449 try {
12450 a || null == t.return || t.return();
12451 } finally {
12452 if (u) throw o;
12453 }
12454 }
12455 };
12456 }
12457 __name(_createForOfIteratorHelper$1, "_createForOfIteratorHelper");
12458 function _unsupportedIterableToArray$1(r, a) {
12459 if (r) {
12460 if ("string" == typeof r) return _arrayLikeToArray$1(r, a);
12461 var t = {}.toString.call(r).slice(8, -1);
12462 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;
12463 }
12464 }
12465 __name(_unsupportedIterableToArray$1, "_unsupportedIterableToArray");
12466 function _arrayLikeToArray$1(r, a) {
12467 (null == a || a > r.length) && (a = r.length);
12468 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
12469 return n;
12470 }
12471 __name(_arrayLikeToArray$1, "_arrayLikeToArray");
12472 var DATE_KEY = "date";
12473 var LAST_7_DAYS_KEY = "7-days";
12474 var LAST_30_DAYS_KEY = "30-days";
12475 var MONTH_FORMAT = (0, _wordpress_i18n.__)("F", "elementor");
12476 /**
12477 * Sorts items in ascending order by date.
12478 *
12479 * @param {Array} historyData
12480 * @return {Array}
12481 */
12482 var sortPromptHistoryData = function sortPromptHistoryData(historyData) {
12483 return _toConsumableArray(historyData).sort(function(a, b) {
12484 return new Date(b[DATE_KEY]) - new Date(a[DATE_KEY]);
12485 });
12486 };
12487 /**
12488 * Groups prompt history data by time periods.
12489 *
12490 * @param {Array} historyData
12491 * @return {Object.<string, {label: string, items: any[]}>}
12492 */
12493 var groupPromptHistoryData = function groupPromptHistoryData(historyData) {
12494 var data = sortPromptHistoryData(historyData);
12495 var currentDate = /* @__PURE__ */ new Date();
12496 var result = _defineProperty(_defineProperty({}, LAST_7_DAYS_KEY, {
12497 label: (0, _wordpress_i18n.__)("Last 7 days", "elementor"),
12498 items: []
12499 }), LAST_30_DAYS_KEY, {
12500 label: (0, _wordpress_i18n.__)("Last 30 days", "elementor"),
12501 items: []
12502 });
12503 var _iterator = _createForOfIteratorHelper$1(data);
12504 var _step;
12505 try {
12506 for (_iterator.s(); !(_step = _iterator.n()).done;) {
12507 var item = _step.value;
12508 var date = new Date(item[DATE_KEY]);
12509 var diff = daysDiff(date, currentDate);
12510 if (diff <= 7) {
12511 result[LAST_7_DAYS_KEY].items.push(item);
12512 continue;
12513 }
12514 if (diff <= 30) {
12515 result[LAST_30_DAYS_KEY].items.push(item);
12516 continue;
12517 }
12518 var month = date.getMonth();
12519 if (!result[month]) result[month] = {
12520 label: translateDate(MONTH_FORMAT, date),
12521 items: []
12522 };
12523 result[month].items.push(item);
12524 }
12525 } catch (err) {
12526 _iterator.e(err);
12527 } finally {
12528 _iterator.f();
12529 }
12530 return result;
12531 };
12532 var renderPeriods = function renderPeriods(_ref) {
12533 var _groupData$LAST_7_DAY;
12534 var _groupData$LAST_30_DA;
12535 var items = _ref.items;
12536 var onDelete = _ref.onDelete;
12537 var groupData = groupPromptHistoryData(items);
12538 var periods = [];
12539 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, {
12540 periodTitle: groupData[LAST_7_DAYS_KEY].label,
12541 onHistoryItemDelete: onDelete,
12542 historyItems: groupData[LAST_7_DAYS_KEY].items
12543 }));
12544 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, {
12545 periodTitle: groupData[LAST_30_DAYS_KEY].label,
12546 onHistoryItemDelete: onDelete,
12547 historyItems: groupData[LAST_30_DAYS_KEY].items
12548 }));
12549 for (var i = 12; i >= 0; i--) if (groupData[i]) periods.push(/*#__PURE__*/ react.default.createElement(PromptHistoryPeriod, {
12550 periodTitle: groupData[i].label,
12551 onHistoryItemDelete: onDelete,
12552 historyItems: groupData[i].items
12553 }));
12554 return periods;
12555 };
12556
12557 //#endregion
12558 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-empty.js
12559 init_history_types();
12560 var PromptHistoryEmpty = function PromptHistoryEmpty(_ref) {
12561 var historyType = _ref.historyType;
12562 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
12563 justifyContent: "center",
12564 sx: {
12565 height: "100%",
12566 textAlign: "center"
12567 },
12568 "data-testid": "e-ph-empty"
12569 }, /*#__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))));
12570 };
12571 PromptHistoryEmpty.propTypes = { historyType: import_prop_types$12.default.oneOf(Object.values(HISTORY_TYPES)).isRequired };
12572
12573 //#endregion
12574 //#region node_modules/react-infinite-scroller/src/InfiniteScroll.js
12575 init_objectWithoutProperties$1();
12576 init_defineProperty$1();
12577 var _excluded$7 = [
12578 "children",
12579 "element",
12580 "hasMore",
12581 "initialLoad",
12582 "isReverse",
12583 "loader",
12584 "loadMore",
12585 "pageStart",
12586 "ref",
12587 "threshold",
12588 "useCapture",
12589 "useWindow",
12590 "getScrollParent"
12591 ];
12592 var InfiniteScroll = class extends react.Component {
12593 constructor(props) {
12594 super(props);
12595 this.scrollListener = this.scrollListener.bind(this);
12596 this.eventListenerOptions = this.eventListenerOptions.bind(this);
12597 this.mousewheelListener = this.mousewheelListener.bind(this);
12598 }
12599 componentDidMount() {
12600 this.pageLoaded = this.props.pageStart;
12601 this.options = this.eventListenerOptions();
12602 this.attachScrollListener();
12603 }
12604 componentDidUpdate() {
12605 if (this.props.isReverse && this.loadMore) {
12606 const parentElement = this.getParentElement(this.scrollComponent);
12607 parentElement.scrollTop = parentElement.scrollHeight - this.beforeScrollHeight + this.beforeScrollTop;
12608 this.loadMore = false;
12609 }
12610 this.attachScrollListener();
12611 }
12612 componentWillUnmount() {
12613 this.detachScrollListener();
12614 this.detachMousewheelListener();
12615 }
12616 isPassiveSupported() {
12617 let passive = false;
12618 const testOptions = { get passive() {
12619 passive = true;
12620 } };
12621 try {
12622 document.addEventListener("test", null, testOptions);
12623 document.removeEventListener("test", null, testOptions);
12624 } catch (e) {}
12625 return passive;
12626 }
12627 eventListenerOptions() {
12628 let options = this.props.useCapture;
12629 if (this.isPassiveSupported()) options = {
12630 useCapture: this.props.useCapture,
12631 passive: true
12632 };
12633 else options = { passive: false };
12634 return options;
12635 }
12636 setDefaultLoader(loader) {
12637 this.defaultLoader = loader;
12638 }
12639 detachMousewheelListener() {
12640 let scrollEl = window;
12641 if (this.props.useWindow === false) scrollEl = this.scrollComponent.parentNode;
12642 scrollEl.removeEventListener("mousewheel", this.mousewheelListener, this.options ? this.options : this.props.useCapture);
12643 }
12644 detachScrollListener() {
12645 let scrollEl = window;
12646 if (this.props.useWindow === false) scrollEl = this.getParentElement(this.scrollComponent);
12647 scrollEl.removeEventListener("scroll", this.scrollListener, this.options ? this.options : this.props.useCapture);
12648 scrollEl.removeEventListener("resize", this.scrollListener, this.options ? this.options : this.props.useCapture);
12649 }
12650 getParentElement(el) {
12651 const scrollParent = this.props.getScrollParent && this.props.getScrollParent();
12652 if (scrollParent != null) return scrollParent;
12653 return el && el.parentNode;
12654 }
12655 filterProps(props) {
12656 return props;
12657 }
12658 attachScrollListener() {
12659 const parentElement = this.getParentElement(this.scrollComponent);
12660 if (!this.props.hasMore || !parentElement) return;
12661 let scrollEl = window;
12662 if (this.props.useWindow === false) scrollEl = parentElement;
12663 scrollEl.addEventListener("mousewheel", this.mousewheelListener, this.options ? this.options : this.props.useCapture);
12664 scrollEl.addEventListener("scroll", this.scrollListener, this.options ? this.options : this.props.useCapture);
12665 scrollEl.addEventListener("resize", this.scrollListener, this.options ? this.options : this.props.useCapture);
12666 if (this.props.initialLoad) this.scrollListener();
12667 }
12668 mousewheelListener(e) {
12669 if (e.deltaY === 1 && !this.isPassiveSupported()) e.preventDefault();
12670 }
12671 scrollListener() {
12672 const el = this.scrollComponent;
12673 const scrollEl = window;
12674 const parentNode = this.getParentElement(el);
12675 let offset;
12676 if (this.props.useWindow) {
12677 const doc = document.documentElement || document.body.parentNode || document.body;
12678 const scrollTop = scrollEl.pageYOffset !== void 0 ? scrollEl.pageYOffset : doc.scrollTop;
12679 if (this.props.isReverse) offset = scrollTop;
12680 else offset = this.calculateOffset(el, scrollTop);
12681 } else if (this.props.isReverse) offset = parentNode.scrollTop;
12682 else offset = el.scrollHeight - parentNode.scrollTop - parentNode.clientHeight;
12683 if (offset < Number(this.props.threshold) && el && el.offsetParent !== null) {
12684 this.detachScrollListener();
12685 this.beforeScrollHeight = parentNode.scrollHeight;
12686 this.beforeScrollTop = parentNode.scrollTop;
12687 if (typeof this.props.loadMore === "function") {
12688 this.props.loadMore(this.pageLoaded += 1);
12689 this.loadMore = true;
12690 }
12691 }
12692 }
12693 calculateOffset(el, scrollTop) {
12694 if (!el) return 0;
12695 return this.calculateTopPosition(el) + (el.offsetHeight - scrollTop - window.innerHeight);
12696 }
12697 calculateTopPosition(el) {
12698 if (!el) return 0;
12699 return el.offsetTop + this.calculateTopPosition(el.offsetParent);
12700 }
12701 render() {
12702 const renderProps = this.filterProps(this.props);
12703 const { children, element, hasMore, initialLoad, isReverse, loader, loadMore, pageStart, ref, threshold, useCapture, useWindow, getScrollParent } = renderProps, props = _objectWithoutProperties$1(renderProps, _excluded$7);
12704 props.ref = (node) => {
12705 this.scrollComponent = node;
12706 if (ref) ref(node);
12707 };
12708 const childrenArray = [children];
12709 if (hasMore) {
12710 if (loader) isReverse ? childrenArray.unshift(loader) : childrenArray.push(loader);
12711 else if (this.defaultLoader) isReverse ? childrenArray.unshift(this.defaultLoader) : childrenArray.push(this.defaultLoader);
12712 }
12713 return react.default.createElement(element, props, childrenArray);
12714 }
12715 };
12716 _defineProperty$1(InfiniteScroll, "propTypes", {
12717 children: import_prop_types$12.default.node.isRequired,
12718 element: import_prop_types$12.default.node,
12719 hasMore: import_prop_types$12.default.bool,
12720 initialLoad: import_prop_types$12.default.bool,
12721 isReverse: import_prop_types$12.default.bool,
12722 loader: import_prop_types$12.default.node,
12723 loadMore: import_prop_types$12.default.func.isRequired,
12724 pageStart: import_prop_types$12.default.number,
12725 ref: import_prop_types$12.default.func,
12726 getScrollParent: import_prop_types$12.default.func,
12727 threshold: import_prop_types$12.default.number,
12728 useCapture: import_prop_types$12.default.bool,
12729 useWindow: import_prop_types$12.default.bool
12730 });
12731 _defineProperty$1(InfiniteScroll, "defaultProps", {
12732 element: "div",
12733 hasMore: false,
12734 initialLoad: true,
12735 pageStart: 0,
12736 ref: null,
12737 threshold: 250,
12738 useWindow: true,
12739 isReverse: false,
12740 useCapture: false,
12741 loader: null,
12742 getScrollParent: null
12743 });
12744
12745 //#endregion
12746 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-upgrade.js
12747 init_defineProperty();
12748 init_history_types();
12749 var VARIANT_FULL = "full";
12750 var VARIANT_SMALL = "small";
12751 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"));
12752 var actionUrl = "https://go.elementor.com/ai-popup-purchase-dropdown/";
12753 var getMessage = function getMessage(variant, historyType) {
12754 return (0, _wordpress_i18n.sprintf)(messages[variant] || messages[VARIANT_FULL], getTranslatedPromptHistoryType(historyType));
12755 };
12756 var PromptHistoryUpgrade = function PromptHistoryUpgrade(_ref) {
12757 var variant = _ref.variant;
12758 var historyType = _ref.historyType;
12759 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
12760 justifyContent: "center",
12761 sx: {
12762 height: VARIANT_SMALL === variant ? "auto" : "100%",
12763 textAlign: "center",
12764 p: 2
12765 },
12766 "data-testid": "e-ph-upgrade-".concat(variant)
12767 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
12768 variant: "body1",
12769 sx: { marginBottom: 2 }
12770 }, getMessage(variant, historyType)), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
12771 variant: "contained",
12772 color: "promotion",
12773 size: "small",
12774 href: actionUrl,
12775 target: "_blank",
12776 rel: "noopener noreferrer",
12777 startIcon: /*#__PURE__*/ react.default.createElement(_elementor_icons.UpgradeIcon, null),
12778 sx: {
12779 width: "50%",
12780 alignSelf: "center",
12781 "&:hover": { color: "promotion.contrastText" }
12782 }
12783 }, (0, _wordpress_i18n.__)("Upgrade now", "elementor")));
12784 };
12785 PromptHistoryUpgrade.propTypes = {
12786 variant: import_prop_types$12.default.oneOf([VARIANT_FULL, VARIANT_SMALL]).isRequired,
12787 historyType: import_prop_types$12.default.oneOf(Object.values(HISTORY_TYPES)).isRequired
12788 };
12789
12790 //#endregion
12791 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-container.js
12792 init_extends();
12793 init_objectWithoutProperties();
12794 init_prompt_history_context();
12795 var _excluded$6 = ["children"];
12796 var _templateObject$1;
12797 var StyledContent$1 = (0, _elementor_ui.styled)(_elementor_ui.Box)(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral([
12798 "\n width: 360px;\n position: relative;\n margin-top: ",
12799 ";\n margin-right: ",
12800 ";\n background-color: ",
12801 ";\n border-radius: ",
12802 ";\n height: ",
12803 ";\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"
12804 ])), function(_ref) {
12805 return _ref.theme.spacing(2);
12806 }, function(_ref2) {
12807 return _ref2.theme.spacing(2);
12808 }, function(_ref3) {
12809 return _ref3.theme.palette.background.paper;
12810 }, function(_ref4) {
12811 var theme = _ref4.theme;
12812 return "".concat(theme.shape.borderRadius, "px");
12813 }, function(_ref5) {
12814 var height = _ref5.height;
12815 return "calc( ".concat(height, "px - 32px )");
12816 });
12817 var ModalContainer = function ModalContainer(_ref6) {
12818 var children = _ref6.children;
12819 var props = _objectWithoutProperties(_ref6, _excluded$6);
12820 var _usePromptHistoryCont = usePromptHistoryContext();
12821 var isOpen = _usePromptHistoryCont.isOpen;
12822 var isModalOpen = _usePromptHistoryCont.isModalOpen;
12823 var onClose = _usePromptHistoryCont.onClose;
12824 var getContainerHeight = _usePromptHistoryCont.getContainerHeight;
12825 var getContainer = _usePromptHistoryCont.getContainer;
12826 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Modal, _extends$1({
12827 container: getContainer(),
12828 open: isModalOpen,
12829 hideBackdrop: true,
12830 onClose,
12831 sx: { position: "absolute" }
12832 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.Backdrop, {
12833 open: true,
12834 sx: {
12835 position: "absolute",
12836 justifyContent: "flex-end",
12837 alignItems: "flex-start"
12838 },
12839 "aria-hidden": false
12840 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Slide, {
12841 direction: "left",
12842 in: isOpen,
12843 timeout: 500,
12844 easing: "ease-in-out"
12845 }, /*#__PURE__*/ react.default.createElement(StyledContent$1, {
12846 "aria-label": (0, _wordpress_i18n.__)("Prompt history modal", "elementor"),
12847 height: getContainerHeight()
12848 }, children))));
12849 };
12850 ModalContainer.propTypes = {
12851 isOpen: import_prop_types$12.default.bool.isRequired,
12852 isModalOpen: import_prop_types$12.default.bool.isRequired,
12853 onClose: import_prop_types$12.default.func.isRequired,
12854 children: import_prop_types$12.default.oneOfType([import_prop_types$12.default.arrayOf(import_prop_types$12.default.node), import_prop_types$12.default.node])
12855 };
12856
12857 //#endregion
12858 //#region modules/ai/assets/js/editor/components/prompt-history/history-modal.js
12859 init_asyncToGenerator();
12860 init_prompt_error_message();
12861 init_prompt_history_context();
12862 var ITEMS_LIMIT = 10;
12863 var FREE_PLAN_ERRORS = ["invalid_connect_data", "no_subscription"];
12864 var PromptHistoryModal = function PromptHistoryModal(props) {
12865 var lastRun = (0, react.useRef)(function() {});
12866 var scrollContainer = (0, react.useRef)(null);
12867 var _usePromptHistoryCont = usePromptHistoryContext();
12868 var historyType = _usePromptHistoryCont.historyType;
12869 var onClose = _usePromptHistoryCont.onClose;
12870 var _usePromptHistory = usePromptHistory(historyType);
12871 var items = _usePromptHistory.items;
12872 var meta = _usePromptHistory.meta;
12873 var isHistoryFetchingInProgress = _usePromptHistory.isLoading;
12874 var historyFetchingError = _usePromptHistory.error;
12875 var fetchData = _usePromptHistory.fetchData;
12876 var deleteItemFromState = _usePromptHistory.deleteItemById;
12877 var _useDeletePromptHisto = useDeletePromptHistoryItem();
12878 var isDeletingInProgress = _useDeletePromptHisto.isLoading;
12879 var historyDeletingError = _useDeletePromptHisto.error;
12880 var deleteItem = _useDeletePromptHisto.deleteItem;
12881 var error = historyFetchingError || historyDeletingError;
12882 var isLoading = isHistoryFetchingInProgress || isDeletingInProgress;
12883 var isLastPage = meta && (meta === null || meta === void 0 ? void 0 : meta.currentPage) === (meta === null || meta === void 0 ? void 0 : meta.totalPages);
12884 var showUpgrade = (items === null || items === void 0 ? void 0 : items.length) > 0 && (meta === null || meta === void 0 ? void 0 : meta.allowedDays) < 90 && isLastPage;
12885 (0, react.useEffect)(function() {
12886 lastRun.current = /*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee() {
12887 return import_regenerator$3.default.wrap(function(_context) {
12888 while (1) switch (_context.prev = _context.next) {
12889 case 0: return _context.abrupt("return", fetchData({
12890 page: 1,
12891 limit: ITEMS_LIMIT
12892 }));
12893 case 1:
12894 case "end": return _context.stop();
12895 }
12896 }, _callee);
12897 }));
12898 lastRun.current();
12899 }, []);
12900 var loadNext = function loadNext() {
12901 if (isLoading || isLastPage) return;
12902 lastRun.current = /*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee2() {
12903 return import_regenerator$3.default.wrap(function(_context2) {
12904 while (1) switch (_context2.prev = _context2.next) {
12905 case 0: return _context2.abrupt("return", fetchData({
12906 page: meta.currentPage + 1,
12907 limit: ITEMS_LIMIT
12908 }));
12909 case 1:
12910 case "end": return _context2.stop();
12911 }
12912 }, _callee2);
12913 }));
12914 lastRun.current();
12915 };
12916 var onHistoryItemDelete = /*#__PURE__*/ function() {
12917 var _ref3 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee4(id) {
12918 return import_regenerator$3.default.wrap(function(_context4) {
12919 while (1) switch (_context4.prev = _context4.next) {
12920 case 0:
12921 lastRun.current = /*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee3() {
12922 return import_regenerator$3.default.wrap(function(_context3) {
12923 while (1) switch (_context3.prev = _context3.next) {
12924 case 0:
12925 _context3.next = 1;
12926 return deleteItem(id);
12927 case 1: return _context3.abrupt("return", _context3.sent);
12928 case 2:
12929 case "end": return _context3.stop();
12930 }
12931 }, _callee3);
12932 }));
12933 _context4.next = 1;
12934 return lastRun.current();
12935 case 1: if (!historyDeletingError) deleteItemFromState(id);
12936 case 2:
12937 case "end": return _context4.stop();
12938 }
12939 }, _callee4);
12940 }));
12941 return function onHistoryItemDelete(_x) {
12942 return _ref3.apply(this, arguments);
12943 };
12944 }();
12945 return /*#__PURE__*/ react.default.createElement(ModalContainer, props, /*#__PURE__*/ react.default.createElement(PromptHistoryModalHeader, { onClose }), error && !FREE_PLAN_ERRORS.includes(error) && /*#__PURE__*/ react.default.createElement(PromptErrorMessage, {
12946 error,
12947 onRetry: lastRun.current,
12948 sx: {
12949 position: "absolute",
12950 zIndex: 1,
12951 marginTop: isLoading ? .5 : "revert"
12952 }
12953 }), isLoading && /*#__PURE__*/ react.default.createElement(_elementor_ui.LinearProgress, {
12954 role: "progressbar",
12955 "aria-label": (0, _wordpress_i18n.__)("Loading", "elementor"),
12956 color: "secondary"
12957 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
12958 sx: {
12959 overflowY: "scroll",
12960 height: "85%"
12961 },
12962 ref: scrollContainer
12963 }, error && FREE_PLAN_ERRORS.includes(error) && /*#__PURE__*/ react.default.createElement(PromptHistoryUpgrade, {
12964 variant: "full",
12965 historyType
12966 }), !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, {
12967 loadMore: loadNext,
12968 getScrollParent: function getScrollParent() {
12969 return scrollContainer.current;
12970 },
12971 useWindow: false,
12972 isReverse: false,
12973 threshold: 30,
12974 initialLoad: false,
12975 hasMore: !isLastPage
12976 }, renderPeriods({
12977 items,
12978 onDelete: onHistoryItemDelete
12979 })), showUpgrade && /*#__PURE__*/ react.default.createElement(PromptHistoryUpgrade, {
12980 variant: "small",
12981 historyType
12982 })));
12983 };
12984
12985 //#endregion
12986 //#region modules/ai/assets/js/editor/components/prompt-history/index.js
12987 init_prompt_history_context();
12988 var PROMPT_HISTORY_MODAL_ID = "prompt-history-modal";
12989 var PromptHistory = function PromptHistory() {
12990 var _usePromptHistoryCont = usePromptHistoryContext();
12991 var isOpen = _usePromptHistoryCont.isOpen;
12992 var isModalOpen = _usePromptHistoryCont.isModalOpen;
12993 var onOpen = _usePromptHistoryCont.onOpen;
12994 var onClose = _usePromptHistoryCont.onClose;
12995 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(PromptHistoryButton, {
12996 isActive: isOpen,
12997 onClick: function onClick() {
12998 return isOpen ? onClose() : onOpen();
12999 },
13000 "aria-haspopup": "dialog",
13001 "aria-controls": PROMPT_HISTORY_MODAL_ID
13002 }), isModalOpen && /*#__PURE__*/ react.default.createElement(PromptHistoryModal, { id: PROMPT_HISTORY_MODAL_ID }));
13003 };
13004
13005 //#endregion
13006 //#region modules/ai/assets/js/editor/pages/form-media/index.js
13007 init_extends();
13008 init_slicedToArray();
13009 init_defineProperty();
13010 function ownKeys$9(e, r) {
13011 var t = Object.keys(e);
13012 if (Object.getOwnPropertySymbols) {
13013 var o = Object.getOwnPropertySymbols(e);
13014 r && (o = o.filter(function(r) {
13015 return Object.getOwnPropertyDescriptor(e, r).enumerable;
13016 })), t.push.apply(t, o);
13017 }
13018 return t;
13019 }
13020 __name(ownKeys$9, "ownKeys");
13021 function _objectSpread$9(e) {
13022 for (var r = 1; r < arguments.length; r++) {
13023 var t = null != arguments[r] ? arguments[r] : {};
13024 r % 2 ? ownKeys$9(Object(t), !0).forEach(function(r) {
13025 _defineProperty(e, r, t[r]);
13026 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function(r) {
13027 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
13028 });
13029 }
13030 return e;
13031 }
13032 __name(_objectSpread$9, "_objectSpread");
13033 var initialData = {
13034 isAllSaved: false,
13035 hasUnsavedChanges: false
13036 };
13037 var SET_UNSAVED_CHANGES = "SET_UNSAVED_CHANGES";
13038 var SAVE_AND_CLOSE = "SAVE_AND_CLOSE";
13039 var reducer = function reducer(state, _ref) {
13040 var type = _ref.type;
13041 var payload = _ref.payload;
13042 switch (type) {
13043 case SET_UNSAVED_CHANGES: return _objectSpread$9(_objectSpread$9({}, state), {}, {
13044 hasUnsavedChanges: payload,
13045 isAllSaved: payload ? false : state.isAllSaved
13046 });
13047 case SAVE_AND_CLOSE: return _objectSpread$9(_objectSpread$9({}, state), {}, {
13048 isAllSaved: true,
13049 hasUnsavedChanges: false
13050 });
13051 default: throw Error("Unknown action.");
13052 }
13053 };
13054 var FormMedia = function FormMedia(_ref2) {
13055 var onClose = _ref2.onClose;
13056 var DialogProps = _ref2.DialogProps;
13057 var getControlValue = _ref2.getControlValue;
13058 var setControlValue = _ref2.setControlValue;
13059 var additionalOptions = _ref2.additionalOptions;
13060 var maybeRenderUpgradeChip = _ref2.maybeRenderUpgradeChip;
13061 var hasSubscription = _ref2.hasSubscription;
13062 var usagePercentage = _ref2.usagePercentage;
13063 var _useReducer2 = _slicedToArray((0, react.useReducer)(reducer, initialData), 2);
13064 var state = _useReducer2[0];
13065 var dispatch = _useReducer2[1];
13066 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
13067 var showUnsavedChangeAlert = _useState2[0];
13068 var setShowUnsavedChangeAlert = _useState2[1];
13069 var setHasUnsavedChanges = function setHasUnsavedChanges(payload) {
13070 return dispatch({
13071 type: SET_UNSAVED_CHANGES,
13072 payload
13073 });
13074 };
13075 var saveAndClose = function saveAndClose() {
13076 return dispatch({ type: SAVE_AND_CLOSE });
13077 };
13078 var onCloseIntent = function onCloseIntent() {
13079 if (state.hasUnsavedChanges) {
13080 setShowUnsavedChangeAlert(true);
13081 return;
13082 }
13083 onClose();
13084 };
13085 var editImageInitialData = getControlValue() === (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.defaultValue) ? {} : getControlValue();
13086 var globalSettings = {
13087 initialImageType: (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.defaultImageType) || "",
13088 hasSubscription,
13089 usagePercentage,
13090 hideBackButton: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.hideBackButton
13091 };
13092 var globalActions = {
13093 state,
13094 getControlValue,
13095 setControlValue,
13096 saveAndClose,
13097 close: onCloseIntent,
13098 setHasUnsavedChanges
13099 };
13100 (0, react.useEffect)(function() {
13101 if (state.isAllSaved) onClose();
13102 }, [state.isAllSaved]);
13103 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(PromptDialog, _extends$1({
13104 id: "e-form-media",
13105 onClose: function onClose() {
13106 return onCloseIntent();
13107 },
13108 maxWidth: "lg"
13109 }, DialogProps), /*#__PURE__*/ react.default.createElement(PromptDialog.Header, {
13110 onClose: function onClose() {
13111 return onCloseIntent();
13112 },
13113 hideAiBetaLogo: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.hideAiBetaLogo
13114 }, !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, {
13115 additionalOptions,
13116 onClose
13117 })))))), showUnsavedChangeAlert && /*#__PURE__*/ react.default.createElement(UnsavedChangesAlert$1, {
13118 onClose,
13119 onCancel: function onCancel() {
13120 return setShowUnsavedChangeAlert(false);
13121 },
13122 open: true
13123 }));
13124 };
13125 FormMedia.propTypes = {
13126 onClose: import_prop_types$12.default.func.isRequired,
13127 DialogProps: import_prop_types$12.default.object,
13128 getControlValue: import_prop_types$12.default.func.isRequired,
13129 setControlValue: import_prop_types$12.default.func.isRequired,
13130 additionalOptions: import_prop_types$12.default.object,
13131 credits: import_prop_types$12.default.number,
13132 maybeRenderUpgradeChip: import_prop_types$12.default.func,
13133 hasSubscription: import_prop_types$12.default.bool,
13134 usagePercentage: import_prop_types$12.default.number
13135 };
13136
13137 //#endregion
13138 //#region modules/ai/assets/js/editor/hooks/use-animation-prompt.js
13139 init_typeof();
13140 init_slicedToArray();
13141 init_defineProperty();
13142 init_asyncToGenerator();
13143 init_api();
13144 init_use_prompt();
13145 function ownKeys$8(e, r) {
13146 var t = Object.keys(e);
13147 if (Object.getOwnPropertySymbols) {
13148 var o = Object.getOwnPropertySymbols(e);
13149 r && (o = o.filter(function(r) {
13150 return Object.getOwnPropertyDescriptor(e, r).enumerable;
13151 })), t.push.apply(t, o);
13152 }
13153 return t;
13154 }
13155 __name(ownKeys$8, "ownKeys");
13156 function _objectSpread$8(e) {
13157 for (var r = 1; r < arguments.length; r++) {
13158 var t = null != arguments[r] ? arguments[r] : {};
13159 r % 2 ? ownKeys$8(Object(t), !0).forEach(function(r) {
13160 _defineProperty(e, r, t[r]);
13161 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function(r) {
13162 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
13163 });
13164 }
13165 return e;
13166 }
13167 __name(_objectSpread$8, "_objectSpread");
13168 var getAnimationResult = /*#__PURE__*/ function() {
13169 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee(payload, motionEffectType) {
13170 return import_regenerator$3.default.wrap(function(_context) {
13171 while (1) switch (_context.prev = _context.next) {
13172 case 0: return _context.abrupt("return", getAnimation(_objectSpread$8(_objectSpread$8({}, payload), {}, { motionEffectType })));
13173 case 1:
13174 case "end": return _context.stop();
13175 }
13176 }, _callee);
13177 }));
13178 return function getAnimationResult(_x, _x2) {
13179 return _ref.apply(this, arguments);
13180 };
13181 }();
13182 var useAnimationPrompt = function useAnimationPrompt(motionEffectType, widgetType, initialValue) {
13183 var _usePrompt = usePrompt(function(payload) {
13184 return getAnimationResult(payload, motionEffectType);
13185 }, initialValue);
13186 var data = _usePrompt.data;
13187 var isLoading = _usePrompt.isLoading;
13188 var error = _usePrompt.error;
13189 var reset = _usePrompt.reset;
13190 var send = _usePrompt.send;
13191 var sendUsageData = _usePrompt.sendUsageData;
13192 var getControlData = function getControlData(controlKey) {
13193 var _elementor$widgetsCac;
13194 var _elementor$widgetsCac2;
13195 return {
13196 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,
13197 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
13198 };
13199 };
13200 var processMotionEffects = function processMotionEffects(jsonObject) {
13201 var result = {};
13202 var firstChild = jsonObject[Object.keys(jsonObject)[0]];
13203 var firstEnableControlKey = Object.keys(firstChild)[0];
13204 result[firstEnableControlKey] = {
13205 isParent: true,
13206 label: getControlData(firstEnableControlKey).label,
13207 value: jsonObject.enabled[firstEnableControlKey],
13208 tabs: 0
13209 };
13210 var processOtherProps = function processOtherProps(props) {
13211 for (var _i = 0, _Object$entries = Object.entries(props); _i < _Object$entries.length; _i++) {
13212 var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2);
13213 var key = _Object$entries$_i[0];
13214 var value = _Object$entries$_i[1];
13215 if ("enabled" === key && value) {
13216 var enableControlKey = Object.keys(value)[0];
13217 result[enableControlKey] = {
13218 isParent: false,
13219 label: getControlData(enableControlKey).label,
13220 value: value[enableControlKey],
13221 tabs: 1
13222 };
13223 } else {
13224 if ("none" === value || "normal" === value) continue;
13225 result[key] = { value };
13226 }
13227 }
13228 };
13229 for (var _i2 = 0, _Object$entries2 = Object.entries(jsonObject); _i2 < _Object$entries2.length; _i2++) {
13230 var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2);
13231 var propKey = _Object$entries2$_i[0];
13232 var propValue = _Object$entries2$_i[1];
13233 if (propKey !== "enabled" && "object" === _typeof(propValue)) processOtherProps(propValue);
13234 }
13235 return result;
13236 };
13237 var processEntranceEffects = function processEntranceEffects(jsonObject) {
13238 var result = {};
13239 var firstChildKey = Object.keys(jsonObject)[0];
13240 var firstChild = jsonObject[firstChildKey];
13241 result[firstChildKey] = {
13242 isParent: true,
13243 label: getControlData(firstChildKey).label,
13244 value: firstChild,
13245 tabs: 0
13246 };
13247 result[firstChild] = {
13248 isParent: false,
13249 label: firstChild,
13250 tabs: 1
13251 };
13252 var processProps = function processProps(props) {
13253 for (var _i3 = 0, _Object$entries3 = Object.entries(props); _i3 < _Object$entries3.length; _i3++) {
13254 var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2);
13255 var key = _Object$entries3$_i[0];
13256 var value = _Object$entries3$_i[1];
13257 if ("none" === value || "normal" === value) continue;
13258 result[key] = { value };
13259 }
13260 };
13261 for (var _i4 = 0, _Object$entries4 = Object.entries(jsonObject); _i4 < _Object$entries4.length; _i4++) {
13262 var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2);
13263 var propKey = _Object$entries4$_i[0];
13264 var propValue = _Object$entries4$_i[1];
13265 if (propKey !== firstChildKey && "object" === _typeof(propValue)) processProps(propValue);
13266 }
13267 return result;
13268 };
13269 var processHoverEffects = function processHoverEffects(jsonObject) {
13270 var result = {};
13271 var isHoverLabelAdded = false;
13272 var processProps = function processProps(props) {
13273 for (var _i5 = 0, _Object$entries5 = Object.entries(props); _i5 < _Object$entries5.length; _i5++) {
13274 var _Object$entries5$_i = _slicedToArray(_Object$entries5[_i5], 2);
13275 var key = _Object$entries5$_i[0];
13276 var value = _Object$entries5$_i[1];
13277 if ("enabled" === key && value) {
13278 var enableControlKey = Object.keys(value)[0];
13279 var _getControlData = getControlData(enableControlKey);
13280 var label = _getControlData.label;
13281 var innerTab = _getControlData.innerTab;
13282 if (!isHoverLabelAdded) {
13283 result[innerTab] = {
13284 isParent: true,
13285 label: getControlData(innerTab).label,
13286 tabs: 0
13287 };
13288 isHoverLabelAdded = true;
13289 }
13290 result[enableControlKey] = {
13291 isParent: false,
13292 label,
13293 value: value[enableControlKey],
13294 tabs: 1
13295 };
13296 } else {
13297 if ("none" === value || "normal" === value) continue;
13298 result[key] = { value };
13299 }
13300 }
13301 };
13302 for (var _i6 = 0, _Object$entries6 = Object.entries(jsonObject); _i6 < _Object$entries6.length; _i6++) {
13303 var propValue = _slicedToArray(_Object$entries6[_i6], 2)[1];
13304 if ("object" === _typeof(propValue)) processProps(propValue);
13305 }
13306 return result;
13307 };
13308 var digestResult = function digestResult(jsonString) {
13309 var result = {};
13310 function traverse(currentObj) {
13311 if (!currentObj || _typeof(currentObj) !== "object") return;
13312 for (var key in currentObj) {
13313 if (!currentObj.hasOwnProperty(key)) continue;
13314 if (["scrolling_effects", "mouse_effects"].includes(key)) {
13315 result = _objectSpread$8(_objectSpread$8({}, result), processMotionEffects(currentObj[key]));
13316 continue;
13317 }
13318 if ("entrance_effects" === key) {
13319 result = _objectSpread$8(_objectSpread$8({}, result), processEntranceEffects(currentObj[key]));
13320 continue;
13321 }
13322 if ("hover_effects" === key) {
13323 result = _objectSpread$8(_objectSpread$8({}, result), processHoverEffects(currentObj[key]));
13324 return;
13325 }
13326 traverse(currentObj[key]);
13327 }
13328 }
13329 traverse(JSON.parse(jsonString));
13330 return result;
13331 };
13332 (0, react.useEffect)(function() {
13333 if (data.result) data.result = digestResult(data.result);
13334 }, [data]);
13335 return {
13336 data,
13337 isLoading,
13338 error,
13339 reset,
13340 send,
13341 sendUsageData
13342 };
13343 };
13344
13345 //#endregion
13346 //#region modules/ai/assets/js/editor/pages/form-animation/index.js
13347 init_asyncToGenerator();
13348 init_slicedToArray();
13349 init_actions_data();
13350 init_loader();
13351 init_prompt_search();
13352 init_prompt_suggestions();
13353 init_generate_button();
13354 init_prompt_error_message();
13355 init_requests_ids();
13356 init_voice_promotion_alert();
13357 var CodeDisplayWrapper$1 = (0, _elementor_ui.styled)(_elementor_ui.Box)(function() {
13358 return {
13359 "& p": {
13360 mb: "10px",
13361 fontSize: "14px",
13362 lineHeight: "1.5"
13363 },
13364 "& pre": { position: "relative" },
13365 "& textarea": {
13366 fontSize: "13px",
13367 lineHeight: "1.7"
13368 }
13369 };
13370 });
13371 var FormAnimation = function FormAnimation(_ref) {
13372 var onClose = _ref.onClose;
13373 var getControlValue = _ref.getControlValue;
13374 var setControlValue = _ref.setControlValue;
13375 var additionalOptions = _ref.additionalOptions;
13376 var credits = _ref.credits;
13377 var children = _ref.children;
13378 var _useAnimationPrompt = useAnimationPrompt(additionalOptions.animationType, additionalOptions.widgetType, credits);
13379 var data = _useAnimationPrompt.data;
13380 var isLoading = _useAnimationPrompt.isLoading;
13381 var error = _useAnimationPrompt.error;
13382 var reset = _useAnimationPrompt.reset;
13383 var send = _useAnimationPrompt.send;
13384 var sendUsageData = _useAnimationPrompt.sendUsageData;
13385 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
13386 var prompt = _useState2[0];
13387 var setPrompt = _useState2[1];
13388 var setGenerate = useRequestIds().setGenerate;
13389 var _useState4 = _slicedToArray((0, react.useState)(""), 2);
13390 var animationSummary = _useState4[0];
13391 var setAnimationSummary = _useState4[1];
13392 var _useState6 = _slicedToArray((0, react.useState)(), 2);
13393 var prevControlValue = _useState6[0];
13394 var setPrevControlValue = _useState6[1];
13395 var lastRun = (0, react.useRef)(function() {});
13396 var autocompleteItems = "hover" === additionalOptions.animationType ? hoverEffectAutocomplete : motionEffectAutocomplete;
13397 var showSuggestions = !prompt;
13398 var handleSubmit = /*#__PURE__*/ function() {
13399 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee(event) {
13400 return import_regenerator$3.default.wrap(function(_context) {
13401 while (1) switch (_context.prev = _context.next) {
13402 case 0:
13403 event.preventDefault();
13404 setGenerate();
13405 lastRun.current = function() {
13406 return send({ prompt });
13407 };
13408 _context.next = 1;
13409 return lastRun.current();
13410 case 1:
13411 case "end": return _context.stop();
13412 }
13413 }, _callee);
13414 }));
13415 return function handleSubmit(_x) {
13416 return _ref2.apply(this, arguments);
13417 };
13418 }();
13419 (0, react.useEffect)(function() {
13420 if (data.result) showPreview(data.result);
13421 }, [data]);
13422 (0, react.useEffect)(function() {
13423 return function() {
13424 restorePrevSettings();
13425 };
13426 }, []);
13427 var showPreview = function showPreview(result) {
13428 var summary = Object.keys(result).filter(function(key) {
13429 return result[key].label;
13430 }).map(function(key) {
13431 var item = result[key];
13432 var tabs = "&nbsp;".repeat(item.tabs);
13433 var bulletIcon = item.tabs > 0 ? "&#8226; " : "";
13434 var label = item.isParent ? "<br/><b>".concat(item.label, ":</b>") : "".concat(bulletIcon, " ").concat(item.label);
13435 return "".concat(tabs).concat(label);
13436 }).join("<br/>");
13437 var title = "".concat((0, _wordpress_i18n.__)("Here’s a breakdown of what was done for creating the animation", "elementor"));
13438 setAnimationSummary("<b>".concat(title, ":</b><br/>").concat(summary));
13439 setPrevControlValue(getControlValue());
13440 elementor.documents.getCurrent().history.setActive(false);
13441 setControlValue(getValidElementor(result));
13442 };
13443 var restorePrevSettings = function restorePrevSettings() {
13444 setControlValue(prevControlValue);
13445 elementor.documents.getCurrent().history.setActive(true);
13446 };
13447 var getValidElementor = function getValidElementor(result) {
13448 return Object.entries(result).filter(function(_ref3) {
13449 return _slicedToArray(_ref3, 2)[1].hasOwnProperty("value");
13450 }).reduce(function(previousValue, _ref5) {
13451 var _ref6 = _slicedToArray(_ref5, 2);
13452 var key = _ref6[0];
13453 previousValue[key] = _ref6[1].value;
13454 return previousValue;
13455 }, {});
13456 };
13457 var applyPrompt = function applyPrompt(result) {
13458 sendUsageData();
13459 restorePrevSettings();
13460 setControlValue(getValidElementor(result));
13461 onClose();
13462 };
13463 if (isLoading) return /*#__PURE__*/ react.default.createElement(Loader, null);
13464 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, error && /*#__PURE__*/ react.default.createElement(PromptErrorMessage, {
13465 error,
13466 onRetry: lastRun.current,
13467 sx: { mb: 2.5 }
13468 }), children, !data.result && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
13469 component: "form",
13470 onSubmit: handleSubmit
13471 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: { pb: 1.5 } }, /*#__PURE__*/ react.default.createElement(PromptSearch, {
13472 placeholder: (0, _wordpress_i18n.__)("Describe the animation you want to create...", "elementor"),
13473 name: "prompt",
13474 value: prompt,
13475 color: "secondary",
13476 onChange: function onChange(event) {
13477 return setPrompt(event.target.value);
13478 }
13479 })), showSuggestions && /*#__PURE__*/ react.default.createElement(PromptSuggestions, {
13480 suggestions: autocompleteItems,
13481 onSelect: setPrompt
13482 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
13483 direction: "row",
13484 alignItems: "center",
13485 sx: {
13486 py: 1.5,
13487 mt: 4
13488 }
13489 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
13490 direction: "row",
13491 justifyContent: "flex-end",
13492 flexGrow: 1
13493 }, /*#__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: {
13494 backgroundColor: "rgba(0, 0, 0, 0.06); ",
13495 padding: "1em",
13496 borderRadius: "4px",
13497 width: "100%",
13498 height: "260px",
13499 overflowX: "auto"
13500 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
13501 variant: "body1",
13502 dangerouslySetInnerHTML: { __html: animationSummary }
13503 })), /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, { introductionKey: "ai-context-animation-promotion" }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
13504 direction: "row",
13505 alignItems: "center",
13506 sx: { mt: 4 }
13507 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
13508 direction: "row",
13509 gap: 1,
13510 justifyContent: "flex-end",
13511 flexGrow: 1
13512 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
13513 size: "small",
13514 color: "secondary",
13515 variant: "text",
13516 onClick: function onClick() {
13517 restorePrevSettings();
13518 reset();
13519 }
13520 }, (0, _wordpress_i18n.__)("New prompt", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
13521 size: "small",
13522 variant: "contained",
13523 color: "primary",
13524 onClick: function onClick() {
13525 return applyPrompt(data.result);
13526 }
13527 }, (0, _wordpress_i18n.__)("Use animation", "elementor"))))));
13528 };
13529 FormAnimation.propTypes = {
13530 onClose: import_prop_types$12.default.func.isRequired,
13531 getControlValue: import_prop_types$12.default.func.isRequired,
13532 setControlValue: import_prop_types$12.default.func.isRequired,
13533 additionalOptions: import_prop_types$12.default.shape({
13534 animationType: import_prop_types$12.default.string,
13535 widgetType: import_prop_types$12.default.string
13536 }),
13537 credits: import_prop_types$12.default.number,
13538 children: import_prop_types$12.default.node
13539 };
13540
13541 //#endregion
13542 //#region \0vite/preload-helper.js
13543 var scriptRel, assetsURL, seen, __vitePreload;
13544 var init_preload_helper = __esmMin((() => {
13545 scriptRel = "modulepreload";
13546 assetsURL = function(dep) {
13547 return "/" + dep;
13548 };
13549 seen = {};
13550 __vitePreload = function preload(baseModule, deps, importerUrl) {
13551 let promise = Promise.resolve();
13552 if (false && deps && deps.length > 0) {
13553 const links = document.getElementsByTagName("link");
13554 const cspNonceMeta = document.querySelector("meta[property=csp-nonce]");
13555 const cspNonce = (cspNonceMeta === null || cspNonceMeta === void 0 ? void 0 : cspNonceMeta.nonce) || (cspNonceMeta === null || cspNonceMeta === void 0 ? void 0 : cspNonceMeta.getAttribute("nonce"));
13556 function allSettled(promises) {
13557 return Promise.all(promises.map((p) => Promise.resolve(p).then((value) => ({
13558 status: "fulfilled",
13559 value
13560 }), (reason) => ({
13561 status: "rejected",
13562 reason
13563 }))));
13564 }
13565 function importMetaResolve(specifier) {
13566 if ({}.resolve) return {}.resolve(specifier);
13567 return new URL(
13568 specifier,
13569 /** #__KEEP__ */
13570 {}.url
13571 ).href;
13572 }
13573 promise = allSettled(deps.map((dep) => {
13574 dep = assetsURL(dep, importerUrl);
13575 dep = importMetaResolve(dep);
13576 if (dep in seen) return;
13577 seen[dep] = true;
13578 const isCss = dep.endsWith(".css");
13579 for (let i = links.length - 1; i >= 0; i--) {
13580 const link = links[i];
13581 if (link.href === dep && (!isCss || link.rel === "stylesheet")) return;
13582 }
13583 const link = document.createElement("link");
13584 link.rel = isCss ? "stylesheet" : scriptRel;
13585 if (!isCss) link.as = "script";
13586 link.crossOrigin = "";
13587 link.href = dep;
13588 if (cspNonce) link.setAttribute("nonce", cspNonce);
13589 document.head.appendChild(link);
13590 if (isCss) return new Promise((res, rej) => {
13591 link.addEventListener("load", res);
13592 link.addEventListener("error", () => rej(/* @__PURE__ */ new Error(`Unable to preload CSS for ${dep}`)));
13593 });
13594 }));
13595 }
13596 function handlePreloadError(err) {
13597 const e = new Event("vite:preloadError", { cancelable: true });
13598 e.payload = err;
13599 window.dispatchEvent(e);
13600 if (!e.defaultPrevented) throw err;
13601 }
13602 return promise.then((res) => {
13603 for (const item of res || []) {
13604 if (item.status !== "rejected") continue;
13605 handlePreloadError(item.reason);
13606 }
13607 return baseModule().catch(handlePreloadError);
13608 });
13609 };
13610 }));
13611
13612 //#endregion
13613 //#region modules/ai/assets/js/editor/pages/form-code/code-block.js
13614 var import_prop_types$2, _excluded$5, CodeBlock;
13615 var init_code_block = __esmMin((() => {
13616 init_extends();
13617 init_objectWithoutProperties();
13618 import_prop_types$2 = /* @__PURE__ */ __toESM(require_prop_types());
13619 init_textarea();
13620 _excluded$5 = [
13621 "node",
13622 "inline",
13623 "children",
13624 "defaultValue",
13625 "onInsert"
13626 ];
13627 CodeBlock = function CodeBlock(_ref) {
13628 _ref.node;
13629 var inline = _ref.inline;
13630 var children = _ref.children;
13631 var defaultValue = _ref.defaultValue;
13632 var onInsert = _ref.onInsert;
13633 var props = _objectWithoutProperties(_ref, _excluded$5);
13634 var codeBlockInput = (0, react.useRef)(null);
13635 if (inline) return /*#__PURE__*/ react.default.createElement("code", props);
13636 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
13637 sx: { position: "relative" },
13638 dir: "ltr"
13639 }, /*#__PURE__*/ react.default.createElement(Textarea, _extends$1({
13640 fullWidth: true,
13641 ref: codeBlockInput,
13642 defaultValue: children[0],
13643 sx: { mb: 1 },
13644 helperText: (0, _wordpress_i18n.__)("Code generated by AI may be inaccurate.", "elementor")
13645 }, props)), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
13646 size: "small",
13647 variant: "contained",
13648 onClick: function onClick() {
13649 return onInsert(defaultValue + "\n" + codeBlockInput.current.value);
13650 },
13651 sx: {
13652 position: "absolute",
13653 right: "11px /* @noflip */",
13654 bottom: "44px"
13655 }
13656 }, (0, _wordpress_i18n.__)("Insert", "elementor")));
13657 };
13658 CodeBlock.propTypes = {
13659 node: import_prop_types$2.default.object,
13660 inline: import_prop_types$2.default.bool,
13661 children: import_prop_types$2.default.arrayOf(import_prop_types$2.default.node).isRequired,
13662 defaultValue: import_prop_types$2.default.string,
13663 onInsert: import_prop_types$2.default.func.isRequired
13664 };
13665 }));
13666
13667 //#endregion
13668 //#region modules/ai/assets/js/editor/hooks/use-code-prompt.js
13669 function ownKeys$7(e, r) {
13670 var t = Object.keys(e);
13671 if (Object.getOwnPropertySymbols) {
13672 var o = Object.getOwnPropertySymbols(e);
13673 r && (o = o.filter(function(r) {
13674 return Object.getOwnPropertyDescriptor(e, r).enumerable;
13675 })), t.push.apply(t, o);
13676 }
13677 return t;
13678 }
13679 function _objectSpread$7(e) {
13680 for (var r = 1; r < arguments.length; r++) {
13681 var t = null != arguments[r] ? arguments[r] : {};
13682 r % 2 ? ownKeys$7(Object(t), !0).forEach(function(r) {
13683 _defineProperty(e, r, t[r]);
13684 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function(r) {
13685 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
13686 });
13687 }
13688 return e;
13689 }
13690 var import_regenerator$1, getCodeResult, useCodePrompt;
13691 var init_use_code_prompt = __esmMin((() => {
13692 init_defineProperty();
13693 init_asyncToGenerator();
13694 import_regenerator$1 = /* @__PURE__ */ __toESM(require_regenerator());
13695 init_api();
13696 init_use_prompt();
13697 __name(ownKeys$7, "ownKeys");
13698 __name(_objectSpread$7, "_objectSpread");
13699 getCodeResult = /*#__PURE__*/ function() {
13700 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$1.default.mark(function _callee(payload, _ref) {
13701 var codeLanguage;
13702 var htmlMarkup;
13703 var elementId;
13704 return import_regenerator$1.default.wrap(function(_context) {
13705 while (1) switch (_context.prev = _context.next) {
13706 case 0:
13707 codeLanguage = _ref.codeLanguage, htmlMarkup = _ref.htmlMarkup, elementId = _ref.elementId;
13708 if (!("css" === codeLanguage)) {
13709 _context.next = 1;
13710 break;
13711 }
13712 return _context.abrupt("return", getCustomCSS(_objectSpread$7(_objectSpread$7({}, payload), {}, {
13713 html_markup: htmlMarkup,
13714 element_id: elementId
13715 })));
13716 case 1: return _context.abrupt("return", getCustomCode(_objectSpread$7(_objectSpread$7({}, payload), {}, { language: codeLanguage })));
13717 case 2:
13718 case "end": return _context.stop();
13719 }
13720 }, _callee);
13721 }));
13722 return function getCodeResult(_x, _x2) {
13723 return _ref2.apply(this, arguments);
13724 };
13725 }();
13726 useCodePrompt = function useCodePrompt(_ref3) {
13727 var codeLanguage = _ref3.codeLanguage;
13728 var htmlMarkup = _ref3.htmlMarkup;
13729 var elementId = _ref3.elementId;
13730 var credits = _ref3.initialCredits;
13731 return usePrompt(function(payload) {
13732 return getCodeResult(payload, {
13733 codeLanguage,
13734 htmlMarkup,
13735 elementId
13736 });
13737 }, { credits });
13738 };
13739 }));
13740
13741 //#endregion
13742 //#region modules/ai/assets/js/editor/pages/form-code/splitTextResult.js
13743 function splitText(inputText) {
13744 if (!inputText) return {};
13745 var codeMatch = inputText.match(/```([\s\S]*?)```/);
13746 var code = codeMatch ? "```".concat(codeMatch[1], "```").trim() : "";
13747 var detailsMatch = inputText.match(/```[\s\S]*?```([\s\S]*)/);
13748 return {
13749 code,
13750 details: detailsMatch === null || detailsMatch === void 0 ? void 0 : detailsMatch[1].trim()
13751 };
13752 }
13753 var init_splitTextResult = __esmMin((() => {}));
13754
13755 //#endregion
13756 //#region node_modules/react-markdown/lib/uri-transformer.js
13757 /**
13758 * @param {string} uri
13759 * @returns {string}
13760 */
13761 function uriTransformer(uri) {
13762 const url = (uri || "").trim();
13763 const first = url.charAt(0);
13764 if (first === "#" || first === "/") return url;
13765 const colon = url.indexOf(":");
13766 if (colon === -1) return url;
13767 let index = -1;
13768 while (++index < protocols.length) {
13769 const protocol = protocols[index];
13770 if (colon === protocol.length && url.slice(0, protocol.length).toLowerCase() === protocol) return url;
13771 }
13772 index = url.indexOf("?");
13773 if (index !== -1 && colon > index) return url;
13774 index = url.indexOf("#");
13775 if (index !== -1 && colon > index) return url;
13776 return "javascript:void(0)";
13777 }
13778 var protocols;
13779 var init_uri_transformer = __esmMin((() => {
13780 protocols = [
13781 "http",
13782 "https",
13783 "mailto",
13784 "tel"
13785 ];
13786 }));
13787
13788 //#endregion
13789 //#region node_modules/vfile/node_modules/is-buffer/index.js
13790 var require_is_buffer$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13791 /*!
13792 * Determine if an object is a Buffer
13793 *
13794 * @author Feross Aboukhadijeh <https://feross.org>
13795 * @license MIT
13796 */
13797 module.exports = function isBuffer(obj) {
13798 return obj != null && obj.constructor != null && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
13799 };
13800 }));
13801
13802 //#endregion
13803 //#region node_modules/unist-util-stringify-position/lib/index.js
13804 /**
13805 * @typedef {import('unist').Node} Node
13806 * @typedef {import('unist').Point} Point
13807 * @typedef {import('unist').Position} Position
13808 */
13809 /**
13810 * @typedef NodeLike
13811 * @property {string} type
13812 * @property {PositionLike | null | undefined} [position]
13813 *
13814 * @typedef PositionLike
13815 * @property {PointLike | null | undefined} [start]
13816 * @property {PointLike | null | undefined} [end]
13817 *
13818 * @typedef PointLike
13819 * @property {number | null | undefined} [line]
13820 * @property {number | null | undefined} [column]
13821 * @property {number | null | undefined} [offset]
13822 */
13823 /**
13824 * Serialize the positional info of a point, position (start and end points),
13825 * or node.
13826 *
13827 * @param {Node | NodeLike | Position | PositionLike | Point | PointLike | null | undefined} [value]
13828 * Node, position, or point.
13829 * @returns {string}
13830 * Pretty printed positional info of a node (`string`).
13831 *
13832 * In the format of a range `ls:cs-le:ce` (when given `node` or `position`)
13833 * or a point `l:c` (when given `point`), where `l` stands for line, `c` for
13834 * column, `s` for `start`, and `e` for end.
13835 * An empty string (`''`) is returned if the given value is neither `node`,
13836 * `position`, nor `point`.
13837 */
13838 function stringifyPosition(value) {
13839 if (!value || typeof value !== "object") return "";
13840 if ("position" in value || "type" in value) return position$1(value.position);
13841 if ("start" in value || "end" in value) return position$1(value);
13842 if ("line" in value || "column" in value) return point$2(value);
13843 return "";
13844 }
13845 /**
13846 * @param {Point | PointLike | null | undefined} point
13847 * @returns {string}
13848 */
13849 function point$2(point) {
13850 return index(point && point.line) + ":" + index(point && point.column);
13851 }
13852 /**
13853 * @param {Position | PositionLike | null | undefined} pos
13854 * @returns {string}
13855 */
13856 function position$1(pos) {
13857 return point$2(pos && pos.start) + "-" + point$2(pos && pos.end);
13858 }
13859 /**
13860 * @param {number | null | undefined} value
13861 * @returns {number}
13862 */
13863 function index(value) {
13864 return value && typeof value === "number" ? value : 1;
13865 }
13866 var init_lib$15 = __esmMin((() => {
13867 __name(point$2, "point");
13868 __name(position$1, "position");
13869 }));
13870
13871 //#endregion
13872 //#region node_modules/unist-util-stringify-position/index.js
13873 var init_unist_util_stringify_position = __esmMin((() => {
13874 init_lib$15();
13875 }));
13876
13877 //#endregion
13878 //#region node_modules/vfile-message/lib/index.js
13879 var VFileMessage;
13880 var init_lib$14 = __esmMin((() => {
13881 init_unist_util_stringify_position();
13882 VFileMessage = class extends Error {
13883 /**
13884 * Create a message for `reason` at `place` from `origin`.
13885 *
13886 * When an error is passed in as `reason`, the `stack` is copied.
13887 *
13888 * @param {string | Error | VFileMessage} reason
13889 * Reason for message, uses the stack and message of the error if given.
13890 *
13891 * > 👉 **Note**: you should use markdown.
13892 * @param {Node | NodeLike | Position | Point | null | undefined} [place]
13893 * Place in file where the message occurred.
13894 * @param {string | null | undefined} [origin]
13895 * Place in code where the message originates (example:
13896 * `'my-package:my-rule'` or `'my-rule'`).
13897 * @returns
13898 * Instance of `VFileMessage`.
13899 */
13900 constructor(reason, place, origin) {
13901 /** @type {[string | null, string | null]} */
13902 const parts = [null, null];
13903 /** @type {Position} */
13904 let position = {
13905 start: {
13906 line: null,
13907 column: null
13908 },
13909 end: {
13910 line: null,
13911 column: null
13912 }
13913 };
13914 super();
13915 if (typeof place === "string") {
13916 origin = place;
13917 place = void 0;
13918 }
13919 if (typeof origin === "string") {
13920 const index = origin.indexOf(":");
13921 if (index === -1) parts[1] = origin;
13922 else {
13923 parts[0] = origin.slice(0, index);
13924 parts[1] = origin.slice(index + 1);
13925 }
13926 }
13927 if (place) {
13928 if ("type" in place || "position" in place) {
13929 if (place.position) position = place.position;
13930 } else if ("start" in place || "end" in place) position = place;
13931 else if ("line" in place || "column" in place) position.start = place;
13932 }
13933 /**
13934 * Serialized positional info of error.
13935 *
13936 * On normal errors, this would be something like `ParseError`, buit in
13937 * `VFile` messages we use this space to show where an error happened.
13938 */
13939 this.name = stringifyPosition(place) || "1:1";
13940 /**
13941 * Reason for message.
13942 *
13943 * @type {string}
13944 */
13945 this.message = typeof reason === "object" ? reason.message : reason;
13946 /**
13947 * Stack of message.
13948 *
13949 * This is used by normal errors to show where something happened in
13950 * programming code, irrelevant for `VFile` messages,
13951 *
13952 * @type {string}
13953 */
13954 this.stack = "";
13955 if (typeof reason === "object" && reason.stack) this.stack = reason.stack;
13956 /**
13957 * Reason for message.
13958 *
13959 * > 👉 **Note**: you should use markdown.
13960 *
13961 * @type {string}
13962 */
13963 this.reason = this.message;
13964 /**
13965 * State of problem.
13966 *
13967 * * `true` — marks associated file as no longer processable (error)
13968 * * `false` — necessitates a (potential) change (warning)
13969 * * `null | undefined` — for things that might not need changing (info)
13970 *
13971 * @type {boolean | null | undefined}
13972 */
13973 this.fatal;
13974 /**
13975 * Starting line of error.
13976 *
13977 * @type {number | null}
13978 */
13979 this.line = position.start.line;
13980 /**
13981 * Starting column of error.
13982 *
13983 * @type {number | null}
13984 */
13985 this.column = position.start.column;
13986 /**
13987 * Full unist position.
13988 *
13989 * @type {Position | null}
13990 */
13991 this.position = position;
13992 /**
13993 * Namespace of message (example: `'my-package'`).
13994 *
13995 * @type {string | null}
13996 */
13997 this.source = parts[0];
13998 /**
13999 * Category of message (example: `'my-rule'`).
14000 *
14001 * @type {string | null}
14002 */
14003 this.ruleId = parts[1];
14004 /**
14005 * Path of a file (used throughout the `VFile` ecosystem).
14006 *
14007 * @type {string | null}
14008 */
14009 this.file;
14010 /**
14011 * Specify the source value that’s being reported, which is deemed
14012 * incorrect.
14013 *
14014 * @type {string | null}
14015 */
14016 this.actual;
14017 /**
14018 * Suggest acceptable values that can be used instead of `actual`.
14019 *
14020 * @type {Array<string> | null}
14021 */
14022 this.expected;
14023 /**
14024 * Link to docs for the message.
14025 *
14026 * > 👉 **Note**: this must be an absolute URL that can be passed as `x`
14027 * > to `new URL(x)`.
14028 *
14029 * @type {string | null}
14030 */
14031 this.url;
14032 /**
14033 * Long form description of the message (you should use markdown).
14034 *
14035 * @type {string | null}
14036 */
14037 this.note;
14038 }
14039 };
14040 VFileMessage.prototype.file = "";
14041 VFileMessage.prototype.name = "";
14042 VFileMessage.prototype.reason = "";
14043 VFileMessage.prototype.message = "";
14044 VFileMessage.prototype.stack = "";
14045 VFileMessage.prototype.fatal = null;
14046 VFileMessage.prototype.column = null;
14047 VFileMessage.prototype.line = null;
14048 VFileMessage.prototype.source = null;
14049 VFileMessage.prototype.ruleId = null;
14050 VFileMessage.prototype.position = null;
14051 }));
14052
14053 //#endregion
14054 //#region node_modules/vfile-message/index.js
14055 var init_vfile_message = __esmMin((() => {
14056 init_lib$14();
14057 }));
14058
14059 //#endregion
14060 //#region node_modules/vfile/lib/minpath.browser.js
14061 /**
14062 * Get the basename from a path.
14063 *
14064 * @param {string} path
14065 * File path.
14066 * @param {string | undefined} [ext]
14067 * Extension to strip.
14068 * @returns {string}
14069 * Stem or basename.
14070 */
14071 function basename(path, ext) {
14072 if (ext !== void 0 && typeof ext !== "string") throw new TypeError("\"ext\" argument must be a string");
14073 assertPath$1(path);
14074 let start = 0;
14075 let end = -1;
14076 let index = path.length;
14077 /** @type {boolean | undefined} */
14078 let seenNonSlash;
14079 if (ext === void 0 || ext.length === 0 || ext.length > path.length) {
14080 while (index--) if (path.charCodeAt(index) === 47) {
14081 if (seenNonSlash) {
14082 start = index + 1;
14083 break;
14084 }
14085 } else if (end < 0) {
14086 seenNonSlash = true;
14087 end = index + 1;
14088 }
14089 return end < 0 ? "" : path.slice(start, end);
14090 }
14091 if (ext === path) return "";
14092 let firstNonSlashEnd = -1;
14093 let extIndex = ext.length - 1;
14094 while (index--) if (path.charCodeAt(index) === 47) {
14095 if (seenNonSlash) {
14096 start = index + 1;
14097 break;
14098 }
14099 } else {
14100 if (firstNonSlashEnd < 0) {
14101 seenNonSlash = true;
14102 firstNonSlashEnd = index + 1;
14103 }
14104 if (extIndex > -1) if (path.charCodeAt(index) === ext.charCodeAt(extIndex--)) {
14105 if (extIndex < 0) end = index;
14106 } else {
14107 extIndex = -1;
14108 end = firstNonSlashEnd;
14109 }
14110 }
14111 if (start === end) end = firstNonSlashEnd;
14112 else if (end < 0) end = path.length;
14113 return path.slice(start, end);
14114 }
14115 /**
14116 * Get the dirname from a path.
14117 *
14118 * @param {string} path
14119 * File path.
14120 * @returns {string}
14121 * File path.
14122 */
14123 function dirname(path) {
14124 assertPath$1(path);
14125 if (path.length === 0) return ".";
14126 let end = -1;
14127 let index = path.length;
14128 /** @type {boolean | undefined} */
14129 let unmatchedSlash;
14130 while (--index) if (path.charCodeAt(index) === 47) {
14131 if (unmatchedSlash) {
14132 end = index;
14133 break;
14134 }
14135 } else if (!unmatchedSlash) unmatchedSlash = true;
14136 return end < 0 ? path.charCodeAt(0) === 47 ? "/" : "." : end === 1 && path.charCodeAt(0) === 47 ? "//" : path.slice(0, end);
14137 }
14138 /**
14139 * Get an extname from a path.
14140 *
14141 * @param {string} path
14142 * File path.
14143 * @returns {string}
14144 * Extname.
14145 */
14146 function extname(path) {
14147 assertPath$1(path);
14148 let index = path.length;
14149 let end = -1;
14150 let startPart = 0;
14151 let startDot = -1;
14152 let preDotState = 0;
14153 /** @type {boolean | undefined} */
14154 let unmatchedSlash;
14155 while (index--) {
14156 const code = path.charCodeAt(index);
14157 if (code === 47) {
14158 if (unmatchedSlash) {
14159 startPart = index + 1;
14160 break;
14161 }
14162 continue;
14163 }
14164 if (end < 0) {
14165 unmatchedSlash = true;
14166 end = index + 1;
14167 }
14168 if (code === 46) {
14169 if (startDot < 0) startDot = index;
14170 else if (preDotState !== 1) preDotState = 1;
14171 } else if (startDot > -1) preDotState = -1;
14172 }
14173 if (startDot < 0 || end < 0 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) return "";
14174 return path.slice(startDot, end);
14175 }
14176 /**
14177 * Join segments from a path.
14178 *
14179 * @param {Array<string>} segments
14180 * Path segments.
14181 * @returns {string}
14182 * File path.
14183 */
14184 function join(...segments) {
14185 let index = -1;
14186 /** @type {string | undefined} */
14187 let joined;
14188 while (++index < segments.length) {
14189 assertPath$1(segments[index]);
14190 if (segments[index]) joined = joined === void 0 ? segments[index] : joined + "/" + segments[index];
14191 }
14192 return joined === void 0 ? "." : normalize$1(joined);
14193 }
14194 /**
14195 * Normalize a basic file path.
14196 *
14197 * @param {string} path
14198 * File path.
14199 * @returns {string}
14200 * File path.
14201 */
14202 function normalize$1(path) {
14203 assertPath$1(path);
14204 const absolute = path.charCodeAt(0) === 47;
14205 let value = normalizeString(path, !absolute);
14206 if (value.length === 0 && !absolute) value = ".";
14207 if (value.length > 0 && path.charCodeAt(path.length - 1) === 47) value += "/";
14208 return absolute ? "/" + value : value;
14209 }
14210 /**
14211 * Resolve `.` and `..` elements in a path with directory names.
14212 *
14213 * @param {string} path
14214 * File path.
14215 * @param {boolean} allowAboveRoot
14216 * Whether `..` can move above root.
14217 * @returns {string}
14218 * File path.
14219 */
14220 function normalizeString(path, allowAboveRoot) {
14221 let result = "";
14222 let lastSegmentLength = 0;
14223 let lastSlash = -1;
14224 let dots = 0;
14225 let index = -1;
14226 /** @type {number | undefined} */
14227 let code;
14228 /** @type {number} */
14229 let lastSlashIndex;
14230 while (++index <= path.length) {
14231 if (index < path.length) code = path.charCodeAt(index);
14232 else if (code === 47) break;
14233 else code = 47;
14234 if (code === 47) {
14235 if (lastSlash === index - 1 || dots === 1) {} else if (lastSlash !== index - 1 && dots === 2) {
14236 if (result.length < 2 || lastSegmentLength !== 2 || result.charCodeAt(result.length - 1) !== 46 || result.charCodeAt(result.length - 2) !== 46) {
14237 if (result.length > 2) {
14238 lastSlashIndex = result.lastIndexOf("/");
14239 if (lastSlashIndex !== result.length - 1) {
14240 if (lastSlashIndex < 0) {
14241 result = "";
14242 lastSegmentLength = 0;
14243 } else {
14244 result = result.slice(0, lastSlashIndex);
14245 lastSegmentLength = result.length - 1 - result.lastIndexOf("/");
14246 }
14247 lastSlash = index;
14248 dots = 0;
14249 continue;
14250 }
14251 } else if (result.length > 0) {
14252 result = "";
14253 lastSegmentLength = 0;
14254 lastSlash = index;
14255 dots = 0;
14256 continue;
14257 }
14258 }
14259 if (allowAboveRoot) {
14260 result = result.length > 0 ? result + "/.." : "..";
14261 lastSegmentLength = 2;
14262 }
14263 } else {
14264 if (result.length > 0) result += "/" + path.slice(lastSlash + 1, index);
14265 else result = path.slice(lastSlash + 1, index);
14266 lastSegmentLength = index - lastSlash - 1;
14267 }
14268 lastSlash = index;
14269 dots = 0;
14270 } else if (code === 46 && dots > -1) dots++;
14271 else dots = -1;
14272 }
14273 return result;
14274 }
14275 /**
14276 * Make sure `path` is a string.
14277 *
14278 * @param {string} path
14279 * File path.
14280 * @returns {asserts path is string}
14281 * Nothing.
14282 */
14283 function assertPath$1(path) {
14284 if (typeof path !== "string") throw new TypeError("Path must be a string. Received " + JSON.stringify(path));
14285 }
14286 var path;
14287 var init_minpath_browser = __esmMin((() => {
14288 path = {
14289 basename,
14290 dirname,
14291 extname,
14292 join,
14293 sep: "/"
14294 };
14295 __name(normalize$1, "normalize");
14296 __name(assertPath$1, "assertPath");
14297 }));
14298
14299 //#endregion
14300 //#region node_modules/vfile/lib/minproc.browser.js
14301 function cwd() {
14302 return "/";
14303 }
14304 var proc;
14305 var init_minproc_browser = __esmMin((() => {
14306 proc = { cwd };
14307 }));
14308
14309 //#endregion
14310 //#region node_modules/vfile/lib/minurl.shared.js
14311 /**
14312 * @typedef URL
14313 * @property {string} hash
14314 * @property {string} host
14315 * @property {string} hostname
14316 * @property {string} href
14317 * @property {string} origin
14318 * @property {string} password
14319 * @property {string} pathname
14320 * @property {string} port
14321 * @property {string} protocol
14322 * @property {string} search
14323 * @property {any} searchParams
14324 * @property {string} username
14325 * @property {() => string} toString
14326 * @property {() => string} toJSON
14327 */
14328 /**
14329 * Check if `fileUrlOrPath` looks like a URL.
14330 *
14331 * @param {unknown} fileUrlOrPath
14332 * File path or URL.
14333 * @returns {fileUrlOrPath is URL}
14334 * Whether it’s a URL.
14335 */
14336 function isUrl(fileUrlOrPath) {
14337 return fileUrlOrPath !== null && typeof fileUrlOrPath === "object" && fileUrlOrPath.href && fileUrlOrPath.origin;
14338 }
14339 var init_minurl_shared = __esmMin((() => {}));
14340
14341 //#endregion
14342 //#region node_modules/vfile/lib/minurl.browser.js
14343 /**
14344 * @param {string | URL} path
14345 * File URL.
14346 * @returns {string}
14347 * File URL.
14348 */
14349 function urlToPath(path) {
14350 if (typeof path === "string") path = new URL(path);
14351 else if (!isUrl(path)) {
14352 /** @type {NodeJS.ErrnoException} */
14353 const error = /* @__PURE__ */ new TypeError("The \"path\" argument must be of type string or an instance of URL. Received `" + path + "`");
14354 error.code = "ERR_INVALID_ARG_TYPE";
14355 throw error;
14356 }
14357 if (path.protocol !== "file:") {
14358 /** @type {NodeJS.ErrnoException} */
14359 const error = /* @__PURE__ */ new TypeError("The URL must be of scheme file");
14360 error.code = "ERR_INVALID_URL_SCHEME";
14361 throw error;
14362 }
14363 return getPathFromURLPosix(path);
14364 }
14365 /**
14366 * Get a path from a POSIX URL.
14367 *
14368 * @param {URL} url
14369 * URL.
14370 * @returns {string}
14371 * File path.
14372 */
14373 function getPathFromURLPosix(url) {
14374 if (url.hostname !== "") {
14375 /** @type {NodeJS.ErrnoException} */
14376 const error = /* @__PURE__ */ new TypeError("File URL host must be \"localhost\" or empty on darwin");
14377 error.code = "ERR_INVALID_FILE_URL_HOST";
14378 throw error;
14379 }
14380 const pathname = url.pathname;
14381 let index = -1;
14382 while (++index < pathname.length) if (pathname.charCodeAt(index) === 37 && pathname.charCodeAt(index + 1) === 50) {
14383 const third = pathname.charCodeAt(index + 2);
14384 if (third === 70 || third === 102) {
14385 /** @type {NodeJS.ErrnoException} */
14386 const error = /* @__PURE__ */ new TypeError("File URL path must not include encoded / characters");
14387 error.code = "ERR_INVALID_FILE_URL_PATH";
14388 throw error;
14389 }
14390 }
14391 return decodeURIComponent(pathname);
14392 }
14393 var init_minurl_browser = __esmMin((() => {
14394 init_minurl_shared();
14395 }));
14396
14397 //#endregion
14398 //#region node_modules/vfile/lib/index.js
14399 /**
14400 * Assert that `part` is not a path (as in, does not contain `path.sep`).
14401 *
14402 * @param {string | null | undefined} part
14403 * File path part.
14404 * @param {string} name
14405 * Part name.
14406 * @returns {void}
14407 * Nothing.
14408 */
14409 function assertPart(part, name) {
14410 if (part && part.includes(path.sep)) throw new Error("`" + name + "` cannot be a path: did not expect `" + path.sep + "`");
14411 }
14412 /**
14413 * Assert that `part` is not empty.
14414 *
14415 * @param {string | undefined} part
14416 * Thing.
14417 * @param {string} name
14418 * Part name.
14419 * @returns {asserts part is string}
14420 * Nothing.
14421 */
14422 function assertNonEmpty(part, name) {
14423 if (!part) throw new Error("`" + name + "` cannot be empty");
14424 }
14425 /**
14426 * Assert `path` exists.
14427 *
14428 * @param {string | undefined} path
14429 * Path.
14430 * @param {string} name
14431 * Dependency name.
14432 * @returns {asserts path is string}
14433 * Nothing.
14434 */
14435 function assertPath(path, name) {
14436 if (!path) throw new Error("Setting `" + name + "` requires `path` to be set too");
14437 }
14438 /**
14439 * Assert `value` is a buffer.
14440 *
14441 * @param {unknown} value
14442 * thing.
14443 * @returns {value is Buffer}
14444 * Whether `value` is a Node.js buffer.
14445 */
14446 function buffer(value) {
14447 return (0, import_is_buffer$1.default)(value);
14448 }
14449 var import_is_buffer$1, order, VFile;
14450 var init_lib$13 = __esmMin((() => {
14451 import_is_buffer$1 = /* @__PURE__ */ __toESM(require_is_buffer$1(), 1);
14452 init_vfile_message();
14453 init_minpath_browser();
14454 init_minproc_browser();
14455 init_minurl_browser();
14456 order = [
14457 "history",
14458 "path",
14459 "basename",
14460 "stem",
14461 "extname",
14462 "dirname"
14463 ];
14464 VFile = class {
14465 /**
14466 * Create a new virtual file.
14467 *
14468 * `options` is treated as:
14469 *
14470 * * `string` or `Buffer` — `{value: options}`
14471 * * `URL` — `{path: options}`
14472 * * `VFile` — shallow copies its data over to the new file
14473 * * `object` — all fields are shallow copied over to the new file
14474 *
14475 * Path related fields are set in the following order (least specific to
14476 * most specific): `history`, `path`, `basename`, `stem`, `extname`,
14477 * `dirname`.
14478 *
14479 * You cannot set `dirname` or `extname` without setting either `history`,
14480 * `path`, `basename`, or `stem` too.
14481 *
14482 * @param {Compatible | null | undefined} [value]
14483 * File value.
14484 * @returns
14485 * New instance.
14486 */
14487 constructor(value) {
14488 /** @type {Options | VFile} */
14489 let options;
14490 if (!value) options = {};
14491 else if (typeof value === "string" || buffer(value)) options = { value };
14492 else if (isUrl(value)) options = { path: value };
14493 else options = value;
14494 /**
14495 * Place to store custom information (default: `{}`).
14496 *
14497 * It’s OK to store custom data directly on the file but moving it to
14498 * `data` is recommended.
14499 *
14500 * @type {Data}
14501 */
14502 this.data = {};
14503 /**
14504 * List of messages associated with the file.
14505 *
14506 * @type {Array<VFileMessage>}
14507 */
14508 this.messages = [];
14509 /**
14510 * List of filepaths the file moved between.
14511 *
14512 * The first is the original path and the last is the current path.
14513 *
14514 * @type {Array<string>}
14515 */
14516 this.history = [];
14517 /**
14518 * Base of `path` (default: `process.cwd()` or `'/'` in browsers).
14519 *
14520 * @type {string}
14521 */
14522 this.cwd = proc.cwd();
14523 /**
14524 * Raw value.
14525 *
14526 * @type {Value}
14527 */
14528 this.value;
14529 /**
14530 * Whether a file was saved to disk.
14531 *
14532 * This is used by vfile reporters.
14533 *
14534 * @type {boolean}
14535 */
14536 this.stored;
14537 /**
14538 * Custom, non-string, compiled, representation.
14539 *
14540 * This is used by unified to store non-string results.
14541 * One example is when turning markdown into React nodes.
14542 *
14543 * @type {unknown}
14544 */
14545 this.result;
14546 /**
14547 * Source map.
14548 *
14549 * This type is equivalent to the `RawSourceMap` type from the `source-map`
14550 * module.
14551 *
14552 * @type {Map | null | undefined}
14553 */
14554 this.map;
14555 let index = -1;
14556 while (++index < order.length) {
14557 const prop = order[index];
14558 if (prop in options && options[prop] !== void 0 && options[prop] !== null) this[prop] = prop === "history" ? [...options[prop]] : options[prop];
14559 }
14560 /** @type {string} */
14561 let prop;
14562 for (prop in options) if (!order.includes(prop)) this[prop] = options[prop];
14563 }
14564 /**
14565 * Get the full path (example: `'~/index.min.js'`).
14566 *
14567 * @returns {string}
14568 */
14569 get path() {
14570 return this.history[this.history.length - 1];
14571 }
14572 /**
14573 * Set the full path (example: `'~/index.min.js'`).
14574 *
14575 * Cannot be nullified.
14576 * You can set a file URL (a `URL` object with a `file:` protocol) which will
14577 * be turned into a path with `url.fileURLToPath`.
14578 *
14579 * @param {string | URL} path
14580 */
14581 set path(path) {
14582 if (isUrl(path)) path = urlToPath(path);
14583 assertNonEmpty(path, "path");
14584 if (this.path !== path) this.history.push(path);
14585 }
14586 /**
14587 * Get the parent path (example: `'~'`).
14588 */
14589 get dirname() {
14590 return typeof this.path === "string" ? path.dirname(this.path) : void 0;
14591 }
14592 /**
14593 * Set the parent path (example: `'~'`).
14594 *
14595 * Cannot be set if there’s no `path` yet.
14596 */
14597 set dirname(dirname) {
14598 assertPath(this.basename, "dirname");
14599 this.path = path.join(dirname || "", this.basename);
14600 }
14601 /**
14602 * Get the basename (including extname) (example: `'index.min.js'`).
14603 */
14604 get basename() {
14605 return typeof this.path === "string" ? path.basename(this.path) : void 0;
14606 }
14607 /**
14608 * Set basename (including extname) (`'index.min.js'`).
14609 *
14610 * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
14611 * on windows).
14612 * Cannot be nullified (use `file.path = file.dirname` instead).
14613 */
14614 set basename(basename) {
14615 assertNonEmpty(basename, "basename");
14616 assertPart(basename, "basename");
14617 this.path = path.join(this.dirname || "", basename);
14618 }
14619 /**
14620 * Get the extname (including dot) (example: `'.js'`).
14621 */
14622 get extname() {
14623 return typeof this.path === "string" ? path.extname(this.path) : void 0;
14624 }
14625 /**
14626 * Set the extname (including dot) (example: `'.js'`).
14627 *
14628 * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
14629 * on windows).
14630 * Cannot be set if there’s no `path` yet.
14631 */
14632 set extname(extname) {
14633 assertPart(extname, "extname");
14634 assertPath(this.dirname, "extname");
14635 if (extname) {
14636 if (extname.charCodeAt(0) !== 46) throw new Error("`extname` must start with `.`");
14637 if (extname.includes(".", 1)) throw new Error("`extname` cannot contain multiple dots");
14638 }
14639 this.path = path.join(this.dirname, this.stem + (extname || ""));
14640 }
14641 /**
14642 * Get the stem (basename w/o extname) (example: `'index.min'`).
14643 */
14644 get stem() {
14645 return typeof this.path === "string" ? path.basename(this.path, this.extname) : void 0;
14646 }
14647 /**
14648 * Set the stem (basename w/o extname) (example: `'index.min'`).
14649 *
14650 * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
14651 * on windows).
14652 * Cannot be nullified (use `file.path = file.dirname` instead).
14653 */
14654 set stem(stem) {
14655 assertNonEmpty(stem, "stem");
14656 assertPart(stem, "stem");
14657 this.path = path.join(this.dirname || "", stem + (this.extname || ""));
14658 }
14659 /**
14660 * Serialize the file.
14661 *
14662 * @param {BufferEncoding | null | undefined} [encoding='utf8']
14663 * Character encoding to understand `value` as when it’s a `Buffer`
14664 * (default: `'utf8'`).
14665 * @returns {string}
14666 * Serialized file.
14667 */
14668 toString(encoding) {
14669 return (this.value || "").toString(encoding || void 0);
14670 }
14671 /**
14672 * Create a warning message associated with the file.
14673 *
14674 * Its `fatal` is set to `false` and `file` is set to the current file path.
14675 * Its added to `file.messages`.
14676 *
14677 * @param {string | Error | VFileMessage} reason
14678 * Reason for message, uses the stack and message of the error if given.
14679 * @param {Node | NodeLike | Position | Point | null | undefined} [place]
14680 * Place in file where the message occurred.
14681 * @param {string | null | undefined} [origin]
14682 * Place in code where the message originates (example:
14683 * `'my-package:my-rule'` or `'my-rule'`).
14684 * @returns {VFileMessage}
14685 * Message.
14686 */
14687 message(reason, place, origin) {
14688 const message = new VFileMessage(reason, place, origin);
14689 if (this.path) {
14690 message.name = this.path + ":" + message.name;
14691 message.file = this.path;
14692 }
14693 message.fatal = false;
14694 this.messages.push(message);
14695 return message;
14696 }
14697 /**
14698 * Create an info message associated with the file.
14699 *
14700 * Its `fatal` is set to `null` and `file` is set to the current file path.
14701 * Its added to `file.messages`.
14702 *
14703 * @param {string | Error | VFileMessage} reason
14704 * Reason for message, uses the stack and message of the error if given.
14705 * @param {Node | NodeLike | Position | Point | null | undefined} [place]
14706 * Place in file where the message occurred.
14707 * @param {string | null | undefined} [origin]
14708 * Place in code where the message originates (example:
14709 * `'my-package:my-rule'` or `'my-rule'`).
14710 * @returns {VFileMessage}
14711 * Message.
14712 */
14713 info(reason, place, origin) {
14714 const message = this.message(reason, place, origin);
14715 message.fatal = null;
14716 return message;
14717 }
14718 /**
14719 * Create a fatal error associated with the file.
14720 *
14721 * Its `fatal` is set to `true` and `file` is set to the current file path.
14722 * Its added to `file.messages`.
14723 *
14724 * > 👉 **Note**: a fatal error means that a file is no longer processable.
14725 *
14726 * @param {string | Error | VFileMessage} reason
14727 * Reason for message, uses the stack and message of the error if given.
14728 * @param {Node | NodeLike | Position | Point | null | undefined} [place]
14729 * Place in file where the message occurred.
14730 * @param {string | null | undefined} [origin]
14731 * Place in code where the message originates (example:
14732 * `'my-package:my-rule'` or `'my-rule'`).
14733 * @returns {never}
14734 * Message.
14735 * @throws {VFileMessage}
14736 * Message.
14737 */
14738 fail(reason, place, origin) {
14739 const message = this.message(reason, place, origin);
14740 message.fatal = true;
14741 throw message;
14742 }
14743 };
14744 }));
14745
14746 //#endregion
14747 //#region node_modules/vfile/index.js
14748 var init_vfile = __esmMin((() => {
14749 init_lib$13();
14750 }));
14751
14752 //#endregion
14753 //#region node_modules/bail/index.js
14754 /**
14755 * Throw a given error.
14756 *
14757 * @param {Error|null|undefined} [error]
14758 * Maybe error.
14759 * @returns {asserts error is null|undefined}
14760 */
14761 function bail(error) {
14762 if (error) throw error;
14763 }
14764 var init_bail = __esmMin((() => {}));
14765
14766 //#endregion
14767 //#region node_modules/unified/node_modules/is-buffer/index.js
14768 var require_is_buffer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14769 /*!
14770 * Determine if an object is a Buffer
14771 *
14772 * @author Feross Aboukhadijeh <https://feross.org>
14773 * @license MIT
14774 */
14775 module.exports = function isBuffer(obj) {
14776 return obj != null && obj.constructor != null && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
14777 };
14778 }));
14779
14780 //#endregion
14781 //#region node_modules/extend/index.js
14782 var require_extend = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14783 var hasOwn = Object.prototype.hasOwnProperty;
14784 var toStr = Object.prototype.toString;
14785 var defineProperty = Object.defineProperty;
14786 var gOPD = Object.getOwnPropertyDescriptor;
14787 var isArray = function isArray(arr) {
14788 if (typeof Array.isArray === "function") return Array.isArray(arr);
14789 return toStr.call(arr) === "[object Array]";
14790 };
14791 var isPlainObject = function isPlainObject(obj) {
14792 if (!obj || toStr.call(obj) !== "[object Object]") return false;
14793 var hasOwnConstructor = hasOwn.call(obj, "constructor");
14794 var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, "isPrototypeOf");
14795 if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) return false;
14796 var key;
14797 for (key in obj);
14798 return typeof key === "undefined" || hasOwn.call(obj, key);
14799 };
14800 var setProperty = function setProperty(target, options) {
14801 if (defineProperty && options.name === "__proto__") defineProperty(target, options.name, {
14802 enumerable: true,
14803 configurable: true,
14804 value: options.newValue,
14805 writable: true
14806 });
14807 else target[options.name] = options.newValue;
14808 };
14809 var getProperty = function getProperty(obj, name) {
14810 if (name === "__proto__") {
14811 if (!hasOwn.call(obj, name)) return;
14812 else if (gOPD) return gOPD(obj, name).value;
14813 }
14814 return obj[name];
14815 };
14816 module.exports = function extend() {
14817 var options;
14818 var name;
14819 var src;
14820 var copy;
14821 var copyIsArray;
14822 var clone;
14823 var target = arguments[0];
14824 var i = 1;
14825 var length = arguments.length;
14826 var deep = false;
14827 if (typeof target === "boolean") {
14828 deep = target;
14829 target = arguments[1] || {};
14830 i = 2;
14831 }
14832 if (target == null || typeof target !== "object" && typeof target !== "function") target = {};
14833 for (; i < length; ++i) {
14834 options = arguments[i];
14835 if (options != null) for (name in options) {
14836 src = getProperty(target, name);
14837 copy = getProperty(options, name);
14838 if (target !== copy) {
14839 if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
14840 if (copyIsArray) {
14841 copyIsArray = false;
14842 clone = src && isArray(src) ? src : [];
14843 } else clone = src && isPlainObject(src) ? src : {};
14844 setProperty(target, {
14845 name,
14846 newValue: extend(deep, clone, copy)
14847 });
14848 } else if (typeof copy !== "undefined") setProperty(target, {
14849 name,
14850 newValue: copy
14851 });
14852 }
14853 }
14854 }
14855 return target;
14856 };
14857 }));
14858
14859 //#endregion
14860 //#region node_modules/is-plain-obj/index.js
14861 function isPlainObject(value) {
14862 if (typeof value !== "object" || value === null) return false;
14863 const prototype = Object.getPrototypeOf(value);
14864 return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
14865 }
14866 var init_is_plain_obj = __esmMin((() => {}));
14867
14868 //#endregion
14869 //#region node_modules/trough/lib/index.js
14870 /**
14871 * @typedef {(error?: Error | null | undefined, ...output: Array<any>) => void} Callback
14872 * Callback.
14873 *
14874 * @typedef {(...input: Array<any>) => any} Middleware
14875 * Ware.
14876 *
14877 * @typedef Pipeline
14878 * Pipeline.
14879 * @property {Run} run
14880 * Run the pipeline.
14881 * @property {Use} use
14882 * Add middleware.
14883 *
14884 * @typedef {(...input: Array<any>) => void} Run
14885 * Call all middleware.
14886 *
14887 * Calls `done` on completion with either an error or the output of the
14888 * last middleware.
14889 *
14890 * > 👉 **Note**: as the length of input defines whether async functions get a
14891 * > `next` function,
14892 * > it’s recommended to keep `input` at one value normally.
14893
14894 *
14895 * @typedef {(fn: Middleware) => Pipeline} Use
14896 * Add middleware.
14897 */
14898 /**
14899 * Create new middleware.
14900 *
14901 * @returns {Pipeline}
14902 * Pipeline.
14903 */
14904 function trough() {
14905 /** @type {Array<Middleware>} */
14906 const fns = [];
14907 /** @type {Pipeline} */
14908 const pipeline = {
14909 run,
14910 use
14911 };
14912 return pipeline;
14913 /** @type {Run} */
14914 function run(...values) {
14915 let middlewareIndex = -1;
14916 /** @type {Callback} */
14917 const callback = values.pop();
14918 if (typeof callback !== "function") throw new TypeError("Expected function as last argument, not " + callback);
14919 next(null, ...values);
14920 /**
14921 * Run the next `fn`, or we’re done.
14922 *
14923 * @param {Error | null | undefined} error
14924 * @param {Array<any>} output
14925 */
14926 function next(error, ...output) {
14927 const fn = fns[++middlewareIndex];
14928 let index = -1;
14929 if (error) {
14930 callback(error);
14931 return;
14932 }
14933 while (++index < values.length) if (output[index] === null || output[index] === void 0) output[index] = values[index];
14934 values = output;
14935 if (fn) wrap$1(fn, next)(...output);
14936 else callback(null, ...output);
14937 }
14938 }
14939 /** @type {Use} */
14940 function use(middelware) {
14941 if (typeof middelware !== "function") throw new TypeError("Expected `middelware` to be a function, not " + middelware);
14942 fns.push(middelware);
14943 return pipeline;
14944 }
14945 }
14946 /**
14947 * Wrap `middleware` into a uniform interface.
14948 *
14949 * You can pass all input to the resulting function.
14950 * `callback` is then called with the output of `middleware`.
14951 *
14952 * If `middleware` accepts more arguments than the later given in input,
14953 * an extra `done` function is passed to it after that input,
14954 * which must be called by `middleware`.
14955 *
14956 * The first value in `input` is the main input value.
14957 * All other input values are the rest input values.
14958 * The values given to `callback` are the input values,
14959 * merged with every non-nullish output value.
14960 *
14961 * * if `middleware` throws an error,
14962 * returns a promise that is rejected,
14963 * or calls the given `done` function with an error,
14964 * `callback` is called with that error
14965 * * if `middleware` returns a value or returns a promise that is resolved,
14966 * that value is the main output value
14967 * * if `middleware` calls `done`,
14968 * all non-nullish values except for the first one (the error) overwrite the
14969 * output values
14970 *
14971 * @param {Middleware} middleware
14972 * Function to wrap.
14973 * @param {Callback} callback
14974 * Callback called with the output of `middleware`.
14975 * @returns {Run}
14976 * Wrapped middleware.
14977 */
14978 function wrap$1(middleware, callback) {
14979 /** @type {boolean} */
14980 let called;
14981 return wrapped;
14982 /**
14983 * Call `middleware`.
14984 * @this {any}
14985 * @param {Array<any>} parameters
14986 * @returns {void}
14987 */
14988 function wrapped(...parameters) {
14989 const fnExpectsCallback = middleware.length > parameters.length;
14990 /** @type {any} */
14991 let result;
14992 if (fnExpectsCallback) parameters.push(done);
14993 try {
14994 result = middleware.apply(this, parameters);
14995 } catch (error) {
14996 const exception = error;
14997 if (fnExpectsCallback && called) throw exception;
14998 return done(exception);
14999 }
15000 if (!fnExpectsCallback) if (result && result.then && typeof result.then === "function") result.then(then, done);
15001 else if (result instanceof Error) done(result);
15002 else then(result);
15003 }
15004 /**
15005 * Call `callback`, only once.
15006 *
15007 * @type {Callback}
15008 */
15009 function done(error, ...output) {
15010 if (!called) {
15011 called = true;
15012 callback(error, ...output);
15013 }
15014 }
15015 /**
15016 * Call `done` with one value.
15017 *
15018 * @param {any} [value]
15019 */
15020 function then(value) {
15021 done(null, value);
15022 }
15023 }
15024 var init_lib$12 = __esmMin((() => {
15025 __name(wrap$1, "wrap");
15026 }));
15027
15028 //#endregion
15029 //#region node_modules/trough/index.js
15030 var init_trough = __esmMin((() => {
15031 init_lib$12();
15032 }));
15033
15034 //#endregion
15035 //#region node_modules/unified/lib/index.js
15036 /**
15037 * @returns {Processor}
15038 */
15039 function base() {
15040 const transformers = trough();
15041 /** @type {Processor['attachers']} */
15042 const attachers = [];
15043 /** @type {Record<string, unknown>} */
15044 let namespace = {};
15045 /** @type {boolean|undefined} */
15046 let frozen;
15047 let freezeIndex = -1;
15048 processor.data = data;
15049 processor.Parser = void 0;
15050 processor.Compiler = void 0;
15051 processor.freeze = freeze;
15052 processor.attachers = attachers;
15053 processor.use = use;
15054 processor.parse = parse;
15055 processor.stringify = stringify;
15056 processor.run = run;
15057 processor.runSync = runSync;
15058 processor.process = process;
15059 processor.processSync = processSync;
15060 return processor;
15061 /** @type {Processor} */
15062 function processor() {
15063 const destination = base();
15064 let index = -1;
15065 while (++index < attachers.length) destination.use(...attachers[index]);
15066 destination.data((0, import_extend.default)(true, {}, namespace));
15067 return destination;
15068 }
15069 /**
15070 * @param {string|Record<string, unknown>} [key]
15071 * @param {unknown} [value]
15072 * @returns {unknown}
15073 */
15074 function data(key, value) {
15075 if (typeof key === "string") {
15076 if (arguments.length === 2) {
15077 assertUnfrozen("data", frozen);
15078 namespace[key] = value;
15079 return processor;
15080 }
15081 return own$6.call(namespace, key) && namespace[key] || null;
15082 }
15083 if (key) {
15084 assertUnfrozen("data", frozen);
15085 namespace = key;
15086 return processor;
15087 }
15088 return namespace;
15089 }
15090 /** @type {Processor['freeze']} */
15091 function freeze() {
15092 if (frozen) return processor;
15093 while (++freezeIndex < attachers.length) {
15094 const [attacher, ...options] = attachers[freezeIndex];
15095 if (options[0] === false) continue;
15096 if (options[0] === true) options[0] = void 0;
15097 /** @type {Transformer|void} */
15098 const transformer = attacher.call(processor, ...options);
15099 if (typeof transformer === "function") transformers.use(transformer);
15100 }
15101 frozen = true;
15102 freezeIndex = Number.POSITIVE_INFINITY;
15103 return processor;
15104 }
15105 /**
15106 * @param {Pluggable|null|undefined} [value]
15107 * @param {...unknown} options
15108 * @returns {Processor}
15109 */
15110 function use(value, ...options) {
15111 /** @type {Record<string, unknown>|undefined} */
15112 let settings;
15113 assertUnfrozen("use", frozen);
15114 if (value === null || value === void 0) {} else if (typeof value === "function") addPlugin(value, ...options);
15115 else if (typeof value === "object") if (Array.isArray(value)) addList(value);
15116 else addPreset(value);
15117 else throw new TypeError("Expected usable value, not `" + value + "`");
15118 if (settings) namespace.settings = Object.assign(namespace.settings || {}, settings);
15119 return processor;
15120 /**
15121 * @param {import('..').Pluggable<unknown[]>} value
15122 * @returns {void}
15123 */
15124 function add(value) {
15125 if (typeof value === "function") addPlugin(value);
15126 else if (typeof value === "object") if (Array.isArray(value)) {
15127 const [plugin, ...options] = value;
15128 addPlugin(plugin, ...options);
15129 } else addPreset(value);
15130 else throw new TypeError("Expected usable value, not `" + value + "`");
15131 }
15132 /**
15133 * @param {Preset} result
15134 * @returns {void}
15135 */
15136 function addPreset(result) {
15137 addList(result.plugins);
15138 if (result.settings) settings = Object.assign(settings || {}, result.settings);
15139 }
15140 /**
15141 * @param {PluggableList|null|undefined} [plugins]
15142 * @returns {void}
15143 */
15144 function addList(plugins) {
15145 let index = -1;
15146 if (plugins === null || plugins === void 0) {} else if (Array.isArray(plugins)) while (++index < plugins.length) {
15147 const thing = plugins[index];
15148 add(thing);
15149 }
15150 else throw new TypeError("Expected a list of plugins, not `" + plugins + "`");
15151 }
15152 /**
15153 * @param {Plugin} plugin
15154 * @param {...unknown} [value]
15155 * @returns {void}
15156 */
15157 function addPlugin(plugin, value) {
15158 let index = -1;
15159 /** @type {Processor['attachers'][number]|undefined} */
15160 let entry;
15161 while (++index < attachers.length) if (attachers[index][0] === plugin) {
15162 entry = attachers[index];
15163 break;
15164 }
15165 if (entry) {
15166 if (isPlainObject(entry[1]) && isPlainObject(value)) value = (0, import_extend.default)(true, entry[1], value);
15167 entry[1] = value;
15168 } else attachers.push([...arguments]);
15169 }
15170 }
15171 /** @type {Processor['parse']} */
15172 function parse(doc) {
15173 processor.freeze();
15174 const file = vfile(doc);
15175 const Parser = processor.Parser;
15176 assertParser("parse", Parser);
15177 if (newable(Parser, "parse")) return new Parser(String(file), file).parse();
15178 return Parser(String(file), file);
15179 }
15180 /** @type {Processor['stringify']} */
15181 function stringify(node, doc) {
15182 processor.freeze();
15183 const file = vfile(doc);
15184 const Compiler = processor.Compiler;
15185 assertCompiler("stringify", Compiler);
15186 assertNode(node);
15187 if (newable(Compiler, "compile")) return new Compiler(node, file).compile();
15188 return Compiler(node, file);
15189 }
15190 /**
15191 * @param {Node} node
15192 * @param {VFileCompatible|RunCallback} [doc]
15193 * @param {RunCallback} [callback]
15194 * @returns {Promise<Node>|void}
15195 */
15196 function run(node, doc, callback) {
15197 assertNode(node);
15198 processor.freeze();
15199 if (!callback && typeof doc === "function") {
15200 callback = doc;
15201 doc = void 0;
15202 }
15203 if (!callback) return new Promise(executor);
15204 executor(null, callback);
15205 /**
15206 * @param {null|((node: Node) => void)} resolve
15207 * @param {(error: Error) => void} reject
15208 * @returns {void}
15209 */
15210 function executor(resolve, reject) {
15211 transformers.run(node, vfile(doc), done);
15212 /**
15213 * @param {Error|null} error
15214 * @param {Node} tree
15215 * @param {VFile} file
15216 * @returns {void}
15217 */
15218 function done(error, tree, file) {
15219 tree = tree || node;
15220 if (error) reject(error);
15221 else if (resolve) resolve(tree);
15222 else callback(null, tree, file);
15223 }
15224 }
15225 }
15226 /** @type {Processor['runSync']} */
15227 function runSync(node, file) {
15228 /** @type {Node|undefined} */
15229 let result;
15230 /** @type {boolean|undefined} */
15231 let complete;
15232 processor.run(node, file, done);
15233 assertDone("runSync", "run", complete);
15234 return result;
15235 /**
15236 * @param {Error|null} [error]
15237 * @param {Node} [tree]
15238 * @returns {void}
15239 */
15240 function done(error, tree) {
15241 bail(error);
15242 result = tree;
15243 complete = true;
15244 }
15245 }
15246 /**
15247 * @param {VFileCompatible} doc
15248 * @param {ProcessCallback} [callback]
15249 * @returns {Promise<VFile>|undefined}
15250 */
15251 function process(doc, callback) {
15252 processor.freeze();
15253 assertParser("process", processor.Parser);
15254 assertCompiler("process", processor.Compiler);
15255 if (!callback) return new Promise(executor);
15256 executor(null, callback);
15257 /**
15258 * @param {null|((file: VFile) => void)} resolve
15259 * @param {(error?: Error|null|undefined) => void} reject
15260 * @returns {void}
15261 */
15262 function executor(resolve, reject) {
15263 const file = vfile(doc);
15264 processor.run(processor.parse(file), file, (error, tree, file) => {
15265 if (error || !tree || !file) done(error);
15266 else {
15267 /** @type {unknown} */
15268 const result = processor.stringify(tree, file);
15269 if (result === void 0 || result === null) {} else if (looksLikeAVFileValue(result)) file.value = result;
15270 else file.result = result;
15271 done(error, file);
15272 }
15273 });
15274 /**
15275 * @param {Error|null|undefined} [error]
15276 * @param {VFile|undefined} [file]
15277 * @returns {void}
15278 */
15279 function done(error, file) {
15280 if (error || !file) reject(error);
15281 else if (resolve) resolve(file);
15282 else callback(null, file);
15283 }
15284 }
15285 }
15286 /** @type {Processor['processSync']} */
15287 function processSync(doc) {
15288 /** @type {boolean|undefined} */
15289 let complete;
15290 processor.freeze();
15291 assertParser("processSync", processor.Parser);
15292 assertCompiler("processSync", processor.Compiler);
15293 const file = vfile(doc);
15294 processor.process(file, done);
15295 assertDone("processSync", "process", complete);
15296 return file;
15297 /**
15298 * @param {Error|null|undefined} [error]
15299 * @returns {void}
15300 */
15301 function done(error) {
15302 complete = true;
15303 bail(error);
15304 }
15305 }
15306 }
15307 /**
15308 * Check if `value` is a constructor.
15309 *
15310 * @param {unknown} value
15311 * @param {string} name
15312 * @returns {boolean}
15313 */
15314 function newable(value, name) {
15315 return typeof value === "function" && value.prototype && (keys(value.prototype) || name in value.prototype);
15316 }
15317 /**
15318 * Check if `value` is an object with keys.
15319 *
15320 * @param {Record<string, unknown>} value
15321 * @returns {boolean}
15322 */
15323 function keys(value) {
15324 /** @type {string} */
15325 let key;
15326 for (key in value) if (own$6.call(value, key)) return true;
15327 return false;
15328 }
15329 /**
15330 * Assert a parser is available.
15331 *
15332 * @param {string} name
15333 * @param {unknown} value
15334 * @returns {asserts value is Parser}
15335 */
15336 function assertParser(name, value) {
15337 if (typeof value !== "function") throw new TypeError("Cannot `" + name + "` without `Parser`");
15338 }
15339 /**
15340 * Assert a compiler is available.
15341 *
15342 * @param {string} name
15343 * @param {unknown} value
15344 * @returns {asserts value is Compiler}
15345 */
15346 function assertCompiler(name, value) {
15347 if (typeof value !== "function") throw new TypeError("Cannot `" + name + "` without `Compiler`");
15348 }
15349 /**
15350 * Assert the processor is not frozen.
15351 *
15352 * @param {string} name
15353 * @param {unknown} frozen
15354 * @returns {asserts frozen is false}
15355 */
15356 function assertUnfrozen(name, frozen) {
15357 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`.");
15358 }
15359 /**
15360 * Assert `node` is a unist node.
15361 *
15362 * @param {unknown} node
15363 * @returns {asserts node is Node}
15364 */
15365 function assertNode(node) {
15366 if (!isPlainObject(node) || typeof node.type !== "string") throw new TypeError("Expected node, got `" + node + "`");
15367 }
15368 /**
15369 * Assert that `complete` is `true`.
15370 *
15371 * @param {string} name
15372 * @param {string} asyncName
15373 * @param {unknown} complete
15374 * @returns {asserts complete is true}
15375 */
15376 function assertDone(name, asyncName, complete) {
15377 if (!complete) throw new Error("`" + name + "` finished async. Use `" + asyncName + "` instead");
15378 }
15379 /**
15380 * @param {VFileCompatible} [value]
15381 * @returns {VFile}
15382 */
15383 function vfile(value) {
15384 return looksLikeAVFile(value) ? value : new VFile(value);
15385 }
15386 /**
15387 * @param {VFileCompatible} [value]
15388 * @returns {value is VFile}
15389 */
15390 function looksLikeAVFile(value) {
15391 return Boolean(value && typeof value === "object" && "message" in value && "messages" in value);
15392 }
15393 /**
15394 * @param {unknown} [value]
15395 * @returns {value is VFileValue}
15396 */
15397 function looksLikeAVFileValue(value) {
15398 return typeof value === "string" || (0, import_is_buffer.default)(value);
15399 }
15400 var import_is_buffer, import_extend, unified, own$6;
15401 var init_lib$11 = __esmMin((() => {
15402 init_bail();
15403 import_is_buffer = /* @__PURE__ */ __toESM(require_is_buffer(), 1);
15404 import_extend = /* @__PURE__ */ __toESM(require_extend(), 1);
15405 init_is_plain_obj();
15406 init_trough();
15407 init_vfile();
15408 unified = base().freeze();
15409 own$6 = {}.hasOwnProperty;
15410 }));
15411
15412 //#endregion
15413 //#region node_modules/unified/index.js
15414 var init_unified = __esmMin((() => {
15415 init_lib$11();
15416 }));
15417
15418 //#endregion
15419 //#region node_modules/mdast-util-to-string/lib/index.js
15420 /**
15421 * Get the text content of a node or list of nodes.
15422 *
15423 * Prefers the node’s plain-text fields, otherwise serializes its children,
15424 * and if the given value is an array, serialize the nodes in it.
15425 *
15426 * @param {unknown} value
15427 * Thing to serialize, typically `Node`.
15428 * @param {Options | null | undefined} [options]
15429 * Configuration (optional).
15430 * @returns {string}
15431 * Serialized `value`.
15432 */
15433 function toString(value, options) {
15434 const settings = options || emptyOptions;
15435 return one$1(value, typeof settings.includeImageAlt === "boolean" ? settings.includeImageAlt : true, typeof settings.includeHtml === "boolean" ? settings.includeHtml : true);
15436 }
15437 /**
15438 * One node or several nodes.
15439 *
15440 * @param {unknown} value
15441 * Thing to serialize.
15442 * @param {boolean} includeImageAlt
15443 * Include image `alt`s.
15444 * @param {boolean} includeHtml
15445 * Include HTML.
15446 * @returns {string}
15447 * Serialized node.
15448 */
15449 function one$1(value, includeImageAlt, includeHtml) {
15450 if (node(value)) {
15451 if ("value" in value) return value.type === "html" && !includeHtml ? "" : value.value;
15452 if (includeImageAlt && "alt" in value && value.alt) return value.alt;
15453 if ("children" in value) return all$1(value.children, includeImageAlt, includeHtml);
15454 }
15455 if (Array.isArray(value)) return all$1(value, includeImageAlt, includeHtml);
15456 return "";
15457 }
15458 /**
15459 * Serialize a list of nodes.
15460 *
15461 * @param {Array<unknown>} values
15462 * Thing to serialize.
15463 * @param {boolean} includeImageAlt
15464 * Include image `alt`s.
15465 * @param {boolean} includeHtml
15466 * Include HTML.
15467 * @returns {string}
15468 * Serialized nodes.
15469 */
15470 function all$1(values, includeImageAlt, includeHtml) {
15471 /** @type {Array<string>} */
15472 const result = [];
15473 let index = -1;
15474 while (++index < values.length) result[index] = one$1(values[index], includeImageAlt, includeHtml);
15475 return result.join("");
15476 }
15477 /**
15478 * Check if `value` looks like a node.
15479 *
15480 * @param {unknown} value
15481 * Thing.
15482 * @returns {value is Node}
15483 * Whether `value` is a node.
15484 */
15485 function node(value) {
15486 return Boolean(value && typeof value === "object");
15487 }
15488 var emptyOptions;
15489 var init_lib$10 = __esmMin((() => {
15490 emptyOptions = {};
15491 __name(one$1, "one");
15492 __name(all$1, "all");
15493 }));
15494
15495 //#endregion
15496 //#region node_modules/mdast-util-to-string/index.js
15497 var init_mdast_util_to_string = __esmMin((() => {
15498 init_lib$10();
15499 }));
15500
15501 //#endregion
15502 //#region node_modules/micromark-util-chunked/index.js
15503 /**
15504 * Like `Array#splice`, but smarter for giant arrays.
15505 *
15506 * `Array#splice` takes all items to be inserted as individual argument which
15507 * causes a stack overflow in V8 when trying to insert 100k items for instance.
15508 *
15509 * Otherwise, this does not return the removed items, and takes `items` as an
15510 * array instead of rest parameters.
15511 *
15512 * @template {unknown} T
15513 * Item type.
15514 * @param {Array<T>} list
15515 * List to operate on.
15516 * @param {number} start
15517 * Index to remove/insert at (can be negative).
15518 * @param {number} remove
15519 * Number of items to remove.
15520 * @param {Array<T>} items
15521 * Items to inject into `list`.
15522 * @returns {void}
15523 * Nothing.
15524 */
15525 function splice(list, start, remove, items) {
15526 const end = list.length;
15527 let chunkStart = 0;
15528 /** @type {Array<unknown>} */
15529 let parameters;
15530 if (start < 0) start = -start > end ? 0 : end + start;
15531 else start = start > end ? end : start;
15532 remove = remove > 0 ? remove : 0;
15533 if (items.length < 1e4) {
15534 parameters = Array.from(items);
15535 parameters.unshift(start, remove);
15536 list.splice(...parameters);
15537 } else {
15538 if (remove) list.splice(start, remove);
15539 while (chunkStart < items.length) {
15540 parameters = items.slice(chunkStart, chunkStart + 1e4);
15541 parameters.unshift(start, 0);
15542 list.splice(...parameters);
15543 chunkStart += 1e4;
15544 start += 1e4;
15545 }
15546 }
15547 }
15548 /**
15549 * Append `items` (an array) at the end of `list` (another array).
15550 * When `list` was empty, returns `items` instead.
15551 *
15552 * This prevents a potentially expensive operation when `list` is empty,
15553 * and adds items in batches to prevent V8 from hanging.
15554 *
15555 * @template {unknown} T
15556 * Item type.
15557 * @param {Array<T>} list
15558 * List to operate on.
15559 * @param {Array<T>} items
15560 * Items to add to `list`.
15561 * @returns {Array<T>}
15562 * Either `list` or `items`.
15563 */
15564 function push(list, items) {
15565 if (list.length > 0) {
15566 splice(list, list.length, 0, items);
15567 return list;
15568 }
15569 return items;
15570 }
15571 var init_micromark_util_chunked = __esmMin((() => {}));
15572
15573 //#endregion
15574 //#region node_modules/micromark-util-combine-extensions/index.js
15575 /**
15576 * Combine multiple syntax extensions into one.
15577 *
15578 * @param {Array<Extension>} extensions
15579 * List of syntax extensions.
15580 * @returns {NormalizedExtension}
15581 * A single combined extension.
15582 */
15583 function combineExtensions(extensions) {
15584 /** @type {NormalizedExtension} */
15585 const all = {};
15586 let index = -1;
15587 while (++index < extensions.length) syntaxExtension(all, extensions[index]);
15588 return all;
15589 }
15590 /**
15591 * Merge `extension` into `all`.
15592 *
15593 * @param {NormalizedExtension} all
15594 * Extension to merge into.
15595 * @param {Extension} extension
15596 * Extension to merge.
15597 * @returns {void}
15598 */
15599 function syntaxExtension(all, extension) {
15600 /** @type {keyof Extension} */
15601 let hook;
15602 for (hook in extension) {
15603 /** @type {Record<string, unknown>} */
15604 const left = (hasOwnProperty.call(all, hook) ? all[hook] : void 0) || (all[hook] = {});
15605 /** @type {Record<string, unknown> | undefined} */
15606 const right = extension[hook];
15607 /** @type {string} */
15608 let code;
15609 if (right) for (code in right) {
15610 if (!hasOwnProperty.call(left, code)) left[code] = [];
15611 const value = right[code];
15612 constructs(left[code], Array.isArray(value) ? value : value ? [value] : []);
15613 }
15614 }
15615 }
15616 /**
15617 * Merge `list` into `existing` (both lists of constructs).
15618 * Mutates `existing`.
15619 *
15620 * @param {Array<unknown>} existing
15621 * @param {Array<unknown>} list
15622 * @returns {void}
15623 */
15624 function constructs(existing, list) {
15625 let index = -1;
15626 /** @type {Array<unknown>} */
15627 const before = [];
15628 while (++index < list.length) (list[index].add === "after" ? existing : before).push(list[index]);
15629 splice(existing, 0, 0, before);
15630 }
15631 var hasOwnProperty;
15632 var init_micromark_util_combine_extensions = __esmMin((() => {
15633 init_micromark_util_chunked();
15634 hasOwnProperty = {}.hasOwnProperty;
15635 }));
15636
15637 //#endregion
15638 //#region node_modules/micromark-util-character/lib/unicode-punctuation-regex.js
15639 var unicodePunctuationRegex;
15640 var init_unicode_punctuation_regex = __esmMin((() => {
15641 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]/;
15642 }));
15643
15644 //#endregion
15645 //#region node_modules/micromark-util-character/index.js
15646 /**
15647 * Check whether a character code is an ASCII control character.
15648 *
15649 * An **ASCII control** is a character in the inclusive range U+0000 NULL (NUL)
15650 * to U+001F (US), or U+007F (DEL).
15651 *
15652 * @param {Code} code
15653 * Code.
15654 * @returns {boolean}
15655 * Whether it matches.
15656 */
15657 function asciiControl(code) {
15658 return code !== null && (code < 32 || code === 127);
15659 }
15660 /**
15661 * Check whether a character code is a markdown line ending.
15662 *
15663 * A **markdown line ending** is the virtual characters M-0003 CARRIAGE RETURN
15664 * LINE FEED (CRLF), M-0004 LINE FEED (LF) and M-0005 CARRIAGE RETURN (CR).
15665 *
15666 * In micromark, the actual character U+000A LINE FEED (LF) and U+000D CARRIAGE
15667 * RETURN (CR) are replaced by these virtual characters depending on whether
15668 * they occurred together.
15669 *
15670 * @param {Code} code
15671 * Code.
15672 * @returns {boolean}
15673 * Whether it matches.
15674 */
15675 function markdownLineEnding(code) {
15676 return code !== null && code < -2;
15677 }
15678 /**
15679 * Check whether a character code is a markdown line ending (see
15680 * `markdownLineEnding`) or markdown space (see `markdownSpace`).
15681 *
15682 * @param {Code} code
15683 * Code.
15684 * @returns {boolean}
15685 * Whether it matches.
15686 */
15687 function markdownLineEndingOrSpace(code) {
15688 return code !== null && (code < 0 || code === 32);
15689 }
15690 /**
15691 * Check whether a character code is a markdown space.
15692 *
15693 * A **markdown space** is the concrete character U+0020 SPACE (SP) and the
15694 * virtual characters M-0001 VIRTUAL SPACE (VS) and M-0002 HORIZONTAL TAB (HT).
15695 *
15696 * In micromark, the actual character U+0009 CHARACTER TABULATION (HT) is
15697 * replaced by one M-0002 HORIZONTAL TAB (HT) and between 0 and 3 M-0001 VIRTUAL
15698 * SPACE (VS) characters, depending on the column at which the tab occurred.
15699 *
15700 * @param {Code} code
15701 * Code.
15702 * @returns {boolean}
15703 * Whether it matches.
15704 */
15705 function markdownSpace(code) {
15706 return code === -2 || code === -1 || code === 32;
15707 }
15708 /**
15709 * Create a code check from a regex.
15710 *
15711 * @param {RegExp} regex
15712 * @returns {(code: Code) => boolean}
15713 */
15714 function regexCheck(regex) {
15715 return check;
15716 /**
15717 * Check whether a code matches the bound regex.
15718 *
15719 * @param {Code} code
15720 * Character code.
15721 * @returns {boolean}
15722 * Whether the character code matches the bound regex.
15723 */
15724 function check(code) {
15725 return code !== null && regex.test(String.fromCharCode(code));
15726 }
15727 }
15728 var asciiAlpha, asciiAlphanumeric, asciiAtext, asciiDigit, asciiHexDigit, asciiPunctuation, unicodePunctuation, unicodeWhitespace;
15729 var init_micromark_util_character = __esmMin((() => {
15730 init_unicode_punctuation_regex();
15731 asciiAlpha = regexCheck(/[A-Za-z]/);
15732 asciiAlphanumeric = regexCheck(/[\dA-Za-z]/);
15733 asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/);
15734 asciiDigit = regexCheck(/\d/);
15735 asciiHexDigit = regexCheck(/[\dA-Fa-f]/);
15736 asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/);
15737 unicodePunctuation = regexCheck(unicodePunctuationRegex);
15738 unicodeWhitespace = regexCheck(/\s/);
15739 }));
15740
15741 //#endregion
15742 //#region node_modules/micromark-factory-space/index.js
15743 /**
15744 * Parse spaces and tabs.
15745 *
15746 * There is no `nok` parameter:
15747 *
15748 * * spaces in markdown are often optional, in which case this factory can be
15749 * used and `ok` will be switched to whether spaces were found or not
15750 * * one line ending or space can be detected with `markdownSpace(code)` right
15751 * before using `factorySpace`
15752 *
15753 * ###### Examples
15754 *
15755 * Where `␉` represents a tab (plus how much it expands) and `␠` represents a
15756 * single space.
15757 *
15758 * ```markdown
15759 * ␉
15760 * ␠␠␠␠
15761 * ␉␠
15762 * ```
15763 *
15764 * @param {Effects} effects
15765 * Context.
15766 * @param {State} ok
15767 * State switched to when successful.
15768 * @param {TokenType} type
15769 * Type (`' \t'`).
15770 * @param {number | undefined} [max=Infinity]
15771 * Max (exclusive).
15772 * @returns
15773 * Start state.
15774 */
15775 function factorySpace(effects, ok, type, max) {
15776 const limit = max ? max - 1 : Number.POSITIVE_INFINITY;
15777 let size = 0;
15778 return start;
15779 /** @type {State} */
15780 function start(code) {
15781 if (markdownSpace(code)) {
15782 effects.enter(type);
15783 return prefix(code);
15784 }
15785 return ok(code);
15786 }
15787 /** @type {State} */
15788 function prefix(code) {
15789 if (markdownSpace(code) && size++ < limit) {
15790 effects.consume(code);
15791 return prefix;
15792 }
15793 effects.exit(type);
15794 return ok(code);
15795 }
15796 }
15797 var init_micromark_factory_space = __esmMin((() => {
15798 init_micromark_util_character();
15799 }));
15800
15801 //#endregion
15802 //#region node_modules/micromark/lib/initialize/content.js
15803 /**
15804 * @this {TokenizeContext}
15805 * @type {Initializer}
15806 */
15807 function initializeContent(effects) {
15808 const contentStart = effects.attempt(this.parser.constructs.contentInitial, afterContentStartConstruct, paragraphInitial);
15809 /** @type {Token} */
15810 let previous;
15811 return contentStart;
15812 /** @type {State} */
15813 function afterContentStartConstruct(code) {
15814 if (code === null) {
15815 effects.consume(code);
15816 return;
15817 }
15818 effects.enter("lineEnding");
15819 effects.consume(code);
15820 effects.exit("lineEnding");
15821 return factorySpace(effects, contentStart, "linePrefix");
15822 }
15823 /** @type {State} */
15824 function paragraphInitial(code) {
15825 effects.enter("paragraph");
15826 return lineStart(code);
15827 }
15828 /** @type {State} */
15829 function lineStart(code) {
15830 const token = effects.enter("chunkText", {
15831 contentType: "text",
15832 previous
15833 });
15834 if (previous) previous.next = token;
15835 previous = token;
15836 return data(code);
15837 }
15838 /** @type {State} */
15839 function data(code) {
15840 if (code === null) {
15841 effects.exit("chunkText");
15842 effects.exit("paragraph");
15843 effects.consume(code);
15844 return;
15845 }
15846 if (markdownLineEnding(code)) {
15847 effects.consume(code);
15848 effects.exit("chunkText");
15849 return lineStart;
15850 }
15851 effects.consume(code);
15852 return data;
15853 }
15854 }
15855 var content$1;
15856 var init_content$1 = __esmMin((() => {
15857 init_micromark_factory_space();
15858 init_micromark_util_character();
15859 content$1 = { tokenize: initializeContent };
15860 }));
15861
15862 //#endregion
15863 //#region node_modules/micromark/lib/initialize/document.js
15864 /**
15865 * @this {TokenizeContext}
15866 * @type {Initializer}
15867 */
15868 function initializeDocument(effects) {
15869 const self = this;
15870 /** @type {Array<StackItem>} */
15871 const stack = [];
15872 let continued = 0;
15873 /** @type {TokenizeContext | undefined} */
15874 let childFlow;
15875 /** @type {Token | undefined} */
15876 let childToken;
15877 /** @type {number} */
15878 let lineStartOffset;
15879 return start;
15880 /** @type {State} */
15881 function start(code) {
15882 if (continued < stack.length) {
15883 const item = stack[continued];
15884 self.containerState = item[1];
15885 return effects.attempt(item[0].continuation, documentContinue, checkNewContainers)(code);
15886 }
15887 return checkNewContainers(code);
15888 }
15889 /** @type {State} */
15890 function documentContinue(code) {
15891 continued++;
15892 if (self.containerState._closeFlow) {
15893 self.containerState._closeFlow = void 0;
15894 if (childFlow) closeFlow();
15895 const indexBeforeExits = self.events.length;
15896 let indexBeforeFlow = indexBeforeExits;
15897 /** @type {Point | undefined} */
15898 let point;
15899 while (indexBeforeFlow--) if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === "chunkFlow") {
15900 point = self.events[indexBeforeFlow][1].end;
15901 break;
15902 }
15903 exitContainers(continued);
15904 let index = indexBeforeExits;
15905 while (index < self.events.length) {
15906 self.events[index][1].end = Object.assign({}, point);
15907 index++;
15908 }
15909 splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
15910 self.events.length = index;
15911 return checkNewContainers(code);
15912 }
15913 return start(code);
15914 }
15915 /** @type {State} */
15916 function checkNewContainers(code) {
15917 if (continued === stack.length) {
15918 if (!childFlow) return documentContinued(code);
15919 if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) return flowStart(code);
15920 self.interrupt = Boolean(childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack);
15921 }
15922 self.containerState = {};
15923 return effects.check(containerConstruct, thereIsANewContainer, thereIsNoNewContainer)(code);
15924 }
15925 /** @type {State} */
15926 function thereIsANewContainer(code) {
15927 if (childFlow) closeFlow();
15928 exitContainers(continued);
15929 return documentContinued(code);
15930 }
15931 /** @type {State} */
15932 function thereIsNoNewContainer(code) {
15933 self.parser.lazy[self.now().line] = continued !== stack.length;
15934 lineStartOffset = self.now().offset;
15935 return flowStart(code);
15936 }
15937 /** @type {State} */
15938 function documentContinued(code) {
15939 self.containerState = {};
15940 return effects.attempt(containerConstruct, containerContinue, flowStart)(code);
15941 }
15942 /** @type {State} */
15943 function containerContinue(code) {
15944 continued++;
15945 stack.push([self.currentConstruct, self.containerState]);
15946 return documentContinued(code);
15947 }
15948 /** @type {State} */
15949 function flowStart(code) {
15950 if (code === null) {
15951 if (childFlow) closeFlow();
15952 exitContainers(0);
15953 effects.consume(code);
15954 return;
15955 }
15956 childFlow = childFlow || self.parser.flow(self.now());
15957 effects.enter("chunkFlow", {
15958 contentType: "flow",
15959 previous: childToken,
15960 _tokenizer: childFlow
15961 });
15962 return flowContinue(code);
15963 }
15964 /** @type {State} */
15965 function flowContinue(code) {
15966 if (code === null) {
15967 writeToChild(effects.exit("chunkFlow"), true);
15968 exitContainers(0);
15969 effects.consume(code);
15970 return;
15971 }
15972 if (markdownLineEnding(code)) {
15973 effects.consume(code);
15974 writeToChild(effects.exit("chunkFlow"));
15975 continued = 0;
15976 self.interrupt = void 0;
15977 return start;
15978 }
15979 effects.consume(code);
15980 return flowContinue;
15981 }
15982 /**
15983 * @param {Token} token
15984 * @param {boolean | undefined} [eof]
15985 * @returns {void}
15986 */
15987 function writeToChild(token, eof) {
15988 const stream = self.sliceStream(token);
15989 if (eof) stream.push(null);
15990 token.previous = childToken;
15991 if (childToken) childToken.next = token;
15992 childToken = token;
15993 childFlow.defineSkip(token.start);
15994 childFlow.write(stream);
15995 if (self.parser.lazy[token.start.line]) {
15996 let index = childFlow.events.length;
15997 while (index--) if (childFlow.events[index][1].start.offset < lineStartOffset && (!childFlow.events[index][1].end || childFlow.events[index][1].end.offset > lineStartOffset)) return;
15998 const indexBeforeExits = self.events.length;
15999 let indexBeforeFlow = indexBeforeExits;
16000 /** @type {boolean | undefined} */
16001 let seen;
16002 /** @type {Point | undefined} */
16003 let point;
16004 while (indexBeforeFlow--) if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === "chunkFlow") {
16005 if (seen) {
16006 point = self.events[indexBeforeFlow][1].end;
16007 break;
16008 }
16009 seen = true;
16010 }
16011 exitContainers(continued);
16012 index = indexBeforeExits;
16013 while (index < self.events.length) {
16014 self.events[index][1].end = Object.assign({}, point);
16015 index++;
16016 }
16017 splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
16018 self.events.length = index;
16019 }
16020 }
16021 /**
16022 * @param {number} size
16023 * @returns {void}
16024 */
16025 function exitContainers(size) {
16026 let index = stack.length;
16027 while (index-- > size) {
16028 const entry = stack[index];
16029 self.containerState = entry[1];
16030 entry[0].exit.call(self, effects);
16031 }
16032 stack.length = size;
16033 }
16034 function closeFlow() {
16035 childFlow.write([null]);
16036 childToken = void 0;
16037 childFlow = void 0;
16038 self.containerState._closeFlow = void 0;
16039 }
16040 }
16041 /**
16042 * @this {TokenizeContext}
16043 * @type {Tokenizer}
16044 */
16045 function tokenizeContainer(effects, ok, nok) {
16046 return factorySpace(effects, effects.attempt(this.parser.constructs.document, ok, nok), "linePrefix", this.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4);
16047 }
16048 var document$2, containerConstruct;
16049 var init_document = __esmMin((() => {
16050 init_micromark_factory_space();
16051 init_micromark_util_character();
16052 init_micromark_util_chunked();
16053 document$2 = { tokenize: initializeDocument };
16054 containerConstruct = { tokenize: tokenizeContainer };
16055 }));
16056
16057 //#endregion
16058 //#region node_modules/micromark-util-classify-character/index.js
16059 /**
16060 * Classify whether a code represents whitespace, punctuation, or something
16061 * else.
16062 *
16063 * Used for attention (emphasis, strong), whose sequences can open or close
16064 * based on the class of surrounding characters.
16065 *
16066 * > 👉 **Note**: eof (`null`) is seen as whitespace.
16067 *
16068 * @param {Code} code
16069 * Code.
16070 * @returns {typeof constants.characterGroupWhitespace | typeof constants.characterGroupPunctuation | undefined}
16071 * Group.
16072 */
16073 function classifyCharacter(code) {
16074 if (code === null || markdownLineEndingOrSpace(code) || unicodeWhitespace(code)) return 1;
16075 if (unicodePunctuation(code)) return 2;
16076 }
16077 var init_micromark_util_classify_character = __esmMin((() => {
16078 init_micromark_util_character();
16079 }));
16080
16081 //#endregion
16082 //#region node_modules/micromark-util-resolve-all/index.js
16083 /**
16084 * @typedef {import('micromark-util-types').Event} Event
16085 * @typedef {import('micromark-util-types').Resolver} Resolver
16086 * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
16087 */
16088 /**
16089 * Call all `resolveAll`s.
16090 *
16091 * @param {Array<{resolveAll?: Resolver | undefined}>} constructs
16092 * List of constructs, optionally with `resolveAll`s.
16093 * @param {Array<Event>} events
16094 * List of events.
16095 * @param {TokenizeContext} context
16096 * Context used by `tokenize`.
16097 * @returns {Array<Event>}
16098 * Changed events.
16099 */
16100 function resolveAll(constructs, events, context) {
16101 /** @type {Array<Resolver>} */
16102 const called = [];
16103 let index = -1;
16104 while (++index < constructs.length) {
16105 const resolve = constructs[index].resolveAll;
16106 if (resolve && !called.includes(resolve)) {
16107 events = resolve(events, context);
16108 called.push(resolve);
16109 }
16110 }
16111 return events;
16112 }
16113 var init_micromark_util_resolve_all = __esmMin((() => {}));
16114
16115 //#endregion
16116 //#region node_modules/micromark-core-commonmark/lib/attention.js
16117 /**
16118 * Take all events and resolve attention to emphasis or strong.
16119 *
16120 * @type {Resolver}
16121 */
16122 function resolveAllAttention(events, context) {
16123 let index = -1;
16124 /** @type {number} */
16125 let open;
16126 /** @type {Token} */
16127 let group;
16128 /** @type {Token} */
16129 let text;
16130 /** @type {Token} */
16131 let openingSequence;
16132 /** @type {Token} */
16133 let closingSequence;
16134 /** @type {number} */
16135 let use;
16136 /** @type {Array<Event>} */
16137 let nextEvents;
16138 /** @type {number} */
16139 let offset;
16140 while (++index < events.length) if (events[index][0] === "enter" && events[index][1].type === "attentionSequence" && events[index][1]._close) {
16141 open = index;
16142 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)) {
16143 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;
16144 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;
16145 const start = Object.assign({}, events[open][1].end);
16146 const end = Object.assign({}, events[index][1].start);
16147 movePoint(start, -use);
16148 movePoint(end, use);
16149 openingSequence = {
16150 type: use > 1 ? "strongSequence" : "emphasisSequence",
16151 start,
16152 end: Object.assign({}, events[open][1].end)
16153 };
16154 closingSequence = {
16155 type: use > 1 ? "strongSequence" : "emphasisSequence",
16156 start: Object.assign({}, events[index][1].start),
16157 end
16158 };
16159 text = {
16160 type: use > 1 ? "strongText" : "emphasisText",
16161 start: Object.assign({}, events[open][1].end),
16162 end: Object.assign({}, events[index][1].start)
16163 };
16164 group = {
16165 type: use > 1 ? "strong" : "emphasis",
16166 start: Object.assign({}, openingSequence.start),
16167 end: Object.assign({}, closingSequence.end)
16168 };
16169 events[open][1].end = Object.assign({}, openingSequence.start);
16170 events[index][1].start = Object.assign({}, closingSequence.end);
16171 nextEvents = [];
16172 if (events[open][1].end.offset - events[open][1].start.offset) nextEvents = push(nextEvents, [[
16173 "enter",
16174 events[open][1],
16175 context
16176 ], [
16177 "exit",
16178 events[open][1],
16179 context
16180 ]]);
16181 nextEvents = push(nextEvents, [
16182 [
16183 "enter",
16184 group,
16185 context
16186 ],
16187 [
16188 "enter",
16189 openingSequence,
16190 context
16191 ],
16192 [
16193 "exit",
16194 openingSequence,
16195 context
16196 ],
16197 [
16198 "enter",
16199 text,
16200 context
16201 ]
16202 ]);
16203 nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + 1, index), context));
16204 nextEvents = push(nextEvents, [
16205 [
16206 "exit",
16207 text,
16208 context
16209 ],
16210 [
16211 "enter",
16212 closingSequence,
16213 context
16214 ],
16215 [
16216 "exit",
16217 closingSequence,
16218 context
16219 ],
16220 [
16221 "exit",
16222 group,
16223 context
16224 ]
16225 ]);
16226 if (events[index][1].end.offset - events[index][1].start.offset) {
16227 offset = 2;
16228 nextEvents = push(nextEvents, [[
16229 "enter",
16230 events[index][1],
16231 context
16232 ], [
16233 "exit",
16234 events[index][1],
16235 context
16236 ]]);
16237 } else offset = 0;
16238 splice(events, open - 1, index - open + 3, nextEvents);
16239 index = open + nextEvents.length - offset - 2;
16240 break;
16241 }
16242 }
16243 index = -1;
16244 while (++index < events.length) if (events[index][1].type === "attentionSequence") events[index][1].type = "data";
16245 return events;
16246 }
16247 /**
16248 * @this {TokenizeContext}
16249 * @type {Tokenizer}
16250 */
16251 function tokenizeAttention(effects, ok) {
16252 const attentionMarkers = this.parser.constructs.attentionMarkers.null;
16253 const previous = this.previous;
16254 const before = classifyCharacter(previous);
16255 /** @type {NonNullable<Code>} */
16256 let marker;
16257 return start;
16258 /**
16259 * Before a sequence.
16260 *
16261 * ```markdown
16262 * > | **
16263 * ^
16264 * ```
16265 *
16266 * @type {State}
16267 */
16268 function start(code) {
16269 marker = code;
16270 effects.enter("attentionSequence");
16271 return inside(code);
16272 }
16273 /**
16274 * In a sequence.
16275 *
16276 * ```markdown
16277 * > | **
16278 * ^^
16279 * ```
16280 *
16281 * @type {State}
16282 */
16283 function inside(code) {
16284 if (code === marker) {
16285 effects.consume(code);
16286 return inside;
16287 }
16288 const token = effects.exit("attentionSequence");
16289 const after = classifyCharacter(code);
16290 const open = !after || after === 2 && before || attentionMarkers.includes(code);
16291 const close = !before || before === 2 && after || attentionMarkers.includes(previous);
16292 token._open = Boolean(marker === 42 ? open : open && (before || !close));
16293 token._close = Boolean(marker === 42 ? close : close && (after || !open));
16294 return ok(code);
16295 }
16296 }
16297 /**
16298 * Move a point a bit.
16299 *
16300 * Note: `move` only works inside lines! It’s not possible to move past other
16301 * chunks (replacement characters, tabs, or line endings).
16302 *
16303 * @param {Point} point
16304 * @param {number} offset
16305 * @returns {void}
16306 */
16307 function movePoint(point, offset) {
16308 point.column += offset;
16309 point.offset += offset;
16310 point._bufferIndex += offset;
16311 }
16312 var attention;
16313 var init_attention = __esmMin((() => {
16314 init_micromark_util_chunked();
16315 init_micromark_util_classify_character();
16316 init_micromark_util_resolve_all();
16317 attention = {
16318 name: "attention",
16319 tokenize: tokenizeAttention,
16320 resolveAll: resolveAllAttention
16321 };
16322 }));
16323
16324 //#endregion
16325 //#region node_modules/micromark-core-commonmark/lib/autolink.js
16326 /**
16327 * @this {TokenizeContext}
16328 * @type {Tokenizer}
16329 */
16330 function tokenizeAutolink(effects, ok, nok) {
16331 let size = 0;
16332 return start;
16333 /**
16334 * Start of an autolink.
16335 *
16336 * ```markdown
16337 * > | a<https://example.com>b
16338 * ^
16339 * > | a<[email protected]>b
16340 * ^
16341 * ```
16342 *
16343 * @type {State}
16344 */
16345 function start(code) {
16346 effects.enter("autolink");
16347 effects.enter("autolinkMarker");
16348 effects.consume(code);
16349 effects.exit("autolinkMarker");
16350 effects.enter("autolinkProtocol");
16351 return open;
16352 }
16353 /**
16354 * After `<`, at 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 open(code) {
16366 if (asciiAlpha(code)) {
16367 effects.consume(code);
16368 return schemeOrEmailAtext;
16369 }
16370 return emailAtext(code);
16371 }
16372 /**
16373 * At second byte of protocol or atext.
16374 *
16375 * ```markdown
16376 * > | a<https://example.com>b
16377 * ^
16378 * > | a<[email protected]>b
16379 * ^
16380 * ```
16381 *
16382 * @type {State}
16383 */
16384 function schemeOrEmailAtext(code) {
16385 if (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) {
16386 size = 1;
16387 return schemeInsideOrEmailAtext(code);
16388 }
16389 return emailAtext(code);
16390 }
16391 /**
16392 * In ambiguous protocol or atext.
16393 *
16394 * ```markdown
16395 * > | a<https://example.com>b
16396 * ^
16397 * > | a<[email protected]>b
16398 * ^
16399 * ```
16400 *
16401 * @type {State}
16402 */
16403 function schemeInsideOrEmailAtext(code) {
16404 if (code === 58) {
16405 effects.consume(code);
16406 size = 0;
16407 return urlInside;
16408 }
16409 if ((code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) && size++ < 32) {
16410 effects.consume(code);
16411 return schemeInsideOrEmailAtext;
16412 }
16413 size = 0;
16414 return emailAtext(code);
16415 }
16416 /**
16417 * After protocol, in URL.
16418 *
16419 * ```markdown
16420 * > | a<https://example.com>b
16421 * ^
16422 * ```
16423 *
16424 * @type {State}
16425 */
16426 function urlInside(code) {
16427 if (code === 62) {
16428 effects.exit("autolinkProtocol");
16429 effects.enter("autolinkMarker");
16430 effects.consume(code);
16431 effects.exit("autolinkMarker");
16432 effects.exit("autolink");
16433 return ok;
16434 }
16435 if (code === null || code === 32 || code === 60 || asciiControl(code)) return nok(code);
16436 effects.consume(code);
16437 return urlInside;
16438 }
16439 /**
16440 * In email atext.
16441 *
16442 * ```markdown
16443 * > | a<[email protected]>b
16444 * ^
16445 * ```
16446 *
16447 * @type {State}
16448 */
16449 function emailAtext(code) {
16450 if (code === 64) {
16451 effects.consume(code);
16452 return emailAtSignOrDot;
16453 }
16454 if (asciiAtext(code)) {
16455 effects.consume(code);
16456 return emailAtext;
16457 }
16458 return nok(code);
16459 }
16460 /**
16461 * In label, after at-sign or dot.
16462 *
16463 * ```markdown
16464 * > | a<[email protected]>b
16465 * ^ ^
16466 * ```
16467 *
16468 * @type {State}
16469 */
16470 function emailAtSignOrDot(code) {
16471 return asciiAlphanumeric(code) ? emailLabel(code) : nok(code);
16472 }
16473 /**
16474 * In label, where `.` and `>` are allowed.
16475 *
16476 * ```markdown
16477 * > | a<[email protected]>b
16478 * ^
16479 * ```
16480 *
16481 * @type {State}
16482 */
16483 function emailLabel(code) {
16484 if (code === 46) {
16485 effects.consume(code);
16486 size = 0;
16487 return emailAtSignOrDot;
16488 }
16489 if (code === 62) {
16490 effects.exit("autolinkProtocol").type = "autolinkEmail";
16491 effects.enter("autolinkMarker");
16492 effects.consume(code);
16493 effects.exit("autolinkMarker");
16494 effects.exit("autolink");
16495 return ok;
16496 }
16497 return emailValue(code);
16498 }
16499 /**
16500 * In label, where `.` and `>` are *not* allowed.
16501 *
16502 * Though, this is also used in `emailLabel` to parse other values.
16503 *
16504 * ```markdown
16505 * > | a<[email protected]>b
16506 * ^
16507 * ```
16508 *
16509 * @type {State}
16510 */
16511 function emailValue(code) {
16512 if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) {
16513 const next = code === 45 ? emailValue : emailLabel;
16514 effects.consume(code);
16515 return next;
16516 }
16517 return nok(code);
16518 }
16519 }
16520 var autolink;
16521 var init_autolink = __esmMin((() => {
16522 init_micromark_util_character();
16523 autolink = {
16524 name: "autolink",
16525 tokenize: tokenizeAutolink
16526 };
16527 }));
16528
16529 //#endregion
16530 //#region node_modules/micromark-core-commonmark/lib/blank-line.js
16531 /**
16532 * @this {TokenizeContext}
16533 * @type {Tokenizer}
16534 */
16535 function tokenizeBlankLine(effects, ok, nok) {
16536 return start;
16537 /**
16538 * Start of blank line.
16539 *
16540 * > 👉 **Note**: `␠` represents a space character.
16541 *
16542 * ```markdown
16543 * > | ␠␠␊
16544 * ^
16545 * > | ␊
16546 * ^
16547 * ```
16548 *
16549 * @type {State}
16550 */
16551 function start(code) {
16552 return markdownSpace(code) ? factorySpace(effects, after, "linePrefix")(code) : after(code);
16553 }
16554 /**
16555 * At eof/eol, after optional whitespace.
16556 *
16557 * > 👉 **Note**: `␠` represents a space character.
16558 *
16559 * ```markdown
16560 * > | ␠␠␊
16561 * ^
16562 * > | ␊
16563 * ^
16564 * ```
16565 *
16566 * @type {State}
16567 */
16568 function after(code) {
16569 return code === null || markdownLineEnding(code) ? ok(code) : nok(code);
16570 }
16571 }
16572 var blankLine;
16573 var init_blank_line = __esmMin((() => {
16574 init_micromark_factory_space();
16575 init_micromark_util_character();
16576 blankLine = {
16577 tokenize: tokenizeBlankLine,
16578 partial: true
16579 };
16580 }));
16581
16582 //#endregion
16583 //#region node_modules/micromark-core-commonmark/lib/block-quote.js
16584 /**
16585 * @this {TokenizeContext}
16586 * @type {Tokenizer}
16587 */
16588 function tokenizeBlockQuoteStart(effects, ok, nok) {
16589 const self = this;
16590 return start;
16591 /**
16592 * Start of block quote.
16593 *
16594 * ```markdown
16595 * > | > a
16596 * ^
16597 * ```
16598 *
16599 * @type {State}
16600 */
16601 function start(code) {
16602 if (code === 62) {
16603 const state = self.containerState;
16604 if (!state.open) {
16605 effects.enter("blockQuote", { _container: true });
16606 state.open = true;
16607 }
16608 effects.enter("blockQuotePrefix");
16609 effects.enter("blockQuoteMarker");
16610 effects.consume(code);
16611 effects.exit("blockQuoteMarker");
16612 return after;
16613 }
16614 return nok(code);
16615 }
16616 /**
16617 * After `>`, before optional whitespace.
16618 *
16619 * ```markdown
16620 * > | > a
16621 * ^
16622 * ```
16623 *
16624 * @type {State}
16625 */
16626 function after(code) {
16627 if (markdownSpace(code)) {
16628 effects.enter("blockQuotePrefixWhitespace");
16629 effects.consume(code);
16630 effects.exit("blockQuotePrefixWhitespace");
16631 effects.exit("blockQuotePrefix");
16632 return ok;
16633 }
16634 effects.exit("blockQuotePrefix");
16635 return ok(code);
16636 }
16637 }
16638 /**
16639 * Start of block quote continuation.
16640 *
16641 * ```markdown
16642 * | > a
16643 * > | > b
16644 * ^
16645 * ```
16646 *
16647 * @this {TokenizeContext}
16648 * @type {Tokenizer}
16649 */
16650 function tokenizeBlockQuoteContinuation(effects, ok, nok) {
16651 const self = this;
16652 return contStart;
16653 /**
16654 * Start of block quote continuation.
16655 *
16656 * Also used to parse the first block quote opening.
16657 *
16658 * ```markdown
16659 * | > a
16660 * > | > b
16661 * ^
16662 * ```
16663 *
16664 * @type {State}
16665 */
16666 function contStart(code) {
16667 if (markdownSpace(code)) return factorySpace(effects, contBefore, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code);
16668 return contBefore(code);
16669 }
16670 /**
16671 * At `>`, after optional whitespace.
16672 *
16673 * Also used to parse the first block quote opening.
16674 *
16675 * ```markdown
16676 * | > a
16677 * > | > b
16678 * ^
16679 * ```
16680 *
16681 * @type {State}
16682 */
16683 function contBefore(code) {
16684 return effects.attempt(blockQuote, ok, nok)(code);
16685 }
16686 }
16687 /** @type {Exiter} */
16688 function exit(effects) {
16689 effects.exit("blockQuote");
16690 }
16691 var blockQuote;
16692 var init_block_quote = __esmMin((() => {
16693 init_micromark_factory_space();
16694 init_micromark_util_character();
16695 blockQuote = {
16696 name: "blockQuote",
16697 tokenize: tokenizeBlockQuoteStart,
16698 continuation: { tokenize: tokenizeBlockQuoteContinuation },
16699 exit
16700 };
16701 }));
16702
16703 //#endregion
16704 //#region node_modules/micromark-core-commonmark/lib/character-escape.js
16705 /**
16706 * @this {TokenizeContext}
16707 * @type {Tokenizer}
16708 */
16709 function tokenizeCharacterEscape(effects, ok, nok) {
16710 return start;
16711 /**
16712 * Start of character escape.
16713 *
16714 * ```markdown
16715 * > | a\*b
16716 * ^
16717 * ```
16718 *
16719 * @type {State}
16720 */
16721 function start(code) {
16722 effects.enter("characterEscape");
16723 effects.enter("escapeMarker");
16724 effects.consume(code);
16725 effects.exit("escapeMarker");
16726 return inside;
16727 }
16728 /**
16729 * After `\`, at punctuation.
16730 *
16731 * ```markdown
16732 * > | a\*b
16733 * ^
16734 * ```
16735 *
16736 * @type {State}
16737 */
16738 function inside(code) {
16739 if (asciiPunctuation(code)) {
16740 effects.enter("characterEscapeValue");
16741 effects.consume(code);
16742 effects.exit("characterEscapeValue");
16743 effects.exit("characterEscape");
16744 return ok;
16745 }
16746 return nok(code);
16747 }
16748 }
16749 var characterEscape;
16750 var init_character_escape = __esmMin((() => {
16751 init_micromark_util_character();
16752 characterEscape = {
16753 name: "characterEscape",
16754 tokenize: tokenizeCharacterEscape
16755 };
16756 }));
16757
16758 //#endregion
16759 //#region node_modules/decode-named-character-reference/index.dom.js
16760 /**
16761 * @param {string} value
16762 * @returns {string | false}
16763 */
16764 function decodeNamedCharacterReference(value) {
16765 const characterReference = "&" + value + ";";
16766 element.innerHTML = characterReference;
16767 const character = element.textContent;
16768 if (character.charCodeAt(character.length - 1) === 59 && value !== "semi") return false;
16769 return character === characterReference ? false : character;
16770 }
16771 var element;
16772 var init_index_dom = __esmMin((() => {
16773 element = document.createElement("i");
16774 }));
16775
16776 //#endregion
16777 //#region node_modules/micromark-core-commonmark/lib/character-reference.js
16778 /**
16779 * @this {TokenizeContext}
16780 * @type {Tokenizer}
16781 */
16782 function tokenizeCharacterReference(effects, ok, nok) {
16783 const self = this;
16784 let size = 0;
16785 /** @type {number} */
16786 let max;
16787 /** @type {(code: Code) => boolean} */
16788 let test;
16789 return start;
16790 /**
16791 * Start of character reference.
16792 *
16793 * ```markdown
16794 * > | a&amp;b
16795 * ^
16796 * > | a&#123;b
16797 * ^
16798 * > | a&#x9;b
16799 * ^
16800 * ```
16801 *
16802 * @type {State}
16803 */
16804 function start(code) {
16805 effects.enter("characterReference");
16806 effects.enter("characterReferenceMarker");
16807 effects.consume(code);
16808 effects.exit("characterReferenceMarker");
16809 return open;
16810 }
16811 /**
16812 * After `&`, at `#` for numeric references or alphanumeric for named
16813 * references.
16814 *
16815 * ```markdown
16816 * > | a&amp;b
16817 * ^
16818 * > | a&#123;b
16819 * ^
16820 * > | a&#x9;b
16821 * ^
16822 * ```
16823 *
16824 * @type {State}
16825 */
16826 function open(code) {
16827 if (code === 35) {
16828 effects.enter("characterReferenceMarkerNumeric");
16829 effects.consume(code);
16830 effects.exit("characterReferenceMarkerNumeric");
16831 return numeric;
16832 }
16833 effects.enter("characterReferenceValue");
16834 max = 31;
16835 test = asciiAlphanumeric;
16836 return value(code);
16837 }
16838 /**
16839 * After `#`, at `x` for hexadecimals or digit for decimals.
16840 *
16841 * ```markdown
16842 * > | a&#123;b
16843 * ^
16844 * > | a&#x9;b
16845 * ^
16846 * ```
16847 *
16848 * @type {State}
16849 */
16850 function numeric(code) {
16851 if (code === 88 || code === 120) {
16852 effects.enter("characterReferenceMarkerHexadecimal");
16853 effects.consume(code);
16854 effects.exit("characterReferenceMarkerHexadecimal");
16855 effects.enter("characterReferenceValue");
16856 max = 6;
16857 test = asciiHexDigit;
16858 return value;
16859 }
16860 effects.enter("characterReferenceValue");
16861 max = 7;
16862 test = asciiDigit;
16863 return value(code);
16864 }
16865 /**
16866 * After markers (`&#x`, `&#`, or `&`), in value, before `;`.
16867 *
16868 * The character reference kind defines what and how many characters are
16869 * allowed.
16870 *
16871 * ```markdown
16872 * > | a&amp;b
16873 * ^^^
16874 * > | a&#123;b
16875 * ^^^
16876 * > | a&#x9;b
16877 * ^
16878 * ```
16879 *
16880 * @type {State}
16881 */
16882 function value(code) {
16883 if (code === 59 && size) {
16884 const token = effects.exit("characterReferenceValue");
16885 if (test === asciiAlphanumeric && !decodeNamedCharacterReference(self.sliceSerialize(token))) return nok(code);
16886 effects.enter("characterReferenceMarker");
16887 effects.consume(code);
16888 effects.exit("characterReferenceMarker");
16889 effects.exit("characterReference");
16890 return ok;
16891 }
16892 if (test(code) && size++ < max) {
16893 effects.consume(code);
16894 return value;
16895 }
16896 return nok(code);
16897 }
16898 }
16899 var characterReference;
16900 var init_character_reference = __esmMin((() => {
16901 init_index_dom();
16902 init_micromark_util_character();
16903 characterReference = {
16904 name: "characterReference",
16905 tokenize: tokenizeCharacterReference
16906 };
16907 }));
16908
16909 //#endregion
16910 //#region node_modules/micromark-core-commonmark/lib/code-fenced.js
16911 /**
16912 * @this {TokenizeContext}
16913 * @type {Tokenizer}
16914 */
16915 function tokenizeCodeFenced(effects, ok, nok) {
16916 const self = this;
16917 /** @type {Construct} */
16918 const closeStart = {
16919 tokenize: tokenizeCloseStart,
16920 partial: true
16921 };
16922 let initialPrefix = 0;
16923 let sizeOpen = 0;
16924 /** @type {NonNullable<Code>} */
16925 let marker;
16926 return start;
16927 /**
16928 * Start of code.
16929 *
16930 * ```markdown
16931 * > | ~~~js
16932 * ^
16933 * | alert(1)
16934 * | ~~~
16935 * ```
16936 *
16937 * @type {State}
16938 */
16939 function start(code) {
16940 return beforeSequenceOpen(code);
16941 }
16942 /**
16943 * In opening fence, after prefix, at sequence.
16944 *
16945 * ```markdown
16946 * > | ~~~js
16947 * ^
16948 * | alert(1)
16949 * | ~~~
16950 * ```
16951 *
16952 * @type {State}
16953 */
16954 function beforeSequenceOpen(code) {
16955 const tail = self.events[self.events.length - 1];
16956 initialPrefix = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0;
16957 marker = code;
16958 effects.enter("codeFenced");
16959 effects.enter("codeFencedFence");
16960 effects.enter("codeFencedFenceSequence");
16961 return sequenceOpen(code);
16962 }
16963 /**
16964 * In opening fence sequence.
16965 *
16966 * ```markdown
16967 * > | ~~~js
16968 * ^
16969 * | alert(1)
16970 * | ~~~
16971 * ```
16972 *
16973 * @type {State}
16974 */
16975 function sequenceOpen(code) {
16976 if (code === marker) {
16977 sizeOpen++;
16978 effects.consume(code);
16979 return sequenceOpen;
16980 }
16981 if (sizeOpen < 3) return nok(code);
16982 effects.exit("codeFencedFenceSequence");
16983 return markdownSpace(code) ? factorySpace(effects, infoBefore, "whitespace")(code) : infoBefore(code);
16984 }
16985 /**
16986 * In opening fence, after the sequence (and optional whitespace), before info.
16987 *
16988 * ```markdown
16989 * > | ~~~js
16990 * ^
16991 * | alert(1)
16992 * | ~~~
16993 * ```
16994 *
16995 * @type {State}
16996 */
16997 function infoBefore(code) {
16998 if (code === null || markdownLineEnding(code)) {
16999 effects.exit("codeFencedFence");
17000 return self.interrupt ? ok(code) : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
17001 }
17002 effects.enter("codeFencedFenceInfo");
17003 effects.enter("chunkString", { contentType: "string" });
17004 return info(code);
17005 }
17006 /**
17007 * In info.
17008 *
17009 * ```markdown
17010 * > | ~~~js
17011 * ^
17012 * | alert(1)
17013 * | ~~~
17014 * ```
17015 *
17016 * @type {State}
17017 */
17018 function info(code) {
17019 if (code === null || markdownLineEnding(code)) {
17020 effects.exit("chunkString");
17021 effects.exit("codeFencedFenceInfo");
17022 return infoBefore(code);
17023 }
17024 if (markdownSpace(code)) {
17025 effects.exit("chunkString");
17026 effects.exit("codeFencedFenceInfo");
17027 return factorySpace(effects, metaBefore, "whitespace")(code);
17028 }
17029 if (code === 96 && code === marker) return nok(code);
17030 effects.consume(code);
17031 return info;
17032 }
17033 /**
17034 * In opening fence, after info and whitespace, before meta.
17035 *
17036 * ```markdown
17037 * > | ~~~js eval
17038 * ^
17039 * | alert(1)
17040 * | ~~~
17041 * ```
17042 *
17043 * @type {State}
17044 */
17045 function metaBefore(code) {
17046 if (code === null || markdownLineEnding(code)) return infoBefore(code);
17047 effects.enter("codeFencedFenceMeta");
17048 effects.enter("chunkString", { contentType: "string" });
17049 return meta(code);
17050 }
17051 /**
17052 * In meta.
17053 *
17054 * ```markdown
17055 * > | ~~~js eval
17056 * ^
17057 * | alert(1)
17058 * | ~~~
17059 * ```
17060 *
17061 * @type {State}
17062 */
17063 function meta(code) {
17064 if (code === null || markdownLineEnding(code)) {
17065 effects.exit("chunkString");
17066 effects.exit("codeFencedFenceMeta");
17067 return infoBefore(code);
17068 }
17069 if (code === 96 && code === marker) return nok(code);
17070 effects.consume(code);
17071 return meta;
17072 }
17073 /**
17074 * At eol/eof in code, before a non-lazy closing fence or content.
17075 *
17076 * ```markdown
17077 * > | ~~~js
17078 * ^
17079 * > | alert(1)
17080 * ^
17081 * | ~~~
17082 * ```
17083 *
17084 * @type {State}
17085 */
17086 function atNonLazyBreak(code) {
17087 return effects.attempt(closeStart, after, contentBefore)(code);
17088 }
17089 /**
17090 * Before code content, not a closing fence, at eol.
17091 *
17092 * ```markdown
17093 * | ~~~js
17094 * > | alert(1)
17095 * ^
17096 * | ~~~
17097 * ```
17098 *
17099 * @type {State}
17100 */
17101 function contentBefore(code) {
17102 effects.enter("lineEnding");
17103 effects.consume(code);
17104 effects.exit("lineEnding");
17105 return contentStart;
17106 }
17107 /**
17108 * Before code content, not a closing fence.
17109 *
17110 * ```markdown
17111 * | ~~~js
17112 * > | alert(1)
17113 * ^
17114 * | ~~~
17115 * ```
17116 *
17117 * @type {State}
17118 */
17119 function contentStart(code) {
17120 return initialPrefix > 0 && markdownSpace(code) ? factorySpace(effects, beforeContentChunk, "linePrefix", initialPrefix + 1)(code) : beforeContentChunk(code);
17121 }
17122 /**
17123 * Before code content, after optional prefix.
17124 *
17125 * ```markdown
17126 * | ~~~js
17127 * > | alert(1)
17128 * ^
17129 * | ~~~
17130 * ```
17131 *
17132 * @type {State}
17133 */
17134 function beforeContentChunk(code) {
17135 if (code === null || markdownLineEnding(code)) return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
17136 effects.enter("codeFlowValue");
17137 return contentChunk(code);
17138 }
17139 /**
17140 * In code content.
17141 *
17142 * ```markdown
17143 * | ~~~js
17144 * > | alert(1)
17145 * ^^^^^^^^
17146 * | ~~~
17147 * ```
17148 *
17149 * @type {State}
17150 */
17151 function contentChunk(code) {
17152 if (code === null || markdownLineEnding(code)) {
17153 effects.exit("codeFlowValue");
17154 return beforeContentChunk(code);
17155 }
17156 effects.consume(code);
17157 return contentChunk;
17158 }
17159 /**
17160 * After code.
17161 *
17162 * ```markdown
17163 * | ~~~js
17164 * | alert(1)
17165 * > | ~~~
17166 * ^
17167 * ```
17168 *
17169 * @type {State}
17170 */
17171 function after(code) {
17172 effects.exit("codeFenced");
17173 return ok(code);
17174 }
17175 /**
17176 * @this {TokenizeContext}
17177 * @type {Tokenizer}
17178 */
17179 function tokenizeCloseStart(effects, ok, nok) {
17180 let size = 0;
17181 return startBefore;
17182 /**
17183 *
17184 *
17185 * @type {State}
17186 */
17187 function startBefore(code) {
17188 effects.enter("lineEnding");
17189 effects.consume(code);
17190 effects.exit("lineEnding");
17191 return start;
17192 }
17193 /**
17194 * Before closing fence, at optional whitespace.
17195 *
17196 * ```markdown
17197 * | ~~~js
17198 * | alert(1)
17199 * > | ~~~
17200 * ^
17201 * ```
17202 *
17203 * @type {State}
17204 */
17205 function start(code) {
17206 effects.enter("codeFencedFence");
17207 return markdownSpace(code) ? factorySpace(effects, beforeSequenceClose, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code) : beforeSequenceClose(code);
17208 }
17209 /**
17210 * In closing fence, after optional whitespace, at sequence.
17211 *
17212 * ```markdown
17213 * | ~~~js
17214 * | alert(1)
17215 * > | ~~~
17216 * ^
17217 * ```
17218 *
17219 * @type {State}
17220 */
17221 function beforeSequenceClose(code) {
17222 if (code === marker) {
17223 effects.enter("codeFencedFenceSequence");
17224 return sequenceClose(code);
17225 }
17226 return nok(code);
17227 }
17228 /**
17229 * In closing fence sequence.
17230 *
17231 * ```markdown
17232 * | ~~~js
17233 * | alert(1)
17234 * > | ~~~
17235 * ^
17236 * ```
17237 *
17238 * @type {State}
17239 */
17240 function sequenceClose(code) {
17241 if (code === marker) {
17242 size++;
17243 effects.consume(code);
17244 return sequenceClose;
17245 }
17246 if (size >= sizeOpen) {
17247 effects.exit("codeFencedFenceSequence");
17248 return markdownSpace(code) ? factorySpace(effects, sequenceCloseAfter, "whitespace")(code) : sequenceCloseAfter(code);
17249 }
17250 return nok(code);
17251 }
17252 /**
17253 * After closing fence sequence, after optional whitespace.
17254 *
17255 * ```markdown
17256 * | ~~~js
17257 * | alert(1)
17258 * > | ~~~
17259 * ^
17260 * ```
17261 *
17262 * @type {State}
17263 */
17264 function sequenceCloseAfter(code) {
17265 if (code === null || markdownLineEnding(code)) {
17266 effects.exit("codeFencedFence");
17267 return ok(code);
17268 }
17269 return nok(code);
17270 }
17271 }
17272 }
17273 /**
17274 * @this {TokenizeContext}
17275 * @type {Tokenizer}
17276 */
17277 function tokenizeNonLazyContinuation(effects, ok, nok) {
17278 const self = this;
17279 return start;
17280 /**
17281 *
17282 *
17283 * @type {State}
17284 */
17285 function start(code) {
17286 if (code === null) return nok(code);
17287 effects.enter("lineEnding");
17288 effects.consume(code);
17289 effects.exit("lineEnding");
17290 return lineStart;
17291 }
17292 /**
17293 *
17294 *
17295 * @type {State}
17296 */
17297 function lineStart(code) {
17298 return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
17299 }
17300 }
17301 var nonLazyContinuation, codeFenced;
17302 var init_code_fenced = __esmMin((() => {
17303 init_micromark_factory_space();
17304 init_micromark_util_character();
17305 nonLazyContinuation = {
17306 tokenize: tokenizeNonLazyContinuation,
17307 partial: true
17308 };
17309 codeFenced = {
17310 name: "codeFenced",
17311 tokenize: tokenizeCodeFenced,
17312 concrete: true
17313 };
17314 }));
17315
17316 //#endregion
17317 //#region node_modules/micromark-core-commonmark/lib/code-indented.js
17318 /**
17319 * @this {TokenizeContext}
17320 * @type {Tokenizer}
17321 */
17322 function tokenizeCodeIndented(effects, ok, nok) {
17323 const self = this;
17324 return start;
17325 /**
17326 * Start of code (indented).
17327 *
17328 * > **Parsing note**: it is not needed to check if this first line is a
17329 * > filled line (that it has a non-whitespace character), because blank lines
17330 * > are parsed already, so we never run into that.
17331 *
17332 * ```markdown
17333 * > | aaa
17334 * ^
17335 * ```
17336 *
17337 * @type {State}
17338 */
17339 function start(code) {
17340 effects.enter("codeIndented");
17341 return factorySpace(effects, afterPrefix, "linePrefix", 5)(code);
17342 }
17343 /**
17344 * At start, after 1 or 4 spaces.
17345 *
17346 * ```markdown
17347 * > | aaa
17348 * ^
17349 * ```
17350 *
17351 * @type {State}
17352 */
17353 function afterPrefix(code) {
17354 const tail = self.events[self.events.length - 1];
17355 return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? atBreak(code) : nok(code);
17356 }
17357 /**
17358 * At a break.
17359 *
17360 * ```markdown
17361 * > | aaa
17362 * ^ ^
17363 * ```
17364 *
17365 * @type {State}
17366 */
17367 function atBreak(code) {
17368 if (code === null) return after(code);
17369 if (markdownLineEnding(code)) return effects.attempt(furtherStart, atBreak, after)(code);
17370 effects.enter("codeFlowValue");
17371 return inside(code);
17372 }
17373 /**
17374 * In code content.
17375 *
17376 * ```markdown
17377 * > | aaa
17378 * ^^^^
17379 * ```
17380 *
17381 * @type {State}
17382 */
17383 function inside(code) {
17384 if (code === null || markdownLineEnding(code)) {
17385 effects.exit("codeFlowValue");
17386 return atBreak(code);
17387 }
17388 effects.consume(code);
17389 return inside;
17390 }
17391 /** @type {State} */
17392 function after(code) {
17393 effects.exit("codeIndented");
17394 return ok(code);
17395 }
17396 }
17397 /**
17398 * @this {TokenizeContext}
17399 * @type {Tokenizer}
17400 */
17401 function tokenizeFurtherStart(effects, ok, nok) {
17402 const self = this;
17403 return furtherStart;
17404 /**
17405 * At eol, trying to parse another indent.
17406 *
17407 * ```markdown
17408 * > | aaa
17409 * ^
17410 * | bbb
17411 * ```
17412 *
17413 * @type {State}
17414 */
17415 function furtherStart(code) {
17416 if (self.parser.lazy[self.now().line]) return nok(code);
17417 if (markdownLineEnding(code)) {
17418 effects.enter("lineEnding");
17419 effects.consume(code);
17420 effects.exit("lineEnding");
17421 return furtherStart;
17422 }
17423 return factorySpace(effects, afterPrefix, "linePrefix", 5)(code);
17424 }
17425 /**
17426 * At start, after 1 or 4 spaces.
17427 *
17428 * ```markdown
17429 * > | aaa
17430 * ^
17431 * ```
17432 *
17433 * @type {State}
17434 */
17435 function afterPrefix(code) {
17436 const tail = self.events[self.events.length - 1];
17437 return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? ok(code) : markdownLineEnding(code) ? furtherStart(code) : nok(code);
17438 }
17439 }
17440 var codeIndented, furtherStart;
17441 var init_code_indented = __esmMin((() => {
17442 init_micromark_factory_space();
17443 init_micromark_util_character();
17444 codeIndented = {
17445 name: "codeIndented",
17446 tokenize: tokenizeCodeIndented
17447 };
17448 furtherStart = {
17449 tokenize: tokenizeFurtherStart,
17450 partial: true
17451 };
17452 }));
17453
17454 //#endregion
17455 //#region node_modules/micromark-core-commonmark/lib/code-text.js
17456 /** @type {Resolver} */
17457 function resolveCodeText(events) {
17458 let tailExitIndex = events.length - 4;
17459 let headEnterIndex = 3;
17460 /** @type {number} */
17461 let index;
17462 /** @type {number | undefined} */
17463 let enter;
17464 if ((events[headEnterIndex][1].type === "lineEnding" || events[headEnterIndex][1].type === "space") && (events[tailExitIndex][1].type === "lineEnding" || events[tailExitIndex][1].type === "space")) {
17465 index = headEnterIndex;
17466 while (++index < tailExitIndex) if (events[index][1].type === "codeTextData") {
17467 events[headEnterIndex][1].type = "codeTextPadding";
17468 events[tailExitIndex][1].type = "codeTextPadding";
17469 headEnterIndex += 2;
17470 tailExitIndex -= 2;
17471 break;
17472 }
17473 }
17474 index = headEnterIndex - 1;
17475 tailExitIndex++;
17476 while (++index <= tailExitIndex) if (enter === void 0) {
17477 if (index !== tailExitIndex && events[index][1].type !== "lineEnding") enter = index;
17478 } else if (index === tailExitIndex || events[index][1].type === "lineEnding") {
17479 events[enter][1].type = "codeTextData";
17480 if (index !== enter + 2) {
17481 events[enter][1].end = events[index - 1][1].end;
17482 events.splice(enter + 2, index - enter - 2);
17483 tailExitIndex -= index - enter - 2;
17484 index = enter + 2;
17485 }
17486 enter = void 0;
17487 }
17488 return events;
17489 }
17490 /**
17491 * @this {TokenizeContext}
17492 * @type {Previous}
17493 */
17494 function previous(code) {
17495 return code !== 96 || this.events[this.events.length - 1][1].type === "characterEscape";
17496 }
17497 /**
17498 * @this {TokenizeContext}
17499 * @type {Tokenizer}
17500 */
17501 function tokenizeCodeText(effects, ok, nok) {
17502 let sizeOpen = 0;
17503 /** @type {number} */
17504 let size;
17505 /** @type {Token} */
17506 let token;
17507 return start;
17508 /**
17509 * Start of code (text).
17510 *
17511 * ```markdown
17512 * > | `a`
17513 * ^
17514 * > | \`a`
17515 * ^
17516 * ```
17517 *
17518 * @type {State}
17519 */
17520 function start(code) {
17521 effects.enter("codeText");
17522 effects.enter("codeTextSequence");
17523 return sequenceOpen(code);
17524 }
17525 /**
17526 * In opening sequence.
17527 *
17528 * ```markdown
17529 * > | `a`
17530 * ^
17531 * ```
17532 *
17533 * @type {State}
17534 */
17535 function sequenceOpen(code) {
17536 if (code === 96) {
17537 effects.consume(code);
17538 sizeOpen++;
17539 return sequenceOpen;
17540 }
17541 effects.exit("codeTextSequence");
17542 return between(code);
17543 }
17544 /**
17545 * Between something and something else.
17546 *
17547 * ```markdown
17548 * > | `a`
17549 * ^^
17550 * ```
17551 *
17552 * @type {State}
17553 */
17554 function between(code) {
17555 if (code === null) return nok(code);
17556 if (code === 32) {
17557 effects.enter("space");
17558 effects.consume(code);
17559 effects.exit("space");
17560 return between;
17561 }
17562 if (code === 96) {
17563 token = effects.enter("codeTextSequence");
17564 size = 0;
17565 return sequenceClose(code);
17566 }
17567 if (markdownLineEnding(code)) {
17568 effects.enter("lineEnding");
17569 effects.consume(code);
17570 effects.exit("lineEnding");
17571 return between;
17572 }
17573 effects.enter("codeTextData");
17574 return data(code);
17575 }
17576 /**
17577 * In data.
17578 *
17579 * ```markdown
17580 * > | `a`
17581 * ^
17582 * ```
17583 *
17584 * @type {State}
17585 */
17586 function data(code) {
17587 if (code === null || code === 32 || code === 96 || markdownLineEnding(code)) {
17588 effects.exit("codeTextData");
17589 return between(code);
17590 }
17591 effects.consume(code);
17592 return data;
17593 }
17594 /**
17595 * In closing sequence.
17596 *
17597 * ```markdown
17598 * > | `a`
17599 * ^
17600 * ```
17601 *
17602 * @type {State}
17603 */
17604 function sequenceClose(code) {
17605 if (code === 96) {
17606 effects.consume(code);
17607 size++;
17608 return sequenceClose;
17609 }
17610 if (size === sizeOpen) {
17611 effects.exit("codeTextSequence");
17612 effects.exit("codeText");
17613 return ok(code);
17614 }
17615 token.type = "codeTextData";
17616 return data(code);
17617 }
17618 }
17619 var codeText;
17620 var init_code_text = __esmMin((() => {
17621 init_micromark_util_character();
17622 codeText = {
17623 name: "codeText",
17624 tokenize: tokenizeCodeText,
17625 resolve: resolveCodeText,
17626 previous
17627 };
17628 }));
17629
17630 //#endregion
17631 //#region node_modules/micromark-util-subtokenize/index.js
17632 /**
17633 * Tokenize subcontent.
17634 *
17635 * @param {Array<Event>} events
17636 * List of events.
17637 * @returns {boolean}
17638 * Whether subtokens were found.
17639 */
17640 function subtokenize(events) {
17641 /** @type {Record<string, number>} */
17642 const jumps = {};
17643 let index = -1;
17644 /** @type {Event} */
17645 let event;
17646 /** @type {number | undefined} */
17647 let lineIndex;
17648 /** @type {number} */
17649 let otherIndex;
17650 /** @type {Event} */
17651 let otherEvent;
17652 /** @type {Array<Event>} */
17653 let parameters;
17654 /** @type {Array<Event>} */
17655 let subevents;
17656 /** @type {boolean | undefined} */
17657 let more;
17658 while (++index < events.length) {
17659 while (index in jumps) index = jumps[index];
17660 event = events[index];
17661 if (index && event[1].type === "chunkFlow" && events[index - 1][1].type === "listItemPrefix") {
17662 subevents = event[1]._tokenizer.events;
17663 otherIndex = 0;
17664 if (otherIndex < subevents.length && subevents[otherIndex][1].type === "lineEndingBlank") otherIndex += 2;
17665 if (otherIndex < subevents.length && subevents[otherIndex][1].type === "content") while (++otherIndex < subevents.length) {
17666 if (subevents[otherIndex][1].type === "content") break;
17667 if (subevents[otherIndex][1].type === "chunkText") {
17668 subevents[otherIndex][1]._isInFirstContentOfListItem = true;
17669 otherIndex++;
17670 }
17671 }
17672 }
17673 if (event[0] === "enter") {
17674 if (event[1].contentType) {
17675 Object.assign(jumps, subcontent(events, index));
17676 index = jumps[index];
17677 more = true;
17678 }
17679 } else if (event[1]._container) {
17680 otherIndex = index;
17681 lineIndex = void 0;
17682 while (otherIndex--) {
17683 otherEvent = events[otherIndex];
17684 if (otherEvent[1].type === "lineEnding" || otherEvent[1].type === "lineEndingBlank") {
17685 if (otherEvent[0] === "enter") {
17686 if (lineIndex) events[lineIndex][1].type = "lineEndingBlank";
17687 otherEvent[1].type = "lineEnding";
17688 lineIndex = otherIndex;
17689 }
17690 } else break;
17691 }
17692 if (lineIndex) {
17693 event[1].end = Object.assign({}, events[lineIndex][1].start);
17694 parameters = events.slice(lineIndex, index);
17695 parameters.unshift(event);
17696 splice(events, lineIndex, index - lineIndex + 1, parameters);
17697 }
17698 }
17699 }
17700 return !more;
17701 }
17702 /**
17703 * Tokenize embedded tokens.
17704 *
17705 * @param {Array<Event>} events
17706 * @param {number} eventIndex
17707 * @returns {Record<string, number>}
17708 */
17709 function subcontent(events, eventIndex) {
17710 const token = events[eventIndex][1];
17711 const context = events[eventIndex][2];
17712 let startPosition = eventIndex - 1;
17713 /** @type {Array<number>} */
17714 const startPositions = [];
17715 const tokenizer = token._tokenizer || context.parser[token.contentType](token.start);
17716 const childEvents = tokenizer.events;
17717 /** @type {Array<[number, number]>} */
17718 const jumps = [];
17719 /** @type {Record<string, number>} */
17720 const gaps = {};
17721 /** @type {Array<Chunk>} */
17722 let stream;
17723 /** @type {Token | undefined} */
17724 let previous;
17725 let index = -1;
17726 /** @type {Token | undefined} */
17727 let current = token;
17728 let adjust = 0;
17729 let start = 0;
17730 const breaks = [start];
17731 while (current) {
17732 while (events[++startPosition][1] !== current);
17733 startPositions.push(startPosition);
17734 if (!current._tokenizer) {
17735 stream = context.sliceStream(current);
17736 if (!current.next) stream.push(null);
17737 if (previous) tokenizer.defineSkip(current.start);
17738 if (current._isInFirstContentOfListItem) tokenizer._gfmTasklistFirstContentOfListItem = true;
17739 tokenizer.write(stream);
17740 if (current._isInFirstContentOfListItem) tokenizer._gfmTasklistFirstContentOfListItem = void 0;
17741 }
17742 previous = current;
17743 current = current.next;
17744 }
17745 current = token;
17746 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) {
17747 start = index + 1;
17748 breaks.push(start);
17749 current._tokenizer = void 0;
17750 current.previous = void 0;
17751 current = current.next;
17752 }
17753 tokenizer.events = [];
17754 if (current) {
17755 current._tokenizer = void 0;
17756 current.previous = void 0;
17757 } else breaks.pop();
17758 index = breaks.length;
17759 while (index--) {
17760 const slice = childEvents.slice(breaks[index], breaks[index + 1]);
17761 const start = startPositions.pop();
17762 jumps.unshift([start, start + slice.length - 1]);
17763 splice(events, start, 2, slice);
17764 }
17765 index = -1;
17766 while (++index < jumps.length) {
17767 gaps[adjust + jumps[index][0]] = adjust + jumps[index][1];
17768 adjust += jumps[index][1] - jumps[index][0] - 1;
17769 }
17770 return gaps;
17771 }
17772 var init_micromark_util_subtokenize = __esmMin((() => {
17773 init_micromark_util_chunked();
17774 }));
17775
17776 //#endregion
17777 //#region node_modules/micromark-core-commonmark/lib/content.js
17778 /**
17779 * Content is transparent: it’s parsed right now. That way, definitions are also
17780 * parsed right now: before text in paragraphs (specifically, media) are parsed.
17781 *
17782 * @type {Resolver}
17783 */
17784 function resolveContent(events) {
17785 subtokenize(events);
17786 return events;
17787 }
17788 /**
17789 * @this {TokenizeContext}
17790 * @type {Tokenizer}
17791 */
17792 function tokenizeContent(effects, ok) {
17793 /** @type {Token | undefined} */
17794 let previous;
17795 return chunkStart;
17796 /**
17797 * Before a content chunk.
17798 *
17799 * ```markdown
17800 * > | abc
17801 * ^
17802 * ```
17803 *
17804 * @type {State}
17805 */
17806 function chunkStart(code) {
17807 effects.enter("content");
17808 previous = effects.enter("chunkContent", { contentType: "content" });
17809 return chunkInside(code);
17810 }
17811 /**
17812 * In a content chunk.
17813 *
17814 * ```markdown
17815 * > | abc
17816 * ^^^
17817 * ```
17818 *
17819 * @type {State}
17820 */
17821 function chunkInside(code) {
17822 if (code === null) return contentEnd(code);
17823 if (markdownLineEnding(code)) return effects.check(continuationConstruct, contentContinue, contentEnd)(code);
17824 effects.consume(code);
17825 return chunkInside;
17826 }
17827 /**
17828 *
17829 *
17830 * @type {State}
17831 */
17832 function contentEnd(code) {
17833 effects.exit("chunkContent");
17834 effects.exit("content");
17835 return ok(code);
17836 }
17837 /**
17838 *
17839 *
17840 * @type {State}
17841 */
17842 function contentContinue(code) {
17843 effects.consume(code);
17844 effects.exit("chunkContent");
17845 previous.next = effects.enter("chunkContent", {
17846 contentType: "content",
17847 previous
17848 });
17849 previous = previous.next;
17850 return chunkInside;
17851 }
17852 }
17853 /**
17854 * @this {TokenizeContext}
17855 * @type {Tokenizer}
17856 */
17857 function tokenizeContinuation(effects, ok, nok) {
17858 const self = this;
17859 return startLookahead;
17860 /**
17861 *
17862 *
17863 * @type {State}
17864 */
17865 function startLookahead(code) {
17866 effects.exit("chunkContent");
17867 effects.enter("lineEnding");
17868 effects.consume(code);
17869 effects.exit("lineEnding");
17870 return factorySpace(effects, prefixed, "linePrefix");
17871 }
17872 /**
17873 *
17874 *
17875 * @type {State}
17876 */
17877 function prefixed(code) {
17878 if (code === null || markdownLineEnding(code)) return nok(code);
17879 const tail = self.events[self.events.length - 1];
17880 if (!self.parser.constructs.disable.null.includes("codeIndented") && tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4) return ok(code);
17881 return effects.interrupt(self.parser.constructs.flow, nok, ok)(code);
17882 }
17883 }
17884 var content, continuationConstruct;
17885 var init_content = __esmMin((() => {
17886 init_micromark_factory_space();
17887 init_micromark_util_character();
17888 init_micromark_util_subtokenize();
17889 content = {
17890 tokenize: tokenizeContent,
17891 resolve: resolveContent
17892 };
17893 continuationConstruct = {
17894 tokenize: tokenizeContinuation,
17895 partial: true
17896 };
17897 }));
17898
17899 //#endregion
17900 //#region node_modules/micromark-factory-destination/index.js
17901 /**
17902 * Parse destinations.
17903 *
17904 * ###### Examples
17905 *
17906 * ```markdown
17907 * <a>
17908 * <a\>b>
17909 * <a b>
17910 * <a)>
17911 * a
17912 * a\)b
17913 * a(b)c
17914 * a(b)
17915 * ```
17916 *
17917 * @param {Effects} effects
17918 * Context.
17919 * @param {State} ok
17920 * State switched to when successful.
17921 * @param {State} nok
17922 * State switched to when unsuccessful.
17923 * @param {TokenType} type
17924 * Type for whole (`<a>` or `b`).
17925 * @param {TokenType} literalType
17926 * Type when enclosed (`<a>`).
17927 * @param {TokenType} literalMarkerType
17928 * Type for enclosing (`<` and `>`).
17929 * @param {TokenType} rawType
17930 * Type when not enclosed (`b`).
17931 * @param {TokenType} stringType
17932 * Type for the value (`a` or `b`).
17933 * @param {number | undefined} [max=Infinity]
17934 * Depth of nested parens (inclusive).
17935 * @returns {State}
17936 * Start state.
17937 */ function factoryDestination(effects, ok, nok, type, literalType, literalMarkerType, rawType, stringType, max) {
17938 const limit = max || Number.POSITIVE_INFINITY;
17939 let balance = 0;
17940 return start;
17941 /**
17942 * Start of destination.
17943 *
17944 * ```markdown
17945 * > | <aa>
17946 * ^
17947 * > | aa
17948 * ^
17949 * ```
17950 *
17951 * @type {State}
17952 */
17953 function start(code) {
17954 if (code === 60) {
17955 effects.enter(type);
17956 effects.enter(literalType);
17957 effects.enter(literalMarkerType);
17958 effects.consume(code);
17959 effects.exit(literalMarkerType);
17960 return enclosedBefore;
17961 }
17962 if (code === null || code === 32 || code === 41 || asciiControl(code)) return nok(code);
17963 effects.enter(type);
17964 effects.enter(rawType);
17965 effects.enter(stringType);
17966 effects.enter("chunkString", { contentType: "string" });
17967 return raw(code);
17968 }
17969 /**
17970 * After `<`, at an enclosed destination.
17971 *
17972 * ```markdown
17973 * > | <aa>
17974 * ^
17975 * ```
17976 *
17977 * @type {State}
17978 */
17979 function enclosedBefore(code) {
17980 if (code === 62) {
17981 effects.enter(literalMarkerType);
17982 effects.consume(code);
17983 effects.exit(literalMarkerType);
17984 effects.exit(literalType);
17985 effects.exit(type);
17986 return ok;
17987 }
17988 effects.enter(stringType);
17989 effects.enter("chunkString", { contentType: "string" });
17990 return enclosed(code);
17991 }
17992 /**
17993 * In enclosed destination.
17994 *
17995 * ```markdown
17996 * > | <aa>
17997 * ^
17998 * ```
17999 *
18000 * @type {State}
18001 */
18002 function enclosed(code) {
18003 if (code === 62) {
18004 effects.exit("chunkString");
18005 effects.exit(stringType);
18006 return enclosedBefore(code);
18007 }
18008 if (code === null || code === 60 || markdownLineEnding(code)) return nok(code);
18009 effects.consume(code);
18010 return code === 92 ? enclosedEscape : enclosed;
18011 }
18012 /**
18013 * After `\`, at a special character.
18014 *
18015 * ```markdown
18016 * > | <a\*a>
18017 * ^
18018 * ```
18019 *
18020 * @type {State}
18021 */
18022 function enclosedEscape(code) {
18023 if (code === 60 || code === 62 || code === 92) {
18024 effects.consume(code);
18025 return enclosed;
18026 }
18027 return enclosed(code);
18028 }
18029 /**
18030 * In raw destination.
18031 *
18032 * ```markdown
18033 * > | aa
18034 * ^
18035 * ```
18036 *
18037 * @type {State}
18038 */
18039 function raw(code) {
18040 if (!balance && (code === null || code === 41 || markdownLineEndingOrSpace(code))) {
18041 effects.exit("chunkString");
18042 effects.exit(stringType);
18043 effects.exit(rawType);
18044 effects.exit(type);
18045 return ok(code);
18046 }
18047 if (balance < limit && code === 40) {
18048 effects.consume(code);
18049 balance++;
18050 return raw;
18051 }
18052 if (code === 41) {
18053 effects.consume(code);
18054 balance--;
18055 return raw;
18056 }
18057 if (code === null || code === 32 || code === 40 || asciiControl(code)) return nok(code);
18058 effects.consume(code);
18059 return code === 92 ? rawEscape : raw;
18060 }
18061 /**
18062 * After `\`, at special character.
18063 *
18064 * ```markdown
18065 * > | a\*a
18066 * ^
18067 * ```
18068 *
18069 * @type {State}
18070 */
18071 function rawEscape(code) {
18072 if (code === 40 || code === 41 || code === 92) {
18073 effects.consume(code);
18074 return raw;
18075 }
18076 return raw(code);
18077 }
18078 }
18079 var init_micromark_factory_destination = __esmMin((() => {
18080 init_micromark_util_character();
18081 }));
18082
18083 //#endregion
18084 //#region node_modules/micromark-factory-label/index.js
18085 /**
18086 * Parse labels.
18087 *
18088 * > 👉 **Note**: labels in markdown are capped at 999 characters in the string.
18089 *
18090 * ###### Examples
18091 *
18092 * ```markdown
18093 * [a]
18094 * [a
18095 * b]
18096 * [a\]b]
18097 * ```
18098 *
18099 * @this {TokenizeContext}
18100 * Tokenize context.
18101 * @param {Effects} effects
18102 * Context.
18103 * @param {State} ok
18104 * State switched to when successful.
18105 * @param {State} nok
18106 * State switched to when unsuccessful.
18107 * @param {TokenType} type
18108 * Type of the whole label (`[a]`).
18109 * @param {TokenType} markerType
18110 * Type for the markers (`[` and `]`).
18111 * @param {TokenType} stringType
18112 * Type for the identifier (`a`).
18113 * @returns {State}
18114 * Start state.
18115 */ function factoryLabel(effects, ok, nok, type, markerType, stringType) {
18116 const self = this;
18117 let size = 0;
18118 /** @type {boolean} */
18119 let seen;
18120 return start;
18121 /**
18122 * Start of label.
18123 *
18124 * ```markdown
18125 * > | [a]
18126 * ^
18127 * ```
18128 *
18129 * @type {State}
18130 */
18131 function start(code) {
18132 effects.enter(type);
18133 effects.enter(markerType);
18134 effects.consume(code);
18135 effects.exit(markerType);
18136 effects.enter(stringType);
18137 return atBreak;
18138 }
18139 /**
18140 * In label, at something, before something else.
18141 *
18142 * ```markdown
18143 * > | [a]
18144 * ^
18145 * ```
18146 *
18147 * @type {State}
18148 */
18149 function atBreak(code) {
18150 if (size > 999 || code === null || code === 91 || code === 93 && !seen || code === 94 && !size && "_hiddenFootnoteSupport" in self.parser.constructs) return nok(code);
18151 if (code === 93) {
18152 effects.exit(stringType);
18153 effects.enter(markerType);
18154 effects.consume(code);
18155 effects.exit(markerType);
18156 effects.exit(type);
18157 return ok;
18158 }
18159 if (markdownLineEnding(code)) {
18160 effects.enter("lineEnding");
18161 effects.consume(code);
18162 effects.exit("lineEnding");
18163 return atBreak;
18164 }
18165 effects.enter("chunkString", { contentType: "string" });
18166 return labelInside(code);
18167 }
18168 /**
18169 * In label, in text.
18170 *
18171 * ```markdown
18172 * > | [a]
18173 * ^
18174 * ```
18175 *
18176 * @type {State}
18177 */
18178 function labelInside(code) {
18179 if (code === null || code === 91 || code === 93 || markdownLineEnding(code) || size++ > 999) {
18180 effects.exit("chunkString");
18181 return atBreak(code);
18182 }
18183 effects.consume(code);
18184 if (!seen) seen = !markdownSpace(code);
18185 return code === 92 ? labelEscape : labelInside;
18186 }
18187 /**
18188 * After `\`, at a special character.
18189 *
18190 * ```markdown
18191 * > | [a\*a]
18192 * ^
18193 * ```
18194 *
18195 * @type {State}
18196 */
18197 function labelEscape(code) {
18198 if (code === 91 || code === 92 || code === 93) {
18199 effects.consume(code);
18200 size++;
18201 return labelInside;
18202 }
18203 return labelInside(code);
18204 }
18205 }
18206 var init_micromark_factory_label = __esmMin((() => {
18207 init_micromark_util_character();
18208 }));
18209
18210 //#endregion
18211 //#region node_modules/micromark-factory-title/index.js
18212 /**
18213 * Parse titles.
18214 *
18215 * ###### Examples
18216 *
18217 * ```markdown
18218 * "a"
18219 * 'b'
18220 * (c)
18221 * "a
18222 * b"
18223 * 'a
18224 * b'
18225 * (a\)b)
18226 * ```
18227 *
18228 * @param {Effects} effects
18229 * Context.
18230 * @param {State} ok
18231 * State switched to when successful.
18232 * @param {State} nok
18233 * State switched to when unsuccessful.
18234 * @param {TokenType} type
18235 * Type of the whole title (`"a"`, `'b'`, `(c)`).
18236 * @param {TokenType} markerType
18237 * Type for the markers (`"`, `'`, `(`, and `)`).
18238 * @param {TokenType} stringType
18239 * Type for the value (`a`).
18240 * @returns {State}
18241 * Start state.
18242 */ function factoryTitle(effects, ok, nok, type, markerType, stringType) {
18243 /** @type {NonNullable<Code>} */
18244 let marker;
18245 return start;
18246 /**
18247 * Start of title.
18248 *
18249 * ```markdown
18250 * > | "a"
18251 * ^
18252 * ```
18253 *
18254 * @type {State}
18255 */
18256 function start(code) {
18257 if (code === 34 || code === 39 || code === 40) {
18258 effects.enter(type);
18259 effects.enter(markerType);
18260 effects.consume(code);
18261 effects.exit(markerType);
18262 marker = code === 40 ? 41 : code;
18263 return begin;
18264 }
18265 return nok(code);
18266 }
18267 /**
18268 * After opening marker.
18269 *
18270 * This is also used at the closing marker.
18271 *
18272 * ```markdown
18273 * > | "a"
18274 * ^
18275 * ```
18276 *
18277 * @type {State}
18278 */
18279 function begin(code) {
18280 if (code === marker) {
18281 effects.enter(markerType);
18282 effects.consume(code);
18283 effects.exit(markerType);
18284 effects.exit(type);
18285 return ok;
18286 }
18287 effects.enter(stringType);
18288 return atBreak(code);
18289 }
18290 /**
18291 * At something, before something else.
18292 *
18293 * ```markdown
18294 * > | "a"
18295 * ^
18296 * ```
18297 *
18298 * @type {State}
18299 */
18300 function atBreak(code) {
18301 if (code === marker) {
18302 effects.exit(stringType);
18303 return begin(marker);
18304 }
18305 if (code === null) return nok(code);
18306 if (markdownLineEnding(code)) {
18307 effects.enter("lineEnding");
18308 effects.consume(code);
18309 effects.exit("lineEnding");
18310 return factorySpace(effects, atBreak, "linePrefix");
18311 }
18312 effects.enter("chunkString", { contentType: "string" });
18313 return inside(code);
18314 }
18315 /**
18316 *
18317 *
18318 * @type {State}
18319 */
18320 function inside(code) {
18321 if (code === marker || code === null || markdownLineEnding(code)) {
18322 effects.exit("chunkString");
18323 return atBreak(code);
18324 }
18325 effects.consume(code);
18326 return code === 92 ? escape : inside;
18327 }
18328 /**
18329 * After `\`, at a special character.
18330 *
18331 * ```markdown
18332 * > | "a\*b"
18333 * ^
18334 * ```
18335 *
18336 * @type {State}
18337 */
18338 function escape(code) {
18339 if (code === marker || code === 92) {
18340 effects.consume(code);
18341 return inside;
18342 }
18343 return inside(code);
18344 }
18345 }
18346 var init_micromark_factory_title = __esmMin((() => {
18347 init_micromark_factory_space();
18348 init_micromark_util_character();
18349 }));
18350
18351 //#endregion
18352 //#region node_modules/micromark-factory-whitespace/index.js
18353 /**
18354 * Parse spaces and tabs.
18355 *
18356 * There is no `nok` parameter:
18357 *
18358 * * line endings or spaces in markdown are often optional, in which case this
18359 * factory can be used and `ok` will be switched to whether spaces were found
18360 * or not
18361 * * one line ending or space can be detected with
18362 * `markdownLineEndingOrSpace(code)` right before using `factoryWhitespace`
18363 *
18364 * @param {Effects} effects
18365 * Context.
18366 * @param {State} ok
18367 * State switched to when successful.
18368 * @returns
18369 * Start state.
18370 */
18371 function factoryWhitespace(effects, ok) {
18372 /** @type {boolean} */
18373 let seen;
18374 return start;
18375 /** @type {State} */
18376 function start(code) {
18377 if (markdownLineEnding(code)) {
18378 effects.enter("lineEnding");
18379 effects.consume(code);
18380 effects.exit("lineEnding");
18381 seen = true;
18382 return start;
18383 }
18384 if (markdownSpace(code)) return factorySpace(effects, start, seen ? "linePrefix" : "lineSuffix")(code);
18385 return ok(code);
18386 }
18387 }
18388 var init_micromark_factory_whitespace = __esmMin((() => {
18389 init_micromark_factory_space();
18390 init_micromark_util_character();
18391 }));
18392
18393 //#endregion
18394 //#region node_modules/micromark-util-normalize-identifier/index.js
18395 /**
18396 * Normalize an identifier (as found in references, definitions).
18397 *
18398 * Collapses markdown whitespace, trim, and then lower- and uppercase.
18399 *
18400 * Some characters are considered “uppercase”, such as U+03F4 (`ϴ`), but if their
18401 * lowercase counterpart (U+03B8 (`θ`)) is uppercased will result in a different
18402 * uppercase character (U+0398 (`Θ`)).
18403 * So, to get a canonical form, we perform both lower- and uppercase.
18404 *
18405 * Using uppercase last makes sure keys will never interact with default
18406 * prototypal values (such as `constructor`): nothing in the prototype of
18407 * `Object` is uppercase.
18408 *
18409 * @param {string} value
18410 * Identifier to normalize.
18411 * @returns {string}
18412 * Normalized identifier.
18413 */
18414 function normalizeIdentifier(value) {
18415 return value.replace(/[\t\n\r ]+/g, " ").replace(/^ | $/g, "").toLowerCase().toUpperCase();
18416 }
18417 var init_micromark_util_normalize_identifier = __esmMin((() => {}));
18418
18419 //#endregion
18420 //#region node_modules/micromark-core-commonmark/lib/definition.js
18421 /**
18422 * @this {TokenizeContext}
18423 * @type {Tokenizer}
18424 */
18425 function tokenizeDefinition(effects, ok, nok) {
18426 const self = this;
18427 /** @type {string} */
18428 let identifier;
18429 return start;
18430 /**
18431 * At start of a definition.
18432 *
18433 * ```markdown
18434 * > | [a]: b "c"
18435 * ^
18436 * ```
18437 *
18438 * @type {State}
18439 */
18440 function start(code) {
18441 effects.enter("definition");
18442 return before(code);
18443 }
18444 /**
18445 * After optional whitespace, at `[`.
18446 *
18447 * ```markdown
18448 * > | [a]: b "c"
18449 * ^
18450 * ```
18451 *
18452 * @type {State}
18453 */
18454 function before(code) {
18455 return factoryLabel.call(self, effects, labelAfter, nok, "definitionLabel", "definitionLabelMarker", "definitionLabelString")(code);
18456 }
18457 /**
18458 * After label.
18459 *
18460 * ```markdown
18461 * > | [a]: b "c"
18462 * ^
18463 * ```
18464 *
18465 * @type {State}
18466 */
18467 function labelAfter(code) {
18468 identifier = normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1));
18469 if (code === 58) {
18470 effects.enter("definitionMarker");
18471 effects.consume(code);
18472 effects.exit("definitionMarker");
18473 return markerAfter;
18474 }
18475 return nok(code);
18476 }
18477 /**
18478 * After marker.
18479 *
18480 * ```markdown
18481 * > | [a]: b "c"
18482 * ^
18483 * ```
18484 *
18485 * @type {State}
18486 */
18487 function markerAfter(code) {
18488 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, destinationBefore)(code) : destinationBefore(code);
18489 }
18490 /**
18491 * Before destination.
18492 *
18493 * ```markdown
18494 * > | [a]: b "c"
18495 * ^
18496 * ```
18497 *
18498 * @type {State}
18499 */
18500 function destinationBefore(code) {
18501 return factoryDestination(effects, destinationAfter, nok, "definitionDestination", "definitionDestinationLiteral", "definitionDestinationLiteralMarker", "definitionDestinationRaw", "definitionDestinationString")(code);
18502 }
18503 /**
18504 * After destination.
18505 *
18506 * ```markdown
18507 * > | [a]: b "c"
18508 * ^
18509 * ```
18510 *
18511 * @type {State}
18512 */
18513 function destinationAfter(code) {
18514 return effects.attempt(titleBefore, after, after)(code);
18515 }
18516 /**
18517 * After definition.
18518 *
18519 * ```markdown
18520 * > | [a]: b
18521 * ^
18522 * > | [a]: b "c"
18523 * ^
18524 * ```
18525 *
18526 * @type {State}
18527 */
18528 function after(code) {
18529 return markdownSpace(code) ? factorySpace(effects, afterWhitespace, "whitespace")(code) : afterWhitespace(code);
18530 }
18531 /**
18532 * After definition, after optional whitespace.
18533 *
18534 * ```markdown
18535 * > | [a]: b
18536 * ^
18537 * > | [a]: b "c"
18538 * ^
18539 * ```
18540 *
18541 * @type {State}
18542 */
18543 function afterWhitespace(code) {
18544 if (code === null || markdownLineEnding(code)) {
18545 effects.exit("definition");
18546 self.parser.defined.push(identifier);
18547 return ok(code);
18548 }
18549 return nok(code);
18550 }
18551 }
18552 /**
18553 * @this {TokenizeContext}
18554 * @type {Tokenizer}
18555 */
18556 function tokenizeTitleBefore(effects, ok, nok) {
18557 return titleBefore;
18558 /**
18559 * After destination, at whitespace.
18560 *
18561 * ```markdown
18562 * > | [a]: b
18563 * ^
18564 * > | [a]: b "c"
18565 * ^
18566 * ```
18567 *
18568 * @type {State}
18569 */
18570 function titleBefore(code) {
18571 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, beforeMarker)(code) : nok(code);
18572 }
18573 /**
18574 * At title.
18575 *
18576 * ```markdown
18577 * | [a]: b
18578 * > | "c"
18579 * ^
18580 * ```
18581 *
18582 * @type {State}
18583 */
18584 function beforeMarker(code) {
18585 return factoryTitle(effects, titleAfter, nok, "definitionTitle", "definitionTitleMarker", "definitionTitleString")(code);
18586 }
18587 /**
18588 * After title.
18589 *
18590 * ```markdown
18591 * > | [a]: b "c"
18592 * ^
18593 * ```
18594 *
18595 * @type {State}
18596 */
18597 function titleAfter(code) {
18598 return markdownSpace(code) ? factorySpace(effects, titleAfterOptionalWhitespace, "whitespace")(code) : titleAfterOptionalWhitespace(code);
18599 }
18600 /**
18601 * After title, after optional whitespace.
18602 *
18603 * ```markdown
18604 * > | [a]: b "c"
18605 * ^
18606 * ```
18607 *
18608 * @type {State}
18609 */
18610 function titleAfterOptionalWhitespace(code) {
18611 return code === null || markdownLineEnding(code) ? ok(code) : nok(code);
18612 }
18613 }
18614 var definition, titleBefore;
18615 var init_definition = __esmMin((() => {
18616 init_micromark_factory_destination();
18617 init_micromark_factory_label();
18618 init_micromark_factory_space();
18619 init_micromark_factory_title();
18620 init_micromark_factory_whitespace();
18621 init_micromark_util_character();
18622 init_micromark_util_normalize_identifier();
18623 definition = {
18624 name: "definition",
18625 tokenize: tokenizeDefinition
18626 };
18627 titleBefore = {
18628 tokenize: tokenizeTitleBefore,
18629 partial: true
18630 };
18631 }));
18632
18633 //#endregion
18634 //#region node_modules/micromark-core-commonmark/lib/hard-break-escape.js
18635 /**
18636 * @this {TokenizeContext}
18637 * @type {Tokenizer}
18638 */
18639 function tokenizeHardBreakEscape(effects, ok, nok) {
18640 return start;
18641 /**
18642 * Start of a hard break (escape).
18643 *
18644 * ```markdown
18645 * > | a\
18646 * ^
18647 * | b
18648 * ```
18649 *
18650 * @type {State}
18651 */
18652 function start(code) {
18653 effects.enter("hardBreakEscape");
18654 effects.consume(code);
18655 return after;
18656 }
18657 /**
18658 * After `\`, at eol.
18659 *
18660 * ```markdown
18661 * > | a\
18662 * ^
18663 * | b
18664 * ```
18665 *
18666 * @type {State}
18667 */
18668 function after(code) {
18669 if (markdownLineEnding(code)) {
18670 effects.exit("hardBreakEscape");
18671 return ok(code);
18672 }
18673 return nok(code);
18674 }
18675 }
18676 var hardBreakEscape;
18677 var init_hard_break_escape = __esmMin((() => {
18678 init_micromark_util_character();
18679 hardBreakEscape = {
18680 name: "hardBreakEscape",
18681 tokenize: tokenizeHardBreakEscape
18682 };
18683 }));
18684
18685 //#endregion
18686 //#region node_modules/micromark-core-commonmark/lib/heading-atx.js
18687 /** @type {Resolver} */
18688 function resolveHeadingAtx(events, context) {
18689 let contentEnd = events.length - 2;
18690 let contentStart = 3;
18691 /** @type {Token} */
18692 let content;
18693 /** @type {Token} */
18694 let text;
18695 if (events[contentStart][1].type === "whitespace") contentStart += 2;
18696 if (contentEnd - 2 > contentStart && events[contentEnd][1].type === "whitespace") contentEnd -= 2;
18697 if (events[contentEnd][1].type === "atxHeadingSequence" && (contentStart === contentEnd - 1 || contentEnd - 4 > contentStart && events[contentEnd - 2][1].type === "whitespace")) contentEnd -= contentStart + 1 === contentEnd ? 2 : 4;
18698 if (contentEnd > contentStart) {
18699 content = {
18700 type: "atxHeadingText",
18701 start: events[contentStart][1].start,
18702 end: events[contentEnd][1].end
18703 };
18704 text = {
18705 type: "chunkText",
18706 start: events[contentStart][1].start,
18707 end: events[contentEnd][1].end,
18708 contentType: "text"
18709 };
18710 splice(events, contentStart, contentEnd - contentStart + 1, [
18711 [
18712 "enter",
18713 content,
18714 context
18715 ],
18716 [
18717 "enter",
18718 text,
18719 context
18720 ],
18721 [
18722 "exit",
18723 text,
18724 context
18725 ],
18726 [
18727 "exit",
18728 content,
18729 context
18730 ]
18731 ]);
18732 }
18733 return events;
18734 }
18735 /**
18736 * @this {TokenizeContext}
18737 * @type {Tokenizer}
18738 */
18739 function tokenizeHeadingAtx(effects, ok, nok) {
18740 let size = 0;
18741 return start;
18742 /**
18743 * Start of a heading (atx).
18744 *
18745 * ```markdown
18746 * > | ## aa
18747 * ^
18748 * ```
18749 *
18750 * @type {State}
18751 */
18752 function start(code) {
18753 effects.enter("atxHeading");
18754 return before(code);
18755 }
18756 /**
18757 * After optional whitespace, at `#`.
18758 *
18759 * ```markdown
18760 * > | ## aa
18761 * ^
18762 * ```
18763 *
18764 * @type {State}
18765 */
18766 function before(code) {
18767 effects.enter("atxHeadingSequence");
18768 return sequenceOpen(code);
18769 }
18770 /**
18771 * In opening sequence.
18772 *
18773 * ```markdown
18774 * > | ## aa
18775 * ^
18776 * ```
18777 *
18778 * @type {State}
18779 */
18780 function sequenceOpen(code) {
18781 if (code === 35 && size++ < 6) {
18782 effects.consume(code);
18783 return sequenceOpen;
18784 }
18785 if (code === null || markdownLineEndingOrSpace(code)) {
18786 effects.exit("atxHeadingSequence");
18787 return atBreak(code);
18788 }
18789 return nok(code);
18790 }
18791 /**
18792 * After something, before something else.
18793 *
18794 * ```markdown
18795 * > | ## aa
18796 * ^
18797 * ```
18798 *
18799 * @type {State}
18800 */
18801 function atBreak(code) {
18802 if (code === 35) {
18803 effects.enter("atxHeadingSequence");
18804 return sequenceFurther(code);
18805 }
18806 if (code === null || markdownLineEnding(code)) {
18807 effects.exit("atxHeading");
18808 return ok(code);
18809 }
18810 if (markdownSpace(code)) return factorySpace(effects, atBreak, "whitespace")(code);
18811 effects.enter("atxHeadingText");
18812 return data(code);
18813 }
18814 /**
18815 * In further sequence (after whitespace).
18816 *
18817 * Could be normal “visible” hashes in the heading or a final sequence.
18818 *
18819 * ```markdown
18820 * > | ## aa ##
18821 * ^
18822 * ```
18823 *
18824 * @type {State}
18825 */
18826 function sequenceFurther(code) {
18827 if (code === 35) {
18828 effects.consume(code);
18829 return sequenceFurther;
18830 }
18831 effects.exit("atxHeadingSequence");
18832 return atBreak(code);
18833 }
18834 /**
18835 * In text.
18836 *
18837 * ```markdown
18838 * > | ## aa
18839 * ^
18840 * ```
18841 *
18842 * @type {State}
18843 */
18844 function data(code) {
18845 if (code === null || code === 35 || markdownLineEndingOrSpace(code)) {
18846 effects.exit("atxHeadingText");
18847 return atBreak(code);
18848 }
18849 effects.consume(code);
18850 return data;
18851 }
18852 }
18853 var headingAtx;
18854 var init_heading_atx = __esmMin((() => {
18855 init_micromark_factory_space();
18856 init_micromark_util_character();
18857 init_micromark_util_chunked();
18858 headingAtx = {
18859 name: "headingAtx",
18860 tokenize: tokenizeHeadingAtx,
18861 resolve: resolveHeadingAtx
18862 };
18863 }));
18864
18865 //#endregion
18866 //#region node_modules/micromark-util-html-tag-name/index.js
18867 var htmlBlockNames, htmlRawNames;
18868 var init_micromark_util_html_tag_name = __esmMin((() => {
18869 htmlBlockNames = [
18870 "address",
18871 "article",
18872 "aside",
18873 "base",
18874 "basefont",
18875 "blockquote",
18876 "body",
18877 "caption",
18878 "center",
18879 "col",
18880 "colgroup",
18881 "dd",
18882 "details",
18883 "dialog",
18884 "dir",
18885 "div",
18886 "dl",
18887 "dt",
18888 "fieldset",
18889 "figcaption",
18890 "figure",
18891 "footer",
18892 "form",
18893 "frame",
18894 "frameset",
18895 "h1",
18896 "h2",
18897 "h3",
18898 "h4",
18899 "h5",
18900 "h6",
18901 "head",
18902 "header",
18903 "hr",
18904 "html",
18905 "iframe",
18906 "legend",
18907 "li",
18908 "link",
18909 "main",
18910 "menu",
18911 "menuitem",
18912 "nav",
18913 "noframes",
18914 "ol",
18915 "optgroup",
18916 "option",
18917 "p",
18918 "param",
18919 "search",
18920 "section",
18921 "summary",
18922 "table",
18923 "tbody",
18924 "td",
18925 "tfoot",
18926 "th",
18927 "thead",
18928 "title",
18929 "tr",
18930 "track",
18931 "ul"
18932 ];
18933 htmlRawNames = [
18934 "pre",
18935 "script",
18936 "style",
18937 "textarea"
18938 ];
18939 }));
18940
18941 //#endregion
18942 //#region node_modules/micromark-core-commonmark/lib/html-flow.js
18943 /** @type {Resolver} */
18944 function resolveToHtmlFlow(events) {
18945 let index = events.length;
18946 while (index--) if (events[index][0] === "enter" && events[index][1].type === "htmlFlow") break;
18947 if (index > 1 && events[index - 2][1].type === "linePrefix") {
18948 events[index][1].start = events[index - 2][1].start;
18949 events[index + 1][1].start = events[index - 2][1].start;
18950 events.splice(index - 2, 2);
18951 }
18952 return events;
18953 }
18954 /**
18955 * @this {TokenizeContext}
18956 * @type {Tokenizer}
18957 */
18958 function tokenizeHtmlFlow(effects, ok, nok) {
18959 const self = this;
18960 /** @type {number} */
18961 let marker;
18962 /** @type {boolean} */
18963 let closingTag;
18964 /** @type {string} */
18965 let buffer;
18966 /** @type {number} */
18967 let index;
18968 /** @type {Code} */
18969 let markerB;
18970 return start;
18971 /**
18972 * Start of HTML (flow).
18973 *
18974 * ```markdown
18975 * > | <x />
18976 * ^
18977 * ```
18978 *
18979 * @type {State}
18980 */
18981 function start(code) {
18982 return before(code);
18983 }
18984 /**
18985 * At `<`, after optional whitespace.
18986 *
18987 * ```markdown
18988 * > | <x />
18989 * ^
18990 * ```
18991 *
18992 * @type {State}
18993 */
18994 function before(code) {
18995 effects.enter("htmlFlow");
18996 effects.enter("htmlFlowData");
18997 effects.consume(code);
18998 return open;
18999 }
19000 /**
19001 * After `<`, at tag name or other stuff.
19002 *
19003 * ```markdown
19004 * > | <x />
19005 * ^
19006 * > | <!doctype>
19007 * ^
19008 * > | <!--xxx-->
19009 * ^
19010 * ```
19011 *
19012 * @type {State}
19013 */
19014 function open(code) {
19015 if (code === 33) {
19016 effects.consume(code);
19017 return declarationOpen;
19018 }
19019 if (code === 47) {
19020 effects.consume(code);
19021 closingTag = true;
19022 return tagCloseStart;
19023 }
19024 if (code === 63) {
19025 effects.consume(code);
19026 marker = 3;
19027 return self.interrupt ? ok : continuationDeclarationInside;
19028 }
19029 if (asciiAlpha(code)) {
19030 effects.consume(code);
19031 buffer = String.fromCharCode(code);
19032 return tagName;
19033 }
19034 return nok(code);
19035 }
19036 /**
19037 * After `<!`, at declaration, comment, or CDATA.
19038 *
19039 * ```markdown
19040 * > | <!doctype>
19041 * ^
19042 * > | <!--xxx-->
19043 * ^
19044 * > | <![CDATA[>&<]]>
19045 * ^
19046 * ```
19047 *
19048 * @type {State}
19049 */
19050 function declarationOpen(code) {
19051 if (code === 45) {
19052 effects.consume(code);
19053 marker = 2;
19054 return commentOpenInside;
19055 }
19056 if (code === 91) {
19057 effects.consume(code);
19058 marker = 5;
19059 index = 0;
19060 return cdataOpenInside;
19061 }
19062 if (asciiAlpha(code)) {
19063 effects.consume(code);
19064 marker = 4;
19065 return self.interrupt ? ok : continuationDeclarationInside;
19066 }
19067 return nok(code);
19068 }
19069 /**
19070 * After `<!-`, inside a comment, at another `-`.
19071 *
19072 * ```markdown
19073 * > | <!--xxx-->
19074 * ^
19075 * ```
19076 *
19077 * @type {State}
19078 */
19079 function commentOpenInside(code) {
19080 if (code === 45) {
19081 effects.consume(code);
19082 return self.interrupt ? ok : continuationDeclarationInside;
19083 }
19084 return nok(code);
19085 }
19086 /**
19087 * After `<![`, inside CDATA, expecting `CDATA[`.
19088 *
19089 * ```markdown
19090 * > | <![CDATA[>&<]]>
19091 * ^^^^^^
19092 * ```
19093 *
19094 * @type {State}
19095 */
19096 function cdataOpenInside(code) {
19097 if (code === "CDATA[".charCodeAt(index++)) {
19098 effects.consume(code);
19099 if (index === 6) return self.interrupt ? ok : continuation;
19100 return cdataOpenInside;
19101 }
19102 return nok(code);
19103 }
19104 /**
19105 * After `</`, in closing tag, at tag name.
19106 *
19107 * ```markdown
19108 * > | </x>
19109 * ^
19110 * ```
19111 *
19112 * @type {State}
19113 */
19114 function tagCloseStart(code) {
19115 if (asciiAlpha(code)) {
19116 effects.consume(code);
19117 buffer = String.fromCharCode(code);
19118 return tagName;
19119 }
19120 return nok(code);
19121 }
19122 /**
19123 * In tag name.
19124 *
19125 * ```markdown
19126 * > | <ab>
19127 * ^^
19128 * > | </ab>
19129 * ^^
19130 * ```
19131 *
19132 * @type {State}
19133 */
19134 function tagName(code) {
19135 if (code === null || code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
19136 const slash = code === 47;
19137 const name = buffer.toLowerCase();
19138 if (!slash && !closingTag && htmlRawNames.includes(name)) {
19139 marker = 1;
19140 return self.interrupt ? ok(code) : continuation(code);
19141 }
19142 if (htmlBlockNames.includes(buffer.toLowerCase())) {
19143 marker = 6;
19144 if (slash) {
19145 effects.consume(code);
19146 return basicSelfClosing;
19147 }
19148 return self.interrupt ? ok(code) : continuation(code);
19149 }
19150 marker = 7;
19151 return self.interrupt && !self.parser.lazy[self.now().line] ? nok(code) : closingTag ? completeClosingTagAfter(code) : completeAttributeNameBefore(code);
19152 }
19153 if (code === 45 || asciiAlphanumeric(code)) {
19154 effects.consume(code);
19155 buffer += String.fromCharCode(code);
19156 return tagName;
19157 }
19158 return nok(code);
19159 }
19160 /**
19161 * After closing slash of a basic tag name.
19162 *
19163 * ```markdown
19164 * > | <div/>
19165 * ^
19166 * ```
19167 *
19168 * @type {State}
19169 */
19170 function basicSelfClosing(code) {
19171 if (code === 62) {
19172 effects.consume(code);
19173 return self.interrupt ? ok : continuation;
19174 }
19175 return nok(code);
19176 }
19177 /**
19178 * After closing slash of a complete tag name.
19179 *
19180 * ```markdown
19181 * > | <x/>
19182 * ^
19183 * ```
19184 *
19185 * @type {State}
19186 */
19187 function completeClosingTagAfter(code) {
19188 if (markdownSpace(code)) {
19189 effects.consume(code);
19190 return completeClosingTagAfter;
19191 }
19192 return completeEnd(code);
19193 }
19194 /**
19195 * At an attribute name.
19196 *
19197 * At first, this state is used after a complete tag name, after whitespace,
19198 * where it expects optional attributes or the end of the tag.
19199 * It is also reused after attributes, when expecting more optional
19200 * attributes.
19201 *
19202 * ```markdown
19203 * > | <a />
19204 * ^
19205 * > | <a :b>
19206 * ^
19207 * > | <a _b>
19208 * ^
19209 * > | <a b>
19210 * ^
19211 * > | <a >
19212 * ^
19213 * ```
19214 *
19215 * @type {State}
19216 */
19217 function completeAttributeNameBefore(code) {
19218 if (code === 47) {
19219 effects.consume(code);
19220 return completeEnd;
19221 }
19222 if (code === 58 || code === 95 || asciiAlpha(code)) {
19223 effects.consume(code);
19224 return completeAttributeName;
19225 }
19226 if (markdownSpace(code)) {
19227 effects.consume(code);
19228 return completeAttributeNameBefore;
19229 }
19230 return completeEnd(code);
19231 }
19232 /**
19233 * In attribute name.
19234 *
19235 * ```markdown
19236 * > | <a :b>
19237 * ^
19238 * > | <a _b>
19239 * ^
19240 * > | <a b>
19241 * ^
19242 * ```
19243 *
19244 * @type {State}
19245 */
19246 function completeAttributeName(code) {
19247 if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) {
19248 effects.consume(code);
19249 return completeAttributeName;
19250 }
19251 return completeAttributeNameAfter(code);
19252 }
19253 /**
19254 * After attribute name, at an optional initializer, the end of the tag, or
19255 * whitespace.
19256 *
19257 * ```markdown
19258 * > | <a b>
19259 * ^
19260 * > | <a b=c>
19261 * ^
19262 * ```
19263 *
19264 * @type {State}
19265 */
19266 function completeAttributeNameAfter(code) {
19267 if (code === 61) {
19268 effects.consume(code);
19269 return completeAttributeValueBefore;
19270 }
19271 if (markdownSpace(code)) {
19272 effects.consume(code);
19273 return completeAttributeNameAfter;
19274 }
19275 return completeAttributeNameBefore(code);
19276 }
19277 /**
19278 * Before unquoted, double quoted, or single quoted attribute value, allowing
19279 * whitespace.
19280 *
19281 * ```markdown
19282 * > | <a b=c>
19283 * ^
19284 * > | <a b="c">
19285 * ^
19286 * ```
19287 *
19288 * @type {State}
19289 */
19290 function completeAttributeValueBefore(code) {
19291 if (code === null || code === 60 || code === 61 || code === 62 || code === 96) return nok(code);
19292 if (code === 34 || code === 39) {
19293 effects.consume(code);
19294 markerB = code;
19295 return completeAttributeValueQuoted;
19296 }
19297 if (markdownSpace(code)) {
19298 effects.consume(code);
19299 return completeAttributeValueBefore;
19300 }
19301 return completeAttributeValueUnquoted(code);
19302 }
19303 /**
19304 * In double or single quoted attribute value.
19305 *
19306 * ```markdown
19307 * > | <a b="c">
19308 * ^
19309 * > | <a b='c'>
19310 * ^
19311 * ```
19312 *
19313 * @type {State}
19314 */
19315 function completeAttributeValueQuoted(code) {
19316 if (code === markerB) {
19317 effects.consume(code);
19318 markerB = null;
19319 return completeAttributeValueQuotedAfter;
19320 }
19321 if (code === null || markdownLineEnding(code)) return nok(code);
19322 effects.consume(code);
19323 return completeAttributeValueQuoted;
19324 }
19325 /**
19326 * In unquoted attribute value.
19327 *
19328 * ```markdown
19329 * > | <a b=c>
19330 * ^
19331 * ```
19332 *
19333 * @type {State}
19334 */
19335 function completeAttributeValueUnquoted(code) {
19336 if (code === null || code === 34 || code === 39 || code === 47 || code === 60 || code === 61 || code === 62 || code === 96 || markdownLineEndingOrSpace(code)) return completeAttributeNameAfter(code);
19337 effects.consume(code);
19338 return completeAttributeValueUnquoted;
19339 }
19340 /**
19341 * After double or single quoted attribute value, before whitespace or the
19342 * end of the tag.
19343 *
19344 * ```markdown
19345 * > | <a b="c">
19346 * ^
19347 * ```
19348 *
19349 * @type {State}
19350 */
19351 function completeAttributeValueQuotedAfter(code) {
19352 if (code === 47 || code === 62 || markdownSpace(code)) return completeAttributeNameBefore(code);
19353 return nok(code);
19354 }
19355 /**
19356 * In certain circumstances of a complete tag where only an `>` is allowed.
19357 *
19358 * ```markdown
19359 * > | <a b="c">
19360 * ^
19361 * ```
19362 *
19363 * @type {State}
19364 */
19365 function completeEnd(code) {
19366 if (code === 62) {
19367 effects.consume(code);
19368 return completeAfter;
19369 }
19370 return nok(code);
19371 }
19372 /**
19373 * After `>` in a complete tag.
19374 *
19375 * ```markdown
19376 * > | <x>
19377 * ^
19378 * ```
19379 *
19380 * @type {State}
19381 */
19382 function completeAfter(code) {
19383 if (code === null || markdownLineEnding(code)) return continuation(code);
19384 if (markdownSpace(code)) {
19385 effects.consume(code);
19386 return completeAfter;
19387 }
19388 return nok(code);
19389 }
19390 /**
19391 * In continuation of any HTML kind.
19392 *
19393 * ```markdown
19394 * > | <!--xxx-->
19395 * ^
19396 * ```
19397 *
19398 * @type {State}
19399 */
19400 function continuation(code) {
19401 if (code === 45 && marker === 2) {
19402 effects.consume(code);
19403 return continuationCommentInside;
19404 }
19405 if (code === 60 && marker === 1) {
19406 effects.consume(code);
19407 return continuationRawTagOpen;
19408 }
19409 if (code === 62 && marker === 4) {
19410 effects.consume(code);
19411 return continuationClose;
19412 }
19413 if (code === 63 && marker === 3) {
19414 effects.consume(code);
19415 return continuationDeclarationInside;
19416 }
19417 if (code === 93 && marker === 5) {
19418 effects.consume(code);
19419 return continuationCdataInside;
19420 }
19421 if (markdownLineEnding(code) && (marker === 6 || marker === 7)) {
19422 effects.exit("htmlFlowData");
19423 return effects.check(blankLineBefore, continuationAfter, continuationStart)(code);
19424 }
19425 if (code === null || markdownLineEnding(code)) {
19426 effects.exit("htmlFlowData");
19427 return continuationStart(code);
19428 }
19429 effects.consume(code);
19430 return continuation;
19431 }
19432 /**
19433 * In continuation, at eol.
19434 *
19435 * ```markdown
19436 * > | <x>
19437 * ^
19438 * | asd
19439 * ```
19440 *
19441 * @type {State}
19442 */
19443 function continuationStart(code) {
19444 return effects.check(nonLazyContinuationStart, continuationStartNonLazy, continuationAfter)(code);
19445 }
19446 /**
19447 * In continuation, at eol, before non-lazy content.
19448 *
19449 * ```markdown
19450 * > | <x>
19451 * ^
19452 * | asd
19453 * ```
19454 *
19455 * @type {State}
19456 */
19457 function continuationStartNonLazy(code) {
19458 effects.enter("lineEnding");
19459 effects.consume(code);
19460 effects.exit("lineEnding");
19461 return continuationBefore;
19462 }
19463 /**
19464 * In continuation, before non-lazy content.
19465 *
19466 * ```markdown
19467 * | <x>
19468 * > | asd
19469 * ^
19470 * ```
19471 *
19472 * @type {State}
19473 */
19474 function continuationBefore(code) {
19475 if (code === null || markdownLineEnding(code)) return continuationStart(code);
19476 effects.enter("htmlFlowData");
19477 return continuation(code);
19478 }
19479 /**
19480 * In comment continuation, after one `-`, expecting another.
19481 *
19482 * ```markdown
19483 * > | <!--xxx-->
19484 * ^
19485 * ```
19486 *
19487 * @type {State}
19488 */
19489 function continuationCommentInside(code) {
19490 if (code === 45) {
19491 effects.consume(code);
19492 return continuationDeclarationInside;
19493 }
19494 return continuation(code);
19495 }
19496 /**
19497 * In raw continuation, after `<`, at `/`.
19498 *
19499 * ```markdown
19500 * > | <script>console.log(1)<\/script>
19501 * ^
19502 * ```
19503 *
19504 * @type {State}
19505 */
19506 function continuationRawTagOpen(code) {
19507 if (code === 47) {
19508 effects.consume(code);
19509 buffer = "";
19510 return continuationRawEndTag;
19511 }
19512 return continuation(code);
19513 }
19514 /**
19515 * In raw continuation, after `</`, in a raw tag name.
19516 *
19517 * ```markdown
19518 * > | <script>console.log(1)<\/script>
19519 * ^^^^^^
19520 * ```
19521 *
19522 * @type {State}
19523 */
19524 function continuationRawEndTag(code) {
19525 if (code === 62) {
19526 const name = buffer.toLowerCase();
19527 if (htmlRawNames.includes(name)) {
19528 effects.consume(code);
19529 return continuationClose;
19530 }
19531 return continuation(code);
19532 }
19533 if (asciiAlpha(code) && buffer.length < 8) {
19534 effects.consume(code);
19535 buffer += String.fromCharCode(code);
19536 return continuationRawEndTag;
19537 }
19538 return continuation(code);
19539 }
19540 /**
19541 * In cdata continuation, after `]`, expecting `]>`.
19542 *
19543 * ```markdown
19544 * > | <![CDATA[>&<]]>
19545 * ^
19546 * ```
19547 *
19548 * @type {State}
19549 */
19550 function continuationCdataInside(code) {
19551 if (code === 93) {
19552 effects.consume(code);
19553 return continuationDeclarationInside;
19554 }
19555 return continuation(code);
19556 }
19557 /**
19558 * In declaration or instruction continuation, at `>`.
19559 *
19560 * ```markdown
19561 * > | <!-->
19562 * ^
19563 * > | <?>
19564 * ^
19565 * > | <!q>
19566 * ^
19567 * > | <!--ab-->
19568 * ^
19569 * > | <![CDATA[>&<]]>
19570 * ^
19571 * ```
19572 *
19573 * @type {State}
19574 */
19575 function continuationDeclarationInside(code) {
19576 if (code === 62) {
19577 effects.consume(code);
19578 return continuationClose;
19579 }
19580 if (code === 45 && marker === 2) {
19581 effects.consume(code);
19582 return continuationDeclarationInside;
19583 }
19584 return continuation(code);
19585 }
19586 /**
19587 * In closed continuation: everything we get until the eol/eof is part of it.
19588 *
19589 * ```markdown
19590 * > | <!doctype>
19591 * ^
19592 * ```
19593 *
19594 * @type {State}
19595 */
19596 function continuationClose(code) {
19597 if (code === null || markdownLineEnding(code)) {
19598 effects.exit("htmlFlowData");
19599 return continuationAfter(code);
19600 }
19601 effects.consume(code);
19602 return continuationClose;
19603 }
19604 /**
19605 * Done.
19606 *
19607 * ```markdown
19608 * > | <!doctype>
19609 * ^
19610 * ```
19611 *
19612 * @type {State}
19613 */
19614 function continuationAfter(code) {
19615 effects.exit("htmlFlow");
19616 return ok(code);
19617 }
19618 }
19619 /**
19620 * @this {TokenizeContext}
19621 * @type {Tokenizer}
19622 */
19623 function tokenizeNonLazyContinuationStart(effects, ok, nok) {
19624 const self = this;
19625 return start;
19626 /**
19627 * At eol, before continuation.
19628 *
19629 * ```markdown
19630 * > | * ```js
19631 * ^
19632 * | b
19633 * ```
19634 *
19635 * @type {State}
19636 */
19637 function start(code) {
19638 if (markdownLineEnding(code)) {
19639 effects.enter("lineEnding");
19640 effects.consume(code);
19641 effects.exit("lineEnding");
19642 return after;
19643 }
19644 return nok(code);
19645 }
19646 /**
19647 * A continuation.
19648 *
19649 * ```markdown
19650 * | * ```js
19651 * > | b
19652 * ^
19653 * ```
19654 *
19655 * @type {State}
19656 */
19657 function after(code) {
19658 return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
19659 }
19660 }
19661 /**
19662 * @this {TokenizeContext}
19663 * @type {Tokenizer}
19664 */
19665 function tokenizeBlankLineBefore(effects, ok, nok) {
19666 return start;
19667 /**
19668 * Before eol, expecting blank line.
19669 *
19670 * ```markdown
19671 * > | <div>
19672 * ^
19673 * |
19674 * ```
19675 *
19676 * @type {State}
19677 */
19678 function start(code) {
19679 effects.enter("lineEnding");
19680 effects.consume(code);
19681 effects.exit("lineEnding");
19682 return effects.attempt(blankLine, ok, nok);
19683 }
19684 }
19685 var htmlFlow, blankLineBefore, nonLazyContinuationStart;
19686 var init_html_flow = __esmMin((() => {
19687 init_micromark_util_character();
19688 init_micromark_util_html_tag_name();
19689 init_blank_line();
19690 htmlFlow = {
19691 name: "htmlFlow",
19692 tokenize: tokenizeHtmlFlow,
19693 resolveTo: resolveToHtmlFlow,
19694 concrete: true
19695 };
19696 blankLineBefore = {
19697 tokenize: tokenizeBlankLineBefore,
19698 partial: true
19699 };
19700 nonLazyContinuationStart = {
19701 tokenize: tokenizeNonLazyContinuationStart,
19702 partial: true
19703 };
19704 }));
19705
19706 //#endregion
19707 //#region node_modules/micromark-core-commonmark/lib/html-text.js
19708 /**
19709 * @this {TokenizeContext}
19710 * @type {Tokenizer}
19711 */
19712 function tokenizeHtmlText(effects, ok, nok) {
19713 const self = this;
19714 /** @type {NonNullable<Code> | undefined} */
19715 let marker;
19716 /** @type {number} */
19717 let index;
19718 /** @type {State} */
19719 let returnState;
19720 return start;
19721 /**
19722 * Start of HTML (text).
19723 *
19724 * ```markdown
19725 * > | a <b> c
19726 * ^
19727 * ```
19728 *
19729 * @type {State}
19730 */
19731 function start(code) {
19732 effects.enter("htmlText");
19733 effects.enter("htmlTextData");
19734 effects.consume(code);
19735 return open;
19736 }
19737 /**
19738 * After `<`, at tag name or other stuff.
19739 *
19740 * ```markdown
19741 * > | a <b> c
19742 * ^
19743 * > | a <!doctype> c
19744 * ^
19745 * > | a <!--b--> c
19746 * ^
19747 * ```
19748 *
19749 * @type {State}
19750 */
19751 function open(code) {
19752 if (code === 33) {
19753 effects.consume(code);
19754 return declarationOpen;
19755 }
19756 if (code === 47) {
19757 effects.consume(code);
19758 return tagCloseStart;
19759 }
19760 if (code === 63) {
19761 effects.consume(code);
19762 return instruction;
19763 }
19764 if (asciiAlpha(code)) {
19765 effects.consume(code);
19766 return tagOpen;
19767 }
19768 return nok(code);
19769 }
19770 /**
19771 * After `<!`, at declaration, comment, or CDATA.
19772 *
19773 * ```markdown
19774 * > | a <!doctype> c
19775 * ^
19776 * > | a <!--b--> c
19777 * ^
19778 * > | a <![CDATA[>&<]]> c
19779 * ^
19780 * ```
19781 *
19782 * @type {State}
19783 */
19784 function declarationOpen(code) {
19785 if (code === 45) {
19786 effects.consume(code);
19787 return commentOpenInside;
19788 }
19789 if (code === 91) {
19790 effects.consume(code);
19791 index = 0;
19792 return cdataOpenInside;
19793 }
19794 if (asciiAlpha(code)) {
19795 effects.consume(code);
19796 return declaration;
19797 }
19798 return nok(code);
19799 }
19800 /**
19801 * In a comment, after `<!-`, at another `-`.
19802 *
19803 * ```markdown
19804 * > | a <!--b--> c
19805 * ^
19806 * ```
19807 *
19808 * @type {State}
19809 */
19810 function commentOpenInside(code) {
19811 if (code === 45) {
19812 effects.consume(code);
19813 return commentEnd;
19814 }
19815 return nok(code);
19816 }
19817 /**
19818 * In comment.
19819 *
19820 * ```markdown
19821 * > | a <!--b--> c
19822 * ^
19823 * ```
19824 *
19825 * @type {State}
19826 */
19827 function comment(code) {
19828 if (code === null) return nok(code);
19829 if (code === 45) {
19830 effects.consume(code);
19831 return commentClose;
19832 }
19833 if (markdownLineEnding(code)) {
19834 returnState = comment;
19835 return lineEndingBefore(code);
19836 }
19837 effects.consume(code);
19838 return comment;
19839 }
19840 /**
19841 * In comment, after `-`.
19842 *
19843 * ```markdown
19844 * > | a <!--b--> c
19845 * ^
19846 * ```
19847 *
19848 * @type {State}
19849 */
19850 function commentClose(code) {
19851 if (code === 45) {
19852 effects.consume(code);
19853 return commentEnd;
19854 }
19855 return comment(code);
19856 }
19857 /**
19858 * In comment, after `--`.
19859 *
19860 * ```markdown
19861 * > | a <!--b--> c
19862 * ^
19863 * ```
19864 *
19865 * @type {State}
19866 */
19867 function commentEnd(code) {
19868 return code === 62 ? end(code) : code === 45 ? commentClose(code) : comment(code);
19869 }
19870 /**
19871 * After `<![`, in CDATA, expecting `CDATA[`.
19872 *
19873 * ```markdown
19874 * > | a <![CDATA[>&<]]> b
19875 * ^^^^^^
19876 * ```
19877 *
19878 * @type {State}
19879 */
19880 function cdataOpenInside(code) {
19881 if (code === "CDATA[".charCodeAt(index++)) {
19882 effects.consume(code);
19883 return index === 6 ? cdata : cdataOpenInside;
19884 }
19885 return nok(code);
19886 }
19887 /**
19888 * In CDATA.
19889 *
19890 * ```markdown
19891 * > | a <![CDATA[>&<]]> b
19892 * ^^^
19893 * ```
19894 *
19895 * @type {State}
19896 */
19897 function cdata(code) {
19898 if (code === null) return nok(code);
19899 if (code === 93) {
19900 effects.consume(code);
19901 return cdataClose;
19902 }
19903 if (markdownLineEnding(code)) {
19904 returnState = cdata;
19905 return lineEndingBefore(code);
19906 }
19907 effects.consume(code);
19908 return cdata;
19909 }
19910 /**
19911 * In CDATA, after `]`, at another `]`.
19912 *
19913 * ```markdown
19914 * > | a <![CDATA[>&<]]> b
19915 * ^
19916 * ```
19917 *
19918 * @type {State}
19919 */
19920 function cdataClose(code) {
19921 if (code === 93) {
19922 effects.consume(code);
19923 return cdataEnd;
19924 }
19925 return cdata(code);
19926 }
19927 /**
19928 * In CDATA, after `]]`, at `>`.
19929 *
19930 * ```markdown
19931 * > | a <![CDATA[>&<]]> b
19932 * ^
19933 * ```
19934 *
19935 * @type {State}
19936 */
19937 function cdataEnd(code) {
19938 if (code === 62) return end(code);
19939 if (code === 93) {
19940 effects.consume(code);
19941 return cdataEnd;
19942 }
19943 return cdata(code);
19944 }
19945 /**
19946 * In declaration.
19947 *
19948 * ```markdown
19949 * > | a <!b> c
19950 * ^
19951 * ```
19952 *
19953 * @type {State}
19954 */
19955 function declaration(code) {
19956 if (code === null || code === 62) return end(code);
19957 if (markdownLineEnding(code)) {
19958 returnState = declaration;
19959 return lineEndingBefore(code);
19960 }
19961 effects.consume(code);
19962 return declaration;
19963 }
19964 /**
19965 * In instruction.
19966 *
19967 * ```markdown
19968 * > | a <?b?> c
19969 * ^
19970 * ```
19971 *
19972 * @type {State}
19973 */
19974 function instruction(code) {
19975 if (code === null) return nok(code);
19976 if (code === 63) {
19977 effects.consume(code);
19978 return instructionClose;
19979 }
19980 if (markdownLineEnding(code)) {
19981 returnState = instruction;
19982 return lineEndingBefore(code);
19983 }
19984 effects.consume(code);
19985 return instruction;
19986 }
19987 /**
19988 * In instruction, after `?`, at `>`.
19989 *
19990 * ```markdown
19991 * > | a <?b?> c
19992 * ^
19993 * ```
19994 *
19995 * @type {State}
19996 */
19997 function instructionClose(code) {
19998 return code === 62 ? end(code) : instruction(code);
19999 }
20000 /**
20001 * After `</`, in closing tag, at tag name.
20002 *
20003 * ```markdown
20004 * > | a </b> c
20005 * ^
20006 * ```
20007 *
20008 * @type {State}
20009 */
20010 function tagCloseStart(code) {
20011 if (asciiAlpha(code)) {
20012 effects.consume(code);
20013 return tagClose;
20014 }
20015 return nok(code);
20016 }
20017 /**
20018 * After `</x`, in a tag name.
20019 *
20020 * ```markdown
20021 * > | a </b> c
20022 * ^
20023 * ```
20024 *
20025 * @type {State}
20026 */
20027 function tagClose(code) {
20028 if (code === 45 || asciiAlphanumeric(code)) {
20029 effects.consume(code);
20030 return tagClose;
20031 }
20032 return tagCloseBetween(code);
20033 }
20034 /**
20035 * In closing tag, after tag name.
20036 *
20037 * ```markdown
20038 * > | a </b> c
20039 * ^
20040 * ```
20041 *
20042 * @type {State}
20043 */
20044 function tagCloseBetween(code) {
20045 if (markdownLineEnding(code)) {
20046 returnState = tagCloseBetween;
20047 return lineEndingBefore(code);
20048 }
20049 if (markdownSpace(code)) {
20050 effects.consume(code);
20051 return tagCloseBetween;
20052 }
20053 return end(code);
20054 }
20055 /**
20056 * After `<x`, in opening tag name.
20057 *
20058 * ```markdown
20059 * > | a <b> c
20060 * ^
20061 * ```
20062 *
20063 * @type {State}
20064 */
20065 function tagOpen(code) {
20066 if (code === 45 || asciiAlphanumeric(code)) {
20067 effects.consume(code);
20068 return tagOpen;
20069 }
20070 if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) return tagOpenBetween(code);
20071 return nok(code);
20072 }
20073 /**
20074 * In opening tag, after tag name.
20075 *
20076 * ```markdown
20077 * > | a <b> c
20078 * ^
20079 * ```
20080 *
20081 * @type {State}
20082 */
20083 function tagOpenBetween(code) {
20084 if (code === 47) {
20085 effects.consume(code);
20086 return end;
20087 }
20088 if (code === 58 || code === 95 || asciiAlpha(code)) {
20089 effects.consume(code);
20090 return tagOpenAttributeName;
20091 }
20092 if (markdownLineEnding(code)) {
20093 returnState = tagOpenBetween;
20094 return lineEndingBefore(code);
20095 }
20096 if (markdownSpace(code)) {
20097 effects.consume(code);
20098 return tagOpenBetween;
20099 }
20100 return end(code);
20101 }
20102 /**
20103 * In attribute name.
20104 *
20105 * ```markdown
20106 * > | a <b c> d
20107 * ^
20108 * ```
20109 *
20110 * @type {State}
20111 */
20112 function tagOpenAttributeName(code) {
20113 if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) {
20114 effects.consume(code);
20115 return tagOpenAttributeName;
20116 }
20117 return tagOpenAttributeNameAfter(code);
20118 }
20119 /**
20120 * After attribute name, before initializer, the end of the tag, or
20121 * whitespace.
20122 *
20123 * ```markdown
20124 * > | a <b c> d
20125 * ^
20126 * ```
20127 *
20128 * @type {State}
20129 */
20130 function tagOpenAttributeNameAfter(code) {
20131 if (code === 61) {
20132 effects.consume(code);
20133 return tagOpenAttributeValueBefore;
20134 }
20135 if (markdownLineEnding(code)) {
20136 returnState = tagOpenAttributeNameAfter;
20137 return lineEndingBefore(code);
20138 }
20139 if (markdownSpace(code)) {
20140 effects.consume(code);
20141 return tagOpenAttributeNameAfter;
20142 }
20143 return tagOpenBetween(code);
20144 }
20145 /**
20146 * Before unquoted, double quoted, or single quoted attribute value, allowing
20147 * whitespace.
20148 *
20149 * ```markdown
20150 * > | a <b c=d> e
20151 * ^
20152 * ```
20153 *
20154 * @type {State}
20155 */
20156 function tagOpenAttributeValueBefore(code) {
20157 if (code === null || code === 60 || code === 61 || code === 62 || code === 96) return nok(code);
20158 if (code === 34 || code === 39) {
20159 effects.consume(code);
20160 marker = code;
20161 return tagOpenAttributeValueQuoted;
20162 }
20163 if (markdownLineEnding(code)) {
20164 returnState = tagOpenAttributeValueBefore;
20165 return lineEndingBefore(code);
20166 }
20167 if (markdownSpace(code)) {
20168 effects.consume(code);
20169 return tagOpenAttributeValueBefore;
20170 }
20171 effects.consume(code);
20172 return tagOpenAttributeValueUnquoted;
20173 }
20174 /**
20175 * In double or single quoted attribute value.
20176 *
20177 * ```markdown
20178 * > | a <b c="d"> e
20179 * ^
20180 * ```
20181 *
20182 * @type {State}
20183 */
20184 function tagOpenAttributeValueQuoted(code) {
20185 if (code === marker) {
20186 effects.consume(code);
20187 marker = void 0;
20188 return tagOpenAttributeValueQuotedAfter;
20189 }
20190 if (code === null) return nok(code);
20191 if (markdownLineEnding(code)) {
20192 returnState = tagOpenAttributeValueQuoted;
20193 return lineEndingBefore(code);
20194 }
20195 effects.consume(code);
20196 return tagOpenAttributeValueQuoted;
20197 }
20198 /**
20199 * In unquoted attribute value.
20200 *
20201 * ```markdown
20202 * > | a <b c=d> e
20203 * ^
20204 * ```
20205 *
20206 * @type {State}
20207 */
20208 function tagOpenAttributeValueUnquoted(code) {
20209 if (code === null || code === 34 || code === 39 || code === 60 || code === 61 || code === 96) return nok(code);
20210 if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) return tagOpenBetween(code);
20211 effects.consume(code);
20212 return tagOpenAttributeValueUnquoted;
20213 }
20214 /**
20215 * After double or single quoted attribute value, before whitespace or the end
20216 * of the tag.
20217 *
20218 * ```markdown
20219 * > | a <b c="d"> e
20220 * ^
20221 * ```
20222 *
20223 * @type {State}
20224 */
20225 function tagOpenAttributeValueQuotedAfter(code) {
20226 if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) return tagOpenBetween(code);
20227 return nok(code);
20228 }
20229 /**
20230 * In certain circumstances of a tag where only an `>` is allowed.
20231 *
20232 * ```markdown
20233 * > | a <b c="d"> e
20234 * ^
20235 * ```
20236 *
20237 * @type {State}
20238 */
20239 function end(code) {
20240 if (code === 62) {
20241 effects.consume(code);
20242 effects.exit("htmlTextData");
20243 effects.exit("htmlText");
20244 return ok;
20245 }
20246 return nok(code);
20247 }
20248 /**
20249 * At eol.
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 * ^
20257 * | b-->
20258 * ```
20259 *
20260 * @type {State}
20261 */
20262 function lineEndingBefore(code) {
20263 effects.exit("htmlTextData");
20264 effects.enter("lineEnding");
20265 effects.consume(code);
20266 effects.exit("lineEnding");
20267 return lineEndingAfter;
20268 }
20269 /**
20270 * After eol, at optional whitespace.
20271 *
20272 * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about
20273 * > empty tokens.
20274 *
20275 * ```markdown
20276 * | a <!--a
20277 * > | b-->
20278 * ^
20279 * ```
20280 *
20281 * @type {State}
20282 */
20283 function lineEndingAfter(code) {
20284 return markdownSpace(code) ? factorySpace(effects, lineEndingAfterPrefix, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code) : lineEndingAfterPrefix(code);
20285 }
20286 /**
20287 * After eol, after optional whitespace.
20288 *
20289 * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about
20290 * > empty tokens.
20291 *
20292 * ```markdown
20293 * | a <!--a
20294 * > | b-->
20295 * ^
20296 * ```
20297 *
20298 * @type {State}
20299 */
20300 function lineEndingAfterPrefix(code) {
20301 effects.enter("htmlTextData");
20302 return returnState(code);
20303 }
20304 }
20305 var htmlText;
20306 var init_html_text = __esmMin((() => {
20307 init_micromark_factory_space();
20308 init_micromark_util_character();
20309 htmlText = {
20310 name: "htmlText",
20311 tokenize: tokenizeHtmlText
20312 };
20313 }));
20314
20315 //#endregion
20316 //#region node_modules/micromark-core-commonmark/lib/label-end.js
20317 /** @type {Resolver} */
20318 function resolveAllLabelEnd(events) {
20319 let index = -1;
20320 while (++index < events.length) {
20321 const token = events[index][1];
20322 if (token.type === "labelImage" || token.type === "labelLink" || token.type === "labelEnd") {
20323 events.splice(index + 1, token.type === "labelImage" ? 4 : 2);
20324 token.type = "data";
20325 index++;
20326 }
20327 }
20328 return events;
20329 }
20330 /** @type {Resolver} */
20331 function resolveToLabelEnd(events, context) {
20332 let index = events.length;
20333 let offset = 0;
20334 /** @type {Token} */
20335 let token;
20336 /** @type {number | undefined} */
20337 let open;
20338 /** @type {number | undefined} */
20339 let close;
20340 /** @type {Array<Event>} */
20341 let media;
20342 while (index--) {
20343 token = events[index][1];
20344 if (open) {
20345 if (token.type === "link" || token.type === "labelLink" && token._inactive) break;
20346 if (events[index][0] === "enter" && token.type === "labelLink") token._inactive = true;
20347 } else if (close) {
20348 if (events[index][0] === "enter" && (token.type === "labelImage" || token.type === "labelLink") && !token._balanced) {
20349 open = index;
20350 if (token.type !== "labelLink") {
20351 offset = 2;
20352 break;
20353 }
20354 }
20355 } else if (token.type === "labelEnd") close = index;
20356 }
20357 const group = {
20358 type: events[open][1].type === "labelLink" ? "link" : "image",
20359 start: Object.assign({}, events[open][1].start),
20360 end: Object.assign({}, events[events.length - 1][1].end)
20361 };
20362 const label = {
20363 type: "label",
20364 start: Object.assign({}, events[open][1].start),
20365 end: Object.assign({}, events[close][1].end)
20366 };
20367 const text = {
20368 type: "labelText",
20369 start: Object.assign({}, events[open + offset + 2][1].end),
20370 end: Object.assign({}, events[close - 2][1].start)
20371 };
20372 media = [[
20373 "enter",
20374 group,
20375 context
20376 ], [
20377 "enter",
20378 label,
20379 context
20380 ]];
20381 media = push(media, events.slice(open + 1, open + offset + 3));
20382 media = push(media, [[
20383 "enter",
20384 text,
20385 context
20386 ]]);
20387 media = push(media, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + offset + 4, close - 3), context));
20388 media = push(media, [
20389 [
20390 "exit",
20391 text,
20392 context
20393 ],
20394 events[close - 2],
20395 events[close - 1],
20396 [
20397 "exit",
20398 label,
20399 context
20400 ]
20401 ]);
20402 media = push(media, events.slice(close + 1));
20403 media = push(media, [[
20404 "exit",
20405 group,
20406 context
20407 ]]);
20408 splice(events, open, events.length, media);
20409 return events;
20410 }
20411 /**
20412 * @this {TokenizeContext}
20413 * @type {Tokenizer}
20414 */
20415 function tokenizeLabelEnd(effects, ok, nok) {
20416 const self = this;
20417 let index = self.events.length;
20418 /** @type {Token} */
20419 let labelStart;
20420 /** @type {boolean} */
20421 let defined;
20422 while (index--) if ((self.events[index][1].type === "labelImage" || self.events[index][1].type === "labelLink") && !self.events[index][1]._balanced) {
20423 labelStart = self.events[index][1];
20424 break;
20425 }
20426 return start;
20427 /**
20428 * Start of label end.
20429 *
20430 * ```markdown
20431 * > | [a](b) c
20432 * ^
20433 * > | [a][b] c
20434 * ^
20435 * > | [a][] b
20436 * ^
20437 * > | [a] b
20438 * ```
20439 *
20440 * @type {State}
20441 */
20442 function start(code) {
20443 if (!labelStart) return nok(code);
20444 if (labelStart._inactive) return labelEndNok(code);
20445 defined = self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize({
20446 start: labelStart.end,
20447 end: self.now()
20448 })));
20449 effects.enter("labelEnd");
20450 effects.enter("labelMarker");
20451 effects.consume(code);
20452 effects.exit("labelMarker");
20453 effects.exit("labelEnd");
20454 return after;
20455 }
20456 /**
20457 * After `]`.
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 after(code) {
20473 if (code === 40) return effects.attempt(resourceConstruct, labelEndOk, defined ? labelEndOk : labelEndNok)(code);
20474 if (code === 91) return effects.attempt(referenceFullConstruct, labelEndOk, defined ? referenceNotFull : labelEndNok)(code);
20475 return defined ? labelEndOk(code) : labelEndNok(code);
20476 }
20477 /**
20478 * After `]`, at `[`, but not at a full reference.
20479 *
20480 * > 👉 **Note**: we only get here if the label is defined.
20481 *
20482 * ```markdown
20483 * > | [a][] b
20484 * ^
20485 * > | [a] b
20486 * ^
20487 * ```
20488 *
20489 * @type {State}
20490 */
20491 function referenceNotFull(code) {
20492 return effects.attempt(referenceCollapsedConstruct, labelEndOk, labelEndNok)(code);
20493 }
20494 /**
20495 * Done, we found something.
20496 *
20497 * ```markdown
20498 * > | [a](b) c
20499 * ^
20500 * > | [a][b] c
20501 * ^
20502 * > | [a][] b
20503 * ^
20504 * > | [a] b
20505 * ^
20506 * ```
20507 *
20508 * @type {State}
20509 */
20510 function labelEndOk(code) {
20511 return ok(code);
20512 }
20513 /**
20514 * Done, it’s nothing.
20515 *
20516 * There was an okay opening, but we didn’t match anything.
20517 *
20518 * ```markdown
20519 * > | [a](b c
20520 * ^
20521 * > | [a][b c
20522 * ^
20523 * > | [a] b
20524 * ^
20525 * ```
20526 *
20527 * @type {State}
20528 */
20529 function labelEndNok(code) {
20530 labelStart._balanced = true;
20531 return nok(code);
20532 }
20533 }
20534 /**
20535 * @this {TokenizeContext}
20536 * @type {Tokenizer}
20537 */
20538 function tokenizeResource(effects, ok, nok) {
20539 return resourceStart;
20540 /**
20541 * At a resource.
20542 *
20543 * ```markdown
20544 * > | [a](b) c
20545 * ^
20546 * ```
20547 *
20548 * @type {State}
20549 */
20550 function resourceStart(code) {
20551 effects.enter("resource");
20552 effects.enter("resourceMarker");
20553 effects.consume(code);
20554 effects.exit("resourceMarker");
20555 return resourceBefore;
20556 }
20557 /**
20558 * In resource, after `(`, at optional whitespace.
20559 *
20560 * ```markdown
20561 * > | [a](b) c
20562 * ^
20563 * ```
20564 *
20565 * @type {State}
20566 */
20567 function resourceBefore(code) {
20568 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceOpen)(code) : resourceOpen(code);
20569 }
20570 /**
20571 * In resource, after optional whitespace, at `)` or a destination.
20572 *
20573 * ```markdown
20574 * > | [a](b) c
20575 * ^
20576 * ```
20577 *
20578 * @type {State}
20579 */
20580 function resourceOpen(code) {
20581 if (code === 41) return resourceEnd(code);
20582 return factoryDestination(effects, resourceDestinationAfter, resourceDestinationMissing, "resourceDestination", "resourceDestinationLiteral", "resourceDestinationLiteralMarker", "resourceDestinationRaw", "resourceDestinationString", 32)(code);
20583 }
20584 /**
20585 * In resource, after destination, at optional whitespace.
20586 *
20587 * ```markdown
20588 * > | [a](b) c
20589 * ^
20590 * ```
20591 *
20592 * @type {State}
20593 */
20594 function resourceDestinationAfter(code) {
20595 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceBetween)(code) : resourceEnd(code);
20596 }
20597 /**
20598 * At invalid destination.
20599 *
20600 * ```markdown
20601 * > | [a](<<) b
20602 * ^
20603 * ```
20604 *
20605 * @type {State}
20606 */
20607 function resourceDestinationMissing(code) {
20608 return nok(code);
20609 }
20610 /**
20611 * In resource, after destination and whitespace, at `(` or title.
20612 *
20613 * ```markdown
20614 * > | [a](b ) c
20615 * ^
20616 * ```
20617 *
20618 * @type {State}
20619 */
20620 function resourceBetween(code) {
20621 if (code === 34 || code === 39 || code === 40) return factoryTitle(effects, resourceTitleAfter, nok, "resourceTitle", "resourceTitleMarker", "resourceTitleString")(code);
20622 return resourceEnd(code);
20623 }
20624 /**
20625 * In resource, after title, at optional whitespace.
20626 *
20627 * ```markdown
20628 * > | [a](b "c") d
20629 * ^
20630 * ```
20631 *
20632 * @type {State}
20633 */
20634 function resourceTitleAfter(code) {
20635 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceEnd)(code) : resourceEnd(code);
20636 }
20637 /**
20638 * In resource, at `)`.
20639 *
20640 * ```markdown
20641 * > | [a](b) d
20642 * ^
20643 * ```
20644 *
20645 * @type {State}
20646 */
20647 function resourceEnd(code) {
20648 if (code === 41) {
20649 effects.enter("resourceMarker");
20650 effects.consume(code);
20651 effects.exit("resourceMarker");
20652 effects.exit("resource");
20653 return ok;
20654 }
20655 return nok(code);
20656 }
20657 }
20658 /**
20659 * @this {TokenizeContext}
20660 * @type {Tokenizer}
20661 */
20662 function tokenizeReferenceFull(effects, ok, nok) {
20663 const self = this;
20664 return referenceFull;
20665 /**
20666 * In a reference (full), at the `[`.
20667 *
20668 * ```markdown
20669 * > | [a][b] d
20670 * ^
20671 * ```
20672 *
20673 * @type {State}
20674 */
20675 function referenceFull(code) {
20676 return factoryLabel.call(self, effects, referenceFullAfter, referenceFullMissing, "reference", "referenceMarker", "referenceString")(code);
20677 }
20678 /**
20679 * In a reference (full), after `]`.
20680 *
20681 * ```markdown
20682 * > | [a][b] d
20683 * ^
20684 * ```
20685 *
20686 * @type {State}
20687 */
20688 function referenceFullAfter(code) {
20689 return self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1))) ? ok(code) : nok(code);
20690 }
20691 /**
20692 * In reference (full) that was missing.
20693 *
20694 * ```markdown
20695 * > | [a][b d
20696 * ^
20697 * ```
20698 *
20699 * @type {State}
20700 */
20701 function referenceFullMissing(code) {
20702 return nok(code);
20703 }
20704 }
20705 /**
20706 * @this {TokenizeContext}
20707 * @type {Tokenizer}
20708 */
20709 function tokenizeReferenceCollapsed(effects, ok, nok) {
20710 return referenceCollapsedStart;
20711 /**
20712 * In reference (collapsed), at `[`.
20713 *
20714 * > 👉 **Note**: we only get here if the label is defined.
20715 *
20716 * ```markdown
20717 * > | [a][] d
20718 * ^
20719 * ```
20720 *
20721 * @type {State}
20722 */
20723 function referenceCollapsedStart(code) {
20724 effects.enter("reference");
20725 effects.enter("referenceMarker");
20726 effects.consume(code);
20727 effects.exit("referenceMarker");
20728 return referenceCollapsedOpen;
20729 }
20730 /**
20731 * In reference (collapsed), at `]`.
20732 *
20733 * > 👉 **Note**: we only get here if the label is defined.
20734 *
20735 * ```markdown
20736 * > | [a][] d
20737 * ^
20738 * ```
20739 *
20740 * @type {State}
20741 */
20742 function referenceCollapsedOpen(code) {
20743 if (code === 93) {
20744 effects.enter("referenceMarker");
20745 effects.consume(code);
20746 effects.exit("referenceMarker");
20747 effects.exit("reference");
20748 return ok;
20749 }
20750 return nok(code);
20751 }
20752 }
20753 var labelEnd, resourceConstruct, referenceFullConstruct, referenceCollapsedConstruct;
20754 var init_label_end = __esmMin((() => {
20755 init_micromark_factory_destination();
20756 init_micromark_factory_label();
20757 init_micromark_factory_title();
20758 init_micromark_factory_whitespace();
20759 init_micromark_util_character();
20760 init_micromark_util_chunked();
20761 init_micromark_util_normalize_identifier();
20762 init_micromark_util_resolve_all();
20763 labelEnd = {
20764 name: "labelEnd",
20765 tokenize: tokenizeLabelEnd,
20766 resolveTo: resolveToLabelEnd,
20767 resolveAll: resolveAllLabelEnd
20768 };
20769 resourceConstruct = { tokenize: tokenizeResource };
20770 referenceFullConstruct = { tokenize: tokenizeReferenceFull };
20771 referenceCollapsedConstruct = { tokenize: tokenizeReferenceCollapsed };
20772 }));
20773
20774 //#endregion
20775 //#region node_modules/micromark-core-commonmark/lib/label-start-image.js
20776 /**
20777 * @this {TokenizeContext}
20778 * @type {Tokenizer}
20779 */
20780 function tokenizeLabelStartImage(effects, ok, nok) {
20781 const self = this;
20782 return start;
20783 /**
20784 * Start of label (image) start.
20785 *
20786 * ```markdown
20787 * > | a ![b] c
20788 * ^
20789 * ```
20790 *
20791 * @type {State}
20792 */
20793 function start(code) {
20794 effects.enter("labelImage");
20795 effects.enter("labelImageMarker");
20796 effects.consume(code);
20797 effects.exit("labelImageMarker");
20798 return open;
20799 }
20800 /**
20801 * After `!`, at `[`.
20802 *
20803 * ```markdown
20804 * > | a ![b] c
20805 * ^
20806 * ```
20807 *
20808 * @type {State}
20809 */
20810 function open(code) {
20811 if (code === 91) {
20812 effects.enter("labelMarker");
20813 effects.consume(code);
20814 effects.exit("labelMarker");
20815 effects.exit("labelImage");
20816 return after;
20817 }
20818 return nok(code);
20819 }
20820 /**
20821 * After `![`.
20822 *
20823 * ```markdown
20824 * > | a ![b] c
20825 * ^
20826 * ```
20827 *
20828 * This is needed in because, when GFM footnotes are enabled, images never
20829 * form when started with a `^`.
20830 * Instead, links form:
20831 *
20832 * ```markdown
20833 * ![^a](b)
20834 *
20835 * ![^a][b]
20836 *
20837 * [b]: c
20838 * ```
20839 *
20840 * ```html
20841 * <p>!<a href=\"b\">^a</a></p>
20842 * <p>!<a href=\"c\">^a</a></p>
20843 * ```
20844 *
20845 * @type {State}
20846 */
20847 function after(code) {
20848 /* c8 ignore next 3 */
20849 return code === 94 && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code) : ok(code);
20850 }
20851 }
20852 var labelStartImage;
20853 var init_label_start_image = __esmMin((() => {
20854 init_label_end();
20855 labelStartImage = {
20856 name: "labelStartImage",
20857 tokenize: tokenizeLabelStartImage,
20858 resolveAll: labelEnd.resolveAll
20859 };
20860 }));
20861
20862 //#endregion
20863 //#region node_modules/micromark-core-commonmark/lib/label-start-link.js
20864 /**
20865 * @this {TokenizeContext}
20866 * @type {Tokenizer}
20867 */
20868 function tokenizeLabelStartLink(effects, ok, nok) {
20869 const self = this;
20870 return start;
20871 /**
20872 * Start of label (link) start.
20873 *
20874 * ```markdown
20875 * > | a [b] c
20876 * ^
20877 * ```
20878 *
20879 * @type {State}
20880 */
20881 function start(code) {
20882 effects.enter("labelLink");
20883 effects.enter("labelMarker");
20884 effects.consume(code);
20885 effects.exit("labelMarker");
20886 effects.exit("labelLink");
20887 return after;
20888 }
20889 /** @type {State} */
20890 function after(code) {
20891 /* c8 ignore next 3 */
20892 return code === 94 && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code) : ok(code);
20893 }
20894 }
20895 var labelStartLink;
20896 var init_label_start_link = __esmMin((() => {
20897 init_label_end();
20898 labelStartLink = {
20899 name: "labelStartLink",
20900 tokenize: tokenizeLabelStartLink,
20901 resolveAll: labelEnd.resolveAll
20902 };
20903 }));
20904
20905 //#endregion
20906 //#region node_modules/micromark-core-commonmark/lib/line-ending.js
20907 /**
20908 * @this {TokenizeContext}
20909 * @type {Tokenizer}
20910 */
20911 function tokenizeLineEnding(effects, ok) {
20912 return start;
20913 /** @type {State} */
20914 function start(code) {
20915 effects.enter("lineEnding");
20916 effects.consume(code);
20917 effects.exit("lineEnding");
20918 return factorySpace(effects, ok, "linePrefix");
20919 }
20920 }
20921 var lineEnding;
20922 var init_line_ending = __esmMin((() => {
20923 init_micromark_factory_space();
20924 lineEnding = {
20925 name: "lineEnding",
20926 tokenize: tokenizeLineEnding
20927 };
20928 }));
20929
20930 //#endregion
20931 //#region node_modules/micromark-core-commonmark/lib/thematic-break.js
20932 /**
20933 * @this {TokenizeContext}
20934 * @type {Tokenizer}
20935 */
20936 function tokenizeThematicBreak(effects, ok, nok) {
20937 let size = 0;
20938 /** @type {NonNullable<Code>} */
20939 let marker;
20940 return start;
20941 /**
20942 * Start of thematic break.
20943 *
20944 * ```markdown
20945 * > | ***
20946 * ^
20947 * ```
20948 *
20949 * @type {State}
20950 */
20951 function start(code) {
20952 effects.enter("thematicBreak");
20953 return before(code);
20954 }
20955 /**
20956 * After optional whitespace, at marker.
20957 *
20958 * ```markdown
20959 * > | ***
20960 * ^
20961 * ```
20962 *
20963 * @type {State}
20964 */
20965 function before(code) {
20966 marker = code;
20967 return atBreak(code);
20968 }
20969 /**
20970 * After something, before something else.
20971 *
20972 * ```markdown
20973 * > | ***
20974 * ^
20975 * ```
20976 *
20977 * @type {State}
20978 */
20979 function atBreak(code) {
20980 if (code === marker) {
20981 effects.enter("thematicBreakSequence");
20982 return sequence(code);
20983 }
20984 if (size >= 3 && (code === null || markdownLineEnding(code))) {
20985 effects.exit("thematicBreak");
20986 return ok(code);
20987 }
20988 return nok(code);
20989 }
20990 /**
20991 * In sequence.
20992 *
20993 * ```markdown
20994 * > | ***
20995 * ^
20996 * ```
20997 *
20998 * @type {State}
20999 */
21000 function sequence(code) {
21001 if (code === marker) {
21002 effects.consume(code);
21003 size++;
21004 return sequence;
21005 }
21006 effects.exit("thematicBreakSequence");
21007 return markdownSpace(code) ? factorySpace(effects, atBreak, "whitespace")(code) : atBreak(code);
21008 }
21009 }
21010 var thematicBreak$1;
21011 var init_thematic_break$1 = __esmMin((() => {
21012 init_micromark_factory_space();
21013 init_micromark_util_character();
21014 thematicBreak$1 = {
21015 name: "thematicBreak",
21016 tokenize: tokenizeThematicBreak
21017 };
21018 }));
21019
21020 //#endregion
21021 //#region node_modules/micromark-core-commonmark/lib/list.js
21022 /**
21023 * @type {Tokenizer}
21024 * @this {TokenizeContext}
21025 */
21026 function tokenizeListStart(effects, ok, nok) {
21027 const self = this;
21028 const tail = self.events[self.events.length - 1];
21029 let initialSize = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0;
21030 let size = 0;
21031 return start;
21032 /** @type {State} */
21033 function start(code) {
21034 const kind = self.containerState.type || (code === 42 || code === 43 || code === 45 ? "listUnordered" : "listOrdered");
21035 if (kind === "listUnordered" ? !self.containerState.marker || code === self.containerState.marker : asciiDigit(code)) {
21036 if (!self.containerState.type) {
21037 self.containerState.type = kind;
21038 effects.enter(kind, { _container: true });
21039 }
21040 if (kind === "listUnordered") {
21041 effects.enter("listItemPrefix");
21042 return code === 42 || code === 45 ? effects.check(thematicBreak$1, nok, atMarker)(code) : atMarker(code);
21043 }
21044 if (!self.interrupt || code === 49) {
21045 effects.enter("listItemPrefix");
21046 effects.enter("listItemValue");
21047 return inside(code);
21048 }
21049 }
21050 return nok(code);
21051 }
21052 /** @type {State} */
21053 function inside(code) {
21054 if (asciiDigit(code) && ++size < 10) {
21055 effects.consume(code);
21056 return inside;
21057 }
21058 if ((!self.interrupt || size < 2) && (self.containerState.marker ? code === self.containerState.marker : code === 41 || code === 46)) {
21059 effects.exit("listItemValue");
21060 return atMarker(code);
21061 }
21062 return nok(code);
21063 }
21064 /**
21065 * @type {State}
21066 **/
21067 function atMarker(code) {
21068 effects.enter("listItemMarker");
21069 effects.consume(code);
21070 effects.exit("listItemMarker");
21071 self.containerState.marker = self.containerState.marker || code;
21072 return effects.check(blankLine, self.interrupt ? nok : onBlank, effects.attempt(listItemPrefixWhitespaceConstruct, endOfPrefix, otherPrefix));
21073 }
21074 /** @type {State} */
21075 function onBlank(code) {
21076 self.containerState.initialBlankLine = true;
21077 initialSize++;
21078 return endOfPrefix(code);
21079 }
21080 /** @type {State} */
21081 function otherPrefix(code) {
21082 if (markdownSpace(code)) {
21083 effects.enter("listItemPrefixWhitespace");
21084 effects.consume(code);
21085 effects.exit("listItemPrefixWhitespace");
21086 return endOfPrefix;
21087 }
21088 return nok(code);
21089 }
21090 /** @type {State} */
21091 function endOfPrefix(code) {
21092 self.containerState.size = initialSize + self.sliceSerialize(effects.exit("listItemPrefix"), true).length;
21093 return ok(code);
21094 }
21095 }
21096 /**
21097 * @type {Tokenizer}
21098 * @this {TokenizeContext}
21099 */
21100 function tokenizeListContinuation(effects, ok, nok) {
21101 const self = this;
21102 self.containerState._closeFlow = void 0;
21103 return effects.check(blankLine, onBlank, notBlank);
21104 /** @type {State} */
21105 function onBlank(code) {
21106 self.containerState.furtherBlankLines = self.containerState.furtherBlankLines || self.containerState.initialBlankLine;
21107 return factorySpace(effects, ok, "listItemIndent", self.containerState.size + 1)(code);
21108 }
21109 /** @type {State} */
21110 function notBlank(code) {
21111 if (self.containerState.furtherBlankLines || !markdownSpace(code)) {
21112 self.containerState.furtherBlankLines = void 0;
21113 self.containerState.initialBlankLine = void 0;
21114 return notInCurrentItem(code);
21115 }
21116 self.containerState.furtherBlankLines = void 0;
21117 self.containerState.initialBlankLine = void 0;
21118 return effects.attempt(indentConstruct, ok, notInCurrentItem)(code);
21119 }
21120 /** @type {State} */
21121 function notInCurrentItem(code) {
21122 self.containerState._closeFlow = true;
21123 self.interrupt = void 0;
21124 return factorySpace(effects, effects.attempt(list$1, ok, nok), "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code);
21125 }
21126 }
21127 /**
21128 * @type {Tokenizer}
21129 * @this {TokenizeContext}
21130 */
21131 function tokenizeIndent(effects, ok, nok) {
21132 const self = this;
21133 return factorySpace(effects, afterPrefix, "listItemIndent", self.containerState.size + 1);
21134 /** @type {State} */
21135 function afterPrefix(code) {
21136 const tail = self.events[self.events.length - 1];
21137 return tail && tail[1].type === "listItemIndent" && tail[2].sliceSerialize(tail[1], true).length === self.containerState.size ? ok(code) : nok(code);
21138 }
21139 }
21140 /**
21141 * @type {Exiter}
21142 * @this {TokenizeContext}
21143 */
21144 function tokenizeListEnd(effects) {
21145 effects.exit(this.containerState.type);
21146 }
21147 /**
21148 * @type {Tokenizer}
21149 * @this {TokenizeContext}
21150 */
21151 function tokenizeListItemPrefixWhitespace(effects, ok, nok) {
21152 const self = this;
21153 return factorySpace(effects, afterPrefix, "listItemPrefixWhitespace", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 5);
21154 /** @type {State} */
21155 function afterPrefix(code) {
21156 const tail = self.events[self.events.length - 1];
21157 return !markdownSpace(code) && tail && tail[1].type === "listItemPrefixWhitespace" ? ok(code) : nok(code);
21158 }
21159 }
21160 var list$1, listItemPrefixWhitespaceConstruct, indentConstruct;
21161 var init_list$1 = __esmMin((() => {
21162 init_micromark_factory_space();
21163 init_micromark_util_character();
21164 init_blank_line();
21165 init_thematic_break$1();
21166 list$1 = {
21167 name: "list",
21168 tokenize: tokenizeListStart,
21169 continuation: { tokenize: tokenizeListContinuation },
21170 exit: tokenizeListEnd
21171 };
21172 listItemPrefixWhitespaceConstruct = {
21173 tokenize: tokenizeListItemPrefixWhitespace,
21174 partial: true
21175 };
21176 indentConstruct = {
21177 tokenize: tokenizeIndent,
21178 partial: true
21179 };
21180 }));
21181
21182 //#endregion
21183 //#region node_modules/micromark-core-commonmark/lib/setext-underline.js
21184 /** @type {Resolver} */
21185 function resolveToSetextUnderline(events, context) {
21186 let index = events.length;
21187 /** @type {number | undefined} */
21188 let content;
21189 /** @type {number | undefined} */
21190 let text;
21191 /** @type {number | undefined} */
21192 let definition;
21193 while (index--) if (events[index][0] === "enter") {
21194 if (events[index][1].type === "content") {
21195 content = index;
21196 break;
21197 }
21198 if (events[index][1].type === "paragraph") text = index;
21199 } else {
21200 if (events[index][1].type === "content") events.splice(index, 1);
21201 if (!definition && events[index][1].type === "definition") definition = index;
21202 }
21203 const heading = {
21204 type: "setextHeading",
21205 start: Object.assign({}, events[text][1].start),
21206 end: Object.assign({}, events[events.length - 1][1].end)
21207 };
21208 events[text][1].type = "setextHeadingText";
21209 if (definition) {
21210 events.splice(text, 0, [
21211 "enter",
21212 heading,
21213 context
21214 ]);
21215 events.splice(definition + 1, 0, [
21216 "exit",
21217 events[content][1],
21218 context
21219 ]);
21220 events[content][1].end = Object.assign({}, events[definition][1].end);
21221 } else events[content][1] = heading;
21222 events.push([
21223 "exit",
21224 heading,
21225 context
21226 ]);
21227 return events;
21228 }
21229 /**
21230 * @this {TokenizeContext}
21231 * @type {Tokenizer}
21232 */
21233 function tokenizeSetextUnderline(effects, ok, nok) {
21234 const self = this;
21235 /** @type {NonNullable<Code>} */
21236 let marker;
21237 return start;
21238 /**
21239 * At start of heading (setext) underline.
21240 *
21241 * ```markdown
21242 * | aa
21243 * > | ==
21244 * ^
21245 * ```
21246 *
21247 * @type {State}
21248 */
21249 function start(code) {
21250 let index = self.events.length;
21251 /** @type {boolean | undefined} */
21252 let paragraph;
21253 while (index--) if (self.events[index][1].type !== "lineEnding" && self.events[index][1].type !== "linePrefix" && self.events[index][1].type !== "content") {
21254 paragraph = self.events[index][1].type === "paragraph";
21255 break;
21256 }
21257 if (!self.parser.lazy[self.now().line] && (self.interrupt || paragraph)) {
21258 effects.enter("setextHeadingLine");
21259 marker = code;
21260 return before(code);
21261 }
21262 return nok(code);
21263 }
21264 /**
21265 * After optional whitespace, at `-` or `=`.
21266 *
21267 * ```markdown
21268 * | aa
21269 * > | ==
21270 * ^
21271 * ```
21272 *
21273 * @type {State}
21274 */
21275 function before(code) {
21276 effects.enter("setextHeadingLineSequence");
21277 return inside(code);
21278 }
21279 /**
21280 * In sequence.
21281 *
21282 * ```markdown
21283 * | aa
21284 * > | ==
21285 * ^
21286 * ```
21287 *
21288 * @type {State}
21289 */
21290 function inside(code) {
21291 if (code === marker) {
21292 effects.consume(code);
21293 return inside;
21294 }
21295 effects.exit("setextHeadingLineSequence");
21296 return markdownSpace(code) ? factorySpace(effects, after, "lineSuffix")(code) : after(code);
21297 }
21298 /**
21299 * After sequence, after optional whitespace.
21300 *
21301 * ```markdown
21302 * | aa
21303 * > | ==
21304 * ^
21305 * ```
21306 *
21307 * @type {State}
21308 */
21309 function after(code) {
21310 if (code === null || markdownLineEnding(code)) {
21311 effects.exit("setextHeadingLine");
21312 return ok(code);
21313 }
21314 return nok(code);
21315 }
21316 }
21317 var setextUnderline;
21318 var init_setext_underline = __esmMin((() => {
21319 init_micromark_factory_space();
21320 init_micromark_util_character();
21321 setextUnderline = {
21322 name: "setextUnderline",
21323 tokenize: tokenizeSetextUnderline,
21324 resolveTo: resolveToSetextUnderline
21325 };
21326 }));
21327
21328 //#endregion
21329 //#region node_modules/micromark-core-commonmark/index.js
21330 var init_micromark_core_commonmark = __esmMin((() => {
21331 init_attention();
21332 init_autolink();
21333 init_blank_line();
21334 init_block_quote();
21335 init_character_escape();
21336 init_character_reference();
21337 init_code_fenced();
21338 init_code_indented();
21339 init_code_text();
21340 init_content();
21341 init_definition();
21342 init_hard_break_escape();
21343 init_heading_atx();
21344 init_html_flow();
21345 init_html_text();
21346 init_label_end();
21347 init_label_start_image();
21348 init_label_start_link();
21349 init_line_ending();
21350 init_list$1();
21351 init_setext_underline();
21352 init_thematic_break$1();
21353 }));
21354
21355 //#endregion
21356 //#region node_modules/micromark/lib/initialize/flow.js
21357 /**
21358 * @this {TokenizeContext}
21359 * @type {Initializer}
21360 */
21361 function initializeFlow(effects) {
21362 const self = this;
21363 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")));
21364 return initial;
21365 /** @type {State} */
21366 function atBlankEnding(code) {
21367 if (code === null) {
21368 effects.consume(code);
21369 return;
21370 }
21371 effects.enter("lineEndingBlank");
21372 effects.consume(code);
21373 effects.exit("lineEndingBlank");
21374 self.currentConstruct = void 0;
21375 return initial;
21376 }
21377 /** @type {State} */
21378 function afterConstruct(code) {
21379 if (code === null) {
21380 effects.consume(code);
21381 return;
21382 }
21383 effects.enter("lineEnding");
21384 effects.consume(code);
21385 effects.exit("lineEnding");
21386 self.currentConstruct = void 0;
21387 return initial;
21388 }
21389 }
21390 var flow$1;
21391 var init_flow = __esmMin((() => {
21392 init_micromark_core_commonmark();
21393 init_micromark_factory_space();
21394 flow$1 = { tokenize: initializeFlow };
21395 }));
21396
21397 //#endregion
21398 //#region node_modules/micromark/lib/initialize/text.js
21399 /**
21400 * @param {'string' | 'text'} field
21401 * @returns {InitialConstruct}
21402 */
21403 function initializeFactory(field) {
21404 return {
21405 tokenize: initializeText,
21406 resolveAll: createResolver(field === "text" ? resolveAllLineSuffixes : void 0)
21407 };
21408 /**
21409 * @this {TokenizeContext}
21410 * @type {Initializer}
21411 */
21412 function initializeText(effects) {
21413 const self = this;
21414 const constructs = this.parser.constructs[field];
21415 const text = effects.attempt(constructs, start, notText);
21416 return start;
21417 /** @type {State} */
21418 function start(code) {
21419 return atBreak(code) ? text(code) : notText(code);
21420 }
21421 /** @type {State} */
21422 function notText(code) {
21423 if (code === null) {
21424 effects.consume(code);
21425 return;
21426 }
21427 effects.enter("data");
21428 effects.consume(code);
21429 return data;
21430 }
21431 /** @type {State} */
21432 function data(code) {
21433 if (atBreak(code)) {
21434 effects.exit("data");
21435 return text(code);
21436 }
21437 effects.consume(code);
21438 return data;
21439 }
21440 /**
21441 * @param {Code} code
21442 * @returns {boolean}
21443 */
21444 function atBreak(code) {
21445 if (code === null) return true;
21446 const list = constructs[code];
21447 let index = -1;
21448 if (list) while (++index < list.length) {
21449 const item = list[index];
21450 if (!item.previous || item.previous.call(self, self.previous)) return true;
21451 }
21452 return false;
21453 }
21454 }
21455 }
21456 /**
21457 * @param {Resolver | undefined} [extraResolver]
21458 * @returns {Resolver}
21459 */
21460 function createResolver(extraResolver) {
21461 return resolveAllText;
21462 /** @type {Resolver} */
21463 function resolveAllText(events, context) {
21464 let index = -1;
21465 /** @type {number | undefined} */
21466 let enter;
21467 while (++index <= events.length) if (enter === void 0) {
21468 if (events[index] && events[index][1].type === "data") {
21469 enter = index;
21470 index++;
21471 }
21472 } else if (!events[index] || events[index][1].type !== "data") {
21473 if (index !== enter + 2) {
21474 events[enter][1].end = events[index - 1][1].end;
21475 events.splice(enter + 2, index - enter - 2);
21476 index = enter + 2;
21477 }
21478 enter = void 0;
21479 }
21480 return extraResolver ? extraResolver(events, context) : events;
21481 }
21482 }
21483 /**
21484 * A rather ugly set of instructions which again looks at chunks in the input
21485 * stream.
21486 * The reason to do this here is that it is *much* faster to parse in reverse.
21487 * And that we can’t hook into `null` to split the line suffix before an EOF.
21488 * To do: figure out if we can make this into a clean utility, or even in core.
21489 * As it will be useful for GFMs literal autolink extension (and maybe even
21490 * tables?)
21491 *
21492 * @type {Resolver}
21493 */
21494 function resolveAllLineSuffixes(events, context) {
21495 let eventIndex = 0;
21496 while (++eventIndex <= events.length) if ((eventIndex === events.length || events[eventIndex][1].type === "lineEnding") && events[eventIndex - 1][1].type === "data") {
21497 const data = events[eventIndex - 1][1];
21498 const chunks = context.sliceStream(data);
21499 let index = chunks.length;
21500 let bufferIndex = -1;
21501 let size = 0;
21502 /** @type {boolean | undefined} */
21503 let tabs;
21504 while (index--) {
21505 const chunk = chunks[index];
21506 if (typeof chunk === "string") {
21507 bufferIndex = chunk.length;
21508 while (chunk.charCodeAt(bufferIndex - 1) === 32) {
21509 size++;
21510 bufferIndex--;
21511 }
21512 if (bufferIndex) break;
21513 bufferIndex = -1;
21514 } else if (chunk === -2) {
21515 tabs = true;
21516 size++;
21517 } else if (chunk === -1) {} else {
21518 index++;
21519 break;
21520 }
21521 }
21522 if (size) {
21523 const token = {
21524 type: eventIndex === events.length || tabs || size < 2 ? "lineSuffix" : "hardBreakTrailing",
21525 start: {
21526 line: data.end.line,
21527 column: data.end.column - size,
21528 offset: data.end.offset - size,
21529 _index: data.start._index + index,
21530 _bufferIndex: index ? bufferIndex : data.start._bufferIndex + bufferIndex
21531 },
21532 end: Object.assign({}, data.end)
21533 };
21534 data.end = Object.assign({}, token.start);
21535 if (data.start.offset === data.end.offset) Object.assign(data, token);
21536 else {
21537 events.splice(eventIndex, 0, [
21538 "enter",
21539 token,
21540 context
21541 ], [
21542 "exit",
21543 token,
21544 context
21545 ]);
21546 eventIndex += 2;
21547 }
21548 }
21549 eventIndex++;
21550 }
21551 return events;
21552 }
21553 var resolver, string$1, text$2;
21554 var init_text$1 = __esmMin((() => {
21555 resolver = { resolveAll: createResolver() };
21556 string$1 = initializeFactory("string");
21557 text$2 = initializeFactory("text");
21558 }));
21559
21560 //#endregion
21561 //#region node_modules/micromark/lib/create-tokenizer.js
21562 /**
21563 * Create a tokenizer.
21564 * Tokenizers deal with one type of data (e.g., containers, flow, text).
21565 * The parser is the object dealing with it all.
21566 * `initialize` works like other constructs, except that only its `tokenize`
21567 * function is used, in which case it doesn’t receive an `ok` or `nok`.
21568 * `from` can be given to set the point before the first character, although
21569 * when further lines are indented, they must be set with `defineSkip`.
21570 *
21571 * @param {ParseContext} parser
21572 * @param {InitialConstruct} initialize
21573 * @param {Omit<Point, '_bufferIndex' | '_index'> | undefined} [from]
21574 * @returns {TokenizeContext}
21575 */
21576 function createTokenizer(parser, initialize, from) {
21577 /** @type {Point} */
21578 let point = Object.assign(from ? Object.assign({}, from) : {
21579 line: 1,
21580 column: 1,
21581 offset: 0
21582 }, {
21583 _index: 0,
21584 _bufferIndex: -1
21585 });
21586 /** @type {Record<string, number>} */
21587 const columnStart = {};
21588 /** @type {Array<Construct>} */
21589 const resolveAllConstructs = [];
21590 /** @type {Array<Chunk>} */
21591 let chunks = [];
21592 /** @type {Array<Token>} */
21593 let stack = [];
21594 /**
21595 * Tools used for tokenizing.
21596 *
21597 * @type {Effects}
21598 */
21599 const effects = {
21600 consume,
21601 enter,
21602 exit,
21603 attempt: constructFactory(onsuccessfulconstruct),
21604 check: constructFactory(onsuccessfulcheck),
21605 interrupt: constructFactory(onsuccessfulcheck, { interrupt: true })
21606 };
21607 /**
21608 * State and tools for resolving and serializing.
21609 *
21610 * @type {TokenizeContext}
21611 */
21612 const context = {
21613 previous: null,
21614 code: null,
21615 containerState: {},
21616 events: [],
21617 parser,
21618 sliceStream,
21619 sliceSerialize,
21620 now,
21621 defineSkip,
21622 write
21623 };
21624 /**
21625 * The state function.
21626 *
21627 * @type {State | void}
21628 */
21629 let state = initialize.tokenize.call(context, effects);
21630 if (initialize.resolveAll) resolveAllConstructs.push(initialize);
21631 return context;
21632 /** @type {TokenizeContext['write']} */
21633 function write(slice) {
21634 chunks = push(chunks, slice);
21635 main();
21636 if (chunks[chunks.length - 1] !== null) return [];
21637 addResult(initialize, 0);
21638 context.events = resolveAll(resolveAllConstructs, context.events, context);
21639 return context.events;
21640 }
21641 /** @type {TokenizeContext['sliceSerialize']} */
21642 function sliceSerialize(token, expandTabs) {
21643 return serializeChunks(sliceStream(token), expandTabs);
21644 }
21645 /** @type {TokenizeContext['sliceStream']} */
21646 function sliceStream(token) {
21647 return sliceChunks(chunks, token);
21648 }
21649 /** @type {TokenizeContext['now']} */
21650 function now() {
21651 const { line, column, offset, _index, _bufferIndex } = point;
21652 return {
21653 line,
21654 column,
21655 offset,
21656 _index,
21657 _bufferIndex
21658 };
21659 }
21660 /** @type {TokenizeContext['defineSkip']} */
21661 function defineSkip(value) {
21662 columnStart[value.line] = value.column;
21663 accountForPotentialSkip();
21664 }
21665 /**
21666 * Main loop (note that `_index` and `_bufferIndex` in `point` are modified by
21667 * `consume`).
21668 * Here is where we walk through the chunks, which either include strings of
21669 * several characters, or numerical character codes.
21670 * The reason to do this in a loop instead of a call is so the stack can
21671 * drain.
21672 *
21673 * @returns {void}
21674 */
21675 function main() {
21676 /** @type {number} */
21677 let chunkIndex;
21678 while (point._index < chunks.length) {
21679 const chunk = chunks[point._index];
21680 if (typeof chunk === "string") {
21681 chunkIndex = point._index;
21682 if (point._bufferIndex < 0) point._bufferIndex = 0;
21683 while (point._index === chunkIndex && point._bufferIndex < chunk.length) go(chunk.charCodeAt(point._bufferIndex));
21684 } else go(chunk);
21685 }
21686 }
21687 /**
21688 * Deal with one code.
21689 *
21690 * @param {Code} code
21691 * @returns {void}
21692 */
21693 function go(code) {
21694 state = state(code);
21695 }
21696 /** @type {Effects['consume']} */
21697 function consume(code) {
21698 if (markdownLineEnding(code)) {
21699 point.line++;
21700 point.column = 1;
21701 point.offset += code === -3 ? 2 : 1;
21702 accountForPotentialSkip();
21703 } else if (code !== -1) {
21704 point.column++;
21705 point.offset++;
21706 }
21707 if (point._bufferIndex < 0) point._index++;
21708 else {
21709 point._bufferIndex++;
21710 if (point._bufferIndex === chunks[point._index].length) {
21711 point._bufferIndex = -1;
21712 point._index++;
21713 }
21714 }
21715 context.previous = code;
21716 }
21717 /** @type {Effects['enter']} */
21718 function enter(type, fields) {
21719 /** @type {Token} */
21720 const token = fields || {};
21721 token.type = type;
21722 token.start = now();
21723 context.events.push([
21724 "enter",
21725 token,
21726 context
21727 ]);
21728 stack.push(token);
21729 return token;
21730 }
21731 /** @type {Effects['exit']} */
21732 function exit(type) {
21733 const token = stack.pop();
21734 token.end = now();
21735 context.events.push([
21736 "exit",
21737 token,
21738 context
21739 ]);
21740 return token;
21741 }
21742 /**
21743 * Use results.
21744 *
21745 * @type {ReturnHandle}
21746 */
21747 function onsuccessfulconstruct(construct, info) {
21748 addResult(construct, info.from);
21749 }
21750 /**
21751 * Discard results.
21752 *
21753 * @type {ReturnHandle}
21754 */
21755 function onsuccessfulcheck(_, info) {
21756 info.restore();
21757 }
21758 /**
21759 * Factory to attempt/check/interrupt.
21760 *
21761 * @param {ReturnHandle} onreturn
21762 * @param {{interrupt?: boolean | undefined} | undefined} [fields]
21763 */
21764 function constructFactory(onreturn, fields) {
21765 return hook;
21766 /**
21767 * Handle either an object mapping codes to constructs, a list of
21768 * constructs, or a single construct.
21769 *
21770 * @param {Array<Construct> | Construct | ConstructRecord} constructs
21771 * @param {State} returnState
21772 * @param {State | undefined} [bogusState]
21773 * @returns {State}
21774 */
21775 function hook(constructs, returnState, bogusState) {
21776 /** @type {Array<Construct>} */
21777 let listOfConstructs;
21778 /** @type {number} */
21779 let constructIndex;
21780 /** @type {Construct} */
21781 let currentConstruct;
21782 /** @type {Info} */
21783 let info;
21784 return Array.isArray(constructs) ? handleListOfConstructs(constructs) : "tokenize" in constructs ? handleListOfConstructs([constructs]) : handleMapOfConstructs(constructs);
21785 /**
21786 * Handle a list of construct.
21787 *
21788 * @param {ConstructRecord} map
21789 * @returns {State}
21790 */
21791 function handleMapOfConstructs(map) {
21792 return start;
21793 /** @type {State} */
21794 function start(code) {
21795 const def = code !== null && map[code];
21796 const all = code !== null && map.null;
21797 return handleListOfConstructs([...Array.isArray(def) ? def : def ? [def] : [], ...Array.isArray(all) ? all : all ? [all] : []])(code);
21798 }
21799 }
21800 /**
21801 * Handle a list of construct.
21802 *
21803 * @param {Array<Construct>} list
21804 * @returns {State}
21805 */
21806 function handleListOfConstructs(list) {
21807 listOfConstructs = list;
21808 constructIndex = 0;
21809 if (list.length === 0) return bogusState;
21810 return handleConstruct(list[constructIndex]);
21811 }
21812 /**
21813 * Handle a single construct.
21814 *
21815 * @param {Construct} construct
21816 * @returns {State}
21817 */
21818 function handleConstruct(construct) {
21819 return start;
21820 /** @type {State} */
21821 function start(code) {
21822 info = store();
21823 currentConstruct = construct;
21824 if (!construct.partial) context.currentConstruct = construct;
21825 if (construct.name && context.parser.constructs.disable.null.includes(construct.name)) return nok(code);
21826 return construct.tokenize.call(fields ? Object.assign(Object.create(context), fields) : context, effects, ok, nok)(code);
21827 }
21828 }
21829 /** @type {State} */
21830 function ok(code) {
21831 onreturn(currentConstruct, info);
21832 return returnState;
21833 }
21834 /** @type {State} */
21835 function nok(code) {
21836 info.restore();
21837 if (++constructIndex < listOfConstructs.length) return handleConstruct(listOfConstructs[constructIndex]);
21838 return bogusState;
21839 }
21840 }
21841 }
21842 /**
21843 * @param {Construct} construct
21844 * @param {number} from
21845 * @returns {void}
21846 */
21847 function addResult(construct, from) {
21848 if (construct.resolveAll && !resolveAllConstructs.includes(construct)) resolveAllConstructs.push(construct);
21849 if (construct.resolve) splice(context.events, from, context.events.length - from, construct.resolve(context.events.slice(from), context));
21850 if (construct.resolveTo) context.events = construct.resolveTo(context.events, context);
21851 }
21852 /**
21853 * Store state.
21854 *
21855 * @returns {Info}
21856 */
21857 function store() {
21858 const startPoint = now();
21859 const startPrevious = context.previous;
21860 const startCurrentConstruct = context.currentConstruct;
21861 const startEventsIndex = context.events.length;
21862 const startStack = Array.from(stack);
21863 return {
21864 restore,
21865 from: startEventsIndex
21866 };
21867 /**
21868 * Restore state.
21869 *
21870 * @returns {void}
21871 */
21872 function restore() {
21873 point = startPoint;
21874 context.previous = startPrevious;
21875 context.currentConstruct = startCurrentConstruct;
21876 context.events.length = startEventsIndex;
21877 stack = startStack;
21878 accountForPotentialSkip();
21879 }
21880 }
21881 /**
21882 * Move the current point a bit forward in the line when it’s on a column
21883 * skip.
21884 *
21885 * @returns {void}
21886 */
21887 function accountForPotentialSkip() {
21888 if (point.line in columnStart && point.column < 2) {
21889 point.column = columnStart[point.line];
21890 point.offset += columnStart[point.line] - 1;
21891 }
21892 }
21893 }
21894 /**
21895 * Get the chunks from a slice of chunks in the range of a token.
21896 *
21897 * @param {Array<Chunk>} chunks
21898 * @param {Pick<Token, 'end' | 'start'>} token
21899 * @returns {Array<Chunk>}
21900 */
21901 function sliceChunks(chunks, token) {
21902 const startIndex = token.start._index;
21903 const startBufferIndex = token.start._bufferIndex;
21904 const endIndex = token.end._index;
21905 const endBufferIndex = token.end._bufferIndex;
21906 /** @type {Array<Chunk>} */
21907 let view;
21908 if (startIndex === endIndex) view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)];
21909 else {
21910 view = chunks.slice(startIndex, endIndex);
21911 if (startBufferIndex > -1) {
21912 const head = view[0];
21913 if (typeof head === "string") view[0] = head.slice(startBufferIndex);
21914 else view.shift();
21915 }
21916 if (endBufferIndex > 0) view.push(chunks[endIndex].slice(0, endBufferIndex));
21917 }
21918 return view;
21919 }
21920 /**
21921 * Get the string value of a slice of chunks.
21922 *
21923 * @param {Array<Chunk>} chunks
21924 * @param {boolean | undefined} [expandTabs=false]
21925 * @returns {string}
21926 */
21927 function serializeChunks(chunks, expandTabs) {
21928 let index = -1;
21929 /** @type {Array<string>} */
21930 const result = [];
21931 /** @type {boolean | undefined} */
21932 let atTab;
21933 while (++index < chunks.length) {
21934 const chunk = chunks[index];
21935 /** @type {string} */
21936 let value;
21937 if (typeof chunk === "string") value = chunk;
21938 else switch (chunk) {
21939 case -5:
21940 value = "\r";
21941 break;
21942 case -4:
21943 value = "\n";
21944 break;
21945 case -3:
21946 value = "\r\n";
21947 break;
21948 case -2:
21949 value = expandTabs ? " " : " ";
21950 break;
21951 case -1:
21952 if (!expandTabs && atTab) continue;
21953 value = " ";
21954 break;
21955 default: value = String.fromCharCode(chunk);
21956 }
21957 atTab = chunk === -2;
21958 result.push(value);
21959 }
21960 return result.join("");
21961 }
21962 var init_create_tokenizer = __esmMin((() => {
21963 init_micromark_util_character();
21964 init_micromark_util_chunked();
21965 init_micromark_util_resolve_all();
21966 }));
21967
21968 //#endregion
21969 //#region node_modules/micromark/lib/constructs.js
21970 var constructs_exports = /* @__PURE__ */ __exportAll({
21971 attentionMarkers: () => attentionMarkers,
21972 contentInitial: () => contentInitial,
21973 disable: () => disable,
21974 document: () => document$1,
21975 flow: () => flow,
21976 flowInitial: () => flowInitial,
21977 insideSpan: () => insideSpan,
21978 string: () => string,
21979 text: () => text$1
21980 });
21981 var document$1, contentInitial, flowInitial, flow, string, text$1, insideSpan, attentionMarkers, disable;
21982 var init_constructs = __esmMin((() => {
21983 init_micromark_core_commonmark();
21984 init_text$1();
21985 document$1 = {
21986 [42]: list$1,
21987 [43]: list$1,
21988 [45]: list$1,
21989 [48]: list$1,
21990 [49]: list$1,
21991 [50]: list$1,
21992 [51]: list$1,
21993 [52]: list$1,
21994 [53]: list$1,
21995 [54]: list$1,
21996 [55]: list$1,
21997 [56]: list$1,
21998 [57]: list$1,
21999 [62]: blockQuote
22000 };
22001 contentInitial = { [91]: definition };
22002 flowInitial = {
22003 [-2]: codeIndented,
22004 [-1]: codeIndented,
22005 [32]: codeIndented
22006 };
22007 flow = {
22008 [35]: headingAtx,
22009 [42]: thematicBreak$1,
22010 [45]: [setextUnderline, thematicBreak$1],
22011 [60]: htmlFlow,
22012 [61]: setextUnderline,
22013 [95]: thematicBreak$1,
22014 [96]: codeFenced,
22015 [126]: codeFenced
22016 };
22017 string = {
22018 [38]: characterReference,
22019 [92]: characterEscape
22020 };
22021 text$1 = {
22022 [-5]: lineEnding,
22023 [-4]: lineEnding,
22024 [-3]: lineEnding,
22025 [33]: labelStartImage,
22026 [38]: characterReference,
22027 [42]: attention,
22028 [60]: [autolink, htmlText],
22029 [91]: labelStartLink,
22030 [92]: [hardBreakEscape, characterEscape],
22031 [93]: labelEnd,
22032 [95]: attention,
22033 [96]: codeText
22034 };
22035 insideSpan = { null: [attention, resolver] };
22036 attentionMarkers = { null: [42, 95] };
22037 disable = { null: [] };
22038 }));
22039
22040 //#endregion
22041 //#region node_modules/micromark/lib/parse.js
22042 /**
22043 * @param {ParseOptions | null | undefined} [options]
22044 * @returns {ParseContext}
22045 */
22046 function parse(options) {
22047 /** @type {ParseContext} */
22048 const parser = {
22049 defined: [],
22050 lazy: {},
22051 constructs: combineExtensions([constructs_exports, ...(options || {}).extensions || []]),
22052 content: create(content$1),
22053 document: create(document$2),
22054 flow: create(flow$1),
22055 string: create(string$1),
22056 text: create(text$2)
22057 };
22058 return parser;
22059 /**
22060 * @param {InitialConstruct} initial
22061 */
22062 function create(initial) {
22063 return creator;
22064 /** @type {Create} */
22065 function creator(from) {
22066 return createTokenizer(parser, initial, from);
22067 }
22068 }
22069 }
22070 var init_parse = __esmMin((() => {
22071 init_micromark_util_combine_extensions();
22072 init_content$1();
22073 init_document();
22074 init_flow();
22075 init_text$1();
22076 init_create_tokenizer();
22077 init_constructs();
22078 }));
22079
22080 //#endregion
22081 //#region node_modules/micromark/lib/preprocess.js
22082 /**
22083 * @returns {Preprocessor}
22084 */
22085 function preprocess() {
22086 let column = 1;
22087 let buffer = "";
22088 /** @type {boolean | undefined} */
22089 let start = true;
22090 /** @type {boolean | undefined} */
22091 let atCarriageReturn;
22092 return preprocessor;
22093 /** @type {Preprocessor} */
22094 function preprocessor(value, encoding, end) {
22095 /** @type {Array<Chunk>} */
22096 const chunks = [];
22097 /** @type {RegExpMatchArray | null} */
22098 let match;
22099 /** @type {number} */
22100 let next;
22101 /** @type {number} */
22102 let startPosition;
22103 /** @type {number} */
22104 let endPosition;
22105 /** @type {Code} */
22106 let code;
22107 value = buffer + value.toString(encoding);
22108 startPosition = 0;
22109 buffer = "";
22110 if (start) {
22111 if (value.charCodeAt(0) === 65279) startPosition++;
22112 start = void 0;
22113 }
22114 while (startPosition < value.length) {
22115 search.lastIndex = startPosition;
22116 match = search.exec(value);
22117 endPosition = match && match.index !== void 0 ? match.index : value.length;
22118 code = value.charCodeAt(endPosition);
22119 if (!match) {
22120 buffer = value.slice(startPosition);
22121 break;
22122 }
22123 if (code === 10 && startPosition === endPosition && atCarriageReturn) {
22124 chunks.push(-3);
22125 atCarriageReturn = void 0;
22126 } else {
22127 if (atCarriageReturn) {
22128 chunks.push(-5);
22129 atCarriageReturn = void 0;
22130 }
22131 if (startPosition < endPosition) {
22132 chunks.push(value.slice(startPosition, endPosition));
22133 column += endPosition - startPosition;
22134 }
22135 switch (code) {
22136 case 0:
22137 chunks.push(65533);
22138 column++;
22139 break;
22140 case 9:
22141 next = Math.ceil(column / 4) * 4;
22142 chunks.push(-2);
22143 while (column++ < next) chunks.push(-1);
22144 break;
22145 case 10:
22146 chunks.push(-4);
22147 column = 1;
22148 break;
22149 default:
22150 atCarriageReturn = true;
22151 column = 1;
22152 }
22153 }
22154 startPosition = endPosition + 1;
22155 }
22156 if (end) {
22157 if (atCarriageReturn) chunks.push(-5);
22158 if (buffer) chunks.push(buffer);
22159 chunks.push(null);
22160 }
22161 return chunks;
22162 }
22163 }
22164 var search;
22165 var init_preprocess = __esmMin((() => {
22166 search = /[\0\t\n\r]/g;
22167 }));
22168
22169 //#endregion
22170 //#region node_modules/micromark/lib/postprocess.js
22171 /**
22172 * @param {Array<Event>} events
22173 * @returns {Array<Event>}
22174 */
22175 function postprocess(events) {
22176 while (!subtokenize(events));
22177 return events;
22178 }
22179 var init_postprocess = __esmMin((() => {
22180 init_micromark_util_subtokenize();
22181 }));
22182
22183 //#endregion
22184 //#region node_modules/micromark-util-decode-numeric-character-reference/index.js
22185 /**
22186 * Turn the number (in string form as either hexa- or plain decimal) coming from
22187 * a numeric character reference into a character.
22188 *
22189 * Sort of like `String.fromCharCode(Number.parseInt(value, base))`, but makes
22190 * non-characters and control characters safe.
22191 *
22192 * @param {string} value
22193 * Value to decode.
22194 * @param {number} base
22195 * Numeric base.
22196 * @returns {string}
22197 * Character.
22198 */
22199 function decodeNumericCharacterReference(value, base) {
22200 const code = Number.parseInt(value, base);
22201 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 "�";
22202 return String.fromCharCode(code);
22203 }
22204 var init_micromark_util_decode_numeric_character_reference = __esmMin((() => {}));
22205
22206 //#endregion
22207 //#region node_modules/micromark-util-decode-string/index.js
22208 /**
22209 * Decode markdown strings (which occur in places such as fenced code info
22210 * strings, destinations, labels, and titles).
22211 *
22212 * The “string” content type allows character escapes and -references.
22213 * This decodes those.
22214 *
22215 * @param {string} value
22216 * Value to decode.
22217 * @returns {string}
22218 * Decoded value.
22219 */
22220 function decodeString(value) {
22221 return value.replace(characterEscapeOrReference, decode);
22222 }
22223 /**
22224 * @param {string} $0
22225 * @param {string} $1
22226 * @param {string} $2
22227 * @returns {string}
22228 */
22229 function decode($0, $1, $2) {
22230 if ($1) return $1;
22231 if ($2.charCodeAt(0) === 35) {
22232 const head = $2.charCodeAt(1);
22233 const hex = head === 120 || head === 88;
22234 return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10);
22235 }
22236 return decodeNamedCharacterReference($2) || $0;
22237 }
22238 var characterEscapeOrReference;
22239 var init_micromark_util_decode_string = __esmMin((() => {
22240 init_index_dom();
22241 init_micromark_util_decode_numeric_character_reference();
22242 characterEscapeOrReference = /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;
22243 }));
22244
22245 //#endregion
22246 //#region node_modules/mdast-util-from-markdown/lib/index.js
22247 /**
22248 * Note this compiler only understand complete buffering, not streaming.
22249 *
22250 * @param {Options | null | undefined} [options]
22251 */
22252 function compiler(options) {
22253 /** @type {Config} */
22254 const config = {
22255 transforms: [],
22256 canContainEols: [
22257 "emphasis",
22258 "fragment",
22259 "heading",
22260 "paragraph",
22261 "strong"
22262 ],
22263 enter: {
22264 autolink: opener(link),
22265 autolinkProtocol: onenterdata,
22266 autolinkEmail: onenterdata,
22267 atxHeading: opener(heading),
22268 blockQuote: opener(blockQuote),
22269 characterEscape: onenterdata,
22270 characterReference: onenterdata,
22271 codeFenced: opener(codeFlow),
22272 codeFencedFenceInfo: buffer,
22273 codeFencedFenceMeta: buffer,
22274 codeIndented: opener(codeFlow, buffer),
22275 codeText: opener(codeText, buffer),
22276 codeTextData: onenterdata,
22277 data: onenterdata,
22278 codeFlowValue: onenterdata,
22279 definition: opener(definition),
22280 definitionDestinationString: buffer,
22281 definitionLabelString: buffer,
22282 definitionTitleString: buffer,
22283 emphasis: opener(emphasis),
22284 hardBreakEscape: opener(hardBreak),
22285 hardBreakTrailing: opener(hardBreak),
22286 htmlFlow: opener(html, buffer),
22287 htmlFlowData: onenterdata,
22288 htmlText: opener(html, buffer),
22289 htmlTextData: onenterdata,
22290 image: opener(image),
22291 label: buffer,
22292 link: opener(link),
22293 listItem: opener(listItem),
22294 listItemValue: onenterlistitemvalue,
22295 listOrdered: opener(list, onenterlistordered),
22296 listUnordered: opener(list),
22297 paragraph: opener(paragraph),
22298 reference: onenterreference,
22299 referenceString: buffer,
22300 resourceDestinationString: buffer,
22301 resourceTitleString: buffer,
22302 setextHeading: opener(heading),
22303 strong: opener(strong),
22304 thematicBreak: opener(thematicBreak)
22305 },
22306 exit: {
22307 atxHeading: closer(),
22308 atxHeadingSequence: onexitatxheadingsequence,
22309 autolink: closer(),
22310 autolinkEmail: onexitautolinkemail,
22311 autolinkProtocol: onexitautolinkprotocol,
22312 blockQuote: closer(),
22313 characterEscapeValue: onexitdata,
22314 characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker,
22315 characterReferenceMarkerNumeric: onexitcharacterreferencemarker,
22316 characterReferenceValue: onexitcharacterreferencevalue,
22317 codeFenced: closer(onexitcodefenced),
22318 codeFencedFence: onexitcodefencedfence,
22319 codeFencedFenceInfo: onexitcodefencedfenceinfo,
22320 codeFencedFenceMeta: onexitcodefencedfencemeta,
22321 codeFlowValue: onexitdata,
22322 codeIndented: closer(onexitcodeindented),
22323 codeText: closer(onexitcodetext),
22324 codeTextData: onexitdata,
22325 data: onexitdata,
22326 definition: closer(),
22327 definitionDestinationString: onexitdefinitiondestinationstring,
22328 definitionLabelString: onexitdefinitionlabelstring,
22329 definitionTitleString: onexitdefinitiontitlestring,
22330 emphasis: closer(),
22331 hardBreakEscape: closer(onexithardbreak),
22332 hardBreakTrailing: closer(onexithardbreak),
22333 htmlFlow: closer(onexithtmlflow),
22334 htmlFlowData: onexitdata,
22335 htmlText: closer(onexithtmltext),
22336 htmlTextData: onexitdata,
22337 image: closer(onexitimage),
22338 label: onexitlabel,
22339 labelText: onexitlabeltext,
22340 lineEnding: onexitlineending,
22341 link: closer(onexitlink),
22342 listItem: closer(),
22343 listOrdered: closer(),
22344 listUnordered: closer(),
22345 paragraph: closer(),
22346 referenceString: onexitreferencestring,
22347 resourceDestinationString: onexitresourcedestinationstring,
22348 resourceTitleString: onexitresourcetitlestring,
22349 resource: onexitresource,
22350 setextHeading: closer(onexitsetextheading),
22351 setextHeadingLineSequence: onexitsetextheadinglinesequence,
22352 setextHeadingText: onexitsetextheadingtext,
22353 strong: closer(),
22354 thematicBreak: closer()
22355 }
22356 };
22357 configure(config, (options || {}).mdastExtensions || []);
22358 /** @type {CompileData} */
22359 const data = {};
22360 return compile;
22361 /**
22362 * Turn micromark events into an mdast tree.
22363 *
22364 * @param {Array<Event>} events
22365 * Events.
22366 * @returns {Root}
22367 * mdast tree.
22368 */
22369 function compile(events) {
22370 /** @type {Root} */
22371 let tree = {
22372 type: "root",
22373 children: []
22374 };
22375 /** @type {Omit<CompileContext, 'sliceSerialize'>} */
22376 const context = {
22377 stack: [tree],
22378 tokenStack: [],
22379 config,
22380 enter,
22381 exit,
22382 buffer,
22383 resume,
22384 setData,
22385 getData
22386 };
22387 /** @type {Array<number>} */
22388 const listStack = [];
22389 let index = -1;
22390 while (++index < events.length) if (events[index][1].type === "listOrdered" || events[index][1].type === "listUnordered") if (events[index][0] === "enter") listStack.push(index);
22391 else index = prepareList(events, listStack.pop(), index);
22392 index = -1;
22393 while (++index < events.length) {
22394 const handler = config[events[index][0]];
22395 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]);
22396 }
22397 if (context.tokenStack.length > 0) {
22398 const tail = context.tokenStack[context.tokenStack.length - 1];
22399 (tail[1] || defaultOnError).call(context, void 0, tail[0]);
22400 }
22401 tree.position = {
22402 start: point$1(events.length > 0 ? events[0][1].start : {
22403 line: 1,
22404 column: 1,
22405 offset: 0
22406 }),
22407 end: point$1(events.length > 0 ? events[events.length - 2][1].end : {
22408 line: 1,
22409 column: 1,
22410 offset: 0
22411 })
22412 };
22413 index = -1;
22414 while (++index < config.transforms.length) tree = config.transforms[index](tree) || tree;
22415 return tree;
22416 }
22417 /**
22418 * @param {Array<Event>} events
22419 * @param {number} start
22420 * @param {number} length
22421 * @returns {number}
22422 */
22423 function prepareList(events, start, length) {
22424 let index = start - 1;
22425 let containerBalance = -1;
22426 let listSpread = false;
22427 /** @type {Token | undefined} */
22428 let listItem;
22429 /** @type {number | undefined} */
22430 let lineIndex;
22431 /** @type {number | undefined} */
22432 let firstBlankLineIndex;
22433 /** @type {boolean | undefined} */
22434 let atMarker;
22435 while (++index <= length) {
22436 const event = events[index];
22437 if (event[1].type === "listUnordered" || event[1].type === "listOrdered" || event[1].type === "blockQuote") {
22438 if (event[0] === "enter") containerBalance++;
22439 else containerBalance--;
22440 atMarker = void 0;
22441 } else if (event[1].type === "lineEndingBlank") {
22442 if (event[0] === "enter") {
22443 if (listItem && !atMarker && !containerBalance && !firstBlankLineIndex) firstBlankLineIndex = index;
22444 atMarker = void 0;
22445 }
22446 } 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;
22447 if (!containerBalance && event[0] === "enter" && event[1].type === "listItemPrefix" || containerBalance === -1 && event[0] === "exit" && (event[1].type === "listUnordered" || event[1].type === "listOrdered")) {
22448 if (listItem) {
22449 let tailIndex = index;
22450 lineIndex = void 0;
22451 while (tailIndex--) {
22452 const tailEvent = events[tailIndex];
22453 if (tailEvent[1].type === "lineEnding" || tailEvent[1].type === "lineEndingBlank") {
22454 if (tailEvent[0] === "exit") continue;
22455 if (lineIndex) {
22456 events[lineIndex][1].type = "lineEndingBlank";
22457 listSpread = true;
22458 }
22459 tailEvent[1].type = "lineEnding";
22460 lineIndex = tailIndex;
22461 } else if (tailEvent[1].type === "linePrefix" || tailEvent[1].type === "blockQuotePrefix" || tailEvent[1].type === "blockQuotePrefixWhitespace" || tailEvent[1].type === "blockQuoteMarker" || tailEvent[1].type === "listItemIndent") {} else break;
22462 }
22463 if (firstBlankLineIndex && (!lineIndex || firstBlankLineIndex < lineIndex)) listItem._spread = true;
22464 listItem.end = Object.assign({}, lineIndex ? events[lineIndex][1].start : event[1].end);
22465 events.splice(lineIndex || index, 0, [
22466 "exit",
22467 listItem,
22468 event[2]
22469 ]);
22470 index++;
22471 length++;
22472 }
22473 if (event[1].type === "listItemPrefix") {
22474 listItem = {
22475 type: "listItem",
22476 _spread: false,
22477 start: Object.assign({}, event[1].start),
22478 end: void 0
22479 };
22480 events.splice(index, 0, [
22481 "enter",
22482 listItem,
22483 event[2]
22484 ]);
22485 index++;
22486 length++;
22487 firstBlankLineIndex = void 0;
22488 atMarker = true;
22489 }
22490 }
22491 }
22492 events[start][1]._spread = listSpread;
22493 return length;
22494 }
22495 /**
22496 * Set data.
22497 *
22498 * @template {keyof CompileData} Key
22499 * Field type.
22500 * @param {Key} key
22501 * Key of field.
22502 * @param {CompileData[Key]} [value]
22503 * New value.
22504 * @returns {void}
22505 * Nothing.
22506 */
22507 function setData(key, value) {
22508 data[key] = value;
22509 }
22510 /**
22511 * Get data.
22512 *
22513 * @template {keyof CompileData} Key
22514 * Field type.
22515 * @param {Key} key
22516 * Key of field.
22517 * @returns {CompileData[Key]}
22518 * Value.
22519 */
22520 function getData(key) {
22521 return data[key];
22522 }
22523 /**
22524 * Create an opener handle.
22525 *
22526 * @param {(token: Token) => Node} create
22527 * Create a node.
22528 * @param {Handle} [and]
22529 * Optional function to also run.
22530 * @returns {Handle}
22531 * Handle.
22532 */
22533 function opener(create, and) {
22534 return open;
22535 /**
22536 * @this {CompileContext}
22537 * @param {Token} token
22538 * @returns {void}
22539 */
22540 function open(token) {
22541 enter.call(this, create(token), token);
22542 if (and) and.call(this, token);
22543 }
22544 }
22545 /**
22546 * @this {CompileContext}
22547 * @returns {void}
22548 */
22549 function buffer() {
22550 this.stack.push({
22551 type: "fragment",
22552 children: []
22553 });
22554 }
22555 /**
22556 * @template {Node} Kind
22557 * Node type.
22558 * @this {CompileContext}
22559 * Context.
22560 * @param {Kind} node
22561 * Node to enter.
22562 * @param {Token} token
22563 * Corresponding token.
22564 * @param {OnEnterError | undefined} [errorHandler]
22565 * Handle the case where this token is open, but it is closed by something else.
22566 * @returns {Kind}
22567 * The given node.
22568 */
22569 function enter(node, token, errorHandler) {
22570 this.stack[this.stack.length - 1].children.push(node);
22571 this.stack.push(node);
22572 this.tokenStack.push([token, errorHandler]);
22573 node.position = { start: point$1(token.start) };
22574 return node;
22575 }
22576 /**
22577 * Create a closer handle.
22578 *
22579 * @param {Handle} [and]
22580 * Optional function to also run.
22581 * @returns {Handle}
22582 * Handle.
22583 */
22584 function closer(and) {
22585 return close;
22586 /**
22587 * @this {CompileContext}
22588 * @param {Token} token
22589 * @returns {void}
22590 */
22591 function close(token) {
22592 if (and) and.call(this, token);
22593 exit.call(this, token);
22594 }
22595 }
22596 /**
22597 * @this {CompileContext}
22598 * Context.
22599 * @param {Token} token
22600 * Corresponding token.
22601 * @param {OnExitError | undefined} [onExitError]
22602 * Handle the case where another token is open.
22603 * @returns {Node}
22604 * The closed node.
22605 */
22606 function exit(token, onExitError) {
22607 const node = this.stack.pop();
22608 const open = this.tokenStack.pop();
22609 if (!open) throw new Error("Cannot close `" + token.type + "` (" + stringifyPosition({
22610 start: token.start,
22611 end: token.end
22612 }) + "): it’s not open");
22613 else if (open[0].type !== token.type) if (onExitError) onExitError.call(this, token, open[0]);
22614 else (open[1] || defaultOnError).call(this, token, open[0]);
22615 node.position.end = point$1(token.end);
22616 return node;
22617 }
22618 /**
22619 * @this {CompileContext}
22620 * @returns {string}
22621 */
22622 function resume() {
22623 return toString(this.stack.pop());
22624 }
22625 /**
22626 * @this {CompileContext}
22627 * @type {Handle}
22628 */
22629 function onenterlistordered() {
22630 setData("expectingFirstListItemValue", true);
22631 }
22632 /**
22633 * @this {CompileContext}
22634 * @type {Handle}
22635 */
22636 function onenterlistitemvalue(token) {
22637 if (getData("expectingFirstListItemValue")) {
22638 const ancestor = this.stack[this.stack.length - 2];
22639 ancestor.start = Number.parseInt(this.sliceSerialize(token), 10);
22640 setData("expectingFirstListItemValue");
22641 }
22642 }
22643 /**
22644 * @this {CompileContext}
22645 * @type {Handle}
22646 */
22647 function onexitcodefencedfenceinfo() {
22648 const data = this.resume();
22649 const node = this.stack[this.stack.length - 1];
22650 node.lang = data;
22651 }
22652 /**
22653 * @this {CompileContext}
22654 * @type {Handle}
22655 */
22656 function onexitcodefencedfencemeta() {
22657 const data = this.resume();
22658 const node = this.stack[this.stack.length - 1];
22659 node.meta = data;
22660 }
22661 /**
22662 * @this {CompileContext}
22663 * @type {Handle}
22664 */
22665 function onexitcodefencedfence() {
22666 if (getData("flowCodeInside")) return;
22667 this.buffer();
22668 setData("flowCodeInside", true);
22669 }
22670 /**
22671 * @this {CompileContext}
22672 * @type {Handle}
22673 */
22674 function onexitcodefenced() {
22675 const data = this.resume();
22676 const node = this.stack[this.stack.length - 1];
22677 node.value = data.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, "");
22678 setData("flowCodeInside");
22679 }
22680 /**
22681 * @this {CompileContext}
22682 * @type {Handle}
22683 */
22684 function onexitcodeindented() {
22685 const data = this.resume();
22686 const node = this.stack[this.stack.length - 1];
22687 node.value = data.replace(/(\r?\n|\r)$/g, "");
22688 }
22689 /**
22690 * @this {CompileContext}
22691 * @type {Handle}
22692 */
22693 function onexitdefinitionlabelstring(token) {
22694 const label = this.resume();
22695 const node = this.stack[this.stack.length - 1];
22696 node.label = label;
22697 node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();
22698 }
22699 /**
22700 * @this {CompileContext}
22701 * @type {Handle}
22702 */
22703 function onexitdefinitiontitlestring() {
22704 const data = this.resume();
22705 const node = this.stack[this.stack.length - 1];
22706 node.title = data;
22707 }
22708 /**
22709 * @this {CompileContext}
22710 * @type {Handle}
22711 */
22712 function onexitdefinitiondestinationstring() {
22713 const data = this.resume();
22714 const node = this.stack[this.stack.length - 1];
22715 node.url = data;
22716 }
22717 /**
22718 * @this {CompileContext}
22719 * @type {Handle}
22720 */
22721 function onexitatxheadingsequence(token) {
22722 const node = this.stack[this.stack.length - 1];
22723 if (!node.depth) node.depth = this.sliceSerialize(token).length;
22724 }
22725 /**
22726 * @this {CompileContext}
22727 * @type {Handle}
22728 */
22729 function onexitsetextheadingtext() {
22730 setData("setextHeadingSlurpLineEnding", true);
22731 }
22732 /**
22733 * @this {CompileContext}
22734 * @type {Handle}
22735 */
22736 function onexitsetextheadinglinesequence(token) {
22737 const node = this.stack[this.stack.length - 1];
22738 node.depth = this.sliceSerialize(token).charCodeAt(0) === 61 ? 1 : 2;
22739 }
22740 /**
22741 * @this {CompileContext}
22742 * @type {Handle}
22743 */
22744 function onexitsetextheading() {
22745 setData("setextHeadingSlurpLineEnding");
22746 }
22747 /**
22748 * @this {CompileContext}
22749 * @type {Handle}
22750 */
22751 function onenterdata(token) {
22752 const node = this.stack[this.stack.length - 1];
22753 let tail = node.children[node.children.length - 1];
22754 if (!tail || tail.type !== "text") {
22755 tail = text();
22756 tail.position = { start: point$1(token.start) };
22757 node.children.push(tail);
22758 }
22759 this.stack.push(tail);
22760 }
22761 /**
22762 * @this {CompileContext}
22763 * @type {Handle}
22764 */
22765 function onexitdata(token) {
22766 const tail = this.stack.pop();
22767 tail.value += this.sliceSerialize(token);
22768 tail.position.end = point$1(token.end);
22769 }
22770 /**
22771 * @this {CompileContext}
22772 * @type {Handle}
22773 */
22774 function onexitlineending(token) {
22775 const context = this.stack[this.stack.length - 1];
22776 if (getData("atHardBreak")) {
22777 const tail = context.children[context.children.length - 1];
22778 tail.position.end = point$1(token.end);
22779 setData("atHardBreak");
22780 return;
22781 }
22782 if (!getData("setextHeadingSlurpLineEnding") && config.canContainEols.includes(context.type)) {
22783 onenterdata.call(this, token);
22784 onexitdata.call(this, token);
22785 }
22786 }
22787 /**
22788 * @this {CompileContext}
22789 * @type {Handle}
22790 */
22791 function onexithardbreak() {
22792 setData("atHardBreak", true);
22793 }
22794 /**
22795 * @this {CompileContext}
22796 * @type {Handle}
22797 */
22798 function onexithtmlflow() {
22799 const data = this.resume();
22800 const node = this.stack[this.stack.length - 1];
22801 node.value = data;
22802 }
22803 /**
22804 * @this {CompileContext}
22805 * @type {Handle}
22806 */
22807 function onexithtmltext() {
22808 const data = this.resume();
22809 const node = this.stack[this.stack.length - 1];
22810 node.value = data;
22811 }
22812 /**
22813 * @this {CompileContext}
22814 * @type {Handle}
22815 */
22816 function onexitcodetext() {
22817 const data = this.resume();
22818 const node = this.stack[this.stack.length - 1];
22819 node.value = data;
22820 }
22821 /**
22822 * @this {CompileContext}
22823 * @type {Handle}
22824 */
22825 function onexitlink() {
22826 const node = this.stack[this.stack.length - 1];
22827 if (getData("inReference")) {
22828 /** @type {ReferenceType} */
22829 const referenceType = getData("referenceType") || "shortcut";
22830 node.type += "Reference";
22831 node.referenceType = referenceType;
22832 delete node.url;
22833 delete node.title;
22834 } else {
22835 delete node.identifier;
22836 delete node.label;
22837 }
22838 setData("referenceType");
22839 }
22840 /**
22841 * @this {CompileContext}
22842 * @type {Handle}
22843 */
22844 function onexitimage() {
22845 const node = this.stack[this.stack.length - 1];
22846 if (getData("inReference")) {
22847 /** @type {ReferenceType} */
22848 const referenceType = getData("referenceType") || "shortcut";
22849 node.type += "Reference";
22850 node.referenceType = referenceType;
22851 delete node.url;
22852 delete node.title;
22853 } else {
22854 delete node.identifier;
22855 delete node.label;
22856 }
22857 setData("referenceType");
22858 }
22859 /**
22860 * @this {CompileContext}
22861 * @type {Handle}
22862 */
22863 function onexitlabeltext(token) {
22864 const string = this.sliceSerialize(token);
22865 const ancestor = this.stack[this.stack.length - 2];
22866 ancestor.label = decodeString(string);
22867 ancestor.identifier = normalizeIdentifier(string).toLowerCase();
22868 }
22869 /**
22870 * @this {CompileContext}
22871 * @type {Handle}
22872 */
22873 function onexitlabel() {
22874 const fragment = this.stack[this.stack.length - 1];
22875 const value = this.resume();
22876 const node = this.stack[this.stack.length - 1];
22877 setData("inReference", true);
22878 if (node.type === "link") node.children = fragment.children;
22879 else node.alt = value;
22880 }
22881 /**
22882 * @this {CompileContext}
22883 * @type {Handle}
22884 */
22885 function onexitresourcedestinationstring() {
22886 const data = this.resume();
22887 const node = this.stack[this.stack.length - 1];
22888 node.url = data;
22889 }
22890 /**
22891 * @this {CompileContext}
22892 * @type {Handle}
22893 */
22894 function onexitresourcetitlestring() {
22895 const data = this.resume();
22896 const node = this.stack[this.stack.length - 1];
22897 node.title = data;
22898 }
22899 /**
22900 * @this {CompileContext}
22901 * @type {Handle}
22902 */
22903 function onexitresource() {
22904 setData("inReference");
22905 }
22906 /**
22907 * @this {CompileContext}
22908 * @type {Handle}
22909 */
22910 function onenterreference() {
22911 setData("referenceType", "collapsed");
22912 }
22913 /**
22914 * @this {CompileContext}
22915 * @type {Handle}
22916 */
22917 function onexitreferencestring(token) {
22918 const label = this.resume();
22919 const node = this.stack[this.stack.length - 1];
22920 node.label = label;
22921 node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();
22922 setData("referenceType", "full");
22923 }
22924 /**
22925 * @this {CompileContext}
22926 * @type {Handle}
22927 */
22928 function onexitcharacterreferencemarker(token) {
22929 setData("characterReferenceType", token.type);
22930 }
22931 /**
22932 * @this {CompileContext}
22933 * @type {Handle}
22934 */
22935 function onexitcharacterreferencevalue(token) {
22936 const data = this.sliceSerialize(token);
22937 const type = getData("characterReferenceType");
22938 /** @type {string} */
22939 let value;
22940 if (type) {
22941 value = decodeNumericCharacterReference(data, type === "characterReferenceMarkerNumeric" ? 10 : 16);
22942 setData("characterReferenceType");
22943 } else value = decodeNamedCharacterReference(data);
22944 const tail = this.stack.pop();
22945 tail.value += value;
22946 tail.position.end = point$1(token.end);
22947 }
22948 /**
22949 * @this {CompileContext}
22950 * @type {Handle}
22951 */
22952 function onexitautolinkprotocol(token) {
22953 onexitdata.call(this, token);
22954 const node = this.stack[this.stack.length - 1];
22955 node.url = this.sliceSerialize(token);
22956 }
22957 /**
22958 * @this {CompileContext}
22959 * @type {Handle}
22960 */
22961 function onexitautolinkemail(token) {
22962 onexitdata.call(this, token);
22963 const node = this.stack[this.stack.length - 1];
22964 node.url = "mailto:" + this.sliceSerialize(token);
22965 }
22966 /** @returns {Blockquote} */
22967 function blockQuote() {
22968 return {
22969 type: "blockquote",
22970 children: []
22971 };
22972 }
22973 /** @returns {Code} */
22974 function codeFlow() {
22975 return {
22976 type: "code",
22977 lang: null,
22978 meta: null,
22979 value: ""
22980 };
22981 }
22982 /** @returns {InlineCode} */
22983 function codeText() {
22984 return {
22985 type: "inlineCode",
22986 value: ""
22987 };
22988 }
22989 /** @returns {Definition} */
22990 function definition() {
22991 return {
22992 type: "definition",
22993 identifier: "",
22994 label: null,
22995 title: null,
22996 url: ""
22997 };
22998 }
22999 /** @returns {Emphasis} */
23000 function emphasis() {
23001 return {
23002 type: "emphasis",
23003 children: []
23004 };
23005 }
23006 /** @returns {Heading} */
23007 function heading() {
23008 return {
23009 type: "heading",
23010 depth: void 0,
23011 children: []
23012 };
23013 }
23014 /** @returns {Break} */
23015 function hardBreak() {
23016 return { type: "break" };
23017 }
23018 /** @returns {HTML} */
23019 function html() {
23020 return {
23021 type: "html",
23022 value: ""
23023 };
23024 }
23025 /** @returns {Image} */
23026 function image() {
23027 return {
23028 type: "image",
23029 title: null,
23030 url: "",
23031 alt: null
23032 };
23033 }
23034 /** @returns {Link} */
23035 function link() {
23036 return {
23037 type: "link",
23038 title: null,
23039 url: "",
23040 children: []
23041 };
23042 }
23043 /**
23044 * @param {Token} token
23045 * @returns {List}
23046 */
23047 function list(token) {
23048 return {
23049 type: "list",
23050 ordered: token.type === "listOrdered",
23051 start: null,
23052 spread: token._spread,
23053 children: []
23054 };
23055 }
23056 /**
23057 * @param {Token} token
23058 * @returns {ListItem}
23059 */
23060 function listItem(token) {
23061 return {
23062 type: "listItem",
23063 spread: token._spread,
23064 checked: null,
23065 children: []
23066 };
23067 }
23068 /** @returns {Paragraph} */
23069 function paragraph() {
23070 return {
23071 type: "paragraph",
23072 children: []
23073 };
23074 }
23075 /** @returns {Strong} */
23076 function strong() {
23077 return {
23078 type: "strong",
23079 children: []
23080 };
23081 }
23082 /** @returns {Text} */
23083 function text() {
23084 return {
23085 type: "text",
23086 value: ""
23087 };
23088 }
23089 /** @returns {ThematicBreak} */
23090 function thematicBreak() {
23091 return { type: "thematicBreak" };
23092 }
23093 }
23094 /**
23095 * Copy a point-like value.
23096 *
23097 * @param {Point} d
23098 * Point-like value.
23099 * @returns {Point}
23100 * unist point.
23101 */
23102 function point$1(d) {
23103 return {
23104 line: d.line,
23105 column: d.column,
23106 offset: d.offset
23107 };
23108 }
23109 /**
23110 * @param {Config} combined
23111 * @param {Array<Extension | Array<Extension>>} extensions
23112 * @returns {void}
23113 */
23114 function configure(combined, extensions) {
23115 let index = -1;
23116 while (++index < extensions.length) {
23117 const value = extensions[index];
23118 if (Array.isArray(value)) configure(combined, value);
23119 else extension(combined, value);
23120 }
23121 }
23122 /**
23123 * @param {Config} combined
23124 * @param {Extension} extension
23125 * @returns {void}
23126 */
23127 function extension(combined, extension) {
23128 /** @type {keyof Extension} */
23129 let key;
23130 for (key in extension) if (own$5.call(extension, key)) {
23131 if (key === "canContainEols") {
23132 const right = extension[key];
23133 if (right) combined[key].push(...right);
23134 } else if (key === "transforms") {
23135 const right = extension[key];
23136 if (right) combined[key].push(...right);
23137 } else if (key === "enter" || key === "exit") {
23138 const right = extension[key];
23139 if (right) Object.assign(combined[key], right);
23140 }
23141 }
23142 }
23143 /** @type {OnEnterError} */
23144 function defaultOnError(left, right) {
23145 if (left) throw new Error("Cannot close `" + left.type + "` (" + stringifyPosition({
23146 start: left.start,
23147 end: left.end
23148 }) + "): a different token (`" + right.type + "`, " + stringifyPosition({
23149 start: right.start,
23150 end: right.end
23151 }) + ") is open");
23152 else throw new Error("Cannot close document, a token (`" + right.type + "`, " + stringifyPosition({
23153 start: right.start,
23154 end: right.end
23155 }) + ") is still open");
23156 }
23157 var own$5, fromMarkdown;
23158 var init_lib$9 = __esmMin((() => {
23159 init_mdast_util_to_string();
23160 init_parse();
23161 init_preprocess();
23162 init_postprocess();
23163 init_micromark_util_decode_numeric_character_reference();
23164 init_micromark_util_decode_string();
23165 init_micromark_util_normalize_identifier();
23166 init_index_dom();
23167 init_unist_util_stringify_position();
23168 own$5 = {}.hasOwnProperty;
23169 fromMarkdown = function(value, encoding, options) {
23170 if (typeof encoding !== "string") {
23171 options = encoding;
23172 encoding = void 0;
23173 }
23174 return compiler(options)(postprocess(parse(options).document().write(preprocess()(value, encoding, true))));
23175 };
23176 __name(point$1, "point");
23177 }));
23178
23179 //#endregion
23180 //#region node_modules/mdast-util-from-markdown/index.js
23181 var init_mdast_util_from_markdown = __esmMin((() => {
23182 init_lib$9();
23183 }));
23184
23185 //#endregion
23186 //#region node_modules/remark-parse/lib/index.js
23187 /**
23188 * @this {import('unified').Processor}
23189 * @type {import('unified').Plugin<[Options?] | void[], string, Root>}
23190 */
23191 function remarkParse(options) {
23192 /** @type {import('unified').ParserFunction<Root>} */
23193 const parser = (doc) => {
23194 const settings = this.data("settings");
23195 return fromMarkdown(doc, Object.assign({}, settings, options, {
23196 extensions: this.data("micromarkExtensions") || [],
23197 mdastExtensions: this.data("fromMarkdownExtensions") || []
23198 }));
23199 };
23200 Object.assign(this, { Parser: parser });
23201 }
23202 var init_lib$8 = __esmMin((() => {
23203 init_mdast_util_from_markdown();
23204 }));
23205
23206 //#endregion
23207 //#region node_modules/remark-parse/index.js
23208 var init_remark_parse = __esmMin((() => {
23209 init_lib$8();
23210 }));
23211
23212 //#endregion
23213 //#region node_modules/mdast-util-to-hast/lib/handlers/blockquote.js
23214 /**
23215 * @typedef {import('hast').Element} Element
23216 * @typedef {import('mdast').Blockquote} Blockquote
23217 * @typedef {import('../state.js').State} State
23218 */
23219 /**
23220 * Turn an mdast `blockquote` node into hast.
23221 *
23222 * @param {State} state
23223 * Info passed around.
23224 * @param {Blockquote} node
23225 * mdast node.
23226 * @returns {Element}
23227 * hast node.
23228 */
23229 function blockquote(state, node) {
23230 /** @type {Element} */
23231 const result = {
23232 type: "element",
23233 tagName: "blockquote",
23234 properties: {},
23235 children: state.wrap(state.all(node), true)
23236 };
23237 state.patch(node, result);
23238 return state.applyData(node, result);
23239 }
23240 var init_blockquote = __esmMin((() => {}));
23241
23242 //#endregion
23243 //#region node_modules/mdast-util-to-hast/lib/handlers/break.js
23244 /**
23245 * @typedef {import('hast').Element} Element
23246 * @typedef {import('hast').Text} Text
23247 * @typedef {import('mdast').Break} Break
23248 * @typedef {import('../state.js').State} State
23249 */
23250 /**
23251 * Turn an mdast `break` node into hast.
23252 *
23253 * @param {State} state
23254 * Info passed around.
23255 * @param {Break} node
23256 * mdast node.
23257 * @returns {Array<Element | Text>}
23258 * hast element content.
23259 */
23260 function hardBreak(state, node) {
23261 /** @type {Element} */
23262 const result = {
23263 type: "element",
23264 tagName: "br",
23265 properties: {},
23266 children: []
23267 };
23268 state.patch(node, result);
23269 return [state.applyData(node, result), {
23270 type: "text",
23271 value: "\n"
23272 }];
23273 }
23274 var init_break = __esmMin((() => {}));
23275
23276 //#endregion
23277 //#region node_modules/mdast-util-to-hast/lib/handlers/code.js
23278 /**
23279 * @typedef {import('hast').Element} Element
23280 * @typedef {import('hast').Properties} Properties
23281 * @typedef {import('mdast').Code} Code
23282 * @typedef {import('../state.js').State} State
23283
23284 */
23285 /**
23286 * Turn an mdast `code` node into hast.
23287 *
23288 * @param {State} state
23289 * Info passed around.
23290 * @param {Code} node
23291 * mdast node.
23292 * @returns {Element}
23293 * hast node.
23294 */
23295 function code(state, node) {
23296 const value = node.value ? node.value + "\n" : "";
23297 const lang = node.lang ? node.lang.match(/^[^ \t]+(?=[ \t]|$)/) : null;
23298 /** @type {Properties} */
23299 const properties = {};
23300 if (lang) properties.className = ["language-" + lang];
23301 /** @type {Element} */
23302 let result = {
23303 type: "element",
23304 tagName: "code",
23305 properties,
23306 children: [{
23307 type: "text",
23308 value
23309 }]
23310 };
23311 if (node.meta) result.data = { meta: node.meta };
23312 state.patch(node, result);
23313 result = state.applyData(node, result);
23314 result = {
23315 type: "element",
23316 tagName: "pre",
23317 properties: {},
23318 children: [result]
23319 };
23320 state.patch(node, result);
23321 return result;
23322 }
23323 var init_code = __esmMin((() => {}));
23324
23325 //#endregion
23326 //#region node_modules/mdast-util-to-hast/lib/handlers/delete.js
23327 /**
23328 * @typedef {import('hast').Element} Element
23329 * @typedef {import('mdast').Delete} Delete
23330 * @typedef {import('../state.js').State} State
23331
23332 */
23333 /**
23334 * Turn an mdast `delete` node into hast.
23335 *
23336 * @param {State} state
23337 * Info passed around.
23338 * @param {Delete} node
23339 * mdast node.
23340 * @returns {Element}
23341 * hast node.
23342 */
23343 function strikethrough(state, node) {
23344 /** @type {Element} */
23345 const result = {
23346 type: "element",
23347 tagName: "del",
23348 properties: {},
23349 children: state.all(node)
23350 };
23351 state.patch(node, result);
23352 return state.applyData(node, result);
23353 }
23354 var init_delete = __esmMin((() => {}));
23355
23356 //#endregion
23357 //#region node_modules/mdast-util-to-hast/lib/handlers/emphasis.js
23358 /**
23359 * @typedef {import('hast').Element} Element
23360 * @typedef {import('mdast').Emphasis} Emphasis
23361 * @typedef {import('../state.js').State} State
23362 */
23363 /**
23364 * Turn an mdast `emphasis` node into hast.
23365 *
23366 * @param {State} state
23367 * Info passed around.
23368 * @param {Emphasis} node
23369 * mdast node.
23370 * @returns {Element}
23371 * hast node.
23372 */
23373 function emphasis(state, node) {
23374 /** @type {Element} */
23375 const result = {
23376 type: "element",
23377 tagName: "em",
23378 properties: {},
23379 children: state.all(node)
23380 };
23381 state.patch(node, result);
23382 return state.applyData(node, result);
23383 }
23384 var init_emphasis = __esmMin((() => {}));
23385
23386 //#endregion
23387 //#region node_modules/micromark-util-sanitize-uri/index.js
23388 /**
23389 * Normalize a URL.
23390 *
23391 * Encode unsafe characters with percent-encoding, skipping already encoded
23392 * sequences.
23393 *
23394 * @param {string} value
23395 * URI to normalize.
23396 * @returns {string}
23397 * Normalized URI.
23398 */
23399 function normalizeUri(value) {
23400 /** @type {Array<string>} */
23401 const result = [];
23402 let index = -1;
23403 let start = 0;
23404 let skip = 0;
23405 while (++index < value.length) {
23406 const code = value.charCodeAt(index);
23407 /** @type {string} */
23408 let replace = "";
23409 if (code === 37 && asciiAlphanumeric(value.charCodeAt(index + 1)) && asciiAlphanumeric(value.charCodeAt(index + 2))) skip = 2;
23410 else if (code < 128) {
23411 if (!/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(code))) replace = String.fromCharCode(code);
23412 } else if (code > 55295 && code < 57344) {
23413 const next = value.charCodeAt(index + 1);
23414 if (code < 56320 && next > 56319 && next < 57344) {
23415 replace = String.fromCharCode(code, next);
23416 skip = 1;
23417 } else replace = "�";
23418 } else replace = String.fromCharCode(code);
23419 if (replace) {
23420 result.push(value.slice(start, index), encodeURIComponent(replace));
23421 start = index + skip + 1;
23422 replace = "";
23423 }
23424 if (skip) {
23425 index += skip;
23426 skip = 0;
23427 }
23428 }
23429 return result.join("") + value.slice(start);
23430 }
23431 var init_micromark_util_sanitize_uri = __esmMin((() => {
23432 init_micromark_util_character();
23433 }));
23434
23435 //#endregion
23436 //#region node_modules/mdast-util-to-hast/lib/handlers/footnote-reference.js
23437 /**
23438 * Turn an mdast `footnoteReference` node into hast.
23439 *
23440 * @param {State} state
23441 * Info passed around.
23442 * @param {FootnoteReference} node
23443 * mdast node.
23444 * @returns {Element}
23445 * hast node.
23446 */
23447 function footnoteReference(state, node) {
23448 const id = String(node.identifier).toUpperCase();
23449 const safeId = normalizeUri(id.toLowerCase());
23450 const index = state.footnoteOrder.indexOf(id);
23451 /** @type {number} */
23452 let counter;
23453 if (index === -1) {
23454 state.footnoteOrder.push(id);
23455 state.footnoteCounts[id] = 1;
23456 counter = state.footnoteOrder.length;
23457 } else {
23458 state.footnoteCounts[id]++;
23459 counter = index + 1;
23460 }
23461 const reuseCounter = state.footnoteCounts[id];
23462 /** @type {Element} */
23463 const link = {
23464 type: "element",
23465 tagName: "a",
23466 properties: {
23467 href: "#" + state.clobberPrefix + "fn-" + safeId,
23468 id: state.clobberPrefix + "fnref-" + safeId + (reuseCounter > 1 ? "-" + reuseCounter : ""),
23469 dataFootnoteRef: true,
23470 ariaDescribedBy: ["footnote-label"]
23471 },
23472 children: [{
23473 type: "text",
23474 value: String(counter)
23475 }]
23476 };
23477 state.patch(node, link);
23478 /** @type {Element} */
23479 const sup = {
23480 type: "element",
23481 tagName: "sup",
23482 properties: {},
23483 children: [link]
23484 };
23485 state.patch(node, sup);
23486 return state.applyData(node, sup);
23487 }
23488 var init_footnote_reference = __esmMin((() => {
23489 init_micromark_util_sanitize_uri();
23490 }));
23491
23492 //#endregion
23493 //#region node_modules/mdast-util-to-hast/lib/handlers/footnote.js
23494 /**
23495 * Turn an mdast `footnote` node into hast.
23496 *
23497 * @param {State} state
23498 * Info passed around.
23499 * @param {Footnote} node
23500 * mdast node.
23501 * @returns {Element}
23502 * hast node.
23503 */
23504 function footnote(state, node) {
23505 const footnoteById = state.footnoteById;
23506 let no = 1;
23507 while (no in footnoteById) no++;
23508 const identifier = String(no);
23509 footnoteById[identifier] = {
23510 type: "footnoteDefinition",
23511 identifier,
23512 children: [{
23513 type: "paragraph",
23514 children: node.children
23515 }],
23516 position: node.position
23517 };
23518 return footnoteReference(state, {
23519 type: "footnoteReference",
23520 identifier,
23521 position: node.position
23522 });
23523 }
23524 var init_footnote = __esmMin((() => {
23525 init_footnote_reference();
23526 }));
23527
23528 //#endregion
23529 //#region node_modules/mdast-util-to-hast/lib/handlers/heading.js
23530 /**
23531 * @typedef {import('hast').Element} Element
23532 * @typedef {import('mdast').Heading} Heading
23533 * @typedef {import('../state.js').State} State
23534 */
23535 /**
23536 * Turn an mdast `heading` node into hast.
23537 *
23538 * @param {State} state
23539 * Info passed around.
23540 * @param {Heading} node
23541 * mdast node.
23542 * @returns {Element}
23543 * hast node.
23544 */
23545 function heading(state, node) {
23546 /** @type {Element} */
23547 const result = {
23548 type: "element",
23549 tagName: "h" + node.depth,
23550 properties: {},
23551 children: state.all(node)
23552 };
23553 state.patch(node, result);
23554 return state.applyData(node, result);
23555 }
23556 var init_heading = __esmMin((() => {}));
23557
23558 //#endregion
23559 //#region node_modules/mdast-util-to-hast/lib/handlers/html.js
23560 /**
23561 * @typedef {import('hast').Element} Element
23562 * @typedef {import('mdast').HTML} Html
23563 * @typedef {import('../state.js').State} State
23564 * @typedef {import('../../index.js').Raw} Raw
23565 */
23566 /**
23567 * Turn an mdast `html` node into hast (`raw` node in dangerous mode, otherwise
23568 * nothing).
23569 *
23570 * @param {State} state
23571 * Info passed around.
23572 * @param {Html} node
23573 * mdast node.
23574 * @returns {Raw | Element | null}
23575 * hast node.
23576 */
23577 function html$2(state, node) {
23578 if (state.dangerous) {
23579 /** @type {Raw} */
23580 const result = {
23581 type: "raw",
23582 value: node.value
23583 };
23584 state.patch(node, result);
23585 return state.applyData(node, result);
23586 }
23587 return null;
23588 }
23589 var init_html$1 = __esmMin((() => {
23590 __name(html$2, "html");
23591 }));
23592
23593 //#endregion
23594 //#region node_modules/mdast-util-to-hast/lib/revert.js
23595 /**
23596 * @typedef {import('hast').ElementContent} ElementContent
23597 *
23598 * @typedef {import('mdast').Content} Content
23599 * @typedef {import('mdast').Reference} Reference
23600 * @typedef {import('mdast').Root} Root
23601 *
23602 * @typedef {import('./state.js').State} State
23603 */
23604 /**
23605 * @typedef {Root | Content} Nodes
23606 * @typedef {Extract<Nodes, Reference>} References
23607 */
23608 /**
23609 * Return the content of a reference without definition as plain text.
23610 *
23611 * @param {State} state
23612 * Info passed around.
23613 * @param {References} node
23614 * Reference node (image, link).
23615 * @returns {ElementContent | Array<ElementContent>}
23616 * hast content.
23617 */
23618 function revert(state, node) {
23619 const subtype = node.referenceType;
23620 let suffix = "]";
23621 if (subtype === "collapsed") suffix += "[]";
23622 else if (subtype === "full") suffix += "[" + (node.label || node.identifier) + "]";
23623 if (node.type === "imageReference") return {
23624 type: "text",
23625 value: "![" + node.alt + suffix
23626 };
23627 const contents = state.all(node);
23628 const head = contents[0];
23629 if (head && head.type === "text") head.value = "[" + head.value;
23630 else contents.unshift({
23631 type: "text",
23632 value: "["
23633 });
23634 const tail = contents[contents.length - 1];
23635 if (tail && tail.type === "text") tail.value += suffix;
23636 else contents.push({
23637 type: "text",
23638 value: suffix
23639 });
23640 return contents;
23641 }
23642 var init_revert = __esmMin((() => {}));
23643
23644 //#endregion
23645 //#region node_modules/mdast-util-to-hast/lib/handlers/image-reference.js
23646 /**
23647 * Turn an mdast `imageReference` node into hast.
23648 *
23649 * @param {State} state
23650 * Info passed around.
23651 * @param {ImageReference} node
23652 * mdast node.
23653 * @returns {ElementContent | Array<ElementContent>}
23654 * hast node.
23655 */
23656 function imageReference(state, node) {
23657 const def = state.definition(node.identifier);
23658 if (!def) return revert(state, node);
23659 /** @type {Properties} */
23660 const properties = {
23661 src: normalizeUri(def.url || ""),
23662 alt: node.alt
23663 };
23664 if (def.title !== null && def.title !== void 0) properties.title = def.title;
23665 /** @type {Element} */
23666 const result = {
23667 type: "element",
23668 tagName: "img",
23669 properties,
23670 children: []
23671 };
23672 state.patch(node, result);
23673 return state.applyData(node, result);
23674 }
23675 var init_image_reference = __esmMin((() => {
23676 init_micromark_util_sanitize_uri();
23677 init_revert();
23678 }));
23679
23680 //#endregion
23681 //#region node_modules/mdast-util-to-hast/lib/handlers/image.js
23682 /**
23683 * Turn an mdast `image` node into hast.
23684 *
23685 * @param {State} state
23686 * Info passed around.
23687 * @param {Image} node
23688 * mdast node.
23689 * @returns {Element}
23690 * hast node.
23691 */
23692 function image(state, node) {
23693 /** @type {Properties} */
23694 const properties = { src: normalizeUri(node.url) };
23695 if (node.alt !== null && node.alt !== void 0) properties.alt = node.alt;
23696 if (node.title !== null && node.title !== void 0) properties.title = node.title;
23697 /** @type {Element} */
23698 const result = {
23699 type: "element",
23700 tagName: "img",
23701 properties,
23702 children: []
23703 };
23704 state.patch(node, result);
23705 return state.applyData(node, result);
23706 }
23707 var init_image = __esmMin((() => {
23708 init_micromark_util_sanitize_uri();
23709 }));
23710
23711 //#endregion
23712 //#region node_modules/mdast-util-to-hast/lib/handlers/inline-code.js
23713 /**
23714 * @typedef {import('hast').Element} Element
23715 * @typedef {import('hast').Text} Text
23716 * @typedef {import('mdast').InlineCode} InlineCode
23717 * @typedef {import('../state.js').State} State
23718 */
23719 /**
23720 * Turn an mdast `inlineCode` node into hast.
23721 *
23722 * @param {State} state
23723 * Info passed around.
23724 * @param {InlineCode} node
23725 * mdast node.
23726 * @returns {Element}
23727 * hast node.
23728 */
23729 function inlineCode(state, node) {
23730 /** @type {Text} */
23731 const text = {
23732 type: "text",
23733 value: node.value.replace(/\r?\n|\r/g, " ")
23734 };
23735 state.patch(node, text);
23736 /** @type {Element} */
23737 const result = {
23738 type: "element",
23739 tagName: "code",
23740 properties: {},
23741 children: [text]
23742 };
23743 state.patch(node, result);
23744 return state.applyData(node, result);
23745 }
23746 var init_inline_code = __esmMin((() => {}));
23747
23748 //#endregion
23749 //#region node_modules/mdast-util-to-hast/lib/handlers/link-reference.js
23750 /**
23751 * Turn an mdast `linkReference` node into hast.
23752 *
23753 * @param {State} state
23754 * Info passed around.
23755 * @param {LinkReference} node
23756 * mdast node.
23757 * @returns {ElementContent | Array<ElementContent>}
23758 * hast node.
23759 */
23760 function linkReference(state, node) {
23761 const def = state.definition(node.identifier);
23762 if (!def) return revert(state, node);
23763 /** @type {Properties} */
23764 const properties = { href: normalizeUri(def.url || "") };
23765 if (def.title !== null && def.title !== void 0) properties.title = def.title;
23766 /** @type {Element} */
23767 const result = {
23768 type: "element",
23769 tagName: "a",
23770 properties,
23771 children: state.all(node)
23772 };
23773 state.patch(node, result);
23774 return state.applyData(node, result);
23775 }
23776 var init_link_reference = __esmMin((() => {
23777 init_micromark_util_sanitize_uri();
23778 init_revert();
23779 }));
23780
23781 //#endregion
23782 //#region node_modules/mdast-util-to-hast/lib/handlers/link.js
23783 /**
23784 * Turn an mdast `link` node into hast.
23785 *
23786 * @param {State} state
23787 * Info passed around.
23788 * @param {Link} node
23789 * mdast node.
23790 * @returns {Element}
23791 * hast node.
23792 */
23793 function link(state, node) {
23794 /** @type {Properties} */
23795 const properties = { href: normalizeUri(node.url) };
23796 if (node.title !== null && node.title !== void 0) properties.title = node.title;
23797 /** @type {Element} */
23798 const result = {
23799 type: "element",
23800 tagName: "a",
23801 properties,
23802 children: state.all(node)
23803 };
23804 state.patch(node, result);
23805 return state.applyData(node, result);
23806 }
23807 var init_link = __esmMin((() => {
23808 init_micromark_util_sanitize_uri();
23809 }));
23810
23811 //#endregion
23812 //#region node_modules/mdast-util-to-hast/lib/handlers/list-item.js
23813 /**
23814 * @typedef {import('hast').Element} Element
23815 * @typedef {import('hast').ElementContent} ElementContent
23816 * @typedef {import('hast').Properties} Properties
23817 * @typedef {import('mdast').Content} Content
23818 * @typedef {import('mdast').ListItem} ListItem
23819 * @typedef {import('mdast').Parent} Parent
23820 * @typedef {import('mdast').Root} Root
23821 * @typedef {import('../state.js').State} State
23822 */
23823 /**
23824 * @typedef {Root | Content} Nodes
23825 * @typedef {Extract<Nodes, Parent>} Parents
23826 */
23827 /**
23828 * Turn an mdast `listItem` node into hast.
23829 *
23830 * @param {State} state
23831 * Info passed around.
23832 * @param {ListItem} node
23833 * mdast node.
23834 * @param {Parents | null | undefined} parent
23835 * Parent of `node`.
23836 * @returns {Element}
23837 * hast node.
23838 */
23839 function listItem(state, node, parent) {
23840 const results = state.all(node);
23841 const loose = parent ? listLoose(parent) : listItemLoose(node);
23842 /** @type {Properties} */
23843 const properties = {};
23844 /** @type {Array<ElementContent>} */
23845 const children = [];
23846 if (typeof node.checked === "boolean") {
23847 const head = results[0];
23848 /** @type {Element} */
23849 let paragraph;
23850 if (head && head.type === "element" && head.tagName === "p") paragraph = head;
23851 else {
23852 paragraph = {
23853 type: "element",
23854 tagName: "p",
23855 properties: {},
23856 children: []
23857 };
23858 results.unshift(paragraph);
23859 }
23860 if (paragraph.children.length > 0) paragraph.children.unshift({
23861 type: "text",
23862 value: " "
23863 });
23864 paragraph.children.unshift({
23865 type: "element",
23866 tagName: "input",
23867 properties: {
23868 type: "checkbox",
23869 checked: node.checked,
23870 disabled: true
23871 },
23872 children: []
23873 });
23874 properties.className = ["task-list-item"];
23875 }
23876 let index = -1;
23877 while (++index < results.length) {
23878 const child = results[index];
23879 if (loose || index !== 0 || child.type !== "element" || child.tagName !== "p") children.push({
23880 type: "text",
23881 value: "\n"
23882 });
23883 if (child.type === "element" && child.tagName === "p" && !loose) children.push(...child.children);
23884 else children.push(child);
23885 }
23886 const tail = results[results.length - 1];
23887 if (tail && (loose || tail.type !== "element" || tail.tagName !== "p")) children.push({
23888 type: "text",
23889 value: "\n"
23890 });
23891 /** @type {Element} */
23892 const result = {
23893 type: "element",
23894 tagName: "li",
23895 properties,
23896 children
23897 };
23898 state.patch(node, result);
23899 return state.applyData(node, result);
23900 }
23901 /**
23902 * @param {Parents} node
23903 * @return {Boolean}
23904 */
23905 function listLoose(node) {
23906 let loose = false;
23907 if (node.type === "list") {
23908 loose = node.spread || false;
23909 const children = node.children;
23910 let index = -1;
23911 while (!loose && ++index < children.length) loose = listItemLoose(children[index]);
23912 }
23913 return loose;
23914 }
23915 /**
23916 * @param {ListItem} node
23917 * @return {Boolean}
23918 */
23919 function listItemLoose(node) {
23920 const spread = node.spread;
23921 return spread === void 0 || spread === null ? node.children.length > 1 : spread;
23922 }
23923 var init_list_item = __esmMin((() => {}));
23924
23925 //#endregion
23926 //#region node_modules/mdast-util-to-hast/lib/handlers/list.js
23927 /**
23928 * @typedef {import('hast').Element} Element
23929 * @typedef {import('hast').Properties} Properties
23930 * @typedef {import('mdast').List} List
23931 * @typedef {import('../state.js').State} State
23932 */
23933 /**
23934 * Turn an mdast `list` node into hast.
23935 *
23936 * @param {State} state
23937 * Info passed around.
23938 * @param {List} node
23939 * mdast node.
23940 * @returns {Element}
23941 * hast node.
23942 */
23943 function list(state, node) {
23944 /** @type {Properties} */
23945 const properties = {};
23946 const results = state.all(node);
23947 let index = -1;
23948 if (typeof node.start === "number" && node.start !== 1) properties.start = node.start;
23949 while (++index < results.length) {
23950 const child = results[index];
23951 if (child.type === "element" && child.tagName === "li" && child.properties && Array.isArray(child.properties.className) && child.properties.className.includes("task-list-item")) {
23952 properties.className = ["contains-task-list"];
23953 break;
23954 }
23955 }
23956 /** @type {Element} */
23957 const result = {
23958 type: "element",
23959 tagName: node.ordered ? "ol" : "ul",
23960 properties,
23961 children: state.wrap(results, true)
23962 };
23963 state.patch(node, result);
23964 return state.applyData(node, result);
23965 }
23966 var init_list = __esmMin((() => {}));
23967
23968 //#endregion
23969 //#region node_modules/mdast-util-to-hast/lib/handlers/paragraph.js
23970 /**
23971 * @typedef {import('hast').Element} Element
23972 * @typedef {import('mdast').Paragraph} Paragraph
23973 * @typedef {import('../state.js').State} State
23974 */
23975 /**
23976 * Turn an mdast `paragraph` node into hast.
23977 *
23978 * @param {State} state
23979 * Info passed around.
23980 * @param {Paragraph} node
23981 * mdast node.
23982 * @returns {Element}
23983 * hast node.
23984 */
23985 function paragraph(state, node) {
23986 /** @type {Element} */
23987 const result = {
23988 type: "element",
23989 tagName: "p",
23990 properties: {},
23991 children: state.all(node)
23992 };
23993 state.patch(node, result);
23994 return state.applyData(node, result);
23995 }
23996 var init_paragraph = __esmMin((() => {}));
23997
23998 //#endregion
23999 //#region node_modules/mdast-util-to-hast/lib/handlers/root.js
24000 /**
24001 * @typedef {import('hast').Root} HastRoot
24002 * @typedef {import('hast').Element} HastElement
24003 * @typedef {import('mdast').Root} MdastRoot
24004 * @typedef {import('../state.js').State} State
24005 */
24006 /**
24007 * Turn an mdast `root` node into hast.
24008 *
24009 * @param {State} state
24010 * Info passed around.
24011 * @param {MdastRoot} node
24012 * mdast node.
24013 * @returns {HastRoot | HastElement}
24014 * hast node.
24015 */
24016 function root(state, node) {
24017 /** @type {HastRoot} */
24018 const result = {
24019 type: "root",
24020 children: state.wrap(state.all(node))
24021 };
24022 state.patch(node, result);
24023 return state.applyData(node, result);
24024 }
24025 var init_root = __esmMin((() => {}));
24026
24027 //#endregion
24028 //#region node_modules/mdast-util-to-hast/lib/handlers/strong.js
24029 /**
24030 * @typedef {import('hast').Element} Element
24031 * @typedef {import('mdast').Strong} Strong
24032 * @typedef {import('../state.js').State} State
24033 */
24034 /**
24035 * Turn an mdast `strong` node into hast.
24036 *
24037 * @param {State} state
24038 * Info passed around.
24039 * @param {Strong} node
24040 * mdast node.
24041 * @returns {Element}
24042 * hast node.
24043 */
24044 function strong(state, node) {
24045 /** @type {Element} */
24046 const result = {
24047 type: "element",
24048 tagName: "strong",
24049 properties: {},
24050 children: state.all(node)
24051 };
24052 state.patch(node, result);
24053 return state.applyData(node, result);
24054 }
24055 var init_strong = __esmMin((() => {}));
24056
24057 //#endregion
24058 //#region node_modules/unist-util-position/lib/index.js
24059 /**
24060 * Get the positional info of `node`.
24061 *
24062 * @param {NodeLike | Node | null | undefined} [node]
24063 * Node.
24064 * @returns {Position}
24065 * Position.
24066 */
24067 function position(node) {
24068 return {
24069 start: pointStart(node),
24070 end: pointEnd(node)
24071 };
24072 }
24073 /**
24074 * Get the positional info of `node`.
24075 *
24076 * @param {'start' | 'end'} type
24077 * Side.
24078 * @returns
24079 * Getter.
24080 */
24081 function point(type) {
24082 return point;
24083 /**
24084 * Get the point info of `node` at a bound side.
24085 *
24086 * @param {NodeLike | Node | null | undefined} [node]
24087 * @returns {Point}
24088 */
24089 function point(node) {
24090 const point = node && node.position && node.position[type] || {};
24091 return {
24092 line: point.line || null,
24093 column: point.column || null,
24094 offset: point.offset > -1 ? point.offset : null
24095 };
24096 }
24097 }
24098 var pointStart, pointEnd;
24099 var init_lib$7 = __esmMin((() => {
24100 pointStart = point("start");
24101 pointEnd = point("end");
24102 }));
24103
24104 //#endregion
24105 //#region node_modules/unist-util-position/index.js
24106 var init_unist_util_position = __esmMin((() => {
24107 init_lib$7();
24108 }));
24109
24110 //#endregion
24111 //#region node_modules/mdast-util-to-hast/lib/handlers/table.js
24112 /**
24113 * Turn an mdast `table` node into hast.
24114 *
24115 * @param {State} state
24116 * Info passed around.
24117 * @param {Table} node
24118 * mdast node.
24119 * @returns {Element}
24120 * hast node.
24121 */
24122 function table(state, node) {
24123 const rows = state.all(node);
24124 const firstRow = rows.shift();
24125 /** @type {Array<Element>} */
24126 const tableContent = [];
24127 if (firstRow) {
24128 /** @type {Element} */
24129 const head = {
24130 type: "element",
24131 tagName: "thead",
24132 properties: {},
24133 children: state.wrap([firstRow], true)
24134 };
24135 state.patch(node.children[0], head);
24136 tableContent.push(head);
24137 }
24138 if (rows.length > 0) {
24139 /** @type {Element} */
24140 const body = {
24141 type: "element",
24142 tagName: "tbody",
24143 properties: {},
24144 children: state.wrap(rows, true)
24145 };
24146 const start = pointStart(node.children[1]);
24147 const end = pointEnd(node.children[node.children.length - 1]);
24148 if (start.line && end.line) body.position = {
24149 start,
24150 end
24151 };
24152 tableContent.push(body);
24153 }
24154 /** @type {Element} */
24155 const result = {
24156 type: "element",
24157 tagName: "table",
24158 properties: {},
24159 children: state.wrap(tableContent, true)
24160 };
24161 state.patch(node, result);
24162 return state.applyData(node, result);
24163 }
24164 var init_table = __esmMin((() => {
24165 init_unist_util_position();
24166 }));
24167
24168 //#endregion
24169 //#region node_modules/mdast-util-to-hast/lib/handlers/table-row.js
24170 /**
24171 * @typedef {import('hast').Properties} Properties
24172 * @typedef {import('hast').Element} Element
24173 * @typedef {import('hast').ElementContent} ElementContent
24174 * @typedef {import('mdast').Content} Content
24175 * @typedef {import('mdast').Parent} Parent
24176 * @typedef {import('mdast').Root} Root
24177 * @typedef {import('mdast').TableRow} TableRow
24178 * @typedef {import('../state.js').State} State
24179 */
24180 /**
24181 * @typedef {Root | Content} Nodes
24182 * @typedef {Extract<Nodes, Parent>} Parents
24183 */
24184 /**
24185 * Turn an mdast `tableRow` node into hast.
24186 *
24187 * @param {State} state
24188 * Info passed around.
24189 * @param {TableRow} node
24190 * mdast node.
24191 * @param {Parents | null | undefined} parent
24192 * Parent of `node`.
24193 * @returns {Element}
24194 * hast node.
24195 */
24196 function tableRow(state, node, parent) {
24197 const siblings = parent ? parent.children : void 0;
24198 const tagName = (siblings ? siblings.indexOf(node) : 1) === 0 ? "th" : "td";
24199 const align = parent && parent.type === "table" ? parent.align : void 0;
24200 const length = align ? align.length : node.children.length;
24201 let cellIndex = -1;
24202 /** @type {Array<ElementContent>} */
24203 const cells = [];
24204 while (++cellIndex < length) {
24205 const cell = node.children[cellIndex];
24206 /** @type {Properties} */
24207 const properties = {};
24208 const alignValue = align ? align[cellIndex] : void 0;
24209 if (alignValue) properties.align = alignValue;
24210 /** @type {Element} */
24211 let result = {
24212 type: "element",
24213 tagName,
24214 properties,
24215 children: []
24216 };
24217 if (cell) {
24218 result.children = state.all(cell);
24219 state.patch(cell, result);
24220 result = state.applyData(node, result);
24221 }
24222 cells.push(result);
24223 }
24224 /** @type {Element} */
24225 const result = {
24226 type: "element",
24227 tagName: "tr",
24228 properties: {},
24229 children: state.wrap(cells, true)
24230 };
24231 state.patch(node, result);
24232 return state.applyData(node, result);
24233 }
24234 var init_table_row = __esmMin((() => {}));
24235
24236 //#endregion
24237 //#region node_modules/mdast-util-to-hast/lib/handlers/table-cell.js
24238 /**
24239 * @typedef {import('hast').Element} Element
24240 * @typedef {import('mdast').TableCell} TableCell
24241 * @typedef {import('../state.js').State} State
24242 */
24243 /**
24244 * Turn an mdast `tableCell` node into hast.
24245 *
24246 * @param {State} state
24247 * Info passed around.
24248 * @param {TableCell} node
24249 * mdast node.
24250 * @returns {Element}
24251 * hast node.
24252 */
24253 function tableCell(state, node) {
24254 /** @type {Element} */
24255 const result = {
24256 type: "element",
24257 tagName: "td",
24258 properties: {},
24259 children: state.all(node)
24260 };
24261 state.patch(node, result);
24262 return state.applyData(node, result);
24263 }
24264 var init_table_cell = __esmMin((() => {}));
24265
24266 //#endregion
24267 //#region node_modules/trim-lines/index.js
24268 /**
24269 * Remove initial and final spaces and tabs at the line breaks in `value`.
24270 * Does not trim initial and final spaces and tabs of the value itself.
24271 *
24272 * @param {string} value
24273 * Value to trim.
24274 * @returns {string}
24275 * Trimmed value.
24276 */
24277 function trimLines(value) {
24278 const source = String(value);
24279 const search = /\r?\n|\r/g;
24280 let match = search.exec(source);
24281 let last = 0;
24282 /** @type {Array<string>} */
24283 const lines = [];
24284 while (match) {
24285 lines.push(trimLine(source.slice(last, match.index), last > 0, true), match[0]);
24286 last = match.index + match[0].length;
24287 match = search.exec(source);
24288 }
24289 lines.push(trimLine(source.slice(last), last > 0, false));
24290 return lines.join("");
24291 }
24292 /**
24293 * @param {string} value
24294 * Line to trim.
24295 * @param {boolean} start
24296 * Whether to trim the start of the line.
24297 * @param {boolean} end
24298 * Whether to trim the end of the line.
24299 * @returns {string}
24300 * Trimmed line.
24301 */
24302 function trimLine(value, start, end) {
24303 let startIndex = 0;
24304 let endIndex = value.length;
24305 if (start) {
24306 let code = value.codePointAt(startIndex);
24307 while (code === tab || code === space) {
24308 startIndex++;
24309 code = value.codePointAt(startIndex);
24310 }
24311 }
24312 if (end) {
24313 let code = value.codePointAt(endIndex - 1);
24314 while (code === tab || code === space) {
24315 endIndex--;
24316 code = value.codePointAt(endIndex - 1);
24317 }
24318 }
24319 return endIndex > startIndex ? value.slice(startIndex, endIndex) : "";
24320 }
24321 var tab, space;
24322 var init_trim_lines = __esmMin((() => {
24323 tab = 9;
24324 space = 32;
24325 }));
24326
24327 //#endregion
24328 //#region node_modules/mdast-util-to-hast/lib/handlers/text.js
24329 /**
24330 * Turn an mdast `text` node into hast.
24331 *
24332 * @param {State} state
24333 * Info passed around.
24334 * @param {MdastText} node
24335 * mdast node.
24336 * @returns {HastText | HastElement}
24337 * hast node.
24338 */
24339 function text(state, node) {
24340 /** @type {HastText} */
24341 const result = {
24342 type: "text",
24343 value: trimLines(String(node.value))
24344 };
24345 state.patch(node, result);
24346 return state.applyData(node, result);
24347 }
24348 var init_text = __esmMin((() => {
24349 init_trim_lines();
24350 }));
24351
24352 //#endregion
24353 //#region node_modules/mdast-util-to-hast/lib/handlers/thematic-break.js
24354 /**
24355 * @typedef {import('hast').Element} Element
24356 * @typedef {import('mdast').ThematicBreak} ThematicBreak
24357 * @typedef {import('../state.js').State} State
24358 */
24359 /**
24360 * Turn an mdast `thematicBreak` node into hast.
24361 *
24362 * @param {State} state
24363 * Info passed around.
24364 * @param {ThematicBreak} node
24365 * mdast node.
24366 * @returns {Element}
24367 * hast node.
24368 */
24369 function thematicBreak(state, node) {
24370 /** @type {Element} */
24371 const result = {
24372 type: "element",
24373 tagName: "hr",
24374 properties: {},
24375 children: []
24376 };
24377 state.patch(node, result);
24378 return state.applyData(node, result);
24379 }
24380 var init_thematic_break = __esmMin((() => {}));
24381
24382 //#endregion
24383 //#region node_modules/mdast-util-to-hast/lib/handlers/index.js
24384 function ignore() {
24385 return null;
24386 }
24387 var handlers;
24388 var init_handlers = __esmMin((() => {
24389 init_blockquote();
24390 init_break();
24391 init_code();
24392 init_delete();
24393 init_emphasis();
24394 init_footnote_reference();
24395 init_footnote();
24396 init_heading();
24397 init_html$1();
24398 init_image_reference();
24399 init_image();
24400 init_inline_code();
24401 init_link_reference();
24402 init_link();
24403 init_list_item();
24404 init_list();
24405 init_paragraph();
24406 init_root();
24407 init_strong();
24408 init_table();
24409 init_table_row();
24410 init_table_cell();
24411 init_text();
24412 init_thematic_break();
24413 handlers = {
24414 blockquote,
24415 break: hardBreak,
24416 code,
24417 delete: strikethrough,
24418 emphasis,
24419 footnoteReference,
24420 footnote,
24421 heading,
24422 html: html$2,
24423 imageReference,
24424 image,
24425 inlineCode,
24426 linkReference,
24427 link,
24428 listItem,
24429 list,
24430 paragraph,
24431 root,
24432 strong,
24433 table,
24434 tableCell,
24435 tableRow,
24436 text,
24437 thematicBreak,
24438 toml: ignore,
24439 yaml: ignore,
24440 definition: ignore,
24441 footnoteDefinition: ignore
24442 };
24443 }));
24444
24445 //#endregion
24446 //#region node_modules/unist-util-is/lib/index.js
24447 /**
24448 * @param {Array<string | Props | TestFunctionAnything>} tests
24449 * @returns {AssertAnything}
24450 */
24451 function anyFactory(tests) {
24452 /** @type {Array<AssertAnything>} */
24453 const checks = [];
24454 let index = -1;
24455 while (++index < tests.length) checks[index] = convert(tests[index]);
24456 return castFactory(any);
24457 /**
24458 * @this {unknown}
24459 * @param {Array<unknown>} parameters
24460 * @returns {boolean}
24461 */
24462 function any(...parameters) {
24463 let index = -1;
24464 while (++index < checks.length) if (checks[index].call(this, ...parameters)) return true;
24465 return false;
24466 }
24467 }
24468 /**
24469 * Turn an object into a test for a node with a certain fields.
24470 *
24471 * @param {Props} check
24472 * @returns {AssertAnything}
24473 */
24474 function propsFactory(check) {
24475 return castFactory(all);
24476 /**
24477 * @param {Node} node
24478 * @returns {boolean}
24479 */
24480 function all(node) {
24481 /** @type {string} */
24482 let key;
24483 for (key in check) if (node[key] !== check[key]) return false;
24484 return true;
24485 }
24486 }
24487 /**
24488 * Turn a string into a test for a node with a certain type.
24489 *
24490 * @param {string} check
24491 * @returns {AssertAnything}
24492 */
24493 function typeFactory(check) {
24494 return castFactory(type);
24495 /**
24496 * @param {Node} node
24497 */
24498 function type(node) {
24499 return node && node.type === check;
24500 }
24501 }
24502 /**
24503 * Turn a custom test into a test for a node that passes that test.
24504 *
24505 * @param {TestFunctionAnything} check
24506 * @returns {AssertAnything}
24507 */
24508 function castFactory(check) {
24509 return assertion;
24510 /**
24511 * @this {unknown}
24512 * @param {unknown} node
24513 * @param {Array<unknown>} parameters
24514 * @returns {boolean}
24515 */
24516 function assertion(node, ...parameters) {
24517 return Boolean(node && typeof node === "object" && "type" in node && Boolean(check.call(this, node, ...parameters)));
24518 }
24519 }
24520 function ok() {
24521 return true;
24522 }
24523 var convert;
24524 var init_lib$6 = __esmMin((() => {
24525 convert = (
24526 /**
24527 * @param {Test} [test]
24528 * @returns {AssertAnything}
24529 */
24530 function(test) {
24531 if (test === void 0 || test === null) return ok;
24532 if (typeof test === "string") return typeFactory(test);
24533 if (typeof test === "object") return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
24534 if (typeof test === "function") return castFactory(test);
24535 throw new Error("Expected function, string, or object as test");
24536 });
24537 }));
24538
24539 //#endregion
24540 //#region node_modules/unist-util-is/index.js
24541 var init_unist_util_is = __esmMin((() => {
24542 init_lib$6();
24543 }));
24544
24545 //#endregion
24546 //#region node_modules/unist-util-visit-parents/lib/color.browser.js
24547 /**
24548 * @param {string} d
24549 * @returns {string}
24550 */
24551 function color(d) {
24552 return d;
24553 }
24554 var init_color_browser = __esmMin((() => {}));
24555
24556 //#endregion
24557 //#region node_modules/unist-util-visit-parents/lib/index.js
24558 /**
24559 * Turn a return value into a clean result.
24560 *
24561 * @param {VisitorResult} value
24562 * Valid return values from visitors.
24563 * @returns {ActionTuple}
24564 * Clean result.
24565 */
24566 function toResult(value) {
24567 if (Array.isArray(value)) return value;
24568 if (typeof value === "number") return [true, value];
24569 return [value];
24570 }
24571 var CONTINUE, EXIT, SKIP, visitParents;
24572 var init_lib$5 = __esmMin((() => {
24573 init_unist_util_is();
24574 init_color_browser();
24575 CONTINUE = true;
24576 EXIT = false;
24577 SKIP = "skip";
24578 visitParents = (
24579 /**
24580 * @param {Node} tree
24581 * @param {Test} test
24582 * @param {Visitor<Node>} visitor
24583 * @param {boolean | null | undefined} [reverse]
24584 * @returns {void}
24585 */
24586 function(tree, test, visitor, reverse) {
24587 if (typeof test === "function" && typeof visitor !== "function") {
24588 reverse = visitor;
24589 visitor = test;
24590 test = null;
24591 }
24592 const is = convert(test);
24593 const step = reverse ? -1 : 1;
24594 factory(tree, void 0, [])();
24595 /**
24596 * @param {Node} node
24597 * @param {number | undefined} index
24598 * @param {Array<Parent>} parents
24599 */
24600 function factory(node, index, parents) {
24601 /** @type {Record<string, unknown>} */
24602 const value = node && typeof node === "object" ? node : {};
24603 if (typeof value.type === "string") {
24604 const name = typeof value.tagName === "string" ? value.tagName : typeof value.name === "string" ? value.name : void 0;
24605 Object.defineProperty(visit, "name", { value: "node (" + color(node.type + (name ? "<" + name + ">" : "")) + ")" });
24606 }
24607 return visit;
24608 function visit() {
24609 /** @type {ActionTuple} */
24610 let result = [];
24611 /** @type {ActionTuple} */
24612 let subresult;
24613 /** @type {number} */
24614 let offset;
24615 /** @type {Array<Parent>} */
24616 let grandparents;
24617 if (!test || is(node, index, parents[parents.length - 1] || null)) {
24618 result = toResult(visitor(node, parents));
24619 if (result[0] === false) return result;
24620 }
24621 if (node.children && result[0] !== "skip") {
24622 offset = (reverse ? node.children.length : -1) + step;
24623 grandparents = parents.concat(node);
24624 while (offset > -1 && offset < node.children.length) {
24625 subresult = factory(node.children[offset], offset, grandparents)();
24626 if (subresult[0] === false) return subresult;
24627 offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
24628 }
24629 }
24630 return result;
24631 }
24632 }
24633 });
24634 }));
24635
24636 //#endregion
24637 //#region node_modules/unist-util-visit-parents/index.js
24638 var init_unist_util_visit_parents = __esmMin((() => {
24639 init_lib$5();
24640 }));
24641
24642 //#endregion
24643 //#region node_modules/unist-util-visit/lib/index.js
24644 var visit;
24645 var init_lib$4 = __esmMin((() => {
24646 init_unist_util_visit_parents();
24647 visit = (
24648 /**
24649 * @param {Node} tree
24650 * @param {Test} test
24651 * @param {Visitor} visitor
24652 * @param {boolean | null | undefined} [reverse]
24653 * @returns {void}
24654 */
24655 function(tree, test, visitor, reverse) {
24656 if (typeof test === "function" && typeof visitor !== "function") {
24657 reverse = visitor;
24658 visitor = test;
24659 test = null;
24660 }
24661 visitParents(tree, test, overload, reverse);
24662 /**
24663 * @param {Node} node
24664 * @param {Array<Parent>} parents
24665 */
24666 function overload(node, parents) {
24667 const parent = parents[parents.length - 1];
24668 return visitor(node, parent ? parent.children.indexOf(node) : null, parent);
24669 }
24670 });
24671 }));
24672
24673 //#endregion
24674 //#region node_modules/unist-util-visit/index.js
24675 var init_unist_util_visit = __esmMin((() => {
24676 init_lib$4();
24677 }));
24678
24679 //#endregion
24680 //#region node_modules/unist-util-generated/lib/index.js
24681 /**
24682 * @typedef PointLike
24683 * @property {number | null | undefined} [line]
24684 * @property {number | null | undefined} [column]
24685 * @property {number | null | undefined} [offset]
24686 *
24687 * @typedef PositionLike
24688 * @property {PointLike | null | undefined} [start]
24689 * @property {PointLike | null | undefined} [end]
24690 *
24691 * @typedef NodeLike
24692 * @property {PositionLike | null | undefined} [position]
24693 */
24694 /**
24695 * Check if `node` is generated.
24696 *
24697 * @param {NodeLike | null | undefined} [node]
24698 * Node to check.
24699 * @returns {boolean}
24700 * Whether `node` is generated (does not have positional info).
24701 */
24702 function generated(node) {
24703 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;
24704 }
24705 var init_lib$3 = __esmMin((() => {}));
24706
24707 //#endregion
24708 //#region node_modules/unist-util-generated/index.js
24709 var init_unist_util_generated = __esmMin((() => {
24710 init_lib$3();
24711 }));
24712
24713 //#endregion
24714 //#region node_modules/mdast-util-definitions/lib/index.js
24715 /**
24716 * Find definitions in `tree`.
24717 *
24718 * Uses CommonMark precedence, which means that earlier definitions are
24719 * preferred over duplicate later definitions.
24720 *
24721 * @param {Node} tree
24722 * Tree to check.
24723 * @returns {GetDefinition}
24724 * Getter.
24725 */
24726 function definitions(tree) {
24727 /** @type {Record<string, Definition>} */
24728 const cache = Object.create(null);
24729 if (!tree || !tree.type) throw new Error("mdast-util-definitions expected node");
24730 visit(tree, "definition", (definition) => {
24731 const id = clean(definition.identifier);
24732 if (id && !own$4.call(cache, id)) cache[id] = definition;
24733 });
24734 return definition;
24735 /** @type {GetDefinition} */
24736 function definition(identifier) {
24737 const id = clean(identifier);
24738 return id && own$4.call(cache, id) ? cache[id] : null;
24739 }
24740 }
24741 /**
24742 * @param {string | null | undefined} [value]
24743 * @returns {string}
24744 */
24745 function clean(value) {
24746 return String(value || "").toUpperCase();
24747 }
24748 var own$4;
24749 var init_lib$2 = __esmMin((() => {
24750 init_unist_util_visit();
24751 own$4 = {}.hasOwnProperty;
24752 }));
24753
24754 //#endregion
24755 //#region node_modules/mdast-util-definitions/index.js
24756 var init_mdast_util_definitions = __esmMin((() => {
24757 init_lib$2();
24758 }));
24759
24760 //#endregion
24761 //#region node_modules/mdast-util-to-hast/lib/state.js
24762 /**
24763 * Create `state` from an mdast tree.
24764 *
24765 * @param {MdastNodes} tree
24766 * mdast node to transform.
24767 * @param {Options | null | undefined} [options]
24768 * Configuration.
24769 * @returns {State}
24770 * `state` function.
24771 */
24772 function createState(tree, options) {
24773 const settings = options || {};
24774 const dangerous = settings.allowDangerousHtml || false;
24775 /** @type {Record<string, MdastFootnoteDefinition>} */
24776 const footnoteById = {};
24777 state.dangerous = dangerous;
24778 state.clobberPrefix = settings.clobberPrefix === void 0 || settings.clobberPrefix === null ? "user-content-" : settings.clobberPrefix;
24779 state.footnoteLabel = settings.footnoteLabel || "Footnotes";
24780 state.footnoteLabelTagName = settings.footnoteLabelTagName || "h2";
24781 state.footnoteLabelProperties = settings.footnoteLabelProperties || { className: ["sr-only"] };
24782 state.footnoteBackLabel = settings.footnoteBackLabel || "Back to content";
24783 state.unknownHandler = settings.unknownHandler;
24784 state.passThrough = settings.passThrough;
24785 state.handlers = _objectSpread2(_objectSpread2({}, handlers), settings.handlers);
24786 state.definition = definitions(tree);
24787 state.footnoteById = footnoteById;
24788 /** @type {Array<string>} */
24789 state.footnoteOrder = [];
24790 /** @type {Record<string, number>} */
24791 state.footnoteCounts = {};
24792 state.patch = patch;
24793 state.applyData = applyData;
24794 state.one = oneBound;
24795 state.all = allBound;
24796 state.wrap = wrap;
24797 state.augment = augment;
24798 visit(tree, "footnoteDefinition", (definition) => {
24799 const id = String(definition.identifier).toUpperCase();
24800 if (!own$3.call(footnoteById, id)) footnoteById[id] = definition;
24801 });
24802 return state;
24803 /**
24804 * Finalise the created `right`, a hast node, from `left`, an mdast node.
24805 *
24806 * @param {MdastNodeWithData | PositionLike | null | undefined} left
24807 * @param {HastElementContent} right
24808 * @returns {HastElementContent}
24809 */
24810 /* c8 ignore start */
24811 function augment(left, right) {
24812 if (left && "data" in left && left.data) {
24813 /** @type {MdastData} */
24814 const data = left.data;
24815 if (data.hName) {
24816 if (right.type !== "element") right = {
24817 type: "element",
24818 tagName: "",
24819 properties: {},
24820 children: []
24821 };
24822 right.tagName = data.hName;
24823 }
24824 if (right.type === "element" && data.hProperties) right.properties = _objectSpread2(_objectSpread2({}, right.properties), data.hProperties);
24825 if ("children" in right && right.children && data.hChildren) right.children = data.hChildren;
24826 }
24827 if (left) {
24828 const ctx = "type" in left ? left : { position: left };
24829 if (!generated(ctx)) right.position = {
24830 start: pointStart(ctx),
24831 end: pointEnd(ctx)
24832 };
24833 }
24834 return right;
24835 }
24836 /* c8 ignore stop */
24837 /**
24838 * Create an element for `node`.
24839 *
24840 * @type {HFunctionProps}
24841 */
24842 /* c8 ignore start */
24843 function state(node, tagName, props, children) {
24844 if (Array.isArray(props)) {
24845 children = props;
24846 props = {};
24847 }
24848 return augment(node, {
24849 type: "element",
24850 tagName,
24851 properties: props || {},
24852 children: children || []
24853 });
24854 }
24855 /* c8 ignore stop */
24856 /**
24857 * Transform an mdast node into a hast node.
24858 *
24859 * @param {MdastNodes} node
24860 * mdast node.
24861 * @param {MdastParents | null | undefined} [parent]
24862 * Parent of `node`.
24863 * @returns {HastElementContent | Array<HastElementContent> | null | undefined}
24864 * Resulting hast node.
24865 */
24866 function oneBound(node, parent) {
24867 return one(state, node, parent);
24868 }
24869 /**
24870 * Transform the children of an mdast node into hast nodes.
24871 *
24872 * @param {MdastNodes} parent
24873 * mdast node to compile
24874 * @returns {Array<HastElementContent>}
24875 * Resulting hast nodes.
24876 */
24877 function allBound(parent) {
24878 return all(state, parent);
24879 }
24880 }
24881 /**
24882 * Copy a node’s positional info.
24883 *
24884 * @param {MdastNodes} from
24885 * mdast node to copy from.
24886 * @param {HastNodes} to
24887 * hast node to copy into.
24888 * @returns {void}
24889 * Nothing.
24890 */
24891 function patch(from, to) {
24892 if (from.position) to.position = position(from);
24893 }
24894 /**
24895 * Honor the `data` of `from` and maybe generate an element instead of `to`.
24896 *
24897 * @template {HastNodes} Type
24898 * Node type.
24899 * @param {MdastNodes} from
24900 * mdast node to use data from.
24901 * @param {Type} to
24902 * hast node to change.
24903 * @returns {Type | HastElement}
24904 * Nothing.
24905 */
24906 function applyData(from, to) {
24907 /** @type {Type | HastElement} */
24908 let result = to;
24909 if (from && from.data) {
24910 const hName = from.data.hName;
24911 const hChildren = from.data.hChildren;
24912 const hProperties = from.data.hProperties;
24913 if (typeof hName === "string") if (result.type === "element") result.tagName = hName;
24914 else result = {
24915 type: "element",
24916 tagName: hName,
24917 properties: {},
24918 children: []
24919 };
24920 if (result.type === "element" && hProperties) result.properties = _objectSpread2(_objectSpread2({}, result.properties), hProperties);
24921 if ("children" in result && result.children && hChildren !== null && hChildren !== void 0) result.children = hChildren;
24922 }
24923 return result;
24924 }
24925 /**
24926 * Transform an mdast node into a hast node.
24927 *
24928 * @param {State} state
24929 * Info passed around.
24930 * @param {MdastNodes} node
24931 * mdast node.
24932 * @param {MdastParents | null | undefined} [parent]
24933 * Parent of `node`.
24934 * @returns {HastElementContent | Array<HastElementContent> | null | undefined}
24935 * Resulting hast node.
24936 */
24937 function one(state, node, parent) {
24938 const type = node && node.type;
24939 if (!type) throw new Error("Expected node, got `" + node + "`");
24940 if (own$3.call(state.handlers, type)) return state.handlers[type](state, node, parent);
24941 if (state.passThrough && state.passThrough.includes(type)) return "children" in node ? _objectSpread2(_objectSpread2({}, node), {}, { children: all(state, node) }) : node;
24942 if (state.unknownHandler) return state.unknownHandler(state, node, parent);
24943 return defaultUnknownHandler(state, node);
24944 }
24945 /**
24946 * Transform the children of an mdast node into hast nodes.
24947 *
24948 * @param {State} state
24949 * Info passed around.
24950 * @param {MdastNodes} parent
24951 * mdast node to compile
24952 * @returns {Array<HastElementContent>}
24953 * Resulting hast nodes.
24954 */
24955 function all(state, parent) {
24956 /** @type {Array<HastElementContent>} */
24957 const values = [];
24958 if ("children" in parent) {
24959 const nodes = parent.children;
24960 let index = -1;
24961 while (++index < nodes.length) {
24962 const result = one(state, nodes[index], parent);
24963 if (result) {
24964 if (index && nodes[index - 1].type === "break") {
24965 if (!Array.isArray(result) && result.type === "text") result.value = result.value.replace(/^\s+/, "");
24966 if (!Array.isArray(result) && result.type === "element") {
24967 const head = result.children[0];
24968 if (head && head.type === "text") head.value = head.value.replace(/^\s+/, "");
24969 }
24970 }
24971 if (Array.isArray(result)) values.push(...result);
24972 else values.push(result);
24973 }
24974 }
24975 }
24976 return values;
24977 }
24978 /**
24979 * Transform an unknown node.
24980 *
24981 * @param {State} state
24982 * Info passed around.
24983 * @param {MdastNodes} node
24984 * Unknown mdast node.
24985 * @returns {HastText | HastElement}
24986 * Resulting hast node.
24987 */
24988 function defaultUnknownHandler(state, node) {
24989 const data = node.data || {};
24990 /** @type {HastText | HastElement} */
24991 const result = "value" in node && !(own$3.call(data, "hProperties") || own$3.call(data, "hChildren")) ? {
24992 type: "text",
24993 value: node.value
24994 } : {
24995 type: "element",
24996 tagName: "div",
24997 properties: {},
24998 children: all(state, node)
24999 };
25000 state.patch(node, result);
25001 return state.applyData(node, result);
25002 }
25003 /**
25004 * Wrap `nodes` with line endings between each node.
25005 *
25006 * @template {HastContent} Type
25007 * Node type.
25008 * @param {Array<Type>} nodes
25009 * List of nodes to wrap.
25010 * @param {boolean | null | undefined} [loose=false]
25011 * Whether to add line endings at start and end.
25012 * @returns {Array<Type | HastText>}
25013 * Wrapped nodes.
25014 */
25015 function wrap(nodes, loose) {
25016 /** @type {Array<Type | HastText>} */
25017 const result = [];
25018 let index = -1;
25019 if (loose) result.push({
25020 type: "text",
25021 value: "\n"
25022 });
25023 while (++index < nodes.length) {
25024 if (index) result.push({
25025 type: "text",
25026 value: "\n"
25027 });
25028 result.push(nodes[index]);
25029 }
25030 if (loose && nodes.length > 0) result.push({
25031 type: "text",
25032 value: "\n"
25033 });
25034 return result;
25035 }
25036 var own$3;
25037 var init_state = __esmMin((() => {
25038 init_unist_util_visit();
25039 init_unist_util_position();
25040 init_unist_util_generated();
25041 init_mdast_util_definitions();
25042 init_handlers();
25043 init_objectSpread2();
25044 own$3 = {}.hasOwnProperty;
25045 }));
25046
25047 //#endregion
25048 //#region node_modules/mdast-util-to-hast/lib/footer.js
25049 /**
25050 * Generate a hast footer for called footnote definitions.
25051 *
25052 * @param {State} state
25053 * Info passed around.
25054 * @returns {Element | undefined}
25055 * `section` element or `undefined`.
25056 */
25057 function footer(state) {
25058 /** @type {Array<ElementContent>} */
25059 const listItems = [];
25060 let index = -1;
25061 while (++index < state.footnoteOrder.length) {
25062 const def = state.footnoteById[state.footnoteOrder[index]];
25063 if (!def) continue;
25064 const content = state.all(def);
25065 const id = String(def.identifier).toUpperCase();
25066 const safeId = normalizeUri(id.toLowerCase());
25067 let referenceIndex = 0;
25068 /** @type {Array<ElementContent>} */
25069 const backReferences = [];
25070 while (++referenceIndex <= state.footnoteCounts[id]) {
25071 /** @type {Element} */
25072 const backReference = {
25073 type: "element",
25074 tagName: "a",
25075 properties: {
25076 href: "#" + state.clobberPrefix + "fnref-" + safeId + (referenceIndex > 1 ? "-" + referenceIndex : ""),
25077 dataFootnoteBackref: true,
25078 className: ["data-footnote-backref"],
25079 ariaLabel: state.footnoteBackLabel
25080 },
25081 children: [{
25082 type: "text",
25083 value: "↩"
25084 }]
25085 };
25086 if (referenceIndex > 1) backReference.children.push({
25087 type: "element",
25088 tagName: "sup",
25089 children: [{
25090 type: "text",
25091 value: String(referenceIndex)
25092 }]
25093 });
25094 if (backReferences.length > 0) backReferences.push({
25095 type: "text",
25096 value: " "
25097 });
25098 backReferences.push(backReference);
25099 }
25100 const tail = content[content.length - 1];
25101 if (tail && tail.type === "element" && tail.tagName === "p") {
25102 const tailTail = tail.children[tail.children.length - 1];
25103 if (tailTail && tailTail.type === "text") tailTail.value += " ";
25104 else tail.children.push({
25105 type: "text",
25106 value: " "
25107 });
25108 tail.children.push(...backReferences);
25109 } else content.push(...backReferences);
25110 /** @type {Element} */
25111 const listItem = {
25112 type: "element",
25113 tagName: "li",
25114 properties: { id: state.clobberPrefix + "fn-" + safeId },
25115 children: state.wrap(content, true)
25116 };
25117 state.patch(def, listItem);
25118 listItems.push(listItem);
25119 }
25120 if (listItems.length === 0) return;
25121 return {
25122 type: "element",
25123 tagName: "section",
25124 properties: {
25125 dataFootnotes: true,
25126 className: ["footnotes"]
25127 },
25128 children: [
25129 {
25130 type: "element",
25131 tagName: state.footnoteLabelTagName,
25132 properties: _objectSpread2(_objectSpread2({}, JSON.parse(JSON.stringify(state.footnoteLabelProperties))), {}, { id: "footnote-label" }),
25133 children: [{
25134 type: "text",
25135 value: state.footnoteLabel
25136 }]
25137 },
25138 {
25139 type: "text",
25140 value: "\n"
25141 },
25142 {
25143 type: "element",
25144 tagName: "ol",
25145 properties: {},
25146 children: state.wrap(listItems, true)
25147 },
25148 {
25149 type: "text",
25150 value: "\n"
25151 }
25152 ]
25153 };
25154 }
25155 var init_footer = __esmMin((() => {
25156 init_micromark_util_sanitize_uri();
25157 init_objectSpread2();
25158 }));
25159
25160 //#endregion
25161 //#region node_modules/mdast-util-to-hast/lib/index.js
25162 /**
25163 * Transform mdast to hast.
25164 *
25165 * ##### Notes
25166 *
25167 * ###### HTML
25168 *
25169 * Raw HTML is available in mdast as `html` nodes and can be embedded in hast
25170 * as semistandard `raw` nodes.
25171 * Most utilities ignore `raw` nodes but two notable ones don’t:
25172 *
25173 * * `hast-util-to-html` also has an option `allowDangerousHtml` which will
25174 * output the raw HTML.
25175 * This is typically discouraged as noted by the option name but is useful
25176 * if you completely trust authors
25177 * * `hast-util-raw` can handle the raw embedded HTML strings by parsing them
25178 * into standard hast nodes (`element`, `text`, etc).
25179 * This is a heavy task as it needs a full HTML parser, but it is the only
25180 * way to support untrusted content
25181 *
25182 * ###### Footnotes
25183 *
25184 * Many options supported here relate to footnotes.
25185 * Footnotes are not specified by CommonMark, which we follow by default.
25186 * They are supported by GitHub, so footnotes can be enabled in markdown with
25187 * `mdast-util-gfm`.
25188 *
25189 * The options `footnoteBackLabel` and `footnoteLabel` define natural language
25190 * that explains footnotes, which is hidden for sighted users but shown to
25191 * assistive technology.
25192 * When your page is not in English, you must define translated values.
25193 *
25194 * Back references use ARIA attributes, but the section label itself uses a
25195 * heading that is hidden with an `sr-only` class.
25196 * To show it to sighted users, define different attributes in
25197 * `footnoteLabelProperties`.
25198 *
25199 * ###### Clobbering
25200 *
25201 * Footnotes introduces a problem, as it links footnote calls to footnote
25202 * definitions on the page through `id` attributes generated from user content,
25203 * which results in DOM clobbering.
25204 *
25205 * DOM clobbering is this:
25206 *
25207 * ```html
25208 * <p id=x></p>
25209 * <script>alert(x) // `x` now refers to the DOM `p#x` element<\/script>
25210 * ```
25211 *
25212 * Elements by their ID are made available by browsers on the `window` object,
25213 * which is a security risk.
25214 * Using a prefix solves this problem.
25215 *
25216 * More information on how to handle clobbering and the prefix is explained in
25217 * Example: headings (DOM clobbering) in `rehype-sanitize`.
25218 *
25219 * ###### Unknown nodes
25220 *
25221 * Unknown nodes are nodes with a type that isn’t in `handlers` or `passThrough`.
25222 * The default behavior for unknown nodes is:
25223 *
25224 * * when the node has a `value` (and doesn’t have `data.hName`,
25225 * `data.hProperties`, or `data.hChildren`, see later), create a hast `text`
25226 * node
25227 * * otherwise, create a `<div>` element (which could be changed with
25228 * `data.hName`), with its children mapped from mdast to hast as well
25229 *
25230 * This behavior can be changed by passing an `unknownHandler`.
25231 *
25232 * @param {MdastNodes} tree
25233 * mdast tree.
25234 * @param {Options | null | undefined} [options]
25235 * Configuration.
25236 * @returns {HastNodes | null | undefined}
25237 * hast tree.
25238 */
25239 function toHast(tree, options) {
25240 const state = createState(tree, options);
25241 const node = state.one(tree, null);
25242 const foot = footer(state);
25243 if (foot) node.children.push({
25244 type: "text",
25245 value: "\n"
25246 }, foot);
25247 return Array.isArray(node) ? {
25248 type: "root",
25249 children: node
25250 } : node;
25251 }
25252 var init_lib$1 = __esmMin((() => {
25253 init_footer();
25254 init_state();
25255 }));
25256
25257 //#endregion
25258 //#region node_modules/mdast-util-to-hast/index.js
25259 var init_mdast_util_to_hast = __esmMin((() => {
25260 init_handlers();
25261 init_state();
25262 init_lib$1();
25263 }));
25264
25265 //#endregion
25266 //#region node_modules/remark-rehype/lib/index.js
25267 /**
25268 * Bridge-mode.
25269 * Runs the destination with the new hast tree.
25270 *
25271 * @type {import('unified').Plugin<[Processor, Options?], MdastRoot>}
25272 */
25273 function bridge(destination, options) {
25274 return (node, file, next) => {
25275 destination.run(toHast(node, options), file, (error) => {
25276 next(error);
25277 });
25278 };
25279 }
25280 /**
25281 * Mutate-mode.
25282 * Further plugins run on the hast tree.
25283 *
25284 * @type {import('unified').Plugin<[Options?]|void[], MdastRoot, HastRoot>}
25285 */
25286 function mutate(options) {
25287 return (node) => toHast(node, options);
25288 }
25289 var remarkRehype;
25290 var init_lib = __esmMin((() => {
25291 init_mdast_util_to_hast();
25292 remarkRehype = (function(destination, options) {
25293 return destination && "run" in destination ? bridge(destination, options) : mutate(destination || options);
25294 });
25295 }));
25296
25297 //#endregion
25298 //#region node_modules/remark-rehype/index.js
25299 var init_remark_rehype = __esmMin((() => {
25300 init_mdast_util_to_hast();
25301 init_lib();
25302 }));
25303
25304 //#endregion
25305 //#region node_modules/property-information/lib/util/schema.js
25306 var Schema;
25307 var init_schema = __esmMin((() => {
25308 Schema = class {
25309 /**
25310 * @constructor
25311 * @param {Properties} property
25312 * @param {Normal} normal
25313 * @param {string} [space]
25314 */
25315 constructor(property, normal, space) {
25316 this.property = property;
25317 this.normal = normal;
25318 if (space) this.space = space;
25319 }
25320 };
25321 /** @type {Properties} */
25322 Schema.prototype.property = {};
25323 /** @type {Normal} */
25324 Schema.prototype.normal = {};
25325 /** @type {string|null} */
25326 Schema.prototype.space = null;
25327 }));
25328
25329 //#endregion
25330 //#region node_modules/property-information/lib/util/merge.js
25331 /**
25332 * @param {Schema[]} definitions
25333 * @param {string} [space]
25334 * @returns {Schema}
25335 */
25336 function merge(definitions, space) {
25337 /** @type {Properties} */
25338 const property = {};
25339 /** @type {Normal} */
25340 const normal = {};
25341 let index = -1;
25342 while (++index < definitions.length) {
25343 Object.assign(property, definitions[index].property);
25344 Object.assign(normal, definitions[index].normal);
25345 }
25346 return new Schema(property, normal, space);
25347 }
25348 var init_merge = __esmMin((() => {
25349 init_schema();
25350 }));
25351
25352 //#endregion
25353 //#region node_modules/property-information/lib/normalize.js
25354 /**
25355 * @param {string} value
25356 * @returns {string}
25357 */
25358 function normalize(value) {
25359 return value.toLowerCase();
25360 }
25361 var init_normalize = __esmMin((() => {}));
25362
25363 //#endregion
25364 //#region node_modules/property-information/lib/util/info.js
25365 var Info;
25366 var init_info = __esmMin((() => {
25367 Info = class {
25368 /**
25369 * @constructor
25370 * @param {string} property
25371 * @param {string} attribute
25372 */
25373 constructor(property, attribute) {
25374 /** @type {string} */
25375 this.property = property;
25376 /** @type {string} */
25377 this.attribute = attribute;
25378 }
25379 };
25380 /** @type {string|null} */
25381 Info.prototype.space = null;
25382 Info.prototype.boolean = false;
25383 Info.prototype.booleanish = false;
25384 Info.prototype.overloadedBoolean = false;
25385 Info.prototype.number = false;
25386 Info.prototype.commaSeparated = false;
25387 Info.prototype.spaceSeparated = false;
25388 Info.prototype.commaOrSpaceSeparated = false;
25389 Info.prototype.mustUseProperty = false;
25390 Info.prototype.defined = false;
25391 }));
25392
25393 //#endregion
25394 //#region node_modules/property-information/lib/util/types.js
25395 var types_exports = /* @__PURE__ */ __exportAll({
25396 boolean: () => boolean,
25397 booleanish: () => booleanish,
25398 commaOrSpaceSeparated: () => commaOrSpaceSeparated,
25399 commaSeparated: () => commaSeparated,
25400 number: () => number,
25401 overloadedBoolean: () => overloadedBoolean,
25402 spaceSeparated: () => spaceSeparated
25403 });
25404 function increment() {
25405 return Math.pow(2, ++powers);
25406 }
25407 var powers, boolean, booleanish, overloadedBoolean, number, spaceSeparated, commaSeparated, commaOrSpaceSeparated;
25408 var init_types = __esmMin((() => {
25409 powers = 0;
25410 boolean = increment();
25411 booleanish = increment();
25412 overloadedBoolean = increment();
25413 number = increment();
25414 spaceSeparated = increment();
25415 commaSeparated = increment();
25416 commaOrSpaceSeparated = increment();
25417 }));
25418
25419 //#endregion
25420 //#region node_modules/property-information/lib/util/defined-info.js
25421 /**
25422 * @param {DefinedInfo} values
25423 * @param {string} key
25424 * @param {unknown} value
25425 */
25426 function mark(values, key, value) {
25427 if (value) values[key] = value;
25428 }
25429 var checks, DefinedInfo;
25430 var init_defined_info = __esmMin((() => {
25431 init_info();
25432 init_types();
25433 checks = Object.keys(types_exports);
25434 DefinedInfo = class extends Info {
25435 /**
25436 * @constructor
25437 * @param {string} property
25438 * @param {string} attribute
25439 * @param {number|null} [mask]
25440 * @param {string} [space]
25441 */
25442 constructor(property, attribute, mask, space) {
25443 let index = -1;
25444 super(property, attribute);
25445 mark(this, "space", space);
25446 if (typeof mask === "number") while (++index < checks.length) {
25447 const check = checks[index];
25448 mark(this, checks[index], (mask & types_exports[check]) === types_exports[check]);
25449 }
25450 }
25451 };
25452 DefinedInfo.prototype.defined = true;
25453 }));
25454
25455 //#endregion
25456 //#region node_modules/property-information/lib/util/create.js
25457 /**
25458 * @param {Definition} definition
25459 * @returns {Schema}
25460 */
25461 function create(definition) {
25462 /** @type {Properties} */
25463 const property = {};
25464 /** @type {Normal} */
25465 const normal = {};
25466 /** @type {string} */
25467 let prop;
25468 for (prop in definition.properties) if (own$2.call(definition.properties, prop)) {
25469 const value = definition.properties[prop];
25470 const info = new DefinedInfo(prop, definition.transform(definition.attributes || {}, prop), value, definition.space);
25471 if (definition.mustUseProperty && definition.mustUseProperty.includes(prop)) info.mustUseProperty = true;
25472 property[prop] = info;
25473 normal[normalize(prop)] = prop;
25474 normal[normalize(info.attribute)] = prop;
25475 }
25476 return new Schema(property, normal, definition.space);
25477 }
25478 var own$2;
25479 var init_create = __esmMin((() => {
25480 init_normalize();
25481 init_schema();
25482 init_defined_info();
25483 own$2 = {}.hasOwnProperty;
25484 }));
25485
25486 //#endregion
25487 //#region node_modules/property-information/lib/xlink.js
25488 var xlink;
25489 var init_xlink = __esmMin((() => {
25490 init_create();
25491 xlink = create({
25492 space: "xlink",
25493 transform(_, prop) {
25494 return "xlink:" + prop.slice(5).toLowerCase();
25495 },
25496 properties: {
25497 xLinkActuate: null,
25498 xLinkArcRole: null,
25499 xLinkHref: null,
25500 xLinkRole: null,
25501 xLinkShow: null,
25502 xLinkTitle: null,
25503 xLinkType: null
25504 }
25505 });
25506 }));
25507
25508 //#endregion
25509 //#region node_modules/property-information/lib/xml.js
25510 var xml;
25511 var init_xml = __esmMin((() => {
25512 init_create();
25513 xml = create({
25514 space: "xml",
25515 transform(_, prop) {
25516 return "xml:" + prop.slice(3).toLowerCase();
25517 },
25518 properties: {
25519 xmlLang: null,
25520 xmlBase: null,
25521 xmlSpace: null
25522 }
25523 });
25524 }));
25525
25526 //#endregion
25527 //#region node_modules/property-information/lib/util/case-sensitive-transform.js
25528 /**
25529 * @param {Record<string, string>} attributes
25530 * @param {string} attribute
25531 * @returns {string}
25532 */
25533 function caseSensitiveTransform(attributes, attribute) {
25534 return attribute in attributes ? attributes[attribute] : attribute;
25535 }
25536 var init_case_sensitive_transform = __esmMin((() => {}));
25537
25538 //#endregion
25539 //#region node_modules/property-information/lib/util/case-insensitive-transform.js
25540 /**
25541 * @param {Record<string, string>} attributes
25542 * @param {string} property
25543 * @returns {string}
25544 */
25545 function caseInsensitiveTransform(attributes, property) {
25546 return caseSensitiveTransform(attributes, property.toLowerCase());
25547 }
25548 var init_case_insensitive_transform = __esmMin((() => {
25549 init_case_sensitive_transform();
25550 }));
25551
25552 //#endregion
25553 //#region node_modules/property-information/lib/xmlns.js
25554 var xmlns;
25555 var init_xmlns = __esmMin((() => {
25556 init_create();
25557 init_case_insensitive_transform();
25558 xmlns = create({
25559 space: "xmlns",
25560 attributes: { xmlnsxlink: "xmlns:xlink" },
25561 transform: caseInsensitiveTransform,
25562 properties: {
25563 xmlns: null,
25564 xmlnsXLink: null
25565 }
25566 });
25567 }));
25568
25569 //#endregion
25570 //#region node_modules/property-information/lib/aria.js
25571 var aria;
25572 var init_aria = __esmMin((() => {
25573 init_types();
25574 init_create();
25575 aria = create({
25576 transform(_, prop) {
25577 return prop === "role" ? prop : "aria-" + prop.slice(4).toLowerCase();
25578 },
25579 properties: {
25580 ariaActiveDescendant: null,
25581 ariaAtomic: booleanish,
25582 ariaAutoComplete: null,
25583 ariaBusy: booleanish,
25584 ariaChecked: booleanish,
25585 ariaColCount: number,
25586 ariaColIndex: number,
25587 ariaColSpan: number,
25588 ariaControls: spaceSeparated,
25589 ariaCurrent: null,
25590 ariaDescribedBy: spaceSeparated,
25591 ariaDetails: null,
25592 ariaDisabled: booleanish,
25593 ariaDropEffect: spaceSeparated,
25594 ariaErrorMessage: null,
25595 ariaExpanded: booleanish,
25596 ariaFlowTo: spaceSeparated,
25597 ariaGrabbed: booleanish,
25598 ariaHasPopup: null,
25599 ariaHidden: booleanish,
25600 ariaInvalid: null,
25601 ariaKeyShortcuts: null,
25602 ariaLabel: null,
25603 ariaLabelledBy: spaceSeparated,
25604 ariaLevel: number,
25605 ariaLive: null,
25606 ariaModal: booleanish,
25607 ariaMultiLine: booleanish,
25608 ariaMultiSelectable: booleanish,
25609 ariaOrientation: null,
25610 ariaOwns: spaceSeparated,
25611 ariaPlaceholder: null,
25612 ariaPosInSet: number,
25613 ariaPressed: booleanish,
25614 ariaReadOnly: booleanish,
25615 ariaRelevant: null,
25616 ariaRequired: booleanish,
25617 ariaRoleDescription: spaceSeparated,
25618 ariaRowCount: number,
25619 ariaRowIndex: number,
25620 ariaRowSpan: number,
25621 ariaSelected: booleanish,
25622 ariaSetSize: number,
25623 ariaSort: null,
25624 ariaValueMax: number,
25625 ariaValueMin: number,
25626 ariaValueNow: number,
25627 ariaValueText: null,
25628 role: null
25629 }
25630 });
25631 }));
25632
25633 //#endregion
25634 //#region node_modules/property-information/lib/html.js
25635 var html$1;
25636 var init_html = __esmMin((() => {
25637 init_types();
25638 init_create();
25639 init_case_insensitive_transform();
25640 html$1 = create({
25641 space: "html",
25642 attributes: {
25643 acceptcharset: "accept-charset",
25644 classname: "class",
25645 htmlfor: "for",
25646 httpequiv: "http-equiv"
25647 },
25648 transform: caseInsensitiveTransform,
25649 mustUseProperty: [
25650 "checked",
25651 "multiple",
25652 "muted",
25653 "selected"
25654 ],
25655 properties: {
25656 abbr: null,
25657 accept: commaSeparated,
25658 acceptCharset: spaceSeparated,
25659 accessKey: spaceSeparated,
25660 action: null,
25661 allow: null,
25662 allowFullScreen: boolean,
25663 allowPaymentRequest: boolean,
25664 allowUserMedia: boolean,
25665 alt: null,
25666 as: null,
25667 async: boolean,
25668 autoCapitalize: null,
25669 autoComplete: spaceSeparated,
25670 autoFocus: boolean,
25671 autoPlay: boolean,
25672 blocking: spaceSeparated,
25673 capture: null,
25674 charSet: null,
25675 checked: boolean,
25676 cite: null,
25677 className: spaceSeparated,
25678 cols: number,
25679 colSpan: null,
25680 content: null,
25681 contentEditable: booleanish,
25682 controls: boolean,
25683 controlsList: spaceSeparated,
25684 coords: number | commaSeparated,
25685 crossOrigin: null,
25686 data: null,
25687 dateTime: null,
25688 decoding: null,
25689 default: boolean,
25690 defer: boolean,
25691 dir: null,
25692 dirName: null,
25693 disabled: boolean,
25694 download: overloadedBoolean,
25695 draggable: booleanish,
25696 encType: null,
25697 enterKeyHint: null,
25698 fetchPriority: null,
25699 form: null,
25700 formAction: null,
25701 formEncType: null,
25702 formMethod: null,
25703 formNoValidate: boolean,
25704 formTarget: null,
25705 headers: spaceSeparated,
25706 height: number,
25707 hidden: boolean,
25708 high: number,
25709 href: null,
25710 hrefLang: null,
25711 htmlFor: spaceSeparated,
25712 httpEquiv: spaceSeparated,
25713 id: null,
25714 imageSizes: null,
25715 imageSrcSet: null,
25716 inert: boolean,
25717 inputMode: null,
25718 integrity: null,
25719 is: null,
25720 isMap: boolean,
25721 itemId: null,
25722 itemProp: spaceSeparated,
25723 itemRef: spaceSeparated,
25724 itemScope: boolean,
25725 itemType: spaceSeparated,
25726 kind: null,
25727 label: null,
25728 lang: null,
25729 language: null,
25730 list: null,
25731 loading: null,
25732 loop: boolean,
25733 low: number,
25734 manifest: null,
25735 max: null,
25736 maxLength: number,
25737 media: null,
25738 method: null,
25739 min: null,
25740 minLength: number,
25741 multiple: boolean,
25742 muted: boolean,
25743 name: null,
25744 nonce: null,
25745 noModule: boolean,
25746 noValidate: boolean,
25747 onAbort: null,
25748 onAfterPrint: null,
25749 onAuxClick: null,
25750 onBeforeMatch: null,
25751 onBeforePrint: null,
25752 onBeforeToggle: null,
25753 onBeforeUnload: null,
25754 onBlur: null,
25755 onCancel: null,
25756 onCanPlay: null,
25757 onCanPlayThrough: null,
25758 onChange: null,
25759 onClick: null,
25760 onClose: null,
25761 onContextLost: null,
25762 onContextMenu: null,
25763 onContextRestored: null,
25764 onCopy: null,
25765 onCueChange: null,
25766 onCut: null,
25767 onDblClick: null,
25768 onDrag: null,
25769 onDragEnd: null,
25770 onDragEnter: null,
25771 onDragExit: null,
25772 onDragLeave: null,
25773 onDragOver: null,
25774 onDragStart: null,
25775 onDrop: null,
25776 onDurationChange: null,
25777 onEmptied: null,
25778 onEnded: null,
25779 onError: null,
25780 onFocus: null,
25781 onFormData: null,
25782 onHashChange: null,
25783 onInput: null,
25784 onInvalid: null,
25785 onKeyDown: null,
25786 onKeyPress: null,
25787 onKeyUp: null,
25788 onLanguageChange: null,
25789 onLoad: null,
25790 onLoadedData: null,
25791 onLoadedMetadata: null,
25792 onLoadEnd: null,
25793 onLoadStart: null,
25794 onMessage: null,
25795 onMessageError: null,
25796 onMouseDown: null,
25797 onMouseEnter: null,
25798 onMouseLeave: null,
25799 onMouseMove: null,
25800 onMouseOut: null,
25801 onMouseOver: null,
25802 onMouseUp: null,
25803 onOffline: null,
25804 onOnline: null,
25805 onPageHide: null,
25806 onPageShow: null,
25807 onPaste: null,
25808 onPause: null,
25809 onPlay: null,
25810 onPlaying: null,
25811 onPopState: null,
25812 onProgress: null,
25813 onRateChange: null,
25814 onRejectionHandled: null,
25815 onReset: null,
25816 onResize: null,
25817 onScroll: null,
25818 onScrollEnd: null,
25819 onSecurityPolicyViolation: null,
25820 onSeeked: null,
25821 onSeeking: null,
25822 onSelect: null,
25823 onSlotChange: null,
25824 onStalled: null,
25825 onStorage: null,
25826 onSubmit: null,
25827 onSuspend: null,
25828 onTimeUpdate: null,
25829 onToggle: null,
25830 onUnhandledRejection: null,
25831 onUnload: null,
25832 onVolumeChange: null,
25833 onWaiting: null,
25834 onWheel: null,
25835 open: boolean,
25836 optimum: number,
25837 pattern: null,
25838 ping: spaceSeparated,
25839 placeholder: null,
25840 playsInline: boolean,
25841 popover: null,
25842 popoverTarget: null,
25843 popoverTargetAction: null,
25844 poster: null,
25845 preload: null,
25846 readOnly: boolean,
25847 referrerPolicy: null,
25848 rel: spaceSeparated,
25849 required: boolean,
25850 reversed: boolean,
25851 rows: number,
25852 rowSpan: number,
25853 sandbox: spaceSeparated,
25854 scope: null,
25855 scoped: boolean,
25856 seamless: boolean,
25857 selected: boolean,
25858 shadowRootClonable: boolean,
25859 shadowRootDelegatesFocus: boolean,
25860 shadowRootMode: null,
25861 shape: null,
25862 size: number,
25863 sizes: null,
25864 slot: null,
25865 span: number,
25866 spellCheck: booleanish,
25867 src: null,
25868 srcDoc: null,
25869 srcLang: null,
25870 srcSet: null,
25871 start: number,
25872 step: null,
25873 style: null,
25874 tabIndex: number,
25875 target: null,
25876 title: null,
25877 translate: null,
25878 type: null,
25879 typeMustMatch: boolean,
25880 useMap: null,
25881 value: booleanish,
25882 width: number,
25883 wrap: null,
25884 writingSuggestions: null,
25885 align: null,
25886 aLink: null,
25887 archive: spaceSeparated,
25888 axis: null,
25889 background: null,
25890 bgColor: null,
25891 border: number,
25892 borderColor: null,
25893 bottomMargin: number,
25894 cellPadding: null,
25895 cellSpacing: null,
25896 char: null,
25897 charOff: null,
25898 classId: null,
25899 clear: null,
25900 code: null,
25901 codeBase: null,
25902 codeType: null,
25903 color: null,
25904 compact: boolean,
25905 declare: boolean,
25906 event: null,
25907 face: null,
25908 frame: null,
25909 frameBorder: null,
25910 hSpace: number,
25911 leftMargin: number,
25912 link: null,
25913 longDesc: null,
25914 lowSrc: null,
25915 marginHeight: number,
25916 marginWidth: number,
25917 noResize: boolean,
25918 noHref: boolean,
25919 noShade: boolean,
25920 noWrap: boolean,
25921 object: null,
25922 profile: null,
25923 prompt: null,
25924 rev: null,
25925 rightMargin: number,
25926 rules: null,
25927 scheme: null,
25928 scrolling: booleanish,
25929 standby: null,
25930 summary: null,
25931 text: null,
25932 topMargin: number,
25933 valueType: null,
25934 version: null,
25935 vAlign: null,
25936 vLink: null,
25937 vSpace: number,
25938 allowTransparency: null,
25939 autoCorrect: null,
25940 autoSave: null,
25941 disablePictureInPicture: boolean,
25942 disableRemotePlayback: boolean,
25943 prefix: null,
25944 property: null,
25945 results: number,
25946 security: null,
25947 unselectable: null
25948 }
25949 });
25950 }));
25951
25952 //#endregion
25953 //#region node_modules/property-information/lib/svg.js
25954 var svg$1;
25955 var init_svg = __esmMin((() => {
25956 init_types();
25957 init_create();
25958 init_case_sensitive_transform();
25959 svg$1 = create({
25960 space: "svg",
25961 attributes: {
25962 accentHeight: "accent-height",
25963 alignmentBaseline: "alignment-baseline",
25964 arabicForm: "arabic-form",
25965 baselineShift: "baseline-shift",
25966 capHeight: "cap-height",
25967 className: "class",
25968 clipPath: "clip-path",
25969 clipRule: "clip-rule",
25970 colorInterpolation: "color-interpolation",
25971 colorInterpolationFilters: "color-interpolation-filters",
25972 colorProfile: "color-profile",
25973 colorRendering: "color-rendering",
25974 crossOrigin: "crossorigin",
25975 dataType: "datatype",
25976 dominantBaseline: "dominant-baseline",
25977 enableBackground: "enable-background",
25978 fillOpacity: "fill-opacity",
25979 fillRule: "fill-rule",
25980 floodColor: "flood-color",
25981 floodOpacity: "flood-opacity",
25982 fontFamily: "font-family",
25983 fontSize: "font-size",
25984 fontSizeAdjust: "font-size-adjust",
25985 fontStretch: "font-stretch",
25986 fontStyle: "font-style",
25987 fontVariant: "font-variant",
25988 fontWeight: "font-weight",
25989 glyphName: "glyph-name",
25990 glyphOrientationHorizontal: "glyph-orientation-horizontal",
25991 glyphOrientationVertical: "glyph-orientation-vertical",
25992 hrefLang: "hreflang",
25993 horizAdvX: "horiz-adv-x",
25994 horizOriginX: "horiz-origin-x",
25995 horizOriginY: "horiz-origin-y",
25996 imageRendering: "image-rendering",
25997 letterSpacing: "letter-spacing",
25998 lightingColor: "lighting-color",
25999 markerEnd: "marker-end",
26000 markerMid: "marker-mid",
26001 markerStart: "marker-start",
26002 navDown: "nav-down",
26003 navDownLeft: "nav-down-left",
26004 navDownRight: "nav-down-right",
26005 navLeft: "nav-left",
26006 navNext: "nav-next",
26007 navPrev: "nav-prev",
26008 navRight: "nav-right",
26009 navUp: "nav-up",
26010 navUpLeft: "nav-up-left",
26011 navUpRight: "nav-up-right",
26012 onAbort: "onabort",
26013 onActivate: "onactivate",
26014 onAfterPrint: "onafterprint",
26015 onBeforePrint: "onbeforeprint",
26016 onBegin: "onbegin",
26017 onCancel: "oncancel",
26018 onCanPlay: "oncanplay",
26019 onCanPlayThrough: "oncanplaythrough",
26020 onChange: "onchange",
26021 onClick: "onclick",
26022 onClose: "onclose",
26023 onCopy: "oncopy",
26024 onCueChange: "oncuechange",
26025 onCut: "oncut",
26026 onDblClick: "ondblclick",
26027 onDrag: "ondrag",
26028 onDragEnd: "ondragend",
26029 onDragEnter: "ondragenter",
26030 onDragExit: "ondragexit",
26031 onDragLeave: "ondragleave",
26032 onDragOver: "ondragover",
26033 onDragStart: "ondragstart",
26034 onDrop: "ondrop",
26035 onDurationChange: "ondurationchange",
26036 onEmptied: "onemptied",
26037 onEnd: "onend",
26038 onEnded: "onended",
26039 onError: "onerror",
26040 onFocus: "onfocus",
26041 onFocusIn: "onfocusin",
26042 onFocusOut: "onfocusout",
26043 onHashChange: "onhashchange",
26044 onInput: "oninput",
26045 onInvalid: "oninvalid",
26046 onKeyDown: "onkeydown",
26047 onKeyPress: "onkeypress",
26048 onKeyUp: "onkeyup",
26049 onLoad: "onload",
26050 onLoadedData: "onloadeddata",
26051 onLoadedMetadata: "onloadedmetadata",
26052 onLoadStart: "onloadstart",
26053 onMessage: "onmessage",
26054 onMouseDown: "onmousedown",
26055 onMouseEnter: "onmouseenter",
26056 onMouseLeave: "onmouseleave",
26057 onMouseMove: "onmousemove",
26058 onMouseOut: "onmouseout",
26059 onMouseOver: "onmouseover",
26060 onMouseUp: "onmouseup",
26061 onMouseWheel: "onmousewheel",
26062 onOffline: "onoffline",
26063 onOnline: "ononline",
26064 onPageHide: "onpagehide",
26065 onPageShow: "onpageshow",
26066 onPaste: "onpaste",
26067 onPause: "onpause",
26068 onPlay: "onplay",
26069 onPlaying: "onplaying",
26070 onPopState: "onpopstate",
26071 onProgress: "onprogress",
26072 onRateChange: "onratechange",
26073 onRepeat: "onrepeat",
26074 onReset: "onreset",
26075 onResize: "onresize",
26076 onScroll: "onscroll",
26077 onSeeked: "onseeked",
26078 onSeeking: "onseeking",
26079 onSelect: "onselect",
26080 onShow: "onshow",
26081 onStalled: "onstalled",
26082 onStorage: "onstorage",
26083 onSubmit: "onsubmit",
26084 onSuspend: "onsuspend",
26085 onTimeUpdate: "ontimeupdate",
26086 onToggle: "ontoggle",
26087 onUnload: "onunload",
26088 onVolumeChange: "onvolumechange",
26089 onWaiting: "onwaiting",
26090 onZoom: "onzoom",
26091 overlinePosition: "overline-position",
26092 overlineThickness: "overline-thickness",
26093 paintOrder: "paint-order",
26094 panose1: "panose-1",
26095 pointerEvents: "pointer-events",
26096 referrerPolicy: "referrerpolicy",
26097 renderingIntent: "rendering-intent",
26098 shapeRendering: "shape-rendering",
26099 stopColor: "stop-color",
26100 stopOpacity: "stop-opacity",
26101 strikethroughPosition: "strikethrough-position",
26102 strikethroughThickness: "strikethrough-thickness",
26103 strokeDashArray: "stroke-dasharray",
26104 strokeDashOffset: "stroke-dashoffset",
26105 strokeLineCap: "stroke-linecap",
26106 strokeLineJoin: "stroke-linejoin",
26107 strokeMiterLimit: "stroke-miterlimit",
26108 strokeOpacity: "stroke-opacity",
26109 strokeWidth: "stroke-width",
26110 tabIndex: "tabindex",
26111 textAnchor: "text-anchor",
26112 textDecoration: "text-decoration",
26113 textRendering: "text-rendering",
26114 transformOrigin: "transform-origin",
26115 typeOf: "typeof",
26116 underlinePosition: "underline-position",
26117 underlineThickness: "underline-thickness",
26118 unicodeBidi: "unicode-bidi",
26119 unicodeRange: "unicode-range",
26120 unitsPerEm: "units-per-em",
26121 vAlphabetic: "v-alphabetic",
26122 vHanging: "v-hanging",
26123 vIdeographic: "v-ideographic",
26124 vMathematical: "v-mathematical",
26125 vectorEffect: "vector-effect",
26126 vertAdvY: "vert-adv-y",
26127 vertOriginX: "vert-origin-x",
26128 vertOriginY: "vert-origin-y",
26129 wordSpacing: "word-spacing",
26130 writingMode: "writing-mode",
26131 xHeight: "x-height",
26132 playbackOrder: "playbackorder",
26133 timelineBegin: "timelinebegin"
26134 },
26135 transform: caseSensitiveTransform,
26136 properties: {
26137 about: commaOrSpaceSeparated,
26138 accentHeight: number,
26139 accumulate: null,
26140 additive: null,
26141 alignmentBaseline: null,
26142 alphabetic: number,
26143 amplitude: number,
26144 arabicForm: null,
26145 ascent: number,
26146 attributeName: null,
26147 attributeType: null,
26148 azimuth: number,
26149 bandwidth: null,
26150 baselineShift: null,
26151 baseFrequency: null,
26152 baseProfile: null,
26153 bbox: null,
26154 begin: null,
26155 bias: number,
26156 by: null,
26157 calcMode: null,
26158 capHeight: number,
26159 className: spaceSeparated,
26160 clip: null,
26161 clipPath: null,
26162 clipPathUnits: null,
26163 clipRule: null,
26164 color: null,
26165 colorInterpolation: null,
26166 colorInterpolationFilters: null,
26167 colorProfile: null,
26168 colorRendering: null,
26169 content: null,
26170 contentScriptType: null,
26171 contentStyleType: null,
26172 crossOrigin: null,
26173 cursor: null,
26174 cx: null,
26175 cy: null,
26176 d: null,
26177 dataType: null,
26178 defaultAction: null,
26179 descent: number,
26180 diffuseConstant: number,
26181 direction: null,
26182 display: null,
26183 dur: null,
26184 divisor: number,
26185 dominantBaseline: null,
26186 download: boolean,
26187 dx: null,
26188 dy: null,
26189 edgeMode: null,
26190 editable: null,
26191 elevation: number,
26192 enableBackground: null,
26193 end: null,
26194 event: null,
26195 exponent: number,
26196 externalResourcesRequired: null,
26197 fill: null,
26198 fillOpacity: number,
26199 fillRule: null,
26200 filter: null,
26201 filterRes: null,
26202 filterUnits: null,
26203 floodColor: null,
26204 floodOpacity: null,
26205 focusable: null,
26206 focusHighlight: null,
26207 fontFamily: null,
26208 fontSize: null,
26209 fontSizeAdjust: null,
26210 fontStretch: null,
26211 fontStyle: null,
26212 fontVariant: null,
26213 fontWeight: null,
26214 format: null,
26215 fr: null,
26216 from: null,
26217 fx: null,
26218 fy: null,
26219 g1: commaSeparated,
26220 g2: commaSeparated,
26221 glyphName: commaSeparated,
26222 glyphOrientationHorizontal: null,
26223 glyphOrientationVertical: null,
26224 glyphRef: null,
26225 gradientTransform: null,
26226 gradientUnits: null,
26227 handler: null,
26228 hanging: number,
26229 hatchContentUnits: null,
26230 hatchUnits: null,
26231 height: null,
26232 href: null,
26233 hrefLang: null,
26234 horizAdvX: number,
26235 horizOriginX: number,
26236 horizOriginY: number,
26237 id: null,
26238 ideographic: number,
26239 imageRendering: null,
26240 initialVisibility: null,
26241 in: null,
26242 in2: null,
26243 intercept: number,
26244 k: number,
26245 k1: number,
26246 k2: number,
26247 k3: number,
26248 k4: number,
26249 kernelMatrix: commaOrSpaceSeparated,
26250 kernelUnitLength: null,
26251 keyPoints: null,
26252 keySplines: null,
26253 keyTimes: null,
26254 kerning: null,
26255 lang: null,
26256 lengthAdjust: null,
26257 letterSpacing: null,
26258 lightingColor: null,
26259 limitingConeAngle: number,
26260 local: null,
26261 markerEnd: null,
26262 markerMid: null,
26263 markerStart: null,
26264 markerHeight: null,
26265 markerUnits: null,
26266 markerWidth: null,
26267 mask: null,
26268 maskContentUnits: null,
26269 maskUnits: null,
26270 mathematical: null,
26271 max: null,
26272 media: null,
26273 mediaCharacterEncoding: null,
26274 mediaContentEncodings: null,
26275 mediaSize: number,
26276 mediaTime: null,
26277 method: null,
26278 min: null,
26279 mode: null,
26280 name: null,
26281 navDown: null,
26282 navDownLeft: null,
26283 navDownRight: null,
26284 navLeft: null,
26285 navNext: null,
26286 navPrev: null,
26287 navRight: null,
26288 navUp: null,
26289 navUpLeft: null,
26290 navUpRight: null,
26291 numOctaves: null,
26292 observer: null,
26293 offset: null,
26294 onAbort: null,
26295 onActivate: null,
26296 onAfterPrint: null,
26297 onBeforePrint: null,
26298 onBegin: null,
26299 onCancel: null,
26300 onCanPlay: null,
26301 onCanPlayThrough: null,
26302 onChange: null,
26303 onClick: null,
26304 onClose: null,
26305 onCopy: null,
26306 onCueChange: null,
26307 onCut: null,
26308 onDblClick: null,
26309 onDrag: null,
26310 onDragEnd: null,
26311 onDragEnter: null,
26312 onDragExit: null,
26313 onDragLeave: null,
26314 onDragOver: null,
26315 onDragStart: null,
26316 onDrop: null,
26317 onDurationChange: null,
26318 onEmptied: null,
26319 onEnd: null,
26320 onEnded: null,
26321 onError: null,
26322 onFocus: null,
26323 onFocusIn: null,
26324 onFocusOut: null,
26325 onHashChange: null,
26326 onInput: null,
26327 onInvalid: null,
26328 onKeyDown: null,
26329 onKeyPress: null,
26330 onKeyUp: null,
26331 onLoad: null,
26332 onLoadedData: null,
26333 onLoadedMetadata: null,
26334 onLoadStart: null,
26335 onMessage: null,
26336 onMouseDown: null,
26337 onMouseEnter: null,
26338 onMouseLeave: null,
26339 onMouseMove: null,
26340 onMouseOut: null,
26341 onMouseOver: null,
26342 onMouseUp: null,
26343 onMouseWheel: null,
26344 onOffline: null,
26345 onOnline: null,
26346 onPageHide: null,
26347 onPageShow: null,
26348 onPaste: null,
26349 onPause: null,
26350 onPlay: null,
26351 onPlaying: null,
26352 onPopState: null,
26353 onProgress: null,
26354 onRateChange: null,
26355 onRepeat: null,
26356 onReset: null,
26357 onResize: null,
26358 onScroll: null,
26359 onSeeked: null,
26360 onSeeking: null,
26361 onSelect: null,
26362 onShow: null,
26363 onStalled: null,
26364 onStorage: null,
26365 onSubmit: null,
26366 onSuspend: null,
26367 onTimeUpdate: null,
26368 onToggle: null,
26369 onUnload: null,
26370 onVolumeChange: null,
26371 onWaiting: null,
26372 onZoom: null,
26373 opacity: null,
26374 operator: null,
26375 order: null,
26376 orient: null,
26377 orientation: null,
26378 origin: null,
26379 overflow: null,
26380 overlay: null,
26381 overlinePosition: number,
26382 overlineThickness: number,
26383 paintOrder: null,
26384 panose1: null,
26385 path: null,
26386 pathLength: number,
26387 patternContentUnits: null,
26388 patternTransform: null,
26389 patternUnits: null,
26390 phase: null,
26391 ping: spaceSeparated,
26392 pitch: null,
26393 playbackOrder: null,
26394 pointerEvents: null,
26395 points: null,
26396 pointsAtX: number,
26397 pointsAtY: number,
26398 pointsAtZ: number,
26399 preserveAlpha: null,
26400 preserveAspectRatio: null,
26401 primitiveUnits: null,
26402 propagate: null,
26403 property: commaOrSpaceSeparated,
26404 r: null,
26405 radius: null,
26406 referrerPolicy: null,
26407 refX: null,
26408 refY: null,
26409 rel: commaOrSpaceSeparated,
26410 rev: commaOrSpaceSeparated,
26411 renderingIntent: null,
26412 repeatCount: null,
26413 repeatDur: null,
26414 requiredExtensions: commaOrSpaceSeparated,
26415 requiredFeatures: commaOrSpaceSeparated,
26416 requiredFonts: commaOrSpaceSeparated,
26417 requiredFormats: commaOrSpaceSeparated,
26418 resource: null,
26419 restart: null,
26420 result: null,
26421 rotate: null,
26422 rx: null,
26423 ry: null,
26424 scale: null,
26425 seed: null,
26426 shapeRendering: null,
26427 side: null,
26428 slope: null,
26429 snapshotTime: null,
26430 specularConstant: number,
26431 specularExponent: number,
26432 spreadMethod: null,
26433 spacing: null,
26434 startOffset: null,
26435 stdDeviation: null,
26436 stemh: null,
26437 stemv: null,
26438 stitchTiles: null,
26439 stopColor: null,
26440 stopOpacity: null,
26441 strikethroughPosition: number,
26442 strikethroughThickness: number,
26443 string: null,
26444 stroke: null,
26445 strokeDashArray: commaOrSpaceSeparated,
26446 strokeDashOffset: null,
26447 strokeLineCap: null,
26448 strokeLineJoin: null,
26449 strokeMiterLimit: number,
26450 strokeOpacity: number,
26451 strokeWidth: null,
26452 style: null,
26453 surfaceScale: number,
26454 syncBehavior: null,
26455 syncBehaviorDefault: null,
26456 syncMaster: null,
26457 syncTolerance: null,
26458 syncToleranceDefault: null,
26459 systemLanguage: commaOrSpaceSeparated,
26460 tabIndex: number,
26461 tableValues: null,
26462 target: null,
26463 targetX: number,
26464 targetY: number,
26465 textAnchor: null,
26466 textDecoration: null,
26467 textRendering: null,
26468 textLength: null,
26469 timelineBegin: null,
26470 title: null,
26471 transformBehavior: null,
26472 type: null,
26473 typeOf: commaOrSpaceSeparated,
26474 to: null,
26475 transform: null,
26476 transformOrigin: null,
26477 u1: null,
26478 u2: null,
26479 underlinePosition: number,
26480 underlineThickness: number,
26481 unicode: null,
26482 unicodeBidi: null,
26483 unicodeRange: null,
26484 unitsPerEm: number,
26485 values: null,
26486 vAlphabetic: number,
26487 vMathematical: number,
26488 vectorEffect: null,
26489 vHanging: number,
26490 vIdeographic: number,
26491 version: null,
26492 vertAdvY: number,
26493 vertOriginX: number,
26494 vertOriginY: number,
26495 viewBox: null,
26496 viewTarget: null,
26497 visibility: null,
26498 width: null,
26499 widths: null,
26500 wordSpacing: null,
26501 writingMode: null,
26502 x: null,
26503 x1: null,
26504 x2: null,
26505 xChannelSelector: null,
26506 xHeight: number,
26507 y: null,
26508 y1: null,
26509 y2: null,
26510 yChannelSelector: null,
26511 z: null,
26512 zoomAndPan: null
26513 }
26514 });
26515 }));
26516
26517 //#endregion
26518 //#region node_modules/property-information/lib/find.js
26519 /**
26520 * @param {Schema} schema
26521 * @param {string} value
26522 * @returns {Info}
26523 */
26524 function find(schema, value) {
26525 const normal = normalize(value);
26526 let prop = value;
26527 let Type = Info;
26528 if (normal in schema.normal) return schema.property[schema.normal[normal]];
26529 if (normal.length > 4 && normal.slice(0, 4) === "data" && valid.test(value)) {
26530 if (value.charAt(4) === "-") {
26531 const rest = value.slice(5).replace(dash, camelcase);
26532 prop = "data" + rest.charAt(0).toUpperCase() + rest.slice(1);
26533 } else {
26534 const rest = value.slice(4);
26535 if (!dash.test(rest)) {
26536 let dashes = rest.replace(cap, kebab);
26537 if (dashes.charAt(0) !== "-") dashes = "-" + dashes;
26538 value = "data" + dashes;
26539 }
26540 }
26541 Type = DefinedInfo;
26542 }
26543 return new Type(prop, value);
26544 }
26545 /**
26546 * @param {string} $0
26547 * @returns {string}
26548 */
26549 function kebab($0) {
26550 return "-" + $0.toLowerCase();
26551 }
26552 /**
26553 * @param {string} $0
26554 * @returns {string}
26555 */
26556 function camelcase($0) {
26557 return $0.charAt(1).toUpperCase();
26558 }
26559 var valid, dash, cap;
26560 var init_find = __esmMin((() => {
26561 init_normalize();
26562 init_defined_info();
26563 init_info();
26564 valid = /^data[-\w.:]+$/i;
26565 dash = /-[a-z]/g;
26566 cap = /[A-Z]/g;
26567 }));
26568
26569 //#endregion
26570 //#region node_modules/property-information/lib/hast-to-react.js
26571 var hastToReact;
26572 var init_hast_to_react = __esmMin((() => {
26573 hastToReact = {
26574 classId: "classID",
26575 dataType: "datatype",
26576 itemId: "itemID",
26577 strokeDashArray: "strokeDasharray",
26578 strokeDashOffset: "strokeDashoffset",
26579 strokeLineCap: "strokeLinecap",
26580 strokeLineJoin: "strokeLinejoin",
26581 strokeMiterLimit: "strokeMiterlimit",
26582 typeOf: "typeof",
26583 xLinkActuate: "xlinkActuate",
26584 xLinkArcRole: "xlinkArcrole",
26585 xLinkHref: "xlinkHref",
26586 xLinkRole: "xlinkRole",
26587 xLinkShow: "xlinkShow",
26588 xLinkTitle: "xlinkTitle",
26589 xLinkType: "xlinkType",
26590 xmlnsXLink: "xmlnsXlink"
26591 };
26592 }));
26593
26594 //#endregion
26595 //#region node_modules/property-information/index.js
26596 var html, svg;
26597 var init_property_information = __esmMin((() => {
26598 init_merge();
26599 init_xlink();
26600 init_xml();
26601 init_xmlns();
26602 init_aria();
26603 init_html();
26604 init_svg();
26605 init_find();
26606 init_hast_to_react();
26607 init_normalize();
26608 html = merge([
26609 xml,
26610 xlink,
26611 xmlns,
26612 aria,
26613 html$1
26614 ], "html");
26615 svg = merge([
26616 xml,
26617 xlink,
26618 xmlns,
26619 aria,
26620 svg$1
26621 ], "svg");
26622 }));
26623
26624 //#endregion
26625 //#region node_modules/react-markdown/lib/rehype-filter.js
26626 /**
26627 * @typedef {import('unist').Node} Node
26628 * @typedef {import('hast').Root} Root
26629 * @typedef {import('hast').Element} Element
26630 *
26631 * @callback AllowElement
26632 * @param {Element} element
26633 * @param {number} index
26634 * @param {Element|Root} parent
26635 * @returns {boolean|undefined}
26636 *
26637 * @typedef Options
26638 * @property {Array<string>} [allowedElements]
26639 * @property {Array<string>} [disallowedElements=[]]
26640 * @property {AllowElement} [allowElement]
26641 * @property {boolean} [unwrapDisallowed=false]
26642 */
26643 /**
26644 * @type {import('unified').Plugin<[Options], Root>}
26645 */
26646 function rehypeFilter(options) {
26647 if (options.allowedElements && options.disallowedElements) throw new TypeError("Only one of `allowedElements` and `disallowedElements` should be defined");
26648 if (options.allowedElements || options.disallowedElements || options.allowElement) return (tree) => {
26649 visit(tree, "element", (node, index, parent_) => {
26650 const parent = parent_;
26651 /** @type {boolean|undefined} */
26652 let remove;
26653 if (options.allowedElements) remove = !options.allowedElements.includes(node.tagName);
26654 else if (options.disallowedElements) remove = options.disallowedElements.includes(node.tagName);
26655 if (!remove && options.allowElement && typeof index === "number") remove = !options.allowElement(node, index, parent);
26656 if (remove && typeof index === "number") {
26657 if (options.unwrapDisallowed && node.children) parent.children.splice(index, 1, ...node.children);
26658 else parent.children.splice(index, 1);
26659 return index;
26660 }
26661 });
26662 };
26663 }
26664 var init_rehype_filter = __esmMin((() => {
26665 init_unist_util_visit();
26666 }));
26667
26668 //#endregion
26669 //#region node_modules/react-is/cjs/react-is.development.js
26670 /**
26671 * @license React
26672 * react-is.development.js
26673 *
26674 * Copyright (c) Facebook, Inc. and its affiliates.
26675 *
26676 * This source code is licensed under the MIT license found in the
26677 * LICENSE file in the root directory of this source tree.
26678 */
26679 var require_react_is_development = /* @__PURE__ */ __commonJSMin(((exports) => {
26680 (function() {
26681 "use strict";
26682 var REACT_ELEMENT_TYPE = Symbol.for("react.element");
26683 var REACT_PORTAL_TYPE = Symbol.for("react.portal");
26684 var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
26685 var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
26686 var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
26687 var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
26688 var REACT_CONTEXT_TYPE = Symbol.for("react.context");
26689 var REACT_SERVER_CONTEXT_TYPE = Symbol.for("react.server_context");
26690 var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
26691 var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
26692 var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
26693 var REACT_MEMO_TYPE = Symbol.for("react.memo");
26694 var REACT_LAZY_TYPE = Symbol.for("react.lazy");
26695 var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
26696 var enableScopeAPI = false;
26697 var enableCacheElement = false;
26698 var enableTransitionTracing = false;
26699 var enableLegacyHidden = false;
26700 var enableDebugTracing = false;
26701 var REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
26702 function isValidElementType(type) {
26703 if (typeof type === "string" || typeof type === "function") return true;
26704 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;
26705 if (typeof type === "object" && type !== null) {
26706 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;
26707 }
26708 return false;
26709 }
26710 function typeOf(object) {
26711 if (typeof object === "object" && object !== null) {
26712 var $$typeof = object.$$typeof;
26713 switch ($$typeof) {
26714 case REACT_ELEMENT_TYPE:
26715 var type = object.type;
26716 switch (type) {
26717 case REACT_FRAGMENT_TYPE:
26718 case REACT_PROFILER_TYPE:
26719 case REACT_STRICT_MODE_TYPE:
26720 case REACT_SUSPENSE_TYPE:
26721 case REACT_SUSPENSE_LIST_TYPE: return type;
26722 default:
26723 var $$typeofType = type && type.$$typeof;
26724 switch ($$typeofType) {
26725 case REACT_SERVER_CONTEXT_TYPE:
26726 case REACT_CONTEXT_TYPE:
26727 case REACT_FORWARD_REF_TYPE:
26728 case REACT_LAZY_TYPE:
26729 case REACT_MEMO_TYPE:
26730 case REACT_PROVIDER_TYPE: return $$typeofType;
26731 default: return $$typeof;
26732 }
26733 }
26734 case REACT_PORTAL_TYPE: return $$typeof;
26735 }
26736 }
26737 }
26738 var ContextConsumer = REACT_CONTEXT_TYPE;
26739 var ContextProvider = REACT_PROVIDER_TYPE;
26740 var Element = REACT_ELEMENT_TYPE;
26741 var ForwardRef = REACT_FORWARD_REF_TYPE;
26742 var Fragment = REACT_FRAGMENT_TYPE;
26743 var Lazy = REACT_LAZY_TYPE;
26744 var Memo = REACT_MEMO_TYPE;
26745 var Portal = REACT_PORTAL_TYPE;
26746 var Profiler = REACT_PROFILER_TYPE;
26747 var StrictMode = REACT_STRICT_MODE_TYPE;
26748 var Suspense = REACT_SUSPENSE_TYPE;
26749 var SuspenseList = REACT_SUSPENSE_LIST_TYPE;
26750 var hasWarnedAboutDeprecatedIsAsyncMode = false;
26751 var hasWarnedAboutDeprecatedIsConcurrentMode = false;
26752 function isAsyncMode(object) {
26753 if (!hasWarnedAboutDeprecatedIsAsyncMode) {
26754 hasWarnedAboutDeprecatedIsAsyncMode = true;
26755 console["warn"]("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.");
26756 }
26757 return false;
26758 }
26759 function isConcurrentMode(object) {
26760 if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
26761 hasWarnedAboutDeprecatedIsConcurrentMode = true;
26762 console["warn"]("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.");
26763 }
26764 return false;
26765 }
26766 function isContextConsumer(object) {
26767 return typeOf(object) === REACT_CONTEXT_TYPE;
26768 }
26769 function isContextProvider(object) {
26770 return typeOf(object) === REACT_PROVIDER_TYPE;
26771 }
26772 function isElement(object) {
26773 return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
26774 }
26775 function isForwardRef(object) {
26776 return typeOf(object) === REACT_FORWARD_REF_TYPE;
26777 }
26778 function isFragment(object) {
26779 return typeOf(object) === REACT_FRAGMENT_TYPE;
26780 }
26781 function isLazy(object) {
26782 return typeOf(object) === REACT_LAZY_TYPE;
26783 }
26784 function isMemo(object) {
26785 return typeOf(object) === REACT_MEMO_TYPE;
26786 }
26787 function isPortal(object) {
26788 return typeOf(object) === REACT_PORTAL_TYPE;
26789 }
26790 function isProfiler(object) {
26791 return typeOf(object) === REACT_PROFILER_TYPE;
26792 }
26793 function isStrictMode(object) {
26794 return typeOf(object) === REACT_STRICT_MODE_TYPE;
26795 }
26796 function isSuspense(object) {
26797 return typeOf(object) === REACT_SUSPENSE_TYPE;
26798 }
26799 function isSuspenseList(object) {
26800 return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
26801 }
26802 exports.ContextConsumer = ContextConsumer;
26803 exports.ContextProvider = ContextProvider;
26804 exports.Element = Element;
26805 exports.ForwardRef = ForwardRef;
26806 exports.Fragment = Fragment;
26807 exports.Lazy = Lazy;
26808 exports.Memo = Memo;
26809 exports.Portal = Portal;
26810 exports.Profiler = Profiler;
26811 exports.StrictMode = StrictMode;
26812 exports.Suspense = Suspense;
26813 exports.SuspenseList = SuspenseList;
26814 exports.isAsyncMode = isAsyncMode;
26815 exports.isConcurrentMode = isConcurrentMode;
26816 exports.isContextConsumer = isContextConsumer;
26817 exports.isContextProvider = isContextProvider;
26818 exports.isElement = isElement;
26819 exports.isForwardRef = isForwardRef;
26820 exports.isFragment = isFragment;
26821 exports.isLazy = isLazy;
26822 exports.isMemo = isMemo;
26823 exports.isPortal = isPortal;
26824 exports.isProfiler = isProfiler;
26825 exports.isStrictMode = isStrictMode;
26826 exports.isSuspense = isSuspense;
26827 exports.isSuspenseList = isSuspenseList;
26828 exports.isValidElementType = isValidElementType;
26829 exports.typeOf = typeOf;
26830 })();
26831 }));
26832
26833 //#endregion
26834 //#region node_modules/react-is/index.js
26835 var require_react_is = /* @__PURE__ */ __commonJSMin(((exports, module) => {
26836 module.exports = require_react_is_development();
26837 }));
26838
26839 //#endregion
26840 //#region node_modules/hast-util-whitespace/index.js
26841 /**
26842 * Check if the given value is *inter-element whitespace*.
26843 *
26844 * @param {unknown} thing
26845 * Thing to check (typically `Node` or `string`).
26846 * @returns {boolean}
26847 * Whether the `value` is inter-element whitespace (`boolean`): consisting of
26848 * zero or more of space, tab (`\t`), line feed (`\n`), carriage return
26849 * (`\r`), or form feed (`\f`).
26850 * If a node is passed it must be a `Text` node, whose `value` field is
26851 * checked.
26852 */
26853 function whitespace(thing) {
26854 /** @type {string} */
26855 const value = thing && typeof thing === "object" && thing.type === "text" ? thing.value || "" : thing;
26856 return typeof value === "string" && value.replace(/[ \t\n\f\r]/g, "") === "";
26857 }
26858 var init_hast_util_whitespace = __esmMin((() => {}));
26859
26860 //#endregion
26861 //#region node_modules/space-separated-tokens/index.js
26862 /**
26863 * Serialize an array of strings as space separated-tokens.
26864 *
26865 * @param {Array<string|number>} values
26866 * List of tokens.
26867 * @returns {string}
26868 * Space-separated tokens.
26869 */
26870 function stringify$1(values) {
26871 return values.join(" ").trim();
26872 }
26873 var init_space_separated_tokens = __esmMin((() => {
26874 __name(stringify$1, "stringify");
26875 }));
26876
26877 //#endregion
26878 //#region node_modules/comma-separated-tokens/index.js
26879 /**
26880 * Serialize an array of strings or numbers to comma-separated tokens.
26881 *
26882 * @param {Array<string|number>} values
26883 * List of tokens.
26884 * @param {Options} [options]
26885 * Configuration for `stringify` (optional).
26886 * @returns {string}
26887 * Comma-separated tokens.
26888 */
26889 function stringify(values, options) {
26890 const settings = options || {};
26891 return (values[values.length - 1] === "" ? [...values, ""] : values).join((settings.padRight ? " " : "") + "," + (settings.padLeft === false ? "" : " ")).trim();
26892 }
26893 var init_comma_separated_tokens = __esmMin((() => {}));
26894
26895 //#endregion
26896 //#region node_modules/inline-style-parser/index.js
26897 var require_inline_style_parser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
26898 var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
26899 var NEWLINE_REGEX = /\n/g;
26900 var WHITESPACE_REGEX = /^\s*/;
26901 var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
26902 var COLON_REGEX = /^:\s*/;
26903 var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/;
26904 var SEMICOLON_REGEX = /^[;\s]*/;
26905 var TRIM_REGEX = /^\s+|\s+$/g;
26906 var NEWLINE = "\n";
26907 var FORWARD_SLASH = "/";
26908 var ASTERISK = "*";
26909 var EMPTY_STRING = "";
26910 var TYPE_COMMENT = "comment";
26911 var TYPE_DECLARATION = "declaration";
26912 /**
26913 * @param {String} style
26914 * @param {Object} [options]
26915 * @return {Object[]}
26916 * @throws {TypeError}
26917 * @throws {Error}
26918 */
26919 module.exports = function(style, options) {
26920 if (typeof style !== "string") throw new TypeError("First argument must be a string");
26921 if (!style) return [];
26922 options = options || {};
26923 /**
26924 * Positional.
26925 */
26926 var lineno = 1;
26927 var column = 1;
26928 /**
26929 * Update lineno and column based on `str`.
26930 *
26931 * @param {String} str
26932 */
26933 function updatePosition(str) {
26934 var lines = str.match(NEWLINE_REGEX);
26935 if (lines) lineno += lines.length;
26936 var i = str.lastIndexOf(NEWLINE);
26937 column = ~i ? str.length - i : column + str.length;
26938 }
26939 /**
26940 * Mark position and patch `node.position`.
26941 *
26942 * @return {Function}
26943 */
26944 function position() {
26945 var start = {
26946 line: lineno,
26947 column
26948 };
26949 return function(node) {
26950 node.position = new Position(start);
26951 whitespace();
26952 return node;
26953 };
26954 }
26955 /**
26956 * Store position information for a node.
26957 *
26958 * @constructor
26959 * @property {Object} start
26960 * @property {Object} end
26961 * @property {undefined|String} source
26962 */
26963 function Position(start) {
26964 this.start = start;
26965 this.end = {
26966 line: lineno,
26967 column
26968 };
26969 this.source = options.source;
26970 }
26971 /**
26972 * Non-enumerable source string.
26973 */
26974 Position.prototype.content = style;
26975 var errorsList = [];
26976 /**
26977 * Error `msg`.
26978 *
26979 * @param {String} msg
26980 * @throws {Error}
26981 */
26982 function error(msg) {
26983 var err = /* @__PURE__ */ new Error(options.source + ":" + lineno + ":" + column + ": " + msg);
26984 err.reason = msg;
26985 err.filename = options.source;
26986 err.line = lineno;
26987 err.column = column;
26988 err.source = style;
26989 if (options.silent) errorsList.push(err);
26990 else throw err;
26991 }
26992 /**
26993 * Match `re` and return captures.
26994 *
26995 * @param {RegExp} re
26996 * @return {undefined|Array}
26997 */
26998 function match(re) {
26999 var m = re.exec(style);
27000 if (!m) return;
27001 var str = m[0];
27002 updatePosition(str);
27003 style = style.slice(str.length);
27004 return m;
27005 }
27006 /**
27007 * Parse whitespace.
27008 */
27009 function whitespace() {
27010 match(WHITESPACE_REGEX);
27011 }
27012 /**
27013 * Parse comments.
27014 *
27015 * @param {Object[]} [rules]
27016 * @return {Object[]}
27017 */
27018 function comments(rules) {
27019 var c;
27020 rules = rules || [];
27021 while (c = comment()) if (c !== false) rules.push(c);
27022 return rules;
27023 }
27024 /**
27025 * Parse comment.
27026 *
27027 * @return {Object}
27028 * @throws {Error}
27029 */
27030 function comment() {
27031 var pos = position();
27032 if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
27033 var i = 2;
27034 while (EMPTY_STRING != style.charAt(i) && (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))) ++i;
27035 i += 2;
27036 if (EMPTY_STRING === style.charAt(i - 1)) return error("End of comment missing");
27037 var str = style.slice(2, i - 2);
27038 column += 2;
27039 updatePosition(str);
27040 style = style.slice(i);
27041 column += 2;
27042 return pos({
27043 type: TYPE_COMMENT,
27044 comment: str
27045 });
27046 }
27047 /**
27048 * Parse declaration.
27049 *
27050 * @return {Object}
27051 * @throws {Error}
27052 */
27053 function declaration() {
27054 var pos = position();
27055 var prop = match(PROPERTY_REGEX);
27056 if (!prop) return;
27057 comment();
27058 if (!match(COLON_REGEX)) return error("property missing ':'");
27059 var val = match(VALUE_REGEX);
27060 var ret = pos({
27061 type: TYPE_DECLARATION,
27062 property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
27063 value: val ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING)) : EMPTY_STRING
27064 });
27065 match(SEMICOLON_REGEX);
27066 return ret;
27067 }
27068 /**
27069 * Parse declarations.
27070 *
27071 * @return {Object[]}
27072 */
27073 function declarations() {
27074 var decls = [];
27075 comments(decls);
27076 var decl;
27077 while (decl = declaration()) if (decl !== false) {
27078 decls.push(decl);
27079 comments(decls);
27080 }
27081 return decls;
27082 }
27083 whitespace();
27084 return declarations();
27085 };
27086 /**
27087 * Trim `str`.
27088 *
27089 * @param {String} str
27090 * @return {String}
27091 */
27092 function trim(str) {
27093 return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
27094 }
27095 }));
27096
27097 //#endregion
27098 //#region node_modules/style-to-object/index.js
27099 var require_style_to_object = /* @__PURE__ */ __commonJSMin(((exports, module) => {
27100 var parse = require_inline_style_parser();
27101 /**
27102 * Parses inline style to object.
27103 *
27104 * @example
27105 * // returns { 'line-height': '42' }
27106 * StyleToObject('line-height: 42;');
27107 *
27108 * @param {String} style - The inline style.
27109 * @param {Function} [iterator] - The iterator function.
27110 * @return {null|Object}
27111 */
27112 function StyleToObject(style, iterator) {
27113 var output = null;
27114 if (!style || typeof style !== "string") return output;
27115 var declaration;
27116 var declarations = parse(style);
27117 var hasIterator = typeof iterator === "function";
27118 var property;
27119 var value;
27120 for (var i = 0, len = declarations.length; i < len; i++) {
27121 declaration = declarations[i];
27122 property = declaration.property;
27123 value = declaration.value;
27124 if (hasIterator) iterator(property, value, declaration);
27125 else if (value) {
27126 output || (output = {});
27127 output[property] = value;
27128 }
27129 }
27130 return output;
27131 }
27132 module.exports = StyleToObject;
27133 module.exports.default = StyleToObject;
27134 }));
27135
27136 //#endregion
27137 //#region node_modules/style-to-object/index.mjs
27138 var import_style_to_object, style_to_object_default;
27139 var init_style_to_object = __esmMin((() => {
27140 import_style_to_object = /* @__PURE__ */ __toESM(require_style_to_object(), 1);
27141 style_to_object_default = import_style_to_object.default;
27142 }));
27143
27144 //#endregion
27145 //#region node_modules/react-markdown/lib/ast-to-react.js
27146 /**
27147 * @template T
27148 * @typedef {Promise.resolve(React).ComponentType<T>} ComponentType<T>
27149 */
27150 /**
27151 * @template {Promise.resolve(React).ElementType} T
27152 * @typedef {Promise.resolve(React).ComponentPropsWithoutRef<T>} ComponentPropsWithoutRef<T>
27153 */
27154 /**
27155 * @typedef {Promise.resolve(React).ReactNode} ReactNode
27156 * @typedef {import('unist').Position} Position
27157 * @typedef {import('hast').Element} Element
27158 * @typedef {import('hast').ElementContent} ElementContent
27159 * @typedef {import('hast').Root} Root
27160 * @typedef {import('hast').Text} Text
27161 * @typedef {import('hast').Comment} Comment
27162 * @typedef {import('hast').DocType} Doctype
27163 * @typedef {import('property-information').Info} Info
27164 * @typedef {import('property-information').Schema} Schema
27165 * @typedef {import('./complex-types.js').ReactMarkdownProps} ReactMarkdownProps
27166 *
27167 * @typedef Raw
27168 * @property {'raw'} type
27169 * @property {string} value
27170 *
27171 * @typedef Context
27172 * @property {Options} options
27173 * @property {Schema} schema
27174 * @property {number} listDepth
27175 *
27176 * @callback TransformLink
27177 * @param {string} href
27178 * @param {Array<ElementContent>} children
27179 * @param {string?} title
27180 * @returns {string}
27181 *
27182 * @callback TransformImage
27183 * @param {string} src
27184 * @param {string} alt
27185 * @param {string?} title
27186 * @returns {string}
27187 *
27188 * @typedef {Promise.resolve(React).HTMLAttributeAnchorTarget} TransformLinkTargetType
27189 *
27190 * @callback TransformLinkTarget
27191 * @param {string} href
27192 * @param {Array<ElementContent>} children
27193 * @param {string?} title
27194 * @returns {TransformLinkTargetType|undefined}
27195 *
27196 * @typedef {keyof JSX.IntrinsicElements} ReactMarkdownNames
27197 *
27198 * To do: is `data-sourcepos` typeable?
27199 *
27200 * @typedef {ComponentPropsWithoutRef<'code'> & ReactMarkdownProps & {inline?: boolean}} CodeProps
27201 * @typedef {ComponentPropsWithoutRef<'h1'> & ReactMarkdownProps & {level: number}} HeadingProps
27202 * @typedef {ComponentPropsWithoutRef<'li'> & ReactMarkdownProps & {checked: boolean|null, index: number, ordered: boolean}} LiProps
27203 * @typedef {ComponentPropsWithoutRef<'ol'> & ReactMarkdownProps & {depth: number, ordered: true}} OrderedListProps
27204 * @typedef {ComponentPropsWithoutRef<'td'> & ReactMarkdownProps & {style?: Record<string, unknown>, isHeader: false}} TableDataCellProps
27205 * @typedef {ComponentPropsWithoutRef<'th'> & ReactMarkdownProps & {style?: Record<string, unknown>, isHeader: true}} TableHeaderCellProps
27206 * @typedef {ComponentPropsWithoutRef<'tr'> & ReactMarkdownProps & {isHeader: boolean}} TableRowProps
27207 * @typedef {ComponentPropsWithoutRef<'ul'> & ReactMarkdownProps & {depth: number, ordered: false}} UnorderedListProps
27208 *
27209 * @typedef {ComponentType<CodeProps>} CodeComponent
27210 * @typedef {ComponentType<HeadingProps>} HeadingComponent
27211 * @typedef {ComponentType<LiProps>} LiComponent
27212 * @typedef {ComponentType<OrderedListProps>} OrderedListComponent
27213 * @typedef {ComponentType<TableDataCellProps>} TableDataCellComponent
27214 * @typedef {ComponentType<TableHeaderCellProps>} TableHeaderCellComponent
27215 * @typedef {ComponentType<TableRowProps>} TableRowComponent
27216 * @typedef {ComponentType<UnorderedListProps>} UnorderedListComponent
27217 *
27218 * @typedef SpecialComponents
27219 * @property {CodeComponent|ReactMarkdownNames} code
27220 * @property {HeadingComponent|ReactMarkdownNames} h1
27221 * @property {HeadingComponent|ReactMarkdownNames} h2
27222 * @property {HeadingComponent|ReactMarkdownNames} h3
27223 * @property {HeadingComponent|ReactMarkdownNames} h4
27224 * @property {HeadingComponent|ReactMarkdownNames} h5
27225 * @property {HeadingComponent|ReactMarkdownNames} h6
27226 * @property {LiComponent|ReactMarkdownNames} li
27227 * @property {OrderedListComponent|ReactMarkdownNames} ol
27228 * @property {TableDataCellComponent|ReactMarkdownNames} td
27229 * @property {TableHeaderCellComponent|ReactMarkdownNames} th
27230 * @property {TableRowComponent|ReactMarkdownNames} tr
27231 * @property {UnorderedListComponent|ReactMarkdownNames} ul
27232 *
27233 * @typedef {Partial<Omit<import('./complex-types.js').NormalComponents, keyof SpecialComponents> & SpecialComponents>} Components
27234 *
27235 * @typedef Options
27236 * @property {boolean} [sourcePos=false]
27237 * @property {boolean} [rawSourcePos=false]
27238 * @property {boolean} [skipHtml=false]
27239 * @property {boolean} [includeElementIndex=false]
27240 * @property {null|false|TransformLink} [transformLinkUri]
27241 * @property {TransformImage} [transformImageUri]
27242 * @property {TransformLinkTargetType|TransformLinkTarget} [linkTarget]
27243 * @property {Components} [components]
27244 */
27245 /**
27246 * @param {Context} context
27247 * @param {Element|Root} node
27248 */
27249 function childrenToReact(context, node) {
27250 /** @type {Array<ReactNode>} */
27251 const children = [];
27252 let childIndex = -1;
27253 /** @type {Comment|Doctype|Element|Raw|Text} */
27254 let child;
27255 while (++childIndex < node.children.length) {
27256 child = node.children[childIndex];
27257 if (child.type === "element") children.push(toReact(context, child, childIndex, node));
27258 else if (child.type === "text") {
27259 if (node.type !== "element" || !tableElements.has(node.tagName) || !whitespace(child)) children.push(child.value);
27260 } else if (child.type === "raw" && !context.options.skipHtml) children.push(child.value);
27261 }
27262 return children;
27263 }
27264 /**
27265 * @param {Context} context
27266 * @param {Element} node
27267 * @param {number} index
27268 * @param {Element|Root} parent
27269 */
27270 function toReact(context, node, index, parent) {
27271 const options = context.options;
27272 const transform = options.transformLinkUri === void 0 ? uriTransformer : options.transformLinkUri;
27273 const parentSchema = context.schema;
27274 /** @type {ReactMarkdownNames} */
27275 const name = node.tagName;
27276 /** @type {Record<string, unknown>} */
27277 const properties = {};
27278 let schema = parentSchema;
27279 /** @type {string} */
27280 let property;
27281 if (parentSchema.space === "html" && name === "svg") {
27282 schema = svg;
27283 context.schema = schema;
27284 }
27285 if (node.properties) {
27286 for (property in node.properties) if (own$1.call(node.properties, property)) addProperty(properties, property, node.properties[property], context);
27287 }
27288 if (name === "ol" || name === "ul") context.listDepth++;
27289 const children = childrenToReact(context, node);
27290 if (name === "ol" || name === "ul") context.listDepth--;
27291 context.schema = parentSchema;
27292 const position = node.position || {
27293 start: {
27294 line: null,
27295 column: null,
27296 offset: null
27297 },
27298 end: {
27299 line: null,
27300 column: null,
27301 offset: null
27302 }
27303 };
27304 const component = options.components && own$1.call(options.components, name) ? options.components[name] : name;
27305 const basic = typeof component === "string" || component === react$1.default.Fragment;
27306 if (!import_react_is.isValidElementType(component)) throw new TypeError(`Component for name \`${name}\` not defined or is not renderable`);
27307 properties.key = index;
27308 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;
27309 if (name === "a" && transform) properties.href = transform(String(properties.href || ""), node.children, typeof properties.title === "string" ? properties.title : null);
27310 if (!basic && name === "code" && parent.type === "element" && parent.tagName !== "pre") properties.inline = true;
27311 if (!basic && (name === "h1" || name === "h2" || name === "h3" || name === "h4" || name === "h5" || name === "h6")) properties.level = Number.parseInt(name.charAt(1), 10);
27312 if (name === "img" && options.transformImageUri) properties.src = options.transformImageUri(String(properties.src || ""), String(properties.alt || ""), typeof properties.title === "string" ? properties.title : null);
27313 if (!basic && name === "li" && parent.type === "element") {
27314 const input = getInputElement(node);
27315 properties.checked = input && input.properties ? Boolean(input.properties.checked) : null;
27316 properties.index = getElementsBeforeCount(parent, node);
27317 properties.ordered = parent.tagName === "ol";
27318 }
27319 if (!basic && (name === "ol" || name === "ul")) {
27320 properties.ordered = name === "ol";
27321 properties.depth = context.listDepth;
27322 }
27323 if (name === "td" || name === "th") {
27324 if (properties.align) {
27325 if (!properties.style) properties.style = {};
27326 properties.style.textAlign = properties.align;
27327 delete properties.align;
27328 }
27329 if (!basic) properties.isHeader = name === "th";
27330 }
27331 if (!basic && name === "tr" && parent.type === "element") properties.isHeader = Boolean(parent.tagName === "thead");
27332 if (options.sourcePos) properties["data-sourcepos"] = flattenPosition(position);
27333 if (!basic && options.rawSourcePos) properties.sourcePosition = node.position;
27334 if (!basic && options.includeElementIndex) {
27335 properties.index = getElementsBeforeCount(parent, node);
27336 properties.siblingCount = getElementsBeforeCount(parent);
27337 }
27338 if (!basic) properties.node = node;
27339 return children.length > 0 ? react$1.default.createElement(component, properties, children) : react$1.default.createElement(component, properties);
27340 }
27341 /**
27342 * @param {Element|Root} node
27343 * @returns {Element?}
27344 */
27345 function getInputElement(node) {
27346 let index = -1;
27347 while (++index < node.children.length) {
27348 const child = node.children[index];
27349 if (child.type === "element" && child.tagName === "input") return child;
27350 }
27351 return null;
27352 }
27353 /**
27354 * @param {Element|Root} parent
27355 * @param {Element} [node]
27356 * @returns {number}
27357 */
27358 function getElementsBeforeCount(parent, node) {
27359 let index = -1;
27360 let count = 0;
27361 while (++index < parent.children.length) {
27362 if (parent.children[index] === node) break;
27363 if (parent.children[index].type === "element") count++;
27364 }
27365 return count;
27366 }
27367 /**
27368 * @param {Record<string, unknown>} props
27369 * @param {string} prop
27370 * @param {unknown} value
27371 * @param {Context} ctx
27372 */
27373 function addProperty(props, prop, value, ctx) {
27374 const info = find(ctx.schema, prop);
27375 let result = value;
27376 if (result === null || result === void 0 || result !== result) return;
27377 if (Array.isArray(result)) result = info.commaSeparated ? stringify(result) : stringify$1(result);
27378 if (info.property === "style" && typeof result === "string") result = parseStyle(result);
27379 if (info.space && info.property) props[own$1.call(hastToReact, info.property) ? hastToReact[info.property] : info.property] = result;
27380 else if (info.attribute) props[info.attribute] = result;
27381 }
27382 /**
27383 * @param {string} value
27384 * @returns {Record<string, string>}
27385 */
27386 function parseStyle(value) {
27387 /** @type {Record<string, string>} */
27388 const result = {};
27389 try {
27390 style_to_object_default(value, iterator);
27391 } catch (_unused) {}
27392 return result;
27393 /**
27394 * @param {string} name
27395 * @param {string} v
27396 */
27397 function iterator(name, v) {
27398 const k = name.slice(0, 4) === "-ms-" ? `ms-${name.slice(4)}` : name;
27399 result[k.replace(/-([a-z])/g, styleReplacer)] = v;
27400 }
27401 }
27402 /**
27403 * @param {unknown} _
27404 * @param {string} $1
27405 */
27406 function styleReplacer(_, $1) {
27407 return $1.toUpperCase();
27408 }
27409 /**
27410 * @param {Position|{start: {line: null, column: null, offset: null}, end: {line: null, column: null, offset: null}}} pos
27411 * @returns {string}
27412 */
27413 function flattenPosition(pos) {
27414 return [
27415 pos.start.line,
27416 ":",
27417 pos.start.column,
27418 "-",
27419 pos.end.line,
27420 ":",
27421 pos.end.column
27422 ].map(String).join("");
27423 }
27424 var import_react_is, own$1, tableElements;
27425 var init_ast_to_react = __esmMin((() => {
27426 import_react_is = /* @__PURE__ */ __toESM(require_react_is(), 1);
27427 init_hast_util_whitespace();
27428 init_property_information();
27429 init_space_separated_tokens();
27430 init_comma_separated_tokens();
27431 init_style_to_object();
27432 init_uri_transformer();
27433 own$1 = {}.hasOwnProperty;
27434 tableElements = /* @__PURE__ */ new Set([
27435 "table",
27436 "thead",
27437 "tbody",
27438 "tfoot",
27439 "tr"
27440 ]);
27441 }));
27442
27443 //#endregion
27444 //#region node_modules/react-markdown/lib/react-markdown.js
27445 /**
27446 * @typedef {Promise.resolve(React).ReactNode} ReactNode
27447 * @typedef {Promise.resolve(React).ReactElement<{}>} ReactElement
27448 * @typedef {import('unified').PluggableList} PluggableList
27449 * @typedef {import('hast').Root} Root
27450 * @typedef {import('./rehype-filter.js').Options} FilterOptions
27451 * @typedef {import('./ast-to-react.js').Options} TransformOptions
27452 *
27453 * @typedef CoreOptions
27454 * @property {string} children
27455 *
27456 * @typedef PluginOptions
27457 * @property {PluggableList} [remarkPlugins=[]]
27458 * @property {PluggableList} [rehypePlugins=[]]
27459 * @property {import('remark-rehype').Options | undefined} [remarkRehypeOptions={}]
27460 *
27461 * @typedef LayoutOptions
27462 * @property {string} [className]
27463 *
27464 * @typedef {CoreOptions & PluginOptions & LayoutOptions & FilterOptions & TransformOptions} ReactMarkdownOptions
27465 *
27466 * @typedef Deprecation
27467 * @property {string} id
27468 * @property {string} [to]
27469 */
27470 /**
27471 * React component to render markdown.
27472 *
27473 * @param {ReactMarkdownOptions} options
27474 * @returns {ReactElement}
27475 */
27476 function ReactMarkdown$1(options) {
27477 for (const key in deprecated) if (own.call(deprecated, key) && own.call(options, key)) {
27478 const deprecation = deprecated[key];
27479 console.warn(`[react-markdown] Warning: please ${deprecation.to ? `use \`${deprecation.to}\` instead of` : "remove"} \`${key}\` (see <${changelog}#${deprecation.id}> for more info)`);
27480 delete deprecated[key];
27481 }
27482 const processor = unified().use(remarkParse).use(options.remarkPlugins || []).use(remarkRehype, _objectSpread2(_objectSpread2({}, options.remarkRehypeOptions), {}, { allowDangerousHtml: true })).use(options.rehypePlugins || []).use(rehypeFilter, options);
27483 const file = new VFile();
27484 if (typeof options.children === "string") file.value = options.children;
27485 else if (options.children !== void 0 && options.children !== null) console.warn(`[react-markdown] Warning: please pass a string as \`children\` (not: \`${options.children}\`)`);
27486 const hastNode = processor.runSync(processor.parse(file), file);
27487 if (hastNode.type !== "root") throw new TypeError("Expected a `root` node");
27488 /** @type {ReactElement} */
27489 let result = react$1.default.createElement(react$1.default.Fragment, {}, childrenToReact({
27490 options,
27491 schema: html,
27492 listDepth: 0
27493 }, hastNode));
27494 if (options.className) result = react$1.default.createElement("div", { className: options.className }, result);
27495 return result;
27496 }
27497 var import_prop_types$1, own, changelog, deprecated;
27498 var init_react_markdown$1 = __esmMin((() => {
27499 init_vfile();
27500 init_unified();
27501 init_remark_parse();
27502 init_remark_rehype();
27503 import_prop_types$1 = /* @__PURE__ */ __toESM(require_prop_types(), 1);
27504 init_property_information();
27505 init_rehype_filter();
27506 init_ast_to_react();
27507 init_objectSpread2();
27508 own = {}.hasOwnProperty;
27509 changelog = "https://github.com/remarkjs/react-markdown/blob/main/changelog.md";
27510 deprecated = {
27511 plugins: {
27512 to: "remarkPlugins",
27513 id: "change-plugins-to-remarkplugins"
27514 },
27515 renderers: {
27516 to: "components",
27517 id: "change-renderers-to-components"
27518 },
27519 astPlugins: { id: "remove-buggy-html-in-markdown-parser" },
27520 allowDangerousHtml: { id: "remove-buggy-html-in-markdown-parser" },
27521 escapeHtml: { id: "remove-buggy-html-in-markdown-parser" },
27522 source: {
27523 to: "children",
27524 id: "change-source-to-children"
27525 },
27526 allowNode: {
27527 to: "allowElement",
27528 id: "replace-allownode-allowedtypes-and-disallowedtypes"
27529 },
27530 allowedTypes: {
27531 to: "allowedElements",
27532 id: "replace-allownode-allowedtypes-and-disallowedtypes"
27533 },
27534 disallowedTypes: {
27535 to: "disallowedElements",
27536 id: "replace-allownode-allowedtypes-and-disallowedtypes"
27537 },
27538 includeNodeIndex: {
27539 to: "includeElementIndex",
27540 id: "change-includenodeindex-to-includeelementindex"
27541 }
27542 };
27543 __name(ReactMarkdown$1, "ReactMarkdown");
27544 ReactMarkdown$1.propTypes = {
27545 children: import_prop_types$1.default.string,
27546 className: import_prop_types$1.default.string,
27547 allowElement: import_prop_types$1.default.func,
27548 allowedElements: import_prop_types$1.default.arrayOf(import_prop_types$1.default.string),
27549 disallowedElements: import_prop_types$1.default.arrayOf(import_prop_types$1.default.string),
27550 unwrapDisallowed: import_prop_types$1.default.bool,
27551 remarkPlugins: import_prop_types$1.default.arrayOf(import_prop_types$1.default.oneOfType([
27552 import_prop_types$1.default.object,
27553 import_prop_types$1.default.func,
27554 import_prop_types$1.default.arrayOf(import_prop_types$1.default.oneOfType([
27555 import_prop_types$1.default.bool,
27556 import_prop_types$1.default.string,
27557 import_prop_types$1.default.object,
27558 import_prop_types$1.default.func,
27559 import_prop_types$1.default.arrayOf(import_prop_types$1.default.any)
27560 ]))
27561 ])),
27562 rehypePlugins: import_prop_types$1.default.arrayOf(import_prop_types$1.default.oneOfType([
27563 import_prop_types$1.default.object,
27564 import_prop_types$1.default.func,
27565 import_prop_types$1.default.arrayOf(import_prop_types$1.default.oneOfType([
27566 import_prop_types$1.default.bool,
27567 import_prop_types$1.default.string,
27568 import_prop_types$1.default.object,
27569 import_prop_types$1.default.func,
27570 import_prop_types$1.default.arrayOf(import_prop_types$1.default.any)
27571 ]))
27572 ])),
27573 sourcePos: import_prop_types$1.default.bool,
27574 rawSourcePos: import_prop_types$1.default.bool,
27575 skipHtml: import_prop_types$1.default.bool,
27576 includeElementIndex: import_prop_types$1.default.bool,
27577 transformLinkUri: import_prop_types$1.default.oneOfType([import_prop_types$1.default.func, import_prop_types$1.default.bool]),
27578 linkTarget: import_prop_types$1.default.oneOfType([import_prop_types$1.default.func, import_prop_types$1.default.string]),
27579 transformImageUri: import_prop_types$1.default.func,
27580 components: import_prop_types$1.default.object
27581 };
27582 }));
27583
27584 //#endregion
27585 //#region node_modules/react-markdown/index.js
27586 var react_markdown_exports = /* @__PURE__ */ __exportAll({
27587 default: () => ReactMarkdown$1,
27588 uriTransformer: () => uriTransformer
27589 });
27590 var init_react_markdown = __esmMin((() => {
27591 init_uri_transformer();
27592 init_react_markdown$1();
27593 }));
27594
27595 //#endregion
27596 //#region modules/ai/assets/js/editor/pages/form-code/index.js
27597 var form_code_exports = /* @__PURE__ */ __exportAll({ default: () => FormCode$1 });
27598 function ownKeys$6(e, r) {
27599 var t = Object.keys(e);
27600 if (Object.getOwnPropertySymbols) {
27601 var o = Object.getOwnPropertySymbols(e);
27602 r && (o = o.filter(function(r) {
27603 return Object.getOwnPropertyDescriptor(e, r).enumerable;
27604 })), t.push.apply(t, o);
27605 }
27606 return t;
27607 }
27608 function _objectSpread$6(e) {
27609 for (var r = 1; r < arguments.length; r++) {
27610 var t = null != arguments[r] ? arguments[r] : {};
27611 r % 2 ? ownKeys$6(Object(t), !0).forEach(function(r) {
27612 _defineProperty(e, r, t[r]);
27613 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function(r) {
27614 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
27615 });
27616 }
27617 return e;
27618 }
27619 var import_regenerator, import_prop_types, ReactMarkdown, generateUniqueId, CodeDisplayWrapper, FormCode$1;
27620 var init_form_code = __esmMin((() => {
27621 init_extends();
27622 init_asyncToGenerator();
27623 init_slicedToArray();
27624 init_defineProperty();
27625 import_regenerator = /* @__PURE__ */ __toESM(require_regenerator());
27626 import_prop_types = /* @__PURE__ */ __toESM(require_prop_types());
27627 init_actions_data();
27628 init_loader();
27629 init_prompt_search();
27630 init_prompt_suggestions();
27631 init_generate_button();
27632 init_prompt_error_message();
27633 init_code_block();
27634 init_use_code_prompt();
27635 init_prompt_history_action_context();
27636 init_prompt_library_link();
27637 init_requests_ids();
27638 init_voice_promotion_alert();
27639 init_splitTextResult();
27640 init_preload_helper();
27641 __name(ownKeys$6, "ownKeys");
27642 __name(_objectSpread$6, "_objectSpread");
27643 ReactMarkdown = (0, react.lazy)(function() {
27644 return __vitePreload(() => Promise.resolve().then(() => (init_react_markdown(), react_markdown_exports)), void 0);
27645 });
27646 generateUniqueId = function generateUniqueId() {
27647 return "custom-css-".concat(Math.random().toString(36).substr(2, 9));
27648 };
27649 CodeDisplayWrapper = (0, _elementor_ui.styled)(_elementor_ui.Box)(function() {
27650 return {
27651 "& p": {
27652 mb: "10px",
27653 fontSize: "13px",
27654 lineHeight: "1.5"
27655 },
27656 "& pre": { position: "relative" },
27657 "& textarea": {
27658 fontSize: "13px",
27659 lineHeight: "1.7"
27660 }
27661 };
27662 });
27663 FormCode$1 = function FormCode(_ref) {
27664 var onClose = _ref.onClose;
27665 var getControlValue = _ref.getControlValue;
27666 var setControlValue = _ref.setControlValue;
27667 var additionalOptions = _ref.additionalOptions;
27668 var credits = _ref.credits;
27669 var children = _ref.children;
27670 var _useCodePrompt = useCodePrompt(_objectSpread$6(_objectSpread$6({}, additionalOptions), {}, { credits }));
27671 var data = _useCodePrompt.data;
27672 var isLoading = _useCodePrompt.isLoading;
27673 var error = _useCodePrompt.error;
27674 var reset = _useCodePrompt.reset;
27675 var send = _useCodePrompt.send;
27676 var sendUsageData = _useCodePrompt.sendUsageData;
27677 var _splitText = splitText(data.result);
27678 var code = _splitText.code;
27679 var details = _splitText.details;
27680 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
27681 var prompt = _useState2[0];
27682 var setPrompt = _useState2[1];
27683 var setGenerate = useRequestIds().setGenerate;
27684 var styleTagId = (0, react.useRef)(generateUniqueId());
27685 useSubscribeOnPromptHistoryAction([{
27686 type: ACTION_TYPES.REUSE,
27687 handler: function handler(action) {
27688 reset();
27689 setPrompt(action.data);
27690 }
27691 }]);
27692 var lastRun = (0, react.useRef)(function() {});
27693 var autocompleteItems = codeHtmlAutocomplete;
27694 var promptLibraryLink = "";
27695 if ("css" === (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.codeLanguage)) {
27696 autocompleteItems = codeCssAutocomplete;
27697 promptLibraryLink = "https://go.elementor.com/ai-prompt-library-css/";
27698 } else if (additionalOptions !== null && additionalOptions !== void 0 && additionalOptions.htmlMarkup) promptLibraryLink = "https://go.elementor.com/ai-prompt-library-html/";
27699 else promptLibraryLink = "https://go.elementor.com/ai-prompt-library-custom-code/";
27700 var showSuggestions = !prompt;
27701 var handleSubmit = /*#__PURE__*/ function() {
27702 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator.default.mark(function _callee(event) {
27703 var response;
27704 return import_regenerator.default.wrap(function(_context) {
27705 while (1) switch (_context.prev = _context.next) {
27706 case 0:
27707 event.preventDefault();
27708 setGenerate();
27709 lastRun.current = function() {
27710 return send({ prompt });
27711 };
27712 _context.next = 1;
27713 return lastRun.current();
27714 case 1:
27715 response = _context.sent;
27716 if ("css" === (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.codeLanguage) && response.result) showCssPreview(splitText(response.result).code);
27717 case 2:
27718 case "end": return _context.stop();
27719 }
27720 }, _callee);
27721 }));
27722 return function handleSubmit(_x) {
27723 return _ref2.apply(this, arguments);
27724 };
27725 }();
27726 (0, react.useEffect)(function() {
27727 return function() {
27728 removeStyleTag();
27729 };
27730 }, []);
27731 var showCssPreview = function showCssPreview(cssCode) {
27732 insertStyleTag(parseCSS(cssCode));
27733 };
27734 var parseCSS = function parseCSS(cssCode) {
27735 var elementId = additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.elementId;
27736 var selector = "document" === elementId ? elementor.config.document.settings.cssWrapperSelector : ".elementor-element.elementor-element-".concat(elementId);
27737 return cssCode && cssCode.replace(/`/g, "").replace(/^css\s*/i, "").replace(/selector/g, selector);
27738 };
27739 var isElementorEditor = function isElementorEditor() {
27740 return window.elementorFrontend;
27741 };
27742 var insertStyleTag = function insertStyleTag(cssCode) {
27743 if (!isElementorEditor()) return;
27744 var style = document.createElement("style");
27745 style.id = styleTagId.current;
27746 style.appendChild(document.createTextNode(cssCode));
27747 elementorFrontend.elements.$body[0].appendChild(style);
27748 };
27749 var removeStyleTag = function removeStyleTag() {
27750 if (!isElementorEditor()) return;
27751 var styleTag = elementorFrontend.elements.$body[0].querySelector("#".concat(styleTagId.current));
27752 if (styleTag) styleTag.remove();
27753 };
27754 var applyPrompt = function applyPrompt(inputText) {
27755 sendUsageData();
27756 setControlValue(inputText);
27757 onClose();
27758 };
27759 if (isLoading) return /*#__PURE__*/ react.default.createElement(Loader, null);
27760 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, error && /*#__PURE__*/ react.default.createElement(PromptErrorMessage, {
27761 error,
27762 onRetry: lastRun.current,
27763 sx: { mb: 2.5 }
27764 }), children, !data.result && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
27765 component: "form",
27766 onSubmit: handleSubmit
27767 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: { pb: 1.5 } }, /*#__PURE__*/ react.default.createElement(PromptSearch, {
27768 placeholder: (0, _wordpress_i18n.__)("Describe the code you want to use...", "elementor"),
27769 name: "prompt",
27770 value: prompt,
27771 color: "secondary",
27772 onChange: function onChange(event) {
27773 return setPrompt(event.target.value);
27774 }
27775 })), showSuggestions && /*#__PURE__*/ react.default.createElement(PromptSuggestions, {
27776 suggestions: autocompleteItems,
27777 onSelect: setPrompt
27778 }, /*#__PURE__*/ react.default.createElement(PromptLibraryLink, { libraryLink: promptLibraryLink })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
27779 direction: "row",
27780 alignItems: "center",
27781 sx: {
27782 py: 1.5,
27783 mt: 4
27784 }
27785 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
27786 direction: "row",
27787 justifyContent: "flex-end",
27788 flexGrow: 1
27789 }, /*#__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) {
27790 return /*#__PURE__*/ react.default.createElement(CodeBlock, _extends$1({}, props, {
27791 defaultValue: getControlValue(),
27792 onInsert: applyPrompt
27793 }));
27794 } } }, code)), details, /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, { introductionKey: "ai-context-code-promotion" }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
27795 direction: "row",
27796 alignItems: "center",
27797 sx: { mt: 4 }
27798 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
27799 direction: "row",
27800 gap: 1,
27801 justifyContent: "flex-end",
27802 flexGrow: 1
27803 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
27804 size: "small",
27805 color: "secondary",
27806 variant: "text",
27807 onClick: function onClick() {
27808 removeStyleTag();
27809 reset();
27810 }
27811 }, (0, _wordpress_i18n.__)("New prompt", "elementor"))))));
27812 };
27813 FormCode$1.propTypes = {
27814 onClose: import_prop_types.default.func.isRequired,
27815 getControlValue: import_prop_types.default.func.isRequired,
27816 setControlValue: import_prop_types.default.func.isRequired,
27817 additionalOptions: import_prop_types.default.shape({
27818 codeLanguage: import_prop_types.default.string,
27819 htmlMarkup: import_prop_types.default.string,
27820 elementId: import_prop_types.default.string,
27821 initialCredits: import_prop_types.default.number
27822 }),
27823 credits: import_prop_types.default.number,
27824 children: import_prop_types.default.node
27825 };
27826 }));
27827
27828 //#endregion
27829 //#region modules/ai/assets/js/editor/page-content.js
27830 init_extends();
27831 init_defineProperty();
27832 init_slicedToArray();
27833 init_history_types();
27834 init_prompt_history_action_context();
27835 init_prompt_history_context();
27836 init_loader();
27837 init_requests_ids();
27838 init_preload_helper();
27839 function ownKeys$5(e, r) {
27840 var t = Object.keys(e);
27841 if (Object.getOwnPropertySymbols) {
27842 var o = Object.getOwnPropertySymbols(e);
27843 r && (o = o.filter(function(r) {
27844 return Object.getOwnPropertyDescriptor(e, r).enumerable;
27845 })), t.push.apply(t, o);
27846 }
27847 return t;
27848 }
27849 __name(ownKeys$5, "ownKeys");
27850 function _objectSpread$5(e) {
27851 for (var r = 1; r < arguments.length; r++) {
27852 var t = null != arguments[r] ? arguments[r] : {};
27853 r % 2 ? ownKeys$5(Object(t), !0).forEach(function(r) {
27854 _defineProperty(e, r, t[r]);
27855 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function(r) {
27856 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
27857 });
27858 }
27859 return e;
27860 }
27861 __name(_objectSpread$5, "_objectSpread");
27862 var FormCode = (0, react.lazy)(function() {
27863 return __vitePreload(() => Promise.resolve().then(() => (init_form_code(), form_code_exports)), void 0);
27864 });
27865 var PageContent = function PageContent(_ref) {
27866 var type = _ref.type;
27867 var controlType = _ref.controlType;
27868 var onClose = _ref.onClose;
27869 var onConnect = _ref.onConnect;
27870 var getControlValue = _ref.getControlValue;
27871 var setControlValue = _ref.setControlValue;
27872 var additionalOptions = _ref.additionalOptions;
27873 var _ref2 = function(_additionalOptions$us) {
27874 return (_additionalOptions$us = additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.useCustomInit) !== null && _additionalOptions$us !== void 0 ? _additionalOptions$us : useUserInfo;
27875 }()();
27876 var isLoading = _ref2.isLoading;
27877 var isConnected = _ref2.isConnected;
27878 var isGetStarted = _ref2.isGetStarted;
27879 var connectUrl = _ref2.connectUrl;
27880 var fetchData = _ref2.fetchData;
27881 var hasSubscription = _ref2.hasSubscription;
27882 var credits = _ref2.credits;
27883 var initialUsagePercentage = _ref2.usagePercentage;
27884 var _useRequestIds = useRequestIds();
27885 var updateUsagePercentage = _useRequestIds.updateUsagePercentage;
27886 var usagePercentage = _useRequestIds.usagePercentage;
27887 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
27888 var isInitUsageDone = _useState2[0];
27889 var setIsInitUsageDone = _useState2[1];
27890 (0, react.useEffect)(function() {
27891 if (!isInitUsageDone && !isLoading && (initialUsagePercentage || 0 === initialUsagePercentage)) {
27892 updateUsagePercentage(initialUsagePercentage);
27893 setIsInitUsageDone(true);
27894 }
27895 }, [
27896 isLoading,
27897 initialUsagePercentage,
27898 isInitUsageDone,
27899 updateUsagePercentage
27900 ]);
27901 var showBadge = useUpgradeMessage({
27902 usagePercentage,
27903 hasSubscription
27904 }).showBadge;
27905 var _useState4 = _slicedToArray((0, react.useState)({ pointerEvents: "none" }), 2);
27906 var sxStyle = _useState4[0];
27907 var setSxStyle = _useState4[1];
27908 var timeoutRef = (0, react.useRef)(null);
27909 var _useState6 = _slicedToArray((0, react.useState)(), 2);
27910 var originalControlValue = _useState6[0];
27911 var setOriginalControlValue = _useState6[1];
27912 var promptDialogStyleProps = {
27913 sx: {
27914 zIndex: 17e4,
27915 "& .MuiDialog-container": {
27916 alignItems: "flex-start",
27917 mt: "media" === type ? "2.5vh" : "18vh"
27918 },
27919 "& .MuiDialogContent-root": {
27920 willChange: "height",
27921 transition: "height 300ms ease-in-out",
27922 position: "relative"
27923 },
27924 "& .MuiBox-root": { boxSizing: "border-box" }
27925 },
27926 PaperProps: { sx: {
27927 m: 0,
27928 maxHeight: "media" === type ? "95vh" : "76vh",
27929 minHeight: "80vh",
27930 height: "auto"
27931 } }
27932 };
27933 var codePromptDialogStyleProps = {
27934 sx: _objectSpread$5(_objectSpread$5({}, promptDialogStyleProps.sx), sxStyle),
27935 PaperProps: {
27936 onMouseEnter: function onMouseEnter() {
27937 clearTimeout(timeoutRef.current);
27938 setSxStyle({ pointerEvents: "all" });
27939 },
27940 onMouseLeave: function onMouseLeave() {
27941 clearTimeout(timeoutRef.current);
27942 timeoutRef.current = setTimeout(function() {
27943 setSxStyle({ pointerEvents: "none" });
27944 }, 200);
27945 },
27946 sx: _objectSpread$5(_objectSpread$5({}, promptDialogStyleProps.PaperProps.sx), {}, { pointerEvents: "auto" })
27947 }
27948 };
27949 var maybeRenderUpgradeChip = function maybeRenderUpgradeChip() {
27950 if (!showBadge) return;
27951 return /*#__PURE__*/ react.default.createElement(UpgradeChip, {
27952 hasSubscription,
27953 usagePercentage
27954 });
27955 };
27956 (0, react.useEffect)(function() {
27957 if (!originalControlValue) setOriginalControlValue(getControlValue());
27958 }, []);
27959 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: {
27960 display: "flex",
27961 justifyContent: "center",
27962 alignItems: "center",
27963 width: "100%"
27964 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
27965 variant: "body1",
27966 color: "secondary"
27967 }, additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.loadingTitle)), /*#__PURE__*/ react.default.createElement(Loader, null)));
27968 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, {
27969 connectUrl,
27970 onSuccess: function onSuccess(data) {
27971 onConnect(data);
27972 fetchData();
27973 }
27974 })));
27975 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 })));
27976 if ("media" === type) return /*#__PURE__*/ react.default.createElement(PromptHistoryProvider, { historyType: HISTORY_TYPES.IMAGE }, /*#__PURE__*/ react.default.createElement(PromptHistoryActionProvider, null, /*#__PURE__*/ react.default.createElement(FormMedia, {
27977 onClose,
27978 getControlValue,
27979 setControlValue,
27980 additionalOptions,
27981 credits,
27982 maybeRenderUpgradeChip,
27983 DialogProps: promptDialogStyleProps,
27984 hasSubscription,
27985 usagePercentage
27986 })));
27987 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, {
27988 className: "e-ai-dialog-content",
27989 dividers: true
27990 }, /*#__PURE__*/ react.default.createElement(react.Suspense, { fallback: /*#__PURE__*/ react.default.createElement(Loader, null) }, /*#__PURE__*/ react.default.createElement(FormCode, {
27991 onClose,
27992 getControlValue,
27993 setControlValue,
27994 additionalOptions,
27995 credits,
27996 usagePercentage
27997 }, /*#__PURE__*/ react.default.createElement(UsageMessages, {
27998 hasSubscription,
27999 usagePercentage,
28000 sx: { mb: 2 },
28001 feature: FREE_TRIAL_FEATURES_NAMES.CODE
28002 })))))));
28003 if ("animation" === type || "hover_animation" === type) {
28004 var onCloseAnimationDialog = function onCloseAnimationDialog() {
28005 setControlValue(originalControlValue);
28006 elementor.documents.getCurrent().history.setActive(true);
28007 onClose();
28008 };
28009 return /*#__PURE__*/ react.default.createElement(PromptDialog, _extends$1({ onClose: onCloseAnimationDialog }, codePromptDialogStyleProps), /*#__PURE__*/ react.default.createElement(PromptDialog.Header, {
28010 onClose: onCloseAnimationDialog,
28011 hideAiBetaLogo: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.hideAiBetaLogo
28012 }, maybeRenderUpgradeChip()), /*#__PURE__*/ react.default.createElement(PromptDialog.Content, {
28013 className: "e-ai-dialog-content",
28014 dividers: true
28015 }, /*#__PURE__*/ react.default.createElement(FormAnimation, {
28016 onClose,
28017 getControlValue,
28018 setControlValue,
28019 additionalOptions: _objectSpread$5(_objectSpread$5({}, additionalOptions), {}, { animationType: "hover_animation" === type ? "hover" : "other" }),
28020 credits,
28021 usagePercentage
28022 }, /*#__PURE__*/ react.default.createElement(UsageMessages, {
28023 hasSubscription,
28024 usagePercentage,
28025 sx: { mb: 2 },
28026 feature: FREE_TRIAL_FEATURES_NAMES.ANIMATION
28027 }))));
28028 }
28029 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, {
28030 onClose,
28031 hideAiBetaLogo: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.hideAiBetaLogo
28032 }, !(additionalOptions !== null && additionalOptions !== void 0 && additionalOptions.withoutHistory) && /*#__PURE__*/ react.default.createElement(PromptHistory, null), maybeRenderUpgradeChip()), /*#__PURE__*/ react.default.createElement(PromptDialog.Content, {
28033 className: "e-ai-dialog-content",
28034 dividers: true
28035 }, /*#__PURE__*/ react.default.createElement(FormText, {
28036 type,
28037 controlType,
28038 onClose,
28039 getControlValue,
28040 setControlValue,
28041 additionalOptions,
28042 credits,
28043 usagePercentage
28044 }, /*#__PURE__*/ react.default.createElement(UsageMessages, {
28045 hasSubscription,
28046 usagePercentage,
28047 sx: { mb: 2 },
28048 feature: FREE_TRIAL_FEATURES_NAMES.TEXT
28049 }))))));
28050 };
28051 PageContent.propTypes = {
28052 type: import_prop_types$12.default.string,
28053 controlType: import_prop_types$12.default.string,
28054 onClose: import_prop_types$12.default.func.isRequired,
28055 onConnect: import_prop_types$12.default.func,
28056 getControlValue: import_prop_types$12.default.func.isRequired,
28057 setControlValue: import_prop_types$12.default.func.isRequired,
28058 additionalOptions: import_prop_types$12.default.object
28059 };
28060
28061 //#endregion
28062 //#region modules/ai/assets/js/editor/utils/preview-container.js
28063 /**
28064 * @typedef {import('elementor/assets/dev/js/editor/container/container')} Container
28065 */
28066 var PREFIX = "e-ai-preview-container";
28067 var CLASS_HIDDEN = PREFIX + "--hidden";
28068 var CLASS_IDLE = PREFIX + "--idle";
28069
28070 //#endregion
28071 //#region modules/ai/assets/js/editor/pages/form-layout/components/unsaved-changes-alert.js
28072 init_extends();
28073 init_objectWithoutProperties();
28074 var _excluded$4 = [
28075 "onClose",
28076 "onCancel",
28077 "title",
28078 "text"
28079 ];
28080 var UnsavedChangesAlert = function UnsavedChangesAlert(_ref) {
28081 var onClose = _ref.onClose;
28082 var onCancel = _ref.onCancel;
28083 var title = _ref.title;
28084 var text = _ref.text;
28085 var props = _objectWithoutProperties(_ref, _excluded$4);
28086 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, _extends$1({
28087 "aria-labelledby": "unsaved-changes-alert-title",
28088 "aria-describedby": "unsaved-changes-alert-description"
28089 }, 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, {
28090 onClick: onCancel,
28091 color: "secondary"
28092 }, (0, _wordpress_i18n.__)("Cancel", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
28093 onClick: onClose,
28094 color: "error",
28095 variant: "contained"
28096 }, (0, _wordpress_i18n.__)("Yes, leave", "elementor"))));
28097 };
28098 UnsavedChangesAlert.propTypes = {
28099 title: import_prop_types$12.default.string,
28100 text: import_prop_types$12.default.string,
28101 onCancel: import_prop_types$12.default.func,
28102 onClose: import_prop_types$12.default.func
28103 };
28104
28105 //#endregion
28106 //#region modules/ai/assets/js/editor/pages/form-layout/components/layout-dialog.js
28107 init_extends();
28108 init_defineProperty();
28109 init_slicedToArray();
28110 init_objectWithoutProperties();
28111 var _excluded$3 = ["sx", "PaperProps"];
28112 function ownKeys$4(e, r) {
28113 var t = Object.keys(e);
28114 if (Object.getOwnPropertySymbols) {
28115 var o = Object.getOwnPropertySymbols(e);
28116 r && (o = o.filter(function(r) {
28117 return Object.getOwnPropertyDescriptor(e, r).enumerable;
28118 })), t.push.apply(t, o);
28119 }
28120 return t;
28121 }
28122 __name(ownKeys$4, "ownKeys");
28123 function _objectSpread$4(e) {
28124 for (var r = 1; r < arguments.length; r++) {
28125 var t = null != arguments[r] ? arguments[r] : {};
28126 r % 2 ? ownKeys$4(Object(t), !0).forEach(function(r) {
28127 _defineProperty(e, r, t[r]);
28128 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function(r) {
28129 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
28130 });
28131 }
28132 return e;
28133 }
28134 __name(_objectSpread$4, "_objectSpread");
28135 var StyledDialog = (0, _elementor_ui.styled)(PromptDialog)(function() {
28136 return {
28137 "& .MuiDialog-container": {
28138 marginTop: 0,
28139 alignItems: "flex-end",
28140 paddingBottom: "16vh"
28141 },
28142 "& .MuiPaper-root": {
28143 margin: 0,
28144 maxHeight: "80vh"
28145 }
28146 };
28147 });
28148 var DialogHeader = function DialogHeader(_ref) {
28149 var onClose = _ref.onClose;
28150 var children = _ref.children;
28151 return /*#__PURE__*/ react.default.createElement(_elementor_ui.AppBar, {
28152 sx: { fontWeight: "normal" },
28153 color: "transparent",
28154 position: "relative"
28155 }, /*#__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, {
28156 component: "span",
28157 variant: "subtitle2",
28158 sx: {
28159 fontWeight: "bold",
28160 textTransform: "uppercase"
28161 }
28162 }, (0, _wordpress_i18n.__)("AI", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Chip, {
28163 label: (0, _wordpress_i18n.__)("Beta", "elementor"),
28164 color: "default",
28165 size: "small",
28166 sx: { ml: 1 }
28167 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
28168 direction: "row",
28169 spacing: 1,
28170 alignItems: "center",
28171 sx: { ml: "auto" }
28172 }, children, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
28173 size: "small",
28174 "aria-label": "close",
28175 onClick: onClose,
28176 sx: { "&.MuiButtonBase-root": { mr: -1 } }
28177 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.XIcon, null)))));
28178 };
28179 DialogHeader.propTypes = {
28180 children: import_prop_types$12.default.node,
28181 onClose: import_prop_types$12.default.func.isRequired
28182 };
28183 var StyledDialogContent = (0, _elementor_ui.styled)(PromptDialog.Content)(function() {
28184 return { "&.MuiDialogContent-root": { padding: 0 } };
28185 });
28186 var LayoutDialog = function LayoutDialog(_ref2) {
28187 var _ref2$sx = _ref2.sx;
28188 var sx = _ref2$sx === void 0 ? {} : _ref2$sx;
28189 var _ref2$PaperProps = _ref2.PaperProps;
28190 var PaperProps = _ref2$PaperProps === void 0 ? {} : _ref2$PaperProps;
28191 var props = _objectWithoutProperties(_ref2, _excluded$3);
28192 var _useState2 = _slicedToArray((0, react.useState)({ pointerEvents: "none" }), 2);
28193 var sxStyle = _useState2[0];
28194 var setSxStyle = _useState2[1];
28195 var timeoutRef = (0, react.useRef)(null);
28196 /**
28197 * The PromptDialog is using disableScrollLock in order to allow scrolling the page when the Dialog is opened.
28198 * When using the react-draggable library inside the editor, the background page scroll is not working smoothly.
28199 * Therefore, we need to delay the pointerEvents: none, which allowing to scroll the page content.
28200 */
28201 return /*#__PURE__*/ react.default.createElement(StyledDialog, _extends$1({
28202 maxWidth: "md",
28203 PaperProps: _objectSpread$4({
28204 sx: { pointerEvents: "auto" },
28205 onMouseEnter: function onMouseEnter() {
28206 clearTimeout(timeoutRef.current);
28207 setSxStyle({ pointerEvents: "all" });
28208 },
28209 onMouseLeave: function onMouseLeave() {
28210 clearTimeout(timeoutRef.current);
28211 timeoutRef.current = setTimeout(function() {
28212 setSxStyle({ pointerEvents: "none" });
28213 }, 200);
28214 }
28215 }, PaperProps)
28216 }, props, { sx: _objectSpread$4(_objectSpread$4({}, sxStyle), sx) }));
28217 };
28218 LayoutDialog.propTypes = {
28219 sx: import_prop_types$12.default.object,
28220 PaperProps: import_prop_types$12.default.object
28221 };
28222 LayoutDialog.Header = DialogHeader;
28223 LayoutDialog.Content = StyledDialogContent;
28224
28225 //#endregion
28226 //#region modules/ai/assets/js/editor/pages/form-layout/components/prompt-autocomplete.js
28227 init_slicedToArray();
28228 init_objectWithoutProperties();
28229 init_extends();
28230 init_defineProperty();
28231 init_prompt_library_link();
28232 var _excluded$2 = ["onSubmit"];
28233 function ownKeys$3(e, r) {
28234 var t = Object.keys(e);
28235 if (Object.getOwnPropertySymbols) {
28236 var o = Object.getOwnPropertySymbols(e);
28237 r && (o = o.filter(function(r) {
28238 return Object.getOwnPropertyDescriptor(e, r).enumerable;
28239 })), t.push.apply(t, o);
28240 }
28241 return t;
28242 }
28243 __name(ownKeys$3, "ownKeys");
28244 function _objectSpread$3(e) {
28245 for (var r = 1; r < arguments.length; r++) {
28246 var t = null != arguments[r] ? arguments[r] : {};
28247 r % 2 ? ownKeys$3(Object(t), !0).forEach(function(r) {
28248 _defineProperty(e, r, t[r]);
28249 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function(r) {
28250 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
28251 });
28252 }
28253 return e;
28254 }
28255 __name(_objectSpread$3, "_objectSpread");
28256 var TextInput = (0, react.forwardRef)(function(props, ref) {
28257 return /*#__PURE__*/ react.default.createElement(_elementor_ui.TextField, _extends$1({
28258 autoFocus: true,
28259 multiline: true,
28260 size: "small",
28261 maxRows: 3,
28262 color: "secondary",
28263 variant: "standard"
28264 }, props, {
28265 inputRef: ref,
28266 InputProps: _objectSpread$3(_objectSpread$3({}, props.InputProps), {}, {
28267 type: "search",
28268 sx: { pt: 0 }
28269 })
28270 }));
28271 });
28272 TextInput.propTypes = { InputProps: import_prop_types$12.default.object };
28273 var PaperComponent = function PaperComponent(props) {
28274 var libraryLink = "variation" === useConfig().mode ? "https://go.elementor.com/ai-prompt-library-variations/" : "https://go.elementor.com/ai-prompt-library-containers/";
28275 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Paper, _extends$1({}, props, {
28276 elevation: 8,
28277 sx: { borderRadius: 2 }
28278 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
28279 component: _elementor_ui.Box,
28280 color: function color(theme) {
28281 return theme.palette.text.tertiary;
28282 },
28283 variant: "caption",
28284 paddingX: 2,
28285 paddingY: 1
28286 }, (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 })));
28287 };
28288 PaperComponent.propTypes = { children: import_prop_types$12.default.node };
28289 var PromptAutocomplete = function PromptAutocomplete(_ref) {
28290 var onSubmit = _ref.onSubmit;
28291 var props = _objectWithoutProperties(_ref, _excluded$2);
28292 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
28293 var showSuggestions = _useState2[0];
28294 var setShowSuggestions = _useState2[1];
28295 var theme = (0, _elementor_ui.useTheme)();
28296 var itemHeight = parseInt(theme.spacing(4));
28297 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Autocomplete, _extends$1({
28298 PaperComponent,
28299 ListboxProps: { sx: { maxHeight: 5 * itemHeight } },
28300 renderOption: function renderOption(optionProps, option) {
28301 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, _extends$1({}, optionProps, {
28302 title: option.text,
28303 noWrap: true,
28304 variant: "body2",
28305 component: _elementor_ui.Box,
28306 sx: { "&.MuiAutocomplete-option": {
28307 display: "block",
28308 minHeight: itemHeight
28309 } }
28310 }), option.text);
28311 },
28312 freeSolo: true,
28313 fullWidth: true,
28314 disableClearable: true,
28315 open: showSuggestions,
28316 onClose: function onClose(e) {
28317 var _e$relatedTarget;
28318 return setShowSuggestions("A" === ((_e$relatedTarget = e.relatedTarget) === null || _e$relatedTarget === void 0 ? void 0 : _e$relatedTarget.tagName));
28319 },
28320 onKeyDown: function onKeyDown(e) {
28321 if ("Enter" === e.key && !e.shiftKey && !showSuggestions) onSubmit(e);
28322 else if ("/" === e.key && "" === e.target.value) {
28323 e.preventDefault();
28324 setShowSuggestions(true);
28325 }
28326 }
28327 }, props));
28328 };
28329 PromptAutocomplete.propTypes = { onSubmit: import_prop_types$12.default.func.isRequired };
28330 PromptAutocomplete.TextInput = TextInput;
28331
28332 //#endregion
28333 //#region modules/ai/assets/js/editor/icons/arrow-left-icon.js
28334 init_extends();
28335 var ArrowLeftIcon = react.default.forwardRef(function(props, ref) {
28336 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
28337 fillRule: "evenodd",
28338 clipRule: "evenodd",
28339 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"
28340 }));
28341 });
28342
28343 //#endregion
28344 //#region modules/ai/assets/js/editor/icons/x-circle-icon.js
28345 init_extends();
28346 var XCircleIcon = react.default.forwardRef(function(props, ref) {
28347 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" }));
28348 });
28349
28350 //#endregion
28351 //#region modules/ai/assets/js/editor/icons/plus-circle-icon.js
28352 init_extends();
28353 var PlusCircleIcon = react.default.forwardRef(function(props, ref) {
28354 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" }));
28355 });
28356
28357 //#endregion
28358 //#region modules/ai/assets/js/editor/components/alert-dialog.js
28359 init_slicedToArray();
28360 var AlertDialog = function AlertDialog(props) {
28361 var _useState2 = _slicedToArray((0, react.useState)(true), 2);
28362 var isShown = _useState2[0];
28363 var setIsShown = _useState2[1];
28364 if (!isShown) return null;
28365 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, {
28366 open: true,
28367 maxWidth: "lg"
28368 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogContent, { sx: { padding: 0 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { sx: {
28369 textAlign: "center",
28370 padding: 3
28371 } }, props.message), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
28372 alignItems: "center",
28373 spacing: 2,
28374 marginBottom: 2
28375 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
28376 variant: "contained",
28377 type: "button",
28378 color: "primary",
28379 onClick: function onClick() {
28380 var _props$onClose;
28381 setIsShown(false);
28382 (_props$onClose = props.onClose) === null || _props$onClose === void 0 || _props$onClose.call(props);
28383 }
28384 }, (0, _wordpress_i18n.__)("Close", "elementor")))));
28385 };
28386 AlertDialog.propTypes = {
28387 message: import_prop_types$12.default.string.isRequired,
28388 onClose: import_prop_types$12.default.func
28389 };
28390
28391 //#endregion
28392 //#region modules/ai/assets/js/editor/hooks/use-timeout.js
28393 init_slicedToArray();
28394 var useTimeout = function useTimeout(delay) {
28395 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
28396 var isTimeout = _useState2[0];
28397 var setIsTimeout = _useState2[1];
28398 var timeoutIdRef = (0, react.useRef)(null);
28399 var turnOffTimeout = function turnOffTimeout() {
28400 clearTimeout(timeoutIdRef.current);
28401 setIsTimeout(false);
28402 };
28403 (0, react.useEffect)(function() {
28404 timeoutIdRef.current = setTimeout(function() {
28405 setIsTimeout(true);
28406 }, delay);
28407 return function() {
28408 clearTimeout(timeoutIdRef.current);
28409 };
28410 }, [delay]);
28411 return [isTimeout, turnOffTimeout];
28412 };
28413
28414 //#endregion
28415 //#region modules/ai/assets/js/editor/pages/form-layout/context/remote-config.js
28416 init_asyncToGenerator();
28417 init_slicedToArray();
28418 init_api();
28419 var RemoteConfigContext = react.default.createContext({});
28420 var useRemoteConfig = function useRemoteConfig() {
28421 return react.default.useContext(RemoteConfigContext);
28422 };
28423 var CONFIG_KEYS = {
28424 WEB_BASED_BUILDER_URL: "webBasedBuilderUrl",
28425 AUTH_TOKEN: "jwt"
28426 };
28427 var RemoteConfigProvider = function RemoteConfigProvider(props) {
28428 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
28429 var isLoading = _useState2[0];
28430 var setIsLoading = _useState2[1];
28431 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
28432 var isLoaded = _useState4[0];
28433 var setIsLoaded = _useState4[1];
28434 var _useState6 = _slicedToArray((0, react.useState)(false), 2);
28435 var isError = _useState6[0];
28436 var setIsError = _useState6[1];
28437 var _useState8 = _slicedToArray((0, react.useState)({}), 2);
28438 var remoteConfig = _useState8[0];
28439 var setRemoteConfig = _useState8[1];
28440 var fetchData = /*#__PURE__*/ function() {
28441 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee() {
28442 var result;
28443 return import_regenerator$3.default.wrap(function(_context) {
28444 while (1) switch (_context.prev = _context.next) {
28445 case 0:
28446 setIsLoading(true);
28447 setIsError(false);
28448 _context.prev = 1;
28449 _context.next = 2;
28450 return getRemoteConfig().finally(function() {
28451 setIsLoaded(true);
28452 setIsLoading(false);
28453 });
28454 case 2:
28455 result = _context.sent;
28456 if (result.config) {
28457 _context.next = 3;
28458 break;
28459 }
28460 throw new Error("Invalid remote config");
28461 case 3:
28462 setRemoteConfig(result.config);
28463 _context.next = 5;
28464 break;
28465 case 4:
28466 _context.prev = 4;
28467 _context["catch"](1);
28468 setIsError(true);
28469 setIsLoaded(true);
28470 setIsLoading(false);
28471 case 5:
28472 case "end": return _context.stop();
28473 }
28474 }, _callee, null, [[1, 4]]);
28475 }));
28476 return function fetchData() {
28477 return _ref.apply(this, arguments);
28478 };
28479 }();
28480 (0, react.useEffect)(function() {
28481 window.addEventListener("elementor/connect/success", fetchData);
28482 return function() {
28483 window.removeEventListener("elementor/connect/success", fetchData);
28484 };
28485 }, []);
28486 if (!isLoaded && !isLoading) fetchData();
28487 return /*#__PURE__*/ react.default.createElement(RemoteConfigContext.Provider, { value: {
28488 isLoading,
28489 isLoaded,
28490 isError,
28491 remoteConfig
28492 } }, props.children);
28493 };
28494 RemoteConfigProvider.propTypes = {
28495 children: import_prop_types$12.default.node.isRequired,
28496 onError: import_prop_types$12.default.func.isRequired
28497 };
28498
28499 //#endregion
28500 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/url-dialog.js
28501 init_slicedToArray();
28502 init_requests_ids();
28503 var UrlDialog = function UrlDialog(props) {
28504 var _useTimeout2 = _slicedToArray(useTimeout(1e4), 2);
28505 var isTimeout = _useTimeout2[0];
28506 var turnOffTimeout = _useTimeout2[1];
28507 var _useUserInfo = useUserInfo();
28508 var isLoading = _useUserInfo.isLoading;
28509 var initialUsagePercentage = _useUserInfo.usagePercentage;
28510 var updateUsagePercentage = useRequestIds().updateUsagePercentage;
28511 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
28512 var isInitUsageDone = _useState2[0];
28513 var setIsInitUsageDone = _useState2[1];
28514 var builderUrl = useRemoteConfig().remoteConfig[CONFIG_KEYS.WEB_BASED_BUILDER_URL];
28515 var iframeOrigin = (builderUrl ? new URL(builderUrl) : {}).origin;
28516 var isOpen = (0, react.useRef)(false);
28517 (0, react.useEffect)(function() {
28518 if (!isInitUsageDone && !isLoading && (initialUsagePercentage || 0 === initialUsagePercentage)) {
28519 updateUsagePercentage(initialUsagePercentage);
28520 setIsInitUsageDone(true);
28521 }
28522 }, [
28523 isLoading,
28524 initialUsagePercentage,
28525 isInitUsageDone,
28526 updateUsagePercentage
28527 ]);
28528 (0, react.useEffect)(function() {
28529 if (!isOpen.current) try {
28530 window.$e.run("ai-integration/open-choose-element", { url: props.url });
28531 isOpen.current = true;
28532 } catch (error) {
28533 console.error(error);
28534 }
28535 }, [isOpen.current]);
28536 (0, react.useEffect)(function() {
28537 var onMessage = function onMessage(event) {
28538 if (event.origin !== iframeOrigin) return;
28539 var _event$data = event.data;
28540 var type = _event$data.type;
28541 var html = _event$data.html;
28542 var url = _event$data.url;
28543 switch (type) {
28544 case "element-selector/close":
28545 isOpen.current = false;
28546 props.onClose();
28547 break;
28548 case "element-selector/loaded":
28549 turnOffTimeout();
28550 isOpen.current = true;
28551 break;
28552 case "element-selector/attach":
28553 props.onAttach([{
28554 type: "url",
28555 previewHTML: html,
28556 content: html,
28557 label: url ? new URL(url).href : "",
28558 source: USER_URL_SOURCE
28559 }]);
28560 break;
28561 }
28562 };
28563 window.addEventListener("message", onMessage);
28564 return function() {
28565 window.removeEventListener("message", onMessage);
28566 };
28567 }, [
28568 iframeOrigin,
28569 props,
28570 turnOffTimeout
28571 ]);
28572 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, !isOpen.current && !isTimeout && /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, {
28573 open: true,
28574 maxWidth: "lg"
28575 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { sx: {
28576 textAlign: "center",
28577 padding: 3
28578 } }, (0, _wordpress_i18n.__)("Loading...", "elementor"))), isTimeout && /*#__PURE__*/ react.default.createElement(AlertDialog, {
28579 message: (0, _wordpress_i18n.__)("The app is not responding. Please try again later. (#408)", "elementor"),
28580 onClose: props.onClose
28581 }));
28582 };
28583 UrlDialog.propTypes = {
28584 onAttach: import_prop_types$12.default.func.isRequired,
28585 onClose: import_prop_types$12.default.func.isRequired,
28586 url: import_prop_types$12.default.string
28587 };
28588
28589 //#endregion
28590 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/library-dialog.js
28591 var LibraryDialog = function LibraryDialog(props) {
28592 var isApplyingTemplate = (0, react.useRef)(false);
28593 (0, react.useEffect)(function() {
28594 var onLibraryHide = function onLibraryHide() {
28595 if (isApplyingTemplate.current) return;
28596 props.onClose();
28597 };
28598 $e.components.get("library").layout.getModal().on("hide", onLibraryHide);
28599 return function() {
28600 $e.components.get("library").layout.getModal().off("hide", onLibraryHide);
28601 };
28602 }, [props]);
28603 (0, react.useEffect)(function() {
28604 var onMessage = function onMessage(event) {
28605 var _event$data = event.data;
28606 var type = _event$data.type;
28607 var json = _event$data.json;
28608 var html = _event$data.html;
28609 var label = _event$data.label;
28610 var source = _event$data.source;
28611 switch (type) {
28612 case "library/attach:start":
28613 isApplyingTemplate.current = true;
28614 break;
28615 case "library/attach":
28616 props.onAttach([{
28617 type: ATTACHMENT_TYPE_JSON,
28618 previewHTML: html,
28619 content: json,
28620 label,
28621 source
28622 }]);
28623 isApplyingTemplate.current = false;
28624 props.onClose();
28625 break;
28626 }
28627 };
28628 window.addEventListener("message", onMessage);
28629 return function() {
28630 window.removeEventListener("message", onMessage);
28631 };
28632 });
28633 $e.run("library/open", {
28634 toDefault: true,
28635 mode: "ai-attachment"
28636 });
28637 isApplyingTemplate.current = false;
28638 return null;
28639 };
28640 LibraryDialog.propTypes = {
28641 onAttach: import_prop_types$12.default.func.isRequired,
28642 onClose: import_prop_types$12.default.func.isRequired
28643 };
28644
28645 //#endregion
28646 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/attach-dialog.js
28647 var AttachDialog = function AttachDialog(props) {
28648 var type = props.type;
28649 var url = props.url;
28650 switch (type) {
28651 case "url": return /*#__PURE__*/ react.default.createElement(UrlDialog, {
28652 url,
28653 onAttach: props.onAttach,
28654 onClose: props.onClose
28655 });
28656 case MENU_TYPE_LIBRARY: return /*#__PURE__*/ react.default.createElement(LibraryDialog, {
28657 onAttach: props.onAttach,
28658 onClose: props.onClose
28659 });
28660 }
28661 return null;
28662 };
28663 AttachDialog.propTypes = {
28664 type: import_prop_types$12.default.string,
28665 onAttach: import_prop_types$12.default.func,
28666 onClose: import_prop_types$12.default.func,
28667 url: import_prop_types$12.default.string
28668 };
28669
28670 //#endregion
28671 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/menu.js
28672 init_slicedToArray();
28673 init_use_introduction();
28674 var Menu = function Menu(props) {
28675 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
28676 var isOpen = _useState2[0];
28677 var setIsOpen = _useState2[1];
28678 var _useState4 = _slicedToArray((0, react.useState)(null), 2);
28679 var selectedType = _useState4[0];
28680 var setSelectedType = _useState4[1];
28681 var direction = (0, _elementor_ui.useTheme)().direction;
28682 var anchorRef = (0, react.useRef)(null);
28683 var _useIntroduction = useIntroduction("e-ai-attachment-badge");
28684 var isViewed = _useIntroduction.isViewed;
28685 var markAsViewed = _useIntroduction.markAsViewed;
28686 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
28687 size: "small",
28688 ref: anchorRef,
28689 disabled: props.disabled,
28690 onClick: function onClick() {
28691 setIsOpen(true);
28692 if (!isViewed) markAsViewed();
28693 },
28694 color: "secondary"
28695 }, function() {
28696 if (isOpen) return /*#__PURE__*/ react.default.createElement(XCircleIcon, { fontSize: "small" });
28697 else if (isViewed) return /*#__PURE__*/ react.default.createElement(PlusCircleIcon, { fontSize: "small" });
28698 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Badge, {
28699 color: "primary",
28700 badgeContent: " ",
28701 variant: "dot"
28702 }, /*#__PURE__*/ react.default.createElement(PlusCircleIcon, { fontSize: "small" }));
28703 }()), /*#__PURE__*/ react.default.createElement(_elementor_ui.Popover, {
28704 open: isOpen,
28705 anchorEl: anchorRef.current,
28706 onClose: function onClose() {
28707 return setIsOpen(false);
28708 },
28709 anchorOrigin: {
28710 vertical: "bottom",
28711 horizontal: "rtl" === direction ? "right" : "left"
28712 },
28713 transformOrigin: {
28714 vertical: "top",
28715 horizontal: "rtl" === direction ? "right" : "left"
28716 }
28717 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, { sx: { width: 440 } }, props.items.map(function(item) {
28718 var IconComponent = item.icon;
28719 return /*#__PURE__*/ react.default.createElement(_elementor_ui.MenuItem, {
28720 key: item.type,
28721 onClick: function onClick() {
28722 setSelectedType(item.type);
28723 setIsOpen(false);
28724 }
28725 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemIcon, null, /*#__PURE__*/ react.default.createElement(IconComponent, null)), item.title);
28726 }))), /*#__PURE__*/ react.default.createElement(AttachDialog, {
28727 type: selectedType,
28728 onAttach: props.onAttach,
28729 onClose: function onClose() {
28730 setIsOpen(false);
28731 setSelectedType(null);
28732 }
28733 }));
28734 };
28735 Menu.propTypes = {
28736 items: import_prop_types$12.default.arrayOf(import_prop_types$12.default.shape({
28737 title: import_prop_types$12.default.string.isRequired,
28738 type: import_prop_types$12.default.string.isRequired,
28739 icon: import_prop_types$12.default.elementType
28740 })).isRequired,
28741 onAttach: import_prop_types$12.default.func.isRequired,
28742 disabled: import_prop_types$12.default.bool
28743 };
28744
28745 //#endregion
28746 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/thumbnail.js
28747 var _templateObject;
28748 var THUMBNAIL_SIZE = 64;
28749 var StyledBody = (0, _elementor_ui.styled)("body")(_templateObject || (_templateObject = _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);
28750 var Thumbnail = function Thumbnail(props) {
28751 var _props$html$match;
28752 var _props$html$match2;
28753 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;
28754 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;
28755 var width = dataWidth ? parseInt(dataWidth) : 64;
28756 var height = dataHeight ? parseInt(dataHeight) : 64;
28757 var scale = 64 / Math.min(height, width);
28758 var top = height > width ? (64 - 64 * (height / width)) / 2 : 0;
28759 var left = width > height ? (64 - 64 * (width / height)) / 2 : 0;
28760 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
28761 dir: "ltr",
28762 sx: {
28763 position: "relative",
28764 cursor: "default",
28765 overflow: "hidden",
28766 border: "1px solid",
28767 borderColor: "grey.300",
28768 borderRadius: 1,
28769 boxSizing: "border-box",
28770 width: 64,
28771 height: 64,
28772 opacity: props.disabled ? .5 : 1
28773 }
28774 }, /*#__PURE__*/ react.default.createElement("iframe", {
28775 title: (0, _wordpress_i18n.__)("Preview", "elementor"),
28776 sandbox: "",
28777 srcDoc: "<style>" + StyledBody.componentStyle.rules.join("") + "</style>" + props.html,
28778 style: {
28779 border: "none",
28780 overflow: "hidden",
28781 width,
28782 height,
28783 transform: "scale(".concat(scale, ")"),
28784 transformOrigin: "".concat(left, "px ").concat(top, "px")
28785 }
28786 }));
28787 };
28788 Thumbnail.propTypes = {
28789 html: import_prop_types$12.default.string.isRequired,
28790 disabled: import_prop_types$12.default.bool
28791 };
28792
28793 //#endregion
28794 //#region modules/ai/assets/js/editor/types/attachment.js
28795 var AttachmentPropType = import_prop_types$12.default.shape({
28796 type: import_prop_types$12.default.string,
28797 previewHTML: import_prop_types$12.default.string,
28798 content: import_prop_types$12.default.string,
28799 label: import_prop_types$12.default.string,
28800 source: import_prop_types$12.default.string
28801 });
28802 var AttachmentsTypesPropType = import_prop_types$12.default.shape({ type: import_prop_types$12.default.shape({
28803 promptPlaceholder: import_prop_types$12.default.string,
28804 promptSuggestions: import_prop_types$12.default.arrayOf(import_prop_types$12.default.shape({ text: import_prop_types$12.default.string.isRequired })),
28805 previewGenerator: import_prop_types$12.default.func
28806 }) });
28807
28808 //#endregion
28809 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/thumbnail-json.js
28810 var ThumbnailJson = function ThumbnailJson(props) {
28811 var _props$attachments;
28812 var attachment = (_props$attachments = props.attachments) === null || _props$attachments === void 0 ? void 0 : _props$attachments.find(function(item) {
28813 return "json" === item.type;
28814 });
28815 if (!attachment) return null;
28816 if (!attachment.previewHTML) return /*#__PURE__*/ react.default.createElement(_elementor_ui.Skeleton, {
28817 animation: "wave",
28818 variant: "rounded",
28819 width: 60,
28820 height: 60
28821 });
28822 return /*#__PURE__*/ react.default.createElement(Thumbnail, {
28823 html: attachment.previewHTML,
28824 disabled: props.disabled
28825 });
28826 };
28827 ThumbnailJson.propTypes = {
28828 attachments: import_prop_types$12.default.arrayOf(AttachmentPropType).isRequired,
28829 disabled: import_prop_types$12.default.bool
28830 };
28831
28832 //#endregion
28833 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/thumbnail-url.js
28834 var ThumbnailUrl = function ThumbnailUrl(props) {
28835 var _props$attachments;
28836 var attachment = (_props$attachments = props.attachments) === null || _props$attachments === void 0 ? void 0 : _props$attachments.find(function(item) {
28837 return "url" === item.type;
28838 });
28839 if (!attachment) return null;
28840 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
28841 position: "relative",
28842 "&:hover::before": {
28843 content: "\"\"",
28844 position: "absolute",
28845 userSelect: "none",
28846 inset: 0,
28847 backgroundColor: "rgba(0,0,0,0.6)",
28848 borderRadius: 1,
28849 zIndex: 1
28850 },
28851 "&:hover .remove-attachment": { display: "flex" }
28852 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
28853 className: "remove-attachment",
28854 size: "small",
28855 "aria-label": (0, _wordpress_i18n.__)("Remove", "elementor"),
28856 disabled: props.disabled,
28857 onClick: function onClick(event) {
28858 event.stopPropagation();
28859 props.onDetach();
28860 },
28861 sx: {
28862 display: "none",
28863 position: "absolute",
28864 insetInlineEnd: 4,
28865 insetBlockStart: 4,
28866 backgroundColor: "secondary.main",
28867 zIndex: 1,
28868 borderRadius: 1,
28869 p: "3px",
28870 "&:hover": { backgroundColor: "secondary.dark" }
28871 }
28872 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.TrashIcon, { sx: {
28873 fontSize: "1.125rem",
28874 color: "common.white"
28875 } })), /*#__PURE__*/ react.default.createElement(Thumbnail, {
28876 disabled: props.disabled,
28877 html: attachment.previewHTML
28878 }));
28879 };
28880 ThumbnailUrl.propTypes = {
28881 attachments: import_prop_types$12.default.arrayOf(AttachmentPropType).isRequired,
28882 disabled: import_prop_types$12.default.bool,
28883 onDetach: import_prop_types$12.default.func
28884 };
28885
28886 //#endregion
28887 //#region modules/ai/assets/js/editor/icons/website-icon.js
28888 init_extends();
28889 var WebsiteIcon = react.default.forwardRef(function(props, ref) {
28890 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
28891 fillRule: "evenodd",
28892 clipRule: "evenodd",
28893 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"
28894 }));
28895 });
28896
28897 //#endregion
28898 //#region modules/ai/assets/js/editor/icons/copy-page-icon.js
28899 init_extends();
28900 var CopyPageIcon = react.default.forwardRef(function(props, ref) {
28901 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
28902 fillRule: "evenodd",
28903 clipRule: "evenodd",
28904 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"
28905 }));
28906 });
28907
28908 //#endregion
28909 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments.js
28910 init_extends();
28911 var ATTACHMENT_TYPE_JSON = "json";
28912 var ATTACHMENT_TYPE_URL = "url";
28913 var MENU_TYPE_LIBRARY = "library";
28914 var USER_URL_SOURCE = "user-url";
28915 var Attachments = function Attachments(props) {
28916 if (!props.attachments.length) return /*#__PURE__*/ react.default.createElement(Menu, {
28917 disabled: props.disabled,
28918 onAttach: props.onAttach,
28919 items: [{
28920 title: (0, _wordpress_i18n.__)("Reference a website", "elementor"),
28921 icon: WebsiteIcon,
28922 type: "url"
28923 }, {
28924 title: (0, _wordpress_i18n.__)("Create variations from Template Library", "elementor"),
28925 icon: CopyPageIcon,
28926 type: MENU_TYPE_LIBRARY
28927 }]
28928 });
28929 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
28930 direction: "row",
28931 spacing: 1
28932 }, props.attachments.map(function(attachment, index) {
28933 switch (attachment.type) {
28934 case ATTACHMENT_TYPE_JSON: return /*#__PURE__*/ react.default.createElement(ThumbnailJson, _extends$1({ key: index }, props));
28935 case "url": return /*#__PURE__*/ react.default.createElement(ThumbnailUrl, _extends$1({ key: index }, props));
28936 default: return null;
28937 }
28938 }));
28939 };
28940 Attachments.propTypes = {
28941 attachments: import_prop_types$12.default.arrayOf(AttachmentPropType).isRequired,
28942 onAttach: import_prop_types$12.default.func.isRequired,
28943 onDetach: import_prop_types$12.default.func,
28944 disabled: import_prop_types$12.default.bool
28945 };
28946
28947 //#endregion
28948 //#region modules/ai/assets/js/editor/pages/form-layout/components/prompt-form.js
28949 init_slicedToArray();
28950 init_extends();
28951 init_objectWithoutProperties();
28952 var _excluded$1 = ["tooltip"];
28953 var PROMPT_SUGGESTIONS = Object.freeze([
28954 { text: (0, _wordpress_i18n.__)("Hero section on [topic] with heading, text, buttons on the right, and an image on the left", "elementor.com") },
28955 { text: (0, _wordpress_i18n.__)("About Us section on [topic] with heading, text, and big image below", "elementor.com") },
28956 { text: (0, _wordpress_i18n.__)("Team section with four image boxes showcasing team members", "elementor.com") },
28957 { text: (0, _wordpress_i18n.__)("FAQ section with a toggle widget showcasing FAQs about [topic]", "elementor.com") },
28958 { text: (0, _wordpress_i18n.__)("Gallery section with a carousel displaying three images at once", "elementor.com") },
28959 { text: (0, _wordpress_i18n.__)("Contact section with a form for [topic]", "elementor.com") },
28960 { text: (0, _wordpress_i18n.__)("Client section featuring companies' logos", "elementor.com") },
28961 { text: (0, _wordpress_i18n.__)("Testimonial section with testimonials, each featuring a star rating and an image", "elementor.com") },
28962 { text: (0, _wordpress_i18n.__)("Service section about [topic], showcasing four services with buttons", "elementor.com") },
28963 { text: (0, _wordpress_i18n.__)("Stats section with counters displaying data about [topic]", "elementor.com") },
28964 { text: (0, _wordpress_i18n.__)("Quote section with colored background, featuring a centered quote", "elementor.com") },
28965 { text: (0, _wordpress_i18n.__)("Pricing section for [topic] with a pricing list", "elementor.com") },
28966 { text: (0, _wordpress_i18n.__)("Subscribe section featuring a simple email form, inviting users to stay informed on [topic]", "elementor.com") }
28967 ]);
28968 var IconButtonWithTooltip = function IconButtonWithTooltip(_ref) {
28969 var tooltip = _ref.tooltip;
28970 var props = _objectWithoutProperties(_ref, _excluded$1);
28971 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: tooltip }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
28972 component: "span",
28973 sx: { cursor: props.disabled ? "default" : "pointer" }
28974 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, props)));
28975 };
28976 IconButtonWithTooltip.propTypes = {
28977 tooltip: import_prop_types$12.default.string,
28978 disabled: import_prop_types$12.default.bool
28979 };
28980 var BackButton = function BackButton(props) {
28981 return /*#__PURE__*/ react.default.createElement(IconButtonWithTooltip, _extends$1({
28982 size: "small",
28983 color: "secondary",
28984 tooltip: (0, _wordpress_i18n.__)("Back to results", "elementor")
28985 }, props), /*#__PURE__*/ react.default.createElement(ArrowLeftIcon, null));
28986 };
28987 var EditButton = function EditButton(props) {
28988 return /*#__PURE__*/ react.default.createElement(IconButtonWithTooltip, _extends$1({
28989 size: "small",
28990 color: "primary",
28991 tooltip: (0, _wordpress_i18n.__)("Edit prompt", "elementor")
28992 }, props), /*#__PURE__*/ react.default.createElement(EditIcon$1, null));
28993 };
28994 var GenerateButton = function GenerateButton(props) {
28995 return /*#__PURE__*/ react.default.createElement(GenerateSubmit, _extends$1({
28996 size: "small",
28997 fullWidth: false
28998 }, props), (0, _wordpress_i18n.__)("Generate", "elementor"));
28999 };
29000 var PromptForm = (0, react.forwardRef)(function(_ref2, ref) {
29001 var _attachments$;
29002 var attachments = _ref2.attachments;
29003 var isActive = _ref2.isActive;
29004 var isLoading = _ref2.isLoading;
29005 var _ref2$showActions = _ref2.showActions;
29006 var showActions = _ref2$showActions === void 0 ? false : _ref2$showActions;
29007 var onAttach = _ref2.onAttach;
29008 var onDetach = _ref2.onDetach;
29009 var _onSubmit = _ref2.onSubmit;
29010 var onBack = _ref2.onBack;
29011 var onEdit = _ref2.onEdit;
29012 var _ref2$shouldResetProm = _ref2.shouldResetPrompt;
29013 var shouldResetPrompt = _ref2$shouldResetProm === void 0 ? false : _ref2$shouldResetProm;
29014 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
29015 var prompt = _useState2[0];
29016 var setPrompt = _useState2[1];
29017 (0, react.useEffect)(function() {
29018 if (shouldResetPrompt) setPrompt("");
29019 }, [shouldResetPrompt]);
29020 var _usePromptEnhancer = usePromptEnhancer(prompt, "layout");
29021 var isEnhancing = _usePromptEnhancer.isEnhancing;
29022 var enhance = _usePromptEnhancer.enhance;
29023 var previousPrompt = (0, react.useRef)("");
29024 var attachmentsTypes = useConfig().attachmentsTypes;
29025 var isInputDisabled = isLoading || isEnhancing || !isActive;
29026 var isInputEmpty = "" === prompt && !attachments.length;
29027 var isGenerateDisabled = isInputDisabled || isInputEmpty;
29028 var attachmentsConfig = attachmentsTypes[((_attachments$ = attachments[0]) === null || _attachments$ === void 0 ? void 0 : _attachments$.type) || ""];
29029 var promptSuggestions = (attachmentsConfig === null || attachmentsConfig === void 0 ? void 0 : attachmentsConfig.promptSuggestions) || PROMPT_SUGGESTIONS;
29030 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");
29031 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
29032 component: "form",
29033 onSubmit: function onSubmit(e) {
29034 return _onSubmit(e, prompt);
29035 },
29036 direction: "row",
29037 sx: { p: 3 },
29038 alignItems: "start",
29039 gap: 1
29040 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
29041 direction: "row",
29042 alignItems: "start",
29043 flexGrow: 1,
29044 spacing: 2
29045 }, showActions && (isActive ? /*#__PURE__*/ react.default.createElement(BackButton, {
29046 disabled: isLoading || isEnhancing,
29047 onClick: function handleBack() {
29048 setPrompt(previousPrompt.current);
29049 onBack();
29050 }
29051 }) : /*#__PURE__*/ react.default.createElement(EditButton, {
29052 disabled: isLoading,
29053 onClick: function handleEdit() {
29054 previousPrompt.current = prompt;
29055 onEdit();
29056 }
29057 })), /*#__PURE__*/ react.default.createElement(Attachments, {
29058 attachments,
29059 onAttach,
29060 onDetach,
29061 disabled: isInputDisabled
29062 }), /*#__PURE__*/ react.default.createElement(PromptAutocomplete, {
29063 value: prompt,
29064 disabled: isInputDisabled,
29065 onSubmit: function onSubmit(e) {
29066 return _onSubmit(e, prompt);
29067 },
29068 options: promptSuggestions,
29069 onChange: function onChange(_, selectedValue) {
29070 return setPrompt(selectedValue.text + " ");
29071 },
29072 renderInput: function renderInput(params) {
29073 return /*#__PURE__*/ react.default.createElement(PromptAutocomplete.TextInput, _extends$1({}, params, {
29074 ref,
29075 onChange: function onChange(e) {
29076 return setPrompt(e.target.value);
29077 },
29078 placeholder: promptPlaceholder
29079 }));
29080 }
29081 })), /*#__PURE__*/ react.default.createElement(EnhanceButton, {
29082 size: "small",
29083 disabled: isGenerateDisabled || "" === prompt,
29084 isLoading: isEnhancing,
29085 onClick: function onClick() {
29086 return enhance().then(function(_ref3) {
29087 var result = _ref3.result;
29088 return setPrompt(result);
29089 });
29090 }
29091 }), /*#__PURE__*/ react.default.createElement(GenerateButton, { disabled: isGenerateDisabled }));
29092 });
29093 PromptForm.propTypes = {
29094 isActive: import_prop_types$12.default.bool,
29095 onAttach: import_prop_types$12.default.func,
29096 onDetach: import_prop_types$12.default.func,
29097 isLoading: import_prop_types$12.default.bool,
29098 showActions: import_prop_types$12.default.bool,
29099 onSubmit: import_prop_types$12.default.func.isRequired,
29100 onBack: import_prop_types$12.default.func.isRequired,
29101 onEdit: import_prop_types$12.default.func.isRequired,
29102 attachments: import_prop_types$12.default.arrayOf(AttachmentPropType),
29103 shouldResetPrompt: import_prop_types$12.default.bool
29104 };
29105
29106 //#endregion
29107 //#region modules/ai/assets/js/editor/pages/form-layout/components/screenshot-container.js
29108 var ScreenshotContainer = (0, _elementor_ui.styled)(_elementor_ui.Box, { shouldForwardProp: function shouldForwardProp(prop) {
29109 return prop !== "outlineOffset";
29110 } })(function(_ref) {
29111 var theme = _ref.theme;
29112 var selected = _ref.selected;
29113 var height = _ref.height;
29114 var disabled = _ref.disabled;
29115 var _ref$outlineOffset = _ref.outlineOffset;
29116 var outlineOffset = _ref$outlineOffset === void 0 ? "0px" : _ref$outlineOffset;
29117 var outlineColor = selected ? theme.palette.text.primary : theme.palette.text.disabled;
29118 var outline = "2px solid ".concat(outlineColor);
29119 return {
29120 height,
29121 cursor: disabled ? "default" : "pointer",
29122 overflow: "hidden",
29123 boxSizing: "border-box",
29124 backgroundPosition: "top center",
29125 backgroundSize: "100% auto",
29126 backgroundRepeat: "no-repeat",
29127 backgroundColor: theme.palette.common.white,
29128 borderRadius: theme.shape.borderRadius * .5,
29129 outlineOffset,
29130 outline,
29131 opacity: disabled ? "0.4" : "1",
29132 transition: "all 50ms linear",
29133 "&:hover": disabled ? {} : { outlineColor: theme.palette.text.primary }
29134 };
29135 });
29136
29137 //#endregion
29138 //#region modules/ai/assets/js/editor/pages/form-layout/components/screenshot-unavailable.js
29139 init_extends();
29140 init_defineProperty();
29141 function ownKeys$2(e, r) {
29142 var t = Object.keys(e);
29143 if (Object.getOwnPropertySymbols) {
29144 var o = Object.getOwnPropertySymbols(e);
29145 r && (o = o.filter(function(r) {
29146 return Object.getOwnPropertyDescriptor(e, r).enumerable;
29147 })), t.push.apply(t, o);
29148 }
29149 return t;
29150 }
29151 __name(ownKeys$2, "ownKeys");
29152 function _objectSpread$2(e) {
29153 for (var r = 1; r < arguments.length; r++) {
29154 var t = null != arguments[r] ? arguments[r] : {};
29155 r % 2 ? ownKeys$2(Object(t), !0).forEach(function(r) {
29156 _defineProperty(e, r, t[r]);
29157 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function(r) {
29158 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
29159 });
29160 }
29161 return e;
29162 }
29163 __name(_objectSpread$2, "_objectSpread");
29164 function ScreenshotUnavailable(props) {
29165 return /*#__PURE__*/ react.default.createElement(ScreenshotContainer, _extends$1({}, props, { sx: _objectSpread$2(_objectSpread$2({}, props.sx || {}), {}, {
29166 display: "flex",
29167 alignItems: "center",
29168 justifyContent: "center",
29169 backgroundColor: "background.paper",
29170 color: "text.tertiary",
29171 fontStyle: "italic",
29172 fontSize: "12px",
29173 paddingInline: 12,
29174 textAlign: "center",
29175 lineHeight: 1.5
29176 }) }), (0, _wordpress_i18n.__)("Preview unavailable", "elementor"));
29177 }
29178 ScreenshotUnavailable.propTypes = { sx: import_prop_types$12.default.object };
29179
29180 //#endregion
29181 //#region modules/ai/assets/js/editor/icons/lock-icon.js
29182 init_extends();
29183 var LockIcon = react.default.forwardRef(function(props, ref) {
29184 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
29185 fillRule: "evenodd",
29186 clipRule: "evenodd",
29187 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"
29188 }), /*#__PURE__*/ react.default.createElement("path", {
29189 fillRule: "evenodd",
29190 clipRule: "evenodd",
29191 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"
29192 }), /*#__PURE__*/ react.default.createElement("path", { d: "M6 12H19V20H6V12Z" }));
29193 });
29194
29195 //#endregion
29196 //#region modules/ai/assets/js/editor/pages/form-layout/components/pro-template-indicator.js
29197 init_slicedToArray();
29198 var popoverId = "e-pro-upgrade-popover";
29199 var StyledContent = (0, _elementor_ui.styled)(_elementor_ui.Paper)(function(_ref) {
29200 var theme = _ref.theme;
29201 return {
29202 position: "relative",
29203 padding: theme.spacing(3),
29204 boxShadow: theme.shadows[4],
29205 zIndex: "9999"
29206 };
29207 });
29208 var StyledArrow = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref2) {
29209 var theme = _ref2.theme;
29210 return {
29211 position: "absolute",
29212 width: theme.spacing(5),
29213 height: theme.spacing(5),
29214 overflow: "hidden",
29215 left: "100% !important",
29216 transform: "translateX(-50%) translateY(-50%) rotate(var(--rotate, 0deg)) !important",
29217 "&::after": {
29218 backgroundColor: theme.palette.background.paper,
29219 content: "\"\"",
29220 display: "block",
29221 position: "absolute",
29222 width: theme.spacing(2.5),
29223 height: theme.spacing(2.5),
29224 top: "50%",
29225 left: "50%",
29226 transform: "translateX(-50%) translateY(-50%) rotate(45deg)",
29227 boxShadow: "5px -5px 5px 0px rgba(0, 0, 0, 0.2)",
29228 backgroundImage: "linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"
29229 }
29230 };
29231 });
29232 var ProTemplateIndicator = function ProTemplateIndicator() {
29233 var actionUrl = "https://go.elementor.com/go-pro-ai/";
29234 var actionLabel = (0, _wordpress_i18n.__)("Go Pro", "elementor");
29235 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
29236 var isPopoverOpen = _useState2[0];
29237 var setIsPopoverOpen = _useState2[1];
29238 var anchorEl = (0, react.useRef)(null);
29239 var arrowEl = (0, react.useRef)(null);
29240 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
29241 flexDirection: "row-reverse",
29242 component: "span",
29243 display: "flex",
29244 onMouseLeave: function hidePopover() {
29245 return setIsPopoverOpen(false);
29246 },
29247 alignItems: "center"
29248 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
29249 ref: anchorEl,
29250 onMouseEnter: function showPopover() {
29251 return setIsPopoverOpen(true);
29252 },
29253 onClick: function onClick(e) {
29254 return e.stopPropagation();
29255 },
29256 "aria-owns": isPopoverOpen ? popoverId : void 0,
29257 "aria-haspopup": "true",
29258 sx: {
29259 m: 1,
29260 "&:hover": { backgroundColor: "action.selected" }
29261 }
29262 }, /*#__PURE__*/ react.default.createElement(LockIcon, { sx: { color: "text.primary" } })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Popper, {
29263 open: isPopoverOpen,
29264 popperOptions: {
29265 placement: "left-start",
29266 modifiers: [{
29267 name: "arrow",
29268 enabled: true,
29269 options: {
29270 element: arrowEl.current,
29271 padding: 5
29272 }
29273 }, {
29274 name: "offset",
29275 options: { offset: [0, 10] }
29276 }]
29277 },
29278 anchorEl: anchorEl.current,
29279 sx: {
29280 zIndex: "9999",
29281 maxWidth: 300
29282 }
29283 }, /*#__PURE__*/ react.default.createElement(StyledContent, null, /*#__PURE__*/ react.default.createElement(StyledArrow, { ref: arrowEl }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
29284 alignItems: "start",
29285 spacing: 2
29286 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Chip, {
29287 color: "promotion",
29288 variant: "outlined",
29289 size: "small",
29290 label: (0, _wordpress_i18n.__)("Pro", "elementor"),
29291 icon: /*#__PURE__*/ react.default.createElement(LockIcon, null)
29292 }), /*#__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, {
29293 variant: "contained",
29294 color: "promotion",
29295 size: "small",
29296 href: actionUrl,
29297 target: "_blank",
29298 sx: { alignSelf: "flex-end" }
29299 }, actionLabel)))));
29300 };
29301
29302 //#endregion
29303 //#region modules/ai/assets/js/editor/pages/form-layout/components/template-badge.js
29304 var TemplateBadge = function TemplateBadge(props) {
29305 var hasPro = useConfig().hasPro;
29306 if ("Pro" === props.type && !hasPro) return /*#__PURE__*/ react.default.createElement(ProTemplateIndicator, null);
29307 return null;
29308 };
29309 TemplateBadge.propTypes = { type: import_prop_types$12.default.string };
29310
29311 //#endregion
29312 //#region modules/ai/assets/js/editor/pages/form-layout/components/screenshot.js
29313 init_defineProperty();
29314 function ownKeys$1(e, r) {
29315 var t = Object.keys(e);
29316 if (Object.getOwnPropertySymbols) {
29317 var o = Object.getOwnPropertySymbols(e);
29318 r && (o = o.filter(function(r) {
29319 return Object.getOwnPropertyDescriptor(e, r).enumerable;
29320 })), t.push.apply(t, o);
29321 }
29322 return t;
29323 }
29324 __name(ownKeys$1, "ownKeys");
29325 function _objectSpread$1(e) {
29326 for (var r = 1; r < arguments.length; r++) {
29327 var t = null != arguments[r] ? arguments[r] : {};
29328 r % 2 ? ownKeys$1(Object(t), !0).forEach(function(r) {
29329 _defineProperty(e, r, t[r]);
29330 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function(r) {
29331 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
29332 });
29333 }
29334 return e;
29335 }
29336 __name(_objectSpread$1, "_objectSpread");
29337 var SCREENSHOT_HEIGHT = "138px";
29338 var Screenshot = function Screenshot(_ref) {
29339 var url = _ref.url;
29340 var type = _ref.type;
29341 var _ref$isLoading = _ref.isLoading;
29342 var isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading;
29343 var _ref$isSelected = _ref.isSelected;
29344 var isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected;
29345 var isPlaceholder = _ref.isPlaceholder;
29346 var disabled = _ref.disabled;
29347 var onClick = _ref.onClick;
29348 var _ref$sx = _ref.sx;
29349 var sx = _ref$sx === void 0 ? {} : _ref$sx;
29350 var outlineOffset = _ref.outlineOffset;
29351 if (isPlaceholder) return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: _objectSpread$1({ height: SCREENSHOT_HEIGHT }, sx) });
29352 if (isLoading) return /*#__PURE__*/ react.default.createElement(_elementor_ui.Skeleton, {
29353 width: "100%",
29354 animation: "wave",
29355 variant: "rounded",
29356 height: SCREENSHOT_HEIGHT,
29357 sx
29358 });
29359 if (!url) return /*#__PURE__*/ react.default.createElement(ScreenshotUnavailable, {
29360 selected: isSelected,
29361 disabled,
29362 sx,
29363 onClick,
29364 height: SCREENSHOT_HEIGHT,
29365 outlineOffset
29366 });
29367 return /*#__PURE__*/ react.default.createElement(ScreenshotContainer, {
29368 selected: isSelected,
29369 disabled,
29370 sx: _objectSpread$1({ backgroundImage: "url('".concat(url, "')") }, sx),
29371 onClick,
29372 height: SCREENSHOT_HEIGHT,
29373 outlineOffset
29374 }, /*#__PURE__*/ react.default.createElement(TemplateBadge, { type }));
29375 };
29376 Screenshot.propTypes = {
29377 isSelected: import_prop_types$12.default.bool,
29378 isLoading: import_prop_types$12.default.bool,
29379 isPlaceholder: import_prop_types$12.default.bool,
29380 disabled: import_prop_types$12.default.bool,
29381 onClick: import_prop_types$12.default.func.isRequired,
29382 url: import_prop_types$12.default.string,
29383 type: import_prop_types$12.default.string,
29384 sx: import_prop_types$12.default.object,
29385 outlineOffset: import_prop_types$12.default.string
29386 };
29387
29388 //#endregion
29389 //#region modules/ai/assets/js/editor/pages/form-layout/hooks/use-layout-prompt.js
29390 init_api();
29391 init_use_prompt();
29392 var useLayoutPrompt = function useLayoutPrompt(type, initialValue) {
29393 return usePrompt(function(requestBody, signal) {
29394 requestBody.variationType = type;
29395 return generateLayout(requestBody, signal);
29396 }, initialValue);
29397 };
29398
29399 //#endregion
29400 //#region modules/ai/assets/js/editor/pages/form-layout/hooks/use-screenshot.js
29401 init_asyncToGenerator();
29402 init_slicedToArray();
29403 var ERROR_INITIAL_VALUE = "";
29404 var useScreenshot = function useScreenshot(type, onData) {
29405 var _useState2 = _slicedToArray((0, react.useState)(ERROR_INITIAL_VALUE), 2);
29406 var error = _useState2[0];
29407 var setError = _useState2[1];
29408 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
29409 var isLoading = _useState4[0];
29410 var setIsLoading = _useState4[1];
29411 var layoutData = useLayoutPrompt(type, null);
29412 return {
29413 generate: function generate(requestBody, signal) {
29414 setIsLoading(true);
29415 setError(ERROR_INITIAL_VALUE);
29416 return layoutData.send(requestBody, signal).then(/*#__PURE__*/ function() {
29417 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee(data) {
29418 var createdScreenshot;
29419 return import_regenerator$3.default.wrap(function(_context) {
29420 while (1) switch (_context.prev = _context.next) {
29421 case 0:
29422 _context.next = 1;
29423 return onData(data.result);
29424 case 1:
29425 createdScreenshot = _context.sent;
29426 createdScreenshot.sendUsageData = function() {
29427 return layoutData.sendUsageData(data);
29428 };
29429 createdScreenshot.baseTemplateId = data.baseTemplateId;
29430 createdScreenshot.type = data.type;
29431 return _context.abrupt("return", createdScreenshot);
29432 case 2:
29433 case "end": return _context.stop();
29434 }
29435 }, _callee);
29436 }));
29437 return function(_x) {
29438 return _ref.apply(this, arguments);
29439 };
29440 }()).catch(function(err) {
29441 setError(err.extra_data ? err : err.message || err);
29442 throw err;
29443 }).finally(function() {
29444 return setIsLoading(false);
29445 });
29446 },
29447 error,
29448 isLoading
29449 };
29450 };
29451
29452 //#endregion
29453 //#region modules/ai/assets/js/editor/pages/form-layout/hooks/use-screenshots.js
29454 init_asyncToGenerator();
29455 init_slicedToArray();
29456 init_requests_ids();
29457 var PENDING_VALUE = { isPending: true };
29458 var useScreenshots = function useScreenshots(_ref) {
29459 var onData = _ref.onData;
29460 var _useState2 = _slicedToArray((0, react.useState)([]), 2);
29461 var screenshots = _useState2[0];
29462 var setScreenshots = _useState2[1];
29463 /**
29464 * The ids for each request are:
29465 * - editorSessionId: a unique id for each editor opening
29466 * - sessionId: a unique id for each session. (open the AI builder)
29467 * - generateId: a unique id for each generate request. (prompt change)
29468 * - batchId: a unique id for each batch of generate requests. (generate, regenerate)
29469 * - requestId: a unique id for each generate request.
29470 */
29471 var currentContext = useConfig().currentContext;
29472 var _useRequestIds = useRequestIds();
29473 var editorSessionId = _useRequestIds.editorSessionId;
29474 var sessionId = _useRequestIds.sessionId;
29475 var setRequest = _useRequestIds.setRequest;
29476 var setBatch = _useRequestIds.setBatch;
29477 var setGenerate = _useRequestIds.setGenerate;
29478 var generateIdRef = (0, react.useRef)("");
29479 var batchId = setBatch();
29480 var screenshotsData = [
29481 useScreenshot(0, onData),
29482 useScreenshot(1, onData),
29483 useScreenshot(2, onData)
29484 ];
29485 var screenshotsGroupCount = screenshotsData.length;
29486 var error = screenshotsData.every(function(s) {
29487 return s === null || s === void 0 ? void 0 : s.error;
29488 }) ? screenshotsData[0].error : "";
29489 var isLoading = screenshotsData.some(function(s) {
29490 return s === null || s === void 0 ? void 0 : s.isLoading;
29491 });
29492 var abortController = (0, react.useRef)(null);
29493 var abort = function abort() {
29494 var _abortController$curr;
29495 return (_abortController$curr = abortController.current) === null || _abortController$curr === void 0 ? void 0 : _abortController$curr.abort();
29496 };
29497 var createScreenshots = /*#__PURE__*/ function() {
29498 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee(prompt, attachments) {
29499 var onGenerate;
29500 var onError;
29501 var promises;
29502 var results;
29503 var isAllFailed;
29504 return import_regenerator$3.default.wrap(function(_context) {
29505 while (1) switch (_context.prev = _context.next) {
29506 case 0:
29507 abortController.current = new AbortController();
29508 onGenerate = function onGenerate(screenshot) {
29509 setScreenshots(function(prev) {
29510 var updatedData = _toConsumableArray(prev);
29511 var pendingIndex = updatedData.indexOf(PENDING_VALUE);
29512 updatedData[pendingIndex] = screenshot;
29513 return updatedData;
29514 });
29515 return true;
29516 };
29517 onError = function onError() {
29518 setScreenshots(function(prev) {
29519 var updatedData = _toConsumableArray(prev);
29520 var pendingIndex = updatedData.lastIndexOf(PENDING_VALUE);
29521 updatedData[pendingIndex] = { isError: true };
29522 return updatedData;
29523 });
29524 return false;
29525 };
29526 promises = screenshotsData.map(function(_ref3) {
29527 var generate = _ref3.generate;
29528 return generate({
29529 prompt,
29530 prevGeneratedIds: screenshots.map(function(screenshot) {
29531 return screenshot.baseTemplateId || "";
29532 }),
29533 currentContext,
29534 ids: {
29535 editorSessionId: editorSessionId.current,
29536 sessionId: sessionId.current,
29537 generateId: generateIdRef.current,
29538 batchId: batchId.current,
29539 requestId: setRequest().current
29540 },
29541 attachments: attachments.map(function(_ref4) {
29542 return {
29543 type: _ref4.type,
29544 content: _ref4.content,
29545 label: _ref4.label,
29546 source: _ref4.source
29547 };
29548 })
29549 }, abortController.current.signal).then(onGenerate).catch(onError);
29550 });
29551 _context.next = 1;
29552 return Promise.all(promises);
29553 case 1:
29554 results = _context.sent;
29555 isAllFailed = results.every(function(value) {
29556 return false === value;
29557 });
29558 if (isAllFailed) setScreenshots(function(prev) {
29559 var updatedData = _toConsumableArray(prev);
29560 updatedData.splice(screenshotsGroupCount * -1);
29561 return updatedData;
29562 });
29563 case 2:
29564 case "end": return _context.stop();
29565 }
29566 }, _callee);
29567 }));
29568 return function createScreenshots(_x, _x2) {
29569 return _ref2.apply(this, arguments);
29570 };
29571 }();
29572 return {
29573 generate: function generate(prompt, attachments) {
29574 var placeholders = Array(screenshotsGroupCount).fill(PENDING_VALUE);
29575 generateIdRef.current = setGenerate().current;
29576 setScreenshots(placeholders);
29577 createScreenshots(prompt, attachments);
29578 },
29579 regenerate: function regenerate(prompt, attachments) {
29580 var placeholders = Array(screenshotsGroupCount).fill(PENDING_VALUE);
29581 setScreenshots(function(prev) {
29582 return [].concat(_toConsumableArray(prev), _toConsumableArray(placeholders));
29583 });
29584 createScreenshots(prompt, attachments);
29585 },
29586 screenshots,
29587 isLoading,
29588 error,
29589 abort
29590 };
29591 };
29592
29593 //#endregion
29594 //#region modules/ai/assets/js/editor/pages/form-layout/hooks/use-slider.js
29595 init_slicedToArray();
29596 var SCREENSHOTS_PER_PAGE = 3;
29597 var useSlider = function useSlider() {
29598 var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
29599 var _ref$slidesCount = _ref.slidesCount;
29600 var slidesCount = _ref$slidesCount === void 0 ? 0 : _ref$slidesCount;
29601 var _ref$slidesPerPage = _ref.slidesPerPage;
29602 var slidesPerPage = _ref$slidesPerPage === void 0 ? 3 : _ref$slidesPerPage;
29603 var _ref$gapPercentage = _ref.gapPercentage;
29604 var gapPercentage = _ref$gapPercentage === void 0 ? 2 : _ref$gapPercentage;
29605 var _useState2 = _slicedToArray((0, react.useState)(1), 2);
29606 var currentPage = _useState2[0];
29607 var setCurrentPage = _useState2[1];
29608 var slideWidthPercentage = (100 - gapPercentage * (slidesPerPage - 1)) / slidesPerPage;
29609 var offsetXPercentage = (slideWidthPercentage + gapPercentage) * slidesPerPage * (currentPage - 1) * -1;
29610 var pagesCount = Math.ceil(slidesCount / slidesPerPage);
29611 (0, react.useEffect)(function() {
29612 if (currentPage > 1 && currentPage > pagesCount) setCurrentPage(pagesCount);
29613 }, [pagesCount]);
29614 return {
29615 currentPage,
29616 setCurrentPage,
29617 pagesCount,
29618 slidesPerPage,
29619 gapPercentage,
29620 offsetXPercentage,
29621 slideWidthPercentage
29622 };
29623 };
29624
29625 //#endregion
29626 //#region modules/ai/assets/js/editor/icons/minimize-diagonal-icon.js
29627 init_extends();
29628 var MinimizeDiagonalIcon = react.default.forwardRef(function(props, ref) {
29629 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
29630 fillRule: "evenodd",
29631 clipRule: "evenodd",
29632 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"
29633 }));
29634 });
29635
29636 //#endregion
29637 //#region modules/ai/assets/js/editor/icons/expand-diagonal-icon.js
29638 init_extends();
29639 var ExpandDiagonalIcon = react.default.forwardRef(function(props, ref) {
29640 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
29641 fillRule: "evenodd",
29642 clipRule: "evenodd",
29643 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"
29644 }));
29645 });
29646
29647 //#endregion
29648 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/prompt-power-notice.js
29649 init_use_introduction();
29650 var PromptPowerNotice = function PromptPowerNotice() {
29651 var _useIntroduction = useIntroduction("e-ai-builder-attachments-power");
29652 var isViewed = _useIntroduction.isViewed;
29653 var markAsViewed = _useIntroduction.markAsViewed;
29654 if (isViewed) return null;
29655 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
29656 pt: 2,
29657 px: 2,
29658 pb: 0
29659 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Alert, {
29660 severity: "info",
29661 onClose: function onClose() {
29662 return markAsViewed();
29663 }
29664 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
29665 variant: "body2",
29666 display: "inline-block",
29667 sx: { paddingInlineEnd: 1 }
29668 }, (0, _wordpress_i18n.__)("You’ve got the power.", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
29669 variant: "body2",
29670 display: "inline-block"
29671 }, (0, _wordpress_i18n.__)("Craft your prompt to affect content, images and/or colors - whichever you decide.", "elementor"))));
29672 };
29673
29674 //#endregion
29675 //#region node_modules/validator/lib/util/assertString.js
29676 var require_assertString = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29677 Object.defineProperty(exports, "__esModule", { value: true });
29678 exports.default = assertString;
29679 function assertString(input) {
29680 if (input === void 0 || input === null) throw new TypeError("Expected a string but received a ".concat(input));
29681 if (input.constructor.name !== "String") throw new TypeError("Expected a string but received a ".concat(input.constructor.name));
29682 }
29683 module.exports = exports.default;
29684 module.exports.default = exports.default;
29685 }));
29686
29687 //#endregion
29688 //#region node_modules/validator/lib/util/checkHost.js
29689 var require_checkHost = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29690 Object.defineProperty(exports, "__esModule", { value: true });
29691 exports.default = checkHost;
29692 function isRegExp(obj) {
29693 return Object.prototype.toString.call(obj) === "[object RegExp]";
29694 }
29695 function checkHost(host, matches) {
29696 for (var i = 0; i < matches.length; i++) {
29697 var match = matches[i];
29698 if (host === match || isRegExp(match) && match.test(host)) return true;
29699 }
29700 return false;
29701 }
29702 module.exports = exports.default;
29703 module.exports.default = exports.default;
29704 }));
29705
29706 //#endregion
29707 //#region node_modules/validator/lib/util/includesString.js
29708 var require_includesString = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29709 Object.defineProperty(exports, "__esModule", { value: true });
29710 exports.default = void 0;
29711 var includes = function includes(str, val) {
29712 return str.indexOf(val) !== -1;
29713 };
29714 exports.default = includes;
29715 module.exports = exports.default;
29716 module.exports.default = exports.default;
29717 }));
29718
29719 //#endregion
29720 //#region node_modules/validator/lib/util/merge.js
29721 var require_merge = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29722 Object.defineProperty(exports, "__esModule", { value: true });
29723 exports.default = merge;
29724 function merge() {
29725 var obj = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
29726 var defaults = arguments.length > 1 ? arguments[1] : void 0;
29727 for (var key in defaults) if (typeof obj[key] === "undefined") obj[key] = defaults[key];
29728 return obj;
29729 }
29730 module.exports = exports.default;
29731 module.exports.default = exports.default;
29732 }));
29733
29734 //#endregion
29735 //#region node_modules/validator/lib/isFQDN.js
29736 var require_isFQDN = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29737 Object.defineProperty(exports, "__esModule", { value: true });
29738 exports.default = isFQDN;
29739 var _assertString = _interopRequireDefault(require_assertString());
29740 var _merge = _interopRequireDefault(require_merge());
29741 function _interopRequireDefault(e) {
29742 return e && e.__esModule ? e : { default: e };
29743 }
29744 var default_fqdn_options = {
29745 require_tld: true,
29746 allow_underscores: false,
29747 allow_trailing_dot: false,
29748 allow_numeric_tld: false,
29749 allow_wildcard: false,
29750 ignore_max_length: false
29751 };
29752 function isFQDN(str, options) {
29753 (0, _assertString.default)(str);
29754 options = (0, _merge.default)(options, default_fqdn_options);
29755 if (options.allow_trailing_dot && str[str.length - 1] === ".") str = str.substring(0, str.length - 1);
29756 if (options.allow_wildcard === true && str.indexOf("*.") === 0) str = str.substring(2);
29757 var parts = str.split(".");
29758 var tld = parts[parts.length - 1];
29759 if (options.require_tld) {
29760 if (parts.length < 2) return false;
29761 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;
29762 if (/\s/.test(tld)) return false;
29763 }
29764 if (!options.allow_numeric_tld && /^\d+$/.test(tld)) return false;
29765 return parts.every(function(part) {
29766 if (part.length > 63 && !options.ignore_max_length) return false;
29767 if (!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(part)) return false;
29768 if (/[\uff01-\uff5e]/.test(part)) return false;
29769 if (/^-|-$/.test(part)) return false;
29770 if (!options.allow_underscores && /_/.test(part)) return false;
29771 return true;
29772 });
29773 }
29774 module.exports = exports.default;
29775 module.exports.default = exports.default;
29776 }));
29777
29778 //#endregion
29779 //#region node_modules/validator/lib/isIP.js
29780 var require_isIP = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29781 Object.defineProperty(exports, "__esModule", { value: true });
29782 exports.default = isIP;
29783 var _assertString = _interopRequireDefault(require_assertString());
29784 function _interopRequireDefault(e) {
29785 return e && e.__esModule ? e : { default: e };
29786 }
29787 function _typeof(o) {
29788 "@babel/helpers - typeof";
29789 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
29790 return typeof o;
29791 } : function(o) {
29792 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
29793 }, _typeof(o);
29794 }
29795 /**
29796 11.3. Examples
29797
29798 The following addresses
29799
29800 fe80::1234 (on the 1st link of the node)
29801 ff02::5678 (on the 5th link of the node)
29802 ff08::9abc (on the 10th organization of the node)
29803
29804 would be represented as follows:
29805
29806 fe80::1234%1
29807 ff02::5678%5
29808 ff08::9abc%10
29809
29810 (Here we assume a natural translation from a zone index to the
29811 <zone_id> part, where the Nth zone of any scope is translated into
29812 "N".)
29813
29814 If we use interface names as <zone_id>, those addresses could also be
29815 represented as follows:
29816
29817 fe80::1234%ne0
29818 ff02::5678%pvc1.3
29819 ff08::9abc%interface10
29820
29821 where the interface "ne0" belongs to the 1st link, "pvc1.3" belongs
29822 to the 5th link, and "interface10" belongs to the 10th organization.
29823 * * */
29824 var IPv4SegmentFormat = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])";
29825 var IPv4AddressFormat = "(".concat(IPv4SegmentFormat, "[.]){3}").concat(IPv4SegmentFormat);
29826 var IPv4AddressRegExp = new RegExp("^".concat(IPv4AddressFormat, "$"));
29827 var IPv6SegmentFormat = "(?:[0-9a-fA-F]{1,4})";
29828 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,})?$");
29829 function isIP(ipAddress) {
29830 var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
29831 (0, _assertString.default)(ipAddress);
29832 var version = (_typeof(options) === "object" ? options.version : arguments[1]) || "";
29833 if (!version) return isIP(ipAddress, { version: 4 }) || isIP(ipAddress, { version: 6 });
29834 if (version.toString() === "4") return IPv4AddressRegExp.test(ipAddress);
29835 if (version.toString() === "6") return IPv6AddressRegExp.test(ipAddress);
29836 return false;
29837 }
29838 module.exports = exports.default;
29839 module.exports.default = exports.default;
29840 }));
29841
29842 //#endregion
29843 //#region node_modules/validator/lib/isURL.js
29844 var require_isURL = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29845 Object.defineProperty(exports, "__esModule", { value: true });
29846 exports.default = isURL;
29847 var _assertString = _interopRequireDefault(require_assertString());
29848 var _checkHost = _interopRequireDefault(require_checkHost());
29849 var _includesString = _interopRequireDefault(require_includesString());
29850 var _isFQDN = _interopRequireDefault(require_isFQDN());
29851 var _isIP = _interopRequireDefault(require_isIP());
29852 var _merge = _interopRequireDefault(require_merge());
29853 function _interopRequireDefault(e) {
29854 return e && e.__esModule ? e : { default: e };
29855 }
29856 function _slicedToArray(r, e) {
29857 return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
29858 }
29859 function _nonIterableRest() {
29860 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
29861 }
29862 function _unsupportedIterableToArray(r, a) {
29863 if (r) {
29864 if ("string" == typeof r) return _arrayLikeToArray(r, a);
29865 var t = {}.toString.call(r).slice(8, -1);
29866 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;
29867 }
29868 }
29869 function _arrayLikeToArray(r, a) {
29870 (null == a || a > r.length) && (a = r.length);
29871 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
29872 return n;
29873 }
29874 function _iterableToArrayLimit(r, l) {
29875 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
29876 if (null != t) {
29877 var e;
29878 var n;
29879 var i;
29880 var u;
29881 var a = [];
29882 var f = !0;
29883 var o = !1;
29884 try {
29885 if (i = (t = t.call(r)).next, 0 === l) {
29886 if (Object(t) !== t) return;
29887 f = !1;
29888 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
29889 } catch (r) {
29890 o = !0, n = r;
29891 } finally {
29892 try {
29893 if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
29894 } finally {
29895 if (o) throw n;
29896 }
29897 }
29898 return a;
29899 }
29900 }
29901 function _arrayWithHoles(r) {
29902 if (Array.isArray(r)) return r;
29903 }
29904 var default_url_options = {
29905 protocols: [
29906 "http",
29907 "https",
29908 "ftp"
29909 ],
29910 require_tld: true,
29911 require_protocol: false,
29912 require_host: true,
29913 require_port: false,
29914 require_valid_protocol: true,
29915 allow_underscores: false,
29916 allow_trailing_dot: false,
29917 allow_protocol_relative_urls: false,
29918 allow_fragments: true,
29919 allow_query_components: true,
29920 validate_length: true,
29921 max_allowed_length: 2084
29922 };
29923 var wrapped_ipv6 = /^\[([^\]]+)\](?::([0-9]+))?$/;
29924 function isURL(url, options) {
29925 (0, _assertString.default)(url);
29926 if (!url || /[\s<>]/.test(url)) return false;
29927 if (url.indexOf("mailto:") === 0) return false;
29928 options = (0, _merge.default)(options, default_url_options);
29929 if (options.validate_length && url.length > options.max_allowed_length) return false;
29930 if (!options.allow_fragments && (0, _includesString.default)(url, "#")) return false;
29931 if (!options.allow_query_components && ((0, _includesString.default)(url, "?") || (0, _includesString.default)(url, "&"))) return false;
29932 var protocol;
29933 var auth;
29934 var host;
29935 var hostname;
29936 var port;
29937 var port_str;
29938 var split = url.split("#");
29939 var ipv6;
29940 url = split.shift();
29941 split = url.split("?");
29942 url = split.shift();
29943 var protocol_match = url.match(/^([a-z][a-z0-9+\-.]*):/i);
29944 var had_explicit_protocol = false;
29945 var cleanUpProtocol = function cleanUpProtocol(potential_protocol) {
29946 had_explicit_protocol = true;
29947 protocol = potential_protocol.toLowerCase();
29948 if (options.require_valid_protocol && options.protocols.indexOf(protocol) === -1) return false;
29949 return url.substring(protocol_match[0].length);
29950 };
29951 if (protocol_match) {
29952 var potential_protocol = protocol_match[1];
29953 var after_colon = url.substring(protocol_match[0].length);
29954 if (!(after_colon.slice(0, 2) === "//")) {
29955 var first_slash_position = after_colon.indexOf("/");
29956 var before_slash = first_slash_position === -1 ? after_colon : after_colon.substring(0, first_slash_position);
29957 var at_position = before_slash.indexOf("@");
29958 if (at_position !== -1) {
29959 var before_at = before_slash.substring(0, at_position);
29960 if (/^[a-zA-Z0-9\-_.%:]*$/.test(before_at)) {
29961 if (options.require_protocol) return false;
29962 } else {
29963 url = cleanUpProtocol(potential_protocol);
29964 if (url === false) return false;
29965 }
29966 } else if (/^[0-9]/.test(after_colon)) {
29967 if (options.require_protocol) return false;
29968 } else {
29969 url = cleanUpProtocol(potential_protocol);
29970 if (url === false) return false;
29971 }
29972 } else {
29973 url = cleanUpProtocol(potential_protocol);
29974 if (url === false) return false;
29975 }
29976 } else if (options.require_protocol) return false;
29977 if (url.slice(0, 2) === "//") {
29978 if (!had_explicit_protocol && !options.allow_protocol_relative_urls) return false;
29979 url = url.slice(2);
29980 }
29981 if (url === "") return false;
29982 split = url.split("/");
29983 url = split.shift();
29984 if (url === "" && !options.require_host) return true;
29985 split = url.split("@");
29986 if (split.length > 1) {
29987 if (options.disallow_auth) return false;
29988 if (split[0] === "") return false;
29989 auth = split.shift();
29990 if (auth.indexOf(":") >= 0 && auth.split(":").length > 2) return false;
29991 var _auth$split2 = _slicedToArray(auth.split(":"), 2);
29992 var user = _auth$split2[0];
29993 var password = _auth$split2[1];
29994 if (user === "" && password === "") return false;
29995 }
29996 hostname = split.join("@");
29997 port_str = null;
29998 ipv6 = null;
29999 var ipv6_match = hostname.match(wrapped_ipv6);
30000 if (ipv6_match) {
30001 host = "";
30002 ipv6 = ipv6_match[1];
30003 port_str = ipv6_match[2] || null;
30004 } else {
30005 split = hostname.split(":");
30006 host = split.shift();
30007 if (split.length) port_str = split.join(":");
30008 }
30009 if (port_str !== null && port_str.length > 0) {
30010 port = parseInt(port_str, 10);
30011 if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) return false;
30012 } else if (options.require_port) return false;
30013 if (options.host_whitelist) return (0, _checkHost.default)(host, options.host_whitelist);
30014 if (host === "" && !options.require_host) return true;
30015 if (!(0, _isIP.default)(host) && !(0, _isFQDN.default)(host, options) && (!ipv6 || !(0, _isIP.default)(ipv6, 6))) return false;
30016 host = host || ipv6;
30017 if (options.host_blacklist && (0, _checkHost.default)(host, options.host_blacklist)) return false;
30018 return true;
30019 }
30020 module.exports = exports.default;
30021 module.exports.default = exports.default;
30022 }));
30023
30024 //#endregion
30025 //#region modules/ai/assets/js/editor/pages/form-layout/index.js
30026 init_objectWithoutProperties();
30027 init_slicedToArray();
30028 init_extends();
30029 init_prompt_error_message();
30030 var import_isURL = /* @__PURE__ */ __toESM(require_isURL());
30031 init_voice_promotion_alert();
30032 var _excluded = ["children"];
30033 var DirectionalMinimizeDiagonalIcon = (0, _elementor_ui.withDirection)(MinimizeDiagonalIcon);
30034 var DirectionalExpandDiagonalIcon = (0, _elementor_ui.withDirection)(ExpandDiagonalIcon);
30035 /**
30036 * @typedef {Object} Attachment
30037 * @property {('json')} type - The type of the attachment, currently only `json` is supported.
30038 * @property {string} previewHTML - HTML content as a string, representing a preview.
30039 * @property {string} content - Actual content of the attachment as a string.
30040 * @property {string} label - Label for the attachment.
30041 */
30042 var RegenerateButton = function RegenerateButton(props) {
30043 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
30044 size: "small",
30045 color: "secondary",
30046 startIcon: /*#__PURE__*/ react.default.createElement(RefreshIcon, null)
30047 }, props), (0, _wordpress_i18n.__)("Regenerate", "elementor"));
30048 };
30049 var UseLayoutButton = function UseLayoutButton(props) {
30050 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
30051 size: "small",
30052 variant: "contained"
30053 }, props), (0, _wordpress_i18n.__)("Use Layout", "elementor"));
30054 };
30055 UseLayoutButton.propTypes = { sx: import_prop_types$12.default.object };
30056 var isRegenerateButtonDisabled = function isRegenerateButtonDisabled(screenshots, isLoading, isPromptFormActive) {
30057 if (isLoading || isPromptFormActive) return true;
30058 return screenshots.length >= 3 * 5;
30059 };
30060 var FormLayout = function FormLayout(_ref) {
30061 var _screenshots$selected;
30062 var _screenshots$2;
30063 var _ref$DialogHeaderProp = _ref.DialogHeaderProps;
30064 var DialogHeaderProps = _ref$DialogHeaderProp === void 0 ? {} : _ref$DialogHeaderProp;
30065 var _ref$DialogContentPro = _ref.DialogContentProps;
30066 var DialogContentProps = _ref$DialogContentPro === void 0 ? {} : _ref$DialogContentPro;
30067 var initialAttachments = _ref.attachments;
30068 var _useConfig = useConfig();
30069 var attachmentsTypes = _useConfig.attachmentsTypes;
30070 var onData = _useConfig.onData;
30071 var onInsert = _useConfig.onInsert;
30072 var onSelect = _useConfig.onSelect;
30073 var onClose = _useConfig.onClose;
30074 var onGenerate = _useConfig.onGenerate;
30075 var _useScreenshots = useScreenshots({ onData });
30076 var screenshots = _useScreenshots.screenshots;
30077 var generate = _useScreenshots.generate;
30078 var regenerate = _useScreenshots.regenerate;
30079 var isLoading = _useScreenshots.isLoading;
30080 var error = _useScreenshots.error;
30081 var abort = _useScreenshots.abort;
30082 var screenshotOutlineOffset = "2px";
30083 var _useSlider = useSlider({ slidesCount: screenshots.length });
30084 var currentPage = _useSlider.currentPage;
30085 var setCurrentPage = _useSlider.setCurrentPage;
30086 var pagesCount = _useSlider.pagesCount;
30087 var gapPercentage = _useSlider.gapPercentage;
30088 var slidesPerPage = _useSlider.slidesPerPage;
30089 var offsetXPercentage = _useSlider.offsetXPercentage;
30090 var slideWidthPercentage = _useSlider.slideWidthPercentage;
30091 var _useState2 = _slicedToArray((0, react.useState)(-1), 2);
30092 var selectedScreenshotIndex = _useState2[0];
30093 var setSelectedScreenshotIndex = _useState2[1];
30094 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
30095 var showUnsavedChangesAlert = _useState4[0];
30096 var setShowUnsavedChangesAlert = _useState4[1];
30097 var _useState6 = _slicedToArray((0, react.useState)(true), 2);
30098 var isPromptEditable = _useState6[0];
30099 var setIsPromptEditable = _useState6[1];
30100 var _useState8 = _slicedToArray((0, react.useState)([]), 2);
30101 var attachments = _useState8[0];
30102 var setAttachments = _useState8[1];
30103 var _useState0 = _slicedToArray((0, react.useState)(false), 2);
30104 var shouldRenderWebApp = _useState0[0];
30105 var setShouldRenderWebApp = _useState0[1];
30106 var _useState10 = _slicedToArray((0, react.useState)(false), 2);
30107 var isMinimized = _useState10[0];
30108 var setIsMinimized = _useState10[1];
30109 var lastRun = (0, react.useRef)(function() {});
30110 var promptInputRef = (0, react.useRef)(null);
30111 var selectedTemplate = (_screenshots$selected = screenshots[selectedScreenshotIndex]) === null || _screenshots$selected === void 0 ? void 0 : _screenshots$selected.template;
30112 var dialogContentChildren = DialogContentProps.children;
30113 var dialogContentProps = _objectWithoutProperties(DialogContentProps, _excluded);
30114 var shouldFallbackToEditPrompt = !!(error && 0 === screenshots.length);
30115 var isPromptFormActive = isPromptEditable || shouldFallbackToEditPrompt;
30116 var abortAndClose = function abortAndClose() {
30117 abort();
30118 onClose();
30119 };
30120 var onCloseIntent = function onCloseIntent() {
30121 if (promptInputRef.current.value.trim() !== "" || screenshots.length > 0) return setShowUnsavedChangesAlert(true);
30122 abortAndClose();
30123 };
30124 var handleGenerate = function handleGenerate(event, prompt) {
30125 event.preventDefault();
30126 if ("" === prompt.trim() && 0 === attachments.length) return;
30127 if ((0, import_isURL.default)(prompt)) {
30128 setShouldRenderWebApp(true);
30129 return;
30130 }
30131 onGenerate();
30132 lastRun.current = function() {
30133 setSelectedScreenshotIndex(-1);
30134 generate(prompt, attachments);
30135 };
30136 lastRun.current();
30137 setIsPromptEditable(false);
30138 setCurrentPage(1);
30139 };
30140 var handleRegenerate = function handleRegenerate() {
30141 lastRun.current = function() {
30142 regenerate(promptInputRef.current.value, attachments);
30143 setCurrentPage(pagesCount + 1);
30144 };
30145 lastRun.current();
30146 };
30147 var applyTemplate = function applyTemplate() {
30148 onInsert(selectedTemplate);
30149 screenshots[selectedScreenshotIndex].sendUsageData();
30150 abortAndClose();
30151 };
30152 var handleScreenshotClick = function handleScreenshotClick(index, template) {
30153 return function() {
30154 if (isPromptFormActive) return;
30155 setSelectedScreenshotIndex(index);
30156 onSelect(template);
30157 };
30158 };
30159 /**
30160 * @param {Attachment[]} items
30161 */
30162 var onAttach = function onAttach(items) {
30163 items.forEach(function(item) {
30164 if (!attachmentsTypes[item.type]) throw new Error("Invalid attachment type: ".concat(item.type));
30165 var typeConfig = attachmentsTypes[item.type];
30166 if (!item.previewHTML && typeConfig.previewGenerator) typeConfig.previewGenerator(item.content).then(function(html) {
30167 item.previewHTML = html;
30168 setAttachments(function(prev) {
30169 return prev.map(function(attachment) {
30170 if (attachment.content === item.content) return item;
30171 return attachment;
30172 });
30173 });
30174 });
30175 });
30176 setAttachments(items);
30177 setShouldRenderWebApp(false);
30178 setIsPromptEditable(true);
30179 };
30180 (0, react.useEffect)(function() {
30181 var _screenshots$;
30182 if ((_screenshots$ = screenshots[0]) === null || _screenshots$ === void 0 ? void 0 : _screenshots$.template) {
30183 onSelect(screenshots[0].template);
30184 setSelectedScreenshotIndex(0);
30185 }
30186 }, [(_screenshots$2 = screenshots[0]) === null || _screenshots$2 === void 0 ? void 0 : _screenshots$2.template]);
30187 (0, react.useEffect)(function() {
30188 if (initialAttachments !== null && initialAttachments !== void 0 && initialAttachments.length) onAttach(initialAttachments);
30189 }, []);
30190 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, {
30191 size: "small",
30192 "aria-label": "minimize",
30193 onClick: function onClick() {
30194 return setIsMinimized(function(prev) {
30195 return !prev;
30196 });
30197 }
30198 }, 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: {
30199 pt: 2,
30200 px: 2,
30201 pb: 0
30202 } }, dialogContentChildren), attachments.length > 0 && /*#__PURE__*/ react.default.createElement(PromptPowerNotice, null), error && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
30203 pt: 2,
30204 px: 2,
30205 pb: 0
30206 } }, /*#__PURE__*/ react.default.createElement(PromptErrorMessage, {
30207 error,
30208 onRetry: lastRun.current
30209 })), showUnsavedChangesAlert && /*#__PURE__*/ react.default.createElement(UnsavedChangesAlert, {
30210 open: showUnsavedChangesAlert,
30211 title: (0, _wordpress_i18n.__)("Leave Elementor AI?", "elementor"),
30212 text: (0, _wordpress_i18n.__)("Your progress will be deleted, and can't be recovered.", "elementor"),
30213 onClose: abortAndClose,
30214 onCancel: function onCancel() {
30215 return setShowUnsavedChangesAlert(false);
30216 }
30217 }), shouldRenderWebApp && /*#__PURE__*/ react.default.createElement(AttachDialog, {
30218 type: "url",
30219 url: promptInputRef.current.value,
30220 onAttach,
30221 onClose: function onClose() {
30222 setShouldRenderWebApp(false);
30223 }
30224 }), /*#__PURE__*/ react.default.createElement(PromptForm, {
30225 shouldResetPrompt: shouldRenderWebApp,
30226 ref: promptInputRef,
30227 isActive: isPromptFormActive,
30228 isLoading,
30229 showActions: screenshots.length > 0 || isLoading,
30230 attachmentsTypes,
30231 attachments,
30232 onAttach,
30233 onDetach: function onDetach(index) {
30234 setAttachments(function(prev) {
30235 var newAttachments = _toConsumableArray(prev);
30236 newAttachments.splice(index, 1);
30237 return newAttachments;
30238 });
30239 setIsPromptEditable(true);
30240 },
30241 onSubmit: handleGenerate,
30242 onBack: function onBack() {
30243 return setIsPromptEditable(false);
30244 },
30245 onEdit: function onEdit() {
30246 return setIsPromptEditable(true);
30247 }
30248 }), (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: {
30249 overflow: "hidden",
30250 p: .5
30251 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
30252 display: "flex",
30253 transition: "all 0.4s ease",
30254 gap: "".concat(gapPercentage, "%"),
30255 transform: "translateX(".concat(offsetXPercentage, "%)")
30256 } }, screenshots.map(function(_ref2, index) {
30257 var screenshot = _ref2.screenshot;
30258 var type = _ref2.type;
30259 var template = _ref2.template;
30260 var isError = _ref2.isError;
30261 var isPending = _ref2.isPending;
30262 return /*#__PURE__*/ react.default.createElement(Screenshot, {
30263 key: index,
30264 url: screenshot,
30265 type,
30266 disabled: isPromptFormActive,
30267 isPlaceholder: isError,
30268 isLoading: isPending,
30269 isSelected: selectedScreenshotIndex === index,
30270 onClick: handleScreenshotClick(index, template),
30271 outlineOffset: screenshotOutlineOffset,
30272 sx: { flex: "0 0 ".concat(slideWidthPercentage, "%") }
30273 });
30274 }))), /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, { introductionKey: "ai-context-layout-promotion" })), screenshots.length > 0 && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
30275 sx: {
30276 pt: 0,
30277 px: 2,
30278 pb: 2
30279 },
30280 display: "grid",
30281 gridTemplateColumns: "repeat(3, 1fr)",
30282 justifyItems: "center"
30283 }, /*#__PURE__*/ react.default.createElement(RegenerateButton, {
30284 onClick: handleRegenerate,
30285 disabled: isRegenerateButtonDisabled(screenshots, isLoading, isPromptFormActive),
30286 sx: { justifySelf: "start" }
30287 }), screenshots.length > slidesPerPage && /*#__PURE__*/ react.default.createElement(_elementor_ui.Pagination, {
30288 page: currentPage,
30289 count: pagesCount,
30290 disabled: isPromptFormActive,
30291 onChange: function onChange(_, page) {
30292 return setCurrentPage(page);
30293 }
30294 }), /*#__PURE__*/ react.default.createElement(UseLayoutButton, {
30295 onClick: applyTemplate,
30296 disabled: isPromptFormActive || -1 === selectedScreenshotIndex,
30297 sx: {
30298 justifySelf: "end",
30299 gridColumn: 3
30300 }
30301 }))))));
30302 };
30303 FormLayout.propTypes = {
30304 DialogHeaderProps: import_prop_types$12.default.object,
30305 DialogContentProps: import_prop_types$12.default.object,
30306 attachments: import_prop_types$12.default.arrayOf(AttachmentPropType)
30307 };
30308
30309 //#endregion
30310 //#region modules/ai/assets/js/editor/layout-content.js
30311 init_slicedToArray();
30312 init_loader();
30313 init_requests_ids();
30314 var LayoutContent = function LayoutContent(props) {
30315 var _useUserInfo = useUserInfo();
30316 var isLoading = _useUserInfo.isLoading;
30317 var isConnected = _useUserInfo.isConnected;
30318 var isGetStarted = _useUserInfo.isGetStarted;
30319 var connectUrl = _useUserInfo.connectUrl;
30320 var fetchData = _useUserInfo.fetchData;
30321 var hasSubscription = _useUserInfo.hasSubscription;
30322 var initialUsagePercentage = _useUserInfo.usagePercentage;
30323 var _useConfig = useConfig();
30324 var onClose = _useConfig.onClose;
30325 var onConnect = _useConfig.onConnect;
30326 var _useRequestIds = useRequestIds();
30327 var updateUsagePercentage = _useRequestIds.updateUsagePercentage;
30328 var usagePercentage = _useRequestIds.usagePercentage;
30329 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
30330 var isInitUsageDone = _useState2[0];
30331 var setIsInitUsageDone = _useState2[1];
30332 (0, react.useEffect)(function() {
30333 if (!isInitUsageDone && !isLoading && (initialUsagePercentage || 0 === initialUsagePercentage)) {
30334 updateUsagePercentage(initialUsagePercentage);
30335 setIsInitUsageDone(true);
30336 }
30337 }, [
30338 isLoading,
30339 initialUsagePercentage,
30340 isInitUsageDone,
30341 updateUsagePercentage
30342 ]);
30343 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 } } })));
30344 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, {
30345 connectUrl,
30346 onSuccess: function onSuccess(data) {
30347 onConnect(data);
30348 fetchData();
30349 }
30350 })));
30351 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 })));
30352 var showUpgradeChip = !hasSubscription || 80 <= usagePercentage;
30353 return /*#__PURE__*/ react.default.createElement(FormLayout, {
30354 attachments: props.attachments,
30355 DialogHeaderProps: { children: showUpgradeChip && /*#__PURE__*/ react.default.createElement(UpgradeChip, {
30356 hasSubscription,
30357 usagePercentage
30358 }) }
30359 });
30360 };
30361 LayoutContent.propTypes = { attachments: import_prop_types$12.default.arrayOf(AttachmentPropType) };
30362
30363 //#endregion
30364 //#region modules/ai/assets/js/editor/layout-app.js
30365 init_requests_ids();
30366 var LayoutApp = function LayoutApp(props) {
30367 return /*#__PURE__*/ react.default.createElement(RemoteConfigProvider, { onError: props.onClose }, /*#__PURE__*/ react.default.createElement(RequestIdsProvider, null, /*#__PURE__*/ react.default.createElement(ConfigProvider, {
30368 mode: props.mode,
30369 attachmentsTypes: props.attachmentsTypes,
30370 onClose: props.onClose,
30371 onConnect: props.onConnect,
30372 onData: props.onData,
30373 onInsert: props.onInsert,
30374 onSelect: props.onSelect,
30375 onGenerate: props.onGenerate,
30376 currentContext: props.currentContext,
30377 hasPro: props.hasPro
30378 }, /*#__PURE__*/ react.default.createElement(LayoutContent, { attachments: props.attachments }))));
30379 };
30380 LayoutApp.propTypes = {
30381 mode: import_prop_types$12.default.oneOf(LAYOUT_APP_MODES).isRequired,
30382 attachmentsTypes: AttachmentsTypesPropType,
30383 attachments: import_prop_types$12.default.arrayOf(AttachmentPropType),
30384 onClose: import_prop_types$12.default.func.isRequired,
30385 onConnect: import_prop_types$12.default.func.isRequired,
30386 onData: import_prop_types$12.default.func.isRequired,
30387 onInsert: import_prop_types$12.default.func.isRequired,
30388 onSelect: import_prop_types$12.default.func.isRequired,
30389 onGenerate: import_prop_types$12.default.func.isRequired,
30390 currentContext: import_prop_types$12.default.object,
30391 hasPro: import_prop_types$12.default.bool
30392 };
30393
30394 //#endregion
30395 //#region modules/ai/assets/js/editor/utils/screenshot.js
30396 init_requests_ids();
30397
30398 //#endregion
30399 //#region modules/ai/assets/js/editor/layout-app-wrapper.js
30400 var LayoutAppWrapper = function LayoutAppWrapper(props) {
30401 return /*#__PURE__*/ react.default.createElement(_elementor_ui.DirectionProvider, { rtl: props.isRTL }, /*#__PURE__*/ react.default.createElement(_elementor_ui.ThemeProvider, { colorScheme: props.colorScheme }, props.children));
30402 };
30403 LayoutAppWrapper.propTypes = {
30404 children: import_prop_types$12.default.node,
30405 isRTL: import_prop_types$12.default.bool,
30406 colorScheme: import_prop_types$12.default.oneOf([
30407 "auto",
30408 "light",
30409 "dark"
30410 ])
30411 };
30412
30413 //#endregion
30414 //#region modules/ai/assets/js/editor/utils/editor-integration.js
30415 init_requests_ids();
30416 var onConnect = function onConnect(data) {
30417 elementorCommon.config.library_connect.is_connected = true;
30418 elementorCommon.config.library_connect.current_access_level = data.kits_access_level || data.access_level || 0;
30419 elementorCommon.config.library_connect.current_access_tier = data.access_tier;
30420 elementorCommon.config.library_connect.plan_type = data.plan_type;
30421 };
30422 var VARIATIONS_PROMPTS = [
30423 { text: (0, _wordpress_i18n.__)("Minimalist design with bold typography about", "elementor") },
30424 { text: (0, _wordpress_i18n.__)("Elegant style with serif fonts discussing", "elementor") },
30425 { text: (0, _wordpress_i18n.__)("Retro vibe with muted colors and classic fonts about", "elementor") },
30426 { text: (0, _wordpress_i18n.__)("Futuristic design with neon accents about", "elementor") },
30427 { text: (0, _wordpress_i18n.__)("Professional look with clean lines for", "elementor") },
30428 { text: (0, _wordpress_i18n.__)("Earthy tones and organic shapes featuring", "elementor") },
30429 { text: (0, _wordpress_i18n.__)("Luxurious theme with rich colors discussing", "elementor") },
30430 { text: (0, _wordpress_i18n.__)("Tech-inspired style with modern fonts about", "elementor") },
30431 { text: (0, _wordpress_i18n.__)("Warm hues with comforting visuals about", "elementor") }
30432 ];
30433 var WEB_BASED_PROMPTS = [
30434 { text: (0, _wordpress_i18n.__)("Change the content to be about [topic]", "elementor") },
30435 { text: (0, _wordpress_i18n.__)("Generate lorem ipsum placeholder text for all paragraphs", "elementor") },
30436 { text: (0, _wordpress_i18n.__)("Revise the content to focus on [topic] and then translate it into Spanish", "elementor") },
30437 { text: (0, _wordpress_i18n.__)("Shift the focus of the content to [topic] in order to showcase our company's mission and values", "elementor") },
30438 { text: (0, _wordpress_i18n.__)("Alter the content to provide helpful tips related to [topic]", "elementor") },
30439 { text: (0, _wordpress_i18n.__)("Adjust the content to include FAQs and answers for common inquiries about [topic]", "elementor") }
30440 ];
30441 var PROMPT_PLACEHOLDER = (0, _wordpress_i18n.__)("Press '/' for suggestions or describe the changes you want to apply (optional)...", "elementor");
30442
30443 //#endregion
30444 //#region modules/ai/assets/js/editor/app.js
30445 init_requests_ids();
30446 var App = function App(props) {
30447 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, {
30448 type: props.type,
30449 controlType: props.controlType,
30450 onClose: props.onClose,
30451 onConnect,
30452 getControlValue: props.getControlValue,
30453 setControlValue: props.setControlValue,
30454 additionalOptions: props.additionalOptions
30455 }))));
30456 };
30457 App.propTypes = {
30458 colorScheme: import_prop_types$12.default.oneOf([
30459 "auto",
30460 "light",
30461 "dark"
30462 ]),
30463 type: import_prop_types$12.default.string,
30464 controlType: import_prop_types$12.default.string,
30465 onClose: import_prop_types$12.default.func,
30466 getControlValue: import_prop_types$12.default.func,
30467 setControlValue: import_prop_types$12.default.func,
30468 additionalOptions: import_prop_types$12.default.object,
30469 isRTL: import_prop_types$12.default.bool
30470 };
30471
30472 //#endregion
30473 //#region modules/ai/assets/js/editor/ai-excerpt.js
30474 init_asyncToGenerator();
30475 init_slicedToArray();
30476 init_requests_ids();
30477 var AIExcerpt = function AIExcerpt(_ref) {
30478 var onClose = _ref.onClose;
30479 var currExcerpt = _ref.currExcerpt;
30480 var updateExcerpt = _ref.updateExcerpt;
30481 var postTextualContent = _ref.postTextualContent;
30482 var _useUserInfo = useUserInfo(true);
30483 var isLoadingUserInfo = _useUserInfo.isLoading;
30484 var isConnected = _useUserInfo.isConnected;
30485 var isGetStarted = _useUserInfo.isGetStarted;
30486 var connectUrl = _useUserInfo.connectUrl;
30487 var fetchData = _useUserInfo.fetchData;
30488 var hasSubscription = _useUserInfo.hasSubscription;
30489 var credits = _useUserInfo.credits;
30490 var initialUsagePercentage = _useUserInfo.usagePercentage;
30491 var _useExcerptPrompt = useExcerptPrompt({
30492 result: currExcerpt,
30493 credits
30494 });
30495 var newExcerpt = _useExcerptPrompt.data;
30496 var error = _useExcerptPrompt.error;
30497 var send = _useExcerptPrompt.send;
30498 var _useRequestIds = useRequestIds();
30499 var updateUsagePercentage = _useRequestIds.updateUsagePercentage;
30500 var usagePercentage = _useRequestIds.usagePercentage;
30501 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
30502 var isInitUsageDone = _useState2[0];
30503 var setIsInitUsageDone = _useState2[1];
30504 (0, react.useEffect)(function() {
30505 if (!isInitUsageDone && !isLoadingUserInfo && (initialUsagePercentage || 0 === initialUsagePercentage)) {
30506 updateUsagePercentage(initialUsagePercentage);
30507 setIsInitUsageDone(true);
30508 }
30509 }, [
30510 isLoadingUserInfo,
30511 initialUsagePercentage,
30512 isInitUsageDone,
30513 updateUsagePercentage
30514 ]);
30515 var generateExcerptOnce = (0, react.useRef)(false);
30516 var _useState4 = _slicedToArray((0, react.useState)(true), 2);
30517 var isLoadingCombined = _useState4[0];
30518 var setIsLoadingCombined = _useState4[1];
30519 var initHook = function initHook() {
30520 return {
30521 isLoading: isLoadingCombined,
30522 isConnected,
30523 isGetStarted,
30524 connectUrl,
30525 fetchData,
30526 hasSubscription,
30527 credits,
30528 usagePercentage
30529 };
30530 };
30531 var fetchAiExcerpt = (0, react.useCallback)(/*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee() {
30532 return import_regenerator$3.default.wrap(function(_context) {
30533 while (1) switch (_context.prev = _context.next) {
30534 case 0:
30535 if (!(send && postTextualContent)) {
30536 _context.next = 1;
30537 break;
30538 }
30539 generateExcerptOnce.current = true;
30540 _context.next = 1;
30541 return send({ content: postTextualContent }).finally(function() {
30542 setIsLoadingCombined(false);
30543 });
30544 case 1:
30545 case "end": return _context.stop();
30546 }
30547 }, _callee);
30548 })), [postTextualContent, send]);
30549 (0, react.useEffect)(function() {
30550 if (!generateExcerptOnce.current && isConnected && isGetStarted) fetchAiExcerpt();
30551 }, [
30552 fetchAiExcerpt,
30553 isConnected,
30554 isGetStarted
30555 ]);
30556 (0, react.useEffect)(function() {
30557 if (!isLoadingUserInfo && (!isConnected || !isGetStarted)) setIsLoadingCombined(false);
30558 }, [
30559 isConnected,
30560 isGetStarted,
30561 isLoadingUserInfo
30562 ]);
30563 var isRTL = elementorCommon.config.isRTL;
30564 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(App, {
30565 type: "text",
30566 getControlValue: function getControlValue() {
30567 return newExcerpt.result ? newExcerpt : currExcerpt;
30568 },
30569 setControlValue: function setControlValue(value) {
30570 return updateExcerpt(value);
30571 },
30572 onClose,
30573 isRTL,
30574 additionalOptions: {
30575 loadingTitle: (0, _wordpress_i18n.__)("Analyzing your post to craft an excerpt...", "elementor"),
30576 useCustomInit: initHook,
30577 initError: error,
30578 initRetry: fetchAiExcerpt
30579 }
30580 }));
30581 };
30582 AIExcerpt.propTypes = {
30583 onClose: import_prop_types$12.default.func.isRequired,
30584 updateExcerpt: import_prop_types$12.default.func.isRequired,
30585 currExcerpt: import_prop_types$12.default.string.isRequired,
30586 postTextualContent: import_prop_types$12.default.string.isRequired
30587 };
30588
30589 //#endregion
30590 //#region modules/ai/assets/js/gutenberg/post-text-utils.js
30591 init_slicedToArray();
30592 var useSelect$2 = wp.data.useSelect;
30593 var useGutenbergPostText = function useGutenbergPostText() {
30594 var postContent = useSelect$2(function(select) {
30595 var _select;
30596 return (_select = select("core/editor")) === null || _select === void 0 ? void 0 : _select.getEditedPostContent();
30597 }, []);
30598 var title = useSelect$2(function(select) {
30599 var _select2;
30600 return (_select2 = select("core/editor")) === null || _select2 === void 0 ? void 0 : _select2.getEditedPostAttribute("title");
30601 }, []);
30602 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
30603 var postTextualContent = _useState2[0];
30604 var setPostTextualContent = _useState2[1];
30605 (0, react.useEffect)(function() {
30606 var tempDiv = document.createElement("div");
30607 tempDiv.innerHTML = postContent;
30608 var extractedText = [title];
30609 function extractTextRecursively(element, extractedTextRec) {
30610 element.childNodes.forEach(function(node) {
30611 if (node.nodeType === Node.TEXT_NODE) {
30612 var text = node.textContent.trim();
30613 if (text) extractedTextRec.push(text);
30614 } else if (node.nodeType === Node.ELEMENT_NODE) extractTextRecursively(node, extractedTextRec);
30615 });
30616 }
30617 extractTextRecursively(tempDiv, extractedText);
30618 setPostTextualContent(extractedText.join("\n").trim());
30619 }, [postContent, title]);
30620 return postTextualContent;
30621 };
30622
30623 //#endregion
30624 //#region modules/ai/assets/js/gutenberg/excerpt.js
30625 init_slicedToArray();
30626 init_requests_ids();
30627 var _wp$data$1 = wp.data;
30628 var useSelect$1 = _wp$data$1.useSelect;
30629 var useDispatch$2 = _wp$data$1.useDispatch;
30630 var GenerateExcerptWithAI = function GenerateExcerptWithAI() {
30631 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
30632 var isOpen = _useState2[0];
30633 var setIsOpen = _useState2[1];
30634 var currExcerpt = useSelect$1(function(select) {
30635 var _select;
30636 return (_select = select("core/editor")) === null || _select === void 0 ? void 0 : _select.getEditedPostAttribute("excerpt");
30637 }, []);
30638 var editPost = useDispatch$2("core/editor").editPost;
30639 var postTextualContent = useGutenbergPostText();
30640 return /*#__PURE__*/ react.default.createElement("div", { style: { paddingTop: "0.6em" } }, /*#__PURE__*/ react.default.createElement(RequestIdsProvider, null, /*#__PURE__*/ react.default.createElement(Icon, { className: "eicon-ai" }), /*#__PURE__*/ react.default.createElement(AiLink, { onClick: function handleButtonClick() {
30641 setIsOpen(true);
30642 } }, (0, _wordpress_i18n.__)("Generate with Elementor AI", "elementor")), isOpen && /*#__PURE__*/ react.default.createElement(AIExcerpt, {
30643 onClose: function handleClose() {
30644 setIsOpen(false);
30645 },
30646 currExcerpt,
30647 updateExcerpt: function updateExcerpt(res) {
30648 return editPost({ excerpt: res });
30649 },
30650 postTextualContent
30651 })));
30652 };
30653
30654 //#endregion
30655 //#region modules/ai/assets/js/media-library/components.js
30656 var AIMediaGenerateApp = function AIMediaGenerateApp(_ref) {
30657 var onClose = _ref.onClose;
30658 var setControlValue = _ref.setControlValue;
30659 var _ref$predefinedPrompt = _ref.predefinedPrompt;
30660 var predefinedPrompt = _ref$predefinedPrompt === void 0 ? "" : _ref$predefinedPrompt;
30661 var _ref$textToImageHook = _ref.textToImageHook;
30662 var textToImageHook = _ref$textToImageHook === void 0 ? null : _ref$textToImageHook;
30663 var _ref$initialSettings = _ref.initialSettings;
30664 var initialSettings = _ref$initialSettings === void 0 ? {} : _ref$initialSettings;
30665 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(App, {
30666 type: "media",
30667 getControlValue: function getControlValue() {},
30668 setControlValue,
30669 onClose,
30670 isRTL: elementorCommon.config.isRTL,
30671 additionalOptions: {
30672 defaultImageType: Object.keys(IMAGE_PROMPT_CATEGORIES)[1],
30673 textToImageHook,
30674 predefinedPrompt,
30675 initialSettings
30676 }
30677 }));
30678 };
30679 AIMediaGenerateApp.propTypes = {
30680 onClose: import_prop_types$12.default.func.isRequired,
30681 predefinedPrompt: import_prop_types$12.default.string,
30682 textToImageHook: import_prop_types$12.default.func,
30683 setControlValue: import_prop_types$12.default.func.isRequired,
30684 initialSettings: import_prop_types$12.default.object
30685 };
30686 var AIMediaEditApp = function AIMediaEditApp(_ref2) {
30687 var onClose = _ref2.onClose;
30688 var imageId = _ref2.imageId;
30689 var image = wp.media.attachment(imageId);
30690 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(App, {
30691 type: "media",
30692 getControlValue: function getControlValue() {
30693 return image.attributes;
30694 },
30695 setControlValue: function setControlValue() {},
30696 onClose,
30697 isRTL: elementorCommon.config.isRTL,
30698 additionalOptions: { location: LOCATIONS.IMAGE_TOOLS }
30699 }));
30700 };
30701 AIMediaEditApp.propTypes = {
30702 onClose: import_prop_types$12.default.func.isRequired,
30703 imageId: import_prop_types$12.default.string
30704 };
30705
30706 //#endregion
30707 //#region modules/ai/assets/js/editor/hooks/use-featured-image-prompt.js
30708 init_asyncToGenerator();
30709 init_api();
30710 var useFeaturedImagePrompt = function useFeaturedImagePrompt(initialValue) {
30711 return useImagePrompt(/*#__PURE__*/ function() {
30712 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee(payload) {
30713 return import_regenerator$3.default.wrap(function(_context) {
30714 while (1) switch (_context.prev = _context.next) {
30715 case 0: return _context.abrupt("return", getFeaturedImage(payload));
30716 case 1:
30717 case "end": return _context.stop();
30718 }
30719 }, _callee);
30720 }));
30721 return function(_x) {
30722 return _ref.apply(this, arguments);
30723 };
30724 }(), initialValue);
30725 };
30726
30727 //#endregion
30728 //#region modules/ai/assets/js/gutenberg/featured-image.js
30729 init_slicedToArray();
30730 init_requests_ids();
30731 var useDispatch$1 = wp.data.useDispatch;
30732 var GenerateFeaturedImageWithAI = function GenerateFeaturedImageWithAI() {
30733 var FEATURED_IMAGE_RATIO = "4:3";
30734 var editPost = useDispatch$1("core/editor").editPost;
30735 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
30736 var isOpen = _useState2[0];
30737 var setIsOpen = _useState2[1];
30738 var handleButtonClick = function handleButtonClick() {
30739 setIsOpen(true);
30740 };
30741 var handleClose = function handleClose() {
30742 setIsOpen(false);
30743 };
30744 var postTextualContent = useGutenbergPostText();
30745 return /*#__PURE__*/ react.default.createElement("div", { style: { paddingTop: "0.6em" } }, /*#__PURE__*/ react.default.createElement(RequestIdsProvider, null, /*#__PURE__*/ react.default.createElement(Icon, { className: "eicon-ai" }), /*#__PURE__*/ react.default.createElement(AiLink, { onClick: handleButtonClick }, (0, _wordpress_i18n.__)("Generate with Elementor AI", "elementor")), isOpen && /*#__PURE__*/ react.default.createElement(AIMediaGenerateApp, {
30746 onClose: handleClose,
30747 predefinedPrompt: postTextualContent,
30748 textToImageHook: useFeaturedImagePrompt,
30749 setControlValue: function setControlValue(value) {
30750 editPost({ featured_media: value === null || value === void 0 ? void 0 : value.id });
30751 },
30752 initialSettings: { aspectRatio: FEATURED_IMAGE_RATIO }
30753 })));
30754 };
30755
30756 //#endregion
30757 //#region modules/ai/assets/js/gutenberg/text-with-ai.js
30758 init_slicedToArray();
30759 init_defineProperty();
30760 init_requests_ids();
30761 function ownKeys(e, r) {
30762 var t = Object.keys(e);
30763 if (Object.getOwnPropertySymbols) {
30764 var o = Object.getOwnPropertySymbols(e);
30765 r && (o = o.filter(function(r) {
30766 return Object.getOwnPropertyDescriptor(e, r).enumerable;
30767 })), t.push.apply(t, o);
30768 }
30769 return t;
30770 }
30771 function _objectSpread(e) {
30772 for (var r = 1; r < arguments.length; r++) {
30773 var t = null != arguments[r] ? arguments[r] : {};
30774 r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
30775 _defineProperty(e, r, t[r]);
30776 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
30777 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
30778 });
30779 }
30780 return e;
30781 }
30782 var _wp$data = wp.data;
30783 var useDispatch = _wp$data.useDispatch;
30784 var useSelect = _wp$data.useSelect;
30785 var createBlock = wp.blocks.createBlock;
30786 var AiText = function AiText(_ref) {
30787 var onClose = _ref.onClose;
30788 var blockName = _ref.blockName;
30789 var _ref$initialValue = _ref.initialValue;
30790 var initialValue = _ref$initialValue === void 0 ? "" : _ref$initialValue;
30791 var _ref$blockClientId = _ref.blockClientId;
30792 var blockClientId = _ref$blockClientId === void 0 ? "" : _ref$blockClientId;
30793 var _useDispatch = useDispatch("core/block-editor");
30794 var replaceBlocks = _useDispatch.replaceBlocks;
30795 var insertBlocks = _useDispatch.insertBlocks;
30796 var insertTextIntoParagraph = function insertTextIntoParagraph(text) {
30797 if (paragraphBlock) {
30798 var updatedBlock = _objectSpread(_objectSpread({}, paragraphBlock), {}, { attributes: _objectSpread(_objectSpread({}, paragraphBlock.attributes), {}, { content: text }) });
30799 replaceBlocks(paragraphBlock.clientId, updatedBlock);
30800 } else insertBlocks(createBlock(blockName, { content: text }));
30801 };
30802 var isRTL = elementorCommon.config.isRTL;
30803 var paragraphBlock = useSelect(function() {
30804 var _wp$data$select;
30805 var currentBlocks = (_wp$data$select = wp.data.select("core/block-editor")) === null || _wp$data$select === void 0 ? void 0 : _wp$data$select.getBlocks();
30806 return {
30807 blocks: currentBlocks,
30808 paragraphBlock: currentBlocks.find(function(block) {
30809 return blockName === block.name && blockClientId === block.clientId;
30810 })
30811 };
30812 }, []).paragraphBlock;
30813 var appType = "core/paragraph" === blockName ? "textarea" : "text";
30814 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(App, {
30815 type: appType,
30816 getControlValue: function getControlValue() {
30817 return initialValue;
30818 },
30819 setControlValue: function setControlValue(value) {
30820 insertTextIntoParagraph(value);
30821 },
30822 onClose,
30823 isRTL,
30824 additionalOptions: { hideAiContext: true }
30825 }));
30826 };
30827 AiText.propTypes = {
30828 onClose: import_prop_types$12.default.func.isRequired,
30829 blockName: import_prop_types$12.default.string.isRequired,
30830 initialValue: import_prop_types$12.default.string,
30831 blockClientId: import_prop_types$12.default.string
30832 };
30833 var GenerateTextWithAi = function GenerateTextWithAi(_ref2) {
30834 var blockName = _ref2.blockName;
30835 var blockClientId = _ref2.blockClientId;
30836 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
30837 var isOpen = _useState2[0];
30838 var setIsOpen = _useState2[1];
30839 return /*#__PURE__*/ react.default.createElement("div", { style: { paddingTop: "0.6em" } }, /*#__PURE__*/ react.default.createElement(RequestIdsProvider, null, /*#__PURE__*/ react.default.createElement(Icon, { className: "eicon-ai" }), /*#__PURE__*/ react.default.createElement(AiLink, { onClick: function handleButtonClick() {
30840 setIsOpen(true);
30841 } }, (0, _wordpress_i18n.__)("Generate with Elementor AI", "elementor")), isOpen && /*#__PURE__*/ react.default.createElement(AiText, {
30842 onClose: function handleClose() {
30843 setIsOpen(false);
30844 },
30845 blockName,
30846 blockClientId
30847 })));
30848 };
30849 GenerateTextWithAi.propTypes = {
30850 blockName: import_prop_types$12.default.string.isRequired,
30851 blockClientId: import_prop_types$12.default.string.isRequired
30852 };
30853
30854 //#endregion
30855 //#region modules/ai/assets/js/gutenberg/edit-text-with-ai.js
30856 init_slicedToArray();
30857 var ToolbarButton = wp.components.ToolbarButton;
30858 var BlockControls = wp.blockEditor.BlockControls;
30859 var EditTextWithAi = function EditTextWithAi(props) {
30860 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
30861 var shouldRenderAiApp = _useState2[0];
30862 var setShouldRenderAiApp = _useState2[1];
30863 var BlockEdit = props.blockEdit;
30864 if (!["core/paragraph", "core/heading"].includes(props.name)) return /*#__PURE__*/ react.default.createElement(BlockEdit, props);
30865 if (shouldRenderAiApp) return /*#__PURE__*/ react.default.createElement(AiText, {
30866 onClose: function onClose() {
30867 return setShouldRenderAiApp(false);
30868 },
30869 blockName: props.name,
30870 initialValue: props.attributes.content ? String(props.attributes.content) : "",
30871 blockClientId: props.clientId
30872 });
30873 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(BlockControls, null, /*#__PURE__*/ react.default.createElement(ToolbarButton, {
30874 icon: /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { color: "secondary" }),
30875 label: (0, _wordpress_i18n.__)("Edit with Elementor AI", "elementor"),
30876 onClick: function onClick() {
30877 return setShouldRenderAiApp(true);
30878 }
30879 })), /*#__PURE__*/ react.default.createElement(BlockEdit, props));
30880 };
30881 EditTextWithAi.propTypes = {
30882 name: import_prop_types$12.default.string,
30883 blockEdit: import_prop_types$12.default.func,
30884 attributes: import_prop_types$12.default.object,
30885 clientId: import_prop_types$12.default.string
30886 };
30887
30888 //#endregion
30889 //#region modules/ai/assets/js/gutenberg/index.js
30890 init_extends();
30891 init_requests_ids();
30892 function _createForOfIteratorHelper(r, e) {
30893 var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
30894 if (!t) {
30895 if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
30896 t && (r = t);
30897 var _n = 0;
30898 var F = function F() {};
30899 return {
30900 s: F,
30901 n: function n() {
30902 return _n >= r.length ? { done: !0 } : {
30903 done: !1,
30904 value: r[_n++]
30905 };
30906 },
30907 e: function e(r) {
30908 throw r;
30909 },
30910 f: F
30911 };
30912 }
30913 throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
30914 }
30915 var o;
30916 var a = !0;
30917 var u = !1;
30918 return {
30919 s: function s() {
30920 t = t.call(r);
30921 },
30922 n: function n() {
30923 var r = t.next();
30924 return a = r.done, r;
30925 },
30926 e: function e(r) {
30927 u = !0, o = r;
30928 },
30929 f: function f() {
30930 try {
30931 a || null == t.return || t.return();
30932 } finally {
30933 if (u) throw o;
30934 }
30935 }
30936 };
30937 }
30938 function _unsupportedIterableToArray(r, a) {
30939 if (r) {
30940 if ("string" == typeof r) return _arrayLikeToArray(r, a);
30941 var t = {}.toString.call(r).slice(8, -1);
30942 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;
30943 }
30944 }
30945 function _arrayLikeToArray(r, a) {
30946 (null == a || a > r.length) && (a = r.length);
30947 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
30948 return n;
30949 }
30950 (function() {
30951 "use strict";
30952 window.EDITOR_SESSION_ID = getUniqueId("wp-gutenberg-session");
30953 wp.domReady(function() {
30954 var addGenerateExcerptWithAI = function addGenerateExcerptWithAI() {
30955 var excerptPanel = document.querySelector(".editor-post-excerpt");
30956 if (excerptPanel && !document.querySelector(".e-excerpt-ai")) {
30957 var _elementorCommon;
30958 var rootElement = document.createElement("div");
30959 rootElement.classList.add("e-excerpt-ai");
30960 excerptPanel.appendChild(rootElement);
30961 var urlSearchParams = new URLSearchParams(window.location.search);
30962 (_elementorCommon = elementorCommon) === null || _elementorCommon === void 0 || (_elementorCommon = _elementorCommon.ajax) === null || _elementorCommon === void 0 || _elementorCommon.addRequestConstant("editor_post_id", urlSearchParams === null || urlSearchParams === void 0 ? void 0 : urlSearchParams.get("post"));
30963 (0, import_client.createRoot)(rootElement).render(/*#__PURE__*/ react.default.createElement(GenerateExcerptWithAI, null));
30964 }
30965 };
30966 var addGenerateFeaturedImageWithAI = function addGenerateFeaturedImageWithAI() {
30967 var featuredImagePanel = document.querySelector(".editor-post-featured-image");
30968 if (featuredImagePanel && !document.querySelector(".e-featured-image-ai")) {
30969 var _elementorCommon2;
30970 var rootElement = document.createElement("div");
30971 rootElement.classList.add("e-featured-image-ai");
30972 featuredImagePanel.appendChild(rootElement);
30973 var postId = wp.data.select("core/editor").getCurrentPostId();
30974 (_elementorCommon2 = elementorCommon) === null || _elementorCommon2 === void 0 || (_elementorCommon2 = _elementorCommon2.ajax) === null || _elementorCommon2 === void 0 || _elementorCommon2.addRequestConstant("editor_post_id", postId);
30975 (0, import_client.createRoot)(rootElement).render(/*#__PURE__*/ react.default.createElement(GenerateFeaturedImageWithAI, null));
30976 }
30977 };
30978 var addTextWithAI = function addTextWithAI(blockName, blockClientId) {
30979 var textPanel = document.querySelector(".block-editor-block-card__description, .block-editor-block-card__content");
30980 if (textPanel && !document.querySelector(".e-text-ai[data-client-id=\"".concat(blockClientId, "\"]"))) {
30981 removeAiIndicator();
30982 var rootElement = document.createElement("div");
30983 rootElement.classList.add("e-text-ai");
30984 rootElement.setAttribute("data-client-id", blockClientId);
30985 textPanel.appendChild(rootElement);
30986 (0, import_client.createRoot)(rootElement).render(/*#__PURE__*/ react.default.createElement(GenerateTextWithAi, {
30987 blockName,
30988 blockClientId
30989 }));
30990 }
30991 };
30992 var removeAiIndicator = function removeAiIndicator() {
30993 var textPanel = document.querySelector(".e-text-ai");
30994 if (textPanel) textPanel.remove();
30995 };
30996 var addAiIndicator = function addAiIndicator(panelName, functionAddAi) {
30997 var _wp$data$select;
30998 if ((_wp$data$select = wp.data.select("core/edit-post")) === null || _wp$data$select === void 0 ? void 0 : _wp$data$select.isEditorPanelEnabled(panelName)) setTimeout(function() {
30999 functionAddAi();
31000 }, 1);
31001 };
31002 var addAiIndicatorToTextBlock = function addAiIndicatorToTextBlock(blockNames) {
31003 var _wp$data$select2;
31004 var selectedBlock = (_wp$data$select2 = wp.data.select("core/block-editor")) === null || _wp$data$select2 === void 0 ? void 0 : _wp$data$select2.getSelectedBlock();
31005 if (selectedBlock && blockNames.some(function(name) {
31006 return selectedBlock.name.includes(name);
31007 })) addTextWithAI(selectedBlock.name, selectedBlock.clientId);
31008 else removeAiIndicator();
31009 };
31010 wp.data.subscribe(function() {
31011 addAiIndicator("post-excerpt", addGenerateExcerptWithAI);
31012 addAiIndicator("featured-image", addGenerateFeaturedImageWithAI);
31013 addAiIndicatorToTextBlock(["paragraph", "heading"]);
31014 });
31015 var observer = new MutationObserver(function(mutationsList) {
31016 var _iterator = _createForOfIteratorHelper(mutationsList);
31017 var _step;
31018 try {
31019 for (_iterator.s(); !(_step = _iterator.n()).done;) if ("childList" === _step.value.type) {
31020 if (document.querySelector(".editor-post-excerpt")) addGenerateExcerptWithAI();
31021 }
31022 } catch (err) {
31023 _iterator.e(err);
31024 } finally {
31025 _iterator.f();
31026 }
31027 });
31028 observer.observe(document.body, {
31029 childList: true,
31030 subtree: true
31031 });
31032 window.addEventListener("beforeunload", function() {
31033 observer.disconnect();
31034 });
31035 });
31036 })(jQuery);
31037 (function(wp) {
31038 var addFilter = wp.hooks.addFilter;
31039 addFilter("editor.BlockEdit", "elementor-ai-toolbar-button", function addAiButtonToToolbar(BlockEdit) {
31040 return function(props) {
31041 return /*#__PURE__*/ react.default.createElement(EditTextWithAi, _extends$1({}, props, { blockEdit: BlockEdit }));
31042 };
31043 });
31044 })(window.wp);
31045 (function() {
31046 "use strict";
31047 wp.data.subscribe(function setElementorWpAiCurrentContext() {
31048 var selectedBlock = wp.data.select("core/block-editor").getSelectedBlock();
31049 if (selectedBlock) {
31050 var blockName = "core/heading" === selectedBlock.name ? "heading" : selectedBlock.name;
31051 window.elementorWpAiCurrentContext = {
31052 widgetType: blockName,
31053 controlName: blockName
31054 };
31055 } else window.elementorWpAiCurrentContext = null;
31056 });
31057 window.addEventListener("beforeunload", function clearElementorAiCurrentContext() {
31058 window.elementorWpAiCurrentContext = null;
31059 });
31060 })();
31061
31062 //#endregion
31063 })(React, wp.i18n, elementorV2.ui, elementorV2.icons, elementorV2.ui['TextField']);
31064 //# sourceMappingURL=ai-gutenberg.js.map