@blogmcp/community 0.3.1 → 0.4.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.
@@ -1,10 +1,11 @@
1
1
  import { reactive, provide, inject, onMounted, onBeforeUnmount, nextTick, defineComponent, ref, computed, createElementBlock, createCommentVNode, unref, openBlock, createElementVNode, toDisplayString, shallowRef, normalizeClass, watch, withModifiers, withDirectives, Fragment, vModelText, renderList, normalizeStyle, createTextVNode, withKeys, resolveComponent, createVNode, createBlock, vModelRadio, vModelCheckbox, vModelSelect, useHost, renderSlot, defineCustomElement } from "vue";
2
- import { COMMUNITY_ROUTES, isKnownModuleState, isRelativeCommunityBase, createCommunityClient, hasCommunityMessage, communityMessage, communityMentionSpans, COMMUNITY_DISPLAY_NAME_MIN, COMMUNITY_DISPLAY_NAME_MAX, COMMUNITY_HANDLE_RE, isKnownNeed, art9ConsentLayoutOf, art9RefusalOf, communityRulesOf, art9ControllersOf, createDiscussionStore, createTopicStore, viewerNeeds, isOwnMessage, findMessage, COMMUNITY_REPORT_NOTE_MAX, reactionsFor, reactionAfter, newClientMsgId, COMMUNITY_MESSAGE_MAX, forumTopicTitleOf, isTopicOpen, loadMoreTopic, refreshTopic, loadMoreDiscussion, refreshDiscussion, pollTopicHead, pollDiscussionHead, communityMentionHandles, surfaceInfoOf, settleTopicFailure, topicTitleLength, COMMUNITY_TOPIC_TITLE_MAX, COMMUNITY_MESSAGE_LINKS_MAX, confirmMessageKey, profilePath, communityMessageAnchor, noteMessageKey, warningMessageKey, AGE_BANDS, COMMUNITY_HANDLE_CHANGE_DAYS, CASE_CATEGORIES, statementPath, communityMessageSeqFromHash, signInLink, followKeyOf, COMMUNITY_FOLLOWS_MAX, followTargetOf, communityAwayOf, COMMUNITY_TOPICS_PAGE_SIZE, knownTopicItemsOf, topicTitleOf, topicPath, communityArticleLink, ESCALATION_CATEGORIES, topicMessageLink, MODERATION_RESTRICTIONS, nextSearchPage, forumSearchQueryOf, COMMUNITY_SEARCH_QUERY_MAX, COMMUNITY_SEARCH_PAGES_MAX, COMMUNITY_SEARCH_QUERY_MIN, communityMessageLink, categoryPath, digestTokenFromHash, readDigestTokenFromHash, forgetDigestToken, isInAppBrowser, COMMUNITY_APPEAL_MAX, isKnownNotificationCode, receiptFromHash, readReceiptFromHash, adverseOutcomeMessageKey, COMMUNITY_GOOD_FAITH, noticeStatusLink, COMMUNITY_NOTICE_DESCRIPTION_MAX, COMMUNITY_NOTIFIER_NAME_MAX, CATEGORY_WITHOUT_NOTIFIER, COMMUNITY_NOTICE_TURNSTILE_ACTION, notificationItemMessageKey, isKnownAuthor, trustLabelMessageKey, isCategoryModerator } from "@blogmcp/sdk/community";
2
+ import { COMMUNITY_ROUTES, isKnownModuleState, isRelativeCommunityBase, createCommunityClient, hasCommunityMessage, communityMessage, communityMentionSpans, COMMUNITY_DISPLAY_NAME_MIN, COMMUNITY_DISPLAY_NAME_MAX, COMMUNITY_HANDLE_RE, isKnownNeed, viewerNeeds, art9ConsentLayoutOf, art9RefusalOf, communityRulesOf, art9ControllersOf, createDiscussionStore, createTopicStore, isOwnMessage, findMessage, COMMUNITY_REPORT_NOTE_MAX, reactionsFor, reactionAfter, newClientMsgId, COMMUNITY_MESSAGE_MAX, forumTopicTitleOf, isTopicOpen, loadMoreTopic, refreshTopic, loadMoreDiscussion, refreshDiscussion, pollTopicHead, pollDiscussionHead, communityMentionHandles, surfaceInfoOf, settleTopicFailure, topicTitleLength, COMMUNITY_TOPIC_TITLE_MAX, COMMUNITY_MESSAGE_LINKS_MAX, confirmMessageKey, profilePath, communityMessageAnchor, noteMessageKey, warningMessageKey, AGE_BANDS, COMMUNITY_HANDLE_CHANGE_DAYS, CASE_CATEGORIES, statementPath, communityMessageSeqFromHash, signInLink, followKeyOf, COMMUNITY_FOLLOWS_MAX, followTargetOf, communityAwayOf, COMMUNITY_TOPICS_PAGE_SIZE, knownTopicItemsOf, topicTitleOf, topicPath, communityArticleLink, ESCALATION_CATEGORIES, topicMessageLink, MODERATION_RESTRICTIONS, nextSearchPage, forumSearchQueryOf, COMMUNITY_SEARCH_QUERY_MAX, COMMUNITY_SEARCH_PAGES_MAX, COMMUNITY_SEARCH_QUERY_MIN, communityMessageLink, categoryPath, digestTokenFromHash, readDigestTokenFromHash, forgetDigestToken, isInAppBrowser, COMMUNITY_APPEAL_MAX, isKnownNotificationCode, receiptFromHash, readReceiptFromHash, adverseOutcomeMessageKey, COMMUNITY_GOOD_FAITH, noticeStatusLink, COMMUNITY_NOTICE_DESCRIPTION_MAX, COMMUNITY_NOTIFIER_NAME_MAX, CATEGORY_WITHOUT_NOTIFIER, COMMUNITY_NOTICE_TURNSTILE_ACTION, notificationItemMessageKey, isKnownAuthor, trustLabelMessageKey, isCategoryModerator } from "@blogmcp/sdk/community";
3
3
  import { sanitizeUrl } from "@blogmcp/sanitize/url";
4
4
  const ROUTE_KEYS = [
5
5
  "statementPath",
6
6
  "myCommunityPath",
7
7
  "rulesPath",
8
+ "termsPath",
8
9
  "reportPath",
9
10
  "noticesPath",
10
11
  "consultationPath",
@@ -52,6 +53,7 @@ function routesWithDefaults(routes, tenant, siteBase = "") {
52
53
  statementPath: routes.statementPath ?? site(tenant?.statementPath) ?? `${siteBase}${COMMUNITY_ROUTES.statement}`,
53
54
  myCommunityPath: routes.myCommunityPath ?? site(tenant?.myCommunityPath) ?? `${siteBase}${COMMUNITY_ROUTES.myCommunity}`,
54
55
  rulesPath: routes.rulesPath ?? `${siteBase}${COMMUNITY_ROUTES.rules}`,
56
+ termsPath: routes.termsPath ?? termsBeside(routes.rulesPath ?? `${siteBase}${COMMUNITY_ROUTES.rules}`),
55
57
  reportPath: routes.reportPath ?? `${siteBase}${COMMUNITY_ROUTES.report}`,
56
58
  noticesPath: routes.noticesPath ?? `${siteBase}${COMMUNITY_ROUTES.notices}`,
57
59
  consultationPath: routes.consultationPath ?? null,
@@ -68,6 +70,9 @@ function routesWithDefaults(routes, tenant, siteBase = "") {
68
70
  searchPath: routes.searchPath ?? `${siteBase}${COMMUNITY_ROUTES.search}`
69
71
  };
70
72
  }
73
+ function termsBeside(rulesPath) {
74
+ return rulesPath.endsWith(COMMUNITY_ROUTES.rules) ? `${rulesPath.slice(0, -COMMUNITY_ROUTES.rules.length)}${COMMUNITY_ROUTES.terms}` : null;
75
+ }
71
76
  const ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
72
77
  const HANDLE_RE = /^[a-z0-9][a-z0-9_]{2,29}$/;
73
78
  const isId = (v) => typeof v === "string" && ID_RE.test(v);
@@ -581,7 +586,7 @@ function suggestedHandle(displayName) {
581
586
  return COMMUNITY_HANDLE_RE.test(stem) ? stem : null;
582
587
  }
583
588
  const PROFILE_FIELDS = /* @__PURE__ */ new Set(["displayName", "handle", "avatarPreset"]);
584
- const TEXT_FIELDS = /* @__PURE__ */ new Set(["rulesTextId", "art9TextId"]);
589
+ const TEXT_FIELDS = /* @__PURE__ */ new Set(["rulesTextId", "termsTextId", "art9TextId"]);
585
590
  const ART9_REFUSAL_READ_ONLY = "art9_refusal_read_only";
586
591
  const refusalRefused = (f) => f.code === "invalid" && f.issueCodes?.includes(ART9_REFUSAL_READ_ONLY) === true;
587
592
  function onboardingFailureText(failure, lang) {
@@ -590,7 +595,7 @@ function onboardingFailureText(failure, lang) {
590
595
  function stepsOf(me, needs, offerArt9, forceArt9) {
591
596
  const steps = [];
592
597
  if (!me.member?.ageBand) steps.push("age");
593
- if (me.acceptances.rules !== "accepted") steps.push("rules");
598
+ if (me.acceptances.rules !== "accepted" || termsAsked(me)) steps.push("rules");
594
599
  const art9 = me.acceptances.art9Consent;
595
600
  const refusedOpen = me.acceptances.art9Refused === true && art9RefusalOf(me.settings?.art9Refusal) === "public_write";
596
601
  const forced = forceArt9 && art9 !== "accepted" && !refusedOpen;
@@ -598,6 +603,7 @@ function stepsOf(me, needs, offerArt9, forceArt9) {
598
603
  if (!me.profile) steps.push("profile");
599
604
  return steps;
600
605
  }
606
+ const termsAsked = (me) => viewerNeeds(me).terms;
601
607
  function consentsOf(text, layout) {
602
608
  if (!text) return [];
603
609
  const listed = art9ControllersOf(text.bodyJson);
@@ -615,6 +621,8 @@ function createOnboarding(o) {
615
621
  me: null,
616
622
  rulesText: null,
617
623
  rules: [],
624
+ termsText: null,
625
+ termsParagraphs: [],
618
626
  art9Text: null,
619
627
  art9Paragraphs: [],
620
628
  art9Layout: "joint",
@@ -643,18 +651,20 @@ function createOnboarding(o) {
643
651
  state.failure = failure;
644
652
  state.phase = "failed";
645
653
  };
646
- async function textsFor(steps) {
647
- const [rules, art9] = await Promise.all([
654
+ async function textsFor(steps, withTerms) {
655
+ const askTerms = withTerms && steps.includes("rules");
656
+ const [rules, terms, art9] = await Promise.all([
648
657
  steps.includes("rules") ? o.client.legal.current({ kind: "rules", locale: o.lang }, call) : null,
658
+ askTerms ? o.client.legal.current({ kind: "terms", locale: o.lang }, call) : null,
649
659
  steps.includes("art9") ? o.client.legal.current({ kind: "art9_consent", locale: o.lang }, call) : null
650
660
  ]);
651
- for (const r of [rules, art9]) {
661
+ for (const r of [rules, terms, art9]) {
652
662
  if (r && !r.ok) {
653
663
  fail(r);
654
664
  return null;
655
665
  }
656
666
  }
657
- return { rules: rules?.ok ? rules.value : null, art9: art9?.ok ? art9.value : null };
667
+ return { rules: rules?.ok ? rules.value : null, terms: terms?.ok ? terms.value : null, art9: art9?.ok ? art9.value : null };
658
668
  }
659
669
  async function read() {
660
670
  const me = await o.client.me.get(call);
@@ -668,12 +678,12 @@ function createOnboarding(o) {
668
678
  return null;
669
679
  }
670
680
  const steps = stepsOf(me.value, needs, offerArt9, forceArt9);
671
- const texts = await textsFor(steps);
681
+ const texts = await textsFor(steps, termsAsked(me.value));
672
682
  return texts ? { me: me.value, steps, texts } : null;
673
683
  }
674
684
  const refusalOffered = () => !offerArt9 && state.art9Refusal === "public_write";
675
685
  function apply(r) {
676
- if (r.texts.rules?.textId !== state.rulesText?.textId) state.rulesAccepted = false;
686
+ if (r.texts.rules?.textId !== state.rulesText?.textId || r.texts.terms?.textId !== state.termsText?.textId) state.rulesAccepted = false;
677
687
  const layout = art9ConsentLayoutOf(r.me.settings?.art9ConsentLayout);
678
688
  const sameText = r.texts.art9 !== null && r.texts.art9.textId === state.art9Text?.textId;
679
689
  state.art9Controllers = consentsOf(r.texts.art9, layout).map((c, i) => {
@@ -688,6 +698,8 @@ function createOnboarding(o) {
688
698
  state.reconsent = r.me.acceptances.rules === "reconsent_required";
689
699
  state.rulesText = r.texts.rules;
690
700
  state.rules = r.texts.rules ? communityRulesOf(r.texts.rules.bodyJson) : [];
701
+ state.termsText = r.texts.terms;
702
+ state.termsParagraphs = r.texts.terms ? htmlToParagraphs(r.texts.terms.body) : [];
691
703
  state.art9Text = r.texts.art9;
692
704
  state.art9Paragraphs = r.texts.art9 ? htmlToParagraphs(r.texts.art9.body) : [];
693
705
  }
@@ -745,6 +757,7 @@ function createOnboarding(o) {
745
757
  ageBand: state.ageBand ?? state.me?.member?.ageBand ?? "18_plus",
746
758
  rulesTextId: state.steps.includes("rules") && state.rulesText ? state.rulesText.textId : ""
747
759
  };
760
+ if (state.steps.includes("rules") && state.termsText) input.termsTextId = state.termsText.textId;
748
761
  let refusing = false;
749
762
  if (state.steps.includes("art9") && state.art9Text) {
750
763
  if (state.art9Accepted) input.art9TextId = state.art9Text.textId;
@@ -807,7 +820,7 @@ function createOnboarding(o) {
807
820
  const r = await read();
808
821
  if (!r) return;
809
822
  apply(r);
810
- if (named.includes("rulesTextId")) state.rulesAccepted = false;
823
+ if (named.includes("rulesTextId") || named.includes("termsTextId")) state.rulesAccepted = false;
811
824
  if (named.includes("art9TextId")) state.art9Accepted = false;
812
825
  state.failure = refusal;
813
826
  state.fields = named;
@@ -2397,56 +2410,60 @@ const _hoisted_14$h = {
2397
2410
  class: "bcm-hint"
2398
2411
  };
2399
2412
  const _hoisted_15$g = ["href"];
2400
- const _hoisted_16$f = { class: "bcm-check" };
2401
- const _hoisted_17$f = {
2413
+ const _hoisted_16$f = ["href"];
2414
+ const _hoisted_17$f = ["id"];
2415
+ const _hoisted_18$f = ["aria-labelledby"];
2416
+ const _hoisted_19$f = { class: "bcm-check" };
2417
+ const _hoisted_20$f = {
2402
2418
  key: 3,
2403
2419
  class: "bcm-section"
2404
2420
  };
2405
- const _hoisted_18$f = ["aria-label"];
2406
- const _hoisted_19$f = {
2421
+ const _hoisted_21$e = ["aria-label"];
2422
+ const _hoisted_22$d = {
2407
2423
  key: 0,
2408
2424
  class: "bcm-fieldset"
2409
2425
  };
2410
- const _hoisted_20$f = { class: "bcm-sr" };
2411
- const _hoisted_21$e = ["onUpdate:modelValue"];
2412
- const _hoisted_22$d = {
2426
+ const _hoisted_23$c = { class: "bcm-sr" };
2427
+ const _hoisted_24$b = ["onUpdate:modelValue"];
2428
+ const _hoisted_25$a = {
2413
2429
  key: 1,
2414
2430
  class: "bcm-check"
2415
2431
  };
2416
- const _hoisted_23$c = {
2432
+ const _hoisted_26$a = {
2417
2433
  key: 4,
2418
2434
  class: "bcm-section"
2419
2435
  };
2420
- const _hoisted_24$b = { class: "bcm-field" };
2421
- const _hoisted_25$a = ["for"];
2422
- const _hoisted_26$a = ["id", "maxlength", "aria-invalid", "aria-describedby"];
2423
- const _hoisted_27$8 = ["id"];
2424
- const _hoisted_28$8 = { class: "bcm-field" };
2425
- const _hoisted_29$7 = ["for"];
2426
- const _hoisted_30$6 = ["id", "maxlength", "placeholder", "aria-invalid", "aria-describedby"];
2427
- const _hoisted_31$5 = ["id"];
2428
- const _hoisted_32$5 = {
2436
+ const _hoisted_27$8 = { class: "bcm-field" };
2437
+ const _hoisted_28$8 = ["for"];
2438
+ const _hoisted_29$7 = ["id", "maxlength", "aria-invalid", "aria-describedby"];
2439
+ const _hoisted_30$6 = ["id"];
2440
+ const _hoisted_31$5 = { class: "bcm-field" };
2441
+ const _hoisted_32$5 = ["for"];
2442
+ const _hoisted_33$5 = ["id", "maxlength", "placeholder", "aria-invalid", "aria-describedby"];
2443
+ const _hoisted_34$4 = ["id"];
2444
+ const _hoisted_35$3 = {
2429
2445
  key: 0,
2430
2446
  class: "bcm-hint"
2431
2447
  };
2432
- const _hoisted_33$5 = { class: "bcm-choices" };
2433
- const _hoisted_34$4 = { class: "bcm-choice" };
2434
- const _hoisted_35$3 = ["name"];
2435
- const _hoisted_36$3 = ["name", "value"];
2436
- const _hoisted_37$2 = {
2448
+ const _hoisted_36$3 = { class: "bcm-choices" };
2449
+ const _hoisted_37$2 = { class: "bcm-choice" };
2450
+ const _hoisted_38$2 = ["name"];
2451
+ const _hoisted_39$2 = ["name", "value"];
2452
+ const _hoisted_40$2 = {
2437
2453
  key: 5,
2438
2454
  class: "bcm-error",
2439
2455
  role: "alert"
2440
2456
  };
2441
- const _hoisted_38$2 = { class: "bcm-row" };
2442
- const _hoisted_39$2 = ["disabled"];
2443
- const _hoisted_40$2 = ["disabled"];
2444
- const _hoisted_41$2 = ["disabled"];
2457
+ const _hoisted_41$2 = { class: "bcm-row" };
2458
+ const _hoisted_42$2 = ["disabled"];
2459
+ const _hoisted_43$2 = ["disabled"];
2460
+ const _hoisted_44$2 = ["disabled"];
2445
2461
  const _sfc_main$l = /* @__PURE__ */ defineComponent({
2446
2462
  __name: "OnboardingSteps",
2447
2463
  props: {
2448
2464
  model: {},
2449
- rulesHref: {}
2465
+ rulesHref: {},
2466
+ termsHref: {}
2450
2467
  },
2451
2468
  emits: ["cancel"],
2452
2469
  setup(__props, { emit: __emit }) {
@@ -2458,6 +2475,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2458
2475
  const heading = ref(null);
2459
2476
  const step = computed(() => props.model.step());
2460
2477
  const fresh = computed(() => s.steps.includes("profile"));
2478
+ const termsLink = computed(() => props.termsHref !== void 0 ? props.termsHref : termsBeside(props.rulesHref));
2461
2479
  const failure = computed(() => {
2462
2480
  const f = s.failure;
2463
2481
  if (!f) return "";
@@ -2550,18 +2568,48 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2550
2568
  href: __props.rulesHref,
2551
2569
  target: "_blank",
2552
2570
  rel: "noopener"
2553
- }, toDisplayString(unref(t)("onboarding.rulesLink")), 9, _hoisted_15$g)
2571
+ }, toDisplayString(unref(t)("onboarding.rulesLink")), 9, _hoisted_15$g),
2572
+ unref(s).termsText && termsLink.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2573
+ _cache[14] || (_cache[14] = createTextVNode(" · ", -1)),
2574
+ createElementVNode("a", {
2575
+ href: termsLink.value,
2576
+ target: "_blank",
2577
+ rel: "noopener",
2578
+ "data-terms-link": ""
2579
+ }, toDisplayString(unref(t)("onboarding.termsLink")), 9, _hoisted_16$f)
2580
+ ], 64)) : createCommentVNode("", true)
2554
2581
  ]),
2555
- createElementVNode("label", _hoisted_16$f, [
2582
+ unref(s).termsText && !termsLink.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2583
+ createElementVNode("p", {
2584
+ id: `${unref(id)}-terms`
2585
+ }, [
2586
+ createElementVNode("strong", null, toDisplayString(unref(t)("onboarding.termsLink")), 1)
2587
+ ], 8, _hoisted_17$f),
2588
+ createElementVNode("div", {
2589
+ class: "bcm-consent",
2590
+ tabindex: "0",
2591
+ role: "document",
2592
+ "aria-labelledby": `${unref(id)}-terms`,
2593
+ "data-terms-inline": ""
2594
+ }, [
2595
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(s).termsParagraphs, (paragraph, i) => {
2596
+ return openBlock(), createElementBlock("p", {
2597
+ key: i,
2598
+ class: "bcm-text"
2599
+ }, toDisplayString(paragraph), 1);
2600
+ }), 128))
2601
+ ], 8, _hoisted_18$f)
2602
+ ], 64)) : createCommentVNode("", true),
2603
+ createElementVNode("label", _hoisted_19$f, [
2556
2604
  withDirectives(createElementVNode("input", {
2557
2605
  "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => unref(s).rulesAccepted = $event),
2558
2606
  type: "checkbox"
2559
2607
  }, null, 512), [
2560
2608
  [vModelCheckbox, unref(s).rulesAccepted]
2561
2609
  ]),
2562
- createElementVNode("span", null, toDisplayString(unref(t)("onboarding.rulesAccept")), 1)
2610
+ createElementVNode("span", null, toDisplayString(unref(s).termsText ? unref(t)("onboarding.rulesTermsAccept") : unref(t)("onboarding.rulesAccept")), 1)
2563
2611
  ])
2564
- ])) : step.value === "art9" ? (openBlock(), createElementBlock("div", _hoisted_17$f, [
2612
+ ])) : step.value === "art9" ? (openBlock(), createElementBlock("div", _hoisted_20$f, [
2565
2613
  createElementVNode("h4", null, toDisplayString(unref(t)("onboarding.art9Title")), 1),
2566
2614
  createElementVNode("p", null, toDisplayString(__props.model.refusalOffered() ? unref(t)("onboarding.art9LedeOptional") : unref(t)("onboarding.art9Lede")), 1),
2567
2615
  createElementVNode("div", {
@@ -2576,9 +2624,9 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2576
2624
  class: "bcm-text"
2577
2625
  }, toDisplayString(paragraph), 1);
2578
2626
  }), 128))
2579
- ], 8, _hoisted_18$f),
2580
- unref(s).art9Controllers.length > 1 ? (openBlock(), createElementBlock("fieldset", _hoisted_19$f, [
2581
- createElementVNode("legend", _hoisted_20$f, toDisplayString(unref(t)("onboarding.art9Title")), 1),
2627
+ ], 8, _hoisted_21$e),
2628
+ unref(s).art9Controllers.length > 1 ? (openBlock(), createElementBlock("fieldset", _hoisted_22$d, [
2629
+ createElementVNode("legend", _hoisted_23$c, toDisplayString(unref(t)("onboarding.art9Title")), 1),
2582
2630
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(s).art9Controllers, (c) => {
2583
2631
  return openBlock(), createElementBlock("label", {
2584
2632
  key: c.entity,
@@ -2588,13 +2636,13 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2588
2636
  "onUpdate:modelValue": ($event) => c.accepted = $event,
2589
2637
  type: "checkbox",
2590
2638
  required: ""
2591
- }, null, 8, _hoisted_21$e), [
2639
+ }, null, 8, _hoisted_24$b), [
2592
2640
  [vModelCheckbox, c.accepted]
2593
2641
  ]),
2594
2642
  createElementVNode("span", null, toDisplayString(unref(t)("onboarding.art9Controller", { label: c.label })), 1)
2595
2643
  ]);
2596
2644
  }), 128))
2597
- ])) : (openBlock(), createElementBlock("label", _hoisted_22$d, [
2645
+ ])) : (openBlock(), createElementBlock("label", _hoisted_25$a, [
2598
2646
  withDirectives(createElementVNode("input", {
2599
2647
  "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => unref(s).art9Accepted = $event),
2600
2648
  type: "checkbox"
@@ -2603,12 +2651,12 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2603
2651
  ]),
2604
2652
  createElementVNode("span", null, toDisplayString(unref(t)("onboarding.art9Accept")), 1)
2605
2653
  ]))
2606
- ])) : step.value === "profile" ? (openBlock(), createElementBlock("div", _hoisted_23$c, [
2654
+ ])) : step.value === "profile" ? (openBlock(), createElementBlock("div", _hoisted_26$a, [
2607
2655
  createElementVNode("h4", null, toDisplayString(unref(t)("onboarding.profileTitle")), 1),
2608
- createElementVNode("div", _hoisted_24$b, [
2656
+ createElementVNode("div", _hoisted_27$8, [
2609
2657
  createElementVNode("label", {
2610
2658
  for: `${unref(id)}-name`
2611
- }, toDisplayString(unref(t)("onboarding.displayName")), 9, _hoisted_25$a),
2659
+ }, toDisplayString(unref(t)("onboarding.displayName")), 9, _hoisted_28$8),
2612
2660
  withDirectives(createElementVNode("input", {
2613
2661
  id: `${unref(id)}-name`,
2614
2662
  "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => unref(s).displayName = $event),
@@ -2617,18 +2665,18 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2617
2665
  maxlength: unref(COMMUNITY_DISPLAY_NAME_MAX) * 2,
2618
2666
  "aria-invalid": __props.model.hasFieldError("displayName"),
2619
2667
  "aria-describedby": `${unref(id)}-name-hint`
2620
- }, null, 8, _hoisted_26$a), [
2668
+ }, null, 8, _hoisted_29$7), [
2621
2669
  [vModelText, unref(s).displayName]
2622
2670
  ]),
2623
2671
  createElementVNode("p", {
2624
2672
  id: `${unref(id)}-name-hint`,
2625
2673
  class: "bcm-hint"
2626
- }, toDisplayString(unref(t)("onboarding.displayNameHint")), 9, _hoisted_27$8)
2674
+ }, toDisplayString(unref(t)("onboarding.displayNameHint")), 9, _hoisted_30$6)
2627
2675
  ]),
2628
- createElementVNode("div", _hoisted_28$8, [
2676
+ createElementVNode("div", _hoisted_31$5, [
2629
2677
  createElementVNode("label", {
2630
2678
  for: `${unref(id)}-handle`
2631
- }, toDisplayString(unref(t)("onboarding.handle")), 9, _hoisted_29$7),
2679
+ }, toDisplayString(unref(t)("onboarding.handle")), 9, _hoisted_32$5),
2632
2680
  withDirectives(createElementVNode("input", {
2633
2681
  id: `${unref(id)}-handle`,
2634
2682
  "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => unref(s).handle = $event),
@@ -2640,24 +2688,24 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2640
2688
  placeholder: __props.model.suggestedHandle() ?? "",
2641
2689
  "aria-invalid": __props.model.hasFieldError("handle"),
2642
2690
  "aria-describedby": `${unref(id)}-handle-hint`
2643
- }, null, 8, _hoisted_30$6), [
2691
+ }, null, 8, _hoisted_33$5), [
2644
2692
  [vModelText, unref(s).handle]
2645
2693
  ]),
2646
2694
  createElementVNode("p", {
2647
2695
  id: `${unref(id)}-handle-hint`,
2648
2696
  class: "bcm-hint"
2649
- }, toDisplayString(unref(t)("onboarding.handleHint", { min: unref(HANDLE_MIN), max: unref(HANDLE_MAX), days: unref(COMMUNITY_HANDLE_CHANGE_DAYS) })), 9, _hoisted_31$5),
2650
- __props.model.suggestedHandle() ? (openBlock(), createElementBlock("p", _hoisted_32$5, toDisplayString(unref(t)("onboarding.handleSuggested", { handle: __props.model.suggestedHandle() ?? "" })), 1)) : createCommentVNode("", true)
2697
+ }, toDisplayString(unref(t)("onboarding.handleHint", { min: unref(HANDLE_MIN), max: unref(HANDLE_MAX), days: unref(COMMUNITY_HANDLE_CHANGE_DAYS) })), 9, _hoisted_34$4),
2698
+ __props.model.suggestedHandle() ? (openBlock(), createElementBlock("p", _hoisted_35$3, toDisplayString(unref(t)("onboarding.handleSuggested", { handle: __props.model.suggestedHandle() ?? "" })), 1)) : createCommentVNode("", true)
2651
2699
  ]),
2652
- createElementVNode("fieldset", _hoisted_33$5, [
2700
+ createElementVNode("fieldset", _hoisted_36$3, [
2653
2701
  createElementVNode("legend", null, toDisplayString(unref(t)("onboarding.avatar")), 1),
2654
- createElementVNode("label", _hoisted_34$4, [
2702
+ createElementVNode("label", _hoisted_37$2, [
2655
2703
  withDirectives(createElementVNode("input", {
2656
2704
  "onUpdate:modelValue": _cache[8] || (_cache[8] = ($event) => unref(s).avatarPreset = $event),
2657
2705
  type: "radio",
2658
2706
  name: `${unref(id)}-avatar`,
2659
2707
  value: null
2660
- }, null, 8, _hoisted_35$3), [
2708
+ }, null, 8, _hoisted_38$2), [
2661
2709
  [vModelRadio, unref(s).avatarPreset]
2662
2710
  ]),
2663
2711
  createElementVNode("span", null, toDisplayString(unref(t)("onboarding.avatarNone")), 1)
@@ -2672,7 +2720,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2672
2720
  type: "radio",
2673
2721
  name: `${unref(id)}-avatar`,
2674
2722
  value: preset.id
2675
- }, null, 8, _hoisted_36$3), [
2723
+ }, null, 8, _hoisted_39$2), [
2676
2724
  [vModelRadio, unref(s).avatarPreset]
2677
2725
  ]),
2678
2726
  createElementVNode("span", null, toDisplayString(preset.emoji), 1)
@@ -2680,22 +2728,22 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2680
2728
  }), 128))
2681
2729
  ])
2682
2730
  ])) : createCommentVNode("", true),
2683
- failure.value ? (openBlock(), createElementBlock("p", _hoisted_37$2, toDisplayString(failure.value), 1)) : createCommentVNode("", true),
2684
- createElementVNode("div", _hoisted_38$2, [
2731
+ failure.value ? (openBlock(), createElementBlock("p", _hoisted_40$2, toDisplayString(failure.value), 1)) : createCommentVNode("", true),
2732
+ createElementVNode("div", _hoisted_41$2, [
2685
2733
  unref(s).index > 0 ? (openBlock(), createElementBlock("button", {
2686
2734
  key: 0,
2687
2735
  type: "button",
2688
2736
  class: "bcm-btn",
2689
2737
  disabled: unref(s).phase === "sending",
2690
2738
  onClick: _cache[10] || (_cache[10] = ($event) => __props.model.back())
2691
- }, toDisplayString(unref(t)("onboarding.back")), 9, _hoisted_39$2)) : createCommentVNode("", true),
2739
+ }, toDisplayString(unref(t)("onboarding.back")), 9, _hoisted_42$2)) : createCommentVNode("", true),
2692
2740
  createElementVNode("button", {
2693
2741
  type: "button",
2694
2742
  class: "bcm-btn",
2695
2743
  disabled: unref(s).phase === "sending",
2696
2744
  onClick: _cache[11] || (_cache[11] = ($event) => emit("cancel"))
2697
- }, toDisplayString(unref(t)("common.cancel")), 9, _hoisted_40$2),
2698
- _cache[14] || (_cache[14] = createElementVNode("span", { class: "bcm-spacer" }, null, -1)),
2745
+ }, toDisplayString(unref(t)("common.cancel")), 9, _hoisted_43$2),
2746
+ _cache[15] || (_cache[15] = createElementVNode("span", { class: "bcm-spacer" }, null, -1)),
2699
2747
  __props.model.canRefuse() ? (openBlock(), createElementBlock("button", {
2700
2748
  key: 1,
2701
2749
  type: "button",
@@ -2706,7 +2754,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2706
2754
  type: "submit",
2707
2755
  class: "bcm-btn bcm-primary",
2708
2756
  disabled: !__props.model.canContinue()
2709
- }, toDisplayString(unref(s).phase === "sending" ? unref(t)("composer.sending") : __props.model.isLast() ? unref(t)("onboarding.submit") : unref(t)("onboarding.continue")), 9, _hoisted_41$2)
2757
+ }, toDisplayString(unref(s).phase === "sending" ? unref(t)("composer.sending") : __props.model.isLast() ? unref(t)("onboarding.submit") : unref(t)("onboarding.continue")), 9, _hoisted_44$2)
2710
2758
  ])
2711
2759
  ], 32))
2712
2760
  ], 8, _hoisted_1$l);
@@ -3230,8 +3278,9 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
3230
3278
  key: 0,
3231
3279
  model: ctl.value.onboarding.value,
3232
3280
  "rules-href": routes.value.rulesPath,
3281
+ "terms-href": routes.value.termsPath,
3233
3282
  onCancel: _cache[7] || (_cache[7] = ($event) => ctl.value.cancelOnboarding())
3234
- }, null, 8, ["model", "rules-href"])) : (openBlock(), createElementBlock("div", _hoisted_18$d, [
3283
+ }, null, 8, ["model", "rules-href", "terms-href"])) : (openBlock(), createElementBlock("div", _hoisted_18$d, [
3235
3284
  createElementVNode("p", null, toDisplayString(unref(t)(needKey.value)), 1),
3236
3285
  createElementVNode("button", {
3237
3286
  type: "button",
@@ -3789,7 +3838,8 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3789
3838
  client: {},
3790
3839
  lang: {},
3791
3840
  signInHref: {},
3792
- rulesHref: {}
3841
+ rulesHref: {},
3842
+ termsHref: {}
3793
3843
  },
3794
3844
  emits: ["joined"],
3795
3845
  setup(__props, { emit: __emit }) {
@@ -3827,8 +3877,9 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3827
3877
  key: 0,
3828
3878
  model: model.value,
3829
3879
  "rules-href": __props.rulesHref,
3880
+ "terms-href": __props.termsHref,
3830
3881
  onCancel: _cache[0] || (_cache[0] = ($event) => model.value = null)
3831
- }, null, 8, ["model", "rules-href"])) : ask.value === "join" ? (openBlock(), createElementBlock("div", _hoisted_3$f, [
3882
+ }, null, 8, ["model", "rules-href", "terms-href"])) : ask.value === "join" ? (openBlock(), createElementBlock("div", _hoisted_3$f, [
3832
3883
  createElementVNode("button", {
3833
3884
  type: "button",
3834
3885
  class: "bcm-btn bcm-primary",
@@ -4156,8 +4207,9 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
4156
4207
  lang: lang.value,
4157
4208
  "sign-in-href": __props.signInHref,
4158
4209
  "rules-href": routes.value.rulesPath,
4210
+ "terms-href": routes.value.termsPath,
4159
4211
  onJoined: _cache[0] || (_cache[0] = ($event) => ctl.value.load())
4160
- }, null, 8, ["failure", "client", "lang", "sign-in-href", "rules-href"])
4212
+ }, null, 8, ["failure", "client", "lang", "sign-in-href", "rules-href", "terms-href"])
4161
4213
  ], 8, _hoisted_5$d)) : state.value.phase === "notFound" ? (openBlock(), createElementBlock("p", {
4162
4214
  key: 2,
4163
4215
  id: `${unref(id)}-title`,
@@ -4244,8 +4296,9 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
4244
4296
  key: 0,
4245
4297
  model: ctl.value.onboarding.value,
4246
4298
  "rules-href": routes.value.rulesPath,
4299
+ "terms-href": routes.value.termsPath,
4247
4300
  onCancel: _cache[3] || (_cache[3] = ($event) => ctl.value.cancelOnboarding())
4248
- }, null, 8, ["model", "rules-href"])) : (openBlock(), createBlock(_sfc_main$r, {
4301
+ }, null, 8, ["model", "rules-href", "terms-href"])) : (openBlock(), createBlock(_sfc_main$r, {
4249
4302
  key: 1,
4250
4303
  ref_key: "composerRef",
4251
4304
  ref: composerRef,
@@ -5397,8 +5450,9 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
5397
5450
  lang: lang.value,
5398
5451
  "sign-in-href": __props.signInHref,
5399
5452
  "rules-href": routes.value.rulesPath,
5453
+ "terms-href": routes.value.termsPath,
5400
5454
  onJoined: _cache[0] || (_cache[0] = ($event) => unref(ctl).load())
5401
- }, null, 8, ["failure", "client", "lang", "sign-in-href", "rules-href"])) : (openBlock(), createElementBlock("div", _hoisted_4$b, [
5455
+ }, null, 8, ["failure", "client", "lang", "sign-in-href", "rules-href", "terms-href"])) : (openBlock(), createElementBlock("div", _hoisted_4$b, [
5402
5456
  createElementVNode("form", {
5403
5457
  class: "bcm-form",
5404
5458
  role: "search",
@@ -5666,8 +5720,9 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
5666
5720
  lang: lang.value,
5667
5721
  "sign-in-href": __props.signInHref,
5668
5722
  "rules-href": routes.value.rulesPath,
5723
+ "terms-href": routes.value.termsPath,
5669
5724
  onJoined: _cache[0] || (_cache[0] = ($event) => unref(ctl).load())
5670
- }, null, 8, ["failure", "client", "lang", "sign-in-href", "rules-href"])) : unref(state).phase === "failed" ? (openBlock(), createElementBlock("div", _hoisted_5$a, [
5725
+ }, null, 8, ["failure", "client", "lang", "sign-in-href", "rules-href", "terms-href"])) : unref(state).phase === "failed" ? (openBlock(), createElementBlock("div", _hoisted_5$a, [
5671
5726
  createElementVNode("span", null, toDisplayString(failure.value), 1),
5672
5727
  createElementVNode("button", {
5673
5728
  type: "button",
@@ -7627,8 +7682,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
7627
7682
  key: 0,
7628
7683
  model: unref(ctl).consent.value,
7629
7684
  "rules-href": routes.value.rulesPath,
7685
+ "terms-href": routes.value.termsPath,
7630
7686
  onCancel: _cache[13] || (_cache[13] = ($event) => unref(ctl).closeConsent())
7631
- }, null, 8, ["model", "rules-href"])) : (openBlock(), createElementBlock("div", _hoisted_76, [
7687
+ }, null, 8, ["model", "rules-href", "terms-href"])) : (openBlock(), createElementBlock("div", _hoisted_76, [
7632
7688
  createElementVNode("button", {
7633
7689
  type: "button",
7634
7690
  class: "bcm-btn bcm-primary",
@@ -9411,8 +9467,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9411
9467
  lang: lang.value,
9412
9468
  "sign-in-href": __props.signInHref,
9413
9469
  "rules-href": routes.value.rulesPath,
9470
+ "terms-href": routes.value.termsPath,
9414
9471
  onJoined: _cache[0] || (_cache[0] = ($event) => thread.value.refresh())
9415
- }, null, 8, ["failure", "client", "lang", "sign-in-href", "rules-href"])
9472
+ }, null, 8, ["failure", "client", "lang", "sign-in-href", "rules-href", "terms-href"])
9416
9473
  ], 8, _hoisted_6$1)) : state.value.phase === "notFound" ? (openBlock(), createElementBlock("p", {
9417
9474
  key: 2,
9418
9475
  id: unref(headingId),
@@ -9497,8 +9554,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9497
9554
  key: 0,
9498
9555
  model: thread.value.onboarding.value,
9499
9556
  "rules-href": routes.value.rulesPath,
9557
+ "terms-href": routes.value.termsPath,
9500
9558
  onCancel: _cache[7] || (_cache[7] = ($event) => thread.value.cancelOnboarding())
9501
- }, null, 8, ["model", "rules-href"])) : (openBlock(), createElementBlock("div", _hoisted_27, [
9559
+ }, null, 8, ["model", "rules-href", "terms-href"])) : (openBlock(), createElementBlock("div", _hoisted_27, [
9502
9560
  createElementVNode("p", null, toDisplayString(unref(t)(needKey.value)), 1),
9503
9561
  createElementVNode("button", {
9504
9562
  type: "button",
@@ -21,6 +21,14 @@ export interface CommunityRoutes {
21
21
  myCommunityPath?: string;
22
22
  /** The rules page (rendered by the host without JavaScript). */
23
23
  rulesPath?: string;
24
+ /**
25
+ * O-16 / F-51: the discussion terms' page (DSA art. 14), linked beside the rules in a first join's onboarding, whose
26
+ * one tick accepts both. Default: `/community/terms` beside a rules page of the managed blog's shape (the default
27
+ * `/community/rules`, or a host's `…/community/rules` such as `/blog/en/community/rules` → `/blog/en/community/terms`);
28
+ * a host whose rules page has another shape and that names no terms page gets none (null), and the onboarding shows
29
+ * the terms' text in place instead.
30
+ */
31
+ termsPath?: string;
24
32
  /** The notice form. */
25
33
  reportPath?: string;
26
34
  /** A notifier's status page (the receipt goes in its fragment). */
@@ -74,7 +82,9 @@ export declare function siteBaseOf(value: unknown): string | null;
74
82
  /**
75
83
  * The pages with the managed blog's defaults filled in under the site's base (statementPath, profilePath, M3's
76
84
  * categoryPath and topicPath stay templates; articlePath, a template too, has no default).
77
- * A page the host or the tenant names is its own full path.
85
+ * A page the host or the tenant names is its own full path. termsPath (O-16) defaults only beside a rules page of the
86
+ * managed blog's shape (`…/community/rules` → `…/community/terms`, the locale prefix kept) — a host with a rules page of
87
+ * its own shape and no terms page gets null (never a `/community/terms` it may not serve).
78
88
  */
79
89
  export declare function routesWithDefaults(routes: CommunityRoutes, tenant?: {
80
90
  statementPath?: string | null;
@@ -83,6 +93,7 @@ export declare function routesWithDefaults(routes: CommunityRoutes, tenant?: {
83
93
  statementPath: string;
84
94
  myCommunityPath: string;
85
95
  rulesPath: string;
96
+ termsPath: string | null;
86
97
  reportPath: string;
87
98
  noticesPath: string;
88
99
  consultationPath: string | null;
@@ -97,6 +108,8 @@ export declare function routesWithDefaults(routes: CommunityRoutes, tenant?: {
97
108
  topicPath: string;
98
109
  searchPath: string;
99
110
  };
111
+ /** O-16: the terms page beside a rules page of the managed blog's shape (`…/community/rules`), else null. */
112
+ export declare function termsBeside(rulesPath: string): string | null;
100
113
  /** A notice target of one of kb-api's four shapes, or null (the form then has nothing to report). */
101
114
  export declare function parseTarget(value: unknown): NoticeTarget | null;
102
115
  export type NoticeTargetKind = 'message' | 'profile' | 'article';
@@ -18,6 +18,16 @@ export interface OnboardingState {
18
18
  me: MyState | null;
19
19
  rulesText: CurrentLegalText | null;
20
20
  rules: CommunityRule[];
21
+ /**
22
+ * O-16 / F-51: the tenant's current terms text when this first join accepts them with the rules (one tick,
23
+ * `rulesAccepted`, covers both); null otherwise — then no `termsTextId` can go.
24
+ */
25
+ termsText: CurrentLegalText | null;
26
+ /**
27
+ * The terms' text as paragraphs — shown in the step itself when the host names no terms page the step can link
28
+ * (OnboardingSteps: a host's own rules page and no `termsHref`), so the reader never ticks terms they cannot read.
29
+ */
30
+ termsParagraphs: string[];
21
31
  art9Text: CurrentLegalText | null;
22
32
  art9Paragraphs: string[];
23
33
  /** me/get's `settings.art9ConsentLayout` (absent: `joint`). */
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ab, B, S, ac, D, t, r, F, u, s, q, M, N, p, P, V, T, W, R, Q, a0, Z, a5, $, U, a6, a7, O, a9, a8, X, a2, a1, _, Y, f, d, a, n, k, j, o, m, g, c, b, e, h, l, i, z, v, K, G, H, L, J, A, x, w, y, C, I, E, aa, a3, a4 } from "./chunks/mount-BpDqOL7w.js";
2
- const VERSION = "0.3.1";
1
+ import { ab, B, S, ac, D, t, r, F, u, s, q, M, N, p, P, V, T, W, R, Q, a0, Z, a5, $, U, a6, a7, O, a9, a8, X, a2, a1, _, Y, f, d, a, n, k, j, o, m, g, c, b, e, h, l, i, z, v, K, G, H, L, J, A, x, w, y, C, I, E, aa, a3, a4 } from "./chunks/mount-Ts_r2fwt.js";
2
+ const VERSION = "0.4.0";
3
3
  export {
4
4
  ab as AVATAR_PRESETS,
5
5
  B as BADGE_ELEMENT_TAG,