@blogmcp/community 0.3.0 → 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;
@@ -1397,6 +1410,7 @@ function createThread(o, subject, realtime) {
1397
1410
  onDone: (me) => {
1398
1411
  state.me = me;
1399
1412
  onboarding.value = null;
1413
+ for (const d of [state.composer, state.inline]) if (d?.failure?.code === "onboarding") d.failure = null;
1400
1414
  state.art9RefusedNote = model.state.art9RefusedSent;
1401
1415
  if (offerArt9) {
1402
1416
  if (me.acceptances.art9Consent === "accepted") announce({ key: "panel.art9Given" });
@@ -2396,56 +2410,60 @@ const _hoisted_14$h = {
2396
2410
  class: "bcm-hint"
2397
2411
  };
2398
2412
  const _hoisted_15$g = ["href"];
2399
- const _hoisted_16$f = { class: "bcm-check" };
2400
- 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 = {
2401
2418
  key: 3,
2402
2419
  class: "bcm-section"
2403
2420
  };
2404
- const _hoisted_18$f = ["aria-label"];
2405
- const _hoisted_19$f = {
2421
+ const _hoisted_21$e = ["aria-label"];
2422
+ const _hoisted_22$d = {
2406
2423
  key: 0,
2407
2424
  class: "bcm-fieldset"
2408
2425
  };
2409
- const _hoisted_20$f = { class: "bcm-sr" };
2410
- const _hoisted_21$e = ["onUpdate:modelValue"];
2411
- const _hoisted_22$d = {
2426
+ const _hoisted_23$c = { class: "bcm-sr" };
2427
+ const _hoisted_24$b = ["onUpdate:modelValue"];
2428
+ const _hoisted_25$a = {
2412
2429
  key: 1,
2413
2430
  class: "bcm-check"
2414
2431
  };
2415
- const _hoisted_23$c = {
2432
+ const _hoisted_26$a = {
2416
2433
  key: 4,
2417
2434
  class: "bcm-section"
2418
2435
  };
2419
- const _hoisted_24$b = { class: "bcm-field" };
2420
- const _hoisted_25$a = ["for"];
2421
- const _hoisted_26$a = ["id", "maxlength", "aria-invalid", "aria-describedby"];
2422
- const _hoisted_27$8 = ["id"];
2423
- const _hoisted_28$8 = { class: "bcm-field" };
2424
- const _hoisted_29$7 = ["for"];
2425
- const _hoisted_30$6 = ["id", "maxlength", "placeholder", "aria-invalid", "aria-describedby"];
2426
- const _hoisted_31$5 = ["id"];
2427
- 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 = {
2428
2445
  key: 0,
2429
2446
  class: "bcm-hint"
2430
2447
  };
2431
- const _hoisted_33$5 = { class: "bcm-choices" };
2432
- const _hoisted_34$4 = { class: "bcm-choice" };
2433
- const _hoisted_35$3 = ["name"];
2434
- const _hoisted_36$3 = ["name", "value"];
2435
- 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 = {
2436
2453
  key: 5,
2437
2454
  class: "bcm-error",
2438
2455
  role: "alert"
2439
2456
  };
2440
- const _hoisted_38$2 = { class: "bcm-row" };
2441
- const _hoisted_39$2 = ["disabled"];
2442
- const _hoisted_40$2 = ["disabled"];
2443
- 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"];
2444
2461
  const _sfc_main$l = /* @__PURE__ */ defineComponent({
2445
2462
  __name: "OnboardingSteps",
2446
2463
  props: {
2447
2464
  model: {},
2448
- rulesHref: {}
2465
+ rulesHref: {},
2466
+ termsHref: {}
2449
2467
  },
2450
2468
  emits: ["cancel"],
2451
2469
  setup(__props, { emit: __emit }) {
@@ -2457,6 +2475,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2457
2475
  const heading = ref(null);
2458
2476
  const step = computed(() => props.model.step());
2459
2477
  const fresh = computed(() => s.steps.includes("profile"));
2478
+ const termsLink = computed(() => props.termsHref !== void 0 ? props.termsHref : termsBeside(props.rulesHref));
2460
2479
  const failure = computed(() => {
2461
2480
  const f = s.failure;
2462
2481
  if (!f) return "";
@@ -2549,18 +2568,48 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2549
2568
  href: __props.rulesHref,
2550
2569
  target: "_blank",
2551
2570
  rel: "noopener"
2552
- }, 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)
2553
2581
  ]),
2554
- 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, [
2555
2604
  withDirectives(createElementVNode("input", {
2556
2605
  "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => unref(s).rulesAccepted = $event),
2557
2606
  type: "checkbox"
2558
2607
  }, null, 512), [
2559
2608
  [vModelCheckbox, unref(s).rulesAccepted]
2560
2609
  ]),
2561
- 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)
2562
2611
  ])
2563
- ])) : step.value === "art9" ? (openBlock(), createElementBlock("div", _hoisted_17$f, [
2612
+ ])) : step.value === "art9" ? (openBlock(), createElementBlock("div", _hoisted_20$f, [
2564
2613
  createElementVNode("h4", null, toDisplayString(unref(t)("onboarding.art9Title")), 1),
2565
2614
  createElementVNode("p", null, toDisplayString(__props.model.refusalOffered() ? unref(t)("onboarding.art9LedeOptional") : unref(t)("onboarding.art9Lede")), 1),
2566
2615
  createElementVNode("div", {
@@ -2575,9 +2624,9 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2575
2624
  class: "bcm-text"
2576
2625
  }, toDisplayString(paragraph), 1);
2577
2626
  }), 128))
2578
- ], 8, _hoisted_18$f),
2579
- unref(s).art9Controllers.length > 1 ? (openBlock(), createElementBlock("fieldset", _hoisted_19$f, [
2580
- 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),
2581
2630
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(s).art9Controllers, (c) => {
2582
2631
  return openBlock(), createElementBlock("label", {
2583
2632
  key: c.entity,
@@ -2587,13 +2636,13 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2587
2636
  "onUpdate:modelValue": ($event) => c.accepted = $event,
2588
2637
  type: "checkbox",
2589
2638
  required: ""
2590
- }, null, 8, _hoisted_21$e), [
2639
+ }, null, 8, _hoisted_24$b), [
2591
2640
  [vModelCheckbox, c.accepted]
2592
2641
  ]),
2593
2642
  createElementVNode("span", null, toDisplayString(unref(t)("onboarding.art9Controller", { label: c.label })), 1)
2594
2643
  ]);
2595
2644
  }), 128))
2596
- ])) : (openBlock(), createElementBlock("label", _hoisted_22$d, [
2645
+ ])) : (openBlock(), createElementBlock("label", _hoisted_25$a, [
2597
2646
  withDirectives(createElementVNode("input", {
2598
2647
  "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => unref(s).art9Accepted = $event),
2599
2648
  type: "checkbox"
@@ -2602,12 +2651,12 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2602
2651
  ]),
2603
2652
  createElementVNode("span", null, toDisplayString(unref(t)("onboarding.art9Accept")), 1)
2604
2653
  ]))
2605
- ])) : step.value === "profile" ? (openBlock(), createElementBlock("div", _hoisted_23$c, [
2654
+ ])) : step.value === "profile" ? (openBlock(), createElementBlock("div", _hoisted_26$a, [
2606
2655
  createElementVNode("h4", null, toDisplayString(unref(t)("onboarding.profileTitle")), 1),
2607
- createElementVNode("div", _hoisted_24$b, [
2656
+ createElementVNode("div", _hoisted_27$8, [
2608
2657
  createElementVNode("label", {
2609
2658
  for: `${unref(id)}-name`
2610
- }, toDisplayString(unref(t)("onboarding.displayName")), 9, _hoisted_25$a),
2659
+ }, toDisplayString(unref(t)("onboarding.displayName")), 9, _hoisted_28$8),
2611
2660
  withDirectives(createElementVNode("input", {
2612
2661
  id: `${unref(id)}-name`,
2613
2662
  "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => unref(s).displayName = $event),
@@ -2616,18 +2665,18 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2616
2665
  maxlength: unref(COMMUNITY_DISPLAY_NAME_MAX) * 2,
2617
2666
  "aria-invalid": __props.model.hasFieldError("displayName"),
2618
2667
  "aria-describedby": `${unref(id)}-name-hint`
2619
- }, null, 8, _hoisted_26$a), [
2668
+ }, null, 8, _hoisted_29$7), [
2620
2669
  [vModelText, unref(s).displayName]
2621
2670
  ]),
2622
2671
  createElementVNode("p", {
2623
2672
  id: `${unref(id)}-name-hint`,
2624
2673
  class: "bcm-hint"
2625
- }, toDisplayString(unref(t)("onboarding.displayNameHint")), 9, _hoisted_27$8)
2674
+ }, toDisplayString(unref(t)("onboarding.displayNameHint")), 9, _hoisted_30$6)
2626
2675
  ]),
2627
- createElementVNode("div", _hoisted_28$8, [
2676
+ createElementVNode("div", _hoisted_31$5, [
2628
2677
  createElementVNode("label", {
2629
2678
  for: `${unref(id)}-handle`
2630
- }, toDisplayString(unref(t)("onboarding.handle")), 9, _hoisted_29$7),
2679
+ }, toDisplayString(unref(t)("onboarding.handle")), 9, _hoisted_32$5),
2631
2680
  withDirectives(createElementVNode("input", {
2632
2681
  id: `${unref(id)}-handle`,
2633
2682
  "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => unref(s).handle = $event),
@@ -2639,24 +2688,24 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2639
2688
  placeholder: __props.model.suggestedHandle() ?? "",
2640
2689
  "aria-invalid": __props.model.hasFieldError("handle"),
2641
2690
  "aria-describedby": `${unref(id)}-handle-hint`
2642
- }, null, 8, _hoisted_30$6), [
2691
+ }, null, 8, _hoisted_33$5), [
2643
2692
  [vModelText, unref(s).handle]
2644
2693
  ]),
2645
2694
  createElementVNode("p", {
2646
2695
  id: `${unref(id)}-handle-hint`,
2647
2696
  class: "bcm-hint"
2648
- }, toDisplayString(unref(t)("onboarding.handleHint", { min: unref(HANDLE_MIN), max: unref(HANDLE_MAX), days: unref(COMMUNITY_HANDLE_CHANGE_DAYS) })), 9, _hoisted_31$5),
2649
- __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)
2650
2699
  ]),
2651
- createElementVNode("fieldset", _hoisted_33$5, [
2700
+ createElementVNode("fieldset", _hoisted_36$3, [
2652
2701
  createElementVNode("legend", null, toDisplayString(unref(t)("onboarding.avatar")), 1),
2653
- createElementVNode("label", _hoisted_34$4, [
2702
+ createElementVNode("label", _hoisted_37$2, [
2654
2703
  withDirectives(createElementVNode("input", {
2655
2704
  "onUpdate:modelValue": _cache[8] || (_cache[8] = ($event) => unref(s).avatarPreset = $event),
2656
2705
  type: "radio",
2657
2706
  name: `${unref(id)}-avatar`,
2658
2707
  value: null
2659
- }, null, 8, _hoisted_35$3), [
2708
+ }, null, 8, _hoisted_38$2), [
2660
2709
  [vModelRadio, unref(s).avatarPreset]
2661
2710
  ]),
2662
2711
  createElementVNode("span", null, toDisplayString(unref(t)("onboarding.avatarNone")), 1)
@@ -2671,7 +2720,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2671
2720
  type: "radio",
2672
2721
  name: `${unref(id)}-avatar`,
2673
2722
  value: preset.id
2674
- }, null, 8, _hoisted_36$3), [
2723
+ }, null, 8, _hoisted_39$2), [
2675
2724
  [vModelRadio, unref(s).avatarPreset]
2676
2725
  ]),
2677
2726
  createElementVNode("span", null, toDisplayString(preset.emoji), 1)
@@ -2679,22 +2728,22 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2679
2728
  }), 128))
2680
2729
  ])
2681
2730
  ])) : createCommentVNode("", true),
2682
- failure.value ? (openBlock(), createElementBlock("p", _hoisted_37$2, toDisplayString(failure.value), 1)) : createCommentVNode("", true),
2683
- 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, [
2684
2733
  unref(s).index > 0 ? (openBlock(), createElementBlock("button", {
2685
2734
  key: 0,
2686
2735
  type: "button",
2687
2736
  class: "bcm-btn",
2688
2737
  disabled: unref(s).phase === "sending",
2689
2738
  onClick: _cache[10] || (_cache[10] = ($event) => __props.model.back())
2690
- }, toDisplayString(unref(t)("onboarding.back")), 9, _hoisted_39$2)) : createCommentVNode("", true),
2739
+ }, toDisplayString(unref(t)("onboarding.back")), 9, _hoisted_42$2)) : createCommentVNode("", true),
2691
2740
  createElementVNode("button", {
2692
2741
  type: "button",
2693
2742
  class: "bcm-btn",
2694
2743
  disabled: unref(s).phase === "sending",
2695
2744
  onClick: _cache[11] || (_cache[11] = ($event) => emit("cancel"))
2696
- }, toDisplayString(unref(t)("common.cancel")), 9, _hoisted_40$2),
2697
- _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)),
2698
2747
  __props.model.canRefuse() ? (openBlock(), createElementBlock("button", {
2699
2748
  key: 1,
2700
2749
  type: "button",
@@ -2705,7 +2754,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2705
2754
  type: "submit",
2706
2755
  class: "bcm-btn bcm-primary",
2707
2756
  disabled: !__props.model.canContinue()
2708
- }, 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)
2709
2758
  ])
2710
2759
  ], 32))
2711
2760
  ], 8, _hoisted_1$l);
@@ -3229,8 +3278,9 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
3229
3278
  key: 0,
3230
3279
  model: ctl.value.onboarding.value,
3231
3280
  "rules-href": routes.value.rulesPath,
3281
+ "terms-href": routes.value.termsPath,
3232
3282
  onCancel: _cache[7] || (_cache[7] = ($event) => ctl.value.cancelOnboarding())
3233
- }, 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, [
3234
3284
  createElementVNode("p", null, toDisplayString(unref(t)(needKey.value)), 1),
3235
3285
  createElementVNode("button", {
3236
3286
  type: "button",
@@ -3596,6 +3646,7 @@ function createCategory(o) {
3596
3646
  onDone: (me) => {
3597
3647
  state.me = me;
3598
3648
  onboarding.value = null;
3649
+ if (state.composer.failure?.code === "onboarding") state.composer.failure = null;
3599
3650
  announce({ key: model.state.art9RefusedSent ? "onboarding.art9RefusedDone" : "onboarding.done" });
3600
3651
  },
3601
3652
  onSignIn: () => {
@@ -3787,7 +3838,8 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3787
3838
  client: {},
3788
3839
  lang: {},
3789
3840
  signInHref: {},
3790
- rulesHref: {}
3841
+ rulesHref: {},
3842
+ termsHref: {}
3791
3843
  },
3792
3844
  emits: ["joined"],
3793
3845
  setup(__props, { emit: __emit }) {
@@ -3825,8 +3877,9 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3825
3877
  key: 0,
3826
3878
  model: model.value,
3827
3879
  "rules-href": __props.rulesHref,
3880
+ "terms-href": __props.termsHref,
3828
3881
  onCancel: _cache[0] || (_cache[0] = ($event) => model.value = null)
3829
- }, 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, [
3830
3883
  createElementVNode("button", {
3831
3884
  type: "button",
3832
3885
  class: "bcm-btn bcm-primary",
@@ -4110,6 +4163,12 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
4110
4163
  void ctl.value?.setSort(e.target.value);
4111
4164
  }
4112
4165
  const composerRef = ref(null);
4166
+ watch(
4167
+ () => ctl.value?.onboarding.value ?? null,
4168
+ (now, before) => {
4169
+ if (now === null && before?.state.phase === "done") void nextTick(() => composerRef.value?.focus());
4170
+ }
4171
+ );
4113
4172
  const liveText = ref("");
4114
4173
  watch(
4115
4174
  () => state.value?.announceId,
@@ -4148,8 +4207,9 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
4148
4207
  lang: lang.value,
4149
4208
  "sign-in-href": __props.signInHref,
4150
4209
  "rules-href": routes.value.rulesPath,
4210
+ "terms-href": routes.value.termsPath,
4151
4211
  onJoined: _cache[0] || (_cache[0] = ($event) => ctl.value.load())
4152
- }, null, 8, ["failure", "client", "lang", "sign-in-href", "rules-href"])
4212
+ }, null, 8, ["failure", "client", "lang", "sign-in-href", "rules-href", "terms-href"])
4153
4213
  ], 8, _hoisted_5$d)) : state.value.phase === "notFound" ? (openBlock(), createElementBlock("p", {
4154
4214
  key: 2,
4155
4215
  id: `${unref(id)}-title`,
@@ -4236,8 +4296,9 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
4236
4296
  key: 0,
4237
4297
  model: ctl.value.onboarding.value,
4238
4298
  "rules-href": routes.value.rulesPath,
4299
+ "terms-href": routes.value.termsPath,
4239
4300
  onCancel: _cache[3] || (_cache[3] = ($event) => ctl.value.cancelOnboarding())
4240
- }, null, 8, ["model", "rules-href"])) : (openBlock(), createBlock(_sfc_main$r, {
4301
+ }, null, 8, ["model", "rules-href", "terms-href"])) : (openBlock(), createBlock(_sfc_main$r, {
4241
4302
  key: 1,
4242
4303
  ref_key: "composerRef",
4243
4304
  ref: composerRef,
@@ -5389,8 +5450,9 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
5389
5450
  lang: lang.value,
5390
5451
  "sign-in-href": __props.signInHref,
5391
5452
  "rules-href": routes.value.rulesPath,
5453
+ "terms-href": routes.value.termsPath,
5392
5454
  onJoined: _cache[0] || (_cache[0] = ($event) => unref(ctl).load())
5393
- }, 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, [
5394
5456
  createElementVNode("form", {
5395
5457
  class: "bcm-form",
5396
5458
  role: "search",
@@ -5658,8 +5720,9 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
5658
5720
  lang: lang.value,
5659
5721
  "sign-in-href": __props.signInHref,
5660
5722
  "rules-href": routes.value.rulesPath,
5723
+ "terms-href": routes.value.termsPath,
5661
5724
  onJoined: _cache[0] || (_cache[0] = ($event) => unref(ctl).load())
5662
- }, 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, [
5663
5726
  createElementVNode("span", null, toDisplayString(failure.value), 1),
5664
5727
  createElementVNode("button", {
5665
5728
  type: "button",
@@ -7619,8 +7682,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
7619
7682
  key: 0,
7620
7683
  model: unref(ctl).consent.value,
7621
7684
  "rules-href": routes.value.rulesPath,
7685
+ "terms-href": routes.value.termsPath,
7622
7686
  onCancel: _cache[13] || (_cache[13] = ($event) => unref(ctl).closeConsent())
7623
- }, null, 8, ["model", "rules-href"])) : (openBlock(), createElementBlock("div", _hoisted_76, [
7687
+ }, null, 8, ["model", "rules-href", "terms-href"])) : (openBlock(), createElementBlock("div", _hoisted_76, [
7624
7688
  createElementVNode("button", {
7625
7689
  type: "button",
7626
7690
  class: "bcm-btn bcm-primary",
@@ -9403,8 +9467,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9403
9467
  lang: lang.value,
9404
9468
  "sign-in-href": __props.signInHref,
9405
9469
  "rules-href": routes.value.rulesPath,
9470
+ "terms-href": routes.value.termsPath,
9406
9471
  onJoined: _cache[0] || (_cache[0] = ($event) => thread.value.refresh())
9407
- }, null, 8, ["failure", "client", "lang", "sign-in-href", "rules-href"])
9472
+ }, null, 8, ["failure", "client", "lang", "sign-in-href", "rules-href", "terms-href"])
9408
9473
  ], 8, _hoisted_6$1)) : state.value.phase === "notFound" ? (openBlock(), createElementBlock("p", {
9409
9474
  key: 2,
9410
9475
  id: unref(headingId),
@@ -9489,8 +9554,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9489
9554
  key: 0,
9490
9555
  model: thread.value.onboarding.value,
9491
9556
  "rules-href": routes.value.rulesPath,
9557
+ "terms-href": routes.value.termsPath,
9492
9558
  onCancel: _cache[7] || (_cache[7] = ($event) => thread.value.cancelOnboarding())
9493
- }, null, 8, ["model", "rules-href"])) : (openBlock(), createElementBlock("div", _hoisted_27, [
9559
+ }, null, 8, ["model", "rules-href", "terms-href"])) : (openBlock(), createElementBlock("div", _hoisted_27, [
9494
9560
  createElementVNode("p", null, toDisplayString(unref(t)(needKey.value)), 1),
9495
9561
  createElementVNode("button", {
9496
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--2_V2q3M.js";
2
- const VERSION = "0.3.0";
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,