lt-ppt 1.0.28 → 1.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,126 @@
1
- import { inject as Y, ref as w, defineComponent as Z, computed as q, onMounted as j, onBeforeUnmount as Q, watch as z, openBlock as K, createElementBlock as $, normalizeStyle as ee } from "vue";
2
- const te = {
1
+ import { inject as pe, ref as w, defineComponent as ge, getCurrentInstance as he, computed as z, onMounted as me, onBeforeUnmount as fe, watch as H, openBlock as Se, createElementBlock as Ce, normalizeStyle as ye } from "vue";
2
+ var $ = /* @__PURE__ */ ((n) => (n.RECT = "rect", n.ELLIPSE = "ellipse", n.POLYGON = "polygon", n))($ || {});
3
+ const G = {
4
+ rect: {
5
+ name: "矩形",
6
+ type: "rect",
7
+ radius: "0",
8
+ style: ""
9
+ },
10
+ rect2: {
11
+ name: "矩形2",
12
+ type: "polygon",
13
+ style: "polygon(0% 0%, 80% 0%, 100% 20%, 100% 100%, 0 100%)",
14
+ createPath: (n, i) => `M 0 0 L ${n * 0.8} 0 L ${n} ${i * 0.2} L ${n} ${i} L 0 ${i} Z`
15
+ },
16
+ rect3: {
17
+ name: "矩形3",
18
+ type: "polygon",
19
+ style: "polygon(0% 0%, 80% 0%, 100% 20%, 100% 100%, 20% 100%, 0% 80%)",
20
+ createPath: (n, i) => `M 0 0 L ${n * 0.8} 0 L ${n} ${i * 0.2} L ${n} ${i} L ${n * 0.2} ${i} L 0 ${i * 0.8} Z`
21
+ },
22
+ roundRect: {
23
+ name: "圆角矩形",
24
+ type: "rect",
25
+ radius: "10px",
26
+ style: "inset(0 round 10px)"
27
+ },
28
+ ellipse: {
29
+ name: "圆形",
30
+ type: "ellipse",
31
+ style: "ellipse(50% 50% at 50% 50%)"
32
+ },
33
+ triangle: {
34
+ name: "三角形",
35
+ type: "polygon",
36
+ style: "polygon(50% 0%, 0% 100%, 100% 100%)",
37
+ createPath: (n, i) => `M ${n * 0.5} 0 L 0 ${i} L ${n} ${i} Z`
38
+ },
39
+ triangle2: {
40
+ name: "三角形2",
41
+ type: "polygon",
42
+ style: "polygon(50% 100%, 0% 0%, 100% 0%)",
43
+ createPath: (n, i) => `M ${n * 0.5} ${i} L 0 0 L ${n} 0 Z`
44
+ },
45
+ triangle3: {
46
+ name: "三角形3",
47
+ type: "polygon",
48
+ style: "polygon(0% 0%, 0% 100%, 100% 100%)",
49
+ createPath: (n, i) => `M 0 0 L 0 ${i} L ${n} ${i} Z`
50
+ },
51
+ rhombus: {
52
+ name: "菱形",
53
+ type: "polygon",
54
+ style: "polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)",
55
+ createPath: (n, i) => `M ${n * 0.5} 0 L ${n} ${i * 0.5} L ${n * 0.5} ${i} L 0 ${i * 0.5} Z`
56
+ },
57
+ pentagon: {
58
+ name: "五边形",
59
+ type: "polygon",
60
+ style: "polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%)",
61
+ createPath: (n, i) => `M ${n * 0.5} 0 L ${n} ${0.38 * i} L ${0.82 * n} ${i} L ${0.18 * n} ${i} L 0 ${0.38 * i} Z`
62
+ },
63
+ hexagon: {
64
+ name: "六边形",
65
+ type: "polygon",
66
+ style: "polygon(20% 0%, 80% 0%, 100% 50%, 80% 100%, 20% 100%, 0% 50%)",
67
+ createPath: (n, i) => `M ${n * 0.2} 0 L ${n * 0.8} 0 L ${n} ${i * 0.5} L ${n * 0.8} ${i} L ${n * 0.2} ${i} L 0 ${i * 0.5} Z`
68
+ },
69
+ heptagon: {
70
+ name: "七边形",
71
+ type: "polygon",
72
+ style: "polygon(50% 0%, 90% 20%, 100% 60%, 75% 100%, 25% 100%, 0% 60%, 10% 20%)",
73
+ createPath: (n, i) => `M ${n * 0.5} 0 L ${n * 0.9} ${i * 0.2} L ${n} ${i * 0.6} L ${n * 0.75} ${i} L ${n * 0.25} ${i} L 0 ${i * 0.6} L ${n * 0.1} ${i * 0.2} Z`
74
+ },
75
+ octagon: {
76
+ name: "八边形",
77
+ type: "polygon",
78
+ style: "polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%)",
79
+ createPath: (n, i) => `M ${n * 0.3} 0 L ${n * 0.7} 0 L ${n} ${i * 0.3} L ${n} ${i * 0.7} L ${n * 0.7} ${i} L ${n * 0.3} ${i} L 0 ${i * 0.7} L 0 ${i * 0.3} Z`
80
+ },
81
+ chevron: {
82
+ name: "V形",
83
+ type: "polygon",
84
+ style: "polygon(75% 0%, 100% 50%, 75% 100%, 0% 100%, 25% 50%, 0% 0%)",
85
+ createPath: (n, i) => `M ${n * 0.75} 0 L ${n} ${i * 0.5} L ${n * 0.75} ${i} L 0 ${i} L ${n * 0.25} ${i * 0.5} L 0 0 Z`
86
+ },
87
+ point: {
88
+ name: "点",
89
+ type: "polygon",
90
+ style: "polygon(0% 0%, 75% 0%, 100% 50%, 75% 100%, 0% 100%)",
91
+ createPath: (n, i) => `M 0 0 L ${n * 0.75} 0 L ${n} ${i * 0.5} L ${n * 0.75} ${i} L 0 ${i} Z`
92
+ },
93
+ arrow: {
94
+ name: "箭头",
95
+ type: "polygon",
96
+ style: "polygon(0% 20%, 60% 20%, 60% 0%, 100% 50%, 60% 100%, 60% 80%, 0% 80%)",
97
+ createPath: (n, i) => `M 0 ${i * 0.2} L ${n * 0.6} ${i * 0.2} L ${n * 0.6} 0 L ${n} ${i * 0.5} L ${n * 0.6} ${i} L ${n * 0.6} ${i * 0.8} L 0 ${i * 0.8} Z`
98
+ },
99
+ parallelogram: {
100
+ name: "平行四边形",
101
+ type: "polygon",
102
+ style: "polygon(30% 0%, 100% 0%, 70% 100%, 0% 100%)",
103
+ createPath: (n, i) => `M ${n * 0.3} 0 L ${n} 0 L ${n * 0.7} ${i} L 0 ${i} Z`
104
+ },
105
+ parallelogram2: {
106
+ name: "平行四边形2",
107
+ type: "polygon",
108
+ style: "polygon(30% 100%, 100% 100%, 70% 0%, 0% 0%)",
109
+ createPath: (n, i) => `M ${n * 0.3} ${i} L ${n} ${i} L ${n * 0.7} 0 L 0 0 Z`
110
+ },
111
+ trapezoid: {
112
+ name: "梯形",
113
+ type: "polygon",
114
+ style: "polygon(25% 0%, 75% 0%, 100% 100%, 0% 100%)",
115
+ createPath: (n, i) => `M ${n * 0.25} 0 L ${n * 0.75} 0 L ${n} ${i} L 0 ${i} Z`
116
+ },
117
+ trapezoid2: {
118
+ name: "梯形2",
119
+ type: "polygon",
120
+ style: "polygon(0% 0%, 100% 0%, 75% 100%, 25% 100%)",
121
+ createPath: (n, i) => `M 0 0 L ${n} 0 L ${n * 0.75} ${i} L ${n * 0.25} ${i} Z`
122
+ }
123
+ }, be = {
3
124
  common: {
4
125
  close: "关闭",
5
126
  cancel: "取消",
@@ -1148,7 +1269,7 @@ const te = {
1148
1269
  latex: "公式"
1149
1270
  }
1150
1271
  }
1151
- }, oe = {
1272
+ }, Le = {
1152
1273
  common: {
1153
1274
  close: "Close",
1154
1275
  cancel: "Cancel",
@@ -2269,41 +2390,41 @@ const te = {
2269
2390
  latex: "Formula"
2270
2391
  }
2271
2392
  }
2272
- }, U = Symbol("lt-ppt-i18n"), ie = { "zh-CN": te, en: oe };
2273
- function N(d, c = "") {
2274
- return Object.entries(d).reduce((s, [i, u]) => {
2275
- const h = c ? `${c}.${i}` : i;
2276
- return u && typeof u == "object" && !Array.isArray(u) ? Object.assign(s, N(u, h)) : s[h] = String(u), s;
2393
+ }, W = Symbol("lt-ppt-i18n"), Ie = { "zh-CN": be, en: Le };
2394
+ function _(n, i = "") {
2395
+ return Object.entries(n).reduce((g, [c, m]) => {
2396
+ const C = i ? `${i}.${c}` : c;
2397
+ return m && typeof m == "object" && !Array.isArray(m) ? Object.assign(g, _(m, C)) : g[C] = String(m), g;
2277
2398
  }, {});
2278
2399
  }
2279
- const b = Object.fromEntries(
2280
- Object.entries(ie).map(([d, c]) => [d, N(c)])
2400
+ const T = Object.fromEntries(
2401
+ Object.entries(Ie).map(([n, i]) => [n, _(i)])
2281
2402
  );
2282
- function ce() {
2283
- const d = Y(U, { locale: w("zh-CN") });
2284
- return { t: (s) => {
2285
- var i, u;
2286
- return ((i = b[d.locale.value]) == null ? void 0 : i[s]) ?? ((u = b["zh-CN"]) == null ? void 0 : u[s]) ?? s;
2287
- }, locale: d.locale };
2403
+ function Re() {
2404
+ const n = pe(W, { locale: w("zh-CN") });
2405
+ return { t: (g) => {
2406
+ var c, m;
2407
+ return ((c = T[n.locale.value]) == null ? void 0 : c[g]) ?? ((m = T["zh-CN"]) == null ? void 0 : m[g]) ?? g;
2408
+ }, locale: n.locale };
2288
2409
  }
2289
- function ne(d) {
2290
- return (c) => {
2291
- var s, i;
2292
- return ((s = b[d.value]) == null ? void 0 : s[c]) ?? ((i = b["zh-CN"]) == null ? void 0 : i[c]) ?? c;
2410
+ function Te(n) {
2411
+ return (i) => {
2412
+ var g, c;
2413
+ return ((g = T[n.value]) == null ? void 0 : g[i]) ?? ((c = T["zh-CN"]) == null ? void 0 : c[i]) ?? i;
2293
2414
  };
2294
2415
  }
2295
- function ue(d) {
2296
- const c = w((d == null ? void 0 : d.locale) ?? "zh-CN");
2416
+ function Fe(n) {
2417
+ const i = w((n == null ? void 0 : n.locale) ?? "zh-CN");
2297
2418
  return {
2298
2419
  install() {
2299
2420
  },
2300
- global: { locale: c, t: (i) => {
2301
- var u, h;
2302
- return ((u = b[c.value]) == null ? void 0 : u[i]) ?? ((h = b["zh-CN"]) == null ? void 0 : h[i]) ?? i;
2421
+ global: { locale: i, t: (c) => {
2422
+ var m, C;
2423
+ return ((m = T[i.value]) == null ? void 0 : m[c]) ?? ((C = T["zh-CN"]) == null ? void 0 : C[c]) ?? c;
2303
2424
  } }
2304
2425
  };
2305
2426
  }
2306
- const le = /* @__PURE__ */ Z({
2427
+ const V = 4096 * 4096, Pe = 8e3, we = /* @__PURE__ */ ge({
2307
2428
  __name: "LtPPT",
2308
2429
  props: {
2309
2430
  initData: {},
@@ -2320,174 +2441,326 @@ const le = /* @__PURE__ */ Z({
2320
2441
  onImageAIEntryClick: {}
2321
2442
  },
2322
2443
  emits: ["image-ai-entry-click"],
2323
- setup(d, { expose: c, emit: s }) {
2324
- const i = d, u = s, h = w();
2325
- let m = null, g = null, k = null, P = null, L = null, x = null, F = null;
2326
- const v = w(i.locale ?? "zh-CN"), A = w(i.theme ?? "dark"), M = q(() => ({
2327
- width: i.width,
2328
- height: i.height
2329
- })), H = (e) => {
2330
- var p, r;
2331
- const t = (p = e.detail) == null ? void 0 : p.element;
2444
+ setup(n, { expose: i, emit: g }) {
2445
+ const c = n, m = g, C = he(), L = w();
2446
+ let S = null, f = null, A = null, R = null, F = null, O = null, B = null;
2447
+ const E = w(c.locale ?? "zh-CN"), D = w(c.theme ?? "dark"), Z = z(() => ({
2448
+ width: c.width,
2449
+ height: c.height
2450
+ })), X = () => {
2451
+ const e = (C == null ? void 0 : C.vnode.props) || {};
2452
+ return !!(e.onImageAIEntryClick || e.onImageAiEntryClick);
2453
+ }, J = z(() => !!c.onImageAIEntryClick || X()), Y = (e) => new Promise((t) => {
2454
+ if (typeof Image > "u") {
2455
+ t(null);
2456
+ return;
2457
+ }
2458
+ let o = !1, r = null;
2459
+ const s = (l) => {
2460
+ o || (o = !0, r && clearTimeout(r), t(l));
2461
+ };
2462
+ r = setTimeout(() => s(null), Pe);
2463
+ const a = new Image();
2464
+ /^https?:\/\//i.test(e) && (a.crossOrigin = "anonymous"), a.decoding = "sync", a.onload = async () => {
2465
+ var l;
2466
+ try {
2467
+ await ((l = a.decode) == null ? void 0 : l.call(a));
2468
+ } catch {
2469
+ }
2470
+ s(a);
2471
+ }, a.onerror = () => s(null), a.src = e;
2472
+ }), q = (e) => {
2473
+ const t = Math.max(1, e.width || 1), o = Math.max(1, e.height || 1);
2474
+ let r = Math.min(typeof window > "u" ? 1 : window.devicePixelRatio || 1, 2);
2475
+ return t * o * r * r > V && (r = Math.sqrt(V / (t * o))), {
2476
+ width: Math.max(1, Math.round(t * r)),
2477
+ height: Math.max(1, Math.round(o * r)),
2478
+ scale: r
2479
+ };
2480
+ }, j = (e, t, o, r, s, a) => {
2481
+ const l = Math.min(Math.max(a, 0), r / 2, s / 2);
2482
+ if (!l) {
2483
+ e.rect(t, o, r, s);
2484
+ return;
2485
+ }
2486
+ e.moveTo(t + l, o), e.lineTo(t + r - l, o), e.quadraticCurveTo(t + r, o, t + r, o + l), e.lineTo(t + r, o + s - l), e.quadraticCurveTo(t + r, o + s, t + r - l, o + s), e.lineTo(t + l, o + s), e.quadraticCurveTo(t, o + s, t, o + s - l), e.lineTo(t, o + l), e.quadraticCurveTo(t, o, t + l, o);
2487
+ }, Q = (e, t, o, r, s) => {
2488
+ var p;
2489
+ const a = G[((p = t.clip) == null ? void 0 : p.shape) || "rect"] || G.rect;
2490
+ if (a.type === $.ELLIPSE) {
2491
+ e.beginPath(), e.ellipse(o / 2, r / 2, o / 2, r / 2, 0, 0, Math.PI * 2), e.clip();
2492
+ return;
2493
+ }
2494
+ if (a.type === $.POLYGON && a.createPath && typeof Path2D < "u") {
2495
+ e.clip(new Path2D(a.createPath(o, r)));
2496
+ return;
2497
+ }
2498
+ const l = a.radius !== void 0 ? (t.radius || Number.parseFloat(a.radius) || 0) * s : 0;
2499
+ e.beginPath(), j(e, 0, 0, o, r, l), e.clip();
2500
+ }, K = (e, t, o) => {
2501
+ if (!e.clip) return { left: 0, top: 0, width: t, height: o };
2502
+ const [r, s] = e.clip.range, a = s[0] - r[0], l = s[1] - r[1];
2503
+ return !Number.isFinite(a) || !Number.isFinite(l) || !a || !l ? { left: 0, top: 0, width: t, height: o } : {
2504
+ left: -r[0] / a * t,
2505
+ top: -r[1] / l * o,
2506
+ width: 100 / a * t,
2507
+ height: 100 / l * o
2508
+ };
2509
+ }, ee = (e) => e.filters ? Object.keys(e.filters).map((t) => {
2510
+ var r;
2511
+ const o = (r = e.filters) == null ? void 0 : r[t];
2512
+ return o ? `${t}(${o})` : "";
2513
+ }).filter(Boolean).join(" ") : "", te = async (e) => {
2514
+ if (!e.src || typeof document > "u") return e.src;
2515
+ try {
2516
+ const t = await Y(e.src);
2517
+ if (!t) return e.src;
2518
+ const o = document.createElement("canvas"), { width: r, height: s, scale: a } = q(e);
2519
+ o.width = r, o.height = s;
2520
+ const l = o.getContext("2d");
2521
+ if (!l) return e.src;
2522
+ l.save(), (e.flipH || e.flipV) && (l.translate(e.flipH ? r : 0, e.flipV ? s : 0), l.scale(e.flipH ? -1 : 1, e.flipV ? -1 : 1)), Q(l, e, r, s, a);
2523
+ const p = ee(e);
2524
+ p && (l.filter = p);
2525
+ const h = K(e, r, s);
2526
+ return l.drawImage(t, h.left, h.top, h.width, h.height), e.colorMask && (l.filter = "none", l.fillStyle = e.colorMask, l.fillRect(0, 0, r, s)), l.restore(), o.toDataURL("image/png");
2527
+ } catch {
2528
+ return e.src;
2529
+ }
2530
+ }, oe = async (e) => {
2531
+ var s, a;
2532
+ const t = (s = e.detail) == null ? void 0 : s.element;
2332
2533
  if (!t || t.type !== "image") return;
2333
- const n = {
2334
- element: JSON.parse(JSON.stringify(t))
2534
+ const o = JSON.parse(JSON.stringify(t));
2535
+ o.clipSrc = await te(t);
2536
+ const r = {
2537
+ element: o
2335
2538
  };
2336
- (r = i.onImageAIEntryClick) == null || r.call(i, n), u("image-ai-entry-click", n);
2337
- }, G = async () => {
2338
- if (!h.value || m) return;
2539
+ (a = c.onImageAIEntryClick) == null || a.call(c, r), m("image-ai-entry-click", r);
2540
+ }, ne = async () => {
2541
+ if (!L.value || S) return;
2339
2542
  const [
2340
2543
  { createApp: e },
2341
2544
  { createPinia: t },
2342
- { default: n },
2343
- { default: p },
2344
- r
2545
+ { default: o },
2546
+ { default: r },
2547
+ s
2345
2548
  ] = await Promise.all([
2346
2549
  import("vue"),
2347
2550
  import("./pinia-CVat9nJz.js"),
2348
- import("./InnerApp-BkVsQnm2.js"),
2349
- import("./index-e8Js74-o.js"),
2350
- import("./index-vmpIx8K7.js")
2551
+ import("./InnerApp-DTdTRK-f.js"),
2552
+ import("./index-CwjKu8Yc.js"),
2553
+ import("./index-jHhH4l0I.js")
2351
2554
  ]);
2352
- if (!h.value) return;
2353
- k = r.useSlidesStore, P = r.useScreenStore, L = r.useMainStore, x = r.useSnapshotStore;
2354
- const o = document.createElement("div");
2355
- o.style.width = "100%", o.style.height = "100%", h.value.appendChild(o), m = e(n, {
2356
- initData: i.initData,
2357
- onUploadFile: i.onUploadFile,
2358
- readonly: i.readonly,
2359
- onChange: i.onChange,
2360
- onSave: i.onSave,
2361
- onInitFinished: i.onInitFinished,
2362
- onReturn: i.onReturn,
2363
- theme: A.value
2364
- }), g = t(), m.use(g), m.provide(U, { locale: v }), m.provide("__lt_ppt_theme__", A), m.config.globalProperties.$t = ne(v), m.use(p), m.mount(o);
2365
- }, V = () => {
2366
- m && (m.unmount(), m = null, g = null), h.value && (h.value.innerHTML = "");
2555
+ if (!L.value) return;
2556
+ A = s.useSlidesStore, R = s.useScreenStore, F = s.useMainStore, O = s.useSnapshotStore;
2557
+ const a = document.createElement("div");
2558
+ a.style.width = "100%", a.style.height = "100%", L.value.appendChild(a), S = e(o, {
2559
+ initData: c.initData,
2560
+ onUploadFile: c.onUploadFile,
2561
+ readonly: c.readonly,
2562
+ onChange: c.onChange,
2563
+ onSave: c.onSave,
2564
+ onInitFinished: c.onInitFinished,
2565
+ onReturn: c.onReturn,
2566
+ theme: D.value
2567
+ }), f = t(), S.use(f), S.provide(W, { locale: E }), S.provide("__lt_ppt_theme__", D), S.provide("__lt_ppt_image_ai_entry_enabled__", J), S.config.globalProperties.$t = Te(E), S.use(r), S.mount(a);
2568
+ }, ie = () => {
2569
+ S && (S.unmount(), S = null, f = null), L.value && (L.value.innerHTML = "");
2367
2570
  };
2368
- j(() => {
2369
- F = G();
2370
- }), Q(() => {
2371
- V();
2372
- }), z(() => i.locale, (e) => {
2373
- v.value = e ?? "zh-CN";
2374
- }), z(() => i.theme, (e) => {
2375
- A.value = e ?? "dark";
2571
+ me(() => {
2572
+ B = ne();
2573
+ }), fe(() => {
2574
+ ie();
2575
+ }), H(() => c.locale, (e) => {
2576
+ E.value = e ?? "zh-CN";
2577
+ }), H(() => c.theme, (e) => {
2578
+ D.value = e ?? "dark";
2376
2579
  });
2377
- const T = () => !g || !k ? null : k(g), R = () => !g || !L ? null : L(g), W = () => !g || !x ? null : x(g), O = async () => (!g && F && await F, !!g), B = (e) => new Promise((t) => {
2580
+ const b = () => !f || !A ? null : A(f), P = () => !f || !F ? null : F(f), le = () => !f || !O ? null : O(f), k = async () => (!f && B && await B, !!f), M = (e) => new Promise((t) => {
2378
2581
  if (typeof Image > "u") {
2379
2582
  t(null);
2380
2583
  return;
2381
2584
  }
2382
- const n = new Image();
2383
- n.onload = () => {
2585
+ const o = new Image();
2586
+ o.decoding = "sync", o.onload = async () => {
2587
+ var r;
2588
+ try {
2589
+ await ((r = o.decode) == null ? void 0 : r.call(o));
2590
+ } catch {
2591
+ }
2384
2592
  t({
2385
- width: n.naturalWidth || n.width,
2386
- height: n.naturalHeight || n.height
2593
+ width: o.naturalWidth || o.width,
2594
+ height: o.naturalHeight || o.height
2387
2595
  });
2388
- }, n.onerror = () => t(null), n.src = e;
2389
- }), y = (e, t) => Number.isFinite(e) && e > 0 ? e : t, D = (e, t) => t.slideId ? e.slides.findIndex((n) => n.id === t.slideId) : t.slideIndex !== void 0 ? Number.isInteger(t.slideIndex) && t.slideIndex >= 0 && t.slideIndex < e.slides.length ? t.slideIndex : -1 : e.slideIndex, X = async (e, t, n, p, r = { width: 300, height: 200 }) => {
2390
- const o = await B(e);
2391
- let l = y(t.width, (o == null ? void 0 : o.width) || r.width), S = y(t.height, (o == null ? void 0 : o.height) || r.height);
2392
- if (t.width !== void 0 && t.height === void 0 && (o != null && o.width) && o.height)
2393
- S = l * o.height / o.width;
2394
- else if (t.height !== void 0 && t.width === void 0 && (o != null && o.width) && o.height)
2395
- l = S * o.width / o.height;
2396
- else if (t.width === void 0 && t.height === void 0 && (o != null && o.width) && o.height) {
2397
- const C = Math.min(1, n / o.width, p / o.height);
2398
- l = o.width * C, S = o.height * C;
2596
+ }, o.onerror = () => t(null), o.src = e;
2597
+ }), I = (e, t) => Number.isFinite(e) && e > 0 ? e : t, U = (e, t, o, r, s) => {
2598
+ let a = I(e.width, (t == null ? void 0 : t.width) || s.width), l = I(e.height, (t == null ? void 0 : t.height) || s.height);
2599
+ if (e.width !== void 0 && e.height === void 0 && (t != null && t.width) && t.height)
2600
+ l = a * t.height / t.width;
2601
+ else if (e.height !== void 0 && e.width === void 0 && (t != null && t.width) && t.height)
2602
+ a = l * t.width / t.height;
2603
+ else if (e.width === void 0 && e.height === void 0 && (t != null && t.width) && t.height) {
2604
+ const p = Math.min(1, o / t.width, r / t.height);
2605
+ a = t.width * p, l = t.height * p;
2606
+ }
2607
+ return { width: a, height: l };
2608
+ }, N = (e) => new Promise((t) => {
2609
+ if (typeof document > "u") {
2610
+ t(null);
2611
+ return;
2399
2612
  }
2400
- return { width: l, height: S };
2401
- }, E = async () => {
2402
- const e = W();
2613
+ const o = document.createElement("video");
2614
+ o.preload = "metadata", o.muted = !0, o.onloadedmetadata = () => {
2615
+ const r = o.videoWidth, s = o.videoHeight;
2616
+ o.onloadedmetadata = null, o.onerror = null, o.removeAttribute("src"), o.load(), t(r && s ? { width: r, height: s } : null);
2617
+ }, o.onerror = () => {
2618
+ o.onloadedmetadata = null, o.onerror = null, o.removeAttribute("src"), o.load(), t(null);
2619
+ }, o.src = e;
2620
+ }), v = (e, t) => t.slideId ? e.slides.findIndex((o) => o.id === t.slideId) : t.slideIndex !== void 0 ? Number.isInteger(t.slideIndex) && t.slideIndex >= 0 && t.slideIndex < e.slides.length ? t.slideIndex : -1 : e.slideIndex, ae = async (e, t, o, r, s = { width: 300, height: 200 }) => {
2621
+ const a = await M(e);
2622
+ return U(t, a, o, r, s);
2623
+ }, x = async () => {
2624
+ const e = le();
2403
2625
  e && await e.addSnapshot();
2404
- }, J = async (e) => {
2405
- if (!e.src || !await O()) return null;
2406
- const t = T(), n = R();
2407
- if (!t || !n || !t.slides.length) return null;
2408
- const p = D(t, e);
2409
- if (p === -1) return null;
2410
- t.slideIndex !== p && t.updateSlideIndex(p);
2411
- const r = t.viewportSize, o = t.viewportSize * t.viewportRatio, { width: l, height: S } = await X(e.src, e, r, o), { nanoid: C } = await import("./index.browser-Wq18ov6h.js"), a = {
2626
+ }, re = async (e) => {
2627
+ if (!e.src || !await k()) return null;
2628
+ const t = b(), o = P();
2629
+ if (!t || !o || !t.slides.length) return null;
2630
+ const r = v(t, e);
2631
+ if (r === -1) return null;
2632
+ t.slideIndex !== r && t.updateSlideIndex(r);
2633
+ const s = t.viewportSize, a = t.viewportSize * t.viewportRatio, { width: l, height: p } = await ae(e.src, e, s, a), { nanoid: h } = await import("./index.browser-Wq18ov6h.js"), d = {
2412
2634
  type: "image",
2413
- id: C(10),
2635
+ id: h(10),
2414
2636
  src: e.src,
2415
2637
  width: l,
2416
- height: S,
2417
- left: e.left ?? (r - l) / 2,
2418
- top: e.top ?? (o - S) / 2,
2638
+ height: p,
2639
+ left: e.left ?? (s - l) / 2,
2640
+ top: e.top ?? (a - p) / 2,
2419
2641
  fixedRatio: e.fixedRatio ?? !0,
2420
2642
  rotate: e.rotate ?? 0
2421
2643
  };
2422
- return t.addElement(a), e.select !== !1 && n.setActiveElementIdList([a.id]), await E(), JSON.parse(JSON.stringify(a));
2423
- }, _ = (e, t, n) => {
2424
- var S, C;
2425
- const p = !!n.slideId || n.slideIndex !== void 0, r = D(e, n), o = n.elementId || (t.activeElementIdList.length === 1 ? t.activeElementIdList[0] : t.handleElementId);
2426
- if (!o) return null;
2427
- if (p || !n.elementId) {
2428
- if (r === -1) return null;
2429
- const a = (S = e.slides[r]) == null ? void 0 : S.elements.find((f) => f.id === o);
2430
- return (a == null ? void 0 : a.type) === "image" ? { slideIndex: r, element: a } : null;
2644
+ return t.addElement(d), e.select !== !1 && o.setActiveElementIdList([d.id]), await x(), JSON.parse(JSON.stringify(d));
2645
+ }, se = (e, t, o) => {
2646
+ var p, h;
2647
+ const r = !!o.slideId || o.slideIndex !== void 0, s = v(e, o), a = o.elementId || (t.activeElementIdList.length === 1 ? t.activeElementIdList[0] : t.handleElementId);
2648
+ if (!a) return null;
2649
+ if (r || !o.elementId) {
2650
+ if (s === -1) return null;
2651
+ const d = (p = e.slides[s]) == null ? void 0 : p.elements.find((u) => u.id === a);
2652
+ return (d == null ? void 0 : d.type) === "image" ? { slideIndex: s, element: d } : null;
2431
2653
  }
2432
- const l = (C = e.slides[e.slideIndex]) == null ? void 0 : C.elements.find((a) => a.id === o);
2654
+ const l = (h = e.slides[e.slideIndex]) == null ? void 0 : h.elements.find((d) => d.id === a);
2433
2655
  if ((l == null ? void 0 : l.type) === "image") return { slideIndex: e.slideIndex, element: l };
2434
- for (let a = 0; a < e.slides.length; a++) {
2435
- const f = e.slides[a].elements.find((I) => I.id === o);
2436
- if ((f == null ? void 0 : f.type) === "image") return { slideIndex: a, element: f };
2656
+ for (let d = 0; d < e.slides.length; d++) {
2657
+ const u = e.slides[d].elements.find((y) => y.id === a);
2658
+ if ((u == null ? void 0 : u.type) === "image") return { slideIndex: d, element: u };
2659
+ }
2660
+ return null;
2661
+ }, de = async (e) => {
2662
+ if (!e.src || !await k()) return null;
2663
+ const t = b(), o = P();
2664
+ if (!t || !o || !t.slides.length) return null;
2665
+ const r = se(t, o, e);
2666
+ if (!r) return null;
2667
+ const { slideIndex: s, element: a } = r, l = { src: e.src };
2668
+ if (e.fixedRatio !== void 0 && (l.fixedRatio = e.fixedRatio), e.resetClip && (l.clip = void 0), !(e.keepSize === !0 && e.width === void 0 && e.height === void 0)) {
2669
+ const d = await M(e.src), u = I(e.width, a.width);
2670
+ let y = I(e.height, a.height);
2671
+ e.height === void 0 && (d != null && d.width) && d.height && (y = u * d.height / d.width), l.width = u, l.height = y, l.left = a.left, l.top = a.top, l.clip = void 0;
2672
+ }
2673
+ const h = t.slides[s].id;
2674
+ return t.updateElement({ id: a.id, props: l, slideId: h }), t.slideIndex !== s && t.updateSlideIndex(s), e.select !== !1 && o.setActiveElementIdList([a.id]), await x(), JSON.parse(JSON.stringify({ ...a, ...l }));
2675
+ }, ce = async (e) => {
2676
+ if (!e.src || !await k()) return null;
2677
+ const t = b(), o = P();
2678
+ if (!t || !o || !t.slides.length) return null;
2679
+ const r = v(t, e);
2680
+ if (r === -1) return null;
2681
+ t.slideIndex !== r && t.updateSlideIndex(r);
2682
+ const s = t.viewportSize, a = t.viewportSize * t.viewportRatio, l = await N(e.src), { width: p, height: h } = U(e, l, s, a, { width: 500, height: 300 }), { nanoid: d } = await import("./index.browser-Wq18ov6h.js"), u = {
2683
+ type: "video",
2684
+ id: d(10),
2685
+ src: e.src,
2686
+ width: p,
2687
+ height: h,
2688
+ left: e.left ?? (s - p) / 2,
2689
+ top: e.top ?? (a - h) / 2,
2690
+ rotate: e.rotate ?? 0,
2691
+ autoplay: e.autoplay ?? !1
2692
+ };
2693
+ return e.poster !== void 0 && (u.poster = e.poster), e.ext && (u.ext = e.ext), t.addElement(u), e.select !== !1 && o.setActiveElementIdList([u.id]), await x(), JSON.parse(JSON.stringify(u));
2694
+ }, ue = (e, t, o) => {
2695
+ var p, h;
2696
+ const r = !!o.slideId || o.slideIndex !== void 0, s = v(e, o), a = o.elementId || (t.activeElementIdList.length === 1 ? t.activeElementIdList[0] : t.handleElementId);
2697
+ if (!a) return null;
2698
+ if (r || !o.elementId) {
2699
+ if (s === -1) return null;
2700
+ const d = (p = e.slides[s]) == null ? void 0 : p.elements.find((u) => u.id === a);
2701
+ return (d == null ? void 0 : d.type) === "video" ? { slideIndex: s, element: d } : null;
2702
+ }
2703
+ const l = (h = e.slides[e.slideIndex]) == null ? void 0 : h.elements.find((d) => d.id === a);
2704
+ if ((l == null ? void 0 : l.type) === "video") return { slideIndex: e.slideIndex, element: l };
2705
+ for (let d = 0; d < e.slides.length; d++) {
2706
+ const u = e.slides[d].elements.find((y) => y.id === a);
2707
+ if ((u == null ? void 0 : u.type) === "video") return { slideIndex: d, element: u };
2437
2708
  }
2438
2709
  return null;
2439
2710
  };
2440
- return c({
2711
+ return i({
2441
2712
  getSlides: () => {
2442
- const e = T();
2713
+ const e = b();
2443
2714
  return e ? JSON.parse(JSON.stringify(e.slides)) : [];
2444
2715
  },
2445
2716
  getSelectedElements: () => {
2446
- const e = R();
2717
+ const e = P();
2447
2718
  return e ? JSON.parse(JSON.stringify(e.activeElementList)) : [];
2448
2719
  },
2449
2720
  setSlides: (e) => {
2450
- const t = T();
2721
+ const t = b();
2451
2722
  t && t.setSlides(e);
2452
2723
  },
2453
2724
  startScreening: () => {
2454
- if (!g || !P) return;
2455
- P(g).setScreening(!0);
2725
+ if (!f || !R) return;
2726
+ R(f).setScreening(!0);
2456
2727
  },
2457
2728
  getCurrentIndex: () => {
2458
- const e = T();
2729
+ const e = b();
2459
2730
  return e ? e.slideIndex : 0;
2460
2731
  },
2461
- insertImage: J,
2462
- replaceImage: async (e) => {
2463
- if (!e.src || !await O()) return null;
2464
- const t = T(), n = R();
2465
- if (!t || !n || !t.slides.length) return null;
2466
- const p = _(t, n, e);
2467
- if (!p) return null;
2468
- const { slideIndex: r, element: o } = p, l = { src: e.src };
2469
- if (e.fixedRatio !== void 0 && (l.fixedRatio = e.fixedRatio), e.resetClip && (l.clip = void 0), !(e.keepSize === !0 && e.width === void 0 && e.height === void 0)) {
2470
- const a = await B(e.src), f = y(e.width, o.width);
2471
- let I = y(e.height, o.height);
2472
- e.height === void 0 && (a != null && a.width) && a.height && (I = f * a.height / a.width), l.width = f, l.height = I, l.left = o.left, l.top = o.top, l.clip = void 0;
2732
+ insertImage: re,
2733
+ replaceImage: de,
2734
+ insertVideo: ce,
2735
+ replaceVideo: async (e) => {
2736
+ if (!e.src || !await k()) return null;
2737
+ const t = b(), o = P();
2738
+ if (!t || !o || !t.slides.length) return null;
2739
+ const r = ue(t, o, e);
2740
+ if (!r) return null;
2741
+ const { slideIndex: s, element: a } = r, l = { src: e.src };
2742
+ if (e.autoplay !== void 0 && (l.autoplay = e.autoplay), e.poster !== void 0 && (l.poster = e.poster || void 0), e.ext !== void 0 && (l.ext = e.ext || void 0), !(e.keepSize === !0 && e.width === void 0 && e.height === void 0)) {
2743
+ const d = await N(e.src), u = I(e.width, a.width);
2744
+ let y = I(e.height, a.height);
2745
+ e.height === void 0 && (d != null && d.width) && d.height && (y = u * d.height / d.width), l.width = u, l.height = y, l.left = a.left, l.top = a.top;
2473
2746
  }
2474
- const C = t.slides[r].id;
2475
- return t.updateElement({ id: o.id, props: l, slideId: C }), t.slideIndex !== r && t.updateSlideIndex(r), e.select !== !1 && n.setActiveElementIdList([o.id]), await E(), JSON.parse(JSON.stringify({ ...o, ...l }));
2747
+ const h = t.slides[s].id;
2748
+ return t.updateElement({ id: a.id, props: l, slideId: h }), t.slideIndex !== s && t.updateSlideIndex(s), e.select !== !1 && o.setActiveElementIdList([a.id]), await x(), JSON.parse(JSON.stringify({ ...a, ...l }));
2476
2749
  }
2477
- }), (e, t) => (K(), $("div", {
2750
+ }), (e, t) => (Se(), Ce("div", {
2478
2751
  ref_key: "containerRef",
2479
- ref: h,
2752
+ ref: L,
2480
2753
  class: "lt-ppt-container",
2481
- style: ee(M.value),
2482
- onImageAiEntryClick: H
2754
+ style: ye(Z.value),
2755
+ onImageAiEntryClick: oe
2483
2756
  }, null, 36));
2484
2757
  }
2485
- }), ae = (d, c) => {
2486
- const s = d.__vccOpts || d;
2487
- for (const [i, u] of c)
2488
- s[i] = u;
2489
- return s;
2490
- }, pe = /* @__PURE__ */ ae(le, [["__scopeId", "data-v-aa99033b"]]), re = [
2758
+ }), ke = (n, i) => {
2759
+ const g = n.__vccOpts || n;
2760
+ for (const [c, m] of i)
2761
+ g[c] = m;
2762
+ return g;
2763
+ }, Oe = /* @__PURE__ */ ke(we, [["__scopeId", "data-v-473d1efa"]]), ve = [
2491
2764
  "SourceHanSans",
2492
2765
  "SourceHanSerif",
2493
2766
  "WenDingPLSongTi",
@@ -2516,18 +2789,20 @@ const le = /* @__PURE__ */ Z({
2516
2789
  "Montserrat",
2517
2790
  "SourceSansPro",
2518
2791
  "Merriweather"
2519
- ], ge = (d = "/fonts") => {
2792
+ ], Be = (n = "/fonts") => {
2520
2793
  if (typeof document > "u" || !document.head) return;
2521
- const c = d.replace(/\/$/, ""), s = document.createElement("style");
2522
- s.textContent = re.map(
2523
- (i) => `@font-face { font-display: swap; font-family: ${i}; src: url('${c}/${i}.woff2') format('woff2'); }`
2794
+ const i = n.replace(/\/$/, ""), g = document.createElement("style");
2795
+ g.textContent = ve.map(
2796
+ (c) => `@font-face { font-display: swap; font-family: ${c}; src: url('${i}/${c}.woff2') format('woff2'); }`
2524
2797
  ).join(`
2525
- `), document.head.appendChild(s);
2798
+ `), document.head.appendChild(g);
2526
2799
  };
2527
2800
  export {
2528
- pe as L,
2529
- ae as _,
2530
- ue as c,
2531
- ge as l,
2532
- ce as u
2801
+ $ as C,
2802
+ Oe as L,
2803
+ ke as _,
2804
+ G as a,
2805
+ Fe as c,
2806
+ Be as l,
2807
+ Re as u
2533
2808
  };