@nubisco/cms-vue 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, defineComponent as o, inject as s, normalizeClass as c, openBlock as l, provide as u, ref as d, renderList as f, renderSlot as p, resolveDynamicComponent as m, toDisplayString as h, unref as g, withCtx as _, withKeys as v, withModifiers as y } from "vue";
1
+ import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createTextVNode as o, defineComponent as s, getCurrentInstance as c, inject as l, mergeProps as u, normalizeClass as d, openBlock as f, provide as p, ref as m, renderList as h, renderSlot as g, resolveDynamicComponent as _, toDisplayString as v, unref as y, withCtx as b, withKeys as x, withModifiers as S } from "vue";
2
2
  //#region src/contract/logic.ts
3
- var b = [
3
+ var C = [
4
4
  {
5
5
  id: "featureFlag",
6
6
  label: "Feature flag",
@@ -67,7 +67,7 @@ var b = [
67
67
  ],
68
68
  resolveAt: "request"
69
69
  }
70
- ], x = {
70
+ ], w = {
71
71
  featureFlag: {
72
72
  label: "Feature flag",
73
73
  color: "#6e6bd6",
@@ -180,9 +180,9 @@ var b = [
180
180
  }]
181
181
  }
182
182
  };
183
- function S(e) {
183
+ function ee(e) {
184
184
  return e.nodes.map((e) => {
185
- let t = x[e.kind], n = e.param ? `${t.label}: ${e.param}` : t.label;
185
+ let t = w[e.kind], n = e.param ? `${t.label}: ${e.param}` : t.label;
186
186
  return {
187
187
  id: e.id,
188
188
  x: e.x,
@@ -198,7 +198,7 @@ function S(e) {
198
198
  };
199
199
  });
200
200
  }
201
- function C(e, t) {
201
+ function te(e, t) {
202
202
  let n = {}, r = (t, n) => e.connections.find((e) => e.toNode === t && e.toPort === n)?.fromNode, i = (e, t) => {
203
203
  let n = r(e, t);
204
204
  return n ? a(n) : !1;
@@ -244,93 +244,636 @@ function C(e, t) {
244
244
  }
245
245
  //#endregion
246
246
  //#region src/evaluate.ts
247
- function w(e, t, n) {
247
+ function T(e, t, n) {
248
248
  if (!e || e.kind === "always") return !0;
249
249
  switch (e.kind) {
250
250
  case "simple": {
251
251
  let n = t[e.input];
252
252
  return n ? n(e.params, e.op, e.value) : !1;
253
253
  }
254
- case "all": return e.of.every((e) => w(e, t, n));
255
- case "any": return e.of.some((e) => w(e, t, n));
256
- case "not": return !w(e.of, t, n);
254
+ case "all": return e.of.every((e) => T(e, t, n));
255
+ case "any": return e.of.some((e) => T(e, t, n));
256
+ case "not": return !T(e.of, t, n);
257
257
  case "graph": {
258
258
  let r = n?.[e.graphId];
259
- return !r || C(r, t).visible;
259
+ return !r || te(r, t).visible;
260
260
  }
261
261
  }
262
262
  }
263
263
  //#endregion
264
264
  //#region src/resolve.ts
265
- function T(e) {
265
+ function E(e) {
266
266
  return typeof e == "object" && !!e && "$t" in e;
267
267
  }
268
- function E(e) {
268
+ function ne(e) {
269
269
  return typeof e == "object" && !!e && "src" in e;
270
270
  }
271
- function D(e) {
271
+ function re(e) {
272
272
  return typeof e == "object" && !!e && "href" in e;
273
273
  }
274
- function O(e, t) {
275
- return e == null ? "" : typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) : T(e) ? t[e.$t] ?? e.$t : "";
274
+ function D(e, t) {
275
+ return e == null ? "" : typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) : E(e) ? t[e.$t] ?? e.$t : "";
276
276
  }
277
277
  //#endregion
278
278
  //#region src/context.ts
279
- var k = Symbol("cms-context");
279
+ var O = Symbol("cms-context");
280
280
  //#endregion
281
281
  //#region src/useField.ts
282
- function A() {
283
- let e = s(k, {
282
+ function ie() {
283
+ let e = l(O, {
284
284
  messages: {},
285
285
  editing: !1,
286
286
  setText: () => {}
287
287
  });
288
- return { t: (t) => O(t, e.messages) };
288
+ return { t: (t) => D(t, e.messages) };
289
+ }
290
+ //#endregion
291
+ //#region src/link.ts
292
+ var k = {
293
+ ok: !1,
294
+ href: "",
295
+ internal: !1,
296
+ newTab: !1,
297
+ status: "empty",
298
+ kind: "none"
299
+ };
300
+ function A(e, t) {
301
+ return {
302
+ ...k,
303
+ status: e,
304
+ kind: t
305
+ };
306
+ }
307
+ function j(e) {
308
+ return e.startsWith("/") && !e.startsWith("//");
309
+ }
310
+ function M(e) {
311
+ return e.startsWith("#") || /^(mailto:|tel:|sms:)/i.test(e);
312
+ }
313
+ function N(e) {
314
+ let t = e.trim();
315
+ return t ? j(t) ? {
316
+ ok: !0,
317
+ href: t,
318
+ internal: !0,
319
+ newTab: !1,
320
+ status: "ok",
321
+ kind: "doc"
322
+ } : {
323
+ ok: !0,
324
+ href: t,
325
+ internal: !1,
326
+ newTab: !M(t),
327
+ status: "ok",
328
+ kind: "url"
329
+ } : k;
330
+ }
331
+ function P(e) {
332
+ return typeof e == "string" ? e.trim() : "";
333
+ }
334
+ function ae(e) {
335
+ let t = P(e);
336
+ return t === "ok" || t === "missing" || t === "unpublished" || t === "empty" || t === "unresolved" ? t : "";
337
+ }
338
+ function F(e, t, n) {
339
+ return M(t) ? !1 : typeof e.newTab == "boolean" ? e.newTab : n;
340
+ }
341
+ function oe(e) {
342
+ let t = P(e.kind), n = ae(e.status), r = P(e.href), i = P(e.route), a = P(e.url), o = t === "doc" || t === "url" || t === "media" ? t : i ? "doc" : a ? "url" : r ? j(r) ? "doc" : "url" : "none";
343
+ if (n && n !== "ok") return A(n, o);
344
+ if (o === "doc") {
345
+ if (!n) return A("unresolved", "doc");
346
+ let t = r || i;
347
+ return t ? {
348
+ ok: !0,
349
+ href: t,
350
+ internal: j(t),
351
+ newTab: F(e, t, !1),
352
+ status: "ok",
353
+ kind: "doc"
354
+ } : A("empty", "doc");
355
+ }
356
+ if (o === "media") {
357
+ let t = r || a || P(e.src);
358
+ return t ? {
359
+ ok: !0,
360
+ href: t,
361
+ internal: j(t),
362
+ newTab: F(e, t, !0),
363
+ status: "ok",
364
+ kind: "media"
365
+ } : A("unresolved", "media");
366
+ }
367
+ let s = r || a;
368
+ return s ? {
369
+ ok: !0,
370
+ href: s,
371
+ internal: j(s),
372
+ newTab: F(e, s, !j(s)),
373
+ status: "ok",
374
+ kind: "url"
375
+ } : A("empty", o);
376
+ }
377
+ function I(e, t = "") {
378
+ if (typeof e == "string") {
379
+ let n = N(e);
380
+ return n.ok || n.status !== "empty" ? n : N(t);
381
+ }
382
+ return e && typeof e == "object" && !Array.isArray(e) ? oe(e) : N(t);
383
+ }
384
+ function L(e, t) {
385
+ if (e) for (let n of t) {
386
+ let t = e[n];
387
+ if (t != null && !(typeof t == "string" && !t.trim())) return t;
388
+ }
389
+ }
390
+ function se(e, t, n = "") {
391
+ return I(L(e, t), n);
392
+ }
393
+ function R(e) {
394
+ if (!e.ok || !e.href) return {};
395
+ let t = { href: e.href };
396
+ return e.newTab && (t.target = "_blank", t.rel = "noopener"), t;
397
+ }
398
+ function z(e) {
399
+ return e.ok && e.href ? "a" : "span";
400
+ }
401
+ function ce(e) {
402
+ return e.ok && e.href ? "" : "cms-link--inert";
403
+ }
404
+ //#endregion
405
+ //#region src/image.ts
406
+ function B(e) {
407
+ if (typeof e == "number" && Number.isFinite(e)) return e;
408
+ if (typeof e == "string" && e.trim() && Number.isFinite(Number(e))) return Number(e);
409
+ }
410
+ function V(e) {
411
+ return typeof e == "string" ? e.trim() : "";
412
+ }
413
+ function H(e, t = {}, n = "") {
414
+ let r = typeof n == "string" ? {
415
+ src: n.trim(),
416
+ alt: ""
417
+ } : n;
418
+ if (typeof e == "string") {
419
+ let t = e.trim();
420
+ return t ? {
421
+ src: t,
422
+ alt: ""
423
+ } : { ...r };
424
+ }
425
+ if (!e || typeof e != "object" || Array.isArray(e)) return { ...r };
426
+ let i = e, a = V(i.src) || V(i.url) || V(i.href);
427
+ if (!a) return { ...r };
428
+ let o = i.alt;
429
+ return {
430
+ src: a,
431
+ alt: typeof o == "string" ? o : o && typeof o == "object" ? D(o, t) : "",
432
+ width: B(i.w) ?? B(i.width),
433
+ height: B(i.h) ?? B(i.height)
434
+ };
435
+ }
436
+ function le(e) {
437
+ return !!H(e).src;
438
+ }
439
+ //#endregion
440
+ //#region src/richtext.ts
441
+ var ue = {
442
+ p: "paragraph",
443
+ h1: "heading1",
444
+ h2: "heading2",
445
+ h3: "heading3",
446
+ h4: "heading4",
447
+ h5: "heading5",
448
+ h6: "heading6",
449
+ ul: "list",
450
+ ol: "oList",
451
+ li: "listItem",
452
+ blockquote: "quote",
453
+ pre: "preformatted",
454
+ code: "code",
455
+ a: "hyperlink",
456
+ img: "image",
457
+ strong: "strong",
458
+ b: "strong",
459
+ em: "em",
460
+ i: "em",
461
+ span: "span",
462
+ br: "break",
463
+ table: "table",
464
+ tr: "row",
465
+ td: "cell",
466
+ th: "cell"
467
+ }, de = /<router-?link\b([^>]*)>/gi, fe = /<\/router-?link\s*>/gi, U = /\s:?to\s*=\s*("([^"]*)"|'([^']*)')/i, pe = /<\/?router-?link\b/i;
468
+ function W(e) {
469
+ if (!pe.test(e)) return e;
470
+ let t = [];
471
+ return e.replace(de, (e, n) => {
472
+ let r = U.exec(n), i = me((r?.[2] ?? r?.[3] ?? "").trim()), a = n.replace(U, ""), o = i ? "a" : "span";
473
+ return t.push(o), i ? `<a href="${G(i)}"${a}>` : `<span${a}>`;
474
+ }).replace(fe, () => `</${t.shift() ?? "a"}>`);
475
+ }
476
+ function me(e) {
477
+ let t = e.slice(0, 1);
478
+ return (t === "'" || t === "\"") && e.endsWith(t) && e.length > 1 ? e.slice(1, -1).trim() : e;
479
+ }
480
+ function G(e) {
481
+ return e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
482
+ }
483
+ var K = /* @__PURE__ */ new Set([
484
+ "area",
485
+ "base",
486
+ "br",
487
+ "col",
488
+ "embed",
489
+ "hr",
490
+ "img",
491
+ "input",
492
+ "link",
493
+ "meta",
494
+ "param",
495
+ "source",
496
+ "track",
497
+ "wbr"
498
+ ]), q = /<(\/?)([a-zA-Z][\w:-]*)((?:"[^"]*"|'[^']*'|[^'">])*?)(\/?)>/g, J = /([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g;
499
+ function he(e) {
500
+ let t = {};
501
+ J.lastIndex = 0;
502
+ let n;
503
+ for (; n = J.exec(e);) {
504
+ let e = n[1];
505
+ e && (t[e] = n[2] ?? n[3] ?? n[4] ?? "");
506
+ }
507
+ return t;
508
+ }
509
+ function ge(e) {
510
+ return Object.entries(e).map(([e, t]) => t === "" ? ` ${e}` : ` ${e}="${G(t)}"`).join("");
511
+ }
512
+ function Y(e) {
513
+ return ue[e.toLowerCase()] ?? "other";
514
+ }
515
+ function _e(e, t) {
516
+ if (!t || !e) return e;
517
+ let n = [], r = "", i = 0;
518
+ q.lastIndex = 0;
519
+ let a;
520
+ for (; a = q.exec(e);) {
521
+ let [o, s, c, l = "", u] = a;
522
+ r += e.slice(i, a.index), i = a.index + o.length;
523
+ let d = c.toLowerCase();
524
+ if (s) {
525
+ let e = n.length - 1;
526
+ for (; e >= 0 && n[e].tag !== d;) e--;
527
+ if (e >= 0) {
528
+ let t = n[e].as;
529
+ n.length = e, r += `</${t}>`;
530
+ } else r += o;
531
+ continue;
532
+ }
533
+ let f = Y(d), p = t[f], m = he(l), h = K.has(d) || !!u;
534
+ if (!p) {
535
+ r += o, h || n.push({
536
+ tag: d,
537
+ as: d
538
+ });
539
+ continue;
540
+ }
541
+ let g = typeof p == "string" ? { class: p } : p({
542
+ type: f,
543
+ tag: d,
544
+ attrs: m
545
+ });
546
+ if (typeof g == "string") {
547
+ r += g, h || n.push({
548
+ tag: d,
549
+ as: d
550
+ });
551
+ continue;
552
+ }
553
+ let _ = (g?.tag ?? d).toLowerCase(), v = {
554
+ ...m,
555
+ ...g?.attrs ?? {}
556
+ };
557
+ g?.class && (v.class = [m.class, g.class].filter(Boolean).join(" ")), r += `<${_}${ge(v)}${h && !K.has(_) ? " /" : ""}>`, h || n.push({
558
+ tag: d,
559
+ as: _
560
+ });
561
+ }
562
+ return r += e.slice(i), r;
563
+ }
564
+ function ve(e) {
565
+ return /<[a-z][\s\S]*>/i.test(e);
566
+ }
567
+ //#endregion
568
+ //#region src/client.ts
569
+ var X = Symbol("cms-client");
570
+ function Z() {
571
+ return typeof window > "u";
572
+ }
573
+ function ye() {
574
+ return typeof window < "u" ? new URLSearchParams(window.location.search) : null;
575
+ }
576
+ function be() {
577
+ let e = ye();
578
+ return e?.has("cms-edit") ? {
579
+ active: !0,
580
+ environment: e.get("cms-env")?.trim() || void 0,
581
+ token: e.get("cms-preview-token")?.trim() || void 0
582
+ } : { active: !1 };
583
+ }
584
+ var xe = { active: !1 };
585
+ function Se(e) {
586
+ if (!e.apiBase) throw Error("createCms: apiBase is required, for example https://cms.example.com");
587
+ if (!e.siteId) throw Error("createCms: siteId is required");
588
+ let t = e.apiBase.replace(/\/$/, ""), n = e.environment || "production", r = e.siteId, i = e.fetch ?? ((e, t) => fetch(e, t)), a = e.preview ?? be;
589
+ function o() {
590
+ try {
591
+ return a() ?? xe;
592
+ } catch {
593
+ return xe;
594
+ }
595
+ }
596
+ function s(e) {
597
+ let i = o(), a = i.active && i.environment || n, s = i.active ? i.token ? `?previewToken=${encodeURIComponent(i.token)}` : "?preview=1" : "";
598
+ return `${t}/api/v1/${r}/${a}/${e.replace(/^\/+/, "")}${s}`;
599
+ }
600
+ async function c(e) {
601
+ let t = o().active || Z() ? "no-store" : "default", n = await i(s(e), { cache: t });
602
+ return n.ok ? {
603
+ status: n.status,
604
+ body: await n.json()
605
+ } : {
606
+ status: n.status,
607
+ body: null
608
+ };
609
+ }
610
+ async function l(e) {
611
+ try {
612
+ let t = await c(e);
613
+ if (!t) return {
614
+ doc: null,
615
+ error: "CMS delivery unreachable",
616
+ outcome: "unavailable"
617
+ };
618
+ if (t.body === null) {
619
+ let e = t.status === 404 || t.status === 410;
620
+ return {
621
+ doc: null,
622
+ error: `CMS delivery ${t.status}`,
623
+ outcome: e ? "missing" : "unavailable"
624
+ };
625
+ }
626
+ let n = t.body;
627
+ return {
628
+ doc: n,
629
+ error: null,
630
+ outcome: n?.zones?.main ? "ok" : "missing"
631
+ };
632
+ } catch {
633
+ return {
634
+ doc: null,
635
+ error: "CMS delivery unreachable",
636
+ outcome: "unavailable"
637
+ };
638
+ }
639
+ }
640
+ async function u(t) {
641
+ if (e.partials === !1) return {
642
+ doc: null,
643
+ error: "CMS partials are off"
644
+ };
645
+ try {
646
+ let e = await c(`_partials/${encodeURIComponent(t)}`);
647
+ if (!e) return {
648
+ doc: null,
649
+ error: "CMS delivery unreachable"
650
+ };
651
+ if (e.body === null) return {
652
+ doc: null,
653
+ error: `CMS delivery ${e.status}`
654
+ };
655
+ let n = e.body;
656
+ return n?.zones?.main?.blocks?.length ? {
657
+ doc: n,
658
+ error: ""
659
+ } : {
660
+ doc: null,
661
+ error: "CMS partial is empty"
662
+ };
663
+ } catch {
664
+ return {
665
+ doc: null,
666
+ error: "CMS delivery unreachable"
667
+ };
668
+ }
669
+ }
670
+ function d(t) {
671
+ return e.navigate ? (e.navigate(t), !0) : e.router ? (e.router.push(t), !0) : !1;
672
+ }
673
+ let f = {
674
+ siteId: r,
675
+ environment: n,
676
+ apiBase: t,
677
+ patchMessageType: e.patchMessageType ?? "nubisco-cms:patch",
678
+ options: e,
679
+ preview: o,
680
+ documentUrl: s,
681
+ navigate: d,
682
+ fetchPage: l,
683
+ fetchPartial: u,
684
+ install(e) {
685
+ e.provide(X, f);
686
+ }
687
+ };
688
+ return f;
689
+ }
690
+ function Q() {
691
+ return l(X, null);
692
+ }
693
+ function Ce() {
694
+ let e = Q();
695
+ if (!e) throw Error("[cms-vue] No CMS client provided. Call app.use(createCms({ siteId }))");
696
+ return e;
697
+ }
698
+ //#endregion
699
+ //#region src/usePage.ts
700
+ function we(e, t) {
701
+ let n = t ?? Q(), r = m(null), i = m(null), a = m("unavailable"), o = m(!1);
702
+ async function s() {
703
+ if (!n) {
704
+ i.value = "CMS client is not configured", a.value = "unavailable";
705
+ return;
706
+ }
707
+ o.value = !0;
708
+ try {
709
+ let t = await n.fetchPage(e);
710
+ r.value = t.doc, i.value = t.error, a.value = t.outcome;
711
+ } finally {
712
+ o.value = !1;
713
+ }
714
+ }
715
+ return {
716
+ doc: r,
717
+ error: i,
718
+ outcome: a,
719
+ loading: o,
720
+ load: s
721
+ };
722
+ }
723
+ //#endregion
724
+ //#region src/usePartial.ts
725
+ var Te = /* @__PURE__ */ new Map();
726
+ function Ee(e) {
727
+ if (!Z()) return Te;
728
+ let t = e ?? c()?.appContext.app;
729
+ return t ? t.__cmsPartialStates ??= /* @__PURE__ */ new Map() : /* @__PURE__ */ new Map();
730
+ }
731
+ function De(e, t) {
732
+ return e ? `${e.siteId}:${e.environment}:${t}` : `:${t}`;
733
+ }
734
+ function Oe() {
735
+ return {
736
+ doc: m(null),
737
+ messages: m({}),
738
+ error: m(null),
739
+ loading: m(!0),
740
+ started: !1,
741
+ ready: null
742
+ };
743
+ }
744
+ function ke(e, t) {
745
+ let n = Ee(t), r = n.get(e);
746
+ return r || (r = Oe(), n.set(e, r)), r;
747
+ }
748
+ function Ae(e, t) {
749
+ if (!e || typeof e != "object") return !1;
750
+ let n = e, r = (typeof n.contentType == "string" ? n.contentType : typeof n.content_type == "string" ? n.content_type : "") === "partial" || n.kind === "partial", i = typeof n.key == "string" ? n.key : typeof n.route == "string" && !n.route.startsWith("/") ? n.route : "";
751
+ return !r && !i ? !1 : !t || i === t || r && i === "";
752
+ }
753
+ function je(e) {
754
+ let t = /* @__PURE__ */ new Set(), n = (e) => {
755
+ if (e) try {
756
+ t.add(new URL(e).origin);
757
+ } catch {}
758
+ };
759
+ n(e?.apiBase);
760
+ for (let t of e?.options.consoleOrigins ?? []) n(t);
761
+ return n(typeof document < "u" ? document.referrer : void 0), Array.from(t);
762
+ }
763
+ function Me(e, t, n) {
764
+ typeof window > "u" || window.addEventListener("message", (r) => {
765
+ if (!e?.preview().active) return;
766
+ if (window.parent !== window) {
767
+ if (r.source !== window.parent || !je(e).includes(r.origin)) return;
768
+ } else if (r.origin !== window.location.origin) return;
769
+ let i = r.data, a = e?.patchMessageType ?? "nubisco-cms:patch";
770
+ !i || i.type !== a || !i.document?.zones?.main || Ae(i.document, t) && (i.messages && typeof i.messages == "object" && (n.messages.value = i.messages), n.doc.value = i.document, n.error.value = "", n.loading.value = !1);
771
+ });
772
+ }
773
+ function Ne(e, t) {
774
+ let n = t ?? Q(), r = ke(De(n, e));
775
+ return r.started || (r.started = !0, n ? (n.options.livePreview !== !1 && n.preview().active && Me(n, e, r), r.ready = n.fetchPartial(e).then((e) => {
776
+ r.doc.value || (r.doc.value = e.doc, r.error.value = e.error, r.loading.value = !1);
777
+ }), r.ready) : (r.error.value = "CMS client is not configured", r.loading.value = !1)), {
778
+ doc: r.doc,
779
+ messages: r.messages,
780
+ error: r.error,
781
+ loading: r.loading,
782
+ whenReady: () => r.ready ?? Promise.resolve()
783
+ };
784
+ }
785
+ function Pe() {
786
+ Te.clear();
787
+ }
788
+ var Fe = "cmsPartials";
789
+ function Ie(e) {
790
+ let t = {};
791
+ for (let [n, r] of Ee(e)) r.loading.value || (t[n] = {
792
+ doc: r.doc.value,
793
+ error: r.error.value
794
+ });
795
+ return t;
796
+ }
797
+ function Le(e, t) {
798
+ if (!(!e || typeof e != "object") && !t?.preview().active) for (let [t, n] of Object.entries(e)) {
799
+ let e = n;
800
+ if (!e || typeof e != "object") continue;
801
+ let r = ke(t);
802
+ r.started || (r.started = !0, r.doc.value = e.doc ?? null, r.error.value = typeof e.error == "string" ? e.error : e.doc ? "" : "CMS partial unavailable", r.loading.value = !1, r.ready = Promise.resolve());
803
+ }
804
+ }
805
+ //#endregion
806
+ //#region src/props.ts
807
+ function Re() {
808
+ return {
809
+ block: {
810
+ type: Object,
811
+ required: !0
812
+ },
813
+ index: {
814
+ type: Number,
815
+ required: !1,
816
+ default: 0
817
+ },
818
+ blocks: {
819
+ type: Array,
820
+ required: !1,
821
+ default: () => []
822
+ },
823
+ context: {
824
+ type: null,
825
+ required: !1,
826
+ default: void 0
827
+ }
828
+ };
829
+ }
830
+ function ze() {
831
+ return Re();
289
832
  }
290
833
  //#endregion
291
834
  //#region src/CmsText.vue?vue&type=script&setup=true&lang.ts
292
- var j = [
835
+ var Be = [
293
836
  "data-cms-block",
294
837
  "data-cms-field",
295
838
  "onKeydown"
296
- ], M = { key: 1 }, N = /*@__PURE__*/ o({
839
+ ], Ve = { key: 1 }, He = /*@__PURE__*/ s({
297
840
  __name: "CmsText",
298
841
  props: {
299
842
  block: {},
300
843
  field: {}
301
844
  },
302
845
  setup(e) {
303
- let n = e, r = s(k, {
846
+ let n = e, r = l(O, {
304
847
  messages: {},
305
848
  editing: !1,
306
849
  setText: () => {}
307
- }), a = t(() => n.block.fields[n.field]), o = t(() => O(a.value, r.messages)), c = d(null);
308
- function u() {
309
- let e = c.value?.innerText.trim() ?? "";
310
- e !== o.value && r.setText(n.block, n.field, a.value, e), c.value?.blur();
850
+ }), a = t(() => n.block.fields[n.field]), o = t(() => D(a.value, r.messages)), s = m(null);
851
+ function c() {
852
+ let e = s.value?.innerText.trim() ?? "";
853
+ e !== o.value && r.setText(n.block, n.field, a.value, e), s.value?.blur();
311
854
  }
312
- return (t, n) => g(r).editing ? (l(), i("span", {
855
+ return (t, n) => y(r).editing ? (f(), i("span", {
313
856
  key: 0,
314
857
  ref_key: "el",
315
- ref: c,
858
+ ref: s,
316
859
  class: "cms-text cms-text--editing",
317
860
  "data-cms-block": e.block.id,
318
861
  "data-cms-field": e.field,
319
862
  contenteditable: "plaintext-only",
320
863
  role: "textbox",
321
864
  tabindex: "0",
322
- onBlur: u,
323
- onKeydown: v(y(u, ["prevent"]), ["enter"])
324
- }, h(o.value), 41, j)) : (l(), i("span", M, h(o.value), 1));
865
+ onBlur: c,
866
+ onKeydown: x(S(c, ["prevent"]), ["enter"])
867
+ }, v(o.value), 41, Be)) : (f(), i("span", Ve, v(o.value), 1));
325
868
  }
326
- }), P = (e, t) => {
869
+ }), $ = (e, t) => {
327
870
  let n = e.__vccOpts || e;
328
871
  for (let [e, r] of t) n[e] = r;
329
872
  return n;
330
- }, F = /*#__PURE__*/ P(N, [["__scopeId", "data-v-57962fd1"]]), I = { class: "bf__type" }, L = {
873
+ }, Ue = /*#__PURE__*/ $(He, [["__scopeId", "data-v-57962fd1"]]), We = { class: "bf__type" }, Ge = {
331
874
  key: 0,
332
875
  class: "bf__badge"
333
- }, R = ["disabled"], z = ["disabled"], B = { class: "bf__body" }, V = /*#__PURE__*/ P(/* @__PURE__ */ o({
876
+ }, Ke = ["disabled"], qe = ["disabled"], Je = { class: "bf__body" }, Ye = /*#__PURE__*/ $(/* @__PURE__ */ s({
334
877
  __name: "BlockFrame",
335
878
  props: {
336
879
  label: {},
@@ -345,7 +888,7 @@ var j = [
345
888
  "select"
346
889
  ],
347
890
  setup(e) {
348
- return (t, n) => (l(), i("div", { class: c(["bf", {
891
+ return (t, n) => (f(), i("div", { class: d(["bf", {
349
892
  "bf--dim": e.hidden,
350
893
  "bf--selected": e.selected
351
894
  }]) }, [a("div", {
@@ -356,32 +899,32 @@ var j = [
356
899
  class: "bf__grip",
357
900
  "aria-hidden": "true"
358
901
  }, "⠿", -1),
359
- a("span", I, h(e.label), 1),
360
- e.hidden ? (l(), i("span", L, "hidden by condition")) : r("", !0),
902
+ a("span", We, v(e.label), 1),
903
+ e.hidden ? (f(), i("span", Ge, "hidden by condition")) : r("", !0),
361
904
  n[4] ||= a("span", { class: "bf__spacer" }, null, -1),
362
905
  a("button", {
363
906
  class: "bf__btn",
364
907
  type: "button",
365
908
  disabled: e.isFirst,
366
909
  title: "Move up",
367
- onClick: n[0] ||= y((e) => t.$emit("up"), ["stop"])
368
- }, " ↑ ", 8, R),
910
+ onClick: n[0] ||= S((e) => t.$emit("up"), ["stop"])
911
+ }, " ↑ ", 8, Ke),
369
912
  a("button", {
370
913
  class: "bf__btn",
371
914
  type: "button",
372
915
  disabled: e.isLast,
373
916
  title: "Move down",
374
- onClick: n[1] ||= y((e) => t.$emit("down"), ["stop"])
375
- }, " ↓ ", 8, z)
376
- ]), a("div", B, [p(t.$slots, "default", {}, void 0, !0)])], 2));
917
+ onClick: n[1] ||= S((e) => t.$emit("down"), ["stop"])
918
+ }, " ↓ ", 8, qe)
919
+ ]), a("div", Je, [g(t.$slots, "default", {}, void 0, !0)])], 2));
377
920
  }
378
- }), [["__scopeId", "data-v-22d52899"]]), H = { class: "cms-zone" }, U = {
921
+ }), [["__scopeId", "data-v-22d52899"]]), Xe = { class: "cms-zone" }, Ze = {
379
922
  key: 1,
380
923
  class: "cms-zone__missing"
381
- }, W = {
924
+ }, Qe = {
382
925
  key: 1,
383
926
  class: "cms-zone__missing"
384
- }, G = /*#__PURE__*/ P(/* @__PURE__ */ o({
927
+ }, $e = /*#__PURE__*/ $(/* @__PURE__ */ s({
385
928
  __name: "CmsZone",
386
929
  props: {
387
930
  zone: {},
@@ -391,12 +934,14 @@ var j = [
391
934
  editing: { type: Boolean },
392
935
  selectedId: {},
393
936
  graphs: {},
937
+ provideBlockProps: { type: Boolean },
938
+ context: {},
394
939
  setText: { type: Function }
395
940
  },
396
941
  emits: ["select"],
397
942
  setup(r, { emit: a }) {
398
943
  let o = r, s = a;
399
- u(k, {
944
+ p(O, {
400
945
  get messages() {
401
946
  return o.messages;
402
947
  },
@@ -406,10 +951,17 @@ var j = [
406
951
  setText: (e, t, n, r) => o.setText?.(e, t, n, r)
407
952
  });
408
953
  function c(e) {
409
- return w(e.when, o.env, o.graphs);
954
+ return T(e.when, o.env, o.graphs);
955
+ }
956
+ let l = t(() => o.zone.blocks.filter(c));
957
+ function d(e) {
958
+ if (o.provideBlockProps) return {
959
+ index: e,
960
+ blocks: o.zone.blocks,
961
+ context: o.context
962
+ };
410
963
  }
411
- let d = t(() => o.zone.blocks.filter(c));
412
- function p(e) {
964
+ function m(e) {
413
965
  return e.type + (e.variation ? ` · ${e.variation}` : "");
414
966
  }
415
967
  function g(e, t) {
@@ -418,9 +970,9 @@ var j = [
418
970
  let [r] = n.splice(e, 1);
419
971
  n.splice(t, 0, r);
420
972
  }
421
- return (t, a) => (l(), i("div", H, [r.editing ? (l(!0), i(e, { key: 0 }, f(r.zone.blocks, (e, t) => (l(), n(V, {
973
+ return (t, a) => (f(), i("div", Xe, [r.editing ? (f(!0), i(e, { key: 0 }, h(r.zone.blocks, (e, t) => (f(), n(Ye, {
422
974
  key: e.id,
423
- label: p(e),
975
+ label: m(e),
424
976
  hidden: !c(e),
425
977
  "is-first": t === 0,
426
978
  "is-last": t === r.zone.blocks.length - 1,
@@ -429,10 +981,10 @@ var j = [
429
981
  onDown: (e) => g(t, t + 1),
430
982
  onSelect: (t) => s("select", e.id)
431
983
  }, {
432
- default: _(() => [r.registry[e.type] ? (l(), n(m(r.registry[e.type]), {
984
+ default: b(() => [r.registry[e.type] ? (f(), n(_(r.registry[e.type]), u({
433
985
  key: 0,
434
986
  block: e
435
- }, null, 8, ["block"])) : (l(), i("div", U, "Unknown block type: " + h(e.type), 1))]),
987
+ }, { ref_for: !0 }, d(t)), null, 16, ["block"])) : (f(), i("div", Ze, "Unknown block type: " + v(e.type), 1))]),
436
988
  _: 2
437
989
  }, 1032, [
438
990
  "label",
@@ -443,11 +995,169 @@ var j = [
443
995
  "onUp",
444
996
  "onDown",
445
997
  "onSelect"
446
- ]))), 128)) : (l(!0), i(e, { key: 1 }, f(d.value, (t) => (l(), i(e, { key: t.id }, [r.registry[t.type] ? (l(), n(m(r.registry[t.type]), {
998
+ ]))), 128)) : (f(!0), i(e, { key: 1 }, h(l.value, (t, a) => (f(), i(e, { key: t.id }, [r.registry[t.type] ? (f(), n(_(r.registry[t.type]), u({
447
999
  key: 0,
448
1000
  block: t
449
- }, null, 8, ["block"])) : (l(), i("div", W, "Unknown block type: " + h(t.type), 1))], 64))), 128))]));
1001
+ }, { ref_for: !0 }, d(a)), null, 16, ["block"])) : (f(), i("div", Qe, "Unknown block type: " + v(t.type), 1))], 64))), 128))]));
1002
+ }
1003
+ }), [["__scopeId", "data-v-0da60d15"]]), et = /* @__PURE__ */ s({
1004
+ __name: "CmsRichText",
1005
+ props: {
1006
+ block: {},
1007
+ field: {},
1008
+ value: {},
1009
+ serializers: {},
1010
+ as: { default: "div" },
1011
+ plainAs: { default: "p" },
1012
+ transform: {}
1013
+ },
1014
+ setup(e, { expose: i }) {
1015
+ let a = e, s = l(O, {
1016
+ messages: {},
1017
+ editing: !1,
1018
+ setText: () => {}
1019
+ }), c = Q(), u = t(() => a.block?.fields);
1020
+ function d(e) {
1021
+ return e === void 0 ? [] : typeof e == "string" ? [e] : e;
1022
+ }
1023
+ let p = t(() => {
1024
+ if (!a.block) return;
1025
+ let e = u.value;
1026
+ return d(a.field).find((t) => e && e[t] !== void 0 && e[t] !== null);
1027
+ }), m = t(() => a.block?.id), h = t(() => a.value === void 0 ? L(u.value, d(a.field)) : a.value), g = t(() => D(h.value, s.messages)), y = t(() => ve(g.value)), x = t(() => y.value ? "" : g.value), S = t(() => {
1028
+ let e = _e(W(g.value), a.serializers);
1029
+ return a.transform && (e = a.transform(e)), e;
1030
+ });
1031
+ function C(e) {
1032
+ if (!c || e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
1033
+ let t = e.target?.closest?.("a");
1034
+ if (!t || t.hasAttribute("download")) return;
1035
+ let n = t.getAttribute("target");
1036
+ if (n && n !== "_self") return;
1037
+ let r = t.getAttribute("href") ?? "";
1038
+ !r.startsWith("/") || r.startsWith("//") || c.navigate(r) && e.preventDefault();
1039
+ }
1040
+ return i({
1041
+ html: S,
1042
+ plain: x
1043
+ }), (t, i) => y.value ? (f(), n(_(e.as), {
1044
+ key: 0,
1045
+ class: "cms-richtext-body",
1046
+ "data-cms-block": m.value,
1047
+ "data-cms-field": p.value,
1048
+ "data-cms-field-kind": "richtext",
1049
+ onClick: C,
1050
+ innerHTML: S.value
1051
+ }, null, 8, [
1052
+ "data-cms-block",
1053
+ "data-cms-field",
1054
+ "innerHTML"
1055
+ ])) : x.value ? (f(), n(_(e.plainAs), {
1056
+ key: 1,
1057
+ class: "cms-richtext-body",
1058
+ "data-cms-block": m.value,
1059
+ "data-cms-field": p.value,
1060
+ "data-cms-field-kind": "richtext"
1061
+ }, {
1062
+ default: b(() => [o(v(x.value), 1)]),
1063
+ _: 1
1064
+ }, 8, ["data-cms-block", "data-cms-field"])) : r("", !0);
1065
+ }
1066
+ }), tt = /*#__PURE__*/ $(/* @__PURE__ */ s({
1067
+ __name: "CmsLink",
1068
+ props: {
1069
+ block: {},
1070
+ field: {},
1071
+ value: {},
1072
+ fallback: {},
1073
+ label: {},
1074
+ labelField: {}
1075
+ },
1076
+ setup(e, { expose: r }) {
1077
+ let i = e, a = l(O, {
1078
+ messages: {},
1079
+ editing: !1,
1080
+ setText: () => {}
1081
+ }), s = Q(), c = t(() => i.block?.fields);
1082
+ function d(e) {
1083
+ return e === void 0 ? [] : typeof e == "string" ? [e] : e;
1084
+ }
1085
+ let p = t(() => {
1086
+ if (!i.block) return;
1087
+ let e = c.value;
1088
+ return d(i.field).find((t) => e && e[t] !== void 0 && e[t] !== null);
1089
+ }), m = t(() => i.block?.id), h = t(() => i.value === void 0 ? L(c.value, d(i.field)) : i.value), y = t(() => I(h.value, i.fallback ?? "")), x = t(() => z(y.value)), S = t(() => R(y.value)), C = t(() => {
1090
+ if (i.label !== void 0) return D(i.label, a.messages);
1091
+ let e = L(c.value, d(i.labelField));
1092
+ return e === void 0 ? "" : D(e, a.messages);
1093
+ });
1094
+ r({ link: y });
1095
+ function w(e) {
1096
+ let t = y.value;
1097
+ !t.ok || !t.internal || !t.href || t.newTab || e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || s && s.navigate(t.href) && e.preventDefault();
1098
+ }
1099
+ return (e, t) => (f(), n(_(x.value), u(S.value, {
1100
+ class: ["cms-link", y.value.ok && y.value.href ? "" : "cms-link--inert"],
1101
+ "data-cms-block": m.value,
1102
+ "data-cms-field": p.value,
1103
+ "data-cms-link-status": y.value.status,
1104
+ onClick: w
1105
+ }), {
1106
+ default: b(() => [g(e.$slots, "default", { link: y.value }, () => [o(v(C.value), 1)], !0)]),
1107
+ _: 3
1108
+ }, 16, [
1109
+ "class",
1110
+ "data-cms-block",
1111
+ "data-cms-field",
1112
+ "data-cms-link-status"
1113
+ ]));
1114
+ }
1115
+ }), [["__scopeId", "data-v-c487c13b"]]), nt = [
1116
+ "src",
1117
+ "alt",
1118
+ "width",
1119
+ "height",
1120
+ "data-cms-block",
1121
+ "data-cms-field"
1122
+ ], rt = /* @__PURE__ */ s({
1123
+ __name: "CmsImage",
1124
+ props: {
1125
+ block: {},
1126
+ field: {},
1127
+ value: {},
1128
+ fallback: {},
1129
+ alt: {}
1130
+ },
1131
+ setup(e, { expose: n }) {
1132
+ let a = e, o = l(O, {
1133
+ messages: {},
1134
+ editing: !1,
1135
+ setText: () => {}
1136
+ }), s = t(() => a.block?.fields);
1137
+ function c(e) {
1138
+ return e === void 0 ? [] : typeof e == "string" ? [e] : e;
1139
+ }
1140
+ let u = t(() => {
1141
+ if (!a.block) return;
1142
+ let e = s.value;
1143
+ return c(a.field).find((t) => e && e[t] !== void 0 && e[t] !== null);
1144
+ }), d = t(() => a.block?.id), p = t(() => a.value === void 0 ? L(s.value, c(a.field)) : a.value), m = t(() => {
1145
+ let e = H(p.value, o.messages, a.fallback ?? "");
1146
+ return a.alt === void 0 ? e : {
1147
+ ...e,
1148
+ alt: a.alt
1149
+ };
1150
+ });
1151
+ return n({ image: m }), (e, t) => m.value.src ? (f(), i("img", {
1152
+ key: 0,
1153
+ src: m.value.src,
1154
+ alt: m.value.alt,
1155
+ width: m.value.width,
1156
+ height: m.value.height,
1157
+ "data-cms-block": d.value,
1158
+ "data-cms-field": u.value
1159
+ }, null, 8, nt)) : r("", !0);
450
1160
  }
451
- }), [["__scopeId", "data-v-b1bd4d10"]]);
1161
+ });
452
1162
  //#endregion
453
- export { k as CMS_CONTEXT, b as CORE_LOGIC_INPUTS, F as CmsText, G as CmsZone, x as NODE_SPECS, w as evaluate, C as evaluateGraph, E as isImage, D as isLink, T as isTRef, O as text, S as toCards, A as useField };
1163
+ export { X as CMS_CLIENT, O as CMS_CONTEXT, Fe as CMS_PARTIAL_STATE_KEY, C as CORE_LOGIC_INPUTS, rt as CmsImage, tt as CmsLink, et as CmsRichText, Ue as CmsText, $e as CmsZone, w as NODE_SPECS, _e as applySerializers, W as compileLinks, Se as createCms, ze as defineBlock, T as evaluate, te as evaluateGraph, Re as getBlockComponentProps, le as hasImage, Le as hydrateCmsPartials, ve as isHtml, ne as isImage, j as isInternalHref, re as isLink, Ae as isPartialDocument, Z as isServerRender, E as isTRef, R as linkAttrs, ce as linkClass, z as linkTag, Y as nodeTypeOf, H as normalizeImage, I as normalizeLink, L as pickField, se as pickLink, be as readPreviewFromLocation, Pe as resetCmsPartials, Ie as snapshotCmsPartials, D as text, ee as toCards, Q as useCms, Ce as useCmsOrThrow, we as useCmsPage, Ne as useCmsPartial, ie as useField };