contentbit 0.7.1 → 1.0.0-rc.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/bin.js CHANGED
@@ -3190,9 +3190,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
3190
3190
  * @param {string} [path]
3191
3191
  * @return {(string|null|Command)}
3192
3192
  */
3193
- executableDir(path2) {
3194
- if (path2 === void 0) return this._executableDir;
3195
- this._executableDir = path2;
3193
+ executableDir(path4) {
3194
+ if (path4 === void 0) return this._executableDir;
3195
+ this._executableDir = path4;
3196
3196
  return this;
3197
3197
  }
3198
3198
  /**
@@ -3453,8 +3453,8 @@ function formatDiagnosticForCli(diagnostic, file2) {
3453
3453
  return lines.join("\n");
3454
3454
  }
3455
3455
  function displayPath(file2) {
3456
- const path2 = relative(process.cwd(), file2);
3457
- if (path2 && !path2.startsWith("..") && !isAbsolute(path2)) return path2;
3456
+ const path4 = relative(process.cwd(), file2);
3457
+ if (path4 && !path4.startsWith("..") && !isAbsolute(path4)) return path4;
3458
3458
  return file2;
3459
3459
  }
3460
3460
  function severityLabel(severity) {
@@ -3486,6 +3486,15 @@ var init_cli_format = __esm({
3486
3486
  }
3487
3487
  });
3488
3488
 
3489
+ // ../core/dist/version.js
3490
+ var VERSION;
3491
+ var init_version = __esm({
3492
+ "../core/dist/version.js"() {
3493
+ "use strict";
3494
+ VERSION = "1.0.0-rc.0";
3495
+ }
3496
+ });
3497
+
3489
3498
  // ../core/dist/props.js
3490
3499
  function parseProps(raw, position, rawStart = position.start) {
3491
3500
  const props = {};
@@ -4340,7 +4349,8 @@ function validateDocument(parsed, registry2, options = {}) {
4340
4349
  position: node.openPosition
4341
4350
  });
4342
4351
  }
4343
- if (!reportUnknownProps(node, def, report))
4352
+ const knownPropsValid = reportUnknownProps(node, def, report);
4353
+ if (!knownPropsValid)
4344
4354
  valid = false;
4345
4355
  if (def.props) {
4346
4356
  const result = def.props.safeParse(node.props);
@@ -4349,8 +4359,9 @@ function validateDocument(parsed, registry2, options = {}) {
4349
4359
  } else {
4350
4360
  valid = false;
4351
4361
  for (const issue2 of result.error.issues) {
4352
- if (issue2.code === "unrecognized_keys")
4362
+ if (issue2.code === "unrecognized_keys" && issue2.path.length === 0 && !knownPropsValid) {
4353
4363
  continue;
4364
+ }
4354
4365
  const prop = typeof issue2.path[0] === "string" && issue2.path[0].length > 0 ? issue2.path[0] : void 0;
4355
4366
  report({
4356
4367
  code: "CB_PROPS_INVALID",
@@ -4738,10 +4749,10 @@ function mergeDefs(...defs) {
4738
4749
  function cloneDef(schema) {
4739
4750
  return mergeDefs(schema._zod.def);
4740
4751
  }
4741
- function getElementAtPath(obj, path2) {
4742
- if (!path2)
4752
+ function getElementAtPath(obj, path4) {
4753
+ if (!path4)
4743
4754
  return obj;
4744
- return path2.reduce((acc, key) => acc?.[key], obj);
4755
+ return path4.reduce((acc, key) => acc?.[key], obj);
4745
4756
  }
4746
4757
  function promiseAllObject(promisesObj) {
4747
4758
  const keys = Object.keys(promisesObj);
@@ -5069,11 +5080,11 @@ function explicitlyAborted(x, startIndex = 0) {
5069
5080
  }
5070
5081
  return false;
5071
5082
  }
5072
- function prefixIssues(path2, issues) {
5083
+ function prefixIssues(path4, issues) {
5073
5084
  return issues.map((iss) => {
5074
5085
  var _a3;
5075
5086
  (_a3 = iss).path ?? (_a3.path = []);
5076
- iss.path.unshift(path2);
5087
+ iss.path.unshift(path4);
5077
5088
  return iss;
5078
5089
  });
5079
5090
  }
@@ -5290,16 +5301,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
5290
5301
  }
5291
5302
  function formatError(error51, mapper = (issue2) => issue2.message) {
5292
5303
  const fieldErrors = { _errors: [] };
5293
- const processError = (error52, path2 = []) => {
5304
+ const processError = (error52, path4 = []) => {
5294
5305
  for (const issue2 of error52.issues) {
5295
5306
  if (issue2.code === "invalid_union" && issue2.errors.length) {
5296
- issue2.errors.map((issues) => processError({ issues }, [...path2, ...issue2.path]));
5307
+ issue2.errors.map((issues) => processError({ issues }, [...path4, ...issue2.path]));
5297
5308
  } else if (issue2.code === "invalid_key") {
5298
- processError({ issues: issue2.issues }, [...path2, ...issue2.path]);
5309
+ processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
5299
5310
  } else if (issue2.code === "invalid_element") {
5300
- processError({ issues: issue2.issues }, [...path2, ...issue2.path]);
5311
+ processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
5301
5312
  } else {
5302
- const fullpath = [...path2, ...issue2.path];
5313
+ const fullpath = [...path4, ...issue2.path];
5303
5314
  if (fullpath.length === 0) {
5304
5315
  fieldErrors._errors.push(mapper(issue2));
5305
5316
  } else {
@@ -5326,17 +5337,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
5326
5337
  }
5327
5338
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
5328
5339
  const result = { errors: [] };
5329
- const processError = (error52, path2 = []) => {
5340
+ const processError = (error52, path4 = []) => {
5330
5341
  var _a3, _b;
5331
5342
  for (const issue2 of error52.issues) {
5332
5343
  if (issue2.code === "invalid_union" && issue2.errors.length) {
5333
- issue2.errors.map((issues) => processError({ issues }, [...path2, ...issue2.path]));
5344
+ issue2.errors.map((issues) => processError({ issues }, [...path4, ...issue2.path]));
5334
5345
  } else if (issue2.code === "invalid_key") {
5335
- processError({ issues: issue2.issues }, [...path2, ...issue2.path]);
5346
+ processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
5336
5347
  } else if (issue2.code === "invalid_element") {
5337
- processError({ issues: issue2.issues }, [...path2, ...issue2.path]);
5348
+ processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
5338
5349
  } else {
5339
- const fullpath = [...path2, ...issue2.path];
5350
+ const fullpath = [...path4, ...issue2.path];
5340
5351
  if (fullpath.length === 0) {
5341
5352
  result.errors.push(mapper(issue2));
5342
5353
  continue;
@@ -5368,8 +5379,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
5368
5379
  }
5369
5380
  function toDotPath(_path) {
5370
5381
  const segs = [];
5371
- const path2 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
5372
- for (const seg of path2) {
5382
+ const path4 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
5383
+ for (const seg of path4) {
5373
5384
  if (typeof seg === "number")
5374
5385
  segs.push(`[${seg}]`);
5375
5386
  else if (typeof seg === "symbol")
@@ -15786,13 +15797,13 @@ function _stringbool(Classes, _params) {
15786
15797
  return codec2;
15787
15798
  }
15788
15799
  // @__NO_SIDE_EFFECTS__
15789
- function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
15800
+ function _stringFormat(Class2, format2, fnOrRegex, _params = {}) {
15790
15801
  const params = normalizeParams(_params);
15791
15802
  const def = {
15792
15803
  ...normalizeParams(_params),
15793
15804
  check: "string_format",
15794
15805
  type: "string",
15795
- format,
15806
+ format: format2,
15796
15807
  fn: typeof fnOrRegex === "function" ? fnOrRegex : (val) => fnOrRegex.test(val),
15797
15808
  ...params
15798
15809
  };
@@ -16235,16 +16246,16 @@ var init_json_schema_processors = __esm({
16235
16246
  stringProcessor = (schema, ctx, _json, _params) => {
16236
16247
  const json2 = _json;
16237
16248
  json2.type = "string";
16238
- const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
16249
+ const { minimum, maximum, format: format2, patterns, contentEncoding } = schema._zod.bag;
16239
16250
  if (typeof minimum === "number")
16240
16251
  json2.minLength = minimum;
16241
16252
  if (typeof maximum === "number")
16242
16253
  json2.maxLength = maximum;
16243
- if (format) {
16244
- json2.format = formatMap[format] ?? format;
16254
+ if (format2) {
16255
+ json2.format = formatMap[format2] ?? format2;
16245
16256
  if (json2.format === "")
16246
16257
  delete json2.format;
16247
- if (format === "time") {
16258
+ if (format2 === "time") {
16248
16259
  delete json2.format;
16249
16260
  }
16250
16261
  }
@@ -16266,8 +16277,8 @@ var init_json_schema_processors = __esm({
16266
16277
  };
16267
16278
  numberProcessor = (schema, ctx, _json, _params) => {
16268
16279
  const json2 = _json;
16269
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
16270
- if (typeof format === "string" && format.includes("int"))
16280
+ const { minimum, maximum, format: format2, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
16281
+ if (typeof format2 === "string" && format2.includes("int"))
16271
16282
  json2.type = "integer";
16272
16283
  else
16273
16284
  json2.type = "number";
@@ -17564,8 +17575,8 @@ function e1642(params) {
17564
17575
  function jwt(params) {
17565
17576
  return _jwt(ZodJWT, params);
17566
17577
  }
17567
- function stringFormat(format, fnOrRegex, _params = {}) {
17568
- return _stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
17578
+ function stringFormat(format2, fnOrRegex, _params = {}) {
17579
+ return _stringFormat(ZodCustomStringFormat, format2, fnOrRegex, _params);
17569
17580
  }
17570
17581
  function hostname2(_params) {
17571
17582
  return _stringFormat(ZodCustomStringFormat, "hostname", regexes_exports.hostname, _params);
@@ -17575,11 +17586,11 @@ function hex2(_params) {
17575
17586
  }
17576
17587
  function hash(alg, params) {
17577
17588
  const enc = params?.enc ?? "hex";
17578
- const format = `${alg}_${enc}`;
17579
- const regex = regexes_exports[format];
17589
+ const format2 = `${alg}_${enc}`;
17590
+ const regex = regexes_exports[format2];
17580
17591
  if (!regex)
17581
- throw new Error(`Unrecognized hash format: ${format}`);
17582
- return _stringFormat(ZodCustomStringFormat, format, regex, params);
17592
+ throw new Error(`Unrecognized hash format: ${format2}`);
17593
+ return _stringFormat(ZodCustomStringFormat, format2, regex, params);
17583
17594
  }
17584
17595
  function number2(params) {
17585
17596
  return _number(ZodNumber, params);
@@ -18799,13 +18810,13 @@ function resolveRef(ref, ctx) {
18799
18810
  if (!ref.startsWith("#")) {
18800
18811
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
18801
18812
  }
18802
- const path2 = ref.slice(1).split("/").filter(Boolean);
18803
- if (path2.length === 0) {
18813
+ const path4 = ref.slice(1).split("/").filter(Boolean);
18814
+ if (path4.length === 0) {
18804
18815
  return ctx.rootSchema;
18805
18816
  }
18806
18817
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
18807
- if (path2[0] === defsKey) {
18808
- const key = path2[1];
18818
+ if (path4[0] === defsKey) {
18819
+ const key = path4[1];
18809
18820
  if (!key || !ctx.defs[key]) {
18810
18821
  throw new Error(`Reference not found: ${ref}`);
18811
18822
  }
@@ -18897,52 +18908,52 @@ function convertBaseSchema(schema, ctx) {
18897
18908
  case "string": {
18898
18909
  let stringSchema = z.string();
18899
18910
  if (schema.format) {
18900
- const format = schema.format;
18901
- if (format === "email") {
18911
+ const format2 = schema.format;
18912
+ if (format2 === "email") {
18902
18913
  stringSchema = stringSchema.check(z.email());
18903
- } else if (format === "uri" || format === "uri-reference") {
18914
+ } else if (format2 === "uri" || format2 === "uri-reference") {
18904
18915
  stringSchema = stringSchema.check(z.url());
18905
- } else if (format === "uuid" || format === "guid") {
18916
+ } else if (format2 === "uuid" || format2 === "guid") {
18906
18917
  stringSchema = stringSchema.check(z.uuid());
18907
- } else if (format === "date-time") {
18918
+ } else if (format2 === "date-time") {
18908
18919
  stringSchema = stringSchema.check(z.iso.datetime());
18909
- } else if (format === "date") {
18920
+ } else if (format2 === "date") {
18910
18921
  stringSchema = stringSchema.check(z.iso.date());
18911
- } else if (format === "time") {
18922
+ } else if (format2 === "time") {
18912
18923
  stringSchema = stringSchema.check(z.iso.time());
18913
- } else if (format === "duration") {
18924
+ } else if (format2 === "duration") {
18914
18925
  stringSchema = stringSchema.check(z.iso.duration());
18915
- } else if (format === "ipv4") {
18926
+ } else if (format2 === "ipv4") {
18916
18927
  stringSchema = stringSchema.check(z.ipv4());
18917
- } else if (format === "ipv6") {
18928
+ } else if (format2 === "ipv6") {
18918
18929
  stringSchema = stringSchema.check(z.ipv6());
18919
- } else if (format === "mac") {
18930
+ } else if (format2 === "mac") {
18920
18931
  stringSchema = stringSchema.check(z.mac());
18921
- } else if (format === "cidr") {
18932
+ } else if (format2 === "cidr") {
18922
18933
  stringSchema = stringSchema.check(z.cidrv4());
18923
- } else if (format === "cidr-v6") {
18934
+ } else if (format2 === "cidr-v6") {
18924
18935
  stringSchema = stringSchema.check(z.cidrv6());
18925
- } else if (format === "base64") {
18936
+ } else if (format2 === "base64") {
18926
18937
  stringSchema = stringSchema.check(z.base64());
18927
- } else if (format === "base64url") {
18938
+ } else if (format2 === "base64url") {
18928
18939
  stringSchema = stringSchema.check(z.base64url());
18929
- } else if (format === "e164") {
18940
+ } else if (format2 === "e164") {
18930
18941
  stringSchema = stringSchema.check(z.e164());
18931
- } else if (format === "jwt") {
18942
+ } else if (format2 === "jwt") {
18932
18943
  stringSchema = stringSchema.check(z.jwt());
18933
- } else if (format === "emoji") {
18944
+ } else if (format2 === "emoji") {
18934
18945
  stringSchema = stringSchema.check(z.emoji());
18935
- } else if (format === "nanoid") {
18946
+ } else if (format2 === "nanoid") {
18936
18947
  stringSchema = stringSchema.check(z.nanoid());
18937
- } else if (format === "cuid") {
18948
+ } else if (format2 === "cuid") {
18938
18949
  stringSchema = stringSchema.check(z.cuid());
18939
- } else if (format === "cuid2") {
18950
+ } else if (format2 === "cuid2") {
18940
18951
  stringSchema = stringSchema.check(z.cuid2());
18941
- } else if (format === "ulid") {
18952
+ } else if (format2 === "ulid") {
18942
18953
  stringSchema = stringSchema.check(z.ulid());
18943
- } else if (format === "xid") {
18954
+ } else if (format2 === "xid") {
18944
18955
  stringSchema = stringSchema.check(z.xid());
18945
- } else if (format === "ksuid") {
18956
+ } else if (format2 === "ksuid") {
18946
18957
  stringSchema = stringSchema.check(z.ksuid());
18947
18958
  }
18948
18959
  }
@@ -19651,7 +19662,7 @@ function buildLinkIndex(inputs, options = {}) {
19651
19662
  const pages = /* @__PURE__ */ new Map();
19652
19663
  const aliases = /* @__PURE__ */ new Map();
19653
19664
  const aliasEntries = [];
19654
- for (const { path: path2, data } of inputs) {
19665
+ for (const { path: path4, data } of inputs) {
19655
19666
  const parsed = parseLinkFrontmatter(data, resolvedOptions);
19656
19667
  if (!parsed.ok || parsed.value === null)
19657
19668
  continue;
@@ -19660,7 +19671,7 @@ function buildLinkIndex(inputs, options = {}) {
19660
19671
  slug: fm.slug,
19661
19672
  key: fm.key,
19662
19673
  locale: effectiveLocale(fm, resolvedOptions),
19663
- path: path2,
19674
+ path: path4,
19664
19675
  title: fm.title,
19665
19676
  keywords: fm.keywords,
19666
19677
  linksTo: [],
@@ -19751,41 +19762,41 @@ function validateLinks(inputs, options = {}) {
19751
19762
  const seenSlug = /* @__PURE__ */ new Map();
19752
19763
  const seenKey = /* @__PURE__ */ new Map();
19753
19764
  const seenAlias = /* @__PURE__ */ new Map();
19754
- for (const { path: path2, data } of inputs) {
19765
+ for (const { path: path4, data } of inputs) {
19755
19766
  const parsed = parseLinkFrontmatter(data, resolvedOptions);
19756
19767
  if (!parsed.ok) {
19757
19768
  for (const e of parsed.errors)
19758
- out.push(diag(path2, "CB_LINK_SHAPE", "error", `invalid link frontmatter: ${e}`));
19769
+ out.push(diag(path4, "CB_LINK_SHAPE", "error", `invalid link frontmatter: ${e}`));
19759
19770
  continue;
19760
19771
  }
19761
19772
  if (parsed.value === null)
19762
19773
  continue;
19763
19774
  const fm = parsed.value;
19764
19775
  const locale = effectiveLocale(fm, resolvedOptions);
19765
- validInputs.push({ path: path2, fm });
19776
+ validInputs.push({ path: path4, fm });
19766
19777
  const slugKey = scopedKey(fm.slug, locale, resolvedOptions);
19767
19778
  const prior = seenSlug.get(slugKey);
19768
19779
  if (prior)
19769
- out.push(diag(path2, "CB_SLUG_DUPLICATE", "error", `slug "${fm.slug}" also used by ${prior}`));
19780
+ out.push(diag(path4, "CB_SLUG_DUPLICATE", "error", `slug "${fm.slug}" also used by ${prior}`));
19770
19781
  else
19771
- seenSlug.set(slugKey, path2);
19782
+ seenSlug.set(slugKey, path4);
19772
19783
  if (usesKeyResolution(resolvedOptions) && !fm.key) {
19773
- out.push(diag(path2, "CB_KEY_MISSING", "error", `page "${fm.slug}" is missing key`));
19784
+ out.push(diag(path4, "CB_KEY_MISSING", "error", `page "${fm.slug}" is missing key`));
19774
19785
  }
19775
19786
  if (fm.key) {
19776
19787
  const keyKey = scopedKey(fm.key, locale, resolvedOptions);
19777
19788
  const priorKey = seenKey.get(keyKey);
19778
19789
  if (priorKey)
19779
- out.push(diag(path2, "CB_KEY_DUPLICATE", "error", `key "${fm.key}" also used by ${priorKey}`));
19790
+ out.push(diag(path4, "CB_KEY_DUPLICATE", "error", `key "${fm.key}" also used by ${priorKey}`));
19780
19791
  else
19781
- seenKey.set(keyKey, path2);
19792
+ seenKey.set(keyKey, path4);
19782
19793
  }
19783
19794
  for (const alias of fm.aliases ?? []) {
19784
19795
  const aliasKey = scopedKey(alias, locale, resolvedOptions);
19785
19796
  if (seenAlias.has(aliasKey))
19786
- out.push(diag(path2, "CB_ALIAS_CONFLICT", "error", `alias "${alias}" already declared by ${seenAlias.get(aliasKey)}`));
19797
+ out.push(diag(path4, "CB_ALIAS_CONFLICT", "error", `alias "${alias}" already declared by ${seenAlias.get(aliasKey)}`));
19787
19798
  else
19788
- seenAlias.set(aliasKey, path2);
19799
+ seenAlias.set(aliasKey, path4);
19789
19800
  }
19790
19801
  }
19791
19802
  const ambiguousPageKeys = ambiguousValidationPageKeys(validInputs, resolvedOptions);
@@ -20313,9 +20324,9 @@ function pageToFrontmatter(page) {
20313
20324
  function stringArray2(value) {
20314
20325
  return Array.isArray(value) && value.every((item) => typeof item === "string") ? value : void 0;
20315
20326
  }
20316
- function getPath(record2, path2) {
20327
+ function getPath(record2, path4) {
20317
20328
  let current = record2;
20318
- for (const part of path2.split(".")) {
20329
+ for (const part of path4.split(".")) {
20319
20330
  if (!current || typeof current !== "object")
20320
20331
  return void 0;
20321
20332
  current = current[part];
@@ -20361,8 +20372,8 @@ function findPlannedByPath(byId, filePath) {
20361
20372
  function pathMatches(configId, filePath) {
20362
20373
  return filePath === configId || filePath.endsWith(`/${configId}`);
20363
20374
  }
20364
- function normalizePath(path2) {
20365
- return path2.replaceAll("\\", "/").replace(/^\.\/+/, "");
20375
+ function normalizePath(path4) {
20376
+ return path4.replaceAll("\\", "/").replace(/^\.\/+/, "");
20366
20377
  }
20367
20378
  function seoPageId(facts, identity) {
20368
20379
  return facts.locale ? `${identity}:${facts.locale}` : identity;
@@ -20628,14 +20639,15 @@ function resolveContentLink(url2, sourcePath, byRoute) {
20628
20639
  if (rawPath === "") {
20629
20640
  return { path: normalizePath2(sourcePath), ...anchor ? { anchor } : {}, kind: "markdown" };
20630
20641
  }
20631
- if (isRelativeMarkdownPath(rawPath)) {
20642
+ const decodedPath = decodeUriComponent(rawPath);
20643
+ if (isRelativeMarkdownPath(decodedPath)) {
20632
20644
  return {
20633
- path: joinPath(dirname(sourcePath), rawPath),
20645
+ path: joinPath(dirname(sourcePath), decodedPath),
20634
20646
  ...anchor ? { anchor } : {},
20635
20647
  kind: "markdown"
20636
20648
  };
20637
20649
  }
20638
- if (hasFileExtension(rawPath))
20650
+ if (hasFileExtension(decodedPath))
20639
20651
  return void 0;
20640
20652
  const destination = routeTarget(rawPath, byRoute);
20641
20653
  return {
@@ -20645,7 +20657,7 @@ function resolveContentLink(url2, sourcePath, byRoute) {
20645
20657
  };
20646
20658
  }
20647
20659
  function isRelativeMarkdownPath(value) {
20648
- return value.startsWith("./") || value.startsWith("../") || /\.mdx?$/i.test(value);
20660
+ return /\.mdx?$/i.test(value);
20649
20661
  }
20650
20662
  function hasFileExtension(value) {
20651
20663
  return /\/[^/]+\.[a-z\d]+$/i.test(`/${value}`);
@@ -20694,8 +20706,8 @@ function normalizedFrontmatterString(value) {
20694
20706
  const normalized = value.trim().replace(/\s+/g, " ").toLocaleLowerCase();
20695
20707
  return normalized || void 0;
20696
20708
  }
20697
- function dirname(path2) {
20698
- const normalized = normalizePath2(path2);
20709
+ function dirname(path4) {
20710
+ const normalized = normalizePath2(path4);
20699
20711
  const index = normalized.lastIndexOf("/");
20700
20712
  return index <= 0 ? normalized.startsWith("/") ? "/" : "" : normalized.slice(0, index);
20701
20713
  }
@@ -20713,8 +20725,8 @@ function joinPath(base, target) {
20713
20725
  }
20714
20726
  return `${absolute || base.startsWith("/") ? "/" : ""}${normalized.join("/")}`;
20715
20727
  }
20716
- function normalizePath2(path2) {
20717
- return joinPath("", path2.replaceAll("\\", "/"));
20728
+ function normalizePath2(path4) {
20729
+ return joinPath("", path4.replaceAll("\\", "/"));
20718
20730
  }
20719
20731
  function decodeUriComponent(value) {
20720
20732
  try {
@@ -20913,6 +20925,205 @@ var init_project_scan = __esm({
20913
20925
  }
20914
20926
  });
20915
20927
 
20928
+ // ../core/dist/page-discovery.js
20929
+ function discoverContentPageFacts(input, options = {}) {
20930
+ const authored = readContentPageFacts(input.frontmatter, options);
20931
+ const key = stringFact(authored, "key", configuredSource(input.frontmatter, "key", options.keyField));
20932
+ const authoredSlug = stringFact(authored, "slug", configuredSource(input.frontmatter, "slug", options.slugField));
20933
+ const slug = authoredSlug ?? pathSlugFact(input.path);
20934
+ const title = stringFact(authored, "title", "frontmatter") ?? headingTitleFact(input.stats) ?? pathTitleFact(input.path);
20935
+ return {
20936
+ identity: key ?? authoredSlug ?? exactPathFact(input.path),
20937
+ title,
20938
+ slug,
20939
+ ...key ? { key } : {},
20940
+ ...optionalStringFact(authored, input.frontmatter, options, "locale"),
20941
+ ...optionalStringFact(authored, input.frontmatter, options, "description"),
20942
+ ...optionalStringFact(authored, input.frontmatter, options, "type"),
20943
+ ...optionalStringFact(authored, input.frontmatter, options, "intent"),
20944
+ ...authored.keywords ? { keywords: exactFact(authored.keywords, "frontmatter") } : {},
20945
+ ...authored.linksTo ? { linksTo: exactFact(authored.linksTo, "frontmatter") } : {}
20946
+ };
20947
+ }
20948
+ function optionalStringFact(facts, frontmatter, options, field) {
20949
+ const configured = field === "locale" ? options.localeField : void 0;
20950
+ const fact = stringFact(facts, field, configuredSource(frontmatter, field, configured));
20951
+ return fact ? { [field]: fact } : {};
20952
+ }
20953
+ function stringFact(facts, field, source) {
20954
+ const value = facts[field];
20955
+ return typeof value === "string" ? exactFact(value, source) : void 0;
20956
+ }
20957
+ function exactFact(value, source) {
20958
+ return { value, source, confidence: "exact" };
20959
+ }
20960
+ function exactPathFact(value) {
20961
+ return { value, source: "path", confidence: "exact" };
20962
+ }
20963
+ function headingTitleFact(stats) {
20964
+ const heading = stats.outline.find((entry) => entry.level === 1);
20965
+ return heading ? { value: heading.text, source: "document", confidence: "likely" } : void 0;
20966
+ }
20967
+ function pathSlugFact(path4) {
20968
+ return { value: slugFromPath(path4), source: "path", confidence: "guess" };
20969
+ }
20970
+ function pathTitleFact(path4) {
20971
+ return { value: titleFromPath(path4), source: "path", confidence: "guess" };
20972
+ }
20973
+ function configuredSource(frontmatter, canonical, configured) {
20974
+ if (!(canonical in frontmatter) && configured && configured in frontmatter)
20975
+ return "config";
20976
+ return "frontmatter";
20977
+ }
20978
+ function slugFromPath(path4) {
20979
+ return filenameFromPath(path4).toLocaleLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "");
20980
+ }
20981
+ function titleFromPath(path4) {
20982
+ return filenameFromPath(path4).replace(/[-_]+/g, " ").replace(/\b\p{L}/gu, (letter) => letter.toUpperCase());
20983
+ }
20984
+ function filenameFromPath(path4) {
20985
+ return path4.slice(Math.max(path4.lastIndexOf("/"), path4.lastIndexOf("\\")) + 1).replace(/\.mdx?$/i, "");
20986
+ }
20987
+ var init_page_discovery = __esm({
20988
+ "../core/dist/page-discovery.js"() {
20989
+ "use strict";
20990
+ init_page_facts();
20991
+ }
20992
+ });
20993
+
20994
+ // ../core/dist/project-discovery.js
20995
+ function discoverContentProject(files, options = {}) {
20996
+ const { root, ...linkOptions } = options;
20997
+ const pages = files.map((file2) => {
20998
+ const path4 = projectRelativePath(file2.path, root);
20999
+ const discovered = discoverContentPageFacts(file2, linkOptions);
21000
+ const facts = {
21001
+ ...discovered,
21002
+ identity: discovered.identity.source === "path" ? { ...discovered.identity, value: path4 } : discovered.identity,
21003
+ ...discovered.type ? { family: { ...discovered.type } } : {}
21004
+ };
21005
+ return { sourcePath: file2.path, path: path4, facts };
21006
+ });
21007
+ const inferablePages = pages.filter((page) => isProjectRelativePath(page.path));
21008
+ inferPathLocales(inferablePages);
21009
+ inferPathFamilies(inferablePages);
21010
+ return {
21011
+ pages,
21012
+ families: summarizeFacts(pages, "family"),
21013
+ locales: summarizeFacts(pages, "locale")
21014
+ };
21015
+ }
21016
+ function inferPathLocales(pages) {
21017
+ const candidates = /* @__PURE__ */ new Map();
21018
+ for (const page of pages) {
21019
+ const segments = pathSegments(page.path);
21020
+ for (let position = 0; position < segments.length - 1; position++) {
21021
+ const locale = segments[position];
21022
+ if (!isLocaleCandidate(locale))
21023
+ continue;
21024
+ const tail = segments.slice(position + 1).join("/");
21025
+ const key = `${position}\0${tail}`;
21026
+ const entry = candidates.get(key) ?? { position, locales: /* @__PURE__ */ new Set() };
21027
+ entry.locales.add(locale);
21028
+ candidates.set(key, entry);
21029
+ }
21030
+ }
21031
+ const supportedPositions = /* @__PURE__ */ new Map();
21032
+ for (const candidate of candidates.values()) {
21033
+ if (candidate.locales.size < 2)
21034
+ continue;
21035
+ supportedPositions.set(candidate.position, (supportedPositions.get(candidate.position) ?? 0) + 1);
21036
+ }
21037
+ const localePositions = new Set([...supportedPositions].filter(([, siblings]) => siblings >= MIN_LOCALE_SIBLINGS).map(([position]) => position));
21038
+ if (localePositions.size === 0)
21039
+ return;
21040
+ const localeGroups = new Set([...candidates].filter(([, candidate]) => candidate.locales.size >= 2 && localePositions.has(candidate.position)).map(([key]) => key));
21041
+ for (const page of pages) {
21042
+ if (page.facts.locale)
21043
+ continue;
21044
+ const segments = pathSegments(page.path);
21045
+ const position = [...localePositions].find((candidate) => {
21046
+ const locale = segments[candidate];
21047
+ if (!isLocaleCandidate(locale))
21048
+ return false;
21049
+ const tail = segments.slice(candidate + 1).join("/");
21050
+ return localeGroups.has(`${candidate}\0${tail}`);
21051
+ });
21052
+ if (position === void 0)
21053
+ continue;
21054
+ page.facts.locale = pathFact(segments[position]);
21055
+ }
21056
+ }
21057
+ function inferPathFamilies(pages) {
21058
+ const candidates = /* @__PURE__ */ new Map();
21059
+ const candidateByPath = /* @__PURE__ */ new Map();
21060
+ for (const page of pages) {
21061
+ if (page.facts.family)
21062
+ continue;
21063
+ const locale = page.facts.locale?.value.toLocaleLowerCase();
21064
+ const candidate = pathSegments(page.path).slice(0, -1).find((segment) => !FAMILY_WRAPPERS.has(segment.toLocaleLowerCase()) && segment.toLocaleLowerCase() !== locale);
21065
+ if (!candidate)
21066
+ continue;
21067
+ candidateByPath.set(page.path, candidate);
21068
+ candidates.set(candidate, (candidates.get(candidate) ?? 0) + 1);
21069
+ }
21070
+ for (const page of pages) {
21071
+ if (page.facts.family)
21072
+ continue;
21073
+ const candidate = candidateByPath.get(page.path);
21074
+ if (!candidate || (candidates.get(candidate) ?? 0) < MIN_FAMILY_FILES)
21075
+ continue;
21076
+ page.facts.family = pathFact(candidate);
21077
+ }
21078
+ }
21079
+ function summarizeFacts(pages, field) {
21080
+ const counts = /* @__PURE__ */ new Map();
21081
+ for (const page of pages) {
21082
+ const value = page.facts[field]?.value;
21083
+ if (value)
21084
+ counts.set(value, (counts.get(value) ?? 0) + 1);
21085
+ }
21086
+ return [...counts].map(([id, files]) => ({ id, files })).sort((a, b) => a.id.localeCompare(b.id));
21087
+ }
21088
+ function pathFact(value) {
21089
+ return { value, source: "path", confidence: "likely" };
21090
+ }
21091
+ function isLocaleCandidate(value) {
21092
+ return Boolean(value && /^[a-z]{2}(?:-[a-z0-9]{2,8})*$/i.test(value));
21093
+ }
21094
+ function isProjectRelativePath(path4) {
21095
+ return !path4.startsWith("/") && !/^[a-z]:/i.test(path4) && !path4.split("/").includes("..");
21096
+ }
21097
+ function pathSegments(path4) {
21098
+ return path4.split("/").filter(Boolean);
21099
+ }
21100
+ function projectRelativePath(path4, root) {
21101
+ const normalizedPath = normalizePath3(path4);
21102
+ if (!root)
21103
+ return trimRelativePrefix(normalizedPath);
21104
+ const normalizedRoot = normalizePath3(root).replace(/\/$/, "");
21105
+ if (normalizedPath.startsWith(`${normalizedRoot}/`)) {
21106
+ return normalizedPath.slice(normalizedRoot.length + 1);
21107
+ }
21108
+ return trimRelativePrefix(normalizedPath);
21109
+ }
21110
+ function normalizePath3(path4) {
21111
+ return path4.replaceAll("\\", "/").replace(/\/+/g, "/");
21112
+ }
21113
+ function trimRelativePrefix(path4) {
21114
+ return path4.startsWith("./") ? path4.slice(2) : path4;
21115
+ }
21116
+ var FAMILY_WRAPPERS, MIN_FAMILY_FILES, MIN_LOCALE_SIBLINGS;
21117
+ var init_project_discovery = __esm({
21118
+ "../core/dist/project-discovery.js"() {
21119
+ "use strict";
21120
+ init_page_discovery();
21121
+ FAMILY_WRAPPERS = /* @__PURE__ */ new Set(["app", "content", "pages", "routes", "src"]);
21122
+ MIN_FAMILY_FILES = 2;
21123
+ MIN_LOCALE_SIBLINGS = 2;
21124
+ }
21125
+ });
21126
+
20916
21127
  // ../core/dist/position.js
20917
21128
  function bodyLineRange(node, bodyLineIndex) {
20918
21129
  const bodyLines = node.body.split("\n");
@@ -21265,9 +21476,11 @@ var init_render_markdown = __esm({
21265
21476
  var init_dist = __esm({
21266
21477
  "../core/dist/index.js"() {
21267
21478
  "use strict";
21479
+ init_version();
21268
21480
  init_frontmatter();
21269
21481
  init_analyze();
21270
21482
  init_project_scan();
21483
+ init_project_discovery();
21271
21484
  init_link_graph();
21272
21485
  init_seo();
21273
21486
  init_registry();
@@ -21601,8 +21814,9 @@ var init_dist2 = __esm({
21601
21814
  });
21602
21815
 
21603
21816
  // ../project/dist/index.js
21817
+ import { createHash } from "node:crypto";
21604
21818
  import { readFile } from "node:fs/promises";
21605
- import { isAbsolute as isAbsolute2, join } from "node:path";
21819
+ import { isAbsolute as isAbsolute2, join, relative as relative2 } from "node:path";
21606
21820
  import { pathToFileURL } from "node:url";
21607
21821
  import { glob } from "tinyglobby";
21608
21822
  async function resolveContentFiles(positionals, cmd, options = {}) {
@@ -21650,7 +21864,7 @@ async function loadContentProject(input) {
21650
21864
  cwd: input.cwd,
21651
21865
  includeGenericBlocks: input.includeGenericBlocks
21652
21866
  });
21653
- const sources = await Promise.all(files.map(async (path2) => ({ path: path2, source: await readFile(path2, "utf8") })));
21867
+ const sources = await Promise.all(files.map(async (path4) => ({ path: path4, source: await readFile(path4, "utf8") })));
21654
21868
  const linkOptions = input.linkOptions ?? {};
21655
21869
  const scan = scanContentProject(sources, registry2, {
21656
21870
  linkOptions,
@@ -21658,7 +21872,118 @@ async function loadContentProject(input) {
21658
21872
  });
21659
21873
  return { files, registry: registry2, sources, linkOptions, scan };
21660
21874
  }
21661
- var ProjectLoadError;
21875
+ async function inspectContentProject(input) {
21876
+ const root = input.cwd ?? process.cwd();
21877
+ const project = await loadContentProject({ ...input, cmd: "snapshot" });
21878
+ const discovery = discoverContentProject(project.scan.files, {
21879
+ root,
21880
+ ...project.linkOptions
21881
+ });
21882
+ const discoveredBySource = new Map(discovery.pages.map((page) => [page.sourcePath, page]));
21883
+ const sourcePaths = [
21884
+ .../* @__PURE__ */ new Set([...project.files, ...project.scan.findings.map((finding2) => finding2.file)])
21885
+ ].filter(isAbsolute2).sort((a, b) => b.length - a.length);
21886
+ const findings = project.scan.findings.map((finding2) => ({
21887
+ ...finding2,
21888
+ file: portablePath(finding2.file, root),
21889
+ message: portableText(finding2.message, root, sourcePaths),
21890
+ ...finding2.hint ? { hint: portableText(finding2.hint, root, sourcePaths) } : {}
21891
+ }));
21892
+ let words = 0;
21893
+ let blocks = 0;
21894
+ let links = 0;
21895
+ const pages = project.scan.files.map((file2) => {
21896
+ const discovered = discoveredBySource.get(file2.path);
21897
+ if (!discovered)
21898
+ throw new Error(`Missing discovered page for ${file2.path}`);
21899
+ words += file2.stats.length.words;
21900
+ blocks += file2.stats.blocks.total;
21901
+ links += file2.stats.links.total;
21902
+ const pageFindings = summarizeContentProjectFindings(file2.findings);
21903
+ const path4 = portablePath(file2.path, root);
21904
+ return {
21905
+ path: path4,
21906
+ contentHash: createHash("sha256").update(file2.source).digest("hex"),
21907
+ facts: {
21908
+ ...discovered.facts,
21909
+ identity: discovered.facts.identity.source === "path" ? { ...discovered.facts.identity, value: path4 } : discovered.facts.identity
21910
+ },
21911
+ stats: {
21912
+ bytes: file2.stats.file.bytes,
21913
+ words: file2.stats.length.words,
21914
+ readingMinutes: file2.stats.length.readingMinutes,
21915
+ outline: file2.stats.outline,
21916
+ blocks: { total: file2.stats.blocks.total, byName: file2.stats.blocks.byName },
21917
+ links: {
21918
+ total: file2.stats.links.total,
21919
+ internal: file2.stats.links.internal,
21920
+ external: file2.stats.links.external
21921
+ },
21922
+ images: file2.stats.images
21923
+ },
21924
+ findings: pageFindings,
21925
+ status: snapshotStatus(pageFindings)
21926
+ };
21927
+ });
21928
+ const graph = snapshotGraph(project.scan, root);
21929
+ return {
21930
+ schemaVersion: CONTENT_PROJECT_SNAPSHOT_SCHEMA_VERSION,
21931
+ ...input.revision ? { revision: input.revision } : {},
21932
+ summary: {
21933
+ files: pages.length,
21934
+ words,
21935
+ blocks,
21936
+ links,
21937
+ findings: project.scan.summary
21938
+ },
21939
+ pages,
21940
+ families: discovery.families,
21941
+ locales: discovery.locales,
21942
+ findings,
21943
+ ...graph ? { graph } : {},
21944
+ ...project.scan.seo ? {
21945
+ seo: {
21946
+ schemaVersion: project.scan.seo.schemaVersion,
21947
+ pages: project.scan.seo.pages.length,
21948
+ existing: project.scan.seo.pages.filter((page) => page.source === "existing").length,
21949
+ planned: project.scan.seo.pages.filter((page) => page.source === "planned").length,
21950
+ findings: project.scan.seo.findings.length
21951
+ }
21952
+ } : {}
21953
+ };
21954
+ }
21955
+ function snapshotGraph(scan, root) {
21956
+ if (!scan.linkIndex)
21957
+ return void 0;
21958
+ const graph = createLinkGraphView(scan.linkIndex, scan.linkDiagnostics ?? []);
21959
+ return {
21960
+ summary: graph.summary,
21961
+ nodes: graph.nodes.map((node) => ({ ...node, path: portablePath(node.path, root) })),
21962
+ edges: graph.edges
21963
+ };
21964
+ }
21965
+ function snapshotStatus(summary) {
21966
+ if (summary.errors > 0)
21967
+ return "error";
21968
+ if (summary.warnings > 0)
21969
+ return "warning";
21970
+ if (summary.suggestions > 0)
21971
+ return "suggestion";
21972
+ return "healthy";
21973
+ }
21974
+ function portablePath(path4, root) {
21975
+ const value = isAbsolute2(path4) ? relative2(root, path4) : path4;
21976
+ return value.replaceAll("\\", "/");
21977
+ }
21978
+ function portableText(value, root, sourcePaths) {
21979
+ let normalized = value.replaceAll("\\", "/");
21980
+ for (const path4 of sourcePaths) {
21981
+ normalized = normalized.replaceAll(path4.replaceAll("\\", "/"), portablePath(path4, root));
21982
+ }
21983
+ const normalizedRoot = root.replaceAll("\\", "/").replace(/\/$/, "");
21984
+ return normalized.replaceAll(`${normalizedRoot}/`, "");
21985
+ }
21986
+ var ProjectLoadError, CONTENT_PROJECT_SNAPSHOT_SCHEMA_VERSION;
21662
21987
  var init_dist3 = __esm({
21663
21988
  "../project/dist/index.js"() {
21664
21989
  "use strict";
@@ -21672,6 +21997,7 @@ var init_dist3 = __esm({
21672
21997
  this.name = "ProjectLoadError";
21673
21998
  }
21674
21999
  };
22000
+ CONTENT_PROJECT_SNAPSHOT_SCHEMA_VERSION = "contentbit.project-snapshot.v1";
21675
22001
  }
21676
22002
  });
21677
22003
 
@@ -21715,7 +22041,7 @@ __export(agents_exports, {
21715
22041
  });
21716
22042
  import { existsSync, readFileSync } from "node:fs";
21717
22043
  import { mkdir, readFile as readFile2, writeFile } from "node:fs/promises";
21718
- import { dirname as dirname2, join as join2, relative as relative2, resolve, sep } from "node:path";
22044
+ import { dirname as dirname2, join as join2, relative as relative3, resolve, sep } from "node:path";
21719
22045
  function upsertBlock(existing, block = AGENTS_MD_BLOCK) {
21720
22046
  const start = existing.indexOf(START);
21721
22047
  const end = existing.indexOf(END);
@@ -21738,19 +22064,19 @@ function rootPointerBlock(packagePath) {
21738
22064
  END
21739
22065
  ].join("\n");
21740
22066
  }
21741
- async function readTextIfExists(path2) {
22067
+ async function readTextIfExists(path4) {
21742
22068
  try {
21743
- return await readFile2(path2, "utf8");
22069
+ return await readFile2(path4, "utf8");
21744
22070
  } catch {
21745
22071
  return "";
21746
22072
  }
21747
22073
  }
21748
- function isWorkspaceRoot(path2) {
21749
- if (existsSync(join2(path2, "pnpm-workspace.yaml"))) return true;
21750
- if (existsSync(join2(path2, "lerna.json"))) return true;
21751
- if (existsSync(join2(path2, "nx.json"))) return true;
22074
+ function isWorkspaceRoot(path4) {
22075
+ if (existsSync(join2(path4, "pnpm-workspace.yaml"))) return true;
22076
+ if (existsSync(join2(path4, "lerna.json"))) return true;
22077
+ if (existsSync(join2(path4, "nx.json"))) return true;
21752
22078
  try {
21753
- const pkg = JSON.parse(readFileSync(join2(path2, "package.json"), "utf8"));
22079
+ const pkg = JSON.parse(readFileSync(join2(path4, "package.json"), "utf8"));
21754
22080
  return Array.isArray(pkg.workspaces) || typeof pkg.workspaces === "object";
21755
22081
  } catch {
21756
22082
  return false;
@@ -21766,7 +22092,7 @@ function findMonorepoRoot(cwd) {
21766
22092
  return void 0;
21767
22093
  }
21768
22094
  function displayRelative(from, to) {
21769
- const rel = relative2(from, to) || ".";
22095
+ const rel = relative3(from, to) || ".";
21770
22096
  return rel.split(sep).join("/");
21771
22097
  }
21772
22098
  async function writeRootPointerIfNeeded(cwd, io) {
@@ -21781,8 +22107,8 @@ async function writeRootPointerIfNeeded(cwd, io) {
21781
22107
  `${created ? "created" : "updated"}: ${displayRelative(cwd, rootAgentsPath)} (contentbit root pointer)`
21782
22108
  );
21783
22109
  }
21784
- async function checkBlockStatus(path2, block, label, io) {
21785
- const existing = await readTextIfExists(path2);
22110
+ async function checkBlockStatus(path4, block, label, io) {
22111
+ const existing = await readTextIfExists(path4);
21786
22112
  if (existing === "") {
21787
22113
  io.stdout(`would create: ${label}`);
21788
22114
  return;
@@ -21820,8 +22146,8 @@ async function checkAgentIntegration(cwd, options, io) {
21820
22146
  }
21821
22147
  if (claude) {
21822
22148
  for (const [name, content] of SKILLS) {
21823
- const path2 = join2(cwd, ".claude/skills", name, "SKILL.md");
21824
- const installed = await readTextIfExists(path2);
22149
+ const path4 = join2(cwd, ".claude/skills", name, "SKILL.md");
22150
+ const installed = await readTextIfExists(path4);
21825
22151
  const shippedVersion = skillVersion(content) ?? "unknown";
21826
22152
  if (installed === "") {
21827
22153
  io.stdout(`would install: .claude/skills/${name}/SKILL.md (version ${shippedVersion})`);
@@ -21856,10 +22182,10 @@ async function installAgentIntegration(cwd, options, io) {
21856
22182
  const claude = options.claude ?? claudeDirExists;
21857
22183
  const agentsMd = options.agentsMd ?? true;
21858
22184
  if (agentsMd) {
21859
- const path2 = join2(cwd, "AGENTS.md");
21860
- const existing = await readTextIfExists(path2);
22185
+ const path4 = join2(cwd, "AGENTS.md");
22186
+ const existing = await readTextIfExists(path4);
21861
22187
  const created = existing === "";
21862
- await writeFile(path2, upsertBlock(existing), "utf8");
22188
+ await writeFile(path4, upsertBlock(existing), "utf8");
21863
22189
  io.stdout(`${created ? "created" : "updated"}: AGENTS.md (contentbit block)`);
21864
22190
  await writeRootPointerIfNeeded(cwd, io);
21865
22191
  }
@@ -21994,7 +22320,7 @@ function detectFramework(cwd, deps) {
21994
22320
  if (existsSync2(join3(cwd, appDir))) {
21995
22321
  return {
21996
22322
  framework: "next",
21997
- componentPath: "components/content-blocks.tsx",
22323
+ componentPath: appDir === "src/app" ? "src/components/content-blocks.tsx" : "components/content-blocks.tsx",
21998
22324
  pagePath: `${appDir}/example/page.tsx`
21999
22325
  };
22000
22326
  }
@@ -22007,7 +22333,9 @@ function astroPage(styled) {
22007
22333
  return `---
22008
22334
  import { genericBlocks } from '@contentbit/blocks'
22009
22335
  import { assertValidDocument, compileDocument, createBlockRegistry } from '@contentbit/core'
22010
- import { getEntry } from 'astro:content'
22336
+ // Vite's ?raw import keeps this example independent from the host project's
22337
+ // content collections. See astro-speedrun-seo for a production collection.
22338
+ import source from '../../content/example.md?raw'
22011
22339
 
22012
22340
  ${importLine}
22013
22341
 
@@ -22015,13 +22343,9 @@ ${importLine}
22015
22343
  import customBlocks from '../../blocks/registry'
22016
22344
  import QuoteBlock from '../../blocks/QuoteBlock.astro'
22017
22345
 
22018
- // Entry ids are the file path relative to the collection base, minus ".md".
22019
- const entry = await getEntry('articles', 'example')
22020
- if (!entry?.body) throw new Error('Entry "example" not found in the articles collection.')
22021
-
22022
22346
  const registry = createBlockRegistry().use(genericBlocks()).use(customBlocks)
22023
22347
  // Static pages render at build time, so invalid blocks fail the build here.
22024
- const document = assertValidDocument(compileDocument(entry.body, registry), entry.id)
22348
+ const document = assertValidDocument(compileDocument(source, registry), 'content/example.md')
22025
22349
  ---
22026
22350
 
22027
22351
  <main style="max-width: 42rem; margin: 0 auto; padding: 3rem 1.5rem;">
@@ -22061,25 +22385,17 @@ async function createAstroPlan(ctx) {
22061
22385
  const files = [["blocks/QuoteBlock.astro", ASTRO_QUOTE_BLOCK]];
22062
22386
  const componentsJsonPath = join3(ctx.cwd, "components.json");
22063
22387
  const styled = !ctx.noStyled && existsSync2(componentsJsonPath) && await ctx.installStyledPack("@contentbit/astro-pack");
22064
- const configCandidates = ["ts", "mts", "mjs", "js"].flatMap((ext) => [
22065
- `src/content.config.${ext}`,
22066
- `src/content/config.${ext}`
22067
- ]);
22068
- const existingConfig = configCandidates.find((p) => existsSync2(join3(ctx.cwd, p)));
22069
- if (existingConfig) {
22070
- ctx.io.stdout(`content config exists (${existingConfig}); add this collection manually:`);
22071
- ctx.io.stdout(ASTRO_CONTENT_CONFIG);
22072
- ctx.io.stdout('the example page expects the "articles" collection above');
22073
- } else {
22074
- files.push(["src/content.config.ts", ASTRO_CONTENT_CONFIG]);
22075
- }
22076
22388
  if (!ctx.noPage) files.push(["src/pages/example.astro", astroPage(styled)]);
22389
+ const nextSteps = ctx.noPage ? [
22390
+ " 2. Wire content/ into your Astro content collection and render it with @contentbit/astro."
22391
+ ] : [" 2. Start the dev server and open /example to see the article rendered."];
22392
+ nextSteps.push(
22393
+ " 3. Production Astro reference: https://github.com/agonist/astro-speedrun-seo",
22394
+ " 4. Styled components: pnpm dlx shadcn@latest add @contentbit/astro-pack"
22395
+ );
22077
22396
  return {
22078
22397
  files,
22079
- nextSteps: [
22080
- " 2. Start the dev server and open /example to see the article rendered.",
22081
- " 3. Styled components: pnpm dlx shadcn@latest add @contentbit/astro-pack"
22082
- ]
22398
+ nextSteps
22083
22399
  };
22084
22400
  }
22085
22401
  function detectTarget(deps) {
@@ -22087,7 +22403,7 @@ function detectTarget(deps) {
22087
22403
  const hasAstro = Boolean(deps.astro);
22088
22404
  return hasAstro ? "astro" : hasReact ? "react" : "markdown";
22089
22405
  }
22090
- var TARGETS, RUNTIME_BASE, TANSTACK_PAGE, NEXT_PAGE, ASTRO_CONTENT_CONFIG, ASTRO_QUOTE_BLOCK, TARGET_ADAPTERS;
22406
+ var TARGETS, RUNTIME_BASE, TANSTACK_PAGE, NEXT_PAGE, ASTRO_QUOTE_BLOCK, TARGET_ADAPTERS;
22091
22407
  var init_init_targets = __esm({
22092
22408
  "src/commands/init-targets.ts"() {
22093
22409
  "use strict";
@@ -22111,8 +22427,7 @@ function ExamplePage() {
22111
22427
  `;
22112
22428
  NEXT_PAGE = `import { readFile } from 'node:fs/promises'
22113
22429
 
22114
- // If your project has no "@/" path alias, switch to a relative import.
22115
- import { Content } from '@/components/content-blocks'
22430
+ import { Content } from '../../components/content-blocks'
22116
22431
 
22117
22432
  export default async function ExamplePage() {
22118
22433
  const source = await readFile('content/example.md', 'utf8')
@@ -22122,18 +22437,6 @@ export default async function ExamplePage() {
22122
22437
  </main>
22123
22438
  )
22124
22439
  }
22125
- `;
22126
- ASTRO_CONTENT_CONFIG = `import { defineCollection } from 'astro:content'
22127
- import { glob } from 'astro/loaders'
22128
-
22129
- export const collections = {
22130
- articles: defineCollection({
22131
- // Astro's builtin Markdown loader. Entry bodies are parsed and validated
22132
- // where they render (see src/pages/example.astro); \`contentbit validate\`
22133
- // covers the same files in CI.
22134
- loader: glob({ pattern: '**/*.md', base: './content' }),
22135
- }),
22136
- }
22137
22440
  `;
22138
22441
  ASTRO_QUOTE_BLOCK = `---
22139
22442
  // The Astro component for the custom \`quote\` block defined in blocks/registry.ts.
@@ -22224,10 +22527,10 @@ function dlxCommand(pm) {
22224
22527
  return ["npx", ["--yes"]];
22225
22528
  }
22226
22529
  function runInstall(pm, args, cwd) {
22227
- return new Promise((resolve4) => {
22530
+ return new Promise((resolve5) => {
22228
22531
  const child = spawn(pm, args, { cwd, stdio: "inherit", shell: process.platform === "win32" });
22229
- child.on("close", (code2) => resolve4(code2 ?? 1));
22230
- child.on("error", () => resolve4(1));
22532
+ child.on("close", (code2) => resolve5(code2 ?? 1));
22533
+ child.on("error", () => resolve5(1));
22231
22534
  });
22232
22535
  }
22233
22536
  async function installStyledPack(cwd, pack, noInstall, io) {
@@ -22250,13 +22553,13 @@ async function installStyledPack(cwd, pack, noInstall, io) {
22250
22553
  if (code2 !== 0) io.stderr("styled pack install failed; falling back to the headless renderer");
22251
22554
  return code2 === 0;
22252
22555
  }
22253
- async function scaffold(path2, content) {
22556
+ async function scaffold(path4, content) {
22254
22557
  try {
22255
- await readFile3(path2, "utf8");
22558
+ await readFile3(path4, "utf8");
22256
22559
  return "skipped";
22257
22560
  } catch {
22258
- await mkdir2(join4(path2, ".."), { recursive: true });
22259
- await writeFile2(path2, content, "utf8");
22561
+ await mkdir2(join4(path4, ".."), { recursive: true });
22562
+ await writeFile2(path4, content, "utf8");
22260
22563
  return "created";
22261
22564
  }
22262
22565
  }
@@ -22286,7 +22589,7 @@ async function initCommand(input, io) {
22286
22589
  initialValue: detected,
22287
22590
  options: [
22288
22591
  { value: "react", label: "React", hint: "ContentBlocks component" },
22289
- { value: "astro", label: "Astro", hint: "content collections + .astro components" },
22592
+ { value: "astro", label: "Astro", hint: "standalone .astro example" },
22290
22593
  { value: "markdown", label: "Plain Markdown", hint: "fallback rendering only" }
22291
22594
  ]
22292
22595
  });
@@ -22320,9 +22623,11 @@ async function initCommand(input, io) {
22320
22623
  } else {
22321
22624
  md = choices[0];
22322
22625
  }
22323
- const runtime = adapter.runtimeDependencies(md);
22626
+ const atCliVersion = (name) => name === "contentbit" || name.startsWith("@contentbit/") ? `${name}@${VERSION}` : name;
22627
+ const runtime = adapter.runtimeDependencies(md).map(atCliVersion);
22628
+ const dev = ["contentbit", "@contentbit/studio"].map(atCliVersion);
22324
22629
  if (input.noInstall) {
22325
- io.stdout(`skipped install: ${runtime.join(" ")} + contentbit @contentbit/studio (dev)`);
22630
+ io.stdout(`skipped install: ${runtime.join(" ")} + ${dev.join(" ")} (dev)`);
22326
22631
  } else {
22327
22632
  const pm2 = detectPackageManager(cwd);
22328
22633
  io.stdout(`installing with ${pm2}: ${runtime.join(" ")}`);
@@ -22330,7 +22635,7 @@ async function initCommand(input, io) {
22330
22635
  io.stderr("install failed");
22331
22636
  return 1;
22332
22637
  }
22333
- if (await runInstall(pm2, installArgs(pm2, true, ["contentbit", "@contentbit/studio"]), cwd) !== 0) {
22638
+ if (await runInstall(pm2, installArgs(pm2, true, dev), cwd) !== 0) {
22334
22639
  io.stderr("install failed");
22335
22640
  return 1;
22336
22641
  }
@@ -22341,7 +22646,6 @@ async function initCommand(input, io) {
22341
22646
  md,
22342
22647
  noPage: Boolean(input.noPage),
22343
22648
  noStyled: Boolean(input.noStyled),
22344
- io,
22345
22649
  installStyledPack: (pack) => installStyledPack(cwd, pack, Boolean(input.noInstall), io)
22346
22650
  });
22347
22651
  const files = [
@@ -22407,6 +22711,7 @@ var REGISTRY_TEMPLATE, EXAMPLE_CONTENT, RELATED_CONTENT, SEO_CONFIG_TEMPLATE;
22407
22711
  var init_init = __esm({
22408
22712
  "src/commands/init.ts"() {
22409
22713
  "use strict";
22714
+ init_dist();
22410
22715
  init_load_registry();
22411
22716
  init_agents();
22412
22717
  init_init_targets();
@@ -22441,6 +22746,8 @@ export default [quote] satisfies BlockDefinition<unknown>[]
22441
22746
  `;
22442
22747
  EXAMPLE_CONTENT = `---
22443
22748
  slug: hello-content-blocks
22749
+ type: article
22750
+ intent: learn the contentbit authoring workflow
22444
22751
  linksTo:
22445
22752
  - related-contentbit-workflows
22446
22753
  aliases:
@@ -22474,6 +22781,8 @@ weaves flowers and leaves.
22474
22781
  `;
22475
22782
  RELATED_CONTENT = `---
22476
22783
  slug: related-contentbit-workflows
22784
+ type: article
22785
+ intent: learn the contentbit validation workflow
22477
22786
  linksTo:
22478
22787
  - hello-content-blocks
22479
22788
  keywords:
@@ -22497,6 +22806,10 @@ stays as the rename record.
22497
22806
 
22498
22807
  export default defineSeoConfig({
22499
22808
  pageTypes: {
22809
+ article: {
22810
+ requiredFrontmatter: ['type', 'intent', 'keywords.primary'],
22811
+ minOutgoingLinks: 1,
22812
+ },
22500
22813
  alternative: {
22501
22814
  requiredFrontmatter: ['type', 'intent', 'keywords.primary'],
22502
22815
  requiredSections: [
@@ -22588,18 +22901,26 @@ async function adoptCommand(input, io) {
22588
22901
  const scan = scanContentProject(project.sources, project.registry, {
22589
22902
  linkOptions: { resolve: linkResolve }
22590
22903
  });
22591
- const report = createAdoptionReport(globs, project.files.length, scan.findings, scan.files);
22904
+ const report = createAdoptionReport(
22905
+ globs,
22906
+ project.files.length,
22907
+ scan.findings,
22908
+ scan.files,
22909
+ process.cwd()
22910
+ );
22592
22911
  if (input.json) io.stdout(JSON.stringify(report, null, 2));
22593
22912
  else io.stdout(formatAdoptionReport(report));
22594
22913
  return 0;
22595
22914
  }
22596
- function createAdoptionReport(globs, files, findings, scannedFiles) {
22915
+ function createAdoptionReport(globs, files, findings, scannedFiles, root) {
22597
22916
  const frontmatters = scannedFiles.map((file2) => file2.frontmatter);
22598
22917
  const frontmatter = countFrontmatter(frontmatters);
22599
22918
  const links = inferLinkResolution(frontmatters);
22600
22919
  const pageTypes = valuesForField(frontmatters, "type");
22601
22920
  const contracts = inferContracts(scannedFiles, pageTypes);
22602
22921
  const localeCoverage = coverageByKey(frontmatters);
22922
+ const discovery = discoverContentProject(scannedFiles, { root });
22923
+ const pages = discovery.pages.map((page) => ({ path: page.path, facts: page.facts }));
22603
22924
  const contentbitConfig = contentbitConfigProposal(globs, links);
22604
22925
  const seoConfig = contracts.length > 0 ? seoConfigProposal(contracts) : void 0;
22605
22926
  return {
@@ -22607,12 +22928,20 @@ function createAdoptionReport(globs, files, findings, scannedFiles) {
22607
22928
  dryRun: true,
22608
22929
  files,
22609
22930
  frontmatter,
22610
- inferred: { content: globs, links: { resolve: links }, pageTypes, contracts },
22931
+ inferred: {
22932
+ content: globs,
22933
+ links: { resolve: links },
22934
+ pageTypes,
22935
+ families: discovery.families,
22936
+ locales: discovery.locales,
22937
+ contracts
22938
+ },
22611
22939
  localeCoverage,
22940
+ pages,
22612
22941
  findings,
22613
22942
  proposals: {
22614
22943
  contentbitConfig,
22615
- frontmatter: frontmatterProposals(scannedFiles),
22944
+ frontmatter: frontmatterProposals(scannedFiles, discovery.pages),
22616
22945
  ...seoConfig ? { seoConfig } : {}
22617
22946
  }
22618
22947
  };
@@ -22681,36 +23010,31 @@ function primaryKeyword(frontmatter) {
22681
23010
  if (!keywords || typeof keywords !== "object" || Array.isArray(keywords)) return void 0;
22682
23011
  return stringValue2(keywords.primary);
22683
23012
  }
22684
- function frontmatterProposals(files) {
23013
+ function frontmatterProposals(files, pages) {
22685
23014
  const proposals = [];
22686
23015
  for (const file2 of files) {
23016
+ const discovered = pages.find((page) => page.sourcePath === file2.path)?.facts;
23017
+ if (!discovered) continue;
22687
23018
  const add = {};
22688
- if (!stringValue2(file2.frontmatter.slug)) add.slug = slugFromPath(file2.path);
23019
+ if (!stringValue2(file2.frontmatter.slug)) add.slug = discovered.slug.value;
22689
23020
  if (!stringValue2(file2.frontmatter.title)) {
22690
- add.title = file2.stats.outline[0]?.text ?? titleFromPath(file2.path);
23021
+ add.title = discovered.title.value;
22691
23022
  }
22692
23023
  if (Object.keys(add).length > 0) proposals.push({ path: file2.path, add });
22693
23024
  }
22694
23025
  return proposals;
22695
23026
  }
22696
- function slugFromPath(path2) {
22697
- return titleFromPath(path2).toLocaleLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "");
22698
- }
22699
- function titleFromPath(path2) {
22700
- const filename = path2.slice(path2.lastIndexOf("/") + 1).replace(/\.mdx?$/i, "");
22701
- return filename.replace(/[-_]+/g, " ").replace(/\b\p{L}/gu, (letter) => letter.toUpperCase());
22702
- }
22703
23027
  function stringValue2(value) {
22704
23028
  return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
22705
23029
  }
22706
- function contentbitConfigProposal(globs, resolve4) {
23030
+ function contentbitConfigProposal(globs, resolve5) {
22707
23031
  const content = globs.length === 1 ? singleQuoted(globs[0]) : `[${globs.map(singleQuoted).join(", ")}]`;
22708
23032
  return `import { defineContentConfig } from '@contentbit/core'
22709
23033
 
22710
23034
  export default defineContentConfig({
22711
23035
  content: ${content},
22712
23036
  links: {
22713
- resolve: '${resolve4}',
23037
+ resolve: '${resolve5}',
22714
23038
  },
22715
23039
  })
22716
23040
  `;
@@ -22810,10 +23134,10 @@ var init_adopt = __esm({
22810
23134
  // src/link-options.ts
22811
23135
  function linkResolverOptions(values) {
22812
23136
  const out = {};
22813
- const resolve4 = stringValue3(values.linkResolve ?? values["link-resolve"]);
22814
- if (resolve4) {
22815
- if (!isResolveMode(resolve4)) throw new Error(`invalid --link-resolve ${resolve4}`);
22816
- out.resolve = resolve4;
23137
+ const resolve5 = stringValue3(values.linkResolve ?? values["link-resolve"]);
23138
+ if (resolve5) {
23139
+ if (!isResolveMode(resolve5)) throw new Error(`invalid --link-resolve ${resolve5}`);
23140
+ out.resolve = resolve5;
22817
23141
  }
22818
23142
  const localeField = stringValue3(values.localeField ?? values["locale-field"]);
22819
23143
  const slugField = stringValue3(values.slugField ?? values["slug-field"]);
@@ -22842,17 +23166,17 @@ import { existsSync as existsSync4 } from "node:fs";
22842
23166
  import { dirname as dirname3, isAbsolute as isAbsolute3, join as join5, resolve as resolve2 } from "node:path";
22843
23167
  import { pathToFileURL as pathToFileURL2 } from "node:url";
22844
23168
  async function loadContentbitConfig(startDir = process.cwd(), explicitPath) {
22845
- const path2 = explicitPath ? isAbsolute3(explicitPath) ? explicitPath : resolve2(startDir, explicitPath) : findConfig(startDir);
22846
- if (!path2) return void 0;
22847
- const mod = await import(pathToFileURL2(path2).href);
23169
+ const path4 = explicitPath ? isAbsolute3(explicitPath) ? explicitPath : resolve2(startDir, explicitPath) : findConfig(startDir);
23170
+ if (!path4) return void 0;
23171
+ const mod = await import(pathToFileURL2(path4).href);
22848
23172
  if (!mod.default || typeof mod.default !== "object") {
22849
- throw new Error(`Contentbit config must default-export a config object: ${path2}`);
23173
+ throw new Error(`Contentbit config must default-export a config object: ${path4}`);
22850
23174
  }
22851
- const content = normalizeContent(mod.default.content, path2);
23175
+ const content = normalizeContent(mod.default.content, path4);
22852
23176
  return {
22853
23177
  config: { ...mod.default, content },
22854
- cwd: dirname3(path2),
22855
- path: path2
23178
+ cwd: dirname3(path4),
23179
+ path: path4
22856
23180
  };
22857
23181
  }
22858
23182
  function findConfig(startDir) {
@@ -22867,11 +23191,11 @@ function findConfig(startDir) {
22867
23191
  current = parent;
22868
23192
  }
22869
23193
  }
22870
- function normalizeContent(value, path2) {
23194
+ function normalizeContent(value, path4) {
22871
23195
  const content = typeof value === "string" ? [value] : value;
22872
23196
  if (!Array.isArray(content) || content.length === 0 || content.some((item) => typeof item !== "string" || item.length === 0)) {
22873
23197
  throw new Error(
22874
- `Contentbit config "content" must be a non-empty string or string array: ${path2}`
23198
+ `Contentbit config "content" must be a non-empty string or string array: ${path4}`
22875
23199
  );
22876
23200
  }
22877
23201
  return content;
@@ -22889,10 +23213,56 @@ var init_project_config = __esm({
22889
23213
  }
22890
23214
  });
22891
23215
 
22892
- // src/script-defaults.ts
23216
+ // src/seo-config.ts
22893
23217
  import { existsSync as existsSync5 } from "node:fs";
23218
+ import { isAbsolute as isAbsolute4, join as join6 } from "node:path";
23219
+ import { pathToFileURL as pathToFileURL3 } from "node:url";
23220
+ async function loadSeoConfig(input = {}) {
23221
+ if (input.noSeo) return {};
23222
+ const cwd = input.cwd ?? process.cwd();
23223
+ const path4 = input.seoConfig ? isAbsolute4(input.seoConfig) ? input.seoConfig : join6(cwd, input.seoConfig) : join6(cwd, DEFAULT_SEO_CONFIG);
23224
+ if (!input.seoConfig && !existsSync5(path4)) return {};
23225
+ const mod = await import(pathToFileURL3(path4).href);
23226
+ if (mod.default === void 0) {
23227
+ throw new Error(`SEO config must default-export a config object: ${path4}`);
23228
+ }
23229
+ return { config: mod.default, path: path4 };
23230
+ }
23231
+ var DEFAULT_SEO_CONFIG;
23232
+ var init_seo_config = __esm({
23233
+ "src/seo-config.ts"() {
23234
+ "use strict";
23235
+ DEFAULT_SEO_CONFIG = "contentbit.seo.config.ts";
23236
+ }
23237
+ });
23238
+
23239
+ // src/command-config.ts
23240
+ import { existsSync as existsSync6 } from "node:fs";
22894
23241
  import { readFile as readFile4 } from "node:fs/promises";
22895
- import { dirname as dirname4, isAbsolute as isAbsolute4, join as join6, resolve as resolve3 } from "node:path";
23242
+ import { dirname as dirname4, isAbsolute as isAbsolute5, join as join7, resolve as resolve3 } from "node:path";
23243
+ async function resolveContentCommandConfig(command, input, startDir = process.cwd()) {
23244
+ const defaults = await discoverContentCommandDefaults(command, input.globs, startDir);
23245
+ const links = {
23246
+ linkResolve: input.linkResolve ?? defaults.linkResolve,
23247
+ localeField: input.localeField ?? defaults.localeField,
23248
+ slugField: input.slugField ?? defaults.slugField,
23249
+ keyField: input.keyField ?? defaults.keyField,
23250
+ defaultLocale: input.defaultLocale ?? defaults.defaultLocale
23251
+ };
23252
+ const seo = {
23253
+ cwd: defaults.cwd,
23254
+ seoConfig: input.seoConfig ?? defaults.seoConfig,
23255
+ noSeo: input.noSeo ?? (input.seoConfig ? false : defaults.noSeo)
23256
+ };
23257
+ return {
23258
+ globs: defaults.globs,
23259
+ cwd: defaults.cwd,
23260
+ registry: input.registry ?? defaults.registry,
23261
+ includeGenericBlocks: !(input.noGenericBlocks || defaults.noGenericBlocks),
23262
+ resolveLinkOptions: () => linkResolverOptions(links),
23263
+ loadSeo: () => loadSeoConfig(seo)
23264
+ };
23265
+ }
22896
23266
  async function discoverContentCommandDefaults(command, explicitGlobs, startDir = process.cwd()) {
22897
23267
  const loadedConfig = await loadContentbitConfig(startDir);
22898
23268
  const configDefaults = loadedConfig ? {
@@ -22921,15 +23291,15 @@ async function discoverContentCommandDefaults(command, explicitGlobs, startDir =
22921
23291
  source: `${found.packageJson}#scripts.${found.scriptName}`
22922
23292
  };
22923
23293
  }
22924
- function resolveConfigPath(cwd, path2) {
22925
- if (!path2) return void 0;
22926
- return isAbsolute4(path2) ? path2 : resolve3(cwd, path2);
23294
+ function resolveConfigPath(cwd, path4) {
23295
+ if (!path4) return void 0;
23296
+ return isAbsolute5(path4) ? path4 : resolve3(cwd, path4);
22927
23297
  }
22928
23298
  async function findPackageScript(command, startDir) {
22929
23299
  let current = resolve3(startDir);
22930
23300
  while (true) {
22931
- const packageJson = join6(current, "package.json");
22932
- if (existsSync5(packageJson)) {
23301
+ const packageJson = join7(current, "package.json");
23302
+ if (existsSync6(packageJson)) {
22933
23303
  const scripts = await packageScripts(packageJson);
22934
23304
  for (const name of SCRIPT_CANDIDATES[command]) {
22935
23305
  const script = scripts[name];
@@ -22946,9 +23316,9 @@ async function findPackageScript(command, startDir) {
22946
23316
  current = parent;
22947
23317
  }
22948
23318
  }
22949
- async function packageScripts(path2) {
23319
+ async function packageScripts(path4) {
22950
23320
  try {
22951
- const pkg = JSON.parse(await readFile4(path2, "utf8"));
23321
+ const pkg = JSON.parse(await readFile4(path4, "utf8"));
22952
23322
  const out = {};
22953
23323
  for (const [name, value] of Object.entries(pkg.scripts ?? {})) {
22954
23324
  if (typeof value === "string") out[name] = value;
@@ -23055,17 +23425,20 @@ function splitShellArgs(input) {
23055
23425
  return args;
23056
23426
  }
23057
23427
  var SCRIPT_CANDIDATES;
23058
- var init_script_defaults = __esm({
23059
- "src/script-defaults.ts"() {
23428
+ var init_command_config = __esm({
23429
+ "src/command-config.ts"() {
23060
23430
  "use strict";
23431
+ init_link_options();
23061
23432
  init_project_config();
23433
+ init_seo_config();
23062
23434
  SCRIPT_CANDIDATES = {
23063
23435
  validate: ["content:check", "content:validate"],
23064
23436
  doctor: ["content:doctor", "content:check"],
23065
23437
  studio: ["studio", "content:studio", "content:check"],
23066
23438
  links: ["content:links", "content:check"],
23067
23439
  stats: ["content:stats", "content:check"],
23068
- brief: ["content:brief", "content:check"]
23440
+ brief: ["content:brief", "content:check"],
23441
+ snapshot: ["content:snapshot", "content:check"]
23069
23442
  };
23070
23443
  }
23071
23444
  });
@@ -23076,20 +23449,14 @@ __export(validate_exports, {
23076
23449
  validateCommand: () => validateCommand
23077
23450
  });
23078
23451
  async function validateCommand(input, io) {
23079
- const defaults = await discoverContentCommandDefaults("validate", input.globs);
23080
- const linkOptions = linkResolverOptions({
23081
- linkResolve: input.linkResolve ?? defaults.linkResolve,
23082
- localeField: input.localeField ?? defaults.localeField,
23083
- slugField: input.slugField ?? defaults.slugField,
23084
- keyField: input.keyField ?? defaults.keyField,
23085
- defaultLocale: input.defaultLocale ?? defaults.defaultLocale
23086
- });
23452
+ const config2 = await resolveContentCommandConfig("validate", input);
23453
+ const linkOptions = config2.resolveLinkOptions();
23087
23454
  const { files, scan } = await loadContentProject2({
23088
23455
  cmd: "validate",
23089
- positionals: defaults.globs,
23090
- cwd: defaults.cwd,
23091
- registry: input.registry ?? defaults.registry,
23092
- includeGenericBlocks: !(input.noGenericBlocks || defaults.noGenericBlocks),
23456
+ positionals: config2.globs,
23457
+ cwd: config2.cwd,
23458
+ registry: config2.registry,
23459
+ includeGenericBlocks: config2.includeGenericBlocks,
23093
23460
  linkOptions,
23094
23461
  scan: { includeStatsFindings: false, includeIntegrityFindings: false }
23095
23462
  });
@@ -23131,33 +23498,9 @@ function diagnosticFromFinding(finding2) {
23131
23498
  var init_validate2 = __esm({
23132
23499
  "src/commands/validate.ts"() {
23133
23500
  "use strict";
23501
+ init_command_config();
23134
23502
  init_cli_format();
23135
23503
  init_content_project();
23136
- init_link_options();
23137
- init_script_defaults();
23138
- }
23139
- });
23140
-
23141
- // src/seo-config.ts
23142
- import { existsSync as existsSync6 } from "node:fs";
23143
- import { isAbsolute as isAbsolute5, join as join7 } from "node:path";
23144
- import { pathToFileURL as pathToFileURL3 } from "node:url";
23145
- async function loadSeoConfig(input = {}) {
23146
- if (input.noSeo) return {};
23147
- const cwd = input.cwd ?? process.cwd();
23148
- const path2 = input.seoConfig ? isAbsolute5(input.seoConfig) ? input.seoConfig : join7(cwd, input.seoConfig) : join7(cwd, DEFAULT_SEO_CONFIG);
23149
- if (!input.seoConfig && !existsSync6(path2)) return {};
23150
- const mod = await import(pathToFileURL3(path2).href);
23151
- if (mod.default === void 0) {
23152
- throw new Error(`SEO config must default-export a config object: ${path2}`);
23153
- }
23154
- return { config: mod.default, path: path2 };
23155
- }
23156
- var DEFAULT_SEO_CONFIG;
23157
- var init_seo_config = __esm({
23158
- "src/seo-config.ts"() {
23159
- "use strict";
23160
- DEFAULT_SEO_CONFIG = "contentbit.seo.config.ts";
23161
23504
  }
23162
23505
  });
23163
23506
 
@@ -23180,30 +23523,20 @@ async function doctorCommand(input, io) {
23180
23523
  return watchDoctor(input, io, first.files);
23181
23524
  }
23182
23525
  async function doctorOnce(input, io) {
23183
- const defaults = await discoverContentCommandDefaults("doctor", input.globs);
23526
+ const config2 = await resolveContentCommandConfig("doctor", input);
23184
23527
  const minSectionWords = parseMinSectionWords(input.minSectionWords);
23185
23528
  if (minSectionWords === null) {
23186
23529
  io.stderr("doctor: --min-section-words must be a non-negative integer.");
23187
23530
  return { exitCode: 2, files: [] };
23188
23531
  }
23189
- const includeGenericBlocks = !(input.noGenericBlocks || defaults.noGenericBlocks);
23190
- const linkOptions = linkResolverOptions({
23191
- linkResolve: input.linkResolve ?? defaults.linkResolve,
23192
- localeField: input.localeField ?? defaults.localeField,
23193
- slugField: input.slugField ?? defaults.slugField,
23194
- keyField: input.keyField ?? defaults.keyField,
23195
- defaultLocale: input.defaultLocale ?? defaults.defaultLocale
23196
- });
23197
- const seoConfig = await loadSeoConfig({
23198
- cwd: defaults.cwd,
23199
- seoConfig: input.seoConfig ?? defaults.seoConfig,
23200
- noSeo: input.noSeo ?? defaults.noSeo
23201
- });
23532
+ const includeGenericBlocks = config2.includeGenericBlocks;
23533
+ const linkOptions = config2.resolveLinkOptions();
23534
+ const seoConfig = await config2.loadSeo();
23202
23535
  const { files, scan } = await loadContentProject2({
23203
23536
  cmd: "doctor",
23204
- positionals: defaults.globs,
23205
- cwd: defaults.cwd,
23206
- registry: input.registry ?? defaults.registry,
23537
+ positionals: config2.globs,
23538
+ cwd: config2.cwd,
23539
+ registry: config2.registry,
23207
23540
  includeGenericBlocks,
23208
23541
  linkOptions,
23209
23542
  scan: { minSectionWords, seoConfig: seoConfig.config, seoConfigPath: seoConfig.path }
@@ -23228,8 +23561,8 @@ async function doctorOnce(input, io) {
23228
23561
  io.stdout(
23229
23562
  formatReport(
23230
23563
  report,
23231
- defaults.globs,
23232
- input.registry ?? defaults.registry,
23564
+ config2.globs,
23565
+ config2.registry,
23233
23566
  includeGenericBlocks,
23234
23567
  linkOptions,
23235
23568
  hasAliases(scan.linkInputs)
@@ -23281,12 +23614,12 @@ async function watchDoctor(input, io, initialFiles) {
23281
23614
  }
23282
23615
  }
23283
23616
  io.stdout("\nWatching for changes\u2026 Press Ctrl+C to stop.");
23284
- return new Promise((resolve4) => {
23617
+ return new Promise((resolve5) => {
23285
23618
  const stop = () => {
23286
23619
  close();
23287
23620
  process.off("SIGINT", stop);
23288
23621
  process.off("SIGTERM", stop);
23289
- resolve4(0);
23622
+ resolve5(0);
23290
23623
  };
23291
23624
  process.once("SIGINT", stop);
23292
23625
  process.once("SIGTERM", stop);
@@ -23350,16 +23683,16 @@ async function skillDriftFindings(files) {
23350
23683
  for (const skill of SHIPPED_SKILLS) {
23351
23684
  const shipped = skillVersion2(skill.content);
23352
23685
  if (!shipped.value) continue;
23353
- const path2 = join8(root, ".claude/skills", skill.name, "SKILL.md");
23354
- if (!existsSync7(path2)) continue;
23355
- const installedContent = await readFile5(path2, "utf8");
23686
+ const path4 = join8(root, ".claude/skills", skill.name, "SKILL.md");
23687
+ if (!existsSync7(path4)) continue;
23688
+ const installedContent = await readFile5(path4, "utf8");
23356
23689
  const installed = skillVersion2(installedContent);
23357
23690
  if (installed.value === shipped.value) continue;
23358
23691
  findings.push({
23359
23692
  severity: "warning",
23360
23693
  source: "agents",
23361
23694
  code: "CB_SKILL_DRIFT",
23362
- file: path2,
23695
+ file: path4,
23363
23696
  line: installed.line ?? 1,
23364
23697
  column: 1,
23365
23698
  message: `${skill.name} skill is stale (installed version ${installed.value ?? "unknown"}, package ships ${shipped.value}).`,
@@ -23517,10 +23850,8 @@ var init_doctor = __esm({
23517
23850
  "use strict";
23518
23851
  init_dist();
23519
23852
  init_cli_format();
23853
+ init_command_config();
23520
23854
  init_content_project();
23521
- init_link_options();
23522
- init_seo_config();
23523
- init_script_defaults();
23524
23855
  init_SKILL();
23525
23856
  init_SKILL2();
23526
23857
  SHIPPED_SKILLS = [
@@ -23537,35 +23868,25 @@ __export(brief_exports, {
23537
23868
  });
23538
23869
  import { glob as glob2 } from "tinyglobby";
23539
23870
  async function briefCommand(input, io) {
23540
- const defaults = await discoverContentCommandDefaults("brief", input.globs);
23541
- const seoConfig = await loadSeoConfig({
23542
- cwd: defaults.cwd,
23543
- seoConfig: input.seoConfig ?? defaults.seoConfig,
23544
- noSeo: defaults.noSeo
23545
- });
23871
+ const config2 = await resolveContentCommandConfig("brief", input);
23872
+ const seoConfig = await config2.loadSeo();
23546
23873
  if (!seoConfig.config) {
23547
23874
  io.stderr(
23548
23875
  "brief: no SEO config found. Add contentbit.seo.config.ts or pass --seo-config <path>."
23549
23876
  );
23550
23877
  return 2;
23551
23878
  }
23552
- const includeGenericBlocks = !(input.noGenericBlocks || defaults.noGenericBlocks);
23553
- const globs = defaults.globs.length > 0 ? defaults.globs : await defaultBriefGlobs(defaults.cwd);
23879
+ const includeGenericBlocks = config2.includeGenericBlocks;
23880
+ const globs = config2.globs.length > 0 ? config2.globs : await defaultBriefGlobs(config2.cwd);
23554
23881
  const { scan } = await loadContentProject2({
23555
23882
  cmd: "brief",
23556
23883
  positionals: globs,
23557
- cwd: defaults.cwd,
23558
- registry: input.registry ?? defaults.registry,
23884
+ cwd: config2.cwd,
23885
+ registry: config2.registry,
23559
23886
  includeGenericBlocks,
23560
- linkOptions: linkResolverOptions({
23561
- linkResolve: input.linkResolve ?? defaults.linkResolve,
23562
- localeField: input.localeField ?? defaults.localeField,
23563
- slugField: input.slugField ?? defaults.slugField,
23564
- keyField: input.keyField ?? defaults.keyField,
23565
- defaultLocale: input.defaultLocale ?? defaults.defaultLocale
23566
- }),
23887
+ linkOptions: config2.resolveLinkOptions(),
23567
23888
  scan: { seoConfig: seoConfig.config, seoConfigPath: seoConfig.path },
23568
- allowEmpty: globs.length === 0
23889
+ allowEmpty: true
23569
23890
  });
23570
23891
  if (!scan.seo) {
23571
23892
  io.stderr("brief: SEO scan did not produce a result.");
@@ -23596,80 +23917,1486 @@ var init_brief = __esm({
23596
23917
  "src/commands/brief.ts"() {
23597
23918
  "use strict";
23598
23919
  init_dist();
23920
+ init_command_config();
23599
23921
  init_content_project();
23600
- init_link_options();
23601
- init_seo_config();
23602
- init_script_defaults();
23603
23922
  DEFAULT_BRIEF_GLOBS = ["content/**/*.{md,mdx}"];
23604
23923
  }
23605
23924
  });
23606
23925
 
23607
- // src/commands/studio.ts
23608
- var studio_exports = {};
23609
- __export(studio_exports, {
23610
- studioCommand: () => studioCommand
23611
- });
23612
- async function studioCommand(input, io) {
23613
- const defaults = await discoverContentCommandDefaults("studio", input.globs);
23614
- const port = parsePort(input.port);
23615
- if (port === null) {
23616
- io.stderr("studio: --port must be an integer between 0 and 65535.");
23617
- return 2;
23618
- }
23619
- const minSectionWords = parseMinSectionWords2(input.minSectionWords);
23620
- if (minSectionWords === null) {
23621
- io.stderr("studio: --min-section-words must be a non-negative integer.");
23622
- return 2;
23926
+ // ../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/errors.js
23927
+ import v8 from "node:v8";
23928
+ import assert2 from "node:assert";
23929
+ import { format, inspect } from "node:util";
23930
+ function formatList(array2, type = "and") {
23931
+ return array2.length < 3 ? array2.join(` ${type} `) : `${array2.slice(0, -1).join(", ")}, ${type} ${array2[array2.length - 1]}`;
23932
+ }
23933
+ function createError(sym, value, constructor) {
23934
+ messages.set(sym, value);
23935
+ return makeNodeErrorWithCode(constructor, sym);
23936
+ }
23937
+ function makeNodeErrorWithCode(Base, key) {
23938
+ return NodeError;
23939
+ function NodeError(...parameters) {
23940
+ const limit = Error.stackTraceLimit;
23941
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
23942
+ const error51 = new Base();
23943
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
23944
+ const message = getMessage(key, parameters, error51);
23945
+ Object.defineProperties(error51, {
23946
+ // Note: no need to implement `kIsNodeError` symbol, would be hard,
23947
+ // probably.
23948
+ message: {
23949
+ value: message,
23950
+ enumerable: false,
23951
+ writable: true,
23952
+ configurable: true
23953
+ },
23954
+ toString: {
23955
+ /** @this {Error} */
23956
+ value() {
23957
+ return `${this.name} [${key}]: ${this.message}`;
23958
+ },
23959
+ enumerable: false,
23960
+ writable: true,
23961
+ configurable: true
23962
+ }
23963
+ });
23964
+ captureLargerStackTrace(error51);
23965
+ error51.code = key;
23966
+ return error51;
23623
23967
  }
23624
- await resolveContentFiles2(defaults.globs, "studio", { cwd: defaults.cwd });
23625
- const seoConfig = await loadSeoConfig({
23626
- cwd: defaults.cwd,
23627
- seoConfig: input.seoConfig ?? defaults.seoConfig,
23628
- noSeo: input.noSeo ?? defaults.noSeo
23629
- });
23630
- let startStudio;
23968
+ }
23969
+ function isErrorStackTraceLimitWritable() {
23631
23970
  try {
23632
- ;
23633
- ({ startStudio } = await import("@contentbit/studio"));
23634
- } catch (error51) {
23635
- if (isMissingStudio(error51)) {
23636
- throw new Error(
23637
- "Studio is installed separately to keep the base CLI lightweight. Install it with your package manager, for example: pnpm add -D @contentbit/studio"
23638
- );
23971
+ if (v8.startupSnapshot.isBuildingSnapshot()) {
23972
+ return false;
23639
23973
  }
23640
- throw error51;
23974
+ } catch {
23641
23975
  }
23642
- const studioOptions = {
23643
- globs: defaults.globs,
23644
- cwd: defaults.cwd,
23645
- registryPath: input.registry ?? defaults.registry,
23646
- includeGenericBlocks: !(input.noGenericBlocks || defaults.noGenericBlocks),
23647
- host: input.host,
23648
- ...port !== void 0 ? { port } : {},
23649
- open: !input.noOpen,
23650
- linkOptions: linkResolverOptions({
23651
- linkResolve: input.linkResolve ?? defaults.linkResolve,
23652
- localeField: input.localeField ?? defaults.localeField,
23653
- slugField: input.slugField ?? defaults.slugField,
23654
- keyField: input.keyField ?? defaults.keyField,
23655
- defaultLocale: input.defaultLocale ?? defaults.defaultLocale
23656
- }),
23657
- minSectionWords,
23658
- seoConfig: seoConfig.config,
23659
- seoConfigPath: seoConfig.path
23660
- };
23661
- const server = await startStudio(studioOptions);
23662
- io.stdout(
23663
- [
23664
- section("contentbit studio"),
23665
- ...formatRows([
23666
- { label: "URL", value: server.url, tone: "info" },
23667
- { label: "Stop", value: "Ctrl+C" }
23668
- ])
23669
- ].join("\n")
23976
+ const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
23977
+ if (desc === void 0) {
23978
+ return Object.isExtensible(Error);
23979
+ }
23980
+ return own.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
23981
+ }
23982
+ function hideStackFrames(wrappedFunction) {
23983
+ const hidden = nodeInternalPrefix + wrappedFunction.name;
23984
+ Object.defineProperty(wrappedFunction, "name", { value: hidden });
23985
+ return wrappedFunction;
23986
+ }
23987
+ function getMessage(key, parameters, self) {
23988
+ const message = messages.get(key);
23989
+ assert2.ok(message !== void 0, "expected `message` to be found");
23990
+ if (typeof message === "function") {
23991
+ assert2.ok(
23992
+ message.length <= parameters.length,
23993
+ // Default options do not count.
23994
+ `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`
23995
+ );
23996
+ return Reflect.apply(message, self, parameters);
23997
+ }
23998
+ const regex = /%[dfijoOs]/g;
23999
+ let expectedLength = 0;
24000
+ while (regex.exec(message) !== null) expectedLength++;
24001
+ assert2.ok(
24002
+ expectedLength === parameters.length,
24003
+ `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`
23670
24004
  );
23671
- const close = () => {
23672
- void server.close();
24005
+ if (parameters.length === 0) return message;
24006
+ parameters.unshift(message);
24007
+ return Reflect.apply(format, null, parameters);
24008
+ }
24009
+ function determineSpecificType(value) {
24010
+ if (value === null || value === void 0) {
24011
+ return String(value);
24012
+ }
24013
+ if (typeof value === "function" && value.name) {
24014
+ return `function ${value.name}`;
24015
+ }
24016
+ if (typeof value === "object") {
24017
+ if (value.constructor && value.constructor.name) {
24018
+ return `an instance of ${value.constructor.name}`;
24019
+ }
24020
+ return `${inspect(value, { depth: -1 })}`;
24021
+ }
24022
+ let inspected = inspect(value, { colors: false });
24023
+ if (inspected.length > 28) {
24024
+ inspected = `${inspected.slice(0, 25)}...`;
24025
+ }
24026
+ return `type ${typeof value} (${inspected})`;
24027
+ }
24028
+ var own, classRegExp, kTypes, codes, messages, nodeInternalPrefix, userStackTraceLimit, captureLargerStackTrace;
24029
+ var init_errors3 = __esm({
24030
+ "../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/errors.js"() {
24031
+ own = {}.hasOwnProperty;
24032
+ classRegExp = /^([A-Z][a-z\d]*)+$/;
24033
+ kTypes = /* @__PURE__ */ new Set([
24034
+ "string",
24035
+ "function",
24036
+ "number",
24037
+ "object",
24038
+ // Accept 'Function' and 'Object' as alternative to the lower cased version.
24039
+ "Function",
24040
+ "Object",
24041
+ "boolean",
24042
+ "bigint",
24043
+ "symbol"
24044
+ ]);
24045
+ codes = {};
24046
+ messages = /* @__PURE__ */ new Map();
24047
+ nodeInternalPrefix = "__node_internal_";
24048
+ codes.ERR_INVALID_ARG_TYPE = createError(
24049
+ "ERR_INVALID_ARG_TYPE",
24050
+ /**
24051
+ * @param {string} name
24052
+ * @param {Array<string> | string} expected
24053
+ * @param {unknown} actual
24054
+ */
24055
+ (name, expected, actual) => {
24056
+ assert2.ok(typeof name === "string", "'name' must be a string");
24057
+ if (!Array.isArray(expected)) {
24058
+ expected = [expected];
24059
+ }
24060
+ let message = "The ";
24061
+ if (name.endsWith(" argument")) {
24062
+ message += `${name} `;
24063
+ } else {
24064
+ const type = name.includes(".") ? "property" : "argument";
24065
+ message += `"${name}" ${type} `;
24066
+ }
24067
+ message += "must be ";
24068
+ const types = [];
24069
+ const instances = [];
24070
+ const other = [];
24071
+ for (const value of expected) {
24072
+ assert2.ok(
24073
+ typeof value === "string",
24074
+ "All expected entries have to be of type string"
24075
+ );
24076
+ if (kTypes.has(value)) {
24077
+ types.push(value.toLowerCase());
24078
+ } else if (classRegExp.exec(value) === null) {
24079
+ assert2.ok(
24080
+ value !== "object",
24081
+ 'The value "object" should be written as "Object"'
24082
+ );
24083
+ other.push(value);
24084
+ } else {
24085
+ instances.push(value);
24086
+ }
24087
+ }
24088
+ if (instances.length > 0) {
24089
+ const pos = types.indexOf("object");
24090
+ if (pos !== -1) {
24091
+ types.slice(pos, 1);
24092
+ instances.push("Object");
24093
+ }
24094
+ }
24095
+ if (types.length > 0) {
24096
+ message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(
24097
+ types,
24098
+ "or"
24099
+ )}`;
24100
+ if (instances.length > 0 || other.length > 0) message += " or ";
24101
+ }
24102
+ if (instances.length > 0) {
24103
+ message += `an instance of ${formatList(instances, "or")}`;
24104
+ if (other.length > 0) message += " or ";
24105
+ }
24106
+ if (other.length > 0) {
24107
+ if (other.length > 1) {
24108
+ message += `one of ${formatList(other, "or")}`;
24109
+ } else {
24110
+ if (other[0].toLowerCase() !== other[0]) message += "an ";
24111
+ message += `${other[0]}`;
24112
+ }
24113
+ }
24114
+ message += `. Received ${determineSpecificType(actual)}`;
24115
+ return message;
24116
+ },
24117
+ TypeError
24118
+ );
24119
+ codes.ERR_INVALID_MODULE_SPECIFIER = createError(
24120
+ "ERR_INVALID_MODULE_SPECIFIER",
24121
+ /**
24122
+ * @param {string} request
24123
+ * @param {string} reason
24124
+ * @param {string} [base]
24125
+ */
24126
+ (request, reason, base = void 0) => {
24127
+ return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
24128
+ },
24129
+ TypeError
24130
+ );
24131
+ codes.ERR_INVALID_PACKAGE_CONFIG = createError(
24132
+ "ERR_INVALID_PACKAGE_CONFIG",
24133
+ /**
24134
+ * @param {string} path
24135
+ * @param {string} [base]
24136
+ * @param {string} [message]
24137
+ */
24138
+ (path4, base, message) => {
24139
+ return `Invalid package config ${path4}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
24140
+ },
24141
+ Error
24142
+ );
24143
+ codes.ERR_INVALID_PACKAGE_TARGET = createError(
24144
+ "ERR_INVALID_PACKAGE_TARGET",
24145
+ /**
24146
+ * @param {string} packagePath
24147
+ * @param {string} key
24148
+ * @param {unknown} target
24149
+ * @param {boolean} [isImport=false]
24150
+ * @param {string} [base]
24151
+ */
24152
+ (packagePath, key, target, isImport = false, base = void 0) => {
24153
+ const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
24154
+ if (key === ".") {
24155
+ assert2.ok(isImport === false);
24156
+ return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
24157
+ }
24158
+ return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(
24159
+ target
24160
+ )} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
24161
+ },
24162
+ Error
24163
+ );
24164
+ codes.ERR_MODULE_NOT_FOUND = createError(
24165
+ "ERR_MODULE_NOT_FOUND",
24166
+ /**
24167
+ * @param {string} path
24168
+ * @param {string} base
24169
+ * @param {boolean} [exactUrl]
24170
+ */
24171
+ (path4, base, exactUrl = false) => {
24172
+ return `Cannot find ${exactUrl ? "module" : "package"} '${path4}' imported from ${base}`;
24173
+ },
24174
+ Error
24175
+ );
24176
+ codes.ERR_NETWORK_IMPORT_DISALLOWED = createError(
24177
+ "ERR_NETWORK_IMPORT_DISALLOWED",
24178
+ "import of '%s' by %s is not supported: %s",
24179
+ Error
24180
+ );
24181
+ codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
24182
+ "ERR_PACKAGE_IMPORT_NOT_DEFINED",
24183
+ /**
24184
+ * @param {string} specifier
24185
+ * @param {string} packagePath
24186
+ * @param {string} base
24187
+ */
24188
+ (specifier, packagePath, base) => {
24189
+ return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
24190
+ },
24191
+ TypeError
24192
+ );
24193
+ codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
24194
+ "ERR_PACKAGE_PATH_NOT_EXPORTED",
24195
+ /**
24196
+ * @param {string} packagePath
24197
+ * @param {string} subpath
24198
+ * @param {string} [base]
24199
+ */
24200
+ (packagePath, subpath, base = void 0) => {
24201
+ if (subpath === ".")
24202
+ return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
24203
+ return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
24204
+ },
24205
+ Error
24206
+ );
24207
+ codes.ERR_UNSUPPORTED_DIR_IMPORT = createError(
24208
+ "ERR_UNSUPPORTED_DIR_IMPORT",
24209
+ "Directory import '%s' is not supported resolving ES modules imported from %s",
24210
+ Error
24211
+ );
24212
+ codes.ERR_UNSUPPORTED_RESOLVE_REQUEST = createError(
24213
+ "ERR_UNSUPPORTED_RESOLVE_REQUEST",
24214
+ 'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.',
24215
+ TypeError
24216
+ );
24217
+ codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
24218
+ "ERR_UNKNOWN_FILE_EXTENSION",
24219
+ /**
24220
+ * @param {string} extension
24221
+ * @param {string} path
24222
+ */
24223
+ (extension, path4) => {
24224
+ return `Unknown file extension "${extension}" for ${path4}`;
24225
+ },
24226
+ TypeError
24227
+ );
24228
+ codes.ERR_INVALID_ARG_VALUE = createError(
24229
+ "ERR_INVALID_ARG_VALUE",
24230
+ /**
24231
+ * @param {string} name
24232
+ * @param {unknown} value
24233
+ * @param {string} [reason='is invalid']
24234
+ */
24235
+ (name, value, reason = "is invalid") => {
24236
+ let inspected = inspect(value);
24237
+ if (inspected.length > 128) {
24238
+ inspected = `${inspected.slice(0, 128)}...`;
24239
+ }
24240
+ const type = name.includes(".") ? "property" : "argument";
24241
+ return `The ${type} '${name}' ${reason}. Received ${inspected}`;
24242
+ },
24243
+ TypeError
24244
+ // Note: extra classes have been shaken out.
24245
+ // , RangeError
24246
+ );
24247
+ captureLargerStackTrace = hideStackFrames(
24248
+ /**
24249
+ * @param {Error} error
24250
+ * @returns {Error}
24251
+ */
24252
+ // @ts-expect-error: fine
24253
+ function(error51) {
24254
+ const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
24255
+ if (stackTraceLimitIsWritable) {
24256
+ userStackTraceLimit = Error.stackTraceLimit;
24257
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
24258
+ }
24259
+ Error.captureStackTrace(error51);
24260
+ if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
24261
+ return error51;
24262
+ }
24263
+ );
24264
+ }
24265
+ });
24266
+
24267
+ // ../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/package-json-reader.js
24268
+ import fs2 from "node:fs";
24269
+ import path2 from "node:path";
24270
+ import { fileURLToPath } from "node:url";
24271
+ function read(jsonPath, { base, specifier }) {
24272
+ const existing = cache.get(jsonPath);
24273
+ if (existing) {
24274
+ return existing;
24275
+ }
24276
+ let string4;
24277
+ try {
24278
+ string4 = fs2.readFileSync(path2.toNamespacedPath(jsonPath), "utf8");
24279
+ } catch (error51) {
24280
+ const exception = (
24281
+ /** @type {ErrnoException} */
24282
+ error51
24283
+ );
24284
+ if (exception.code !== "ENOENT") {
24285
+ throw exception;
24286
+ }
24287
+ }
24288
+ const result = {
24289
+ exists: false,
24290
+ pjsonPath: jsonPath,
24291
+ main: void 0,
24292
+ name: void 0,
24293
+ type: "none",
24294
+ // Ignore unknown types for forwards compatibility
24295
+ exports: void 0,
24296
+ imports: void 0
24297
+ };
24298
+ if (string4 !== void 0) {
24299
+ let parsed;
24300
+ try {
24301
+ parsed = JSON.parse(string4);
24302
+ } catch (error_) {
24303
+ const cause = (
24304
+ /** @type {ErrnoException} */
24305
+ error_
24306
+ );
24307
+ const error51 = new ERR_INVALID_PACKAGE_CONFIG(
24308
+ jsonPath,
24309
+ (base ? `"${specifier}" from ` : "") + fileURLToPath(base || specifier),
24310
+ cause.message
24311
+ );
24312
+ error51.cause = cause;
24313
+ throw error51;
24314
+ }
24315
+ result.exists = true;
24316
+ if (hasOwnProperty.call(parsed, "name") && typeof parsed.name === "string") {
24317
+ result.name = parsed.name;
24318
+ }
24319
+ if (hasOwnProperty.call(parsed, "main") && typeof parsed.main === "string") {
24320
+ result.main = parsed.main;
24321
+ }
24322
+ if (hasOwnProperty.call(parsed, "exports")) {
24323
+ result.exports = parsed.exports;
24324
+ }
24325
+ if (hasOwnProperty.call(parsed, "imports")) {
24326
+ result.imports = parsed.imports;
24327
+ }
24328
+ if (hasOwnProperty.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) {
24329
+ result.type = parsed.type;
24330
+ }
24331
+ }
24332
+ cache.set(jsonPath, result);
24333
+ return result;
24334
+ }
24335
+ function getPackageScopeConfig(resolved) {
24336
+ let packageJSONUrl = new URL("package.json", resolved);
24337
+ while (true) {
24338
+ const packageJSONPath2 = packageJSONUrl.pathname;
24339
+ if (packageJSONPath2.endsWith("node_modules/package.json")) {
24340
+ break;
24341
+ }
24342
+ const packageConfig = read(fileURLToPath(packageJSONUrl), {
24343
+ specifier: resolved
24344
+ });
24345
+ if (packageConfig.exists) {
24346
+ return packageConfig;
24347
+ }
24348
+ const lastPackageJSONUrl = packageJSONUrl;
24349
+ packageJSONUrl = new URL("../package.json", packageJSONUrl);
24350
+ if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) {
24351
+ break;
24352
+ }
24353
+ }
24354
+ const packageJSONPath = fileURLToPath(packageJSONUrl);
24355
+ return {
24356
+ pjsonPath: packageJSONPath,
24357
+ exists: false,
24358
+ type: "none"
24359
+ };
24360
+ }
24361
+ function getPackageType(url2) {
24362
+ return getPackageScopeConfig(url2).type;
24363
+ }
24364
+ var hasOwnProperty, ERR_INVALID_PACKAGE_CONFIG, cache;
24365
+ var init_package_json_reader = __esm({
24366
+ "../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/package-json-reader.js"() {
24367
+ init_errors3();
24368
+ hasOwnProperty = {}.hasOwnProperty;
24369
+ ({ ERR_INVALID_PACKAGE_CONFIG } = codes);
24370
+ cache = /* @__PURE__ */ new Map();
24371
+ }
24372
+ });
24373
+
24374
+ // ../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/get-format.js
24375
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
24376
+ function mimeToFormat(mime) {
24377
+ if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime))
24378
+ return "module";
24379
+ if (mime === "application/json") return "json";
24380
+ return null;
24381
+ }
24382
+ function getDataProtocolModuleFormat(parsed) {
24383
+ const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(
24384
+ parsed.pathname
24385
+ ) || [null, null, null];
24386
+ return mimeToFormat(mime);
24387
+ }
24388
+ function extname(url2) {
24389
+ const pathname = url2.pathname;
24390
+ let index = pathname.length;
24391
+ while (index--) {
24392
+ const code2 = pathname.codePointAt(index);
24393
+ if (code2 === 47) {
24394
+ return "";
24395
+ }
24396
+ if (code2 === 46) {
24397
+ return pathname.codePointAt(index - 1) === 47 ? "" : pathname.slice(index);
24398
+ }
24399
+ }
24400
+ return "";
24401
+ }
24402
+ function getFileProtocolModuleFormat(url2, _context, ignoreErrors) {
24403
+ const value = extname(url2);
24404
+ if (value === ".js") {
24405
+ const packageType = getPackageType(url2);
24406
+ if (packageType !== "none") {
24407
+ return packageType;
24408
+ }
24409
+ return "commonjs";
24410
+ }
24411
+ if (value === "") {
24412
+ const packageType = getPackageType(url2);
24413
+ if (packageType === "none" || packageType === "commonjs") {
24414
+ return "commonjs";
24415
+ }
24416
+ return "module";
24417
+ }
24418
+ const format2 = extensionFormatMap[value];
24419
+ if (format2) return format2;
24420
+ if (ignoreErrors) {
24421
+ return void 0;
24422
+ }
24423
+ const filepath = fileURLToPath2(url2);
24424
+ throw new ERR_UNKNOWN_FILE_EXTENSION(value, filepath);
24425
+ }
24426
+ function getHttpProtocolModuleFormat() {
24427
+ }
24428
+ function defaultGetFormatWithoutErrors(url2, context) {
24429
+ const protocol = url2.protocol;
24430
+ if (!hasOwnProperty2.call(protocolHandlers, protocol)) {
24431
+ return null;
24432
+ }
24433
+ return protocolHandlers[protocol](url2, context, true) || null;
24434
+ }
24435
+ var ERR_UNKNOWN_FILE_EXTENSION, hasOwnProperty2, extensionFormatMap, protocolHandlers;
24436
+ var init_get_format = __esm({
24437
+ "../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/get-format.js"() {
24438
+ init_package_json_reader();
24439
+ init_errors3();
24440
+ ({ ERR_UNKNOWN_FILE_EXTENSION } = codes);
24441
+ hasOwnProperty2 = {}.hasOwnProperty;
24442
+ extensionFormatMap = {
24443
+ // @ts-expect-error: hush.
24444
+ __proto__: null,
24445
+ ".cjs": "commonjs",
24446
+ ".js": "module",
24447
+ ".json": "json",
24448
+ ".mjs": "module"
24449
+ };
24450
+ protocolHandlers = {
24451
+ // @ts-expect-error: hush.
24452
+ __proto__: null,
24453
+ "data:": getDataProtocolModuleFormat,
24454
+ "file:": getFileProtocolModuleFormat,
24455
+ "http:": getHttpProtocolModuleFormat,
24456
+ "https:": getHttpProtocolModuleFormat,
24457
+ "node:"() {
24458
+ return "builtin";
24459
+ }
24460
+ };
24461
+ }
24462
+ });
24463
+
24464
+ // ../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/utils.js
24465
+ function getDefaultConditions() {
24466
+ return DEFAULT_CONDITIONS;
24467
+ }
24468
+ function getDefaultConditionsSet() {
24469
+ return DEFAULT_CONDITIONS_SET;
24470
+ }
24471
+ function getConditionsSet(conditions) {
24472
+ if (conditions !== void 0 && conditions !== getDefaultConditions()) {
24473
+ if (!Array.isArray(conditions)) {
24474
+ throw new ERR_INVALID_ARG_VALUE(
24475
+ "conditions",
24476
+ conditions,
24477
+ "expected an array"
24478
+ );
24479
+ }
24480
+ return new Set(conditions);
24481
+ }
24482
+ return getDefaultConditionsSet();
24483
+ }
24484
+ var ERR_INVALID_ARG_VALUE, DEFAULT_CONDITIONS, DEFAULT_CONDITIONS_SET;
24485
+ var init_utils = __esm({
24486
+ "../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/utils.js"() {
24487
+ init_errors3();
24488
+ ({ ERR_INVALID_ARG_VALUE } = codes);
24489
+ DEFAULT_CONDITIONS = Object.freeze(["node", "import"]);
24490
+ DEFAULT_CONDITIONS_SET = new Set(DEFAULT_CONDITIONS);
24491
+ }
24492
+ });
24493
+
24494
+ // ../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/resolve.js
24495
+ import assert3 from "node:assert";
24496
+ import { statSync, realpathSync } from "node:fs";
24497
+ import process4 from "node:process";
24498
+ import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL4 } from "node:url";
24499
+ import path3 from "node:path";
24500
+ import { builtinModules } from "node:module";
24501
+ function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
24502
+ if (process4.noDeprecation) {
24503
+ return;
24504
+ }
24505
+ const pjsonPath = fileURLToPath3(packageJsonUrl);
24506
+ const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
24507
+ process4.emitWarning(
24508
+ `Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target}" for module request "${request}" ${request === match ? "" : `matched to "${match}" `}in the "${internal ? "imports" : "exports"}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath3(base)}` : ""}.`,
24509
+ "DeprecationWarning",
24510
+ "DEP0166"
24511
+ );
24512
+ }
24513
+ function emitLegacyIndexDeprecation(url2, packageJsonUrl, base, main) {
24514
+ if (process4.noDeprecation) {
24515
+ return;
24516
+ }
24517
+ const format2 = defaultGetFormatWithoutErrors(url2, { parentURL: base.href });
24518
+ if (format2 !== "module") return;
24519
+ const urlPath = fileURLToPath3(url2.href);
24520
+ const packagePath = fileURLToPath3(new URL(".", packageJsonUrl));
24521
+ const basePath = fileURLToPath3(base);
24522
+ if (!main) {
24523
+ process4.emitWarning(
24524
+ `No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(
24525
+ packagePath.length
24526
+ )}", imported from ${basePath}.
24527
+ Default "index" lookups for the main are deprecated for ES modules.`,
24528
+ "DeprecationWarning",
24529
+ "DEP0151"
24530
+ );
24531
+ } else if (path3.resolve(packagePath, main) !== urlPath) {
24532
+ process4.emitWarning(
24533
+ `Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(
24534
+ packagePath.length
24535
+ )}", imported from ${basePath}.
24536
+ Automatic extension resolution of the "main" field is deprecated for ES modules.`,
24537
+ "DeprecationWarning",
24538
+ "DEP0151"
24539
+ );
24540
+ }
24541
+ }
24542
+ function tryStatSync(path4) {
24543
+ try {
24544
+ return statSync(path4);
24545
+ } catch {
24546
+ }
24547
+ }
24548
+ function fileExists(url2) {
24549
+ const stats = statSync(url2, { throwIfNoEntry: false });
24550
+ const isFile = stats ? stats.isFile() : void 0;
24551
+ return isFile === null || isFile === void 0 ? false : isFile;
24552
+ }
24553
+ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
24554
+ let guess;
24555
+ if (packageConfig.main !== void 0) {
24556
+ guess = new URL(packageConfig.main, packageJsonUrl);
24557
+ if (fileExists(guess)) return guess;
24558
+ const tries2 = [
24559
+ `./${packageConfig.main}.js`,
24560
+ `./${packageConfig.main}.json`,
24561
+ `./${packageConfig.main}.node`,
24562
+ `./${packageConfig.main}/index.js`,
24563
+ `./${packageConfig.main}/index.json`,
24564
+ `./${packageConfig.main}/index.node`
24565
+ ];
24566
+ let i2 = -1;
24567
+ while (++i2 < tries2.length) {
24568
+ guess = new URL(tries2[i2], packageJsonUrl);
24569
+ if (fileExists(guess)) break;
24570
+ guess = void 0;
24571
+ }
24572
+ if (guess) {
24573
+ emitLegacyIndexDeprecation(
24574
+ guess,
24575
+ packageJsonUrl,
24576
+ base,
24577
+ packageConfig.main
24578
+ );
24579
+ return guess;
24580
+ }
24581
+ }
24582
+ const tries = ["./index.js", "./index.json", "./index.node"];
24583
+ let i = -1;
24584
+ while (++i < tries.length) {
24585
+ guess = new URL(tries[i], packageJsonUrl);
24586
+ if (fileExists(guess)) break;
24587
+ guess = void 0;
24588
+ }
24589
+ if (guess) {
24590
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
24591
+ return guess;
24592
+ }
24593
+ throw new ERR_MODULE_NOT_FOUND(
24594
+ fileURLToPath3(new URL(".", packageJsonUrl)),
24595
+ fileURLToPath3(base)
24596
+ );
24597
+ }
24598
+ function finalizeResolution(resolved, base, preserveSymlinks) {
24599
+ if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) {
24600
+ throw new ERR_INVALID_MODULE_SPECIFIER(
24601
+ resolved.pathname,
24602
+ 'must not include encoded "/" or "\\" characters',
24603
+ fileURLToPath3(base)
24604
+ );
24605
+ }
24606
+ let filePath;
24607
+ try {
24608
+ filePath = fileURLToPath3(resolved);
24609
+ } catch (error51) {
24610
+ const cause = (
24611
+ /** @type {ErrnoException} */
24612
+ error51
24613
+ );
24614
+ Object.defineProperty(cause, "input", { value: String(resolved) });
24615
+ Object.defineProperty(cause, "module", { value: String(base) });
24616
+ throw cause;
24617
+ }
24618
+ const stats = tryStatSync(
24619
+ filePath.endsWith("/") ? filePath.slice(-1) : filePath
24620
+ );
24621
+ if (stats && stats.isDirectory()) {
24622
+ const error51 = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, fileURLToPath3(base));
24623
+ error51.url = String(resolved);
24624
+ throw error51;
24625
+ }
24626
+ if (!stats || !stats.isFile()) {
24627
+ const error51 = new ERR_MODULE_NOT_FOUND(
24628
+ filePath || resolved.pathname,
24629
+ base && fileURLToPath3(base),
24630
+ true
24631
+ );
24632
+ error51.url = String(resolved);
24633
+ throw error51;
24634
+ }
24635
+ if (!preserveSymlinks) {
24636
+ const real = realpathSync(filePath);
24637
+ const { search, hash: hash2 } = resolved;
24638
+ resolved = pathToFileURL4(real + (filePath.endsWith(path3.sep) ? "/" : ""));
24639
+ resolved.search = search;
24640
+ resolved.hash = hash2;
24641
+ }
24642
+ return resolved;
24643
+ }
24644
+ function importNotDefined(specifier, packageJsonUrl, base) {
24645
+ return new ERR_PACKAGE_IMPORT_NOT_DEFINED(
24646
+ specifier,
24647
+ packageJsonUrl && fileURLToPath3(new URL(".", packageJsonUrl)),
24648
+ fileURLToPath3(base)
24649
+ );
24650
+ }
24651
+ function exportsNotFound(subpath, packageJsonUrl, base) {
24652
+ return new ERR_PACKAGE_PATH_NOT_EXPORTED(
24653
+ fileURLToPath3(new URL(".", packageJsonUrl)),
24654
+ subpath,
24655
+ base && fileURLToPath3(base)
24656
+ );
24657
+ }
24658
+ function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
24659
+ const reason = `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath3(packageJsonUrl)}`;
24660
+ throw new ERR_INVALID_MODULE_SPECIFIER(
24661
+ request,
24662
+ reason,
24663
+ base && fileURLToPath3(base)
24664
+ );
24665
+ }
24666
+ function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
24667
+ target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
24668
+ return new ERR_INVALID_PACKAGE_TARGET(
24669
+ fileURLToPath3(new URL(".", packageJsonUrl)),
24670
+ subpath,
24671
+ target,
24672
+ internal,
24673
+ base && fileURLToPath3(base)
24674
+ );
24675
+ }
24676
+ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
24677
+ if (subpath !== "" && !pattern && target[target.length - 1] !== "/")
24678
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
24679
+ if (!target.startsWith("./")) {
24680
+ if (internal && !target.startsWith("../") && !target.startsWith("/")) {
24681
+ let isURL2 = false;
24682
+ try {
24683
+ new URL(target);
24684
+ isURL2 = true;
24685
+ } catch {
24686
+ }
24687
+ if (!isURL2) {
24688
+ const exportTarget = pattern ? RegExpPrototypeSymbolReplace.call(
24689
+ patternRegEx,
24690
+ target,
24691
+ () => subpath
24692
+ ) : target + subpath;
24693
+ return packageResolve(exportTarget, packageJsonUrl, conditions);
24694
+ }
24695
+ }
24696
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
24697
+ }
24698
+ if (invalidSegmentRegEx.exec(target.slice(2)) !== null) {
24699
+ if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
24700
+ if (!isPathMap) {
24701
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
24702
+ const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
24703
+ patternRegEx,
24704
+ target,
24705
+ () => subpath
24706
+ ) : target;
24707
+ emitInvalidSegmentDeprecation(
24708
+ resolvedTarget,
24709
+ request,
24710
+ match,
24711
+ packageJsonUrl,
24712
+ internal,
24713
+ base,
24714
+ true
24715
+ );
24716
+ }
24717
+ } else {
24718
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
24719
+ }
24720
+ }
24721
+ const resolved = new URL(target, packageJsonUrl);
24722
+ const resolvedPath = resolved.pathname;
24723
+ const packagePath = new URL(".", packageJsonUrl).pathname;
24724
+ if (!resolvedPath.startsWith(packagePath))
24725
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
24726
+ if (subpath === "") return resolved;
24727
+ if (invalidSegmentRegEx.exec(subpath) !== null) {
24728
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
24729
+ if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
24730
+ if (!isPathMap) {
24731
+ const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
24732
+ patternRegEx,
24733
+ target,
24734
+ () => subpath
24735
+ ) : target;
24736
+ emitInvalidSegmentDeprecation(
24737
+ resolvedTarget,
24738
+ request,
24739
+ match,
24740
+ packageJsonUrl,
24741
+ internal,
24742
+ base,
24743
+ false
24744
+ );
24745
+ }
24746
+ } else {
24747
+ throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
24748
+ }
24749
+ }
24750
+ if (pattern) {
24751
+ return new URL(
24752
+ RegExpPrototypeSymbolReplace.call(
24753
+ patternRegEx,
24754
+ resolved.href,
24755
+ () => subpath
24756
+ )
24757
+ );
24758
+ }
24759
+ return new URL(subpath, resolved);
24760
+ }
24761
+ function isArrayIndex(key) {
24762
+ const keyNumber = Number(key);
24763
+ if (`${keyNumber}` !== key) return false;
24764
+ return keyNumber >= 0 && keyNumber < 4294967295;
24765
+ }
24766
+ function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
24767
+ if (typeof target === "string") {
24768
+ return resolvePackageTargetString(
24769
+ target,
24770
+ subpath,
24771
+ packageSubpath,
24772
+ packageJsonUrl,
24773
+ base,
24774
+ pattern,
24775
+ internal,
24776
+ isPathMap,
24777
+ conditions
24778
+ );
24779
+ }
24780
+ if (Array.isArray(target)) {
24781
+ const targetList = target;
24782
+ if (targetList.length === 0) return null;
24783
+ let lastException;
24784
+ let i = -1;
24785
+ while (++i < targetList.length) {
24786
+ const targetItem = targetList[i];
24787
+ let resolveResult;
24788
+ try {
24789
+ resolveResult = resolvePackageTarget(
24790
+ packageJsonUrl,
24791
+ targetItem,
24792
+ subpath,
24793
+ packageSubpath,
24794
+ base,
24795
+ pattern,
24796
+ internal,
24797
+ isPathMap,
24798
+ conditions
24799
+ );
24800
+ } catch (error51) {
24801
+ const exception = (
24802
+ /** @type {ErrnoException} */
24803
+ error51
24804
+ );
24805
+ lastException = exception;
24806
+ if (exception.code === "ERR_INVALID_PACKAGE_TARGET") continue;
24807
+ throw error51;
24808
+ }
24809
+ if (resolveResult === void 0) continue;
24810
+ if (resolveResult === null) {
24811
+ lastException = null;
24812
+ continue;
24813
+ }
24814
+ return resolveResult;
24815
+ }
24816
+ if (lastException === void 0 || lastException === null) {
24817
+ return null;
24818
+ }
24819
+ throw lastException;
24820
+ }
24821
+ if (typeof target === "object" && target !== null) {
24822
+ const keys = Object.getOwnPropertyNames(target);
24823
+ let i = -1;
24824
+ while (++i < keys.length) {
24825
+ const key = keys[i];
24826
+ if (isArrayIndex(key)) {
24827
+ throw new ERR_INVALID_PACKAGE_CONFIG2(
24828
+ fileURLToPath3(packageJsonUrl),
24829
+ base,
24830
+ '"exports" cannot contain numeric property keys.'
24831
+ );
24832
+ }
24833
+ }
24834
+ i = -1;
24835
+ while (++i < keys.length) {
24836
+ const key = keys[i];
24837
+ if (key === "default" || conditions && conditions.has(key)) {
24838
+ const conditionalTarget = (
24839
+ /** @type {unknown} */
24840
+ target[key]
24841
+ );
24842
+ const resolveResult = resolvePackageTarget(
24843
+ packageJsonUrl,
24844
+ conditionalTarget,
24845
+ subpath,
24846
+ packageSubpath,
24847
+ base,
24848
+ pattern,
24849
+ internal,
24850
+ isPathMap,
24851
+ conditions
24852
+ );
24853
+ if (resolveResult === void 0) continue;
24854
+ return resolveResult;
24855
+ }
24856
+ }
24857
+ return null;
24858
+ }
24859
+ if (target === null) {
24860
+ return null;
24861
+ }
24862
+ throw invalidPackageTarget(
24863
+ packageSubpath,
24864
+ target,
24865
+ packageJsonUrl,
24866
+ internal,
24867
+ base
24868
+ );
24869
+ }
24870
+ function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
24871
+ if (typeof exports === "string" || Array.isArray(exports)) return true;
24872
+ if (typeof exports !== "object" || exports === null) return false;
24873
+ const keys = Object.getOwnPropertyNames(exports);
24874
+ let isConditionalSugar = false;
24875
+ let i = 0;
24876
+ let keyIndex = -1;
24877
+ while (++keyIndex < keys.length) {
24878
+ const key = keys[keyIndex];
24879
+ const currentIsConditionalSugar = key === "" || key[0] !== ".";
24880
+ if (i++ === 0) {
24881
+ isConditionalSugar = currentIsConditionalSugar;
24882
+ } else if (isConditionalSugar !== currentIsConditionalSugar) {
24883
+ throw new ERR_INVALID_PACKAGE_CONFIG2(
24884
+ fileURLToPath3(packageJsonUrl),
24885
+ base,
24886
+ `"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`
24887
+ );
24888
+ }
24889
+ }
24890
+ return isConditionalSugar;
24891
+ }
24892
+ function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
24893
+ if (process4.noDeprecation) {
24894
+ return;
24895
+ }
24896
+ const pjsonPath = fileURLToPath3(pjsonUrl);
24897
+ if (emittedPackageWarnings.has(pjsonPath + "|" + match)) return;
24898
+ emittedPackageWarnings.add(pjsonPath + "|" + match);
24899
+ process4.emitWarning(
24900
+ `Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath3(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`,
24901
+ "DeprecationWarning",
24902
+ "DEP0155"
24903
+ );
24904
+ }
24905
+ function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
24906
+ let exports = packageConfig.exports;
24907
+ if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) {
24908
+ exports = { ".": exports };
24909
+ }
24910
+ if (own2.call(exports, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
24911
+ const target = exports[packageSubpath];
24912
+ const resolveResult = resolvePackageTarget(
24913
+ packageJsonUrl,
24914
+ target,
24915
+ "",
24916
+ packageSubpath,
24917
+ base,
24918
+ false,
24919
+ false,
24920
+ false,
24921
+ conditions
24922
+ );
24923
+ if (resolveResult === null || resolveResult === void 0) {
24924
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
24925
+ }
24926
+ return resolveResult;
24927
+ }
24928
+ let bestMatch = "";
24929
+ let bestMatchSubpath = "";
24930
+ const keys = Object.getOwnPropertyNames(exports);
24931
+ let i = -1;
24932
+ while (++i < keys.length) {
24933
+ const key = keys[i];
24934
+ const patternIndex = key.indexOf("*");
24935
+ if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
24936
+ if (packageSubpath.endsWith("/")) {
24937
+ emitTrailingSlashPatternDeprecation(
24938
+ packageSubpath,
24939
+ packageJsonUrl,
24940
+ base
24941
+ );
24942
+ }
24943
+ const patternTrailer = key.slice(patternIndex + 1);
24944
+ if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
24945
+ bestMatch = key;
24946
+ bestMatchSubpath = packageSubpath.slice(
24947
+ patternIndex,
24948
+ packageSubpath.length - patternTrailer.length
24949
+ );
24950
+ }
24951
+ }
24952
+ }
24953
+ if (bestMatch) {
24954
+ const target = (
24955
+ /** @type {unknown} */
24956
+ exports[bestMatch]
24957
+ );
24958
+ const resolveResult = resolvePackageTarget(
24959
+ packageJsonUrl,
24960
+ target,
24961
+ bestMatchSubpath,
24962
+ bestMatch,
24963
+ base,
24964
+ true,
24965
+ false,
24966
+ packageSubpath.endsWith("/"),
24967
+ conditions
24968
+ );
24969
+ if (resolveResult === null || resolveResult === void 0) {
24970
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
24971
+ }
24972
+ return resolveResult;
24973
+ }
24974
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
24975
+ }
24976
+ function patternKeyCompare(a, b) {
24977
+ const aPatternIndex = a.indexOf("*");
24978
+ const bPatternIndex = b.indexOf("*");
24979
+ const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
24980
+ const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
24981
+ if (baseLengthA > baseLengthB) return -1;
24982
+ if (baseLengthB > baseLengthA) return 1;
24983
+ if (aPatternIndex === -1) return 1;
24984
+ if (bPatternIndex === -1) return -1;
24985
+ if (a.length > b.length) return -1;
24986
+ if (b.length > a.length) return 1;
24987
+ return 0;
24988
+ }
24989
+ function packageImportsResolve(name, base, conditions) {
24990
+ if (name === "#" || name.startsWith("#/") || name.endsWith("/")) {
24991
+ const reason = "is not a valid internal imports specifier name";
24992
+ throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, fileURLToPath3(base));
24993
+ }
24994
+ let packageJsonUrl;
24995
+ const packageConfig = getPackageScopeConfig(base);
24996
+ if (packageConfig.exists) {
24997
+ packageJsonUrl = pathToFileURL4(packageConfig.pjsonPath);
24998
+ const imports = packageConfig.imports;
24999
+ if (imports) {
25000
+ if (own2.call(imports, name) && !name.includes("*")) {
25001
+ const resolveResult = resolvePackageTarget(
25002
+ packageJsonUrl,
25003
+ imports[name],
25004
+ "",
25005
+ name,
25006
+ base,
25007
+ false,
25008
+ true,
25009
+ false,
25010
+ conditions
25011
+ );
25012
+ if (resolveResult !== null && resolveResult !== void 0) {
25013
+ return resolveResult;
25014
+ }
25015
+ } else {
25016
+ let bestMatch = "";
25017
+ let bestMatchSubpath = "";
25018
+ const keys = Object.getOwnPropertyNames(imports);
25019
+ let i = -1;
25020
+ while (++i < keys.length) {
25021
+ const key = keys[i];
25022
+ const patternIndex = key.indexOf("*");
25023
+ if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
25024
+ const patternTrailer = key.slice(patternIndex + 1);
25025
+ if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
25026
+ bestMatch = key;
25027
+ bestMatchSubpath = name.slice(
25028
+ patternIndex,
25029
+ name.length - patternTrailer.length
25030
+ );
25031
+ }
25032
+ }
25033
+ }
25034
+ if (bestMatch) {
25035
+ const target = imports[bestMatch];
25036
+ const resolveResult = resolvePackageTarget(
25037
+ packageJsonUrl,
25038
+ target,
25039
+ bestMatchSubpath,
25040
+ bestMatch,
25041
+ base,
25042
+ true,
25043
+ true,
25044
+ false,
25045
+ conditions
25046
+ );
25047
+ if (resolveResult !== null && resolveResult !== void 0) {
25048
+ return resolveResult;
25049
+ }
25050
+ }
25051
+ }
25052
+ }
25053
+ }
25054
+ throw importNotDefined(name, packageJsonUrl, base);
25055
+ }
25056
+ function parsePackageName(specifier, base) {
25057
+ let separatorIndex = specifier.indexOf("/");
25058
+ let validPackageName = true;
25059
+ let isScoped = false;
25060
+ if (specifier[0] === "@") {
25061
+ isScoped = true;
25062
+ if (separatorIndex === -1 || specifier.length === 0) {
25063
+ validPackageName = false;
25064
+ } else {
25065
+ separatorIndex = specifier.indexOf("/", separatorIndex + 1);
25066
+ }
25067
+ }
25068
+ const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
25069
+ if (invalidPackageNameRegEx.exec(packageName) !== null) {
25070
+ validPackageName = false;
25071
+ }
25072
+ if (!validPackageName) {
25073
+ throw new ERR_INVALID_MODULE_SPECIFIER(
25074
+ specifier,
25075
+ "is not a valid package name",
25076
+ fileURLToPath3(base)
25077
+ );
25078
+ }
25079
+ const packageSubpath = "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex));
25080
+ return { packageName, packageSubpath, isScoped };
25081
+ }
25082
+ function packageResolve(specifier, base, conditions) {
25083
+ if (builtinModules.includes(specifier)) {
25084
+ return new URL("node:" + specifier);
25085
+ }
25086
+ const { packageName, packageSubpath, isScoped } = parsePackageName(
25087
+ specifier,
25088
+ base
25089
+ );
25090
+ const packageConfig = getPackageScopeConfig(base);
25091
+ if (packageConfig.exists) {
25092
+ const packageJsonUrl2 = pathToFileURL4(packageConfig.pjsonPath);
25093
+ if (packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) {
25094
+ return packageExportsResolve(
25095
+ packageJsonUrl2,
25096
+ packageSubpath,
25097
+ packageConfig,
25098
+ base,
25099
+ conditions
25100
+ );
25101
+ }
25102
+ }
25103
+ let packageJsonUrl = new URL(
25104
+ "./node_modules/" + packageName + "/package.json",
25105
+ base
25106
+ );
25107
+ let packageJsonPath = fileURLToPath3(packageJsonUrl);
25108
+ let lastPath;
25109
+ do {
25110
+ const stat = tryStatSync(packageJsonPath.slice(0, -13));
25111
+ if (!stat || !stat.isDirectory()) {
25112
+ lastPath = packageJsonPath;
25113
+ packageJsonUrl = new URL(
25114
+ (isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json",
25115
+ packageJsonUrl
25116
+ );
25117
+ packageJsonPath = fileURLToPath3(packageJsonUrl);
25118
+ continue;
25119
+ }
25120
+ const packageConfig2 = read(packageJsonPath, { base, specifier });
25121
+ if (packageConfig2.exports !== void 0 && packageConfig2.exports !== null) {
25122
+ return packageExportsResolve(
25123
+ packageJsonUrl,
25124
+ packageSubpath,
25125
+ packageConfig2,
25126
+ base,
25127
+ conditions
25128
+ );
25129
+ }
25130
+ if (packageSubpath === ".") {
25131
+ return legacyMainResolve(packageJsonUrl, packageConfig2, base);
25132
+ }
25133
+ return new URL(packageSubpath, packageJsonUrl);
25134
+ } while (packageJsonPath.length !== lastPath.length);
25135
+ throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath3(base), false);
25136
+ }
25137
+ function isRelativeSpecifier(specifier) {
25138
+ if (specifier[0] === ".") {
25139
+ if (specifier.length === 1 || specifier[1] === "/") return true;
25140
+ if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) {
25141
+ return true;
25142
+ }
25143
+ }
25144
+ return false;
25145
+ }
25146
+ function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
25147
+ if (specifier === "") return false;
25148
+ if (specifier[0] === "/") return true;
25149
+ return isRelativeSpecifier(specifier);
25150
+ }
25151
+ function moduleResolve(specifier, base, conditions, preserveSymlinks) {
25152
+ if (conditions === void 0) {
25153
+ conditions = getConditionsSet();
25154
+ }
25155
+ const protocol = base.protocol;
25156
+ const isData = protocol === "data:";
25157
+ const isRemote = isData || protocol === "http:" || protocol === "https:";
25158
+ let resolved;
25159
+ if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
25160
+ try {
25161
+ resolved = new URL(specifier, base);
25162
+ } catch (error_) {
25163
+ const error51 = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
25164
+ error51.cause = error_;
25165
+ throw error51;
25166
+ }
25167
+ } else if (protocol === "file:" && specifier[0] === "#") {
25168
+ resolved = packageImportsResolve(specifier, base, conditions);
25169
+ } else {
25170
+ try {
25171
+ resolved = new URL(specifier);
25172
+ } catch (error_) {
25173
+ if (isRemote && !builtinModules.includes(specifier)) {
25174
+ const error51 = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
25175
+ error51.cause = error_;
25176
+ throw error51;
25177
+ }
25178
+ resolved = packageResolve(specifier, base, conditions);
25179
+ }
25180
+ }
25181
+ assert3.ok(resolved !== void 0, "expected to be defined");
25182
+ if (resolved.protocol !== "file:") {
25183
+ return resolved;
25184
+ }
25185
+ return finalizeResolution(resolved, base, preserveSymlinks);
25186
+ }
25187
+ function checkIfDisallowedImport(specifier, parsed, parsedParentURL) {
25188
+ if (parsedParentURL) {
25189
+ const parentProtocol = parsedParentURL.protocol;
25190
+ if (parentProtocol === "http:" || parentProtocol === "https:") {
25191
+ if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
25192
+ const parsedProtocol = parsed?.protocol;
25193
+ if (parsedProtocol && parsedProtocol !== "https:" && parsedProtocol !== "http:") {
25194
+ throw new ERR_NETWORK_IMPORT_DISALLOWED(
25195
+ specifier,
25196
+ parsedParentURL,
25197
+ "remote imports cannot import from a local location."
25198
+ );
25199
+ }
25200
+ return { url: parsed?.href || "" };
25201
+ }
25202
+ if (builtinModules.includes(specifier)) {
25203
+ throw new ERR_NETWORK_IMPORT_DISALLOWED(
25204
+ specifier,
25205
+ parsedParentURL,
25206
+ "remote imports cannot import from a local location."
25207
+ );
25208
+ }
25209
+ throw new ERR_NETWORK_IMPORT_DISALLOWED(
25210
+ specifier,
25211
+ parsedParentURL,
25212
+ "only relative and absolute specifiers are supported."
25213
+ );
25214
+ }
25215
+ }
25216
+ }
25217
+ function isURL(self) {
25218
+ return Boolean(
25219
+ self && typeof self === "object" && "href" in self && typeof self.href === "string" && "protocol" in self && typeof self.protocol === "string" && self.href && self.protocol
25220
+ );
25221
+ }
25222
+ function throwIfInvalidParentURL(parentURL) {
25223
+ if (parentURL === void 0) {
25224
+ return;
25225
+ }
25226
+ if (typeof parentURL !== "string" && !isURL(parentURL)) {
25227
+ throw new codes.ERR_INVALID_ARG_TYPE(
25228
+ "parentURL",
25229
+ ["string", "URL"],
25230
+ parentURL
25231
+ );
25232
+ }
25233
+ }
25234
+ function defaultResolve(specifier, context = {}) {
25235
+ const { parentURL } = context;
25236
+ assert3.ok(parentURL !== void 0, "expected `parentURL` to be defined");
25237
+ throwIfInvalidParentURL(parentURL);
25238
+ let parsedParentURL;
25239
+ if (parentURL) {
25240
+ try {
25241
+ parsedParentURL = new URL(parentURL);
25242
+ } catch {
25243
+ }
25244
+ }
25245
+ let parsed;
25246
+ let protocol;
25247
+ try {
25248
+ parsed = shouldBeTreatedAsRelativeOrAbsolutePath(specifier) ? new URL(specifier, parsedParentURL) : new URL(specifier);
25249
+ protocol = parsed.protocol;
25250
+ if (protocol === "data:") {
25251
+ return { url: parsed.href, format: null };
25252
+ }
25253
+ } catch {
25254
+ }
25255
+ const maybeReturn = checkIfDisallowedImport(
25256
+ specifier,
25257
+ parsed,
25258
+ parsedParentURL
25259
+ );
25260
+ if (maybeReturn) return maybeReturn;
25261
+ if (protocol === void 0 && parsed) {
25262
+ protocol = parsed.protocol;
25263
+ }
25264
+ if (protocol === "node:") {
25265
+ return { url: specifier };
25266
+ }
25267
+ if (parsed && parsed.protocol === "node:") return { url: specifier };
25268
+ const conditions = getConditionsSet(context.conditions);
25269
+ const url2 = moduleResolve(specifier, new URL(parentURL), conditions, false);
25270
+ return {
25271
+ // Do NOT cast `url` to a string: that will work even when there are real
25272
+ // problems, silencing them
25273
+ url: url2.href,
25274
+ format: defaultGetFormatWithoutErrors(url2, { parentURL })
25275
+ };
25276
+ }
25277
+ var RegExpPrototypeSymbolReplace, ERR_NETWORK_IMPORT_DISALLOWED, ERR_INVALID_MODULE_SPECIFIER, ERR_INVALID_PACKAGE_CONFIG2, ERR_INVALID_PACKAGE_TARGET, ERR_MODULE_NOT_FOUND, ERR_PACKAGE_IMPORT_NOT_DEFINED, ERR_PACKAGE_PATH_NOT_EXPORTED, ERR_UNSUPPORTED_DIR_IMPORT, ERR_UNSUPPORTED_RESOLVE_REQUEST, own2, invalidSegmentRegEx, deprecatedInvalidSegmentRegEx, invalidPackageNameRegEx, patternRegEx, encodedSeparatorRegEx, emittedPackageWarnings, doubleSlashRegEx;
25278
+ var init_resolve = __esm({
25279
+ "../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/resolve.js"() {
25280
+ init_get_format();
25281
+ init_errors3();
25282
+ init_package_json_reader();
25283
+ init_utils();
25284
+ RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
25285
+ ({
25286
+ ERR_NETWORK_IMPORT_DISALLOWED,
25287
+ ERR_INVALID_MODULE_SPECIFIER,
25288
+ ERR_INVALID_PACKAGE_CONFIG: ERR_INVALID_PACKAGE_CONFIG2,
25289
+ ERR_INVALID_PACKAGE_TARGET,
25290
+ ERR_MODULE_NOT_FOUND,
25291
+ ERR_PACKAGE_IMPORT_NOT_DEFINED,
25292
+ ERR_PACKAGE_PATH_NOT_EXPORTED,
25293
+ ERR_UNSUPPORTED_DIR_IMPORT,
25294
+ ERR_UNSUPPORTED_RESOLVE_REQUEST
25295
+ } = codes);
25296
+ own2 = {}.hasOwnProperty;
25297
+ invalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i;
25298
+ deprecatedInvalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i;
25299
+ invalidPackageNameRegEx = /^\.|%|\\/;
25300
+ patternRegEx = /\*/g;
25301
+ encodedSeparatorRegEx = /%2f|%5c/i;
25302
+ emittedPackageWarnings = /* @__PURE__ */ new Set();
25303
+ doubleSlashRegEx = /[/\\]{2}/;
25304
+ }
25305
+ });
25306
+
25307
+ // ../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/index.js
25308
+ function resolve4(specifier, parent) {
25309
+ if (!parent) {
25310
+ throw new Error(
25311
+ "Please pass `parent`: `import-meta-resolve` cannot ponyfill that"
25312
+ );
25313
+ }
25314
+ try {
25315
+ return defaultResolve(specifier, { parentURL: parent }).url;
25316
+ } catch (error51) {
25317
+ const exception = (
25318
+ /** @type {ErrnoException} */
25319
+ error51
25320
+ );
25321
+ if ((exception.code === "ERR_UNSUPPORTED_DIR_IMPORT" || exception.code === "ERR_MODULE_NOT_FOUND") && typeof exception.url === "string") {
25322
+ return exception.url;
25323
+ }
25324
+ throw error51;
25325
+ }
25326
+ }
25327
+ var init_import_meta_resolve = __esm({
25328
+ "../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/index.js"() {
25329
+ init_resolve();
25330
+ }
25331
+ });
25332
+
25333
+ // src/commands/studio.ts
25334
+ var studio_exports = {};
25335
+ __export(studio_exports, {
25336
+ studioCommand: () => studioCommand
25337
+ });
25338
+ import { join as join9 } from "node:path";
25339
+ import { pathToFileURL as pathToFileURL5 } from "node:url";
25340
+ async function studioCommand(input, io) {
25341
+ const config2 = await resolveContentCommandConfig("studio", input);
25342
+ const port = parsePort(input.port);
25343
+ if (port === null) {
25344
+ io.stderr("studio: --port must be an integer between 0 and 65535.");
25345
+ return 2;
25346
+ }
25347
+ const minSectionWords = parseMinSectionWords2(input.minSectionWords);
25348
+ if (minSectionWords === null) {
25349
+ io.stderr("studio: --min-section-words must be a non-negative integer.");
25350
+ return 2;
25351
+ }
25352
+ await resolveContentFiles2(config2.globs, "studio", { cwd: config2.cwd });
25353
+ const seoConfig = await config2.loadSeo();
25354
+ let studioUrl;
25355
+ try {
25356
+ studioUrl = resolve4(
25357
+ "@contentbit/studio",
25358
+ pathToFileURL5(join9(config2.cwd ?? process.cwd(), "package.json")).href
25359
+ );
25360
+ } catch (error51) {
25361
+ if (!isMissingStudio(error51)) throw error51;
25362
+ }
25363
+ let startStudio;
25364
+ try {
25365
+ ;
25366
+ ({ startStudio } = await (studioUrl ? import(studioUrl) : import("@contentbit/studio")));
25367
+ } catch (error51) {
25368
+ if (!studioUrl && isMissingStudio(error51)) {
25369
+ throw new Error(
25370
+ "Studio is installed separately to keep the base CLI lightweight. Install it with your package manager, for example: pnpm add -D @contentbit/studio"
25371
+ );
25372
+ }
25373
+ throw error51;
25374
+ }
25375
+ const studioOptions = {
25376
+ globs: config2.globs,
25377
+ cwd: config2.cwd,
25378
+ registryPath: config2.registry,
25379
+ includeGenericBlocks: config2.includeGenericBlocks,
25380
+ host: input.host,
25381
+ ...port !== void 0 ? { port } : {},
25382
+ open: !input.noOpen,
25383
+ linkOptions: config2.resolveLinkOptions(),
25384
+ minSectionWords,
25385
+ seoConfig: seoConfig.config,
25386
+ seoConfigPath: seoConfig.path
25387
+ };
25388
+ const server = await startStudio(studioOptions);
25389
+ io.stdout(
25390
+ [
25391
+ section("contentbit studio"),
25392
+ ...formatRows([
25393
+ { label: "URL", value: server.url, tone: "info" },
25394
+ { label: "Stop", value: "Ctrl+C" }
25395
+ ])
25396
+ ].join("\n")
25397
+ );
25398
+ const close = () => {
25399
+ void server.close();
23673
25400
  };
23674
25401
  process.once("SIGINT", close);
23675
25402
  process.once("SIGTERM", close);
@@ -23695,11 +25422,38 @@ function parseMinSectionWords2(value) {
23695
25422
  var init_studio = __esm({
23696
25423
  "src/commands/studio.ts"() {
23697
25424
  "use strict";
25425
+ init_command_config();
25426
+ init_import_meta_resolve();
23698
25427
  init_cli_format();
23699
25428
  init_content_project();
23700
- init_link_options();
23701
- init_seo_config();
23702
- init_script_defaults();
25429
+ }
25430
+ });
25431
+
25432
+ // src/commands/snapshot.ts
25433
+ var snapshot_exports = {};
25434
+ __export(snapshot_exports, {
25435
+ snapshotCommand: () => snapshotCommand
25436
+ });
25437
+ async function snapshotCommand(input, io) {
25438
+ const config2 = await resolveContentCommandConfig("snapshot", input);
25439
+ const seoConfig = await config2.loadSeo();
25440
+ const snapshot = await inspectContentProject({
25441
+ positionals: config2.globs,
25442
+ cwd: config2.cwd,
25443
+ registry: config2.registry,
25444
+ includeGenericBlocks: config2.includeGenericBlocks,
25445
+ linkOptions: config2.resolveLinkOptions(),
25446
+ scan: { seoConfig: seoConfig.config, seoConfigPath: seoConfig.path },
25447
+ revision: input.revision
25448
+ });
25449
+ io.stdout(JSON.stringify(snapshot, null, 2));
25450
+ return 0;
25451
+ }
25452
+ var init_snapshot = __esm({
25453
+ "src/commands/snapshot.ts"() {
25454
+ "use strict";
25455
+ init_dist3();
25456
+ init_command_config();
23703
25457
  }
23704
25458
  });
23705
25459
 
@@ -23710,14 +25464,14 @@ __export(stats_exports, {
23710
25464
  });
23711
25465
  import { readFile as readFile6 } from "node:fs/promises";
23712
25466
  async function statsCommand(input, io) {
23713
- const defaults = await discoverContentCommandDefaults("stats", input.globs);
23714
- const all = input.noValidate ? await statsOnly(defaults.globs, defaults.cwd) : await statsWithValidation(
25467
+ const config2 = await resolveContentCommandConfig("stats", input);
25468
+ const all = input.noValidate ? await statsOnly(config2.globs, config2.cwd) : await statsWithValidation(
23715
25469
  {
23716
- registry: input.registry ?? defaults.registry,
23717
- noGenericBlocks: input.noGenericBlocks || defaults.noGenericBlocks,
23718
- cwd: defaults.cwd
25470
+ registry: config2.registry,
25471
+ includeGenericBlocks: config2.includeGenericBlocks,
25472
+ cwd: config2.cwd
23719
25473
  },
23720
- defaults.globs
25474
+ config2.globs
23721
25475
  );
23722
25476
  io.stdout(JSON.stringify(all.length === 1 ? all[0] : all, null, 2));
23723
25477
  return 0;
@@ -23728,7 +25482,7 @@ async function statsWithValidation(input, positionals) {
23728
25482
  positionals,
23729
25483
  cwd: input.cwd,
23730
25484
  registry: input.registry,
23731
- includeGenericBlocks: !input.noGenericBlocks,
25485
+ includeGenericBlocks: input.includeGenericBlocks,
23732
25486
  linkOptions: {}
23733
25487
  });
23734
25488
  return scan.files.map((file2) => {
@@ -23751,8 +25505,8 @@ var init_stats = __esm({
23751
25505
  "src/commands/stats.ts"() {
23752
25506
  "use strict";
23753
25507
  init_dist();
25508
+ init_command_config();
23754
25509
  init_content_project();
23755
- init_script_defaults();
23756
25510
  }
23757
25511
  });
23758
25512
 
@@ -23862,10 +25616,10 @@ var init_docs = __esm({
23862
25616
  import { readFile as readFile8 } from "node:fs/promises";
23863
25617
  async function collectLinkInputs(files) {
23864
25618
  const inputs = [];
23865
- for (const path2 of files) {
23866
- const source = await readFile8(path2, "utf8");
25619
+ for (const path4 of files) {
25620
+ const source = await readFile8(path4, "utf8");
23867
25621
  const fm = extractFrontmatter(source);
23868
- inputs.push({ path: path2, data: fm?.data ?? {} });
25622
+ inputs.push({ path: path4, data: fm?.data ?? {} });
23869
25623
  }
23870
25624
  return inputs;
23871
25625
  }
@@ -23882,18 +25636,12 @@ __export(links_exports, {
23882
25636
  linksCommand: () => linksCommand
23883
25637
  });
23884
25638
  import { mkdir as mkdir3, readFile as readFile9 } from "node:fs/promises";
23885
- import { dirname as dirname6, join as join9 } from "node:path";
25639
+ import { dirname as dirname6, join as join10 } from "node:path";
23886
25640
  async function linksCommand(input, io) {
23887
- const defaults = await discoverContentCommandDefaults("links", input.globs);
23888
- const files = await resolveContentFiles2(defaults.globs, "links", { cwd: defaults.cwd });
25641
+ const config2 = await resolveContentCommandConfig("links", input);
25642
+ const files = await resolveContentFiles2(config2.globs, "links", { cwd: config2.cwd });
23889
25643
  const inputs = await collectLinkInputs(files);
23890
- const linkOptions = linkResolverOptions({
23891
- linkResolve: input.linkResolve ?? defaults.linkResolve,
23892
- localeField: input.localeField ?? defaults.localeField,
23893
- slugField: input.slugField ?? defaults.slugField,
23894
- keyField: input.keyField ?? defaults.keyField,
23895
- defaultLocale: input.defaultLocale ?? defaults.defaultLocale
23896
- });
25644
+ const linkOptions = config2.resolveLinkOptions();
23897
25645
  let errors = 0;
23898
25646
  let warnings = 0;
23899
25647
  for (const { file: file2, diagnostic } of validateLinks(inputs, linkOptions)) {
@@ -23933,7 +25681,7 @@ async function linksCommand(input, io) {
23933
25681
  }
23934
25682
  }
23935
25683
  }
23936
- const outPath = input.out ?? join9(defaults.cwd ?? process.cwd(), ".contentbit", "link-index.json");
25684
+ const outPath = input.out ?? join10(config2.cwd ?? process.cwd(), ".contentbit", "link-index.json");
23937
25685
  await mkdir3(dirname6(outPath), { recursive: true });
23938
25686
  await io.writeFile(outPath, JSON.stringify(serializeLinkIndex(index), null, 2) + "\n");
23939
25687
  const graph = linkGraphSummary(index);
@@ -23961,11 +25709,10 @@ var init_links2 = __esm({
23961
25709
  "src/commands/links.ts"() {
23962
25710
  "use strict";
23963
25711
  init_dist();
25712
+ init_command_config();
23964
25713
  init_cli_format();
23965
25714
  init_content_project();
23966
- init_link_options();
23967
25715
  init_links_io();
23968
- init_script_defaults();
23969
25716
  }
23970
25717
  });
23971
25718
 
@@ -24149,6 +25896,26 @@ function createProgram(io, setExitCode) {
24149
25896
  )
24150
25897
  );
24151
25898
  });
25899
+ const snapshot = program2.command("snapshot").description("print a portable project snapshot as JSON").argument("[globs...]", "Content files or quoted globs; defaults to project config").option("--registry <module>", "Load custom block definitions from this module").option("--no-generic-blocks", "Do not include the built-in generic block pack").option("--seo-config <module>", "Load SEO contracts from this module").option("--no-seo", "Disable SEO config discovery and findings").option("--revision <id>", "Attach a Git revision or other source identifier");
25900
+ addLinkOptions(snapshot);
25901
+ snapshot.action(async (globs, rawOptions) => {
25902
+ const options = optionsFrom(rawOptions);
25903
+ const { snapshotCommand: snapshotCommand2 } = await Promise.resolve().then(() => (init_snapshot(), snapshot_exports));
25904
+ setExitCode(
25905
+ await snapshotCommand2(
25906
+ {
25907
+ globs,
25908
+ registry: options.registry,
25909
+ noGenericBlocks: options.genericBlocks === false,
25910
+ seoConfig: options.seoConfig,
25911
+ noSeo: options.seo === false ? true : void 0,
25912
+ revision: options.revision,
25913
+ ...linkOptionsFrom(options)
25914
+ },
25915
+ io
25916
+ )
25917
+ );
25918
+ });
24152
25919
  program2.command("stats").description("print document stats as JSON").argument("[globs...]", "Content files or quoted globs; defaults to project config").option("--registry <module>", "Load custom block definitions from this module").option("--no-generic-blocks", "Do not include the built-in generic block pack").option("--no-validate", "Analyze Markdown without loading or validating blocks").action(async (globs, rawOptions) => {
24153
25920
  const options = optionsFrom(rawOptions);
24154
25921
  const { statsCommand: statsCommand2 } = await Promise.resolve().then(() => (init_stats(), stats_exports));
@@ -24304,6 +26071,7 @@ Commands:
24304
26071
  brief print an agent-ready SEO brief
24305
26072
  doctor inspect content health and repair suggestions
24306
26073
  studio browse content locally
26074
+ snapshot print a portable project snapshot as JSON
24307
26075
  stats print document stats as JSON
24308
26076
  render render one file to plain Markdown
24309
26077
  instructions print LLM authoring instructions
@@ -24321,6 +26089,7 @@ Common:
24321
26089
  brief <key-or-slug> [globs...] [--registry <module.ts>] [--no-generic-blocks] [--seo-config <module.ts>] [--json]
24322
26090
  doctor [globs...] [--watch] [--registry <module.ts>] [--no-generic-blocks] [--strict-warnings] [--strict-seo] [--seo-config <module.ts>] [--no-seo] [--json] [--min-section-words <n>] [--link-resolve <mode>]
24323
26091
  studio [globs...] [--registry <module.ts>] [--port <n>] [--host <host>] [--no-open] [--no-generic-blocks] [--seo-config <module.ts>] [--no-seo] [--link-resolve <mode>]
26092
+ snapshot [globs...] [--registry <module.ts>] [--no-generic-blocks] [--seo-config <module.ts>] [--no-seo] [--revision <id>] [--link-resolve <mode>]
24324
26093
  stats <globs...> [--registry <module.ts>] [--no-generic-blocks] [--no-validate]
24325
26094
  render <file> [--target markdown] [--registry <module.ts>] [--no-generic-blocks] [--out <file>]
24326
26095
  instructions [--audience llm|human] [--no-examples] [--registry <module.ts>] [--no-generic-blocks] [--out <file>]
@@ -24335,6 +26104,6 @@ import { writeFile as writeFile3 } from "node:fs/promises";
24335
26104
  var code = await run(process.argv.slice(2), {
24336
26105
  stdout: (s) => console.log(s),
24337
26106
  stderr: (s) => console.error(s),
24338
- writeFile: (path2, content) => writeFile3(path2, content, "utf8")
26107
+ writeFile: (path4, content) => writeFile3(path4, content, "utf8")
24339
26108
  });
24340
26109
  process.exitCode = code;