@wix/himalaya-cli 0.1080.0 → 0.1081.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.
@@ -4,6 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
8
  var __commonJS = (cb, mod) => function __require() {
8
9
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
10
  };
@@ -23,6 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
25
  mod
25
26
  ));
27
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
26
28
 
27
29
  // ../../node_modules/ajv/dist/compile/codegen/code.js
28
30
  var require_code = __commonJS({
@@ -92,7 +94,7 @@ var require_code = __commonJS({
92
94
  }
93
95
  exports._ = _;
94
96
  var plus = new _Code("+");
95
- function str(strs, ...args) {
97
+ function str2(strs, ...args) {
96
98
  const expr = [safeStringify(strs[0])];
97
99
  let i = 0;
98
100
  while (i < args.length) {
@@ -103,7 +105,7 @@ var require_code = __commonJS({
103
105
  optimize(expr);
104
106
  return new _Code(expr);
105
107
  }
106
- exports.str = str;
108
+ exports.str = str2;
107
109
  function addCodeArg(code, arg) {
108
110
  if (arg instanceof _Code)
109
111
  code.push(...arg._items);
@@ -146,7 +148,7 @@ var require_code = __commonJS({
146
148
  return;
147
149
  }
148
150
  function strConcat(c1, c2) {
149
- return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str`${c1}${c2}`;
151
+ return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str2`${c1}${c2}`;
150
152
  }
151
153
  exports.strConcat = strConcat;
152
154
  function interpolate(x) {
@@ -1108,22 +1110,22 @@ var require_util = __commonJS({
1108
1110
  return (0, codegen_1._)`${topSchemaRef}${schemaPath}${(0, codegen_1.getProperty)(keyword)}`;
1109
1111
  }
1110
1112
  exports.schemaRefOrVal = schemaRefOrVal;
1111
- function unescapeFragment(str) {
1112
- return unescapeJsonPointer(decodeURIComponent(str));
1113
+ function unescapeFragment(str2) {
1114
+ return unescapeJsonPointer(decodeURIComponent(str2));
1113
1115
  }
1114
1116
  exports.unescapeFragment = unescapeFragment;
1115
- function escapeFragment(str) {
1116
- return encodeURIComponent(escapeJsonPointer(str));
1117
+ function escapeFragment(str2) {
1118
+ return encodeURIComponent(escapeJsonPointer(str2));
1117
1119
  }
1118
1120
  exports.escapeFragment = escapeFragment;
1119
- function escapeJsonPointer(str) {
1120
- if (typeof str == "number")
1121
- return `${str}`;
1122
- return str.replace(/~/g, "~0").replace(/\//g, "~1");
1121
+ function escapeJsonPointer(str2) {
1122
+ if (typeof str2 == "number")
1123
+ return `${str2}`;
1124
+ return str2.replace(/~/g, "~0").replace(/\//g, "~1");
1123
1125
  }
1124
1126
  exports.escapeJsonPointer = escapeJsonPointer;
1125
- function unescapeJsonPointer(str) {
1126
- return str.replace(/~1/g, "/").replace(/~0/g, "~");
1127
+ function unescapeJsonPointer(str2) {
1128
+ return str2.replace(/~1/g, "/").replace(/~0/g, "~");
1127
1129
  }
1128
1130
  exports.unescapeJsonPointer = unescapeJsonPointer;
1129
1131
  function eachItem(xs, f) {
@@ -2148,8 +2150,8 @@ var require_json_schema_traverse = __commonJS({
2148
2150
  post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
2149
2151
  }
2150
2152
  }
2151
- function escapeJsonPtr(str) {
2152
- return str.replace(/~/g, "~0").replace(/\//g, "~1");
2153
+ function escapeJsonPtr(str2) {
2154
+ return str2.replace(/~/g, "~0").replace(/\//g, "~1");
2153
2155
  }
2154
2156
  }
2155
2157
  });
@@ -3213,10 +3215,10 @@ var require_utils = __commonJS({
3213
3215
  return { host, isIPV6: false };
3214
3216
  }
3215
3217
  }
3216
- function findToken(str, token) {
3218
+ function findToken(str2, token) {
3217
3219
  let ind = 0;
3218
- for (let i = 0; i < str.length; i++) {
3219
- if (str[i] === token) ind++;
3220
+ for (let i = 0; i < str2.length; i++) {
3221
+ if (str2[i] === token) ind++;
3220
3222
  }
3221
3223
  return ind;
3222
3224
  }
@@ -3953,7 +3955,7 @@ var require_core = __commonJS({
3953
3955
  var util_1 = require_util();
3954
3956
  var $dataRefSchema = require_data();
3955
3957
  var uri_1 = require_uri();
3956
- var defaultRegExp = (str, flags) => new RegExp(str, flags);
3958
+ var defaultRegExp = (str2, flags) => new RegExp(str2, flags);
3957
3959
  defaultRegExp.code = "new RegExp";
3958
3960
  var META_IGNORE_OPTIONS = ["removeAdditional", "useDefaults", "coerceTypes"];
3959
3961
  var EXT_SCOPE_NAMES = /* @__PURE__ */ new Set([
@@ -4748,16 +4750,16 @@ var require_ucs2length = __commonJS({
4748
4750
  "../../node_modules/ajv/dist/runtime/ucs2length.js"(exports) {
4749
4751
  "use strict";
4750
4752
  Object.defineProperty(exports, "__esModule", { value: true });
4751
- function ucs2length(str) {
4752
- const len = str.length;
4753
+ function ucs2length(str2) {
4754
+ const len = str2.length;
4753
4755
  let length = 0;
4754
4756
  let pos = 0;
4755
4757
  let value;
4756
4758
  while (pos < len) {
4757
4759
  length++;
4758
- value = str.charCodeAt(pos++);
4760
+ value = str2.charCodeAt(pos++);
4759
4761
  if (value >= 55296 && value <= 56319 && pos < len) {
4760
- value = str.charCodeAt(pos);
4762
+ value = str2.charCodeAt(pos);
4761
4763
  if ((value & 64512) === 56320)
4762
4764
  pos++;
4763
4765
  }
@@ -6640,8 +6642,8 @@ var require_formats = __commonJS({
6640
6642
  }
6641
6643
  var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
6642
6644
  var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
6643
- function date(str) {
6644
- const matches = DATE.exec(str);
6645
+ function date(str2) {
6646
+ const matches = DATE.exec(str2);
6645
6647
  if (!matches)
6646
6648
  return false;
6647
6649
  const year = +matches[1];
@@ -6660,8 +6662,8 @@ var require_formats = __commonJS({
6660
6662
  }
6661
6663
  var TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;
6662
6664
  function getTime(strictTimeZone) {
6663
- return function time(str) {
6664
- const matches = TIME.exec(str);
6665
+ return function time(str2) {
6666
+ const matches = TIME.exec(str2);
6665
6667
  if (!matches)
6666
6668
  return false;
6667
6669
  const hr = +matches[1];
@@ -6707,8 +6709,8 @@ var require_formats = __commonJS({
6707
6709
  var DATE_TIME_SEPARATOR = /t|\s/i;
6708
6710
  function getDateTime(strictTimeZone) {
6709
6711
  const time = getTime(strictTimeZone);
6710
- return function date_time(str) {
6711
- const dateTime = str.split(DATE_TIME_SEPARATOR);
6712
+ return function date_time(str2) {
6713
+ const dateTime = str2.split(DATE_TIME_SEPARATOR);
6712
6714
  return dateTime.length === 2 && date(dateTime[0]) && time(dateTime[1]);
6713
6715
  };
6714
6716
  }
@@ -6733,13 +6735,13 @@ var require_formats = __commonJS({
6733
6735
  }
6734
6736
  var NOT_URI_FRAGMENT = /\/|:/;
6735
6737
  var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
6736
- function uri(str) {
6737
- return NOT_URI_FRAGMENT.test(str) && URI.test(str);
6738
+ function uri(str2) {
6739
+ return NOT_URI_FRAGMENT.test(str2) && URI.test(str2);
6738
6740
  }
6739
6741
  var BYTE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;
6740
- function byte(str) {
6742
+ function byte(str2) {
6741
6743
  BYTE.lastIndex = 0;
6742
- return BYTE.test(str);
6744
+ return BYTE.test(str2);
6743
6745
  }
6744
6746
  var MIN_INT32 = -(2 ** 31);
6745
6747
  var MAX_INT32 = 2 ** 31 - 1;
@@ -6753,11 +6755,11 @@ var require_formats = __commonJS({
6753
6755
  return true;
6754
6756
  }
6755
6757
  var Z_ANCHOR = /[^\\]\\Z/;
6756
- function regex(str) {
6757
- if (Z_ANCHOR.test(str))
6758
+ function regex(str2) {
6759
+ if (Z_ANCHOR.test(str2))
6758
6760
  return false;
6759
6761
  try {
6760
- new RegExp(str);
6762
+ new RegExp(str2);
6761
6763
  return true;
6762
6764
  } catch (e) {
6763
6765
  return false;
@@ -8015,6 +8017,446 @@ function workerSubtreePolicyErrors(policy) {
8015
8017
  return out;
8016
8018
  }
8017
8019
 
8020
+ // ../../core/ts/src/rich-content-limits.generated.ts
8021
+ var RICH_CONTENT_LIMITS = Object.freeze({ maxBytes: 262144, maxNodes: 5e3, maxDepth: 16 });
8022
+
8023
+ // ../../core/ts/src/rich-content.ts
8024
+ var RICH_CONTENT_LIMITS2 = RICH_CONTENT_LIMITS;
8025
+ var RICH_CONTENT_CARD_LABELS = Object.freeze({
8026
+ EMBED: "Embedded content",
8027
+ HTML: "Embedded content",
8028
+ APP_EMBED: "Embedded content",
8029
+ LINK_PREVIEW: "Link",
8030
+ POLL: "Poll",
8031
+ FILE: "File",
8032
+ AUDIO: "Audio",
8033
+ MAP: "Map",
8034
+ GIF: "GIF",
8035
+ VIDEO: "Video"
8036
+ });
8037
+ var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
8038
+ var str = (v) => typeof v === "string" ? v : "";
8039
+ var kids = (n) => Array.isArray(n.nodes) ? n.nodes : [];
8040
+ var typeOf = (n) => typeof n.type === "string" ? n.type : "";
8041
+ function at(v, ...keys) {
8042
+ let c = v;
8043
+ for (const k of keys) {
8044
+ if (!isObj(c)) return void 0;
8045
+ c = c[k];
8046
+ }
8047
+ return c;
8048
+ }
8049
+ function int(v) {
8050
+ return typeof v === "number" && Number.isInteger(v) && v >= -2147483648 && v <= 2147483647 ? v : void 0;
8051
+ }
8052
+ var LINK = /^(https?:\/\/[^\s/?#]\S*|mailto:\S+|tel:\S+)$/i;
8053
+ var MEDIA = /^https:\/\/[^\s/?#]\S*$/i;
8054
+ var AUTHORITY = /^https?:\/\/([^/?#]*)/i;
8055
+ function richContentLinkUrl(raw) {
8056
+ if (typeof raw !== "string") return void 0;
8057
+ const url = raw.trim();
8058
+ return LINK.test(url) ? url : void 0;
8059
+ }
8060
+ function richContentMediaUrl(raw) {
8061
+ return typeof raw === "string" && MEDIA.test(raw) ? raw : void 0;
8062
+ }
8063
+ var isHttp = (url) => /^https?:\/\//i.test(url);
8064
+ var asciiLower = (s) => s.replace(/[A-Z]/g, (c) => c.toLowerCase());
8065
+ function richContentHost(url) {
8066
+ const m = AUTHORITY.exec(url);
8067
+ if (m) {
8068
+ const authority = m[1].slice(m[1].lastIndexOf("@") + 1);
8069
+ if (authority.startsWith("[")) {
8070
+ const close = authority.indexOf("]");
8071
+ return asciiLower(close >= 0 ? authority.slice(0, close + 1) : authority);
8072
+ }
8073
+ const colon2 = authority.indexOf(":");
8074
+ return asciiLower(colon2 >= 0 ? authority.slice(0, colon2) : authority);
8075
+ }
8076
+ const colon = url.indexOf(":");
8077
+ return colon > 0 && /^(mailto|tel)$/i.test(url.slice(0, colon)) ? url.slice(colon + 1) : "";
8078
+ }
8079
+ var VIDEO_CARD_HOSTS = /* @__PURE__ */ new Set([
8080
+ "youtube.com",
8081
+ "www.youtube.com",
8082
+ "m.youtube.com",
8083
+ "youtu.be",
8084
+ "vimeo.com",
8085
+ "www.vimeo.com",
8086
+ "player.vimeo.com"
8087
+ ]);
8088
+ var sameStyle = (a, b) => a.bold === b.bold && a.italic === b.italic && a.underline === b.underline && a.link === b.link;
8089
+ function pushSpan(out, s) {
8090
+ if (s.text === "") return;
8091
+ const last = out[out.length - 1];
8092
+ if (last && sameStyle(last, s)) last.text += s.text;
8093
+ else out.push(s);
8094
+ }
8095
+ function spanOf(textNode) {
8096
+ const text2 = str(at(textNode, "textData", "text"));
8097
+ if (text2 === "") return null;
8098
+ let bold = false, italic = false, underline = false;
8099
+ let link;
8100
+ const decorations = at(textNode, "textData", "decorations");
8101
+ if (Array.isArray(decorations)) {
8102
+ for (const d of decorations) {
8103
+ if (!isObj(d)) continue;
8104
+ switch (d.type) {
8105
+ case "BOLD":
8106
+ if (!(typeof d.fontWeightValue === "number" && d.fontWeightValue < 600)) bold = true;
8107
+ break;
8108
+ case "ITALIC":
8109
+ if (d.italicData !== false) italic = true;
8110
+ break;
8111
+ case "UNDERLINE":
8112
+ if (d.underlineData !== false) underline = true;
8113
+ break;
8114
+ case "LINK": {
8115
+ const url = richContentLinkUrl(at(d, "linkData", "link", "url"));
8116
+ if (url !== void 0) link = url;
8117
+ break;
8118
+ }
8119
+ default:
8120
+ break;
8121
+ }
8122
+ }
8123
+ }
8124
+ const span = { text: text2 };
8125
+ if (bold) span.bold = true;
8126
+ if (italic) span.italic = true;
8127
+ if (underline) span.underline = true;
8128
+ if (link !== void 0) span.link = link;
8129
+ return span;
8130
+ }
8131
+ function spansOf(node) {
8132
+ const out = [];
8133
+ for (const k of kids(node)) {
8134
+ if (!isObj(k) || typeOf(k) !== "TEXT") continue;
8135
+ const s = spanOf(k);
8136
+ if (s) pushSpan(out, s);
8137
+ }
8138
+ return out;
8139
+ }
8140
+ function textOf(node) {
8141
+ let out = "";
8142
+ for (const k of kids(node)) if (isObj(k) && typeOf(k) === "TEXT") out += str(at(k, "textData", "text"));
8143
+ return out;
8144
+ }
8145
+ function plainText(node) {
8146
+ if (typeOf(node) === "TEXT") return str(at(node, "textData", "text"));
8147
+ const children = kids(node).filter(isObj);
8148
+ const sep = children.every((c) => typeOf(c) === "TEXT") ? "" : "\n";
8149
+ return children.map(plainText).join(sep);
8150
+ }
8151
+ var PATH_SHAPED = /^[0-9.]+$/;
8152
+ var usableId = (raw) => raw !== "" && !PATH_SHAPED.test(raw) && !raw.includes("/") && !raw.includes("$");
8153
+ var Ids = class {
8154
+ constructor() {
8155
+ __publicField(this, "claimed", /* @__PURE__ */ new Set());
8156
+ }
8157
+ claim(n, path) {
8158
+ const raw = n.id;
8159
+ const id = typeof raw === "string" && usableId(raw) && !this.claimed.has(raw) ? raw : path;
8160
+ this.claimed.add(id);
8161
+ return id;
8162
+ }
8163
+ };
8164
+ function alignOf(v) {
8165
+ switch (v) {
8166
+ case "LEFT":
8167
+ return "left";
8168
+ case "CENTER":
8169
+ return "center";
8170
+ case "RIGHT":
8171
+ return "right";
8172
+ case "JUSTIFY":
8173
+ return "justify";
8174
+ default:
8175
+ return void 0;
8176
+ }
8177
+ }
8178
+ var CARD_TYPES = /* @__PURE__ */ new Set(["EMBED", "HTML", "APP_EMBED", "LINK_PREVIEW", "POLL", "FILE", "AUDIO", "MAP", "GIF"]);
8179
+ function cardFields(n, type) {
8180
+ const firstLink = (...candidates) => {
8181
+ for (const c of candidates) {
8182
+ const u = richContentLinkUrl(c);
8183
+ if (u !== void 0) return u;
8184
+ }
8185
+ return void 0;
8186
+ };
8187
+ switch (type) {
8188
+ case "EMBED":
8189
+ return { title: str(at(n, "embedData", "oembed", "title")), url: firstLink(at(n, "embedData", "oembed", "url"), at(n, "embedData", "src")) };
8190
+ case "HTML":
8191
+ return { title: "", url: firstLink(at(n, "htmlData", "url")) };
8192
+ case "APP_EMBED":
8193
+ return { title: str(at(n, "appEmbedData", "name")), url: firstLink(at(n, "appEmbedData", "url")) };
8194
+ case "LINK_PREVIEW":
8195
+ return { title: str(at(n, "linkPreviewData", "title")), url: firstLink(at(n, "linkPreviewData", "link", "url")) };
8196
+ case "POLL":
8197
+ return { title: str(at(n, "pollData", "poll", "title")) };
8198
+ case "FILE":
8199
+ return { title: str(at(n, "fileData", "name")), url: firstLink(at(n, "fileData", "src", "url")) };
8200
+ case "AUDIO":
8201
+ return { title: str(at(n, "audioData", "name")), url: firstLink(at(n, "audioData", "audio", "src", "url")) };
8202
+ case "MAP": {
8203
+ const location = str(at(n, "mapData", "mapSettings", "locationName"));
8204
+ return { title: location !== "" ? location : str(at(n, "mapData", "mapSettings", "address")) };
8205
+ }
8206
+ case "GIF":
8207
+ return { title: "", url: firstLink(at(n, "gifData", "original", "gif")) };
8208
+ default:
8209
+ return { title: "" };
8210
+ }
8211
+ }
8212
+ function card(id, nodeType, title, url) {
8213
+ const b = { kind: "card", id, title, nodeType };
8214
+ if (url !== void 0) b.url = url;
8215
+ return b;
8216
+ }
8217
+ function forceBold(blocks) {
8218
+ return blocks.map((b) => {
8219
+ switch (b.kind) {
8220
+ case "paragraph": {
8221
+ const spans = [];
8222
+ for (const s of b.spans) pushSpan(spans, { ...s, bold: true });
8223
+ return { ...b, spans };
8224
+ }
8225
+ case "quote":
8226
+ return { ...b, blocks: forceBold(b.blocks) };
8227
+ case "list":
8228
+ return { ...b, items: b.items.map((it) => ({ id: it.id, blocks: forceBold(it.blocks) })) };
8229
+ default:
8230
+ return b;
8231
+ }
8232
+ });
8233
+ }
8234
+ function blocksOf(ids, nodes, prefix) {
8235
+ const out = [];
8236
+ nodes.forEach((n, i) => {
8237
+ if (isObj(n)) out.push(...blockOf(ids, n, prefix === "" ? String(i) : `${prefix}.${i}`));
8238
+ });
8239
+ return out;
8240
+ }
8241
+ function blockOf(ids, n, path) {
8242
+ const type = typeOf(n);
8243
+ switch (type) {
8244
+ case "PARAGRAPH": {
8245
+ const b = { kind: "paragraph", id: ids.claim(n, path), spans: spansOf(n) };
8246
+ const align = alignOf(at(n, "paragraphData", "textStyle", "textAlignment"));
8247
+ if (align) b.align = align;
8248
+ const indent = int(at(n, "paragraphData", "indentation"));
8249
+ if (indent !== void 0 && indent > 0) b.indent = indent;
8250
+ return [b];
8251
+ }
8252
+ case "HEADING": {
8253
+ const raw = int(at(n, "headingData", "level"));
8254
+ const level = raw !== void 0 && raw >= 1 && raw <= 6 ? raw : 2;
8255
+ return [{ kind: "heading", id: ids.claim(n, path), level, spans: spansOf(n) }];
8256
+ }
8257
+ case "BULLETED_LIST":
8258
+ case "ORDERED_LIST": {
8259
+ const ordered = type === "ORDERED_LIST";
8260
+ const b = { kind: "list", id: ids.claim(n, path), ordered, items: [] };
8261
+ const start = int(at(n, "orderedListData", "start"));
8262
+ if (ordered && start !== void 0 && start !== 1) b.start = start;
8263
+ kids(n).forEach((k, j) => {
8264
+ if (!isObj(k) || typeOf(k) !== "LIST_ITEM") return;
8265
+ const itemPath = `${path}.${j}`;
8266
+ const itemId = ids.claim(k, itemPath);
8267
+ b.items.push({ id: itemId, blocks: blocksOf(ids, kids(k), itemPath) });
8268
+ });
8269
+ return [b];
8270
+ }
8271
+ case "BLOCKQUOTE": {
8272
+ const id = ids.claim(n, path);
8273
+ return [{ kind: "quote", id, blocks: blocksOf(ids, kids(n), path) }];
8274
+ }
8275
+ case "CODE_BLOCK":
8276
+ return [{ kind: "code", id: ids.claim(n, path), text: textOf(n) }];
8277
+ case "DIVIDER":
8278
+ return [{ kind: "divider", id: ids.claim(n, path) }];
8279
+ case "IMAGE": {
8280
+ const src = richContentMediaUrl(at(n, "imageData", "image", "src", "url"));
8281
+ if (src === void 0) return [];
8282
+ const b = { kind: "image", id: ids.claim(n, path), src };
8283
+ const alt = str(at(n, "imageData", "altText"));
8284
+ if (alt !== "") b.alt = alt;
8285
+ let caption = str(at(n, "imageData", "caption"));
8286
+ if (caption === "") {
8287
+ const node = kids(n).find((k) => isObj(k) && typeOf(k) === "CAPTION");
8288
+ if (isObj(node)) caption = textOf(node);
8289
+ }
8290
+ if (caption !== "") b.caption = caption;
8291
+ const w = int(at(n, "imageData", "image", "width"));
8292
+ if (w !== void 0 && w > 0) b.width = w;
8293
+ const h = int(at(n, "imageData", "image", "height"));
8294
+ if (h !== void 0 && h > 0) b.height = h;
8295
+ return [b];
8296
+ }
8297
+ case "GALLERY": {
8298
+ const images = [];
8299
+ const items = at(n, "galleryData", "items");
8300
+ if (Array.isArray(items)) {
8301
+ for (const item of items) {
8302
+ const src = richContentMediaUrl(at(item, "image", "media", "src", "url"));
8303
+ if (src === void 0) continue;
8304
+ const image2 = { src };
8305
+ const alt = str(at(item, "altText"));
8306
+ if (alt !== "") image2.alt = alt;
8307
+ images.push(image2);
8308
+ }
8309
+ }
8310
+ return images.length ? [{ kind: "gallery", id: ids.claim(n, path), images }] : [];
8311
+ }
8312
+ case "VIDEO": {
8313
+ const raw = at(n, "videoData", "video", "src", "url");
8314
+ const link = richContentLinkUrl(raw);
8315
+ if (link !== void 0 && isHttp(link) && VIDEO_CARD_HOSTS.has(richContentHost(link))) {
8316
+ return [card(ids.claim(n, path), "VIDEO", str(at(n, "videoData", "title")), link)];
8317
+ }
8318
+ const src = richContentMediaUrl(raw);
8319
+ if (src === void 0) return [];
8320
+ const b = { kind: "video", id: ids.claim(n, path), src };
8321
+ const poster = richContentMediaUrl(at(n, "videoData", "thumbnail", "src", "url"));
8322
+ if (poster !== void 0) b.poster = poster;
8323
+ return [b];
8324
+ }
8325
+ case "BUTTON":
8326
+ case "LINK_BUTTON": {
8327
+ const url = richContentLinkUrl(at(n, "buttonData", "link", "url"));
8328
+ if (url === void 0) return [];
8329
+ return [{ kind: "button", id: ids.claim(n, path), label: str(at(n, "buttonData", "text")), url }];
8330
+ }
8331
+ case "TABLE": {
8332
+ const rows = [];
8333
+ for (const r of kids(n)) {
8334
+ if (!isObj(r) || typeOf(r) !== "TABLE_ROW") continue;
8335
+ rows.push(kids(r).filter(isObj).filter((c) => typeOf(c) === "TABLE_CELL").map((c) => kids(c).filter(isObj).map(textOf).join("\n")));
8336
+ }
8337
+ return rows.length ? [{ kind: "table", id: ids.claim(n, path), rows }] : [];
8338
+ }
8339
+ case "COLLAPSIBLE_LIST": {
8340
+ const out = [];
8341
+ kids(n).forEach((item, j) => {
8342
+ if (!isObj(item)) return;
8343
+ kids(item).forEach((part, k) => {
8344
+ if (!isObj(part)) return;
8345
+ const bs = blocksOf(ids, kids(part), `${path}.${j}.${k}`);
8346
+ out.push(...typeOf(part) === "COLLAPSIBLE_ITEM_TITLE" ? forceBold(bs) : bs);
8347
+ });
8348
+ });
8349
+ return out;
8350
+ }
8351
+ case "TEXT": {
8352
+ const s = spanOf(n);
8353
+ return s ? [{ kind: "paragraph", id: ids.claim(n, path), spans: [s] }] : [];
8354
+ }
8355
+ default: {
8356
+ if (CARD_TYPES.has(type)) {
8357
+ const { title, url } = cardFields(n, type);
8358
+ return [card(ids.claim(n, path), type, title, url)];
8359
+ }
8360
+ const text2 = plainText(n);
8361
+ return text2.trim() !== "" ? [{ kind: "paragraph", id: ids.claim(n, path), spans: [{ text: text2 }] }] : [];
8362
+ }
8363
+ }
8364
+ }
8365
+ function utf8Length(s, cap) {
8366
+ let n = 0;
8367
+ for (let i = 0; i < s.length; i++) {
8368
+ const c = s.charCodeAt(i);
8369
+ if (c < 128) n += 1;
8370
+ else if (c < 2048) n += 2;
8371
+ else if (c >= 55296 && c <= 56319 && i + 1 < s.length && (s.charCodeAt(i + 1) & 64512) === 56320) {
8372
+ n += 4;
8373
+ i++;
8374
+ } else n += 3;
8375
+ if (n > cap) return n;
8376
+ }
8377
+ return n;
8378
+ }
8379
+ function repairLoneSurrogateEscapes(json) {
8380
+ if (!json.includes("\\u")) return json;
8381
+ const hexAt = (i) => {
8382
+ const h = json.slice(i, i + 4);
8383
+ return /^[0-9A-Fa-f]{4}$/.test(h) ? parseInt(h, 16) : -1;
8384
+ };
8385
+ let out = "";
8386
+ let inString = false;
8387
+ for (let i = 0; i < json.length; i++) {
8388
+ const c = json[i];
8389
+ if (!inString) {
8390
+ if (c === '"') inString = true;
8391
+ out += c;
8392
+ continue;
8393
+ }
8394
+ if (c === '"') {
8395
+ inString = false;
8396
+ out += c;
8397
+ continue;
8398
+ }
8399
+ if (c !== "\\" || i + 1 >= json.length) {
8400
+ out += c;
8401
+ continue;
8402
+ }
8403
+ const e = json[i + 1];
8404
+ const v = e === "u" ? hexAt(i + 2) : -1;
8405
+ if (v < 0) {
8406
+ out += c + e;
8407
+ i++;
8408
+ continue;
8409
+ }
8410
+ if (v >= 55296 && v <= 56319) {
8411
+ const low = json[i + 6] === "\\" && json[i + 7] === "u" ? hexAt(i + 8) : -1;
8412
+ if (low >= 56320 && low <= 57343) {
8413
+ out += json.slice(i, i + 12);
8414
+ i += 11;
8415
+ continue;
8416
+ }
8417
+ out += "\\ufffd";
8418
+ i += 5;
8419
+ continue;
8420
+ }
8421
+ if (v >= 56320 && v <= 57343) {
8422
+ out += "\\ufffd";
8423
+ i += 5;
8424
+ continue;
8425
+ }
8426
+ out += json.slice(i, i + 6);
8427
+ i += 5;
8428
+ }
8429
+ return out;
8430
+ }
8431
+ function measure(nodes, limits) {
8432
+ let count = 0;
8433
+ const work = [];
8434
+ for (let i = nodes.length - 1; i >= 0; i--) work.push([nodes[i], 1]);
8435
+ while (work.length) {
8436
+ const [n, depth] = work.pop();
8437
+ if (!isObj(n)) continue;
8438
+ if (depth > limits.maxDepth) return "too_deep";
8439
+ count++;
8440
+ const k = kids(n);
8441
+ for (let i = k.length - 1; i >= 0; i--) work.push([k[i], depth + 1]);
8442
+ }
8443
+ return count > limits.maxNodes ? "too_many_nodes" : null;
8444
+ }
8445
+ function layoutRichContent(json, limits = RICH_CONTENT_LIMITS2) {
8446
+ if (json === "") return { blocks: [] };
8447
+ if (utf8Length(json, limits.maxBytes) > limits.maxBytes) return { rejected: "too_large" };
8448
+ let parsed;
8449
+ try {
8450
+ parsed = JSON.parse(repairLoneSurrogateEscapes(json));
8451
+ } catch {
8452
+ return { rejected: "invalid_json" };
8453
+ }
8454
+ if (!isObj(parsed) || !Array.isArray(parsed.nodes)) return { rejected: "not_a_document" };
8455
+ const over = measure(parsed.nodes, limits);
8456
+ if (over) return { rejected: over };
8457
+ return { blocks: blocksOf(new Ids(), parsed.nodes, "") };
8458
+ }
8459
+
8018
8460
  // ../../core/dev-server/src/builder.ts
8019
8461
  var auto = (_kind) => "";
8020
8462
  function slugId(prefix, key) {
@@ -8046,7 +8488,7 @@ function text(text2, style, opts) {
8046
8488
  body: { package: "himalaya", type: "Text", props: { text: text2, style, color: opts?.color, maxLines: opts?.maxLines, collapseWhenEmpty: opts?.collapseWhenEmpty, animateValue: opts?.animateValue, animateReveal: opts?.animateReveal, markdown: opts?.markdown, textDirection: opts?.textDirection } }
8047
8489
  };
8048
8490
  }
8049
- function card(children, opts) {
8491
+ function card2(children, opts) {
8050
8492
  return {
8051
8493
  id: opts?.id ?? auto("card"),
8052
8494
  body: { package: "himalaya", type: "Card", props: { children } }
@@ -8154,6 +8596,22 @@ function legend(props, opts) {
8154
8596
  function dataTable(props, opts) {
8155
8597
  return { id: opts?.id ?? auto("data_table"), body: { package: "himalaya", type: "DataTable", props } };
8156
8598
  }
8599
+ var RICH_CONTENT_PATH = /^(?:\$service:[A-Za-z][A-Za-z0-9_-]{0,63}\.[A-Za-z0-9_.[\]-]+|\$item\.[A-Za-z0-9_]+)$/;
8600
+ function richContent(props, opts) {
8601
+ if (!opts?.id) throw new Error("richContent: an explicit id is required \u2014 child test ids are `<id>/<blockId>` (invariant 27)");
8602
+ const hasPath = props.documentJsonPath !== void 0;
8603
+ const hasLiteral = props.documentJson !== void 0;
8604
+ if (hasPath === hasLiteral) throw new Error("richContent: pass exactly one of documentJsonPath and documentJson");
8605
+ if (hasPath && !RICH_CONTENT_PATH.test(props.documentJsonPath)) {
8606
+ throw new Error(`richContent: documentJsonPath must be $service:<service>.<path> or $item.<field>, got "${props.documentJsonPath}"`);
8607
+ }
8608
+ if (hasLiteral) {
8609
+ const laid = layoutRichContent(props.documentJson);
8610
+ if ("rejected" in laid) throw new Error(`richContent: documentJson rejected (${laid.rejected})`);
8611
+ }
8612
+ const node = { id: opts.id, body: { package: "himalaya", type: "RichContent", props } };
8613
+ return opts.modifiers ? withModifiers(node, opts.modifiers) : node;
8614
+ }
8157
8615
  function spacer(opts) {
8158
8616
  const props = {};
8159
8617
  if (opts?.value !== void 0) props.value = opts.value;
@@ -8643,7 +9101,7 @@ export {
8643
9101
  banner,
8644
9102
  bottomSheet,
8645
9103
  button,
8646
- card,
9104
+ card2 as card,
8647
9105
  carousel,
8648
9106
  chart,
8649
9107
  chip,
@@ -8693,6 +9151,7 @@ export {
8693
9151
  popover,
8694
9152
  progressBar,
8695
9153
  rating,
9154
+ richContent,
8696
9155
  richText,
8697
9156
  richTextField,
8698
9157
  rive,