@bettercms-ai/types 1.69.0 → 1.70.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
@@ -82,20 +82,20 @@ function withVisibleChildren(block, now) {
82
82
  // A slide or a tab panel: `{ id, children }`.
83
83
  mapSame(held, (row) => {
84
84
  const children = row?.children;
85
- const shown = visibleBlocks(children, now);
86
- return shown === children ? row : { ...row, children: shown };
85
+ const shown2 = visibleBlocks(children, now);
86
+ return shown2 === children ? row : { ...row, children: shown2 };
87
87
  })
88
88
  );
89
89
  return next === held ? block : { ...block, props: { ...p, [key]: next } };
90
90
  }
91
91
  function visibleBlocks(blocks, now) {
92
92
  if (!Array.isArray(blocks)) return blocks;
93
- const shown = blocks.filter((block) => inWindow(block, now) && !hiddenEverywhere(block));
93
+ const shown2 = blocks.filter((block) => inWindow(block, now) && !hiddenEverywhere(block));
94
94
  const pruned = mapSame(
95
- shown,
95
+ shown2,
96
96
  (block) => block && typeof block === "object" ? withVisibleChildren(block, now) : block
97
97
  );
98
- return shown.length === blocks.length && pruned === shown ? blocks : pruned;
98
+ return shown2.length === blocks.length && pruned === shown2 ? blocks : pruned;
99
99
  }
100
100
  function isBlock(value) {
101
101
  return typeof value === "object" && value !== null && "type" in value && typeof value["type"] === "string";
@@ -4504,25 +4504,50 @@ var LANDMARK_SELECTOR = "header,nav,footer";
4504
4504
  var LANDMARK_TAGS = /* @__PURE__ */ new Set(["HEADER", "NAV", "FOOTER"]);
4505
4505
  var DIALOG_SELECTOR = 'dialog,[role="dialog"]';
4506
4506
  var MAIN_SELECTOR = 'main,[role="main"]';
4507
- function isChromeLandmark(el, landmarks) {
4507
+ function isChromeLandmark(el, landmarks, wrapped = false) {
4508
4508
  if (!LANDMARK_TAGS.has(el.tagName)) return false;
4509
4509
  if (!landmarks) return true;
4510
4510
  const fence = el.parentElement?.closest(MAIN_SELECTOR);
4511
- return !fence || fence === el.parentElement && isPageShell(fence);
4511
+ if (!fence || fence === el.parentElement && isPageShell(fence)) return true;
4512
+ if (!wrapped) return false;
4513
+ const node = el;
4514
+ return el.tagName === "FOOTER" ? closesMain(node, fence, "last") : isPageShell(fence, true) && closesMain(node, fence, "first");
4512
4515
  }
4513
4516
  var INERT_TAGS = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "TEMPLATE", "NOSCRIPT", "LINK"]);
4514
- function isPageShell(main) {
4515
- const kids = Array.from(main.children).filter((k) => !INERT_TAGS.has(k.tagName));
4517
+ var shown = (el) => Array.from(el.children).filter((k) => !INERT_TAGS.has(k.tagName));
4518
+ function closesMain(el, main, end) {
4519
+ for (let at = el; at !== main; at = at.parentElement) {
4520
+ const parent = at.parentElement;
4521
+ if (!parent || parent !== main && parent.tagName !== "DIV") return false;
4522
+ const kids = shown(parent);
4523
+ if ((end === "first" ? kids[0] : kids[kids.length - 1]) !== at) return false;
4524
+ }
4525
+ return true;
4526
+ }
4527
+ var endOf = (main, end) => {
4528
+ let at = main;
4529
+ do {
4530
+ const kids = shown(at);
4531
+ at = end === "first" ? kids[0] : kids[kids.length - 1];
4532
+ } while (at?.tagName === "DIV");
4533
+ return at;
4534
+ };
4535
+ function isPageShell(main, wrapped = false) {
4536
+ const kids = shown(main);
4537
+ if (wrapped) {
4538
+ const first2 = endOf(main, "first")?.tagName;
4539
+ return kids.length > 1 && (first2 === "HEADER" || first2 === "NAV") && endOf(main, "last")?.tagName === "FOOTER";
4540
+ }
4516
4541
  const first = kids[0]?.tagName;
4517
4542
  return (first === "HEADER" || first === "NAV") && kids.length > 1 && kids[kids.length - 1].tagName === "FOOTER";
4518
4543
  }
4519
- function locatorFor(el, region, landmarks = false) {
4544
+ function locatorFor(el, region, landmarks = false, wrapped = false) {
4520
4545
  const ancestors = [];
4521
4546
  for (
4522
4547
  let parent = el.parentElement;
4523
4548
  // The cast is the overloads' promise: `landmarks` is only ever true for a `LandmarkChainElement`,
4524
4549
  // and `isChromeLandmark` never reads past the tag with it false.
4525
- parent && parent.tagName !== "BODY" && !isChromeLandmark(parent, landmarks);
4550
+ parent && parent.tagName !== "BODY" && !isChromeLandmark(parent, landmarks, wrapped);
4526
4551
  parent = parent.parentElement
4527
4552
  ) {
4528
4553
  ancestors.unshift(parent.tagName.toLowerCase());
@@ -4541,15 +4566,15 @@ function siblingIndexOf(el) {
4541
4566
  for (let s = linked.previousElementSibling; s; s = s.previousElementSibling ?? null) i += 1;
4542
4567
  return i;
4543
4568
  }
4544
- function locatorPath(el, landmarks = false) {
4569
+ function locatorPath(el, landmarks = false, wrapped = false) {
4545
4570
  const path = [];
4546
- for (let parent = el.parentElement; parent && parent.tagName !== "BODY" && !isChromeLandmark(parent, landmarks); parent = parent.parentElement) {
4571
+ for (let parent = el.parentElement; parent && parent.tagName !== "BODY" && !isChromeLandmark(parent, landmarks, wrapped); parent = parent.parentElement) {
4547
4572
  path.unshift(parent.parentElement ? siblingIndexOf(parent) : 0);
4548
4573
  }
4549
4574
  return path;
4550
4575
  }
4551
4576
  var LOCATOR_PATH = /* @__PURE__ */ Symbol.for("bcms.locator.path");
4552
- function landmarkRegions(doc, dialogs = false, landmarks = false) {
4577
+ function landmarkRegions(doc, dialogs = false, landmarks = false, wrapped = false) {
4553
4578
  const counts = /* @__PURE__ */ new Map();
4554
4579
  const out = [];
4555
4580
  const selector = dialogs ? `${LANDMARK_SELECTOR},${DIALOG_SELECTOR}` : LANDMARK_SELECTOR;
@@ -4557,7 +4582,7 @@ function landmarkRegions(doc, dialogs = false, landmarks = false) {
4557
4582
  if (!landmarks) {
4558
4583
  if (el.parentElement?.closest(selector)) continue;
4559
4584
  } else if (LANDMARK_TAGS.has(el.tagName)) {
4560
- if (!isChromeLandmark(el, true) || el.parentElement?.closest(selector)) continue;
4585
+ if (!isChromeLandmark(el, true, wrapped) || el.parentElement?.closest(selector)) continue;
4561
4586
  } else if (el.parentElement?.closest(DIALOG_SELECTOR)) {
4562
4587
  continue;
4563
4588
  }
@@ -5243,7 +5268,9 @@ var UI_REFUSAL_CODES = {
5243
5268
  "size_exceeded",
5244
5269
  // CMS-stored UI (dock-ui.ts): an import off the allow-list; one name in both the repo and the CMS
5245
5270
  "import_denied",
5246
- "name_conflict"
5271
+ "name_conflict",
5272
+ // CMS-stored UI: a raw form element where the kit has the control (dock UI is kit only)
5273
+ "raw_control"
5247
5274
  ],
5248
5275
  protocol: ["unsupported", "handshake_timeout", "origin_mismatch", "write_denied"],
5249
5276
  runtime: ["crashed", "blank", "csp_violation"],
@@ -5542,6 +5569,546 @@ function isVariantVisible(prop, values, props) {
5542
5569
  // src/heading-id.ts
5543
5570
  var slugify = (s) => s.toLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "section";
5544
5571
 
5572
+ // src/name-judge.ts
5573
+ var LABEL_CARRIER = {
5574
+ NAV: "navigation",
5575
+ BUTTON: "button",
5576
+ A: "link",
5577
+ IMG: "image",
5578
+ svg: "image",
5579
+ FIGURE: "image",
5580
+ PICTURE: "image",
5581
+ INPUT: "field",
5582
+ TEXTAREA: "field",
5583
+ SELECT: "field",
5584
+ HEADER: "header",
5585
+ FOOTER: "footer",
5586
+ ASIDE: "aside",
5587
+ SECTION: "section",
5588
+ H1: "heading",
5589
+ H2: "heading",
5590
+ H3: "heading",
5591
+ H4: "heading",
5592
+ H5: "heading",
5593
+ H6: "heading"
5594
+ };
5595
+ var ROLE_VOCABULARY = [.../* @__PURE__ */ new Set([
5596
+ // A top-level field's role in its section.
5597
+ "headline",
5598
+ "heading",
5599
+ "subheading",
5600
+ "eyebrow",
5601
+ "intro",
5602
+ "paragraph",
5603
+ "text",
5604
+ "primary-button",
5605
+ "secondary-button",
5606
+ "button",
5607
+ "button-label",
5608
+ "link",
5609
+ "home-link",
5610
+ "image",
5611
+ "icon",
5612
+ "logo",
5613
+ "background-image",
5614
+ "video-poster",
5615
+ "video",
5616
+ "embed",
5617
+ "audio",
5618
+ "body",
5619
+ "content",
5620
+ "copyright",
5621
+ "email",
5622
+ "phone",
5623
+ "price",
5624
+ "percentage",
5625
+ "number",
5626
+ "date",
5627
+ "stat-value",
5628
+ "stat-label",
5629
+ "quote",
5630
+ "attribution",
5631
+ "caption",
5632
+ "label",
5633
+ "summary",
5634
+ "address",
5635
+ "code",
5636
+ "term",
5637
+ "definition",
5638
+ "table-heading",
5639
+ "table-cell",
5640
+ "list-item",
5641
+ "list",
5642
+ "links",
5643
+ "band",
5644
+ // A column's role in its row.
5645
+ "title",
5646
+ "subtitle",
5647
+ "description",
5648
+ "value",
5649
+ // What a band's shape calls an element.
5650
+ "plan-name",
5651
+ "cents",
5652
+ "billing-period",
5653
+ "badge",
5654
+ "features",
5655
+ "question",
5656
+ "answer",
5657
+ "author",
5658
+ "role",
5659
+ // The parts of a plan's price object. @see foldPrice in derive-schema.ts
5660
+ "amount",
5661
+ "period",
5662
+ // What an attribute is, by what carries it.
5663
+ "tooltip",
5664
+ "placeholder",
5665
+ "image-description",
5666
+ "counter-target",
5667
+ "attribute",
5668
+ ...Object.values(LABEL_CARRIER).map((carrier) => `${carrier}-label`),
5669
+ // What a list's rows are.
5670
+ "plans",
5671
+ "questions",
5672
+ "quotes",
5673
+ "testimonials",
5674
+ "stats",
5675
+ "logos",
5676
+ "cards",
5677
+ "items"
5678
+ ])];
5679
+ var VOCABULARY = new Set(ROLE_VOCABULARY);
5680
+ var BOX_WORDS = /* @__PURE__ */ new Set([
5681
+ "wrap",
5682
+ "wrapper",
5683
+ "fixed",
5684
+ "sticky",
5685
+ "static",
5686
+ "container",
5687
+ "inner",
5688
+ "outer",
5689
+ "main",
5690
+ "content",
5691
+ "section",
5692
+ "block",
5693
+ "flex",
5694
+ "grid",
5695
+ "row",
5696
+ "col",
5697
+ "column",
5698
+ "columns",
5699
+ "box",
5700
+ "layout",
5701
+ "page",
5702
+ "body",
5703
+ "root",
5704
+ "app",
5705
+ "site",
5706
+ "isolate",
5707
+ "relative",
5708
+ "absolute",
5709
+ "group",
5710
+ "item",
5711
+ "items",
5712
+ "overflow",
5713
+ "hidden",
5714
+ "visible",
5715
+ "prose",
5716
+ "astro",
5717
+ "div",
5718
+ "area",
5719
+ "shell",
5720
+ "panel",
5721
+ "stack",
5722
+ "cluster",
5723
+ "frame",
5724
+ "band",
5725
+ "region"
5726
+ ]);
5727
+ var PLACEHOLDER_WORDS = /* @__PURE__ */ new Set(["sec", "span"]);
5728
+ var GENERIC_ROLES = "text|paragraph|number|link|links|icon|image|item|items|list|attribute|span|element|logo|logos|stat|stats";
5729
+ var GENERIC_SCOPE = "(?:dialog|modal|popup|overlay|drawer)(?:\\s+\\d{1,3})?|section\\s+\\d{1,3}";
5730
+ var GENERIC_ROLE_NAME = new RegExp(
5731
+ `^(?:(?<scope>${GENERIC_SCOPE})\\s+)?(?:${GENERIC_ROLES})(?<n>\\s+\\d{1,3})?(?:\\s+(?:url|label))?$`,
5732
+ "i"
5733
+ );
5734
+ var WORD_ITEMS = new RegExp("^\\p{L}+\\s+items?$", "iu");
5735
+ function isArtifactName(name2) {
5736
+ const l = name2.trim();
5737
+ if (!l) return true;
5738
+ if (/^[a-z0-9]+([-_][a-z0-9]+)+$/.test(l) || /[[\]{}|]/.test(l)) return true;
5739
+ if (/\b(?=[a-z0-9]*\d)(?=[a-z0-9]*[a-z])[a-z0-9]{5,}\b/i.test(l) || /\d{5,}/.test(l)) return true;
5740
+ const counted = /^([a-z]+)[\s-]?\d*$/i.exec(l);
5741
+ if (counted !== null && (BOX_WORDS.has(counted[1].toLowerCase()) || PLACEHOLDER_WORDS.has(counted[1].toLowerCase()))) return true;
5742
+ const role = GENERIC_ROLE_NAME.exec(l);
5743
+ if (role && (role.groups?.scope || role.groups?.n)) return true;
5744
+ const head = /^(.+?)\s+›\s+/.exec(l)?.[1];
5745
+ if (head) {
5746
+ const headRole = GENERIC_ROLE_NAME.exec(head);
5747
+ if (headRole && (headRole.groups?.scope || headRole.groups?.n)) return true;
5748
+ }
5749
+ return WORD_ITEMS.test(l);
5750
+ }
5751
+ var isCountedName = (name2) => /\S\s+\d{1,3}$/.test(name2.trim());
5752
+ var TRAILING = /* @__PURE__ */ new Set(["a", "an", "the", "and", "or", "of", "to", "for", "with", "by", "in", "on", "at", "your", "our", "from", "is", "are"]);
5753
+ var PHRASE_MAX = 40;
5754
+ var FILLER_EN = [
5755
+ ...TRAILING,
5756
+ "as",
5757
+ "into",
5758
+ "over",
5759
+ "than",
5760
+ "so",
5761
+ "but",
5762
+ "nor",
5763
+ "my",
5764
+ "their",
5765
+ "its",
5766
+ "his",
5767
+ "her",
5768
+ "we",
5769
+ "you",
5770
+ "it",
5771
+ "us",
5772
+ "they",
5773
+ "i",
5774
+ "we've",
5775
+ "we're",
5776
+ "you're",
5777
+ "you'll",
5778
+ "it's",
5779
+ "let's",
5780
+ "lets",
5781
+ "be",
5782
+ "was",
5783
+ "were",
5784
+ "this",
5785
+ "that",
5786
+ "these",
5787
+ "those",
5788
+ "something",
5789
+ "everything",
5790
+ "anything",
5791
+ "more",
5792
+ "most",
5793
+ "very",
5794
+ "just",
5795
+ "all",
5796
+ "can",
5797
+ "could",
5798
+ "will",
5799
+ "would",
5800
+ "should",
5801
+ "may",
5802
+ "might",
5803
+ "must",
5804
+ "do",
5805
+ "does",
5806
+ "did",
5807
+ "don't",
5808
+ "not",
5809
+ "never",
5810
+ "still",
5811
+ "only",
5812
+ "even",
5813
+ "also",
5814
+ "own",
5815
+ "ever",
5816
+ "already",
5817
+ "have",
5818
+ "has",
5819
+ "had"
5820
+ ];
5821
+ var LANGS = {
5822
+ en: { filler: new Set(FILLER_EN), tail: /* @__PURE__ */ new Set(["of", "in", "for", "from", "with", "by", "on", "at", "into", "over", "about"]) },
5823
+ de: {
5824
+ filler: /* @__PURE__ */ new Set(["der", "die", "das", "den", "dem", "des", "ein", "eine", "einen", "einem", "einer", "und", "oder", "f\xFCr", "mit", "von", "zu", "zum", "zur", "im", "in", "am", "an", "auf", "aus", "bei", "nach", "\xFCber", "unter", "um", "wir", "sie", "ihr", "ihre", "unser", "unsere", "unseren", "unserer", "mein", "es", "ist", "sind", "sich", "uns"]),
5825
+ tail: /* @__PURE__ */ new Set(["von", "f\xFCr", "mit", "im", "in", "am", "auf", "aus", "bei", "nach", "\xFCber", "unter", "um", "zu", "zum", "zur"])
5826
+ },
5827
+ fr: {
5828
+ filler: /* @__PURE__ */ new Set(["le", "la", "les", "l'", "un", "une", "des", "de", "du", "d'", "et", "ou", "pour", "avec", "en", "au", "aux", "dans", "sur", "par", "\xE0", "nous", "vous", "notre", "nos", "votre", "vos", "leur", "leurs", "ce", "cette", "ces", "est", "sont", "qui", "que"]),
5829
+ tail: /* @__PURE__ */ new Set(["de", "du", "des", "pour", "avec", "en", "dans", "sur", "par", "\xE0", "au", "aux"])
5830
+ },
5831
+ es: {
5832
+ filler: /* @__PURE__ */ new Set(["el", "la", "los", "las", "un", "una", "unos", "unas", "de", "del", "y", "o", "para", "con", "en", "al", "por", "a", "nuestro", "nuestra", "nuestros", "nuestras", "su", "sus", "que", "es", "son", "lo"]),
5833
+ tail: /* @__PURE__ */ new Set(["de", "del", "para", "con", "en", "por", "a", "al"])
5834
+ }
5835
+ };
5836
+ var LAST_ADVERBS = /* @__PURE__ */ new Set(["today", "now", "here", "below", "together", "again", "forever", "worldwide", "ahead", "well", "too", "instead", "anywhere", "everywhere", "online"]);
5837
+ var INTERROGATIVE = /* @__PURE__ */ new Set(["what", "how", "why", "who", "when", "where", "which"]);
5838
+ var LEAD = /* @__PURE__ */ new Set(["a", "an", "the", "our", "your", "my", "their", "his", "her", "its", "unser", "unsere", "nos", "notre", "vos", "votre", "nuestro", "nuestra", "nuestros", "nuestras"]);
5839
+ var langOf = (lang) => lang?.trim().toLowerCase().split(/[-_]/)[0] || void 0;
5840
+ var titleCase = (s) => s.replace(new RegExp("(^|\\s)(\\p{Ll})", "gu"), (_, gap, ch) => gap + ch.toUpperCase());
5841
+ function tokensOf(text2) {
5842
+ return text2.split(" ").map((w) => w === "&" ? w : w.replace(/^[^\p{L}\p{M}\p{N}\p{Sc}]+|[^\p{L}\p{M}\p{N}%+]+$/gu, "")).filter((w) => w === "&" || /[\p{L}\p{N}]/u.test(w));
5843
+ }
5844
+ var hasLetter = (w) => new RegExp("\\p{L}", "u").test(w);
5845
+ function sectionPhrase(heading, { copy = false, lang } = {}) {
5846
+ let whole = heading.replace(/\s+/g, " ").trim();
5847
+ if (!new RegExp("\\p{Ll}", "u").test(whole) && new RegExp("\\p{Lu}", "u").test(whole) && whole.includes(" ")) whole = whole.toLowerCase();
5848
+ const say = (words) => {
5849
+ const named = words.join(" ");
5850
+ const phrase = (copy ? named.charAt(0).toUpperCase() + named.slice(1) : titleCase(named)).slice(0, PHRASE_MAX);
5851
+ return hasLetter(phrase) ? phrase : void 0;
5852
+ };
5853
+ const table = LANGS[langOf(lang) ?? "en"];
5854
+ const split = /([,;:.!?])\s|\s([—–-])\s/u.exec(whole);
5855
+ const clause = tokensOf(split ? whole.slice(0, split.index) : whole);
5856
+ if (split && clause.length === 1 && split[1] !== "," && hasLetter(clause[0]) && !table?.filler.has(clause[0].toLowerCase())) return say(clause);
5857
+ const commaJoined = split?.[1] === "," && clause.length < 2;
5858
+ const said = clause.length >= 2 ? clause : tokensOf(whole);
5859
+ if (said.length === 0) return void 0;
5860
+ if (!table) return say(said.slice(0, 3));
5861
+ const lower = said.map((w) => w.toLowerCase());
5862
+ let meaning = said.flatMap((w, i) => hasLetter(w) && !table.filler.has(lower[i]) ? [i] : []);
5863
+ const short = LEAD.has(lower[0]) && said.length > 1 ? 1 : 0;
5864
+ const rest = said.length - short;
5865
+ const fourOk = rest === 4 && (INTERROGATIVE.has(lower[short]) || meaning.length <= 1);
5866
+ if (!copy && !commaJoined && (rest <= 3 || fourOk) && meaning.length <= 3 && (meaning.length >= 2 || INTERROGATIVE.has(lower[short]) || table.filler.has(lower[short]))) {
5867
+ return say(said.slice(short));
5868
+ }
5869
+ if (meaning.length === 0) return say(said.slice(0, 2));
5870
+ while (meaning.length > 2 && LAST_ADVERBS.has(lower[meaning.at(-1)])) meaning = meaning.slice(0, -1);
5871
+ const [first, last] = [meaning[0], meaning.at(-1)];
5872
+ const end = last + 1 < said.length && !hasLetter(said[last + 1]) ? last + 2 : last + 1;
5873
+ if (meaning.length <= 2 && last - first <= 2) return say(said.slice(first, end));
5874
+ if (copy) return say(meaning.slice(0, 2).map((i) => said[i]));
5875
+ const tail = lower.findIndex((w, i) => i > first && table.tail.has(w));
5876
+ const head = tail < 0 ? meaning : meaning.filter((i) => i < tail);
5877
+ const verbLike = !/(?:[^s]s|ing)$/iu.test(lower[first]);
5878
+ if (tail > 0 && head.length < 2 && first === 0 && said.length >= 4 && verbLike) {
5879
+ const after = meaning.filter((i) => i > tail);
5880
+ const run = after.filter((i, n) => n === 0 || n === 1 && i === after[0] + 1);
5881
+ const kept = run.length > 1 && LAST_ADVERBS.has(lower[run[1]]) ? run.slice(0, 1) : run;
5882
+ if (kept.length > 0) return say(kept.map((i) => said[i]));
5883
+ }
5884
+ return say(head.slice(-2).map((i) => said[i]));
5885
+ }
5886
+ function headingClause(heading) {
5887
+ const whole = heading.replace(/\s+/g, " ").trim();
5888
+ const clause = whole.split(/[,;:.!?]\s|\s[—–-]\s/)[0];
5889
+ const said = clause.split(" ").length >= 3 ? clause : whole;
5890
+ const cut = said.split(" ").filter(Boolean);
5891
+ if (said.length > PHRASE_MAX) {
5892
+ while (cut.length > 1 && cut.join(" ").length > PHRASE_MAX) cut.pop();
5893
+ while (cut.length > 1 && TRAILING.has(cut.at(-1).toLowerCase().replace(/[^\p{L}']/gu, ""))) cut.pop();
5894
+ }
5895
+ const phrase = titleCase(cut.join(" ").replace(/[\p{P}\s]+$/u, "")).slice(0, PHRASE_MAX);
5896
+ return phrase || void 0;
5897
+ }
5898
+ var BOUND = {
5899
+ // "Häufig Gestellte Fragen", "Why Choose Us": a short heading kept whole is a name.
5900
+ block: { words: 4, meaning: 3 },
5901
+ // The block, then the element, then a modifier: "Get In Touch heading", "Header home link URL".
5902
+ field: { words: 7, meaning: 5 }
5903
+ };
5904
+ var FIELD_ROLE_BOX_WORDS = /* @__PURE__ */ new Set(["body", "content"]);
5905
+ var NAME_PART_SEP = " \u203A ";
5906
+ function namingProblem(name2, kind, { copy, lang } = {}) {
5907
+ const filler = (LANGS[langOf(lang) ?? "en"] ?? LANGS.en).filler;
5908
+ const parts = name2.split(NAME_PART_SEP);
5909
+ for (const [n, raw] of parts.entries()) {
5910
+ const part = raw.trim();
5911
+ const as = n < parts.length - 1 ? "block" : kind;
5912
+ const words = tokensOf(part).filter(hasLetter);
5913
+ const suggest = (rule) => {
5914
+ if (rule === "artifact") return { part, rule };
5915
+ const suggested = sectionPhrase(part, { copy: rule === "copy", lang });
5916
+ return { part, rule, ...suggested && suggested !== part && !namingProblem(suggested, as, { lang }) ? { suggested } : {} };
5917
+ };
5918
+ if (isArtifactName(part) && !(as === "field" && FIELD_ROLE_BOX_WORDS.has(part.toLowerCase()))) return suggest("artifact");
5919
+ if (/[.!?]$/u.test(part) || words.length > BOUND[as].words || words.some((w) => w.length > PHRASE_MAX)) return suggest("sentence");
5920
+ if (words.filter((w) => !filler.has(w.toLowerCase())).length > BOUND[as].meaning) return suggest("too-many-words");
5921
+ const said = (copy ?? "").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim().toLowerCase();
5922
+ if (as === "field" && words.length >= 3 && said.startsWith(part.toLowerCase())) return suggest("copy");
5923
+ }
5924
+ return void 0;
5925
+ }
5926
+ var ACRONYMS = { cta: "CTA", faq: "FAQ", seo: "SEO", url: "URL", api: "API", ai: "AI" };
5927
+ var acronymOf = (word) => {
5928
+ const l = word.toLowerCase();
5929
+ return ACRONYMS[l] ?? (l.endsWith("s") && ACRONYMS[l.slice(0, -1)] ? `${ACRONYMS[l.slice(0, -1)]}s` : void 0);
5930
+ };
5931
+ var CODE_WORDS = { href: "link", src: "image", alt: "alt text", id: "", key: "", attr: "" };
5932
+ var CONTROL_WORDS = /* @__PURE__ */ new Set(["link", "links", "button", "menu", "nav"]);
5933
+ function sentenceCase(name2, keep = properNounsOf([name2])) {
5934
+ return name2.split(NAME_PART_SEP).map(
5935
+ (part) => part.trim().split(/\s+/).map((w, i) => acronymOf(w) ?? (i === 0 ? w.charAt(0).toUpperCase() + w.slice(1) : new RegExp("^\\p{Lu}\\p{Ll}+$", "u").test(w) && !keep.has(w) ? w.toLowerCase() : w)).join(" ")
5936
+ ).join(NAME_PART_SEP);
5937
+ }
5938
+ var SMALL_WORDS = /* @__PURE__ */ new Set(["a", "an", "and", "at", "by", "for", "from", "in", "of", "on", "the", "to", "with"]);
5939
+ function properNounsOf(labels, { across = false } = {}) {
5940
+ const firsts = /* @__PURE__ */ new Map();
5941
+ for (const label of labels) {
5942
+ for (const part of label.split(NAME_PART_SEP)) {
5943
+ const [first = "", ...rest] = part.trim().split(/\s+/);
5944
+ if (!rest.some((w) => new RegExp("^\\p{Ll}", "u").test(w) && !SMALL_WORDS.has(w)) || rest.some((w) => new RegExp("^\\p{Lu}", "u").test(w) && SMALL_WORDS.has(w.toLowerCase()))) continue;
5945
+ for (const w of rest) {
5946
+ if (!new RegExp("^\\p{Lu}\\p{Ll}+$", "u").test(w) || acronymOf(w) !== void 0 || VOCABULARY.has(w.toLowerCase())) continue;
5947
+ firsts.set(w, (firsts.get(w) ?? /* @__PURE__ */ new Set()).add(first.toLowerCase()));
5948
+ }
5949
+ }
5950
+ }
5951
+ return new Set([...firsts].filter(([, at]) => !across || at.size >= 2).map(([w]) => w));
5952
+ }
5953
+ function readabilityProblem(name2, opts = {}) {
5954
+ const { tag, button = false, inHeading = false, keep = properNounsOf([name2]) } = opts;
5955
+ const parts = name2.split(NAME_PART_SEP).map((p) => p.trim());
5956
+ const field = parts.at(-1);
5957
+ const words = field.split(/\s+/).filter(Boolean);
5958
+ const final = words.at(-1) ?? "";
5959
+ const fixed = (said) => {
5960
+ if (said.length === 0) return void 0;
5961
+ const next = sentenceCase([...parts.slice(0, -1), said.join(" ")].join(NAME_PART_SEP), keep);
5962
+ return next !== name2 && !readabilityProblem(next, opts) && !namingProblem(next, "field") ? next : void 0;
5963
+ };
5964
+ const problem = (part, rule, suggested) => ({ part, rule, ...suggested ? { suggested } : {} });
5965
+ const code = CODE_WORDS[final.toLowerCase()];
5966
+ if (code !== void 0 && final !== final.toUpperCase()) {
5967
+ const before = words.slice(0, -1);
5968
+ return problem(field, "code-word", fixed(code && before.at(-1)?.toLowerCase() !== code ? [...before, code] : before));
5969
+ }
5970
+ const shouted = parts.find((p) => p.split(/\s+/).some((w) => acronymOf(w) !== void 0 && acronymOf(w) !== w));
5971
+ if (shouted !== void 0) {
5972
+ const next = sentenceCase(name2, keep);
5973
+ const then = next !== name2 ? readabilityProblem(next, { ...opts, keep }) : void 0;
5974
+ return problem(shouted, "acronym-case", next === name2 ? void 0 : then ? then.suggested : next);
5975
+ }
5976
+ const isButton = /^BUTTON$/i.test(tag ?? "");
5977
+ const isAnchor = /^A$/i.test(tag ?? "");
5978
+ const heading = inHeading || isAnchor && /^heading$/i.test(final);
5979
+ if ((isButton || isAnchor) && !heading && /^(?:text|heading)$/i.test(final) && !words.some((w) => CONTROL_WORDS.has(w.toLowerCase()))) {
5980
+ return problem(field, "role-mismatch", fixed([...words.slice(0, -1), ...isButton || button ? ["button", "label"] : ["link", "text"]]));
5981
+ }
5982
+ return void 0;
5983
+ }
5984
+ function caseTwins(labels) {
5985
+ const said = /* @__PURE__ */ new Map();
5986
+ for (const label of labels) {
5987
+ const l = label.trim();
5988
+ said.set(l.toLowerCase(), (said.get(l.toLowerCase()) ?? /* @__PURE__ */ new Set()).add(l));
5989
+ }
5990
+ return new Set([...said.values()].filter((s) => s.size > 1).flatMap((s) => [...s]));
5991
+ }
5992
+ var ORDINAL = /^(?:second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|no\.\s*\d{1,3})\s+(.+)$/i;
5993
+ var ROLE_WORDS = new Set(ROLE_VOCABULARY.map((r) => r.replace(/-/g, " ")));
5994
+ var GLUE_HEADS = [
5995
+ "section",
5996
+ "block",
5997
+ "wrapper",
5998
+ "wrap",
5999
+ "container",
6000
+ "content",
6001
+ "layout",
6002
+ "column",
6003
+ "shell",
6004
+ "region",
6005
+ "cluster",
6006
+ "hero",
6007
+ "features",
6008
+ "feature",
6009
+ "pricing",
6010
+ "testimonials",
6011
+ "faq",
6012
+ "cta",
6013
+ "stats",
6014
+ "logos",
6015
+ "gallery",
6016
+ "contact",
6017
+ "newsletter",
6018
+ "banner"
6019
+ ];
6020
+ var BAND_WORDS = /* @__PURE__ */ new Set([...GLUE_HEADS, ...BOX_WORDS]);
6021
+ var gluedApart = (word) => {
6022
+ if (!new RegExp("^\\p{Lu}?\\p{Ll}{6,}$", "u").test(word)) return void 0;
6023
+ const l = word.toLowerCase();
6024
+ if (VOCABULARY.has(l) || BAND_WORDS.has(l)) return void 0;
6025
+ const head = GLUE_HEADS.find((h) => l.startsWith(h) && l.length - h.length >= 3 && (BAND_WORDS.has(l.slice(h.length)) || BAND_WORDS.has(l.slice(h.length).replace(/s$/, ""))));
6026
+ return head ? `${head} ${l.slice(head.length)}` : void 0;
6027
+ };
6028
+ var ROLE_COUNTED = new RegExp("^(\\p{L}+(?:\\s\\p{L}+)?)\\s+(?:\\d{1,3}|\\p{Ll})$", "u");
6029
+ var gluedKey = (name2, key) => {
6030
+ const parts = (key ?? "").toLowerCase().split(/[^\p{L}]+/u).filter(Boolean);
6031
+ const l = name2.toLowerCase();
6032
+ return parts.length > 1 && new RegExp("^\\p{L}+$", "u").test(name2) && l === parts.join("") && !VOCABULARY.has(l) && !BAND_WORDS.has(l) ? parts.join(" ") : void 0;
6033
+ };
6034
+ var BARE_ROLE = /^(?:text|paragraph|number|link|icon|image|item|element|attribute)$/i;
6035
+ var runOf = (name2) => name2.trim().toLowerCase().replace(/\b\d{1,3}\b/g, "#");
6036
+ var uncounted = (name2) => {
6037
+ const l = name2.trim().toLowerCase();
6038
+ const digit = /^(.*\S)[\s-]+\d{1,3}$/.exec(l)?.[1];
6039
+ return digit ?? ORDINAL.exec(l)?.[1];
6040
+ };
6041
+ function judgeName(name2, kind, ctx = {}) {
6042
+ const { siblings, copy, type, lang, key, ...element } = ctx;
6043
+ const own2 = namingProblem(name2, kind, { copy, lang }) ?? readabilityProblem(name2, element);
6044
+ if (own2) return own2;
6045
+ const parts = name2.split(NAME_PART_SEP).map((p) => p.trim());
6046
+ for (const part of parts) {
6047
+ const ordinal = ORDINAL.exec(part);
6048
+ if (ordinal && ROLE_WORDS.has(ordinal[1].toLowerCase())) return { part, rule: "ordinal" };
6049
+ const twice = new RegExp("(?:^|\\s)(\\p{L}+)\\s+\\1(?=\\s|$)", "iu").exec(part);
6050
+ if (twice) {
6051
+ const once = part.replace(new RegExp(`(^|\\s)(${twice[1]})\\s+${twice[1]}(?=\\s|$)`, "iu"), "$1$2");
6052
+ return { part, rule: "repeated-word", ...judgeName(name2.replace(part, once), kind, { lang }) ? {} : { suggested: name2.replace(part, once) } };
6053
+ }
6054
+ const word = part.split(/\s+/).find((w) => gluedApart(w) !== void 0);
6055
+ const apart = word ? gluedApart(word) : gluedKey(part, key);
6056
+ if (apart) {
6057
+ const next = sentenceCase(name2.replace(word ?? part, apart));
6058
+ return { part, rule: "glued", ...judgeName(next, kind, { lang }) ? {} : { suggested: next } };
6059
+ }
6060
+ const role = ROLE_COUNTED.exec(part);
6061
+ if (role && ROLE_WORDS.has(role[1].toLowerCase())) return { part, rule: "counted" };
6062
+ }
6063
+ if (kind === "block" && isCountedName(name2)) return { part: name2, rule: "counted" };
6064
+ if (!siblings) return void 0;
6065
+ const l = name2.trim();
6066
+ const at = besideOf(siblings);
6067
+ const other = (bucket) => !!bucket?.some((s) => s.name !== l && (!type || !s.type || s.type === type));
6068
+ if (at.byLower.get(l.toLowerCase())?.some((s) => s.name !== l)) return { part: l, rule: "case-twin" };
6069
+ if (type && (at.byLower.get(l.toLowerCase())?.filter((s) => s.name === l && s.type === type).length ?? 0) > 1) return { part: l, rule: "twin" };
6070
+ const run = runOf(l);
6071
+ const ownWords = !!copy && copy.trim().startsWith(l);
6072
+ const bare = uncounted(l);
6073
+ if (!ownWords && run !== l.toLowerCase() && other(at.byRun.get(run))) return { part: l, rule: "counted" };
6074
+ if (!ownWords && bare !== void 0 && other(at.byLower.get(bare))) return { part: l, rule: "counted" };
6075
+ if (!/\d/.test(l) && other(at.byUncounted.get(l.toLowerCase()))) return { part: l, rule: "bare-role" };
6076
+ const ofType = type ? at.byType.get(type) : void 0;
6077
+ if (ofType && BARE_ROLE.test(l) && ofType.size > (ofType.has(l) ? 1 : 0)) return { part: l, rule: "bare-role" };
6078
+ const said = copy ? sentenceOf(copy) : void 0;
6079
+ if (said && l.startsWith(`${said} `)) return { part: said, rule: "copy-sentence" };
6080
+ for (let i = l.indexOf(" "); i > 0; i = l.indexOf(" ", i + 1)) if (at.sentences.has(l.slice(0, i))) return { part: l.slice(0, i), rule: "copy-sentence" };
6081
+ return void 0;
6082
+ }
6083
+ var sentenceOf = (said) => {
6084
+ const whole = headingClause(said);
6085
+ return whole && whole.split(" ").length >= 3 && whole !== sectionPhrase(said) ? whole : void 0;
6086
+ };
6087
+ var prepared = /* @__PURE__ */ new WeakMap();
6088
+ function besideOf(siblings) {
6089
+ const known = prepared.get(siblings);
6090
+ if (known) return known;
6091
+ const at = { byLower: /* @__PURE__ */ new Map(), byRun: /* @__PURE__ */ new Map(), byUncounted: /* @__PURE__ */ new Map(), byType: /* @__PURE__ */ new Map(), sentences: /* @__PURE__ */ new Set() };
6092
+ const add = (map, key, s) => {
6093
+ const bucket = map.get(key);
6094
+ if (bucket) bucket.push(s);
6095
+ else map.set(key, [s]);
6096
+ };
6097
+ for (const raw of siblings) {
6098
+ const one = typeof raw === "string" ? { name: raw } : raw;
6099
+ const s = { name: one.name.trim(), ...one.type ? { type: one.type } : {} };
6100
+ add(at.byLower, s.name.toLowerCase(), s);
6101
+ add(at.byRun, runOf(s.name), s);
6102
+ const bare = uncounted(s.name);
6103
+ if (bare !== void 0) add(at.byUncounted, bare, s);
6104
+ if (s.type) at.byType.set(s.type, (at.byType.get(s.type) ?? /* @__PURE__ */ new Set()).add(s.name));
6105
+ const sentence = typeof raw === "string" || !raw.copy ? void 0 : sentenceOf(raw.copy);
6106
+ if (sentence) at.sentences.add(sentence);
6107
+ }
6108
+ prepared.set(siblings, at);
6109
+ return at;
6110
+ }
6111
+
5545
6112
  // src/icon-value.ts
5546
6113
  import { iconSvg as iconSvg2 } from "@bettercms-ai/icons/markup";
5547
6114
  var ICON_SOURCES = ["pack", "library", "upload"];
@@ -5624,6 +6191,7 @@ export {
5624
6191
  BLOCK_FIELD_TYPES,
5625
6192
  BLOCK_FIELD_TYPES_RENDERABLE_NOW,
5626
6193
  BODY_SCHEMA_ORIGINS,
6194
+ BOX_WORDS,
5627
6195
  BREAKPOINTS,
5628
6196
  BUTTON_ACTIONS,
5629
6197
  BUTTON_FULL_WIDTH_INVALID,
@@ -5693,11 +6261,13 @@ export {
5693
6261
  MAIN_SELECTOR,
5694
6262
  MAX_LOCAL_SETUP_BYTES,
5695
6263
  MAX_SITE_MAP_BYTES,
6264
+ NAME_PART_SEP,
5696
6265
  NAVIGATION_SECTION_ID,
5697
6266
  OPEN_MODES,
5698
6267
  OPEN_MODE_TYPES,
5699
6268
  OPTION_DESCRIPTION_MAX,
5700
6269
  PAGE_CONTENT_ANCHOR_ID,
6270
+ PHRASE_MAX,
5701
6271
  PRIMITIVE_ARRAY_RULE,
5702
6272
  REFERENCE_CREATE_REFUSAL_CODES,
5703
6273
  RESPONSIVE_CSS,
@@ -5712,6 +6282,7 @@ export {
5712
6282
  RICHTEXT_MARK_FEATURES,
5713
6283
  RICHTEXT_TOGGLE_FEATURES,
5714
6284
  ROLE_KEYS,
6285
+ ROLE_VOCABULARY,
5715
6286
  SCHEMA_HASH_INPUTS,
5716
6287
  SECTION_ANCHOR,
5717
6288
  SECTION_CSS_CLASS,
@@ -5776,6 +6347,7 @@ export {
5776
6347
  buttonVariantOf,
5777
6348
  candidateRole,
5778
6349
  canonicalJson,
6350
+ caseTwins,
5779
6351
  compactIcon,
5780
6352
  componentInstanceAddresses,
5781
6353
  componentPropTargetKey,
@@ -5800,6 +6372,7 @@ export {
5800
6372
  formatNumber,
5801
6373
  formatPropsAttribute,
5802
6374
  getBlockType,
6375
+ headingClause,
5803
6376
  headingPaintCss,
5804
6377
  hiddenEverywhere,
5805
6378
  hideOnAttr,
@@ -5809,11 +6382,13 @@ export {
5809
6382
  iconValueProblem,
5810
6383
  imageFrameCss,
5811
6384
  inWindow,
6385
+ isArtifactName,
5812
6386
  isBlock,
5813
6387
  isButtonLookValue,
5814
6388
  isChromeLandmark,
5815
6389
  isCodeButton,
5816
6390
  isComponentGateCode,
6391
+ isCountedName,
5817
6392
  isDeriveReservedKey,
5818
6393
  isDockUiImportAllowed,
5819
6394
  isEmbedReason,
@@ -5828,6 +6403,7 @@ export {
5828
6403
  isTableValue,
5829
6404
  isUiRefusal,
5830
6405
  isVariantVisible,
6406
+ judgeName,
5831
6407
  keyWords,
5832
6408
  landmarkRegions,
5833
6409
  linkAnchorOf,
@@ -5837,6 +6413,7 @@ export {
5837
6413
  locatorFor,
5838
6414
  locatorPath,
5839
6415
  mayOverwrite,
6416
+ namingProblem,
5840
6417
  normaliseRichTextFeatures,
5841
6418
  normalizeIcon,
5842
6419
  normalizeLinkValue,
@@ -5850,9 +6427,11 @@ export {
5850
6427
  pickFieldStyle,
5851
6428
  placementBindOf,
5852
6429
  planSections,
6430
+ properNounsOf,
5853
6431
  readButtonValue,
5854
6432
  readNumberFormat,
5855
6433
  readPath,
6434
+ readabilityProblem,
5856
6435
  referenceCreateRefusal,
5857
6436
  regionOf,
5858
6437
  renderTableHtml,
@@ -5862,6 +6441,8 @@ export {
5862
6441
  safeCssUrl,
5863
6442
  schemaHashInput,
5864
6443
  sectionIdentityAttrs,
6444
+ sectionPhrase,
6445
+ sentenceCase,
5865
6446
  sideFloorApplies,
5866
6447
  sideSpaceCss,
5867
6448
  slotBindOf,